2024-03-25 23:42:40 +01:00
|
|
|
{"version":3,"file":"modedit-modal.min.js","sources":["../src/modedit-modal.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint-disable no-trailing-spaces */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n\nimport {loadFragment} from 'core/fragment';\nimport {load_strings} 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 = load_strings({\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 console.info(\"Loading form\");\n loadFragment('local_treestudyplan', 'mod_edit_form', this.coursectxid, params).then((html,js) =>{\n replaceNodeContents(self.$refs[\"content\"], html, js);\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 }).catch(notification.exception);\n\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
|