mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
cd339ce7cb
Summary: Fixes misc. bugs with forms, updates Grist URLs on static form pages to link to the new forms marketing page, and adds a forms announcement popup that's shown next to the Add New button within a document. Test Plan: Browser tests. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D4185
109 lines
4.3 KiB
HTML
109 lines
4.3 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf8">
|
|
{{#if BASE}}
|
|
<base href="{{ BASE }}">
|
|
{{/if}}
|
|
<title>{{ TITLE }}</title>
|
|
<link rel="icon" type="image/x-icon" href="icons/favicon.png" />
|
|
<script src="forms/grist-form-submit.js"></script>
|
|
<script src="forms/purify.min.js"></script>
|
|
<script>
|
|
// Make all links open in a new tab.
|
|
DOMPurify.addHook('uponSanitizeAttribute', (node) => {
|
|
if (!('target' in node)) { return; }
|
|
node.setAttribute('target', '_blank');
|
|
// Make sure that this is set explicitly, as it's often set by the browser.
|
|
node.setAttribute('rel', 'noopener');
|
|
});
|
|
</script>
|
|
<link rel="stylesheet" href="forms/form.css">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
</head>
|
|
|
|
<body>
|
|
<main class='grist-form-container'>
|
|
<form class='grist-form'
|
|
onsubmit="event.target.parentElement.querySelector('.grist-form-confirm').style.display = 'flex', event.target.style.display = 'none'"
|
|
data-grist-doc="{{ DOC_URL }}"
|
|
data-grist-table="{{ TABLE_ID }}"
|
|
data-grist-success-url="{{ SUCCESS_URL }}"
|
|
>
|
|
{{ dompurify CONTENT }}
|
|
<div class='grist-form-footer'>
|
|
<div class="grist-power-by">
|
|
<a href="{{ FORMS_LANDING_PAGE_URL }}" target="_blank">
|
|
<div>Powered by</div>
|
|
<div class="grist-logo"></div>
|
|
</a>
|
|
</div>
|
|
<div class='grist-form-build-form-link-container'>
|
|
<a class='grist-form-build-form-link' href="{{ FORMS_LANDING_PAGE_URL }}" target="_blank">
|
|
Build your own form
|
|
<div class="grist-form-icon grist-form-icon-expand"></div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="grist-form-confirm-container">
|
|
<div class='grist-form-confirm' style='display: none'>
|
|
<div class="grist-form-confirm-body">
|
|
<img class='grist-form-confirm-image' src="forms/form-submitted.svg">
|
|
<div class='grist-form-confirm-text'>
|
|
{{ SUCCESS_TEXT }}
|
|
</div>
|
|
{{#if ANOTHER_RESPONSE }}
|
|
<div class='grist-form-confirm-buttons'>
|
|
<button
|
|
class='grist-form-confirm-new-response-button'
|
|
onclick='window.location.reload()'
|
|
>
|
|
Submit new response
|
|
</button>
|
|
</div>
|
|
{{/if}}
|
|
</div>
|
|
<div class='grist-form-confirm-footer'>
|
|
<div class="grist-power-by">
|
|
<a href="https://www.getgrist.com/forms/?utm_source=grist-forms&utm_medium=grist-forms&utm_campaign=forms-footer" target="_blank">
|
|
<div>Powered by</div>
|
|
<div class="grist-logo"></div>
|
|
</a>
|
|
</div>
|
|
<div class='grist-form-build-form-link-container'>
|
|
<a class='grist-form-build-form-link' href="https://www.getgrist.com/forms/?utm_source=grist-forms&utm_medium=grist-forms&utm_campaign=forms-footer" target="_blank">
|
|
Build your own form
|
|
<div class="grist-form-icon grist-form-icon-expand"></div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<script>
|
|
// Validate choice list on submit
|
|
document.querySelector('.grist-form input[type="submit"]').addEventListener('click', function(event) {
|
|
// When submit is pressed make sure that all choice lists that are required
|
|
// have at least one option selected
|
|
const choiceLists = document.querySelectorAll('.grist-checkbox-list.required:not(:has(input:checked))');
|
|
Array.from(choiceLists).forEach(function(choiceList) {
|
|
// If the form has at least one checkbox make it required
|
|
const firstCheckbox = choiceList.querySelector('input[type="checkbox"]');
|
|
firstCheckbox?.setAttribute('required', 'required');
|
|
});
|
|
|
|
// All other required choice lists with at least one option selected are no longer required
|
|
const choiceListsRequired = document.querySelectorAll('.grist-checkbox-list.required:has(input:checked)');
|
|
Array.from(choiceListsRequired).forEach(function(choiceList) {
|
|
// If the form has at least one checkbox make it required
|
|
const firstCheckbox = choiceList.querySelector('input[type="checkbox"]');
|
|
firstCheckbox?.removeAttribute('required');
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|