fix: modal save button + missing translations

- Replace form="id" cross-element approach with requestSubmit() for
  reliable save button wiring in modal footer
- Re-call _bindDirty after validation-error re-render so dirty guard
  is preserved across save attempts
- Translate missing Dutch strings: Order saved, Error saving order,
  Question details, View
This commit is contained in:
2026-07-06 22:41:34 +02:00
parent 4a87ac574d
commit 3b6ff680e5
4 changed files with 26 additions and 3 deletions
@@ -56,6 +56,12 @@ export default class extends Controller {
_bindForm(url) {
const form = this.modalBodyTarget.querySelector('form');
if (!form) return;
if (this.hasModalFooterTarget) {
const saveBtn = this.modalFooterTarget.querySelector('[type="submit"]');
saveBtn?.addEventListener('click', () => form.requestSubmit(), {once: true});
}
form.addEventListener('submit', async (e) => {
e.preventDefault();
const res = await fetch(url, {
@@ -69,6 +75,7 @@ export default class extends Controller {
} else {
this.modalBodyTarget.innerHTML = await res.text();
this._moveFooter();
this._bindDirty();
this._bindForm(url);
}
}, {once: true});
@@ -32,6 +32,6 @@
{% if isModal ?? false %}
<template data-modal-footer>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ 'Cancel'|trans }}</button>
<button type="submit" form="{{ form.vars.id }}" class="btn btn-primary">{{ 'Save'|trans }}</button>
<button type="submit" class="btn btn-primary">{{ 'Save'|trans }}</button>
</template>
{% endif %}
@@ -30,6 +30,6 @@
{% if isModal ?? false %}
<template data-modal-footer>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ 'Cancel'|trans }}</button>
<button type="submit" form="{{ form.vars.id }}" class="btn btn-primary">{{ 'Save'|trans }}</button>
<button type="submit" class="btn btn-primary">{{ 'Save'|trans }}</button>
</template>
{% endif %}
+17 -1
View File
@@ -257,6 +257,10 @@
<source>Error clearing quiz</source>
<target>Fout bij het leegmaken van de test</target>
</trans-unit>
<trans-unit id="NXU7HO." resname="Error saving order">
<source>Error saving order</source>
<target>Fout bij opslaan volgorde</target>
</trans-unit>
<trans-unit id="bgWPQMg" resname="Export to XLSX">
<source>Export to XLSX</source>
<target>Exporteren naar XLSX</target>
@@ -409,13 +413,17 @@
<source>Open</source>
<target>Openen</target>
</trans-unit>
<trans-unit id="vhCGOEN" resname="Order saved">
<source>Order saved</source>
<target>Volgorde opgeslagen</target>
</trans-unit>
<trans-unit id="HmgPmMV" resname="Overview">
<source>Overview</source>
<target>Overzicht</target>
</trans-unit>
<trans-unit id="PywqOf4" resname="Owner(s)">
<source>Owner(s)</source>
<target>Eigenaar(s)</target>
<target>Eigena(a)r(en)</target>
</trans-unit>
<trans-unit id="GqmFSHc" resname="Password">
<source>Password</source>
@@ -473,6 +481,10 @@
<source>Question bank</source>
<target>Vragenbank</target>
</trans-unit>
<trans-unit id="z7Pp9b9" resname="Question details">
<source>Question details</source>
<target>Vraagdetails</target>
</trans-unit>
<trans-unit id="htaUa1k" resname="Question removed from quiz %quiz%">
<source>Question removed from quiz %quiz%</source>
<target>Vraag verwijderd uit quiz %quiz%</target>
@@ -717,6 +729,10 @@
<source>Used in</source>
<target>Gebruikt in</target>
</trans-unit>
<trans-unit id=".EmYZIu" resname="View">
<source>View</source>
<target>Bekijken</target>
</trans-unit>
<trans-unit id="JWRtx_o" resname="White">
<source>White</source>
<target>Wit</target>