Merge branch 'MDL-70962-311' of git://github.com/paulholden/moodle into MOODLE_311_STABLE

This commit is contained in:
Andrew Nicols
2021-03-29 11:58:54 +08:00
6 changed files with 23 additions and 9 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5 -1
View File
@@ -456,7 +456,11 @@ define([
// This is a non-spec feature of jQuery and cannot be produced with spec promises.
// We can encourage people to migrate to this approach, and in future we can swap
// it so that setBody() calls setBodyPromise().
return promise.then(({html, js}) => this.setBody($.when(html, js)));
return promise.then(({html, js}) => this.setBody($.when(html, js)))
.catch(exception => {
this.hide();
throw exception;
});
};
/**
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+14 -4
View File
@@ -124,7 +124,9 @@ export default class ModalForm {
// we need to make sure that the modal already exists when we render the form. Some form elements
// such as date_selector inspect the existing elements on the page to find the highest z-index.
const formParams = new URLSearchParams(Object.entries(this.config.args || {}));
this.modal.setBodyContent(this.getBody(formParams.toString()));
const bodyContent = this.getBody(formParams.toString());
this.modal.setBodyContent(bodyContent);
bodyContent.catch(Notification.exception);
// After successfull submit, when we press "Cancel" or close the dialogue by clicking on X in the top right corner.
this.modal.getRoot().on(ModalEvents.hidden, () => {
@@ -270,8 +272,12 @@ export default class ModalForm {
notifyResetFormChanges() {
return new Promise(resolve => {
Y.use('event', 'moodle-core-event', 'moodle-core-formchangechecker', () => {
Event.notifyFormSubmitAjax(this.modal.getRoot().find('form')[0], true);
M.core_formchangechecker.reset_form_dirty_state();
// Ensure that modal contains a form element (it may not if the form class threw an early exception).
const form = this.modal.getRoot().find('form')[0];
if (form) {
Event.notifyFormSubmitAjax(form, true);
M.core_formchangechecker.reset_form_dirty_state();
}
resolve();
});
});
@@ -307,7 +313,11 @@ export default class ModalForm {
let formData = this.modal.getRoot().find('form').serialize();
formData = formData + '&' + encodeURIComponent(button.getAttribute('name')) + '=' +
encodeURIComponent(button.getAttribute('value'));
this.modal.setBodyContent(this.getBody(formData));
const bodyContent = this.getBody(formData);
this.modal.setBodyContent(bodyContent);
bodyContent.catch(Notification.exception);
return null;
})
.catch(null);