mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +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
|
* @public
|
||||||
*/
|
*/
|
||||||
load(args = null) {
|
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');
|
const pendingPromise = new Pending('core_form/dynamicform:load');
|
||||||
return this.getBody(formData.toString())
|
return this.getBody(formData)
|
||||||
.then((resp) => this.updateForm(resp))
|
.then((resp) => this.updateForm(resp))
|
||||||
.then(pendingPromise.resolve);
|
.then(pendingPromise.resolve);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,13 @@ export default class ModalForm {
|
||||||
*/
|
*/
|
||||||
show() {
|
show() {
|
||||||
const pendingPromise = new Pending('core_form/modalform:init');
|
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)
|
return ModalFactory.create(this.config.modalConfig)
|
||||||
.then((modal) => {
|
.then((modal) => {
|
||||||
this.modal = 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,
|
// 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
|
// 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.
|
// 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 formParams = serialize(this.config.args || {});
|
||||||
const bodyContent = this.getBody(formParams.toString());
|
const bodyContent = this.getBody(formParams);
|
||||||
this.modal.setBodyContent(bodyContent);
|
this.modal.setBodyContent(bodyContent);
|
||||||
bodyContent.catch(Notification.exception);
|
bodyContent.catch(Notification.exception);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue