moodle_local_treestudyplan/amd/build/util/mform-helper.min.js.map

1 line
11 KiB
Plaintext
Raw Normal View History

{"version":3,"file":"mform-helper.min.js","sources":["../../src/util/mform-helper.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint no-bitwise: \"off\"*/\n/*eslint-disable no-trailing-spaces*/\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n\nimport {call} from 'core/ajax';\nimport {processCollectedJavascript} from 'core/fragment';\nimport {replaceNodeContents} from 'core/templates';\nimport notification from 'core/notification';\nimport {load_strings} from './string-helper';\nimport Debugger from './debugger';\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\n/**\n * Create a random UUID in both secure and insecure contexts\n * @returns UUID\n */\nfunction create_uuid() {\n if (crypto.randomUUID !== undefined ) {\n return crypto.randomUUID();\n } else {\n return \"10000000-1000-4000-8000-100000000000\".replace(/[018]/g, c =>\n (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)\n );\n }\n}\n\nexport default {\n install(Vue/*,options*/){\n let debug = new Debugger(\"treestudyplan-mform-helper\");\n let strings = load_strings({\n editmod: {\n save$core: \"save$core\",\n cancel$core: \"cancel$core\",\n }\n });\n\n Vue.component('mform', {\n props: {\n name: {\n type: String,\n },\n params: {\n type: Object,\n },\n title: {\n type: String,\n default: \"\",\n },\n variant: {\n type: String,\n default: \"primary\",\n },\n type: {\n type: String,\n default: \"link\",\n }\n },\n data() {\n return {\n content: \"\",\n loading: true,\n uuid: create_uuid(),\n text: strings,\n submitok: false,\n observer: null,\n inputs: [],\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 debug.info(`Loading form \"${self.name}\" with params`,self.params);\n self.loading = false;\n call([{\n methodname: 'local_treestudyplan_get_mform',\n args: {formname: self.name, params: JSON.stringify(self.params)}\n }])[0].then((data)=>{\n const html = data.html;\n self.loading = false;\n // Process the collected javascript;\n const js = processCollectedJavascript(data.javascript);\n replaceNodeContents(self.$refs[\"content\"], html, js);\n self.initListenChanges();\n }).catch(notification.exception);\n\n },\n onSave() {\n const self = this;\n let form = this.$refs[\"content\"].getElementsByTagName(\"form\")[0