1 line
5.9 KiB
Plaintext
1 line
5.9 KiB
Plaintext
{"version":3,"file":"modedit-modal.min.js","sources":["../src/modedit-modal.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint capitalized-comments: \"off\" */\n/* eslint-env es6 */\n\nimport {loadFragment} from 'core/fragment';\nimport {loadStrings} from './util/string-helper';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\nimport {replaceNodeContents} from 'core/templates';\n// import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only\n// import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only\n\n/* Moodle 3.11 safe import for when needed\nlet markFormSubmitted = () => {};\nlet notifyFormSubmittedByJavascript = () => {};\n\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if(ns.markFormSubmitted) {\n markFormSubmitted = ns.markFormSubmitted;\n }\n if(ns.notifyFormSubmittedByJavascript) {\n notifyFormSubmittedByJavascript = ns.notifyFormSubmittedByJavascript;\n }\n}).catch(()=>{});\n*/\n\nexport default {\n install(Vue/* ,options */) {\n\n let strings = loadStrings({\n editmod: {\n save$core: \"save$core\",\n cancel$core: \"cancel$core\",\n }\n });\n\n Vue.component('s-edit-mod', {\n props: {\n cmid: {\n type: Number,\n },\n coursectxid: {\n type: Number,\n },\n title: {\n type: String,\n 'default': \"\",\n },\n genericonly: {\n type: Boolean,\n 'default': false,\n }\n },\n data() {\n return {\n content: \"\",\n text: strings.editmod,\n };\n },\n computed: {\n },\n methods: {\n openForm() {\n const self = this;\n self.$refs.editormodal.show();\n },\n onShown() {\n const self = this;\n let params = {cmid: this.cmid};\n loadFragment('local_treestudyplan', 'mod_edit_form', this.coursectxid, params).then((html, js) => {\n replaceNodeContents(self.$refs.content, html, js);\n return null;\n }).catch(notification.exception);\n\n },\n onSave() {\n const self = this;\n let form = this.$refs.content.getElementsByTagName(\"form\")[0];\n\n // markFormSubmitted(form); // Moodle 4.00+ only\n // We call this, so other modules can update the form with the latest state.\n form.dispatchEvent(new Event(\"save-form-state\"));\n // Tell all form fields we are about to submit the form.\n // notifyFormSubmittedByJavascript(form); // Moodle 4.00+ only\n\n const formdata = new FormData(form);\n const data = new URLSearchParams(formdata).toString();\n // const formdata = new FormData(form);\n // const data = {};\n // formdata.forEach((value, key) => (data[key] = value));\n\n call([{\n methodname: 'local_treestudyplan_submit_cm_editform',\n args: {cmid: this.cmid, formdata: data}\n }])[0].then(() => {\n self.$emit(\"saved\", formdata);\n return null;\n }).catch(notification.exception);\n }\n },\n template: `\n <span class='s-edit-mod'><a href='#' @click.prevent=\"openForm\"><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-cm-'+cmid\"\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 class=\"d-flex justify-content-center mb-3\"><b-spinner variant=\"primary\"></b-spinner></div\n ></div\n ></b-modal>\n </span>\n `,\n });\n }\n};\n\n"],"names":["install","Vue","strings","editmod","save$core","cancel$core","component","props","cmid","type","Number","coursectxid","title","String","genericonly","Boolean","data","content","text","computed","methods","openForm","this","$refs","editormodal","show","onShown","self","params","then","html","js","catch","notification","exception","onSave","form","getElementsByTagName","dispatchEvent","Event","formdata","FormData","URLSearchParams","toString","methodname","args","$emit","template"],"mappings":"mYA2Be,CACXA,QAAQC,SAEAC,SAAU,6BAAY,CACtBC,QAAS,CACLC,UAAW,YACXC,YAAa,iBAIrBJ,IAAIK,UAAU,aAAc,CACxBC,MAAO,CACHC,KAAM,CACFC,KAAMC,QAEVC,YAAa,CACTF,KAAMC,QAEVE,MAAO,CACHH,KAAMI,eACK,IAEfC,YAAa,CACTL,KAAMM,iBACK,IAGnBC,KAAI,KACO,CACHC,QAAS,GACTC,KAAMhB,QAAQC,UAGtBgB,SAAU,GAEVC,QAAS,CACLC,WACiBC,KACRC,MAAMC,YAAYC,QAE3BC,gBACUC,KAAOL,SACTM,OAAS,CAACpB,KAAMc,KAAKd,iCACZ,sBAAuB,gBAAiBc,KAAKX,YAAaiB,QAAQC,MAAK,CAACC,KAAMC,yCACnEJ,KAAKJ,MAAMN,QAASa,KAAMC,IACvC,QACRC,MAAMC,sBAAaC,YAG1BC,eACUR,KAAOL,SACTc,KAAOd,KAAKC,MAAMN,QAAQoB,qBAAqB,QAAQ,GAI3DD,KAAKE,cAAc,IAAIC,MAAM,0BAIvBC,SAAW,IAAIC,SAASL,MACxBpB,KAAO,IAAI0B,gBAAgBF,UAAUG,0BAKtC,CAAC,CACFC,WAAY,yCACZC,KAAM,CAACrC,KAAMc,KAAKd,KAAMgC,SAAUxB,SAClC,GAAGa,MAAK,KACRF,KAAKmB,MAAM,QAASN,UACb,QACRR,MAAMC,sBAAaC,aAG9Ba,SAAW"} |