Minor fix in mfom helper javascript
This commit is contained in:
parent
49fa4b2ed3
commit
d4e4a8fca9
2
amd/build/util/mform-helper.min.js
vendored
2
amd/build/util/mform-helper.min.js
vendored
|
@ -1,3 +1,3 @@
|
|||
define("local_treestudyplan/util/mform-helper",["exports","core/ajax","core/fragment","core/notification","./string-helper","./debugger"],(function(_exports,_ajax,_fragment,_notification,_stringHelper,_debugger){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_notification=_interopRequireDefault(_notification),_debugger=_interopRequireDefault(_debugger);var _default={install:function(Vue){var debug=new _debugger.default("treestudyplan-mform-helper"),strings=(0,_stringHelper.load_strings)({editmod:{save$core:"save$core",cancel$core:"cancel$core"}});Vue.component("mform",{props:{name:{type:String},params:{type:Object}},data:function(){return{content:"",loading:!0,uuid:void 0!==crypto.randomUUID?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(c){return(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16)})),text:strings}},computed:{},methods:{openForm:function(){this.$refs.editormodal.show()},onShown:function(){var self=this;debug.info('Loading form "'.concat(self.name,'" with params'),self.params),self.loading=!1,(0,_ajax.call)([{methodname:"local_treestudyplan_get_mform",args:{name:self.name,params:self.params}}])[0].then((function(data){self.content=data.html,self.loading=!1,(0,_fragment.processCollectedJavascript)(data.js)})).catch(_notification.default.exception)},onSave:function(){var self=this,form=this.$refs.content.getElementsByTagName("form")[0];form.dispatchEvent(new Event("save-form-state"));var formdata=new FormData(form),data=new URLSearchParams(formdata).toString();(0,_ajax.call)([{methodname:"local_treestudyplan_submit_mform",args:{name:self.name,params:self.params,data:data}}])[0].then((function(){self.$emit("saved",formdata)})).catch(_notification.default.exception)}},template:'\n <span class=\'s-edit-mod\'><a href=\'#\' @click.prevent="open"><slot><i class="fa fa-cog"></i></slot></a>\n <b-modal\n ref="editormodal"\n scrollable\n centered\n size="xl"\n id="\'modal-\'+uuid"\n @shown="onShown"\n @ok="onSave"\n :title="title"\n :ok-title="text.save$core"\n ><div :class="\'s-edit-mod-form \'+ (genericonly?\'genericonly\':\'\')" ref="content"\n ><div v-if="loading" class="d-flex justify-content-center mb-3"\n ><b-spinner variant="primary"></b-spinner\n ></div\n ><span v-else v-html="content"\n ></div\n ></b-modal>\n </span>\n '})}};return _exports.default=_default,_exports.default}));
|
||||
define("local_treestudyplan/util/mform-helper",["exports","core/ajax","core/fragment","core/notification","./string-helper","./debugger"],(function(_exports,_ajax,_fragment,_notification,_stringHelper,_debugger){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_notification=_interopRequireDefault(_notification),_debugger=_interopRequireDefault(_debugger);var _default={install:function(Vue){var debug=new _debugger.default("treestudyplan-mform-helper"),strings=(0,_stringHelper.load_strings)({editmod:{save$core:"save$core",cancel$core:"cancel$core"}});Vue.component("mform",{props:{name:{type:String},params:{type:Object}},data:function(){return{content:"",loading:!0,uuid:void 0!==crypto.randomUUID?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(c){return(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16)})),text:strings}},computed:{},methods:{openForm:function(){this.$refs.editormodal.show()},onShown:function(){var self=this;debug.info('Loading form "'.concat(self.name,'" with params'),self.params),self.loading=!1,(0,_ajax.call)([{methodname:"local_treestudyplan_get_mform",args:{name:self.name,params:JSON.stringify(self.params)}}])[0].then((function(data){self.content=data.html,self.loading=!1,(0,_fragment.processCollectedJavascript)(data.js)})).catch(_notification.default.exception)},onSave:function(){var self=this,form=this.$refs.content.getElementsByTagName("form")[0];form.dispatchEvent(new Event("save-form-state"));var formdata=new FormData(form),data=new URLSearchParams(formdata).toString();(0,_ajax.call)([{methodname:"local_treestudyplan_submit_mform",args:{name:self.name,params:JSON.stringify(self.params),data:data}}])[0].then((function(){self.$emit("saved",formdata)})).catch(_notification.default.exception)}},template:'\n <span class=\'s-edit-mod\'><a href=\'#\' @click.prevent="open"><slot><i class="fa fa-cog"></i></slot></a>\n <b-modal\n ref="editormodal"\n scrollable\n centered\n size="xl"\n id="\'modal-\'+uuid"\n @shown="onShown"\n @ok="onSave"\n :title="title"\n :ok-title="text.save$core"\n ><div :class="\'s-edit-mod-form \'+ (genericonly?\'genericonly\':\'\')" ref="content"\n ><div v-if="loading" class="d-flex justify-content-center mb-3"\n ><b-spinner variant="primary"></b-spinner\n ></div\n ><span v-else v-html="content"\n ></div\n ></b-modal>\n </span>\n '})}};return _exports.default=_default,_exports.default}));
|
||||
|
||||
//# sourceMappingURL=mform-helper.min.js.map
|
File diff suppressed because one or more lines are too long
|
@ -68,7 +68,7 @@ export default {
|
|||
self.loading = false;
|
||||
call([{
|
||||
methodname: 'local_treestudyplan_get_mform',
|
||||
args: {name: self.name, params: self.params}
|
||||
args: {name: self.name, params: JSON.stringify(self.params)}
|
||||
}])[0].then((data)=>{
|
||||
self.content = data.html;
|
||||
self.loading = false;
|
||||
|
@ -76,10 +76,6 @@ export default {
|
|||
processCollectedJavascript(data.js);
|
||||
}).catch(notification.exception);
|
||||
|
||||
//loadFragment('local_treestudyplan', 'mod_edit_form', this.coursectxid, params).then((html,js) =>{
|
||||
// replaceNodeContents(self.$refs["content"], html, js);
|
||||
//}).catch(notification.exception);
|
||||
|
||||
},
|
||||
onSave(){
|
||||
const self = this;
|
||||
|
@ -92,14 +88,11 @@ export default {
|
|||
// notifyFormSubmittedByJavascript(form); // Moodle 4.00+ only
|
||||
|
||||
const formdata = new FormData(form);
|
||||
const data =new URLSearchParams(formdata).toString();
|
||||
//const formdata = new FormData(form);
|
||||
//const data = {};
|
||||
//formdata.forEach((value, key) => (data[key] = value));
|
||||
const data = new URLSearchParams(formdata).toString();
|
||||
|
||||
call([{
|
||||
methodname: 'local_treestudyplan_submit_mform',
|
||||
args: {name: self.name, params: self.params, data: data}
|
||||
args: {name: self.name, params: JSON.stringify(self.params), data: data}
|
||||
}])[0].then(()=>{
|
||||
self.$emit("saved",formdata);
|
||||
}).catch(notification.exception);
|
||||
|
|
Loading…
Reference in New Issue
Block a user