diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-12-04 15:24:25 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-12-04 15:24:25 +0000 |
| commit | fac89b11bc20d86ec435c1b450ccc50219002ecf (patch) | |
| tree | 6d779253179cd5813aa5ab315d4a0d106fbbfe4c /resources/assets/javascripts/bootstrap/forms.js | |
| parent | d448125b9902919c070ce7aecbfdfe1b47feb3b5 (diff) | |
update vue2 -> vue3, fixes #3747
Closes #3747
Merge request studip/studip!3108
Diffstat (limited to 'resources/assets/javascripts/bootstrap/forms.js')
| -rw-r--r-- | resources/assets/javascripts/bootstrap/forms.js | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/resources/assets/javascripts/bootstrap/forms.js b/resources/assets/javascripts/bootstrap/forms.js index e159699..bd863eb 100644 --- a/resources/assets/javascripts/bootstrap/forms.js +++ b/resources/assets/javascripts/bootstrap/forms.js @@ -1,5 +1,6 @@ -import { $gettext, $gettextInterpolate } from '../lib/gettext'; +import { $gettext } from '../lib/gettext'; import Report from '../lib/report.ts'; +import Dialog from "../lib/dialog"; // Allow fieldsets to collapse $(document).on( @@ -242,12 +243,13 @@ function createSelect2(element) { } STUDIP.ready(function () { - let forms = window.document.querySelectorAll('form.default.studipform:not(.vueified)'); + let forms = window.document.querySelectorAll('.studipform:not(.vueified)'); if (forms.length > 0) { STUDIP.Vue.load().then(({createApp}) => { forms.forEach(f => { - createApp({ - el: f, + f.classList.add('vueified'); + + const app = createApp({ data() { let params = JSON.parse(f.dataset.inputs); params.STUDIPFORM_REQUIRED = f.dataset.required ? JSON.parse(f.dataset.required) : []; @@ -343,9 +345,9 @@ STUDIP.ready(function () { note.description = $(this).data('validation_requirement'); } if (this.validity.tooShort) { - note.description = $gettextInterpolate( - $gettext('Geben Sie mindestens %{min} Zeichen ein.'), - {min: this.minLength} + note.description = $gettext( + 'Geben Sie mindestens %{min} Zeichen ein.', + { min: this.minLength } ); } if (this.validity.valueMissing) { @@ -353,9 +355,9 @@ STUDIP.ready(function () { note.description = $gettext('Dieses Feld muss ausgewählt sein.'); } else { if (this.minLength > 0) { - note.description = $gettextInterpolate( - $gettext('Hier muss ein Wert mit mindestens %{min} Zeichen eingetragen werden.'), - {min: this.minLength} + note.description = $gettext( + 'Hier muss ein Wert mit mindestens %{min} Zeichen eingetragen werden.', + { min: this.minLength } ); } else { note.description = $gettext('Hier muss ein Wert eingetragen werden.'); @@ -419,10 +421,19 @@ STUDIP.ready(function () { return orderedNotes; } }, - mounted () { - $(this.$el).addClass("vueified"); + mounted() { + if (this.$el.closest('.ui-dialog')) { + const cancelButton = this.$el.querySelector('footer .button.cancel:last-of-type'); + if (cancelButton) { + cancelButton.addEventListener('click', (e) => { + Dialog.close(); + e.preventDefault(); + }) + } + } } }); + app.mount(f); }); }); } @@ -435,12 +446,8 @@ STUDIP.ready(function () { if (simple_vue_items.length > 0) { STUDIP.Vue.load().then(({createApp}) => { simple_vue_items.forEach(f => { - createApp({ - el: f, - mounted() { - this.$el.classList.add('vueified'); - } - }); + f.classList.add('vueified'); + createApp().mount(f); }); }); } |
