mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-71686-master' of https://github.com/marinaglancy/moodle
This commit is contained in:
commit
2423c26749
6 changed files with 21 additions and 8 deletions
2
lib/form/amd/build/dynamicform.min.js
vendored
2
lib/form/amd/build/dynamicform.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
lib/form/amd/build/modalform.min.js
vendored
2
lib/form/amd/build/modalform.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -136,9 +136,15 @@ export default class DynamicForm {
|
|||
* @public
|
||||
*/
|
||||
load(args = null) {
|
||||
const formData = new URLSearchParams(Object.entries(args || {}));
|
||||
const serialize = function(obj, prefix = '') {
|
||||
return [].concat(...Object.entries(obj).map(([idx, v]) => {
|
||||
const k = prefix ? prefix + "[" + idx + "]" : idx;
|
||||
return (typeof v === "object") ? serialize(v, k) : `${k}=${encodeURIComponent(v)}`;
|
||||
})).join("&");
|
||||
};
|
||||
const formData = serialize(args || {});
|
||||
const pendingPromise = new Pending('core_form/dynamicform:load');
|
||||
return this.getBody(formData.toString())
|
||||
return this.getBody(formData)
|
||||
.then((resp) => this.updateForm(resp))
|
||||
.then(pendingPromise.resolve);
|
||||
}
|
||||
|
|
|
@ -115,6 +115,13 @@ export default class ModalForm {
|
|||
*/
|
||||
show() {
|
||||
const pendingPromise = new Pending('core_form/modalform:init');
|
||||
const serialize = function(obj, prefix = '') {
|
||||
return [].concat(...Object.entries(obj).map(([idx, v]) => {
|
||||
const k = prefix ? prefix + "[" + idx + "]" : idx;
|
||||
return (typeof v === "object") ? serialize(v, k) : `${k}=${encodeURIComponent(v)}`;
|
||||
})).join("&");
|
||||
};
|
||||
|
||||
return ModalFactory.create(this.config.modalConfig)
|
||||
.then((modal) => {
|
||||
this.modal = modal;
|
||||
|
@ -122,8 +129,8 @@ export default class ModalForm {
|
|||
// Retrieve the form and set the modal body. We can not set the body in the modalConfig,
|
||||
// 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 || {}));
|
||||
const bodyContent = this.getBody(formParams.toString());
|
||||
const formParams = serialize(this.config.args || {});
|
||||
const bodyContent = this.getBody(formParams);
|
||||
this.modal.setBodyContent(bodyContent);
|
||||
bodyContent.catch(Notification.exception);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue