ESLint Code cleanup

This commit is contained in:
PMKuipers 2024-06-03 23:24:16 +02:00
parent e999fdb125
commit 5c1f21cee0
133 changed files with 1170 additions and 13281 deletions

View File

@ -1,3 +1,4 @@
/* eslint no-console: "off" */
// This file is part of Moodle - http://moodle.org/ // This file is part of Moodle - http://moodle.org/
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
@ -22,7 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
/** /**
* Grunt configuration. * Grunt configuration.
* *
@ -34,48 +34,48 @@ module.exports = function(grunt) {
const sass = require('sass'); const sass = require('sass');
// Import grunt configuration for moodle base // Import grunt configuration for moodle base
process.chdir("../.."); // change dir to moodle base process.chdir("../.."); // Change dir to moodle base
require(path.resolve(`./Gruntfile.js`))(grunt); // Run Gruntfile module from moodle base require(path.resolve(`./Gruntfile.js`))(grunt); // Run Gruntfile module from moodle base
grunt.registerTask('scssplugin','Compile scss/styles.sccs into styles.css and css/devstyles.css', () => { grunt.registerTask('scssplugin', 'Compile scss/styles.sccs into styles.css and css/devstyles.css', () => {
const devoutput = 'css/devstyles.css'; const devoutput = 'css/devstyles.css';
const prodoutput = 'styles.css'; const prodoutput = 'styles.css';
// Get full path of compenent and scss folder // Get full path of compenent and scss folder
const componentPath = path.join(grunt.moodleEnv.gruntFilePath,grunt.moodleEnv.componentDirectory); const componentPath = path.join(grunt.moodleEnv.gruntFilePath, grunt.moodleEnv.componentDirectory);
const scssPath = path.join(componentPath, 'scss','styles.scss'); const scssPath = path.join(componentPath, 'scss', 'styles.scss');
console.log(`Compiling ${scssPath} including any imported files therein`); console.log(`Compiling ${scssPath} including any imported files therein`);
process.chdir(path.join(componentPath, 'scss')); process.chdir(path.join(componentPath, 'scss'));
const result = sass.compile(scssPath); const result = sass.compile(scssPath);
if ( result ) { if (result) {
console.info("got result"); console.info("got result");
// Some regex processing to match moodle stylelint styles // Some regex processing to match moodle stylelint styles
// change tab indent to 4 instead of 2 // Change tab indent to 4 instead of 2
let css = result.css.replace(/^ ([^ ])/gm ," $1"); let css = result.css.replace(/^ {2}([^ ])/gm, " $1");
// insert a newline after every comma in a css selector // Insert a newline after every comma in a css selector
// (only combined selectors will get that long) // (only combined selectors will get that long)
css = css.replace(/^[^ ].*[\{,]$/gm , (m) => { // Find CSS selector lines css = css.replace(/^[^ ].*[{,]$/gm, (m) => { // Find CSS selector lines
return m.replace(/, /g,",\n"); // replace comma followed by space with comma newline return m.replace(/, /g, ",\n"); // Replace comma followed by space with comma newline
}); });
// replace hex color codes with lowercase (convenience function since I don't really care for the hex codes lowercase only rule) // Replace hex color codes with lowercase.
const hexCodeToLower = (match, m1, m2) => { const hexCodeToLower = (match, m1, m2) => {
return '#'+m1.toLowerCase()+m2; return '#' + m1.toLowerCase() + m2;
} };
css = css.replace(/#([A-F0-9a-f]{3})([^A-F0-9a-f]?)/gm , hexCodeToLower); // 3 digit color codes css = css.replace(/#([A-F0-9a-f]{3})([^A-F0-9a-f]?)/gm, hexCodeToLower); // 3 digit color codes
css = css.replace(/#([A-F0-9a-f]{6})([^A-F0-9a-f]?)/gm , hexCodeToLower); // 6 digit color codes css = css.replace(/#([A-F0-9a-f]{6})([^A-F0-9a-f]?)/gm, hexCodeToLower); // 6 digit color codes
css = css.replace(/#([A-F0-9a-f]{8})([^A-F0-9a-f]?)/gm , hexCodeToLower); // 8 digit color codes (with alpha) css = css.replace(/#([A-F0-9a-f]{8})([^A-F0-9a-f]?)/gm, hexCodeToLower); // 8 digit color codes (with alpha)
// All other errors should really be fixed in the scss files :) // All other errors should really be fixed in the scss files :)
[devoutput,prodoutput].forEach((output) => { [devoutput, prodoutput].forEach((output) => {
console.info(`Storing ${output}`); console.info(`Storing ${output}`);
grunt.file.write(path.join(componentPath, output),css); grunt.file.write(path.join(componentPath, output), css);
}); });
} }
@ -92,7 +92,7 @@ module.exports = function(grunt) {
}); });
// Remove gherkinlint from the startup list, since it exits with an error because of errors in moodle's own code // Remove gherkinlint from the startup list, since it exits with an error because of errors in moodle's own code
grunt.moodleEnv.startupTasks.splice(grunt.moodleEnv.startupTasks.indexOf("gherkinlint"),1); grunt.moodleEnv.startupTasks.splice(grunt.moodleEnv.startupTasks.indexOf("gherkinlint"), 1);
// Add the 'scssplugin' task as a startup task. // Add the 'scssplugin' task as a startup task.
grunt.moodleEnv.startupTasks.push('scssplugin'); grunt.moodleEnv.startupTasks.push('scssplugin');

View File

@ -1,13 +1,13 @@
# Moodle studyplan plugin # Moodle studyplan plugin
Plugin to organize a curriculum into an easy to read graphical respresentation of courses and student progress therein. Plugin to organize a curriculum into an easy to read graphical representation of courses and student progress therein.
The studyplan plugin extends Moodle with the ability to show students and teachers an overview of their curriculum and results therein. The studyplan plugin extends Moodle with the ability to show students and teachers an overview of their curriculum and results therein.
By showing students an easy to read graphical overview of their progress over multiple courses, students are more in control of their own By showing students an easy to read graphical overview of their progress over multiple courses, students are more in control of their own
learning process than by just listing results alone learning process than by just listing results alone
## Installing ## Installing
Install the plugin by adding the zip file manually to the installed plugins in your moodle version Install the plugin by adding the zip file manually to the installed plugins in your Moodle version
## Configuration post install ## Configuration post install

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/cfg-grades",["exports","core/str","core/ajax","./debugger","./string-helper"],(function(_exports,_str,_ajax,_debugger,_stringHelper){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){{const intRx=/\d/,integerChange=event=>{event.key.length>1||intRx.test(event.key)||event.preventDefault()};for(let input of document.querySelectorAll('input[type="number"][step="1"][min="0"]'))input.addEventListener("keydown",integerChange)}{const decimal=/^[0-9]*?\.[0-9]*?$/,intRx=/\d/,floatChange=event=>{event.key.length>1||"."===event.key&&!event.currentTarget.value.match(decimal)||intRx.test(event.key)||event.preventDefault()};for(let input of document.querySelectorAll('input[type="number"][min="0"]:not([step])'))input.addEventListener("keydown",floatChange);for(let input of document.querySelectorAll('input[type="text"].float'))input.addEventListener("keydown",floatChange)}};new(_debugger=(obj=_debugger)&&obj.__esModule?obj:{default:obj}).default("treestudyplan-config-grades")})); define("local_treestudyplan/cfg-grades",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){{const intRx=/\d/,integerChange=event=>{event.key.length>1||intRx.test(event.key)||event.preventDefault()};for(let input of document.querySelectorAll('input[type="number"][step="1"][min="0"]'))input.addEventListener("keydown",integerChange)}{const decimal=/^[0-9]*?\.[0-9]*?$/,intRx=/\d/,floatChange=event=>{event.key.length>1||"."===event.key&&!event.currentTarget.value.match(decimal)||intRx.test(event.key)||event.preventDefault()};for(let input of document.querySelectorAll('input[type="number"][min="0"]:not([step])'))input.addEventListener("keydown",floatChange);for(let input of document.querySelectorAll('input[type="text"].float'))input.addEventListener("keydown",floatChange)}}}));
//# sourceMappingURL=cfg-grades.min.js.map //# sourceMappingURL=cfg-grades.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"cfg-grades.min.js","sources":["../src/cfg-grades.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint no-trailing-spaces: \"off\" */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {get_string,get_strings} from 'core/str';\nimport {call} from 'core/ajax';\nimport Debugger from './debugger';\n\nimport {load_strings} from './string-helper';\n\nlet debug = new Debugger(\"treestudyplan-config-grades\");\n\n/*\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n },\n});\n*/\n\n/**\n * Initialize grade cfg page\n */\nexport function init() {\n { const\n intRx = /\\d/,\n integerChange = (event) => {\n if ( (event.key.length > 1) || intRx.test(event.key)\n ) {\n return;\n }\n event.preventDefault();\n };\n\n for (let input of document.querySelectorAll( 'input[type=\"number\"][step=\"1\"][min=\"0\"]' )){\n input.addEventListener(\"keydown\", integerChange);\n }\n\n }\n\n { const\n decimal= /^[0-9]*?\\.[0-9]*?$/,\n intRx = /\\d/,\n floatChange = (event) => {\n if ( (event.key.length > 1) || ( (event.key === \".\") && (!event.currentTarget.value.match(decimal)) )\n || intRx.test(event.key)\n ) {\n return;\n }\n event.preventDefault();\n };\n\n for (let input of document.querySelectorAll( 'input[type=\"number\"][min=\"0\"]:not([step])' )){\n input.addEventListener(\"keydown\", floatChange);\n }\n for (let input of document.querySelectorAll( 'input[type=\"text\"].float' )){\n input.addEventListener(\"keydown\", floatChange);\n }\n\n }\n\n\n}\n\n"],"names":["intRx","integerChange","event","key","length","test","preventDefault","input","document","querySelectorAll","addEventListener","decimal","floatChange","currentTarget","value","match"],"mappings":"iQA6BQA,MAAQ,KACRC,cAAiBC,QACTA,MAAMC,IAAIC,OAAS,GAAMJ,MAAMK,KAAKH,MAAMC,MAIhDD,MAAMI,sBAGL,IAAIC,SAASC,SAASC,iBAAkB,2CAC3CF,MAAMG,iBAAiB,UAAWT,sBAMlCU,QAAS,qBACTX,MAAQ,KACRY,YAAeV,QACPA,MAAMC,IAAIC,OAAS,GAAuB,MAAdF,MAAMC,MAAkBD,MAAMW,cAAcC,MAAMC,MAAMJ,UACjFX,MAAMK,KAAKH,MAAMC,MAI1BD,MAAMI,sBAGL,IAAIC,SAASC,SAASC,iBAAkB,6CAC3CF,MAAMG,iBAAiB,UAAWE,iBAE/B,IAAIL,SAASC,SAASC,iBAAkB,4BAC3CF,MAAMG,iBAAiB,UAAWE,eA9C9B,yEAAa"} {"version":3,"file":"cfg-grades.min.js","sources":["../src/cfg-grades.js"],"sourcesContent":["/* eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\n/**\n * Initialize grade cfg page\n */\nexport function init() {\n { const\n intRx = /\\d/,\n integerChange = (event) => {\n if ((event.key.length > 1) || intRx.test(event.key)\n ) {\n return;\n }\n event.preventDefault();\n };\n\n for (let input of document.querySelectorAll('input[type=\"number\"][step=\"1\"][min=\"0\"]')) {\n input.addEventListener(\"keydown\", integerChange);\n }\n\n }\n\n { const\n decimal = /^[0-9]*?\\.[0-9]*?$/,\n intRx = /\\d/,\n floatChange = (event) => {\n if ((event.key.length > 1) || ((event.key === \".\") && (!event.currentTarget.value.match(decimal)))\n || intRx.test(event.key)\n ) {\n return;\n }\n event.preventDefault();\n };\n\n for (let input of document.querySelectorAll('input[type=\"number\"][min=\"0\"]:not([step])')) {\n input.addEventListener(\"keydown\", floatChange);\n }\n for (let input of document.querySelectorAll('input[type=\"text\"].float')) {\n input.addEventListener(\"keydown\", floatChange);\n }\n\n }\n\n\n}\n\n"],"names":["intRx","integerChange","event","key","length","test","preventDefault","input","document","querySelectorAll","addEventListener","decimal","floatChange","currentTarget","value","match"],"mappings":"gKASQA,MAAQ,KACRC,cAAiBC,QACVA,MAAMC,IAAIC,OAAS,GAAMJ,MAAMK,KAAKH,MAAMC,MAI/CD,MAAMI,sBAGL,IAAIC,SAASC,SAASC,iBAAiB,2CAC1CF,MAAMG,iBAAiB,UAAWT,sBAMlCU,QAAU,qBACVX,MAAQ,KACRY,YAAeV,QACRA,MAAMC,IAAIC,OAAS,GAAsB,MAAdF,MAAMC,MAAkBD,MAAMW,cAAcC,MAAMC,MAAMJ,UAC/EX,MAAMK,KAAKH,MAAMC,MAI1BD,MAAMI,sBAGL,IAAIC,SAASC,SAASC,iBAAiB,6CAC1CF,MAAMG,iBAAiB,UAAWE,iBAE/B,IAAIL,SAASC,SAASC,iBAAiB,4BAC1CF,MAAMG,iBAAiB,UAAWE"}

View File

@ -1 +1 @@
{"version":3,"file":"downloader.min.js","sources":["../src/downloader.js"],"sourcesContent":["/*eslint no-console: \"off\"*/\n\n/**\n * Save a piece of text to file as if it was downloaded\n * @param {string} filename\n * @param {string} text\n * @param {string} type\n */\nexport function download(filename, text, type) {\n if(undefined == type) { type = \"text/plain\"; }\n var pom = document.createElement('a');\n pom.setAttribute('href', 'data:'+type+';charset=utf-8,' + encodeURIComponent(text));\n pom.setAttribute('download', filename);\n\n if (document.createEvent) {\n var event = document.createEvent('MouseEvents');\n event.initEvent('click', true, true);\n pom.dispatchEvent(event);\n }\n else {\n pom.click();\n }\n}\n\n/**\n * This callback type is called `requestCallback` and is displayed as a global symbol.\n *\n * @callback fileOpenedCallback\n * @param {File} file File name\n * @param {string} content File Contents\n */\n\n/**\n * Open a file from disk and read its contents\n * @param {fileOpenedCallback} onready Callback to run when file is opened\n * @param {Array} accept Array of mime types that the file dialog will accept\n */\nexport function upload(onready,accept) {\n let input = document.createElement('input');\n input.type = 'file';\n if(Array.isArray(accept)){\n if(accept.count > 0){\n input.accept = accept.join(\", \");\n }\n } else if (undefined !== accept){\n input.accept = accept;\n }\n input.onchange = () => {\n let files = Array.from(input.files);\n if(files.length > 0){\n let file = files[0];\n var reader = new FileReader();\n reader.onload = function(e) {\n var contents = e.target.result;\n if(onready instanceof Function){\n onready(file,contents);\n }\n };\n reader.readAsText(file);\n }\n };\n\n if (document.createEvent) {\n var event = document.createEvent('MouseEvents');\n event.initEvent('click', true, true);\n input.dispatchEvent(event);\n }\n else {\n input.click();\n }\n}"],"names":["filename","text","type","undefined","pom","document","createElement","setAttribute","encodeURIComponent","createEvent","event","initEvent","dispatchEvent","click","onready","accept","input","Array","isArray","count","join","onchange","files","from","length","file","reader","FileReader","onload","e","contents","target","result","Function","readAsText"],"mappings":"2JAQyBA,SAAUC,KAAMC,MAClCC,MAAaD,OAAQA,KAAO,kBAC3BE,IAAMC,SAASC,cAAc,QACjCF,IAAIG,aAAa,OAAQ,QAAQL,KAAK,kBAAoBM,mBAAmBP,OAC7EG,IAAIG,aAAa,WAAYP,UAEzBK,SAASI,YAAa,KAClBC,MAAQL,SAASI,YAAY,eACjCC,MAAMC,UAAU,SAAS,GAAM,GAC/BP,IAAIQ,cAAcF,YAGlBN,IAAIS,kCAiBWC,QAAQC,YACvBC,MAAQX,SAASC,cAAc,SACnCU,MAAMd,KAAO,OACVe,MAAMC,QAAQH,QACVA,OAAOI,MAAQ,IACdH,MAAMD,OAASA,OAAOK,KAAK,YAExBjB,IAAcY,SACrBC,MAAMD,OAASA,WAEnBC,MAAMK,SAAW,SACLC,MAAUL,MAAMM,KAAKP,MAAMM,UAC5BA,MAAME,OAAS,EAAE,KACZC,KAAOH,MAAM,OACbI,OAAS,IAAIC,WACjBD,OAAOE,OAAS,SAASC,OACjBC,SAAWD,EAAEE,OAAOC,OACrBlB,mBAAmBmB,UAClBnB,QAAQW,KAAKK,WAGrBJ,OAAOQ,WAAWT,QAI1BpB,SAASI,YAAa,KAClBC,MAAQL,SAASI,YAAY,eACjCC,MAAMC,UAAU,SAAS,GAAM,GAC/BK,MAAMJ,cAAcF,YAGpBM,MAAMH"} {"version":3,"file":"downloader.min.js","sources":["../src/downloader.js"],"sourcesContent":["/**\n * Save a piece of text to file as if it was downloaded\n * @param {string} filename\n * @param {string} text\n * @param {string} type\n */\nexport function download(filename, text, type) {\n if (undefined == type) {\n type = \"text/plain\";\n }\n var pom = document.createElement('a');\n pom.setAttribute('href', 'data:' + type + ';charset=utf-8,' + encodeURIComponent(text));\n pom.setAttribute('download', filename);\n\n if (document.createEvent) {\n var event = document.createEvent('MouseEvents');\n event.initEvent('click', true, true);\n pom.dispatchEvent(event);\n } else {\n pom.click();\n }\n}\n\n/**\n * This callback type is called `requestCallback` and is displayed as a global symbol.\n *\n * @callback fileOpenedCallback\n * @param {File} file File name\n * @param {string} content File Contents\n */\n\n/**\n * Open a file from disk and read its contents\n * @param {fileOpenedCallback} onready Callback to run when file is opened\n * @param {Array} accept Array of mime types that the file dialog will accept\n */\nexport function upload(onready, accept) {\n let input = document.createElement('input');\n input.type = 'file';\n if (Array.isArray(accept)) {\n if (accept.count > 0) {\n input.accept = accept.join(\", \");\n }\n } else if (undefined !== accept) {\n input.accept = accept;\n }\n input.onchange = () => {\n let files = Array.from(input.files);\n if (files.length > 0) {\n let file = files[0];\n var reader = new FileReader();\n reader.onload = function(e) {\n var contents = e.target.result;\n if (onready instanceof Function) {\n onready(file, contents);\n }\n };\n reader.readAsText(file);\n }\n };\n\n if (document.createEvent) {\n var event = document.createEvent('MouseEvents');\n event.initEvent('click', true, true);\n input.dispatchEvent(event);\n } else {\n input.click();\n }\n}"],"names":["filename","text","type","undefined","pom","document","createElement","setAttribute","encodeURIComponent","createEvent","event","initEvent","dispatchEvent","click","onready","accept","input","Array","isArray","count","join","onchange","files","from","length","file","reader","FileReader","onload","e","contents","target","result","Function","readAsText"],"mappings":"2JAMyBA,SAAUC,KAAMC,MACjCC,MAAaD,OACbA,KAAO,kBAEPE,IAAMC,SAASC,cAAc,QACjCF,IAAIG,aAAa,OAAQ,QAAUL,KAAO,kBAAoBM,mBAAmBP,OACjFG,IAAIG,aAAa,WAAYP,UAEzBK,SAASI,YAAa,KAClBC,MAAQL,SAASI,YAAY,eACjCC,MAAMC,UAAU,SAAS,GAAM,GAC/BP,IAAIQ,cAAcF,YAElBN,IAAIS,kCAiBWC,QAASC,YACxBC,MAAQX,SAASC,cAAc,SACnCU,MAAMd,KAAO,OACTe,MAAMC,QAAQH,QACVA,OAAOI,MAAQ,IACfH,MAAMD,OAASA,OAAOK,KAAK,YAExBjB,IAAcY,SACrBC,MAAMD,OAASA,WAEnBC,MAAMK,SAAW,SACLC,MAAQL,MAAMM,KAAKP,MAAMM,UACzBA,MAAME,OAAS,EAAG,KACdC,KAAOH,MAAM,OACbI,OAAS,IAAIC,WACjBD,OAAOE,OAAS,SAASC,OACjBC,SAAWD,EAAEE,OAAOC,OACpBlB,mBAAmBmB,UACnBnB,QAAQW,KAAMK,WAGtBJ,OAAOQ,WAAWT,QAI1BpB,SAASI,YAAa,KAClBC,MAAQL,SAASI,YAAY,eACjCC,MAAMC,UAAU,SAAS,GAAM,GAC/BK,MAAMJ,cAAcF,YAEpBM,MAAMH"}

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/modedit-modal",["exports","core/fragment","./util/string-helper","core/ajax","core/notification","core/templates"],(function(_exports,_fragment,_stringHelper,_ajax,_notification,_templates){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_notification=(obj=_notification)&&obj.__esModule?obj:{default:obj};var _default={install(Vue){let strings=(0,_stringHelper.load_strings)({editmod:{save$core:"save$core",cancel$core:"cancel$core"}});Vue.component("s-edit-mod",{props:{cmid:{type:Number},coursectxid:{type:Number},title:{type:String,default:""},genericonly:{type:Boolean,default:!1}},data:()=>({content:"",text:strings.editmod}),computed:{},methods:{openForm(){this.$refs.editormodal.show()},onShown(){const self=this;let params={cmid:this.cmid};console.info("Loading form"),(0,_fragment.loadFragment)("local_treestudyplan","mod_edit_form",this.coursectxid,params).then(((html,js)=>{(0,_templates.replaceNodeContents)(self.$refs.content,html,js)})).catch(_notification.default.exception)},onSave(){const self=this;let form=this.$refs.content.getElementsByTagName("form")[0];form.dispatchEvent(new Event("save-form-state"));const formdata=new FormData(form),data=new URLSearchParams(formdata).toString();(0,_ajax.call)([{methodname:"local_treestudyplan_submit_cm_editform",args:{cmid:this.cmid,formdata:data}}])[0].then((()=>{self.$emit("saved",formdata)})).catch(_notification.default.exception)}},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 '})}};return _exports.default=_default,_exports.default})); define("local_treestudyplan/modedit-modal",["exports","core/fragment","./util/string-helper","core/ajax","core/notification","core/templates"],(function(_exports,_fragment,_stringHelper,_ajax,_notification,_templates){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_notification=(obj=_notification)&&obj.__esModule?obj:{default:obj};var _default={install(Vue){let strings=(0,_stringHelper.loadStrings)({editmod:{save$core:"save$core",cancel$core:"cancel$core"}});Vue.component("s-edit-mod",{props:{cmid:{type:Number},coursectxid:{type:Number},title:{type:String,default:""},genericonly:{type:Boolean,default:!1}},data:()=>({content:"",text:strings.editmod}),computed:{},methods:{openForm(){this.$refs.editormodal.show()},onShown(){const self=this;let params={cmid:this.cmid};(0,_fragment.loadFragment)("local_treestudyplan","mod_edit_form",this.coursectxid,params).then(((html,js)=>((0,_templates.replaceNodeContents)(self.$refs.content,html,js),null))).catch(_notification.default.exception)},onSave(){const self=this;let form=this.$refs.content.getElementsByTagName("form")[0];form.dispatchEvent(new Event("save-form-state"));const formdata=new FormData(form),data=new URLSearchParams(formdata).toString();(0,_ajax.call)([{methodname:"local_treestudyplan_submit_cm_editform",args:{cmid:this.cmid,formdata:data}}])[0].then((()=>(self.$emit("saved",formdata),null))).catch(_notification.default.exception)}},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 '})}};return _exports.default=_default,_exports.default}));
//# sourceMappingURL=modedit-modal.min.js.map //# sourceMappingURL=modedit-modal.min.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/page-invitemanager",["exports","./util/debugger","core/str","core/modal_factory","core/modal_events"],(function(_exports,_debugger,_str,_modal_factory,_modal_events){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){getstr_func([{key:"ok",component:"core"},{key:"confirm",component:"core"}]).then((s=>{const strOk=s[0],strConfirm=s[1];document.querySelectorAll(".path-local-treestudyplan a.m-action-confirm").forEach((el=>{el.addEventListener("click",(e=>{e.preventDefault();const link=e.currentTarget;let href=link.getAttribute("data-actionhref"),text=link.getAttribute("data-confirmtext"),oktext=link.getAttribute("data-confirmbtn");null==oktext&&(oktext=strOk);let title=link.getAttribute("data-confirmtitle");null==title&&(title=strConfirm),_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:title,body:text}).then((function(modal){return modal.setSaveButtonText(oktext),modal.getRoot().on(_modal_events.default.save,(function(){window.location=href})),modal.modal[0].style["max-width"]="345px",modal.show(),modal}))}))}))}))},_debugger=_interopRequireDefault(_debugger),_modal_factory=_interopRequireDefault(_modal_factory),_modal_events=_interopRequireDefault(_modal_events);const getstr_func=void 0!==_str.getStrings?_str.getStrings:_str.get_strings;new _debugger.default("treestudyplan")})); define("local_treestudyplan/page-invitemanager",["exports","./util/debugger","core/str","core/modal_factory","core/modal_events"],(function(_exports,_debugger,_str,_modal_factory,_modal_events){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){getstrFunc([{key:"ok",component:"core"},{key:"confirm",component:"core"}]).then((s=>{const strOk=s[0],strConfirm=s[1];document.querySelectorAll(".path-local-treestudyplan a.m-action-confirm").forEach((el=>{el.addEventListener("click",(e=>{e.preventDefault();const link=e.currentTarget;let href=link.getAttribute("data-actionhref"),text=link.getAttribute("data-confirmtext"),oktext=link.getAttribute("data-confirmbtn");null==oktext&&(oktext=strOk);let title=link.getAttribute("data-confirmtitle");null==title&&(title=strConfirm),_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:title,body:text}).then((modal=>(modal.setSaveButtonText(oktext),modal.getRoot().on(_modal_events.default.save,(()=>{window.location=href})),modal.modal[0].style["max-width"]="345px",modal.show(),modal))).catch((x=>{debug.warn(x)}))}))}))})).catch((x=>{debug.warn(x)}))},_debugger=_interopRequireDefault(_debugger),_modal_factory=_interopRequireDefault(_modal_factory),_modal_events=_interopRequireDefault(_modal_events);const getstrFunc=void 0!==_str.getStrings?_str.getStrings:_str.get_strings;let debug=new _debugger.default("treestudyplan-invitemanager")}));
//# sourceMappingURL=page-invitemanager.min.js.map //# sourceMappingURL=page-invitemanager.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"page-invitemanager.min.js","sources":["../src/page-invitemanager.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport Debugger from './util/debugger';\nimport {get_strings} from 'core/str';\nimport {getStrings} from 'core/str';\nimport ModalFactory from 'core/modal_factory';\nimport ModalEvents from 'core/modal_events';\n\n/* Determine the proper getstrings function to use (MDL4.3+ recommends use of getStrings, which is jquery independent) */\nconst getstr_func = (getStrings !== undefined)?getStrings:get_strings;\n\nlet debug = new Debugger(\"treestudyplan\");\n\n /**\n * Init function for page-invitemanager\n * @return undefined\n */\nexport function init() {\n getstr_func([\n { key: 'ok', component: 'core'},\n { key: 'confirm', component: 'core'},\n ]).then((s) => {\n const strOk = s[0];\n const strConfirm = s[1];\n\n const els = document.querySelectorAll('.path-local-treestudyplan a.m-action-confirm');\n els.forEach((el) => {\n el.addEventListener('click', (e) => {\n e.preventDefault();\n const link = e.currentTarget;\n let href = link.getAttribute('data-actionhref');\n let text = link.getAttribute('data-confirmtext');\n let oktext = link.getAttribute('data-confirmbtn');\n if (undefined == oktext) {\n oktext = strOk;\n }\n let title = link.getAttribute('data-confirmtitle');\n if (undefined == title) {\n title = strConfirm;\n }\n\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: title,\n body: text,\n }).then(function (modal) {\n modal.setSaveButtonText(oktext);\n\n let root = modal.getRoot();\n root.on(ModalEvents.save, function () {\n window.location = href;\n });\n modal.modal[0].style[\"max-width\"] = \"345px\";\n modal.show();\n return modal;\n });\n });\n });\n });\n}\n"],"names":["getstr_func","key","component","then","s","strOk","strConfirm","document","querySelectorAll","forEach","el","addEventListener","e","preventDefault","link","currentTarget","href","getAttribute","text","oktext","undefined","title","create","type","ModalFactory","types","SAVE_CANCEL","body","modal","setSaveButtonText","getRoot","on","ModalEvents","save","window","location","style","show","getStrings","get_strings","Debugger"],"mappings":"qWAuBIA,YAAY,CACR,CAAEC,IAAK,KAAMC,UAAW,QACxB,CAAED,IAAK,UAAWC,UAAW,UAC9BC,MAAMC,UACCC,MAAQD,EAAE,GACVE,WAAaF,EAAE,GAETG,SAASC,iBAAiB,gDAClCC,SAASC,KACTA,GAAGC,iBAAiB,SAAUC,IAC1BA,EAAEC,uBACIC,KAAOF,EAAEG,kBACXC,KAAOF,KAAKG,aAAa,mBACzBC,KAAOJ,KAAKG,aAAa,oBACzBE,OAASL,KAAKG,aAAa,mBAC3BG,MAAaD,SACbA,OAASd,WAETgB,MAAQP,KAAKG,aAAa,qBAC1BG,MAAaC,QACbA,MAAQf,mCAGCgB,OAAO,CAChBC,KAAMC,uBAAaC,MAAMC,YACzBL,MAAOA,MACPM,KAAMT,OACPf,MAAK,SAAUyB,cACdA,MAAMC,kBAAkBV,QAEbS,MAAME,UACZC,GAAGC,sBAAYC,MAAM,WACtBC,OAAOC,SAAWnB,QAEtBY,MAAMA,MAAM,GAAGQ,MAAM,aAAe,QACpCR,MAAMS,OACCT,+KA7CrB5B,iBAA8BoB,IAAfkB,gBAA0BA,gBAAWC,iBAE9C,IAAIC,kBAAS"} {"version":3,"file":"page-invitemanager.min.js","sources":["../src/page-invitemanager.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint no-unused-vars: \"off\" */\n/* eslint linebreak-style: \"off\" */\n/* eslint-env es6*/\n/* eslint camelcase: \"off\" */\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport Debugger from './util/debugger';\nimport {get_strings} from 'core/str';\nimport {getStrings} from 'core/str';\nimport ModalFactory from 'core/modal_factory';\nimport ModalEvents from 'core/modal_events';\n\n/* Determine the proper getstrings function to use (MDL4.3+ recommends use of getStrings, which is jquery independent) */\nconst getstrFunc = (getStrings !== undefined) ? getStrings : get_strings;\n\nlet debug = new Debugger(\"treestudyplan-invitemanager\");\n\n /**\n * Init function for page-invitemanager\n */\nexport function init() {\n getstrFunc([\n {key: 'ok', component: 'core'},\n {key: 'confirm', component: 'core'},\n ]).then((s) => {\n const strOk = s[0];\n const strConfirm = s[1];\n\n const els = document.querySelectorAll('.path-local-treestudyplan a.m-action-confirm');\n els.forEach((el) => {\n el.addEventListener('click', (e) => {\n e.preventDefault();\n const link = e.currentTarget;\n let href = link.getAttribute('data-actionhref');\n let text = link.getAttribute('data-confirmtext');\n let oktext = link.getAttribute('data-confirmbtn');\n if (undefined == oktext) {\n oktext = strOk;\n }\n let title = link.getAttribute('data-confirmtitle');\n if (undefined == title) {\n title = strConfirm;\n }\n\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: title,\n body: text,\n }).then((modal) => {\n modal.setSaveButtonText(oktext);\n\n let root = modal.getRoot();\n root.on(ModalEvents.save, () => {\n window.location = href;\n });\n modal.modal[0].style[\"max-width\"] = \"345px\";\n modal.show();\n return modal;\n }).catch((x) => {\n debug.warn(x);\n });\n });\n });\n return;\n }).catch((x) => {\n debug.warn(x);\n });\n}\n"],"names":["getstrFunc","key","component","then","s","strOk","strConfirm","document","querySelectorAll","forEach","el","addEventListener","e","preventDefault","link","currentTarget","href","getAttribute","text","oktext","undefined","title","create","type","ModalFactory","types","SAVE_CANCEL","body","modal","setSaveButtonText","getRoot","on","ModalEvents","save","window","location","style","show","catch","x","debug","warn","getStrings","get_strings","Debugger"],"mappings":"qWAuBIA,WAAW,CACP,CAACC,IAAK,KAAMC,UAAW,QACvB,CAACD,IAAK,UAAWC,UAAW,UAC7BC,MAAMC,UACCC,MAAQD,EAAE,GACVE,WAAaF,EAAE,GAETG,SAASC,iBAAiB,gDAClCC,SAASC,KACTA,GAAGC,iBAAiB,SAAUC,IAC1BA,EAAEC,uBACIC,KAAOF,EAAEG,kBACXC,KAAOF,KAAKG,aAAa,mBACzBC,KAAOJ,KAAKG,aAAa,oBACzBE,OAASL,KAAKG,aAAa,mBAC3BG,MAAaD,SACbA,OAASd,WAETgB,MAAQP,KAAKG,aAAa,qBAC1BG,MAAaC,QACbA,MAAQf,mCAGCgB,OAAO,CAChBC,KAAMC,uBAAaC,MAAMC,YACzBL,MAAOA,MACPM,KAAMT,OACPf,MAAMyB,QACLA,MAAMC,kBAAkBV,QAEbS,MAAME,UACZC,GAAGC,sBAAYC,MAAM,KACtBC,OAAOC,SAAWnB,IAAlB,IAEJY,MAAMA,MAAM,GAAGQ,MAAM,aAAe,QACpCR,MAAMS,OACCT,SACRU,OAAOC,IACNC,MAAMC,KAAKF,eAKxBD,OAAOC,IACNC,MAAMC,KAAKF,mKApDbvC,gBAA6BoB,IAAfsB,gBAA4BA,gBAAaC,qBAEzDH,MAAQ,IAAII,kBAAS"}

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/page-myreport",["exports","./vue/vue","./report-viewer-components","./util/debugger","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_vue,_reportViewerComponents,_debugger,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){let type=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"own",arg1=arguments.length>1?arguments[1]:void 0;new _vue.default({el:"#root",data:{studyplans:[],type:type,invitekey:"invited"==type?arg1:null,userid:"other"==type?arg1:null},methods:{}})},_vue=_interopRequireDefault(_vue),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_debugger=_interopRequireDefault(_debugger),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);new _debugger.default("treestudyplan-report")})); define("local_treestudyplan/page-myreport",["exports","./vue/vue","./report-viewer-components","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_vue,_reportViewerComponents,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){let type=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"own",arg1=arguments.length>1?arguments[1]:void 0;new _vue.default({el:"#root",data:{studyplans:[],type:type,invitekey:"invited"==type?arg1:null,userid:"other"==type?arg1:null},methods:{}})},_vue=_interopRequireDefault(_vue),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default)}));
//# sourceMappingURL=page-myreport.min.js.map //# sourceMappingURL=page-myreport.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"page-myreport.min.js","sources":["../src/page-myreport.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint no-trailing-spaces: \"off\" */\n/*eslint no-console: \"off\" */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport Vue from './vue/vue';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\nimport Debugger from './util/debugger';\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\nlet debug = new Debugger(\"treestudyplan-report\");\n\n/**\n * Initialize the Page\n * @param {string} type Type of page to show\n * @param {Object} arg1 Argument1 as passed\n */\n export function init(type=\"own\",arg1) {\n let app = new Vue({\n el: '#root',\n data: {\n \"studyplans\": [],\n \"type\": type,\n \"invitekey\": (type==\"invited\")?arg1:null,\n \"userid\": (type==\"other\")?arg1:null,\n },\n methods: {\n\n },\n });\n\n}\n\n"],"names":["type","arg1","Vue","el","data","methods","use","RVComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"2aA4BsBA,4DAAK,MAAMC,4CACnB,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,YACY,QACNJ,eACY,WAANA,KAAiBC,KAAK,YACnB,SAAND,KAAeC,KAAK,MAEnCI,QAAS,2QAzBbC,IAAIC,8CAKJD,IAAIE,iCAEJF,IAAIG,uBAEI,IAAIC,kBAAS"} {"version":3,"file":"page-myreport.min.js","sources":["../src/page-myreport.js"],"sourcesContent":["/* eslint no-unused-vars: \"off\" */\n/* eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport Vue from './vue/vue';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n/**\n * Initialize the Page\n * @param {string} type Type of page to show\n * @param {Object} arg1 Argument1 as passed\n */\n export function init(type = \"own\", arg1) {\n let app = new Vue({\n el: '#root',\n data: {\n \"studyplans\": [],\n \"type\": type,\n \"invitekey\": (type == \"invited\") ? arg1 : null,\n \"userid\": (type == \"other\") ? arg1 : null,\n },\n methods: {\n\n },\n });\n\n}\n\n"],"names":["type","arg1","Vue","el","data","methods","use","RVComponents","PortalVue","BootstrapVue"],"mappings":"+YAoBsBA,4DAAO,MAAOC,4CACtB,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,YACY,QACNJ,eACc,WAARA,KAAqBC,KAAO,YACvB,SAARD,KAAmBC,KAAO,MAEzCI,QAAS,+NArBbC,IAAIC,8CAGJD,IAAIE,iCAEJF,IAAIG"}

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/page-result-overview",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-report-components","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanReportComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(studyplanid,pageid,firstperiod,lastperiod){if(void 0===pageid||!Number.isInteger(Number(pageid))||void 0===studyplanid||!Number.isInteger(Number(studyplanid)))return void debug.error("Error: studyplan id and page id not provided as integer numbers to script.",studyplanid,pageid,firstperiod,lastperiod);studyplanid=Number(studyplanid),pageid=Number(pageid);new _vue.default({el:"#root",data:{structure:null,studyplan:null,page:null,text:strings.studyplan_report},async mounted(){},created(){this.loadStructure(pageid,firstperiod,lastperiod)},computed:{},methods:{loadStructure(pageid,firstperiod,lastperiod){const self=this;this.structure=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_report_structure",args:{pageid:pageid,firstperiod:firstperiod,lastperiod:lastperiod}}])[0].then((function(response){self.structure=response,self.studyplan=response.studyplan,self.page=response.page})).catch(_notification.default.exception)},selectedPage(e){debug.info("SelectedPage",e);const pageid=e.target.value;this.loadStructure(pageid)},selectedFirstPeriod(e){debug.info("selectedFirstPeriod",e);let f=e.target.value,l=this.structure.lastperiod;l<f&&(l=f),this.loadStructure(this.page.id,f,l)},selectedLastPeriod(e){debug.info("selectedLastPeriod",e);let f=this.structure.firstperiod,l=e.target.value;l<f&&(l=f),this.loadStructure(this.page.id,f,l)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_studyplanReportComponents=_interopRequireDefault(_studyplanReportComponents),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_studyplanReportComponents.default),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);let debug=new _debugger.default("treestudyplanviewer"),strings=(0,_stringHelper.load_strings)({studyplan_report:{studyplan_select_placeholder:"studyplan_select_placeholder",studyplan:"studyplan",page:"studyplanpage",periods:"periods",period:"period",loading:"loading@core",all:"all@core",from:"from@core",to:"to@core"}})})); define("local_treestudyplan/page-result-overview",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-report-components","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanReportComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(studyplanid,pageid,firstperiod,lastperiod){if(void 0===pageid||!Number.isInteger(Number(pageid))||void 0===studyplanid||!Number.isInteger(Number(studyplanid)))return void debug.error("Error: studyplan id and page id not provided as integer numbers to script.",studyplanid,pageid,firstperiod,lastperiod);studyplanid=Number(studyplanid),pageid=Number(pageid);new _vue.default({el:"#root",data:{structure:null,studyplan:null,page:null,text:strings.studyplanReport},created(){this.loadStructure(pageid,firstperiod,lastperiod)},computed:{},methods:{loadStructure(pageid,firstperiod,lastperiod){const self=this;this.structure=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_report_structure",args:{pageid:pageid,firstperiod:firstperiod,lastperiod:lastperiod}}])[0].then((response=>{self.structure=response,self.studyplan=response.studyplan,self.page=response.page})).catch(_notification.default.exception)},selectedPage(e){debug.info("SelectedPage",e);const pageid=e.target.value;this.loadStructure(pageid)},selectedFirstPeriod(e){debug.info("selectedFirstPeriod",e);let f=e.target.value,l=this.structure.lastperiod;l<f&&(l=f),this.loadStructure(this.page.id,f,l)},selectedLastPeriod(e){debug.info("selectedLastPeriod",e);let f=this.structure.firstperiod,l=e.target.value;l<f&&(l=f),this.loadStructure(this.page.id,f,l)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_studyplanReportComponents=_interopRequireDefault(_studyplanReportComponents),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_studyplanReportComponents.default),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);let debug=new _debugger.default("treestudyplanviewer"),strings=(0,_stringHelper.loadStrings)({studyplanReport:{studyplan:"studyplan",page:"studyplanpage",periods:"periods",period:"period",loading:"loading@core",all:"all@core",from:"from@core",to:"to@core"}})}));
//# sourceMappingURL=page-result-overview.min.js.map //# sourceMappingURL=page-result-overview.min.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/primary-nav-tools",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.hide_primary=function(hrefs){("string"==typeof hrefs||hrefs instanceof String)&&(hrefs=[hrefs]);if("object"==typeof hrefs&&Array.isArray(hrefs)){let css="";for(const ix in hrefs){const href=hrefs[ix];css+=`\n li > a[href*="${href}"] {\n display: none !important; \n }\n `,css+=`\n #usernavigation a[href*="${href}"] {\n display: none !important;\n }\n `}const element=document.createElement("style");element.setAttribute("type","text/css"),"textContent"in element?element.textContent=css:element.styleSheet.cssText=css,document.head.appendChild(element)}}})); define("local_treestudyplan/primary-nav-tools",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.hidePrimary=function(hrefs){("string"==typeof hrefs||hrefs instanceof String)&&(hrefs=[hrefs]);if("object"==typeof hrefs&&Array.isArray(hrefs)){let css="";for(const ix in hrefs){const href=hrefs[ix];css+=`\n li > a[href*="${href}"] {\n display: none !important; \n }\n `,css+=`\n #usernavigation a[href*="${href}"] {\n display: none !important;\n }\n `}const element=document.createElement("style");element.setAttribute("type","text/css"),"textContent"in element?element.textContent=css:element.styleSheet.cssText=css,document.head.appendChild(element)}}}));
//# sourceMappingURL=primary-nav-tools.min.js.map //# sourceMappingURL=primary-nav-tools.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"primary-nav-tools.min.js","sources":["../src/primary-nav-tools.js"],"sourcesContent":["/*eslint-env es6*/\n/*eslint no-console: \"off\"*/\n\n/**\n * Hide a primary navigation item by href\n * @param {string|Array} hrefs The link that should be hidden\n */\nexport function hide_primary(hrefs) {\n if(typeof hrefs === 'string' || hrefs instanceof String){\n hrefs = [hrefs];\n }\n\n if(typeof hrefs === 'object' && Array.isArray(hrefs)){\n let css = '' ;\n for(const ix in hrefs){\n const href = hrefs[ix];\n css += `\n li > a[href*=\"${href}\"] {\n display: none !important; \n }\n `;\n css += `\n #usernavigation a[href*=\"${href}\"] {\n display: none !important;\n }\n `;\n }\n\n\n const element = document.createElement('style');\n element.setAttribute('type', 'text/css');\n\n if ('textContent' in element) {\n element.textContent = css;\n } else {\n element.styleSheet.cssText = css;\n }\n\n document.head.appendChild(element);\n\n }\n}\n"],"names":["hrefs","String","Array","isArray","css","ix","href","element","document","createElement","setAttribute","textContent","styleSheet","cssText","head","appendChild"],"mappings":"sKAO6BA,QACL,iBAAVA,OAAsBA,iBAAiBC,UAC7CD,MAAQ,CAACA,WAGO,iBAAVA,OAAsBE,MAAMC,QAAQH,OAAO,KAC7CI,IAAM,OACN,MAAMC,MAAML,MAAM,OACZM,KAAON,MAAMK,IACnBD,KAAQ,mCACYE,4FAIpBF,KAAQ,8CACuBE,iGAO7BC,QAAUC,SAASC,cAAc,SACvCF,QAAQG,aAAa,OAAQ,YAEzB,gBAAiBH,QACjBA,QAAQI,YAAcP,IAEtBG,QAAQK,WAAWC,QAAUT,IAGjCI,SAASM,KAAKC,YAAYR"} {"version":3,"file":"primary-nav-tools.min.js","sources":["../src/primary-nav-tools.js"],"sourcesContent":["/* eslint-env es6*/\n/* eslint no-console: \"off\"*/\n\n/**\n * Hide a primary navigation item by href\n * @param {string|Array} hrefs The link that should be hidden\n */\nexport function hidePrimary(hrefs) {\n if (typeof hrefs === 'string' || hrefs instanceof String) {\n hrefs = [hrefs];\n }\n\n if (typeof hrefs === 'object' && Array.isArray(hrefs)) {\n let css = '';\n for (const ix in hrefs) {\n const href = hrefs[ix];\n css += `\n li > a[href*=\"${href}\"] {\n display: none !important; \n }\n `;\n css += `\n #usernavigation a[href*=\"${href}\"] {\n display: none !important;\n }\n `;\n }\n\n\n const element = document.createElement('style');\n element.setAttribute('type', 'text/css');\n\n if ('textContent' in element) {\n element.textContent = css;\n } else {\n element.styleSheet.cssText = css;\n }\n\n document.head.appendChild(element);\n\n }\n}\n"],"names":["hrefs","String","Array","isArray","css","ix","href","element","document","createElement","setAttribute","textContent","styleSheet","cssText","head","appendChild"],"mappings":"qKAO4BA,QACH,iBAAVA,OAAsBA,iBAAiBC,UAC9CD,MAAQ,CAACA,WAGQ,iBAAVA,OAAsBE,MAAMC,QAAQH,OAAQ,KAC/CI,IAAM,OACL,MAAMC,MAAML,MAAO,OACdM,KAAON,MAAMK,IACnBD,KAAQ,mCACYE,4FAIpBF,KAAQ,8CACuBE,iGAO7BC,QAAUC,SAASC,cAAc,SACvCF,QAAQG,aAAa,OAAQ,YAEzB,gBAAiBH,QACjBA,QAAQI,YAAcP,IAEtBG,QAAQK,WAAWC,QAAUT,IAGjCI,SAASM,KAAKC,YAAYR"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/studyplan-processor",["exports"],(function(_exports){function ProcessStudyplan(studyplan){for(const ip in studyplan.pages){ProcessStudyplanPage(studyplan.pages[ip])}return studyplan}function ProcessStudyplanPage(page){let connections={};for(const il in page.studylines){const line=page.studylines[il];for(const is in line.slots){const slot=line.slots[is];if(void 0!==slot.courses)for(const ic in slot.courses){const itm=slot.courses[ic];for(const idx in itm.connections.in){const conn=itm.connections.in[idx];conn.id in connections?itm.connections[idx]=connections[conn.id]:connections[conn.id]=conn}for(const idx in itm.connections.out){const conn=itm.connections.out[idx];conn.id in connections?itm.connections[idx]=connections[conn.id]:connections[conn.id]=conn}}if(void 0!==slot.filters)for(const ix in slot.filters){const itm=slot.filters[ix];for(const idx in itm.connections.in){const conn=itm.connections.in[idx];conn.id in connections?itm.connections[idx]=connections[conn.id]:connections[conn.id]=conn}for(const idx in itm.connections.out){const conn=itm.connections.out[idx];conn.id in connections?itm.connections[idx]=connections[conn.id]:connections[conn.id]=conn}}}}return page}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.ProcessStudyplan=ProcessStudyplan,_exports.ProcessStudyplanPage=ProcessStudyplanPage,_exports.ProcessStudyplans=function(studyplans){for(const isx in studyplans){ProcessStudyplan(studyplans[isx])}return studyplans},_exports.objCopy=function(target,source,fields){null==fields&&(fields=Object.getOwnPropertyNames(source));for(const ix in fields){const field=fields[ix];target[field]=source[field]}return target},_exports.transportItem=function(target,source,identifier,param){param||(param="value");let item,itemindex;for(const ix in source)if(source[ix][param]==identifier){item=source[ix],itemindex=ix;break}item&&(target.push(item),source.splice(itemindex,1))}})); define("local_treestudyplan/studyplan-processor",["exports"],(function(_exports){function processStudyplan(studyplan){for(const ip in studyplan.pages){processStudyplanPage(studyplan.pages[ip])}return studyplan}function processStudyplanPage(page){let connections={};for(const il in page.studylines){const line=page.studylines[il];for(const is in line.slots){const slot=line.slots[is];if(void 0!==slot.courses)for(const ic in slot.courses){const itm=slot.courses[ic];for(const idx in itm.connections.in){const conn=itm.connections.in[idx];conn.id in connections?itm.connections[idx]=connections[conn.id]:connections[conn.id]=conn}for(const idx in itm.connections.out){const conn=itm.connections.out[idx];conn.id in connections?itm.connections[idx]=connections[conn.id]:connections[conn.id]=conn}}if(void 0!==slot.filters)for(const ix in slot.filters){const itm=slot.filters[ix];for(const idx in itm.connections.in){const conn=itm.connections.in[idx];conn.id in connections?itm.connections[idx]=connections[conn.id]:connections[conn.id]=conn}for(const idx in itm.connections.out){const conn=itm.connections.out[idx];conn.id in connections?itm.connections[idx]=connections[conn.id]:connections[conn.id]=conn}}}}return page}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.objCopy=function(target,source,fields){null==fields&&(fields=Object.getOwnPropertyNames(source));for(const ix in fields){const field=fields[ix];target[field]=source[field]}return target},_exports.processStudyplan=processStudyplan,_exports.processStudyplanPage=processStudyplanPage,_exports.processStudyplans=function(studyplans){for(const isx in studyplans){processStudyplan(studyplans[isx])}return studyplans},_exports.transportItem=function(target,source,identifier,param){param||(param="value");let item,itemindex;for(const ix in source)if(source[ix][param]==identifier){item=source[ix],itemindex=ix;break}item&&(target.push(item),source.splice(itemindex,1))}}));
//# sourceMappingURL=studyplan-processor.min.js.map //# sourceMappingURL=studyplan-processor.min.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"file":"browserbuttonevents.min.js","sources":["../../src/util/browserbuttonevents.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint no-trailing-spaces: \"off\" */\n/*eslint-env es6*/\n\nimport Debugger from './debugger';\nconst debug = new Debugger(\"browserbuttonevents\");\n\n/**\n * \n * @param {function} backwardCB \n * @param {function} forwardCB \n * @param {function} reloadCB \n */\nexport function addBrowserButtonEvent(backwardCB, forwardCB = null, reloadCB = null) {\n debug.log(\"Registering navigation events\",backwardCB,forwardCB,reloadCB);\n const reorient = (e) => { // After travelling in the history stack\n const positionLastShown = Number( // If none, then zero\n sessionStorage.getItem( 'positionLastShown' ));\n// debug.log(\"Popstate event\",e,positionLastShown,history);\n let position = history.state; // Absolute position in stack\n if( position === null ) { // Meaning a new entry on the stack\n position = positionLastShown + 1; // Top of stack\n \n // (1) Stamp the entry with its own position in the stack\n history.replaceState( position, /*no title*/'' ); \n }\n \n // (2) Keep track of the last position shown\n sessionStorage.setItem( 'positionLastShown', String(position) );\n \n // (3) Discover the direction of travel by comparing the two\n const direction = Math.sign( position - positionLastShown );\n debug.log( 'Travel direction is ' + direction ); \n // One of backward (-1), reload (0) and forward (1)\n if (direction == -1 && backwardCB) {\n backwardCB();\n }\n if (direction == 1 && forwardCB) {\n forwardCB();\n }\n if (direction == 0 && reloadCB) {\n reloadCB();\n }\n };\n //addEventListener( 'pageshow', reorient );\n addEventListener( 'popstate', reorient ); // Travel in same page\n}"],"names":["backwardCB","forwardCB","reloadCB","debug","log","addEventListener","e","positionLastShown","Number","sessionStorage","getItem","position","history","state","replaceState","setItem","String","direction","Math","sign"],"mappings":"qNAesCA,gBAAYC,iEAAY,KAAMC,gEAAW,KAC3EC,MAAMC,IAAI,gCAAgCJ,WAAWC,UAAUC,UA+B/DG,iBAAkB,YA9BAC,UACRC,kBAAoBC,OACxBC,eAAeC,QAAS,0BAEtBC,SAAWC,QAAQC,MACN,OAAbF,WACAA,SAAWJ,kBAAoB,EAG/BK,QAAQE,aAAcH,SAAsB,KAIhDF,eAAeM,QAAS,oBAAqBC,OAAOL,iBAG9CM,UAAYC,KAAKC,KAAMR,SAAWJ,mBACxCJ,MAAMC,IAAK,uBAAyBa,YAElB,GAAdA,WAAmBjB,YACnBA,aAEa,GAAbiB,WAAkBhB,WAClBA,YAEa,GAAbgB,WAAkBf,UAClBA,qBApCNC,MAAQ,yEAAa"} {"version":3,"file":"browserbuttonevents.min.js","sources":["../../src/util/browserbuttonevents.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint no-unused-vars: \"off\" */\n/* eslint linebreak-style: \"off\" */\n/* eslint no-trailing-spaces: \"off\" */\n/* eslint capitalized-comments: \"off\" */\n/* eslint-env es6 */\n\nimport Debugger from './debugger';\nconst debug = new Debugger(\"browserbuttonevents\");\n\n/**\n * \n * @param {function} backwardCB \n * @param {function} forwardCB \n * @param {function} reloadCB \n */\nexport function addBrowserButtonEvent(backwardCB, forwardCB = null, reloadCB = null) {\n debug.log(\"Registering navigation events\", backwardCB, forwardCB, reloadCB);\n const reorient = (e) => { // After travelling in the history stack\n const positionLastShown = Number( // If none, then zero\n sessionStorage.getItem('positionLastShown'));\n // debug.log(\"Popstate event\",e,positionLastShown,history);\n let position = history.state; // Absolute position in stack\n if (position === null) { // Meaning a new entry on the stack\n position = positionLastShown + 1; // Top of stack\n \n // (1) Stamp the entry with its own position in the stack\n history.replaceState(position, /* no title */''); \n }\n \n // (2) Keep track of the last position shown\n sessionStorage.setItem('positionLastShown', String(position));\n \n // (3) Discover the direction of travel by comparing the two\n const direction = Math.sign(position - positionLastShown);\n debug.log('Travel direction is ' + direction); \n // One of backward (-1), reload (0) and forward (1)\n if (direction == -1 && backwardCB) {\n backwardCB();\n }\n if (direction == 1 && forwardCB) {\n forwardCB();\n }\n if (direction == 0 && reloadCB) {\n reloadCB();\n }\n };\n // addEventListener( 'pageshow', reorient );\n addEventListener('popstate', reorient); // Travel in same page\n}"],"names":["backwardCB","forwardCB","reloadCB","debug","log","addEventListener","e","positionLastShown","Number","sessionStorage","getItem","position","history","state","replaceState","setItem","String","direction","Math","sign"],"mappings":"qNAgBsCA,gBAAYC,iEAAY,KAAMC,gEAAW,KAC3EC,MAAMC,IAAI,gCAAiCJ,WAAYC,UAAWC,UA+BlEG,iBAAiB,YA9BCC,UACRC,kBAAoBC,OACxBC,eAAeC,QAAQ,0BAErBC,SAAWC,QAAQC,MACN,OAAbF,WACAA,SAAWJ,kBAAoB,EAG/BK,QAAQE,aAAaH,SAAwB,KAIjDF,eAAeM,QAAQ,oBAAqBC,OAAOL,iBAG7CM,UAAYC,KAAKC,KAAKR,SAAWJ,mBACvCJ,MAAMC,IAAI,uBAAyBa,YAEjB,GAAdA,WAAmBjB,YACnBA,aAEa,GAAbiB,WAAkBhB,WAClBA,YAEa,GAAbgB,WAAkBf,UAClBA,qBApCNC,MAAQ,yEAAa"}

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/util/date-helper",["exports"],(function(_exports){function format_date(d,short){d instanceof Date||("number"==typeof d&&(d*=1e3),d=new Date(d));let monthformat="short";return!0===short?monthformat="numeric":!1===short&&(monthformat="long"),d.toLocaleDateString(document.documentElement.lang,{year:"numeric",month:monthformat,day:"numeric"})}function studyplanDates(plan){let earliestStart=null,latestEnd=null,openEnded=!1;for(const ix in plan.pages){const page=plan.pages[ix],s=new Date(page.startdate);if(page.enddate||(openEnded=!0),(!earliestStart||s<earliestStart)&&(earliestStart=s),page.enddate){const e=new Date(page.enddate);(!latestEnd||e>latestEnd)&&(latestEnd=e)}}return{start:earliestStart,end:openEnded?null:latestEnd}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.add_days=function(datestr,days){const date=new Date(datestr);return function(date){const d=new Date(date);let month=""+(d.getMonth()+1),day=""+d.getDate();const year=d.getFullYear();month.length<2&&(month="0"+month);day.length<2&&(day="0"+day);return[year,month,day].join("-")}(new Date(date.getTime()+864e5*days))},_exports.datespaninfo=function(first,last){first instanceof Date||(first=new Date(first));last instanceof Date||(last=new Date(last));first.setHours(0),first.setMinutes(0),first.setSeconds(0),first.setMilliseconds(0),last.setHours(23),last.setMinutes(59),last.setSeconds(59),last.setMilliseconds(999);const dayspan=Math.round((last-first+1)/864e5),years=Math.floor(dayspan/365),ydaysleft=dayspan%365,weeks=Math.floor(ydaysleft/7);return{first:first,last:last,totaldays:dayspan,years:years,weeks:weeks,days:ydaysleft%7,formatted:{first:format_date(first),last:format_date(last)}}},_exports.format_date=format_date,_exports.format_datetime=function(d,short){d instanceof Date||("number"==typeof d&&(d*=1e3),d=new Date(d));let monthformat="short";!0===short?monthformat="numeric":!1===short&&(monthformat="long");return d.toLocaleDateString(document.documentElement.lang,{year:"numeric",month:monthformat,day:"numeric"})+" "+d.toLocaleTimeString(document.documentElement.lang,{timeStyle:"short"})},_exports.studyplanDates=studyplanDates,_exports.studyplanPageTiming=function(page){const now=(new Date).getTime();if(page.timeless)return"present";const start=new Date(page.startdate),end=page.enddate?new Date(page.enddate):null;return start<now?end&&now>end?"past":"present":"future"},_exports.studyplanTiming=function(plan){const now=(new Date).getTime();if(!plan.pages&&0==plan.pages.length||plan.pages[0]&&plan.pages[0].timeless)return"present";const dates=studyplanDates(plan);return dates.start<now?dates.end&&now>dates.end?"past":"present":"future"}})); define("local_treestudyplan/util/date-helper",["exports"],(function(_exports){function formatDate(d,short){d instanceof Date||("number"==typeof d&&(d*=1e3),d=new Date(d));let monthformat="short";return!0===short?monthformat="numeric":!1===short&&(monthformat="long"),d.toLocaleDateString(document.documentElement.lang,{year:"numeric",month:monthformat,day:"numeric"})}function studyplanDates(plan){let earliestStart=null,latestEnd=null,openEnded=!1;for(const ix in plan.pages){const page=plan.pages[ix],s=new Date(page.startdate);if(page.enddate||(openEnded=!0),(!earliestStart||s<earliestStart)&&(earliestStart=s),page.enddate){const e=new Date(page.enddate);(!latestEnd||e>latestEnd)&&(latestEnd=e)}}return{start:earliestStart,end:openEnded?null:latestEnd}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.addDays=function(datestr,days){const date=new Date(datestr);return function(date){const d=new Date(date);let month=""+(d.getMonth()+1),day=""+d.getDate();const year=d.getFullYear();month.length<2&&(month="0"+month);day.length<2&&(day="0"+day);return[year,month,day].join("-")}(new Date(date.getTime()+864e5*days))},_exports.datespaninfo=function(first,last){first instanceof Date||(first=new Date(first));last instanceof Date||(last=new Date(last));first.setHours(0),first.setMinutes(0),first.setSeconds(0),first.setMilliseconds(0),last.setHours(23),last.setMinutes(59),last.setSeconds(59),last.setMilliseconds(999);const dayspan=Math.round((last-first+1)/864e5),years=Math.floor(dayspan/365),ydaysleft=dayspan%365,weeks=Math.floor(ydaysleft/7);return{first:first,last:last,totaldays:dayspan,years:years,weeks:weeks,days:ydaysleft%7,formatted:{first:formatDate(first),last:formatDate(last)}}},_exports.formatDate=formatDate,_exports.formatDatetime=function(d,short){d instanceof Date||("number"==typeof d&&(d*=1e3),d=new Date(d));let monthformat="short";!0===short?monthformat="numeric":!1===short&&(monthformat="long");return d.toLocaleDateString(document.documentElement.lang,{year:"numeric",month:monthformat,day:"numeric"})+" "+d.toLocaleTimeString(document.documentElement.lang,{timeStyle:"short"})},_exports.studyplanDates=studyplanDates,_exports.studyplanPageTiming=function(page){const now=(new Date).getTime();if(page.timeless)return"present";const start=new Date(page.startdate),end=page.enddate?new Date(page.enddate):null;return start<now?end&&now>end?"past":"present":"future"},_exports.studyplanTiming=function(plan){const now=(new Date).getTime();if(!plan.pages&&0==plan.pages.length||plan.pages[0]&&plan.pages[0].timeless)return"present";const dates=studyplanDates(plan);return dates.start<now?dates.end&&now>dates.end?"past":"present":"future"}}));
//# sourceMappingURL=date-helper.min.js.map //# sourceMappingURL=date-helper.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"file":"debounce.min.js","sources":["../../src/util/debounce.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\n/**\n * Limits consecutive function calls.\n * @param {function} func The function to wrap.\n * @param {int} wait The time limit between function calls.\n * @param {bool} immediate perform the actual function call first rather than after the timout passed.\n * @returns {function} a new function that wraps the debounce.\n */\nfunction debounce(func, wait, immediate) {\n let timeout;\n return function() {\n let context = this, args = arguments;\n let later = function() {\n timeout = null;\n if (!immediate){ func.apply(context, args); }\n };\n let callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow){ func.apply(context, args); }\n };\n}\n\nexport {debounce};"],"names":["func","wait","immediate","timeout","context","this","args","arguments","callNow","clearTimeout","setTimeout","apply"],"mappings":"8JAakBA,KAAMC,KAAMC,eACtBC,eACG,eACCC,QAAUC,KAAMC,KAAOC,UAKvBC,QAAUN,YAAcC,QAC5BM,aAAaN,SACbA,QAAUO,YANE,WACRP,QAAU,KACLD,WAAYF,KAAKW,MAAMP,QAASE,QAIbL,MACxBO,SAAUR,KAAKW,MAAMP,QAASE"} {"version":3,"file":"debounce.min.js","sources":["../../src/util/debounce.js"],"sourcesContent":["/* eslint no-var: \"error\"*/\n/* eslint no-console: \"off\"*/\n/* eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\n/**\n * Limits consecutive function calls.\n * @param {function} func The function to wrap.\n * @param {int} wait The time limit between function calls.\n * @param {bool} immediate perform the actual function call first rather than after the timout passed.\n * @returns {function} a new function that wraps the debounce.\n */\nfunction debounce(func, wait, immediate) {\n let timeout;\n return function() {\n let context = this;\n let args = arguments;\n let later = function() {\n timeout = null;\n if (!immediate) {\n func.apply(context, args);\n }\n };\n let callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) {\n func.apply(context, args);\n }\n };\n}\n\nexport {debounce};"],"names":["func","wait","immediate","timeout","context","this","args","arguments","callNow","clearTimeout","setTimeout","apply"],"mappings":"8JAakBA,KAAMC,KAAMC,eACtBC,eACG,eACCC,QAAUC,KACVC,KAAOC,UAOPC,QAAUN,YAAcC,QAC5BM,aAAaN,SACbA,QAAUO,YARE,WACRP,QAAU,KACLD,WACDF,KAAKW,MAAMP,QAASE,QAKAL,MACxBO,SACAR,KAAKW,MAAMP,QAASE"}

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/util/debugger",["exports","core/config"],(function(_exports,_config){var obj;return Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=function(handle){let output_enabled=_config.default.developerdebug;output_enabled?console.warn(`In development environment. Debugger output enabled for ${handle}`):console.warn(`In production environment. Debugger output disabled for ${handle}`);return{write(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.info.apply(console,args)}},log(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.log.apply(console,args)}},info(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.info.apply(console,args)}},warn(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.warn.apply(console,args)}},error(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.error.apply(console,args)}},time(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.time.apply(console,args)}},timeEnd(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.timeEnd.apply(console,args)}},timeLog(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.timeLog.apply(console,args)}},timeStamp(){if(output_enabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.timeStamp.apply(console,args)}},enable:function(){output_enabled=!0},disable:function(){output_enabled=!1}}},_config=(obj=_config)&&obj.__esModule?obj:{default:obj},_exports.default})); define("local_treestudyplan/util/debugger",["exports","core/config"],(function(_exports,_config){var obj;return Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=function(handle){let outputEnabled=_config.default.developerdebug;outputEnabled?console.warn(`In development environment. Debugger output enabled for ${handle}`):console.warn(`In production environment. Debugger output disabled for ${handle}`);return{write(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.info.apply(console,args)}},log(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.log.apply(console,args)}},info(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.info.apply(console,args)}},warn(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.warn.apply(console,args)}},error(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.error.apply(console,args)}},time(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.time.apply(console,args)}},timeEnd(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.timeEnd.apply(console,args)}},timeLog(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.timeLog.apply(console,args)}},timeStamp(){if(outputEnabled){let args=Array.prototype.slice.call(arguments);args.unshift(handle+": "),console.timeStamp.apply(console,args)}},enable(){outputEnabled=!0},disable(){outputEnabled=!1}}},_config=(obj=_config)&&obj.__esModule?obj:{default:obj},_exports.default}));
//# sourceMappingURL=debugger.min.js.map //# sourceMappingURL=debugger.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"debugger.min.js","sources":["../../src/util/debugger.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint-env es6*/\n\nimport Config from \"core/config\";\n\n/**\n * Start a new debugger\n * @param {*} handle The string to attach to all messages from this debugger\n * @returns Debugger object\n */\nexport default function (handle) {\n let output_enabled = Config.developerdebug;\n if(output_enabled){\n console.warn(`In development environment. Debugger output enabled for ${handle}`);\n } else {\n console.warn(`In production environment. Debugger output disabled for ${handle}`);\n }\n\n return {\n write() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.info.apply(console, args);\n }\n },\n log() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.log.apply(console, args);\n }\n },\n info() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.info.apply(console, args);\n }\n },\n warn() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.warn.apply(console, args);\n }\n },\n error() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.error.apply(console, args);\n }\n },\n time() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.time.apply(console, args);\n }\n },\n timeEnd() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.timeEnd.apply(console, args);\n }\n },\n timeLog() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.timeLog.apply(console, args);\n }\n },\n timeStamp() {\n if (output_enabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.timeStamp.apply(console, args);\n }\n },\n enable: function debugger_enable() {\n output_enabled = true;\n },\n\n disable: function debugger_disable() {\n output_enabled = false;\n }\n };\n\n}\n"],"names":["handle","output_enabled","Config","developerdebug","console","warn","write","args","Array","prototype","slice","call","arguments","unshift","info","apply","log","error","time","timeEnd","timeLog","timeStamp","enable","disable"],"mappings":"kMAWyBA,YACjBC,eAAiBC,gBAAOC,eACzBF,eACCG,QAAQC,KAAM,2DAA0DL,UAExEI,QAAQC,KAAM,2DAA0DL,gBAGrE,CACHM,WACQL,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQU,KAAKC,MAAMX,QAASG,QAGpCS,SACQf,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQY,IAAID,MAAMX,QAASG,QAGnCO,UACQb,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQU,KAAKC,MAAMX,QAASG,QAGpCF,UACQJ,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQC,KAAKU,MAAMX,QAASG,QAGpCU,WACQhB,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQa,MAAMF,MAAMX,QAASG,QAGrCW,UACQjB,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQc,KAAKH,MAAMX,QAASG,QAGpCY,aACQlB,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQe,QAAQJ,MAAMX,QAASG,QAGvCa,aACQnB,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQgB,QAAQL,MAAMX,QAASG,QAGvCc,eACQpB,eAAgB,KACZM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQiB,UAAUN,MAAMX,QAASG,QAGzCe,OAAQ,WACJrB,gBAAiB,GAGrBsB,QAAS,WACLtB,gBAAiB"} {"version":3,"file":"debugger.min.js","sources":["../../src/util/debugger.js"],"sourcesContent":["/* eslint no-var: \"error\"*/\n/* eslint no-console: \"off\"*/\n/* eslint-env es6*/\n\nimport Config from \"core/config\";\n\n/**\n * Start a new debugger\n * @param {*} handle The string to attach to all messages from this debugger\n * @returns {object} Debugger object\n */\nexport default function(handle) {\n let outputEnabled = Config.developerdebug;\n if (outputEnabled) {\n console.warn(`In development environment. Debugger output enabled for ${handle}`);\n } else {\n console.warn(`In production environment. Debugger output disabled for ${handle}`);\n }\n\n return {\n write() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.info.apply(console, args);\n }\n },\n log() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.log.apply(console, args);\n }\n },\n info() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.info.apply(console, args);\n }\n },\n warn() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.warn.apply(console, args);\n }\n },\n error() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.error.apply(console, args);\n }\n },\n time() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.time.apply(console, args);\n }\n },\n timeEnd() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.timeEnd.apply(console, args);\n }\n },\n timeLog() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.timeLog.apply(console, args);\n }\n },\n timeStamp() {\n if (outputEnabled) {\n let args = Array.prototype.slice.call(arguments);\n args.unshift(handle + \": \");\n console.timeStamp.apply(console, args);\n }\n },\n enable() {\n outputEnabled = true;\n },\n disable() {\n outputEnabled = false;\n }\n };\n\n}\n"],"names":["handle","outputEnabled","Config","developerdebug","console","warn","write","args","Array","prototype","slice","call","arguments","unshift","info","apply","log","error","time","timeEnd","timeLog","timeStamp","enable","disable"],"mappings":"kMAWwBA,YAChBC,cAAgBC,gBAAOC,eACvBF,cACAG,QAAQC,KAAM,2DAA0DL,UAExEI,QAAQC,KAAM,2DAA0DL,gBAGrE,CACHM,WACQL,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQU,KAAKC,MAAMX,QAASG,QAGpCS,SACQf,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQY,IAAID,MAAMX,QAASG,QAGnCO,UACQb,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQU,KAAKC,MAAMX,QAASG,QAGpCF,UACQJ,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQC,KAAKU,MAAMX,QAASG,QAGpCU,WACQhB,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQa,MAAMF,MAAMX,QAASG,QAGrCW,UACQjB,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQc,KAAKH,MAAMX,QAASG,QAGpCY,aACQlB,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQe,QAAQJ,MAAMX,QAASG,QAGvCa,aACQnB,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQgB,QAAQL,MAAMX,QAASG,QAGvCc,eACQpB,cAAe,KACXM,KAAOC,MAAMC,UAAUC,MAAMC,KAAKC,WACtCL,KAAKM,QAAQb,OAAS,MACtBI,QAAQiB,UAAUN,MAAMX,QAASG,QAGzCe,SACIrB,eAAgB,GAEpBsB,UACItB,eAAgB"}

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/util/fittext-vue",["exports","./css-calc","./fitty","./textfit"],(function(_exports,_cssCalc,_fitty,_textfit){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_fitty=(obj=_fitty)&&obj.__esModule?obj:{default:obj};var _default={install(Vue){Vue.component("fittext",{props:{maxsize:{type:String,default:"512px"},minsize:{type:String,default:"10px"},vertical:Boolean,singleline:Boolean,dynamic:Boolean},data:()=>({resizeObserver:null,mutationObserver:null}),computed:{rootStyle(){return this.vertical?"height: 100%;":"width: 100%;"}},methods:{},mounted(){(0,_fitty.default)(this.$refs.text,{minSize:(0,_cssCalc.calc)(this.minsize),maxSize:(0,_cssCalc.calc)(this.maxsize),vertical:this.vertical,multiline:!this.singleline})},unmounted(){this.mutationObserver&&this.mutationObserver.disconnect(),this.resizeObserver&&this.resizeObserver.disconnect()},template:"\n <div class='q-fittext' ref='container' :style=\"rootStyle + ';min-height:0;min-width:0;'\">\n <span :style=\"'display:block; white-space:'+ ((singleline)?'nowrap':'normal')+';' + rootStyle\" class='q-fittext-text' ref='text'><slot></slot>\n </span\n ></div>\n "})}};return _exports.default=_default,_exports.default})); define("local_treestudyplan/util/fittext-vue",["exports","./css-calc","./fitty"],(function(_exports,_cssCalc,_fitty){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_fitty=(obj=_fitty)&&obj.__esModule?obj:{default:obj};var _default={install(Vue){Vue.component("fittext",{props:{maxsize:{type:String,default:"512px"},minsize:{type:String,default:"10px"},vertical:Boolean,singleline:Boolean,dynamic:Boolean},data:()=>({resizeObserver:null,mutationObserver:null}),computed:{rootStyle(){return this.vertical?"height: 100%;":"width: 100%;"}},methods:{},mounted(){(0,_fitty.default)(this.$refs.text,{minSize:(0,_cssCalc.calc)(this.minsize),maxSize:(0,_cssCalc.calc)(this.maxsize),vertical:this.vertical,multiline:!this.singleline})},unmounted(){this.mutationObserver&&this.mutationObserver.disconnect(),this.resizeObserver&&this.resizeObserver.disconnect()},template:"\n <div class='q-fittext' ref='container' :style=\"rootStyle + ';min-height:0;min-width:0;'\">\n <span :style=\"'display:block; white-space:'+ ((singleline)?'nowrap':'normal')+';' + rootStyle\" class='q-fittext-text' ref='text'><slot></slot>\n </span\n ></div>\n "})}};return _exports.default=_default,_exports.default}));
//# sourceMappingURL=fittext-vue.min.js.map //# sourceMappingURL=fittext-vue.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"fittext-vue.min.js","sources":["../../src/util/fittext-vue.js"],"sourcesContent":["/*eslint no-unused-vars: warn */\n/*eslint max-len: [\"error\", { \"code\": 160 }] */\n/*eslint-disable no-trailing-spaces */\n/*eslint-env es6*/\n\nimport {calc} from \"./css-calc\";\nimport fitty from \"./fitty\";\nimport {textFit} from \"./textfit\";\n\nexport default {\n install(Vue/*,options*/){\n Vue.component('fittext',{\n props: {\n maxsize: {\n type: String,\n default: \"512px\",\n },\n minsize: {\n type: String,\n default: \"10px\",\n },\n vertical: Boolean,\n singleline: Boolean,\n dynamic: Boolean,\n },\n data() {\n return {\n resizeObserver: null,\n mutationObserver: null,\n };\n },\n computed: {\n rootStyle() {\n if (this.vertical) {\n return `height: 100%;`;\n } else {\n return `width: 100%;`;\n }\n }\n },\n methods: {\n },\n mounted() {\n const self = this;\n // If the content could change after initial presentation,\n // Use the fitty method. It is slightly worse on multiline horizontal text,\n // but better supports content that can change later on.\n fitty(self.$refs.text,\n {\n minSize: calc(self.minsize),\n maxSize: calc(self.maxsize),\n vertical: self.vertical,\n multiline: !self.singleline,\n });\n },\n unmounted() {\n if(this.mutationObserver) {\n this.mutationObserver.disconnect();\n }\n if(this.resizeObserver) {\n this.resizeObserver.disconnect();\n }\n },\n template: `\n <div class='q-fittext' ref='container' :style=\"rootStyle + ';min-height:0;min-width:0;'\">\n <span :style=\"'display:block; white-space:'+ ((singleline)?'nowrap':'normal')+';' + rootStyle\" class='q-fittext-text' ref='text'><slot></slot>\n </span\n ></div>\n `,\n });\n },\n};"],"names":["install","Vue","component","props","maxsize","type","String","default","minsize","vertical","Boolean","singleline","dynamic","data","resizeObserver","mutationObserver","computed","rootStyle","this","methods","mounted","$refs","text","minSize","maxSize","multiline","unmounted","disconnect","template"],"mappings":"qSASe,CACXA,QAAQC,KACJA,IAAIC,UAAU,UAAU,CACxBC,MAAO,CACHC,QAAS,CACLC,KAAMC,OACNC,QAAS,SAEbC,QAAS,CACLH,KAAMC,OACNC,QAAS,QAEbE,SAAUC,QACVC,WAAYD,QACZE,QAASF,SAEbG,KAAI,KACO,CACHC,eAAgB,KAChBC,iBAAkB,OAG1BC,SAAU,CACNC,mBACQC,KAAKT,SACG,gBAEA,iBAIpBU,QAAS,GAETC,6BACiBF,KAIFG,MAAMC,KACb,CACAC,SAAS,iBANAL,KAMUV,SACnBgB,SAAS,iBAPAN,KAOUd,SACnBK,SARSS,KAQMT,SACfgB,WATSP,KASQP,cAGzBe,YACOR,KAAKH,uBACCA,iBAAiBY,aAEvBT,KAAKJ,qBACCA,eAAea,cAG5BC,SAAW"} {"version":3,"file":"fittext-vue.min.js","sources":["../../src/util/fittext-vue.js"],"sourcesContent":["/* eslint no-unused-vars: warn */\n/* eslint max-len: [\"error\", { \"code\": 160 }] */\n/* eslint-disable no-trailing-spaces */\n/* eslint capitalized-comments: \"off\" */\n/* eslint-env es6*/\n\nimport {calc} from \"./css-calc\";\nimport fitty from \"./fitty\";\n\nexport default {\n install(Vue/* ,options */) {\n Vue.component('fittext', {\n props: {\n maxsize: {\n type: String,\n 'default': \"512px\",\n },\n minsize: {\n type: String,\n 'default': \"10px\",\n },\n vertical: Boolean,\n singleline: Boolean,\n dynamic: Boolean,\n },\n data() {\n return {\n resizeObserver: null,\n mutationObserver: null,\n };\n },\n computed: {\n rootStyle() {\n if (this.vertical) {\n return `height: 100%;`;\n } else {\n return `width: 100%;`;\n }\n }\n },\n methods: {\n },\n mounted() {\n const self = this;\n // If the content could change after initial presentation,\n // Use the fitty method. It is slightly worse on multiline horizontal text,\n // but better supports content that can change later on.\n fitty(self.$refs.text,\n {\n minSize: calc(self.minsize),\n maxSize: calc(self.maxsize),\n vertical: self.vertical,\n multiline: !self.singleline,\n });\n },\n unmounted() {\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n }\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n }\n },\n template: `\n <div class='q-fittext' ref='container' :style=\"rootStyle + ';min-height:0;min-width:0;'\">\n <span :style=\"'display:block; white-space:'+ ((singleline)?'nowrap':'normal')+';' + rootStyle\" class='q-fittext-text' ref='text'><slot></slot>\n </span\n ></div>\n `,\n });\n },\n};"],"names":["install","Vue","component","props","maxsize","type","String","minsize","vertical","Boolean","singleline","dynamic","data","resizeObserver","mutationObserver","computed","rootStyle","this","methods","mounted","$refs","text","minSize","maxSize","multiline","unmounted","disconnect","template"],"mappings":"gRASe,CACXA,QAAQC,KACJA,IAAIC,UAAU,UAAW,CACzBC,MAAO,CACHC,QAAS,CACLC,KAAMC,eACK,SAEfC,QAAS,CACLF,KAAMC,eACK,QAEfE,SAAUC,QACVC,WAAYD,QACZE,QAASF,SAEbG,KAAI,KACO,CACHC,eAAgB,KAChBC,iBAAkB,OAG1BC,SAAU,CACNC,mBACQC,KAAKT,SACG,gBAEA,iBAIpBU,QAAS,GAETC,6BACiBF,KAIFG,MAAMC,KACb,CACAC,SAAS,iBANAL,KAMUV,SACnBgB,SAAS,iBAPAN,KAOUb,SACnBI,SARSS,KAQMT,SACfgB,WATSP,KASQP,cAGzBe,YACQR,KAAKH,uBACAA,iBAAiBY,aAEtBT,KAAKJ,qBACAA,eAAea,cAG5BC,SAAW"}

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/util/formfields",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.text_integer=function(id){let unsigned=arguments.length>1&&void 0!==arguments[1]&&arguments[1],nonzero=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const element=document.getElementById(id);element&&element.addEventListener("input",(()=>{var val=element.value;if(""!=val)return!(isNaN(val)&&(unsigned||"-"!=val)||unsigned&&val<0||nonzero&&0==val)||(unsigned?(element.value=val.replace(/[^0-9]/g,""),nonzero&&0==val&&(element.value="")):element.value=val.replace(/[^0-9-]/g,"").replace(/(.{1})(-)/g,"$1"),!1)}))}})); define("local_treestudyplan/util/formfields",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.textInteger=function(id){let unsigned=arguments.length>1&&void 0!==arguments[1]&&arguments[1],nonzero=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const element=document.getElementById(id);element&&element.addEventListener("input",(()=>{var val=element.value;return""!=val?!(isNaN(val)&&(unsigned||"-"!=val)||unsigned&&val<0||nonzero&&0==val)||(unsigned?(element.value=val.replace(/[^0-9]/g,""),nonzero&&0==val&&(element.value="")):element.value=val.replace(/[^0-9-]/g,"").replace(/(.{1})(-)/g,"$1"),!1):null}))}}));
//# sourceMappingURL=formfields.min.js.map //# sourceMappingURL=formfields.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"formfields.min.js","sources":["../../src/util/formfields.js"],"sourcesContent":["/**\n * convert a text field into an integer only text field\n * @param {string} id The Id of the form field\n * @param {bool} unsigned Allow only unsigned values\n * @param {bool} nonzero Do not allow zero values\n */\nexport function text_integer(id,unsigned=false,nonzero=false){\n const element = document.getElementById(id);\n\n if (element) {\n element.addEventListener(\"input\",() => {\n var val = element.value;\n if (val != '') {\n if ((isNaN(val) && !(!unsigned && val == '-')) || (unsigned && val < 0) || (nonzero && val == 0)) {\n // Set input value empty\n if (unsigned) {\n element.value = val.replace(/[^0-9]/g,'');\n if (nonzero && val == 0) {\n element.value = '';\n }\n } else {\n element.value = val.replace(/[^0-9-]/g,'').replace(/(.{1})(-)/g,'$1');\n }\n return false;\n } else {\n return true;\n }\n }\n });\n }\n}"],"names":["id","unsigned","nonzero","element","document","getElementById","addEventListener","val","value","isNaN","replace"],"mappings":"oKAM6BA,QAAGC,iEAAeC,sEACrCC,QAAUC,SAASC,eAAeL,IAEpCG,SACAA,QAAQG,iBAAiB,SAAQ,SACzBC,IAAMJ,QAAQK,SACP,IAAPD,YACKE,MAAMF,OAAWN,UAAmB,KAAPM,MAAiBN,UAAYM,IAAM,GAAOL,SAAkB,GAAPK,OAE/EN,UACAE,QAAQK,MAAQD,IAAIG,QAAQ,UAAU,IAClCR,SAAkB,GAAPK,MACXJ,QAAQK,MAAQ,KAGpBL,QAAQK,MAAQD,IAAIG,QAAQ,WAAW,IAAIA,QAAQ,aAAa,OAE7D"} {"version":3,"file":"formfields.min.js","sources":["../../src/util/formfields.js"],"sourcesContent":["/**\n * Convert a text field into an integer only text field\n * @param {string} id The Id of the form field\n * @param {bool} unsigned Allow only unsigned values\n * @param {bool} nonzero Do not allow zero values\n */\nexport function textInteger(id, unsigned = false, nonzero = false) {\n const element = document.getElementById(id);\n\n if (element) {\n element.addEventListener(\"input\", () => {\n var val = element.value;\n if (val != '') {\n if ((isNaN(val) && !(!unsigned && val == '-')) || (unsigned && val < 0) || (nonzero && val == 0)) {\n // Set input value empty\n if (unsigned) {\n element.value = val.replace(/[^0-9]/g, '');\n if (nonzero && val == 0) {\n element.value = '';\n }\n } else {\n element.value = val.replace(/[^0-9-]/g, '').replace(/(.{1})(-)/g, '$1');\n }\n return false;\n } else {\n return true;\n }\n }\n return null;\n });\n }\n}"],"names":["id","unsigned","nonzero","element","document","getElementById","addEventListener","val","value","isNaN","replace"],"mappings":"mKAM4BA,QAAIC,iEAAkBC,sEACxCC,QAAUC,SAASC,eAAeL,IAEpCG,SACAA,QAAQG,iBAAiB,SAAS,SAC1BC,IAAMJ,QAAQK,YACP,IAAPD,MACKE,MAAMF,OAAWN,UAAmB,KAAPM,MAAiBN,UAAYM,IAAM,GAAOL,SAAkB,GAAPK,OAE/EN,UACAE,QAAQK,MAAQD,IAAIG,QAAQ,UAAW,IACnCR,SAAkB,GAAPK,MACXJ,QAAQK,MAAQ,KAGpBL,QAAQK,MAAQD,IAAIG,QAAQ,WAAY,IAAIA,QAAQ,aAAc,OAE/D,GAKR,IAAP"}

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/util/premium",["exports","core/ajax","core/notification"],(function(_exports,_ajax,_notification){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.premiumenabled=function(){const premium=premiumstatus();return!premium||!!premium.enabled},_notification=(obj=_notification)&&obj.__esModule?obj:{default:obj};let premiumstatus_cache=null;function premiumstatus(){return premiumstatus_cache||(0,_ajax.call)([{methodname:"local_treestudyplan_premiumstatus",args:{}}])[0].then((function(response){premiumstatus_cache=response})).catch(_notification.default.exception),premiumstatus_cache}premiumstatus()})); define("local_treestudyplan/util/premium",["exports","core/ajax","core/notification"],(function(_exports,_ajax,_notification){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.premiumenabled=function(){const premium=premiumstatus();return!premium||!!premium.enabled},_notification=(obj=_notification)&&obj.__esModule?obj:{default:obj};let premiumstatusCache=null;function premiumstatus(){return premiumstatusCache||(0,_ajax.call)([{methodname:"local_treestudyplan_premiumstatus",args:{}}])[0].then((response=>{premiumstatusCache=response})).catch(_notification.default.exception),premiumstatusCache}premiumstatus()}));
//# sourceMappingURL=premium.min.js.map //# sourceMappingURL=premium.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"premium.min.js","sources":["../../src/util/premium.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint-env es6*/\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\n// Prepare default value.\nlet premiumstatus_cache = null;\n\n/**\n * Check if premium status is enabled.\n * @returns {Bool} True/False\n */\nexport function premiumenabled (){\n const premium = premiumstatus();\n if (premium) {\n return (premium.enabled)?true:false;\n } else {\n return true; // Temporarily return true, that is easier than going full async.\n }\n}\n\n/**\n * Get premium status object\n * @returns {Object} The premium status object\n */\nfunction premiumstatus() {\n if (!premiumstatus_cache) {\n // Retrieve premium status if needed.\n call([{\n methodname: 'local_treestudyplan_premiumstatus',\n args: {}\n }])[0].then(function(response){\n premiumstatus_cache = response;\n }).catch(notification.exception);\n }\n return premiumstatus_cache;\n}\n\n// Preload premium status.\npremiumstatus();"],"names":["premium","premiumstatus","enabled","premiumstatus_cache","methodname","args","then","response","catch","notification","exception"],"mappings":"uOAcUA,QAAUC,uBACZD,WACQA,QAAQE,iFATpBC,oBAAsB,cAmBjBF,uBACAE,oCAEI,CAAC,CACFC,WAAY,oCACZC,KAAM,MACN,GAAGC,MAAK,SAASC,UACjBJ,oBAAsBI,YACvBC,MAAMC,sBAAaC,WAEnBP,oBAIXF"} {"version":3,"file":"premium.min.js","sources":["../../src/util/premium.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint-env es6*/\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\n// Prepare default value.\nlet premiumstatusCache = null;\n\n/**\n * Check if premium status is enabled.\n * @returns {Bool} True/False\n */\nexport function premiumenabled() {\n const premium = premiumstatus();\n if (premium) {\n return (premium.enabled) ? true : false;\n } else {\n return true; // Temporarily return true, that is easier than going full async.\n }\n}\n\n/**\n * Get premium status object\n * @returns {Object} The premium status object\n */\nfunction premiumstatus() {\n if (!premiumstatusCache) {\n // Retrieve premium status if needed.\n call([{\n methodname: 'local_treestudyplan_premiumstatus',\n args: {}\n }])[0].then((response) => {\n premiumstatusCache = response;\n return;\n }).catch(notification.exception);\n }\n return premiumstatusCache;\n}\n\n// Preload premium status.\npremiumstatus();"],"names":["premium","premiumstatus","enabled","premiumstatusCache","methodname","args","then","response","catch","notification","exception"],"mappings":"uOAcUA,QAAUC,uBACZD,WACQA,QAAQE,iFATpBC,mBAAqB,cAmBhBF,uBACAE,mCAEI,CAAC,CACFC,WAAY,oCACZC,KAAM,MACN,GAAGC,MAAMC,WACTJ,mBAAqBI,YAEtBC,MAAMC,sBAAaC,WAEnBP,mBAIXF"}

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/util/settings",["exports","core/ajax","core/notification"],(function(_exports,_ajax,_notification){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.settings=function(key){const settings=loadsettings();return key in settings?settings[key]:null},_notification=(obj=_notification)&&obj.__esModule?obj:{default:obj};let settingcache=null;function loadsettings(){return settingcache||(0,_ajax.call)([{methodname:"local_treestudyplan_getsettings",args:{}}])[0].then((function(response){settingcache=response})).catch(_notification.default.exception),settingcache}loadsettings()})); define("local_treestudyplan/util/settings",["exports","core/ajax","core/notification"],(function(_exports,_ajax,_notification){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.settings=function(key){const settings=loadsettings();return key in settings?settings[key]:null},_notification=(obj=_notification)&&obj.__esModule?obj:{default:obj};let settingcache=null;function loadsettings(){return settingcache||(0,_ajax.call)([{methodname:"local_treestudyplan_getsettings",args:{}}])[0].then((response=>{settingcache=response})).catch(_notification.default.exception),settingcache}loadsettings()}));
//# sourceMappingURL=settings.min.js.map //# sourceMappingURL=settings.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"settings.min.js","sources":["../../src/util/settings.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint-env es6*/\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\n// Prepare default value.\nlet settingcache = null;\n\n/**\n * Check if premium status is enabled.\n * @param {String} key\n * @returns {}\n */\nexport function settings ( key ){\n const settings = loadsettings();\n if ( key in settings ) {\n return settings[key];\n } else {\n return null;\n }\n}\n\n/**\n * Get settings from server or cache\n * @returns {Object} The settings object\n */\nfunction loadsettings() {\n if (!settingcache) {\n // Retrieve setting cache if needed.\n call([{\n methodname: 'local_treestudyplan_getsettings',\n args: {}\n }])[0].then(function(response){\n settingcache = response;\n }).catch(notification.exception);\n }\n return settingcache;\n}\n\n// Preload premium status.\nloadsettings();"],"names":["key","settings","loadsettings","settingcache","methodname","args","then","response","catch","notification","exception"],"mappings":"0NAc2BA,WACjBC,SAAWC,sBACZF,OAAOC,SACDA,SAASD,KAET,8EAZXG,aAAe,cAoBVD,sBACAC,6BAEI,CAAC,CACFC,WAAY,kCACZC,KAAM,MACN,GAAGC,MAAK,SAASC,UACjBJ,aAAeI,YAChBC,MAAMC,sBAAaC,WAEnBP,aAIXD"} {"version":3,"file":"settings.min.js","sources":["../../src/util/settings.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint-env es6*/\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\n// Prepare default value.\nlet settingcache = null;\n\n/**\n * Check if premium status is enabled.\n * @param {String} key\n * @returns {*}\n */\nexport function settings(key) {\n const settings = loadsettings();\n if (key in settings) {\n return settings[key];\n } else {\n return null;\n }\n}\n\n/**\n * Get settings from server or cache\n * @returns {Object} The settings object\n */\nfunction loadsettings() {\n if (!settingcache) {\n // Retrieve setting cache if needed.\n call([{\n methodname: 'local_treestudyplan_getsettings',\n args: {}\n }])[0].then((response) => {\n settingcache = response;\n return;\n }).catch(notification.exception);\n }\n return settingcache;\n}\n\n// Preload premium status.\nloadsettings();"],"names":["key","settings","loadsettings","settingcache","methodname","args","then","response","catch","notification","exception"],"mappings":"0NAcyBA,WACfC,SAAWC,sBACbF,OAAOC,SACAA,SAASD,KAET,8EAZXG,aAAe,cAoBVD,sBACAC,6BAEI,CAAC,CACFC,WAAY,kCACZC,KAAM,MACN,GAAGC,MAAMC,WACTJ,aAAeI,YAEhBC,MAAMC,sBAAaC,WAEnBP,aAIXD"}

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/util/string-helper",["exports","core/str"],(function(_exports,_str){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.load_stringkeys=function(string_keys,plugin){void 0===plugin&&(plugin="local_treestudyplan");for(let idx in string_keys){let stringkeys=[];for(const i in string_keys[idx]){let parts=string_keys[idx][i].textkey.split("$"),identifier=parts[0],component=parts.length>1?parts[1]:plugin;stringkeys.push({key:identifier,component:component})}getstr_func(stringkeys).then((function(strings){for(const i in strings){const s=strings[i];string_keys[idx][i].text=s}}))}return string_keys},_exports.load_strings=function(strings,plugin){void 0===plugin&&(plugin="local_treestudyplan");for(let idx in strings){let stringkeys=[];for(const handle in strings[idx]){let parts=strings[idx][handle].split(/[$@]/),identifier=parts[0],component=parts.length>1?parts[1]:plugin;stringkeys.push({key:identifier,component:component})}getstr_func(stringkeys).then((function(str){let i=0;for(const handle in strings[idx])strings[idx][handle]=str[i],i++}))}return strings},_exports.strformat=function(str,values){return str.replace(/\{(\w+)\}/g,((m,m1)=>m1&&values.hasOwnProperty(m1)?values[m1]:m))};const getstr_func=void 0!==_str.getStrings?_str.getStrings:_str.get_strings})); define("local_treestudyplan/util/string-helper",["exports","core/str","./debugger"],(function(_exports,_str,_debugger){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.loadStringKeys=function(string_keys,plugin){void 0===plugin&&(plugin="local_treestudyplan");for(let idx in string_keys){let stringkeys=[];for(const i in string_keys[idx]){let parts=string_keys[idx][i].textkey.split("$"),identifier=parts[0],component=parts.length>1?parts[1]:plugin;stringkeys.push({key:identifier,component:component})}getstrFunc(stringkeys).then((function(strings){for(const i in strings){const s=strings[i];string_keys[idx][i].text=s}})).catch((x=>{debug.warn(x)}))}return string_keys},_exports.loadStrings=function(strings,plugin){void 0===plugin&&(plugin="local_treestudyplan");for(let idx in strings){let stringkeys=[];for(const handle in strings[idx]){let parts=strings[idx][handle].split(/[$@]/),identifier=parts[0],component=parts.length>1?parts[1]:plugin;stringkeys.push({key:identifier,component:component})}getstrFunc(stringkeys).then((function(str){let i=0;for(const handle in strings[idx])strings[idx][handle]=str[i],i++})).catch((x=>{debug.warn(x)}))}return strings},_exports.strformat=function(str,values){return str.replace(/\{(\w+)\}/g,((m,m1)=>m1&&values.hasOwnProperty(m1)?values[m1]:m))};let debug=new(_debugger=(obj=_debugger)&&obj.__esModule?obj:{default:obj}).default("string-helper");const getstrFunc=void 0!==_str.getStrings?_str.getStrings:_str.get_strings}));
//# sourceMappingURL=string-helper.min.js.map //# sourceMappingURL=string-helper.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"string-helper.min.js","sources":["../../src/util/string-helper.js"],"sourcesContent":["import {get_strings} from 'core/str';\nimport {getStrings} from 'core/str';\n\n/* Determine the proper getstrings function to use (MDL4.3+ recommends use of getStrings, which is jquery independent) */\nconst getstr_func = (getStrings !== undefined)?getStrings:get_strings;\n\n/**\n * Load the translation of strings from a strings object\n * @param {Object} strings The map of strings\n * @param {String} plugin Name of plugin to load for by default (leave empty for 'local_treestudyplan')\n * @returns {Object} The map with strings loaded in\n */\nexport function load_strings(strings,plugin){\n if (plugin === undefined) {\n plugin = 'local_treestudyplan';\n }\n for(let idx in strings){\n let stringkeys = [];\n for(const handle in strings[idx]){\n const key = strings[idx][handle];\n let parts = key.split(/[$@]/);\n let identifier = parts[0];\n let component = (parts.length > 1)?parts[1]:plugin;\n stringkeys.push({ key: identifier, component: component});\n }\n getstr_func(stringkeys).then(function(str){\n let i = 0;\n for(const handle in strings[idx]){\n strings[idx][handle] = str[i];\n i++;\n }\n });\n }\n\n return strings;\n}\n\n/**\n * Load the translation of strings from a strings object based on keys\n * Used for loading values for a drop down menu or the like\n * @param {Object} string_keys The map of stringkeys\n * @param {String} plugin Name of plugin to load for by default (leave empty for 'local_treestudyplan')\n * @returns {Object} The map with strings loaded in\n */\nexport function load_stringkeys(string_keys,plugin){\n if (plugin === undefined) {\n plugin = 'local_treestudyplan';\n }\n for(let idx in string_keys){\n // Get text strings for condition settings\n let stringkeys = [];\n for(const i in string_keys[idx]){\n const key = string_keys[idx][i].textkey;\n let parts = key.split(\"$\");\n let identifier = parts[0];\n let component = (parts.length > 1)?parts[1]:plugin;\n stringkeys.push({ key: identifier, component: component});\n }\n getstr_func(stringkeys).then(function(strings){\n for(const i in strings) {\n const s = strings[i];\n const l = string_keys[idx][i];\n l.text = s;\n }\n });\n }\n return string_keys;\n}\n\n/**\n * String formatting function - replaces {name} in string by value of same key in values parameter\n * @param {string} str String t\n * @param {object} values Object containing keys to replace {key} strings with\n * @returns Formatted string\n */\nexport function strformat(str,values) {\n return str.replace(/\\{(\\w+)\\}/g, (m, m1) => {\n if (m1 && values.hasOwnProperty(m1)) {\n return values[m1];\n } else {\n return m;\n }\n });\n}"],"names":["string_keys","plugin","undefined","idx","stringkeys","i","parts","textkey","split","identifier","component","length","push","key","getstr_func","then","strings","s","text","handle","str","values","replace","m","m1","hasOwnProperty","getStrings","get_strings"],"mappings":"0LA4CgCA,YAAYC,aACzBC,IAAXD,SACAA,OAAS,2BAET,IAAIE,OAAOH,YAAY,KAEnBI,WAAa,OACb,MAAMC,KAAML,YAAYG,KAAK,KAEzBG,MADQN,YAAYG,KAAKE,GAAGE,QAChBC,MAAM,KAClBC,WAAaH,MAAM,GACnBI,UAAaJ,MAAMK,OAAS,EAAGL,MAAM,GAAGL,OAC5CG,WAAWQ,KAAK,CAAEC,IAAKJ,WAAYC,UAAWA,YAElDI,YAAYV,YAAYW,MAAK,SAASC,aAC9B,MAAMX,KAAKW,QAAS,OACdC,EAAID,QAAQX,GACRL,YAAYG,KAAKE,GACzBa,KAAOD,aAIdjB,4CAtDkBgB,QAAQf,aAClBC,IAAXD,SACAA,OAAS,2BAET,IAAIE,OAAOa,QAAQ,KACfZ,WAAa,OACb,MAAMe,UAAWH,QAAQb,KAAK,KAE1BG,MADQU,QAAQb,KAAKgB,QACTX,MAAM,QAClBC,WAAaH,MAAM,GACnBI,UAAaJ,MAAMK,OAAS,EAAGL,MAAM,GAAGL,OAC5CG,WAAWQ,KAAK,CAAEC,IAAKJ,WAAYC,UAAWA,YAElDI,YAAYV,YAAYW,MAAK,SAASK,SAC9Bf,EAAI,MACJ,MAAMc,UAAUH,QAAQb,KACxBa,QAAQb,KAAKgB,QAAUC,IAAIf,GAC3BA,cAKLW,qCAyCeI,IAAIC,eACnBD,IAAIE,QAAQ,cAAc,CAACC,EAAGC,KAC7BA,IAAMH,OAAOI,eAAeD,IACrBH,OAAOG,IAEPD,WA5EbT,iBAA8BZ,IAAfwB,gBAA0BA,gBAAWC"} {"version":3,"file":"string-helper.min.js","sources":["../../src/util/string-helper.js"],"sourcesContent":["/* eslint camelcase: \"off\" */\nimport {get_strings} from 'core/str';\nimport {getStrings} from 'core/str';\nimport Debugger from './debugger';\nlet debug = new Debugger(\"string-helper\");\n\n/* Determine the proper getstrings function to use (MDL4.3+ recommends use of getStrings, which is jquery independent) */\nconst getstrFunc = (getStrings !== undefined) ? getStrings : get_strings;\n\n/**\n * Load the translation of strings from a strings object\n * @param {Object} strings The map of strings\n * @param {String} plugin Name of plugin to load for by default (leave empty for 'local_treestudyplan')\n * @returns {Object} The map with strings loaded in\n */\nexport function loadStrings(strings, plugin) {\n if (plugin === undefined) {\n plugin = 'local_treestudyplan';\n }\n for (let idx in strings) {\n let stringkeys = [];\n for (const handle in strings[idx]) {\n const key = strings[idx][handle];\n let parts = key.split(/[$@]/);\n let identifier = parts[0];\n let component = (parts.length > 1) ? parts[1] : plugin;\n stringkeys.push({key: identifier, component: component});\n }\n getstrFunc(stringkeys).then(function(str) {\n let i = 0;\n for (const handle in strings[idx]) {\n strings[idx][handle] = str[i];\n i++;\n }\n return;\n }).catch((x) => {\n debug.warn(x);\n });\n }\n\n return strings;\n}\n\n/**\n * Load the translation of strings from a strings object based on keys\n * Used for loading values for a drop down menu or the like\n * @param {Object} string_keys The map of stringkeys\n * @param {String} plugin Name of plugin to load for by default (leave empty for 'local_treestudyplan')\n * @returns {Object} The map with strings loaded in\n */\nexport function loadStringKeys(string_keys, plugin) {\n if (plugin === undefined) {\n plugin = 'local_treestudyplan';\n }\n for (let idx in string_keys) {\n // Get text strings for condition settings\n let stringkeys = [];\n for (const i in string_keys[idx]) {\n const key = string_keys[idx][i].textkey;\n let parts = key.split(\"$\");\n let identifier = parts[0];\n let component = (parts.length > 1) ? parts[1] : plugin;\n stringkeys.push({key: identifier, component: component});\n }\n getstrFunc(stringkeys).then(function(strings) {\n for (const i in strings) {\n const s = strings[i];\n const l = string_keys[idx][i];\n l.text = s;\n }\n return;\n }).catch((x) => {\n debug.warn(x);\n });\n }\n return string_keys;\n}\n\n/**\n * String formatting function - replaces {name} in string by value of same key in values parameter\n * @param {string} str String t\n * @param {object} values Object containing keys to replace {key} strings with\n * @returns {string} Formatted string\n */\nexport function strformat(str, values) {\n return str.replace(/\\{(\\w+)\\}/g, (m, m1) => {\n if (m1 && values.hasOwnProperty(m1)) {\n return values[m1];\n } else {\n return m;\n }\n });\n}"],"names":["string_keys","plugin","undefined","idx","stringkeys","i","parts","textkey","split","identifier","component","length","push","key","getstrFunc","then","strings","s","text","catch","x","debug","warn","handle","str","values","replace","m","m1","hasOwnProperty","getStrings","get_strings"],"mappings":"wNAkD+BA,YAAaC,aACzBC,IAAXD,SACAA,OAAS,2BAER,IAAIE,OAAOH,YAAa,KAErBI,WAAa,OACZ,MAAMC,KAAKL,YAAYG,KAAM,KAE1BG,MADQN,YAAYG,KAAKE,GAAGE,QAChBC,MAAM,KAClBC,WAAaH,MAAM,GACnBI,UAAaJ,MAAMK,OAAS,EAAKL,MAAM,GAAKL,OAChDG,WAAWQ,KAAK,CAACC,IAAKJ,WAAYC,UAAWA,YAEjDI,WAAWV,YAAYW,MAAK,SAASC,aAC5B,MAAMX,KAAKW,QAAS,OACfC,EAAID,QAAQX,GACRL,YAAYG,KAAKE,GACzBa,KAAOD,MAGdE,OAAOC,IACNC,MAAMC,KAAKF,aAGZpB,2CA5DiBgB,QAASf,aAClBC,IAAXD,SACAA,OAAS,2BAER,IAAIE,OAAOa,QAAS,KACjBZ,WAAa,OACZ,MAAMmB,UAAUP,QAAQb,KAAM,KAE3BG,MADQU,QAAQb,KAAKoB,QACTf,MAAM,QAClBC,WAAaH,MAAM,GACnBI,UAAaJ,MAAMK,OAAS,EAAKL,MAAM,GAAKL,OAChDG,WAAWQ,KAAK,CAACC,IAAKJ,WAAYC,UAAWA,YAEjDI,WAAWV,YAAYW,MAAK,SAASS,SAC7BnB,EAAI,MACH,MAAMkB,UAAUP,QAAQb,KACzBa,QAAQb,KAAKoB,QAAUC,IAAInB,GAC3BA,OAGLc,OAAOC,IACNC,MAAMC,KAAKF,aAIZJ,qCA4CeQ,IAAKC,eACpBD,IAAIE,QAAQ,cAAc,CAACC,EAAGC,KAC7BA,IAAMH,OAAOI,eAAeD,IACrBH,OAAOG,IAEPD,SArFfN,MAAQ,yEAAa,uBAGnBP,gBAA6BZ,IAAf4B,gBAA4BA,gBAAaC"}

View File

@ -1,3 +1,3 @@
define("local_treestudyplan/util/svgarc",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.svgarcpath=_exports.svgarc=void 0;const cos=Math.cos,sin=Math.sin,π=Math.PI,f_matrix_times=(_ref,_ref2)=>{let[[a,b],[c,d]]=_ref,[x,y]=_ref2;return[a*x+b*y,c*x+d*y]},f_vec_add=(_ref3,_ref4)=>{let[a1,a2]=_ref3,[b1,b2]=_ref4;return[a1+b1,a2+b2]},svgarcpath=(_ref5,_ref6,_ref7,φ)=>{let[cx,cy]=_ref5,[rx,ry]=_ref6,[t1,Δ]=_ref7;Δ%=2*π;const rotMatrix=[[cos(x=φ),-sin(x)],[sin(x),cos(x)]];var x;const[sX,sY]=f_vec_add(f_matrix_times(rotMatrix,[rx*cos(t1),ry*sin(t1)]),[cx,cy]),[eX,eY]=f_vec_add(f_matrix_times(rotMatrix,[rx*cos(t1+Δ),ry*sin(t1+Δ)]),[cx,cy]),fA=Δ>π?1:0,fS=Δ>0?1:0;return isNaN(eY)||isNaN(eX)?"":"M "+sX+" "+sY+" A "+[rx,ry,φ/(2*π)*360,fA,fS,eX,eY].join(" ")};_exports.svgarcpath=svgarcpath;_exports.svgarc=(_ref8,_ref9,_ref10,φ)=>{let[cx,cy]=_ref8,[rx,ry]=_ref9,[t1,Δ]=_ref10;const path_2wk2r=document.createElementNS("http://www.w3.org/2000/svg","path"),d=svgarcpath([cx,cy],[rx,ry],[t1,Δ],φ);return path_2wk2r.setAttribute("d",d),path_2wk2r}})); define("local_treestudyplan/util/svgarc",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.svgarcpath=_exports.svgarc=void 0;const cos=Math.cos,sin=Math.sin,π=Math.PI,fMatrixTimes=(_ref,_ref2)=>{let[[a,b],[c,d]]=_ref,[x,y]=_ref2;return[a*x+b*y,c*x+d*y]},fVecAdd=(_ref3,_ref4)=>{let[a1,a2]=_ref3,[b1,b2]=_ref4;return[a1+b1,a2+b2]},svgarcpath=(_ref5,_ref6,_ref7,φ)=>{let[cx,cy]=_ref5,[rx,ry]=_ref6,[t1,Δ]=_ref7;Δ%=2*π;const rotMatrix=[[cos(x=φ),-sin(x)],[sin(x),cos(x)]];var x;const[sX,sY]=fVecAdd(fMatrixTimes(rotMatrix,[rx*cos(t1),ry*sin(t1)]),[cx,cy]),[eX,eY]=fVecAdd(fMatrixTimes(rotMatrix,[rx*cos(t1+Δ),ry*sin(t1+Δ)]),[cx,cy]),fA=Δ>π?1:0,fS=Δ>0?1:0;return isNaN(eY)||isNaN(eX)?"":"M "+sX+" "+sY+" A "+[rx,ry,φ/(2*π)*360,fA,fS,eX,eY].join(" ")};_exports.svgarcpath=svgarcpath;_exports.svgarc=(_ref8,_ref9,_ref10,φ)=>{let[cx,cy]=_ref8,[rx,ry]=_ref9,[t1,Δ]=_ref10;const path2wk2r=document.createElementNS("http://www.w3.org/2000/svg","path"),d=svgarcpath([cx,cy],[rx,ry],[t1,Δ],φ);return path2wk2r.setAttribute("d",d),path2wk2r}}));
//# sourceMappingURL=svgarc.min.js.map //# sourceMappingURL=svgarc.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"svgarc.min.js","sources":["../../src/util/svgarc.js"],"sourcesContent":["/*\nCopyright © 2020 Xah Lee, © 2023 P.M Kuipers\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the “Software”),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\nURL: SVG Circle Arc http://xahlee.info/js/svg_circle_arc.html\n*/\n\nconst cos = Math.cos;\nconst sin = Math.sin;\nconst π = Math.PI;\n\nconst f_matrix_times = (( [[a,b], [c,d]], [x,y]) => [ a * x + b * y, c * x + d * y]);\nconst f_rotate_matrix = (x => [[cos(x),-sin(x)], [sin(x), cos(x)]]);\nconst f_vec_add = (([a1, a2], [b1, b2]) => [a1 + b1, a2 + b2]);\n\n// function modified by pmkuipers for text params\n/**\n * Create svg path text for an arc\n * @param {*} center [cx,cy] center of ellipse\n * @param {*} radius [rx,ry] major minor radius\n * @param {*} angle [t1, Δ] start angle, in radian, angle to sweep, in radian. positive.\n * @param {*} φ rotation on the whole, in radian\n * @returns a SVG path element that represent a ellipse. Text describing the arc path in an svg path element\n */\nconst svgarcpath = (([cx,cy],[rx,ry], [t1, Δ], φ ) => {\n Δ = Δ % (2*π);\n const rotMatrix = f_rotate_matrix (φ);\n const [sX, sY] = ( f_vec_add ( f_matrix_times ( rotMatrix, [rx * cos(t1), ry * sin(t1)] ), [cx,cy] ) );\n const [eX, eY] = ( f_vec_add ( f_matrix_times ( rotMatrix, [rx * cos(t1+Δ), ry * sin(t1+Δ)] ), [cx,cy] ) );\n const fA = ( ( Δ > π ) ? 1 : 0 );\n const fS = ( ( Δ > 0 ) ? 1 : 0 );\n if ( isNaN(eY) || isNaN(eX) ) {\n return \"\";\n } else {\n return \"M \" + sX + \" \" + sY + \" A \" + [ rx , ry , φ / (2*π) *360, fA, fS, eX, eY ].join(\" \");\n }\n});\n\n/**\n * Create an svg arc element\n * @param {*} center [cx,cy] center of ellipse\n * @param {*} radius [rx,ry] major minor radius\n * @param {*} angle [t1, Δ] start angle, in radian, angle to sweep, in radian. positive.\n * @param {*} φ rotation on the whole, in radian\n * @returns a SVG path element that represent a ellipse.\n */\nconst svgarc = (([cx,cy],[rx,ry], [t1, Δ], φ ) => {\n const path_2wk2r = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n const d = svgarcpath([cx,cy],[rx,ry], [t1, Δ], φ );\n path_2wk2r.setAttribute(\"d\", d);\n return path_2wk2r;\n});\n\nexport {svgarc, svgarcpath};"],"names":["cos","Math","sin","π","PI","f_matrix_times","a","b","c","d","x","y","f_vec_add","a1","a2","b1","b2","svgarcpath","φ","cx","cy","rx","ry","t1","Δ","rotMatrix","sX","sY","eX","eY","fA","fS","isNaN","join","path_2wk2r","document","createElementNS","setAttribute"],"mappings":"kLAoBMA,IAAMC,KAAKD,IACXE,IAAMD,KAAKC,IACXC,EAAIF,KAAKG,GAETC,eAAkB,oBAAIC,EAAEC,IAAKC,EAAEC,UAAMC,EAAEC,eAAO,CAAEL,EAAII,EAAIH,EAAII,EAAGH,EAAIE,EAAID,EAAIE,EAAzD,EAElBC,UAAa,oBAAEC,GAAIC,WAAMC,GAAIC,gBAAQ,CAACH,GAAKE,GAAID,GAAKE,GAAvC,EAWbC,WAAc,mBAA2BC,SAAzBC,GAAGC,WAAKC,GAAGC,WAAMC,GAAIC,SACvCA,GAAS,EAAErB,QACLsB,UAdoB,CAAC,CAACzB,IAAPU,EAccQ,IAdChB,IAAIQ,IAAK,CAACR,IAAIQ,GAAIV,IAAIU,KAArCA,YAedgB,GAAIC,IAAQf,UAAYP,eAAiBoB,UAAW,CAACJ,GAAKrB,IAAIuB,IAAKD,GAAKpB,IAAIqB,MAAQ,CAACJ,GAAGC,MACxFQ,GAAIC,IAAQjB,UAAYP,eAAiBoB,UAAW,CAACJ,GAAKrB,IAAIuB,GAAGC,GAAIF,GAAKpB,IAAIqB,GAAGC,KAAO,CAACL,GAAGC,KAC7FU,GAAUN,EAAIrB,EAAM,EAAI,EACxB4B,GAAUP,EAAI,EAAM,EAAI,SACzBQ,MAAMH,KAAOG,MAAMJ,IACb,GAEA,KAAOF,GAAK,IAAMC,GAAK,MAAQ,CAAEN,GAAKC,GAAKJ,GAAK,EAAEf,GAAI,IAAK2B,GAAIC,GAAIH,GAAIC,IAAKI,KAAK,qDAYhF,oBAA2Bf,SAAzBC,GAAGC,WAAKC,GAAGC,WAAMC,GAAIC,gBAC7BU,WAAaC,SAASC,gBAAgB,6BAA8B,QACpE3B,EAAIQ,WAAW,CAACE,GAAGC,IAAI,CAACC,GAAGC,IAAK,CAACC,GAAIC,GAAIN,UAC/CgB,WAAWG,aAAa,IAAK5B,GACtByB,UAAP"} {"version":3,"file":"svgarc.min.js","sources":["../../src/util/svgarc.js"],"sourcesContent":["/*\nCopyright © 2020 Xah Lee, © 2023 P.M Kuipers\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the “Software”),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\nURL: SVG Circle Arc http://xahlee.info/js/svg_circle_arc.html\n*/\n\nconst cos = Math.cos;\nconst sin = Math.sin;\nconst π = Math.PI;\n\nconst fMatrixTimes = (([[a, b], [c, d]], [x, y]) => [a * x + b * y, c * x + d * y]);\nconst fRotateMatrix = (x => [[cos(x), -sin(x)], [sin(x), cos(x)]]);\nconst fVecAdd = (([a1, a2], [b1, b2]) => [a1 + b1, a2 + b2]);\n\n// Function modified by pmkuipers for text params\n/**\n * Create svg path text for an arc\n * @param {*} center [cx,cy] center of ellipse\n * @param {*} radius [rx,ry] major minor radius\n * @param {*} angle [t1, Δ] start angle, in radian, angle to sweep, in radian. positive.\n * @param {*} φ rotation on the whole, in radian\n * @returns {string} a SVG path description that represent a ellipse. Text describing the arc path in an svg path element\n */\nconst svgarcpath = (([cx, cy], [rx, ry], [t1, Δ], φ) => {\n Δ = Δ % (2 * π);\n const rotMatrix = fRotateMatrix(φ);\n const [sX, sY] = (fVecAdd(fMatrixTimes(rotMatrix, [rx * cos(t1), ry * sin(t1)]), [cx, cy]));\n const [eX, eY] = (fVecAdd(fMatrixTimes(rotMatrix, [rx * cos(t1 + Δ), ry * sin(t1 + Δ)]), [cx, cy]));\n const fA = ((Δ > π) ? 1 : 0);\n const fS = ((Δ > 0) ? 1 : 0);\n if (isNaN(eY) || isNaN(eX)) {\n return \"\";\n } else {\n return \"M \" + sX + \" \" + sY + \" A \" + [rx, ry, φ / (2 * π) * 360, fA, fS, eX, eY].join(\" \");\n }\n});\n\n/**\n * Create an svg arc element\n * @param {*} center [cx,cy] center of ellipse\n * @param {*} radius [rx,ry] major minor radius\n * @param {*} angle [t1, Δ] start angle, in radian, angle to sweep, in radian. positive.\n * @param {*} φ rotation on the whole, in radian\n * @returns {string} a SVG path element that represent a ellipse.\n */\nconst svgarc = (([cx, cy], [rx, ry], [t1, Δ], φ) => {\n const path2wk2r = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n const d = svgarcpath([cx, cy], [rx, ry], [t1, Δ], φ);\n path2wk2r.setAttribute(\"d\", d);\n return path2wk2r;\n});\n\nexport {svgarc, svgarcpath};"],"names":["cos","Math","sin","π","PI","fMatrixTimes","a","b","c","d","x","y","fVecAdd","a1","a2","b1","b2","svgarcpath","φ","cx","cy","rx","ry","t1","Δ","rotMatrix","sX","sY","eX","eY","fA","fS","isNaN","join","path2wk2r","document","createElementNS","setAttribute"],"mappings":"kLAoBMA,IAAMC,KAAKD,IACXE,IAAMD,KAAKC,IACXC,EAAIF,KAAKG,GAETC,aAAgB,oBAAGC,EAAGC,IAAKC,EAAGC,UAAMC,EAAGC,eAAO,CAACL,EAAII,EAAIH,EAAII,EAAGH,EAAIE,EAAID,EAAIE,EAA1D,EAEhBC,QAAW,oBAAEC,GAAIC,WAAMC,GAAIC,gBAAQ,CAACH,GAAKE,GAAID,GAAKE,GAAvC,EAWXC,WAAc,mBAA8BC,SAA5BC,GAAIC,WAAMC,GAAIC,WAAMC,GAAIC,SAC1CA,GAAS,EAAIrB,QACPsB,UAdkB,CAAC,CAACzB,IAAPU,EAcaQ,IAdGhB,IAAIQ,IAAK,CAACR,IAAIQ,GAAIV,IAAIU,KAAtCA,YAeZgB,GAAIC,IAAOf,QAAQP,aAAaoB,UAAW,CAACJ,GAAKrB,IAAIuB,IAAKD,GAAKpB,IAAIqB,MAAO,CAACJ,GAAIC,MAC/EQ,GAAIC,IAAOjB,QAAQP,aAAaoB,UAAW,CAACJ,GAAKrB,IAAIuB,GAAKC,GAAIF,GAAKpB,IAAIqB,GAAKC,KAAM,CAACL,GAAIC,KACxFU,GAAON,EAAIrB,EAAK,EAAI,EACpB4B,GAAOP,EAAI,EAAK,EAAI,SACtBQ,MAAMH,KAAOG,MAAMJ,IACZ,GAEA,KAAOF,GAAK,IAAMC,GAAK,MAAQ,CAACN,GAAIC,GAAIJ,GAAK,EAAIf,GAAK,IAAK2B,GAAIC,GAAIH,GAAIC,IAAII,KAAK,qDAY/E,oBAA8Bf,SAA5BC,GAAIC,WAAMC,GAAIC,WAAMC,GAAIC,gBAChCU,UAAYC,SAASC,gBAAgB,6BAA8B,QACnE3B,EAAIQ,WAAW,CAACE,GAAIC,IAAK,CAACC,GAAIC,IAAK,CAACC,GAAIC,GAAIN,UAClDgB,UAAUG,aAAa,IAAK5B,GACrByB,SAAP"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
/* eslint-disable */
/*! /*!
* BootstrapVue 2.23.1 * BootstrapVue 2.23.1
* *

View File

@ -1,27 +1,7 @@
/*eslint no-var: "error" */ /* eslint-env es6*/
/*eslint no-unused-vars: "off" */
/*eslint linebreak-style: "off" */
/*eslint no-trailing-spaces: "off" */
/*eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
// You can call it anything you like // You can call it anything you like
import {get_string,get_strings} from 'core/str';
import {call} from 'core/ajax';
import Debugger from './debugger';
import {load_strings} from './string-helper';
let debug = new Debugger("treestudyplan-config-grades");
/*
let strings = load_strings({
studyplan: {
studyplan_select_placeholder: 'studyplan_select_placeholder',
},
});
*/
/** /**
* Initialize grade cfg page * Initialize grade cfg page
*/ */
@ -29,24 +9,24 @@ export function init() {
{ const { const
intRx = /\d/, intRx = /\d/,
integerChange = (event) => { integerChange = (event) => {
if ( (event.key.length > 1) || intRx.test(event.key) if ((event.key.length > 1) || intRx.test(event.key)
) { ) {
return; return;
} }
event.preventDefault(); event.preventDefault();
}; };
for (let input of document.querySelectorAll( 'input[type="number"][step="1"][min="0"]' )){ for (let input of document.querySelectorAll('input[type="number"][step="1"][min="0"]')) {
input.addEventListener("keydown", integerChange); input.addEventListener("keydown", integerChange);
} }
} }
{ const { const
decimal= /^[0-9]*?\.[0-9]*?$/, decimal = /^[0-9]*?\.[0-9]*?$/,
intRx = /\d/, intRx = /\d/,
floatChange = (event) => { floatChange = (event) => {
if ( (event.key.length > 1) || ( (event.key === ".") && (!event.currentTarget.value.match(decimal)) ) if ((event.key.length > 1) || ((event.key === ".") && (!event.currentTarget.value.match(decimal)))
|| intRx.test(event.key) || intRx.test(event.key)
) { ) {
return; return;
@ -54,10 +34,10 @@ export function init() {
event.preventDefault(); event.preventDefault();
}; };
for (let input of document.querySelectorAll( 'input[type="number"][min="0"]:not([step])' )){ for (let input of document.querySelectorAll('input[type="number"][min="0"]:not([step])')) {
input.addEventListener("keydown", floatChange); input.addEventListener("keydown", floatChange);
} }
for (let input of document.querySelectorAll( 'input[type="text"].float' )){ for (let input of document.querySelectorAll('input[type="text"].float')) {
input.addEventListener("keydown", floatChange); input.addEventListener("keydown", floatChange);
} }

View File

@ -1,5 +1,3 @@
/*eslint no-console: "off"*/
/** /**
* Save a piece of text to file as if it was downloaded * Save a piece of text to file as if it was downloaded
* @param {string} filename * @param {string} filename
@ -7,17 +5,18 @@
* @param {string} type * @param {string} type
*/ */
export function download(filename, text, type) { export function download(filename, text, type) {
if(undefined == type) { type = "text/plain"; } if (undefined == type) {
type = "text/plain";
}
var pom = document.createElement('a'); var pom = document.createElement('a');
pom.setAttribute('href', 'data:'+type+';charset=utf-8,' + encodeURIComponent(text)); pom.setAttribute('href', 'data:' + type + ';charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename); pom.setAttribute('download', filename);
if (document.createEvent) { if (document.createEvent) {
var event = document.createEvent('MouseEvents'); var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true); event.initEvent('click', true, true);
pom.dispatchEvent(event); pom.dispatchEvent(event);
} } else {
else {
pom.click(); pom.click();
} }
} }
@ -35,25 +34,25 @@ export function download(filename, text, type) {
* @param {fileOpenedCallback} onready Callback to run when file is opened * @param {fileOpenedCallback} onready Callback to run when file is opened
* @param {Array} accept Array of mime types that the file dialog will accept * @param {Array} accept Array of mime types that the file dialog will accept
*/ */
export function upload(onready,accept) { export function upload(onready, accept) {
let input = document.createElement('input'); let input = document.createElement('input');
input.type = 'file'; input.type = 'file';
if(Array.isArray(accept)){ if (Array.isArray(accept)) {
if(accept.count > 0){ if (accept.count > 0) {
input.accept = accept.join(", "); input.accept = accept.join(", ");
} }
} else if (undefined !== accept){ } else if (undefined !== accept) {
input.accept = accept; input.accept = accept;
} }
input.onchange = () => { input.onchange = () => {
let files = Array.from(input.files); let files = Array.from(input.files);
if(files.length > 0){ if (files.length > 0) {
let file = files[0]; let file = files[0];
var reader = new FileReader(); var reader = new FileReader();
reader.onload = function(e) { reader.onload = function(e) {
var contents = e.target.result; var contents = e.target.result;
if(onready instanceof Function){ if (onready instanceof Function) {
onready(file,contents); onready(file, contents);
} }
}; };
reader.readAsText(file); reader.readAsText(file);
@ -64,8 +63,7 @@ export function upload(onready,accept) {
var event = document.createEvent('MouseEvents'); var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true); event.initEvent('click', true, true);
input.dispatchEvent(event); input.dispatchEvent(event);
} } else {
else {
input.click(); input.click();
} }
} }

View File

@ -1,16 +1,14 @@
/*eslint no-var: "error"*/ /* eslint no-var: "error" */
/*eslint no-console: "off"*/ /* eslint capitalized-comments: "off" */
/*eslint-disable no-trailing-spaces */ /* eslint-env es6 */
/*eslint-env es6*/
// Put this file in path/to/plugin/amd/src
import {loadFragment} from 'core/fragment'; import {loadFragment} from 'core/fragment';
import {load_strings} from './util/string-helper'; import {loadStrings} from './util/string-helper';
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import notification from 'core/notification'; import notification from 'core/notification';
import {replaceNodeContents} from 'core/templates'; import {replaceNodeContents} from 'core/templates';
//import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only // import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only
//import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only // import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only
/* Moodle 3.11 safe import for when needed /* Moodle 3.11 safe import for when needed
let markFormSubmitted = () => {}; let markFormSubmitted = () => {};
@ -28,9 +26,9 @@ import('core_form/changechecker').then((ns) => {
*/ */
export default { export default {
install(Vue/*,options*/){ install(Vue/* ,options */) {
let strings = load_strings({ let strings = loadStrings({
editmod: { editmod: {
save$core: "save$core", save$core: "save$core",
cancel$core: "cancel$core", cancel$core: "cancel$core",
@ -42,16 +40,16 @@ export default {
cmid: { cmid: {
type: Number, type: Number,
}, },
coursectxid:{ coursectxid: {
type: Number, type: Number,
}, },
title: { title: {
type: String, type: String,
default: "", 'default': "",
}, },
genericonly: { genericonly: {
type: Boolean, type: Boolean,
default: false, 'default': false,
} }
}, },
data() { data() {
@ -63,22 +61,22 @@ export default {
computed: { computed: {
}, },
methods: { methods: {
openForm(){ openForm() {
const self = this; const self = this;
self.$refs["editormodal"].show(); self.$refs.editormodal.show();
}, },
onShown(){ onShown() {
const self = this; const self = this;
let params = {cmid: this.cmid}; let params = {cmid: this.cmid};
console.info("Loading form"); loadFragment('local_treestudyplan', 'mod_edit_form', this.coursectxid, params).then((html, js) => {
loadFragment('local_treestudyplan', 'mod_edit_form', this.coursectxid, params).then((html,js) =>{ replaceNodeContents(self.$refs.content, html, js);
replaceNodeContents(self.$refs["content"], html, js); return null;
}).catch(notification.exception); }).catch(notification.exception);
}, },
onSave(){ onSave() {
const self = this; const self = this;
let form = this.$refs["content"].getElementsByTagName("form")[0]; let form = this.$refs.content.getElementsByTagName("form")[0];
// markFormSubmitted(form); // Moodle 4.00+ only // markFormSubmitted(form); // Moodle 4.00+ only
// We call this, so other modules can update the form with the latest state. // We call this, so other modules can update the form with the latest state.
@ -88,17 +86,17 @@ export default {
const formdata = new FormData(form); const formdata = new FormData(form);
const data = new URLSearchParams(formdata).toString(); const data = new URLSearchParams(formdata).toString();
//const formdata = new FormData(form); // const formdata = new FormData(form);
//const data = {}; // const data = {};
//formdata.forEach((value, key) => (data[key] = value)); // formdata.forEach((value, key) => (data[key] = value));
call([{ call([{
methodname: 'local_treestudyplan_submit_cm_editform', methodname: 'local_treestudyplan_submit_cm_editform',
args: {cmid: this.cmid, formdata: data} args: {cmid: this.cmid, formdata: data}
}])[0].then(()=>{ }])[0].then(() => {
self.$emit("saved",formdata); self.$emit("saved", formdata);
return null;
}).catch(notification.exception); }).catch(notification.exception);
} }
}, },
template: ` template: `

View File

@ -1,8 +1,9 @@
/*eslint no-var: "error" */ /* eslint no-var: "error" */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/*eslint linebreak-style: "off" */ /* eslint linebreak-style: "off" */
/*eslint no-trailing-spaces: "off" */ /* eslint no-trailing-spaces: "off" */
/*eslint-env es6*/ /* eslint max-depth: ["error", 6]*/
/* eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
// You can call it anything you like // You can call it anything you like
@ -12,8 +13,8 @@ import notification from 'core/notification';
import Vue from './vue/vue'; import Vue from './vue/vue';
import Debugger from './util/debugger'; import Debugger from './util/debugger';
import {load_strings} from './util/string-helper'; import {loadStrings} from './util/string-helper';
import {ProcessStudyplan} from './studyplan-processor'; import {processStudyplan} from './studyplan-processor';
import {studyplanTiming} from './util/date-helper'; import {studyplanTiming} from './util/date-helper';
import {addBrowserButtonEvent} from './util/browserbuttonevents'; import {addBrowserButtonEvent} from './util/browserbuttonevents';
@ -37,10 +38,8 @@ Vue.use(BootstrapVue);
let debug = new Debugger("treestudyplancoach"); let debug = new Debugger("treestudyplancoach");
let strings = load_strings({ let strings = loadStrings({
coach: { coach: {
studyplan_select_placeholder: 'studyplan_select_placeholder',
switch_coach_editmode: 'switch_coach_editmode',
}, },
}); });
@ -73,34 +72,34 @@ export function init() {
call([{ call([{
methodname: 'local_treestudyplan_list_coaching_studyplans', methodname: 'local_treestudyplan_list_coaching_studyplans',
args: {} args: {}
}])[0].then(function(response){ }])[0].then(function(response) {
const timingval = { present: 0, past: 1, future: 2}; const timingval = {present: 0, past: 1, future: 2};
response.sort((a,b) => { response.sort((a, b) => {
const timinga = studyplanTiming(a); const timinga = studyplanTiming(a);
const timingb = studyplanTiming(b); const timingb = studyplanTiming(b);
const t = timingval[timinga] - timingval[timingb]; const t = timingval[timinga] - timingval[timingb];
if(t == 0){ if (t == 0) {
// sort by name if timing is equal // Sort by name if timing is equal
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
} } else {
else {
return t; return t;
} }
}); });
app.studyplans = response; app.studyplans = response;
// load studyplan from hash if applicable // Load studyplan from hash if applicable
const hash = window.location.hash.replace('#',''); const hash = window.location.hash.replace('#', '');
const parts = hash.split("-"); const parts = hash.split("-");
if(!!parts && parts.length > 0 && parts[0] != ''){ if (!!parts && parts.length > 0 && parts[0] != '') {
for(let idx in app.studyplans){ for (let idx in app.studyplans) {
if(app.studyplans[idx].id == parts[0]){ if (app.studyplans[idx].id == parts[0]) {
app.selectStudyplan(app.studyplans[idx],parts[1],false); app.selectStudyplan(app.studyplans[idx], parts[1], false);
break; break;
} }
} }
} }
return;
}).catch(notification.exception); }).catch(notification.exception);
addBrowserButtonEvent(this.navChanged, this.navChanged); addBrowserButtonEvent(this.navChanged, this.navChanged);
}, },
@ -108,33 +107,33 @@ export function init() {
}, },
methods: { methods: {
navChanged() { navChanged() {
const hash = window.location.hash.replace('#',''); const hash = window.location.hash.replace('#', '');
const parts = hash.split("-"); const parts = hash.split("-");
debug.log("Navigation changed",hash,parts); debug.log("Navigation changed", hash, parts);
if(!!parts && parts.length > 0){ if (!!parts && parts.length > 0) {
const planid = Number(parts[0]); const planid = Number(parts[0]);
const studentid = (parts.length > 1)?Number(parts[1]):0; const studentid = (parts.length > 1) ? Number(parts[1]) : 0;
debug.log("Selected ids",planid,studentid,this.selected.planid,this.selected.studentid); debug.log("Selected ids", planid, studentid, this.selected.planid, this.selected.studentid);
if ( planid == 0) { if (planid == 0) {
if (planid != this.selected.planid) { if (planid != this.selected.planid) {
this.closeStudyplan(false); this.closeStudyplan(false);
} }
} else if ( this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0) ) { } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {
debug.info ("Requested plan changed - loading studyplan"); debug.info("Requested plan changed - loading studyplan");
for(let idx in app.studyplans){ for (let idx in app.studyplans) {
const plan = this.studyplans[idx]; const plan = this.studyplans[idx];
if(Number(plan.id) == planid){ if (Number(plan.id) == planid) {
this.selectStudyplan(plan,studentid,false); this.selectStudyplan(plan, studentid, false);
break; break;
} }
} }
} else if (this.selected.studentid != studentid) { } else if (this.selected.studentid != studentid) {
for(const group of app.associatedstudents) { for (const group of app.associatedstudents) {
for(const student of group.users){ for (const student of group.users) {
if(Number(student.id) == studentid){ if (Number(student.id) == studentid) {
app.showStudentView(student,false); app.showStudentView(student, false);
break; break;
} }
} }
@ -142,7 +141,7 @@ export function init() {
} }
} }
}, },
closeStudyplan(updatehash=true) { closeStudyplan(updatehash = true) {
app.selected.planid = 0; app.selected.planid = 0;
app.selected.studentid = 0; app.selected.studentid = 0;
app.activestudyplan = null; app.activestudyplan = null;
@ -154,10 +153,10 @@ export function init() {
} }
}, },
selectStudyplan(studyplan,studentid,updatehash=true){ selectStudyplan(studyplan, studentid, updatehash = true) {
app.selected.planid = Number(studyplan.id); app.selected.planid = Number(studyplan.id);
app.selected.studentid = studentid?Number(studentid):0; app.selected.studentid = studentid ? Number(studentid) : 0;
// fetch studyplan // Fetch studyplan
const self = this; const self = this;
self.loadingstudyplan = true; self.loadingstudyplan = true;
self.associatedstudents = []; self.associatedstudents = [];
@ -165,20 +164,20 @@ export function init() {
self.studentstudyplan = null; self.studentstudyplan = null;
call([{ call([{
methodname: 'local_treestudyplan_get_studyplan_map', methodname: 'local_treestudyplan_get_studyplan_map',
args: { id: studyplan.id} args: {id: studyplan.id}
}])[0].then(function(response){ }])[0].then((response) => {
self.activestudyplan = ProcessStudyplan(response,true); self.activestudyplan = processStudyplan(response, true);
call([{ call([{
methodname: 'local_treestudyplan_all_associated_grouped', methodname: 'local_treestudyplan_all_associated_grouped',
args: { studyplan_id: studyplan.id} args: {'studyplan_id': studyplan.id}
}])[0].then(function(response){ }])[0].then(function(response) {
self.associatedstudents = response; self.associatedstudents = response;
let foundstudent = false; let foundstudent = false;
if(studentid){ if (studentid) {
for(const group of self.associatedstudents) { for (const group of self.associatedstudents) {
for(const student of group.users){ for (const student of group.users) {
if(student.id == studentid){ if (student.id == studentid) {
foundstudent = true; foundstudent = true;
self.showStudentView(student); self.showStudentView(student);
break; break;
@ -188,15 +187,16 @@ export function init() {
} }
if (!foundstudent) { if (!foundstudent) {
// Select first student available. // Select first student available.
for(const group of self.associatedstudents) { for (const group of self.associatedstudents) {
for(const student of group.users){ for (const student of group.users) {
foundstudent = true; foundstudent = true;
self.showStudentView(student); self.showStudentView(student);
break; break;
} }
} }
} }
if (!foundstudent) { // update hash with just the studyplan if no student was available for display if (!foundstudent) {
// Update hash with just the studyplan if no student was available for display
app.selected.studentid = 0; app.selected.studentid = 0;
if (updatehash) { if (updatehash) {
window.location.hash = app.activestudyplan.id; window.location.hash = app.activestudyplan.id;
@ -204,30 +204,32 @@ export function init() {
self.displayedstudyplan = self.activestudyplan; self.displayedstudyplan = self.activestudyplan;
self.loadingstudyplan = false; self.loadingstudyplan = false;
} }
return;
}).catch(notification.exception); }).catch(notification.exception);
return;
}).catch(function(error){ }).catch(function(error) {
notification.exception(error); notification.exception(error);
app.loadingstudyplan = false; app.loadingstudyplan = false;
}); });
}, },
showStudentView(student,updatehash=true){ showStudentView(student, updatehash = true) {
app.selected.studentid = student?Number(student.id):0; app.selected.studentid = student ? Number(student.id) : 0;
if (student) { if (student) {
app.selectedstudent = student; app.selectedstudent = student;
app.studentstudyplan = null; app.studentstudyplan = null;
app.loadingstudyplan = true; app.loadingstudyplan = true;
call([{ call([{
methodname: 'local_treestudyplan_get_user_studyplan', methodname: 'local_treestudyplan_get_user_studyplan',
args: { userid: student.id, studyplanid: app.activestudyplan.id} args: {userid: student.id, studyplanid: app.activestudyplan.id}
}])[0].then(function(response){ }])[0].then((response) => {
app.studentstudyplan = ProcessStudyplan(response,false); app.studentstudyplan = processStudyplan(response, false);
app.displayedstudyplan = app.studentstudyplan; app.displayedstudyplan = app.studentstudyplan;
app.loadingstudyplan = false; app.loadingstudyplan = false;
if (updatehash) { if (updatehash) {
window.location.hash = app.activestudyplan.id + "-" + student.id; window.location.hash = app.activestudyplan.id + "-" + student.id;
} }
}).catch(function(error){ return;
}).catch(function(error) {
notification.exception(error); notification.exception(error);
app.loadingstudyplan = false; app.loadingstudyplan = false;
}); });
@ -235,8 +237,8 @@ export function init() {
this.showOverview(updatehash); this.showOverview(updatehash);
} }
}, },
showOverview(updatehash=true){ showOverview(updatehash = true) {
debug.info("Switch to overview",updatehash); debug.info("Switch to overview", updatehash);
app.selected.studentid = 0; app.selected.studentid = 0;
app.selectedstudent = null; app.selectedstudent = null;
app.studentstudyplan = null; app.studentstudyplan = null;

View File

@ -1,8 +1,8 @@
/*eslint no-var: "error" */ /* eslint no-var: "error" */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/*eslint linebreak-style: "off" */ /* eslint linebreak-style: "off" */
/*eslint no-trailing-spaces: "off" */ /* eslint no-trailing-spaces: "off" */
/*eslint-env es6*/ /* eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
// You can call it anything you like // You can call it anything you like
@ -25,8 +25,8 @@ Vue.use(ModalComponents);
import Debugger from './util/debugger'; import Debugger from './util/debugger';
import {addBrowserButtonEvent} from './util/browserbuttonevents'; import {addBrowserButtonEvent} from './util/browserbuttonevents';
import {load_strings} from './util/string-helper'; import {loadStrings} from './util/string-helper';
import {ProcessStudyplan} from './studyplan-processor'; import {processStudyplan} from './studyplan-processor';
import {download,upload} from './downloader'; import {download,upload} from './downloader';
import {studyplanTiming} from './util/date-helper'; import {studyplanTiming} from './util/date-helper';
import { premiumenabled, premiumstatus } from "./util/premium"; import { premiumenabled, premiumstatus } from "./util/premium";
@ -51,7 +51,7 @@ import('core_form/changechecker').then((ns) => {
let strings = load_strings({ let strings = loadStrings({
studyplan: { studyplan: {
studyplan_select_placeholder: 'studyplan_select_placeholder', studyplan_select_placeholder: 'studyplan_select_placeholder',
advanced_import_from_file: 'advanced_import_from_file', advanced_import_from_file: 'advanced_import_from_file',
@ -261,7 +261,7 @@ export function init(contextid,categoryid,options) {
methodname: 'local_treestudyplan_get_studyplan_map', methodname: 'local_treestudyplan_get_studyplan_map',
args: { id: studyplanid} args: { id: studyplanid}
}])[0].then(function(response){ }])[0].then(function(response){
app.activestudyplan = ProcessStudyplan(response); app.activestudyplan = processStudyplan(response);
debug.info('studyplan processed'); debug.info('studyplan processed');
app.loadingstudyplan = false; app.loadingstudyplan = false;
window.location.hash = app.activestudyplan.id; window.location.hash = app.activestudyplan.id;

View File

@ -1,7 +1,8 @@
/*eslint no-var: "error" */ /* eslint no-var: "error" */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/*eslint linebreak-style: "off" */ /* eslint linebreak-style: "off" */
/*eslint-env es6*/ /* eslint-env es6*/
/* eslint camelcase: "off" */
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
// You can call it anything you like // You can call it anything you like
@ -12,18 +13,17 @@ import ModalFactory from 'core/modal_factory';
import ModalEvents from 'core/modal_events'; import ModalEvents from 'core/modal_events';
/* Determine the proper getstrings function to use (MDL4.3+ recommends use of getStrings, which is jquery independent) */ /* Determine the proper getstrings function to use (MDL4.3+ recommends use of getStrings, which is jquery independent) */
const getstr_func = (getStrings !== undefined)?getStrings:get_strings; const getstrFunc = (getStrings !== undefined) ? getStrings : get_strings;
let debug = new Debugger("treestudyplan"); let debug = new Debugger("treestudyplan-invitemanager");
/** /**
* Init function for page-invitemanager * Init function for page-invitemanager
* @return undefined
*/ */
export function init() { export function init() {
getstr_func([ getstrFunc([
{ key: 'ok', component: 'core'}, {key: 'ok', component: 'core'},
{ key: 'confirm', component: 'core'}, {key: 'confirm', component: 'core'},
]).then((s) => { ]).then((s) => {
const strOk = s[0]; const strOk = s[0];
const strConfirm = s[1]; const strConfirm = s[1];
@ -48,18 +48,23 @@ export function init() {
type: ModalFactory.types.SAVE_CANCEL, type: ModalFactory.types.SAVE_CANCEL,
title: title, title: title,
body: text, body: text,
}).then(function (modal) { }).then((modal) => {
modal.setSaveButtonText(oktext); modal.setSaveButtonText(oktext);
let root = modal.getRoot(); let root = modal.getRoot();
root.on(ModalEvents.save, function () { root.on(ModalEvents.save, () => {
window.location = href; window.location = href;
}); });
modal.modal[0].style["max-width"] = "345px"; modal.modal[0].style["max-width"] = "345px";
modal.show(); modal.show();
return modal; return modal;
}).catch((x) => {
debug.warn(x);
}); });
}); });
}); });
return;
}).catch((x) => {
debug.warn(x);
}); });
} }

View File

@ -1,9 +1,5 @@
/*eslint no-var: "error" */ /* eslint no-unused-vars: "off" */
/*eslint no-unused-vars: "off" */ /* eslint-env es6*/
/*eslint linebreak-style: "off" */
/*eslint no-trailing-spaces: "off" */
/*eslint no-console: "off" */
/*eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
// You can call it anything you like // You can call it anything you like
@ -12,28 +8,24 @@ import Vue from './vue/vue';
import RVComponents from './report-viewer-components'; import RVComponents from './report-viewer-components';
Vue.use(RVComponents); Vue.use(RVComponents);
import Debugger from './util/debugger';
import PortalVue from './portal-vue/portal-vue.esm'; import PortalVue from './portal-vue/portal-vue.esm';
Vue.use(PortalVue); Vue.use(PortalVue);
import BootstrapVue from './bootstrap-vue/bootstrap-vue'; import BootstrapVue from './bootstrap-vue/bootstrap-vue';
Vue.use(BootstrapVue); Vue.use(BootstrapVue);
let debug = new Debugger("treestudyplan-report");
/** /**
* Initialize the Page * Initialize the Page
* @param {string} type Type of page to show * @param {string} type Type of page to show
* @param {Object} arg1 Argument1 as passed * @param {Object} arg1 Argument1 as passed
*/ */
export function init(type="own",arg1) { export function init(type = "own", arg1) {
let app = new Vue({ let app = new Vue({
el: '#root', el: '#root',
data: { data: {
"studyplans": [], "studyplans": [],
"type": type, "type": type,
"invitekey": (type=="invited")?arg1:null, "invitekey": (type == "invited") ? arg1 : null,
"userid": (type=="other")?arg1:null, "userid": (type == "other") ? arg1 : null,
}, },
methods: { methods: {

View File

@ -1,8 +1,8 @@
/*eslint no-var: "error" */ /* eslint no-var: "error" */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/*eslint linebreak-style: "off" */ /* eslint linebreak-style: "off" */
/*eslint no-trailing-spaces: "off" */ /* eslint no-trailing-spaces: "off" */
/*eslint-env es6*/ /* eslint-env es6*/
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import notification from 'core/notification'; import notification from 'core/notification';
@ -10,7 +10,7 @@ import notification from 'core/notification';
import Vue from './vue/vue'; import Vue from './vue/vue';
import Debugger from './util/debugger'; import Debugger from './util/debugger';
import {load_strings} from './util/string-helper'; import {loadStrings} from './util/string-helper';
import SRComponents from './studyplan-report-components'; import SRComponents from './studyplan-report-components';
Vue.use(SRComponents); Vue.use(SRComponents);
@ -28,9 +28,8 @@ Vue.use(BootstrapVue);
let debug = new Debugger("treestudyplanviewer"); let debug = new Debugger("treestudyplanviewer");
let strings = load_strings({ let strings = loadStrings({
studyplan_report: { studyplanReport: {
studyplan_select_placeholder: 'studyplan_select_placeholder',
studyplan: 'studyplan', studyplan: 'studyplan',
page: 'studyplanpage', page: 'studyplanpage',
periods: 'periods', periods: 'periods',
@ -67,56 +66,54 @@ export function init(studyplanid, pageid, firstperiod, lastperiod) {
structure: null, structure: null,
studyplan: null, studyplan: null,
page: null, page: null,
text: strings.studyplan_report, text: strings.studyplanReport,
},
async mounted() {
}, },
created() { created() {
// On creation, load the page as specified // On creation, load the page as specified
this.loadStructure(pageid,firstperiod,lastperiod); this.loadStructure(pageid, firstperiod, lastperiod);
}, },
computed: { computed: {
}, },
methods: { methods: {
loadStructure(pageid,firstperiod,lastperiod) { loadStructure(pageid, firstperiod, lastperiod) {
const self = this; const self = this;
this.structure = null; // Starts loading icon. Hides old data. this.structure = null; // Starts loading icon. Hides old data.
call([{ call([{
methodname: 'local_treestudyplan_get_report_structure', methodname: 'local_treestudyplan_get_report_structure',
args: { pageid: pageid, args: {pageid: pageid,
firstperiod: firstperiod, firstperiod: firstperiod,
lastperiod: lastperiod lastperiod: lastperiod
} }
}])[0].then(function(response){ }])[0].then((response) => {
self.structure = response; self.structure = response;
self.studyplan = response.studyplan; self.studyplan = response.studyplan;
self.page = response.page; self.page = response.page;
return;
}).catch(notification.exception); }).catch(notification.exception);
}, },
selectedPage(e) { selectedPage(e) {
debug.info("SelectedPage",e); debug.info("SelectedPage", e);
const pageid = e.target.value; const pageid = e.target.value;
this.loadStructure(pageid); this.loadStructure(pageid);
}, },
selectedFirstPeriod(e) { selectedFirstPeriod(e) {
debug.info("selectedFirstPeriod",e); debug.info("selectedFirstPeriod", e);
let f = e.target.value; let f = e.target.value;
let l = this.structure.lastperiod; let l = this.structure.lastperiod;
if ( l < f) { if (l < f) {
l = f; l = f;
} }
this.loadStructure(this.page.id,f,l); this.loadStructure(this.page.id, f, l);
}, },
selectedLastPeriod(e) { selectedLastPeriod(e) {
debug.info("selectedLastPeriod",e); debug.info("selectedLastPeriod", e);
let f = this.structure.firstperiod; let f = this.structure.firstperiod;
let l = e.target.value; let l = e.target.value;
if ( l < f) { if (l < f) {
l = f; l = f;
} }
this.loadStructure(this.page.id,f,l); this.loadStructure(this.page.id, f, l);
}, },
}, },

View File

@ -1,8 +1,6 @@
/*eslint no-var: "error" */ /* eslint no-unused-vars: "off" */
/*eslint no-unused-vars: "off" */ /* eslint no-trailing-spaces: "off" */
/*eslint linebreak-style: "off" */ /* eslint max-depth: ["error", 5] */
/*eslint no-trailing-spaces: "off" */
/*eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
// You can call it anything you like // You can call it anything you like
@ -12,14 +10,13 @@ import notification from 'core/notification';
import Vue from './vue/vue'; import Vue from './vue/vue';
import Debugger from './util/debugger'; import Debugger from './util/debugger';
import {load_strings} from './util/string-helper'; import {loadStrings} from './util/string-helper';
import {ProcessStudyplan} from './studyplan-processor'; import {processStudyplan} from './studyplan-processor';
import {studyplanTiming} from './util/date-helper'; import {studyplanTiming} from './util/date-helper';
import {addBrowserButtonEvent} from './util/browserbuttonevents'; import {addBrowserButtonEvent} from './util/browserbuttonevents';
import RVComponents from './report-viewer-components'; import RVComponents from './report-viewer-components';
Vue.use(RVComponents); Vue.use(RVComponents);
import TSComponents from './treestudyplan-components';
import ModalComponents from './modedit-modal'; import ModalComponents from './modedit-modal';
Vue.use(ModalComponents); Vue.use(ModalComponents);
@ -31,25 +28,29 @@ Vue.use(BootstrapVue);
let debug = new Debugger("treestudyplanviewer"); let debug = new Debugger("treestudyplanviewer");
let strings = load_strings({ let strings = loadStrings({
studyplan: { studyplan: {
studyplan_select_placeholder: 'studyplan_select_placeholder', studyplanSelectPlaceholder: 'studyplan_select_placeholder',
}, },
}); });
/** /**
* Initialize the Page * Initialize the Page
* @param {int} contextid The context we should attempt to work in (1:1 related to the category) * @param {number} contextid The context we should attempt to work in (1:1 related to the category)
* @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context) * @param {number} categoryid The category we shoud attempt to work in (1:1 related to the context)
*/ */
export function init(contextid,categoryid) { export function init(contextid, categoryid) {
// Make sure the id's are numeric and integer // Make sure the id's are numeric and integer
if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;} if (undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1) {
else { contextid = Number(contextid);} // ensure a numeric value instead of string contextid = 1;
if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;} } else { // Ensure a numeric value instead of string
else { categoryid = Number(categoryid);} // ensure a numeric value instead of string contextid = Number(contextid);
}
const in_systemcontext = (contextid <= 1); if (undefined === categoryid || !Number.isInteger(Number(categoryid))) {
categoryid = 0;
} else { // Ensure a numeric value instead of string
categoryid = Number(categoryid);
}
let app = new Vue({ let app = new Vue({
el: '#root', el: '#root',
@ -74,93 +75,93 @@ export function init(contextid,categoryid) {
async mounted() { async mounted() {
call([{ call([{
methodname: 'local_treestudyplan_list_studyplans', methodname: 'local_treestudyplan_list_studyplans',
args: {context_id: contextid} args: {'context_id': contextid}
}])[0].then(function(response){ }])[0].then((response) => {
const timingval = { present: 0, past: 1, future: 2}; const timingval = {present: 0, past: 1, future: 2};
response.sort((a,b) => { response.sort((a, b) => {
const timinga = studyplanTiming(a); const timinga = studyplanTiming(a);
const timingb = studyplanTiming(b); const timingb = studyplanTiming(b);
const t = timingval[timinga] - timingval[timingb]; const t = timingval[timinga] - timingval[timingb];
if(t == 0){ if (t == 0) {
// sort by name if timing is equal // Sort by name if timing is equal
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
} } else {
else {
return t; return t;
} }
}); });
app.studyplans = response; app.studyplans = response;
// load studyplan from hash if applicable // Load studyplan from hash if applicable
const hash = window.location.hash.replace('#',''); const hash = window.location.hash.replace('#', '');
const parts = hash.split("-"); const parts = hash.split("-");
if(!!parts && parts.length > 0 && parts[0] != ''){ if (!!parts && parts.length > 0 && parts[0] != '') {
for(let idx in app.studyplans){ for (let idx in app.studyplans) {
if(app.studyplans[idx].id == parts[0]){ if (app.studyplans[idx].id == parts[0]) {
app.selectStudyplan(app.studyplans[idx],parts[1]); app.selectStudyplan(app.studyplans[idx], parts[1]);
break; break;
} }
} }
} }
return;
}).catch(notification.exception); }).catch(notification.exception);
call([{ call([{
methodname: 'local_treestudyplan_list_available_categories', methodname: 'local_treestudyplan_list_available_categories',
args: { operation: 'view', refcontext_id: contextid} args: {operation: 'view', 'refcontext_id': contextid}
}])[0].then(function(response){ }])[0].then((response) => {
const contexts = []; const contexts = [];
for(const ix in response){ for (const ix in response) {
const cat = response[ix]; const cat = response[ix];
if(cat.studyplancount > 0 || cat.context_id == contextid){ if (cat.studyplancount > 0 || cat.context_id == contextid) {
contexts.push(cat); contexts.push(cat);
} }
} }
app.usedcontexts = contexts; app.usedcontexts = contexts;
return;
}).catch(notification.exception); }).catch(notification.exception);
addBrowserButtonEvent(this.navChanged, this.navChanged); addBrowserButtonEvent(this.navChanged, this.navChanged);
}, },
computed: { computed: {
dropdown_title(){ dropdownTitle() {
if(this.activestudyplan && this.activestudyplan.name){ if (this.activestudyplan && this.activestudyplan.name) {
return this.activestudyplan.name; return this.activestudyplan.name;
} } else {
else{ return this.text.studyplanSelectPlaceholder;
return this.text.studyplan_select_placeholder;
} }
}, },
contextid(){ contextid() {
return contextid; return contextid;
} }
}, },
methods: { methods: {
navChanged() { navChanged() {
const hash = window.location.hash.replace('#',''); const hash = window.location.hash.replace('#', '');
const parts = hash.split("-"); const parts = hash.split("-");
debug.log("Navigation changed",hash,parts); debug.log("Navigation changed", hash, parts);
if(!!parts && parts.length > 0){ if (!!parts && parts.length > 0) {
const planid = Number(parts[0]); const planid = Number(parts[0]);
const studentid = (parts.length > 1)?Number(parts[1]):0; const studentid = (parts.length > 1) ? Number(parts[1]) : 0;
debug.log("Selected ids",planid,studentid,this.selected.planid,this.selected.studentid); debug.log("Selected ids", planid, studentid, this.selected.planid, this.selected.studentid);
if ( planid == 0) { if (planid == 0) {
if (planid != this.selected.planid) { if (planid != this.selected.planid) {
this.closeStudyplan(false); this.closeStudyplan(false);
} }
} else if ( this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0) ) { } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {
debug.info ("Requested plan changed - loading studyplan"); debug.info("Requested plan changed - loading studyplan");
for(let idx in app.studyplans){ for (let idx in app.studyplans) {
const plan = this.studyplans[idx]; const plan = this.studyplans[idx];
if(Number(plan.id) == planid){ if (Number(plan.id) == planid) {
this.selectStudyplan(plan,studentid,false); this.selectStudyplan(plan, studentid, false);
break; break;
} }
} }
} else if (this.selected.studentid != studentid) { } else if (this.selected.studentid != studentid) {
for(const group of app.associatedstudents) { for (const group of app.associatedstudents) {
for(const student of group.users){ for (const student of group.users) {
if(Number(student.id) == studentid){ if (Number(student.id) == studentid) {
app.showStudentView(student,false); app.showStudentView(student, false);
break; break;
} }
} }
@ -168,16 +169,16 @@ export function init(contextid,categoryid) {
} }
} }
}, },
switchContext(ctxid){ switchContext(ctxid) {
const params = new URLSearchParams(location.search); const params = new URLSearchParams(location.search);
params.delete('categoryid'); params.delete('categoryid');
params.set('contextid', ctxid); params.set('contextid', ctxid);
setTimeout(() => { setTimeout(() => {
// Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler. // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.
window.location.href = window.location.pathname + "?" + params.toString(); window.location.href = window.location.pathname + "?" + params.toString();
},50); }, 50);
}, },
closeStudyplan(updatehash=true) { closeStudyplan(updatehash = true) {
app.selected.planid = 0; app.selected.planid = 0;
app.selected.studentid = 0; app.selected.studentid = 0;
app.activestudyplan = null; app.activestudyplan = null;
@ -189,32 +190,32 @@ export function init(contextid,categoryid) {
} }
}, },
selectStudyplan(studyplan,studentid,updatehash=true){ selectStudyplan(studyplan, studentid, updatehash = true) {
app.selected.planid = Number(studyplan.id); app.selected.planid = Number(studyplan.id);
app.selected.studentid = studentid?Number(studentid):0; app.selected.studentid = studentid ? Number(studentid) : 0;
// fetch studyplan // Fetch studyplan
app.loadingstudyplan = true; app.loadingstudyplan = true;
app.associatedstudents = []; app.associatedstudents = [];
app.selectedstudent = null; app.selectedstudent = null;
app.studentstudyplan = null; app.studentstudyplan = null;
call([{ call([{
methodname: 'local_treestudyplan_get_studyplan_map', methodname: 'local_treestudyplan_get_studyplan_map',
args: { id: studyplan.id} args: {id: studyplan.id}
}])[0].then(function(response){ }])[0].then((response) => {
app.activestudyplan = ProcessStudyplan(response,true); app.activestudyplan = processStudyplan(response, true);
call([{ call([{
methodname: 'local_treestudyplan_all_associated_grouped', methodname: 'local_treestudyplan_all_associated_grouped',
args: { studyplan_id: studyplan.id} args: {'studyplan_id': studyplan.id}
}])[0].then(function(response){ }])[0].then((response) => {
app.associatedstudents = response; app.associatedstudents = response;
let foundstudent = false; let foundstudent = false;
if(studentid){ if (studentid) {
for(const group of app.associatedstudents) { for (const group of app.associatedstudents) {
for(const student of group.users){ for (const student of group.users) {
if(student.id == studentid){ if (student.id == studentid) {
foundstudent = true; foundstudent = true;
app.showStudentView(student,updatehash); app.showStudentView(student, updatehash);
break; break;
} }
} }
@ -228,30 +229,32 @@ export function init(contextid,categoryid) {
app.displayedstudyplan = app.activestudyplan; app.displayedstudyplan = app.activestudyplan;
app.loadingstudyplan = false; app.loadingstudyplan = false;
} }
return;
}).catch(notification.exception); }).catch(notification.exception);
return;
}).catch(function(error){ }).catch(function(error) {
notification.exception(error); notification.exception(error);
app.loadingstudyplan = false; app.loadingstudyplan = false;
}); });
}, },
showStudentView(student,updatehash=true){ showStudentView(student, updatehash = true) {
app.selected.studentid = student?Number(student.id):0; app.selected.studentid = student ? Number(student.id) : 0;
if (student) { if (student) {
app.selectedstudent = student; app.selectedstudent = student;
app.studentstudyplan = null; app.studentstudyplan = null;
app.loadingstudyplan = true; app.loadingstudyplan = true;
call([{ call([{
methodname: 'local_treestudyplan_get_user_studyplan', methodname: 'local_treestudyplan_get_user_studyplan',
args: { userid: student.id, studyplanid: app.selected.planid} args: {userid: student.id, studyplanid: app.selected.planid}
}])[0].then(function(response){ }])[0].then((response) => {
app.studentstudyplan = ProcessStudyplan(response,false); app.studentstudyplan = processStudyplan(response, false);
app.displayedstudyplan = app.studentstudyplan; app.displayedstudyplan = app.studentstudyplan;
app.loadingstudyplan = false; app.loadingstudyplan = false;
if (updatehash) { if (updatehash) {
window.location.hash = app.activestudyplan.id + "-" + student.id; window.location.hash = app.activestudyplan.id + "-" + student.id;
} }
}).catch(function(error){ return;
}).catch((error) => {
notification.exception(error); notification.exception(error);
app.loadingstudyplan = false; app.loadingstudyplan = false;
}); });
@ -259,7 +262,7 @@ export function init(contextid,categoryid) {
this.showOverview(updatehash); this.showOverview(updatehash);
} }
}, },
showOverview(updatehash=true){ showOverview(updatehash = true) {
app.selected.studentid = 0; app.selected.studentid = 0;
app.selectedstudent = null; app.selectedstudent = null;
app.studentstudyplan = null; app.studentstudyplan = null;

View File

@ -1,18 +1,18 @@
/*eslint-env es6*/ /* eslint-env es6*/
/*eslint no-console: "off"*/ /* eslint no-console: "off"*/
/** /**
* Hide a primary navigation item by href * Hide a primary navigation item by href
* @param {string|Array} hrefs The link that should be hidden * @param {string|Array} hrefs The link that should be hidden
*/ */
export function hide_primary(hrefs) { export function hidePrimary(hrefs) {
if(typeof hrefs === 'string' || hrefs instanceof String){ if (typeof hrefs === 'string' || hrefs instanceof String) {
hrefs = [hrefs]; hrefs = [hrefs];
} }
if(typeof hrefs === 'object' && Array.isArray(hrefs)){ if (typeof hrefs === 'object' && Array.isArray(hrefs)) {
let css = '' ; let css = '';
for(const ix in hrefs){ for (const ix in hrefs) {
const href = hrefs[ix]; const href = hrefs[ix];
css += ` css += `
li > a[href*="${href}"] { li > a[href*="${href}"] {

View File

@ -1,22 +1,22 @@
/*eslint no-var: "error"*/ /* eslint no-var: "error"*/
/*eslint no-console: "off"*/ /* eslint no-console: "off"*/
/*eslint no-unused-vars: warn */ /* eslint no-unused-vars: warn */
/*eslint max-len: ["error", { "code": 160 }] */ /* eslint max-len: ["error", { "code": 160 }] */
/*eslint-disable no-trailing-spaces */ /* eslint-disable no-trailing-spaces */
/*eslint-env es6*/ /* eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
import {SimpleLine} from './simpleline/simpleline'; import {SimpleLine} from './simpleline/simpleline';
import {get_strings} from 'core/str'; import {get_strings} from 'core/str';
import {load_strings} from './util/string-helper'; import {loadStrings} from './util/string-helper';
import {format_date, format_datetime, studyplanPageTiming,studyplanTiming} from './util/date-helper'; import {formatDate, formatDatetime, studyplanPageTiming,studyplanTiming} from './util/date-helper';
import {addBrowserButtonEvent} from './util/browserbuttonevents'; import {addBrowserButtonEvent} from './util/browserbuttonevents';
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import notification from 'core/notification'; import notification from 'core/notification';
import {svgarcpath} from './util/svgarc'; import {svgarcpath} from './util/svgarc';
import Debugger from './util/debugger'; import Debugger from './util/debugger';
import Config from 'core/config'; import Config from 'core/config';
import {ProcessStudyplan, ProcessStudyplanPage, objCopy} from './studyplan-processor'; import {processStudyplan, processStudyplanPage, objCopy} from './studyplan-processor';
import TSComponents from './treestudyplan-components'; import TSComponents from './treestudyplan-components';
/*import {eventTypes as editSwEventTypes} from 'core/edit_switch';*/ /*import {eventTypes as editSwEventTypes} from 'core/edit_switch';*/
import { premiumenabled, premiumstatus } from "./util/premium"; import { premiumenabled, premiumstatus } from "./util/premium";
@ -78,7 +78,7 @@ export default {
} }
} }
let strings = load_strings({ let strings = loadStrings({
report: { report: {
loading: "loadinghelp@core", loading: "loadinghelp@core",
studyplan_past: "studyplan_past", studyplan_past: "studyplan_past",
@ -254,23 +254,23 @@ export default {
}, },
max: { max: {
type: Number, type: Number,
default: 100, 'default': 100,
}, },
min: { min: {
type: Number, type: Number,
default: 0, 'default': 0,
}, },
stroke: { stroke: {
type: Number, type: Number,
default: 0.2, 'default': 0.2,
}, },
bgopacity: { bgopacity: {
type: Number, type: Number,
default: 0.2, 'default': 0.2,
}, },
title: { title: {
type: String, type: String,
default: "", 'default': "",
}, },
icon: { icon: {
type: String, type: String,
@ -488,7 +488,7 @@ export default {
studyplanid: plan.id, studyplanid: plan.id,
}), }),
}])[0].then(function(response){ }])[0].then(function(response){
self.selectedstudyplan = ProcessStudyplan(response); self.selectedstudyplan = processStudyplan(response);
self.loadingstudyplan = false; self.loadingstudyplan = false;
window.location.hash = self.selectedstudyplan.id; window.location.hash = self.selectedstudyplan.id;
}).catch(notification.exception); }).catch(notification.exception);
@ -551,15 +551,15 @@ export default {
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
teachermode: { teachermode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
coaching: { coaching: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
}, },
data() { data() {
@ -594,7 +594,7 @@ export default {
}, },
methods: { methods: {
pageduration(page){ pageduration(page){
return format_date(page.startdate,false) + " - " + format_date(page.enddate,false); return formatDate(page.startdate,false) + " - " + formatDate(page.enddate,false);
}, },
columns(page) { columns(page) {
return 1+ (page.periods * 2); return 1+ (page.periods * 2);
@ -824,19 +824,19 @@ export default {
props: { props: {
value : { value : {
type: Object, // Studyline type: Object, // Studyline
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
teachermode: { teachermode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
layers: { layers: {
type: Number, type: Number,
default: 1, 'default': 1,
}, },
studentid: { studentid: {
type: Number, type: Number,
@ -885,7 +885,7 @@ export default {
return this.text.byname.replace('{$a}',''); return this.text.byname.replace('{$a}','');
}, },
enrolldate() { enrolldate() {
return format_datetime(this.value.enrol.enrolled_time); return formatDatetime(this.value.enrol.enrolled_time);
}, },
sorted_students() { sorted_students() {
const self =this; const self =this;
@ -923,7 +923,7 @@ export default {
}, },
methods: { methods: {
premiumenabled, premiumenabled,
format_datetime, formatDatetime,
onLineHeightChange(lineid){ onLineHeightChange(lineid){
// All layers for this line have the first slot send an update message on layer height change. // All layers for this line have the first slot send an update message on layer height change.
// When one of those updates is received, record the height and recalculate the total height of the // When one of those updates is received, record the height and recalculate the total height of the
@ -1086,7 +1086,7 @@ export default {
<td><span v-if="student.enrol.enrolled" class="text-success">{{text.enrolled}}</span <td><span v-if="student.enrol.enrolled" class="text-success">{{text.enrolled}}</span
><span v-else class="text-danger">{{text.notenrolled}}</span></td> ><span v-else class="text-danger">{{text.notenrolled}}</span></td>
<td><span v-if="student.enrol.enrolled" <td><span v-if="student.enrol.enrolled"
>{{format_datetime(student.enrol.enrolled_time)}}</span></td> >{{formatDatetime(student.enrol.enrolled_time)}}</span></td>
<td><span v-if="student.enrol.enrolled" <td><span v-if="student.enrol.enrolled"
>{{student.enrol.enrolled_by}}</span></td> >{{student.enrol.enrolled_by}}</span></td>
<td ><b-button v-if="!student.enrol.enrolled && (can_enrol || can_unenrol)" <td ><b-button v-if="!student.enrol.enrolled && (can_enrol || can_unenrol)"
@ -1166,11 +1166,11 @@ export default {
}, },
type : { type : {
type: String, type: String,
default: 'gradable', 'default': 'gradable',
}, },
slotindex : { slotindex : {
type: Number, type: Number,
default: 0, 'default': 0,
}, },
line : { line : {
type: Object, type: Object,
@ -1189,11 +1189,11 @@ export default {
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
teachermode: { teachermode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
period: { period: {
type: Object, type: Object,
@ -1265,7 +1265,7 @@ export default {
props: { props: {
value :{ value :{
type: Object, type: Object,
default: function(){ return null;}, 'default': function(){ return null;},
}, },
plan: { plan: {
type: Object, type: Object,
@ -1273,15 +1273,15 @@ export default {
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
teachermode: { teachermode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
cloud: { cloud: {
type: Boolean, type: Boolean,
default: false, 'default': false,
} }
}, },
data() { data() {
@ -1437,7 +1437,7 @@ export default {
props: { props: {
'value' :{ 'value' :{
type: Object, type: Object,
default: function(){ return null;}, 'default': function(){ return null;},
}, },
}, },
data() { data() {
@ -1492,11 +1492,11 @@ export default {
}, },
computed: { computed: {
startdate(){ startdate(){
return format_date(this.value.course.startdate); return formatDate(this.value.course.startdate);
}, },
enddate(){ enddate(){
if(this.value.course.enddate > 0){ if(this.value.course.enddate > 0){
return format_date(this.value.course.enddate); return formatDate(this.value.course.enddate);
} }
else { else {
return this.text.noenddate; return this.text.noenddate;
@ -1531,7 +1531,7 @@ export default {
methods: { methods: {
completion_icon(completion) { completion_icon(completion) {
switch(completion){ switch(completion){
default: // case "incomplete" default: // Case "incomplete"
return "circle-o"; return "circle-o";
case "pending": case "pending":
return "question-circle"; return "question-circle";
@ -1549,7 +1549,7 @@ export default {
}, },
circle_icon(completion) { circle_icon(completion) {
switch(completion){ switch(completion){
default: // case "incomplete" default: // Case "incomplete"
return null; return null;
case "failed": case "failed":
return "times"; return "times";
@ -1708,11 +1708,11 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
}, },
data() { data() {
@ -1744,7 +1744,7 @@ export default {
methods: { methods: {
completion_icon(completion) { completion_icon(completion) {
switch(completion){ switch(completion){
default: // case "incomplete" default: // Case "incomplete"
return "circle-o"; return "circle-o";
case "pending": case "pending":
return "question-circle"; return "question-circle";
@ -1805,15 +1805,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
course: { course: {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -1960,15 +1960,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
item: { item: {
type: Object, type: Object,
default: function(){ return { id: null};}, 'default': function(){ return { id: null};},
} }
}, },
data() { data() {
@ -2270,11 +2270,11 @@ export default {
return status; return status;
}, },
startdate(){ startdate(){
return format_date(this.value.course.startdate); return formatDate(this.value.course.startdate);
}, },
enddate(){ enddate(){
if(this.value.course.enddate > 0){ if(this.value.course.enddate > 0){
return format_date(this.value.course.enddate); return formatDate(this.value.course.enddate);
} }
else { else {
return this.text.noenddate; return this.text.noenddate;
@ -2445,7 +2445,7 @@ export default {
props: { props: {
value : { value : {
type: Object, // Item type: Object, // Item
default: function(){ return {};}, 'default': function(){ return {};},
}, },
useRequiredGrades: { useRequiredGrades: {
type: Boolean, type: Boolean,
@ -2459,11 +2459,11 @@ export default {
}, },
computed: { computed: {
startdate(){ startdate(){
return format_date(this.value.course.startdate); return formatDate(this.value.course.startdate);
}, },
enddate(){ enddate(){
if(this.value.course.enddate > 0){ if(this.value.course.enddate > 0){
return format_date(this.value.course.enddate); return formatDate(this.value.course.enddate);
} }
else { else {
return this.text.noenddate; return this.text.noenddate;
@ -2557,11 +2557,11 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
useRequiredGrades: { useRequiredGrades: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
}, },
data() { data() {
@ -2670,15 +2670,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
course: { course: {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -2773,15 +2773,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
item: { item: {
type: Object, type: Object,
default: function(){ return { id: null};}, 'default': function(){ return { id: null};},
} }
}, },
data() { data() {
@ -2963,15 +2963,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
width: { width: {
type: Number, type: Number,
default: 150, 'default': 150,
}, },
height: { height: {
type: Number, type: Number,
default: 15, 'default': 15,
} }
}, },
data() { data() {
@ -3038,7 +3038,7 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return { 'default': function(){ return {
students: 0, students: 0,
completed: 0, completed: 0,
completed_pass: 0, completed_pass: 0,
@ -3048,11 +3048,11 @@ export default {
}, },
width: { width: {
type: Number, type: Number,
default: 150, 'default': 150,
}, },
height: { height: {
type: Number, type: Number,
default: 15, 'default': 15,
} }
}, },
data() { data() {
@ -3150,7 +3150,7 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return { 'default': function(){ return {
students: 10, students: 10,
completed: 2, completed: 2,
completed_pass: 2, completed_pass: 2,
@ -3160,15 +3160,15 @@ export default {
}, },
stroke: { stroke: {
type: Number, type: Number,
default: 0.2, 'default': 0.2,
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
title: { title: {
type: String, type: String,
default: "", 'default': "",
} }
}, },
computed: { computed: {
@ -3277,15 +3277,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
teachermode: { teachermode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
} }
}, },
data() { data() {
@ -3318,15 +3318,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
teachermode: { teachermode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
} }
}, },
data() { data() {
@ -3355,15 +3355,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
teachermode: { teachermode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
} }
}, },
data() { data() {
@ -3395,15 +3395,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
teachermode: { teachermode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
} }
}, },
data() { data() {
@ -3614,7 +3614,7 @@ export default {
props: { props: {
'value' :{ 'value' :{
type: Object, type: Object,
default: function(){ return null;}, 'default': function(){ return null;},
}, },
}, },
data() { data() {

View File

@ -1,5 +1,5 @@
/*eslint no-trailing-spaces: "off"*/ /* eslint no-trailing-spaces: "off"*/
/*eslint no-eval: "off"*/ /* eslint no-eval: "off"*/
/*********************************** /***********************************
* Licence: MIT * Licence: MIT

View File

@ -1,5 +1,5 @@
/*eslint no-console: "off"*/ /* eslint no-console: "off"*/
/*eslint no-trailing-spaces: "off"*/ /* eslint no-trailing-spaces: "off"*/
/* /*
The MIT License (MIT) The MIT License (MIT)

View File

@ -10,15 +10,16 @@ import {SimpleLine} from "./simpleline/simpleline";
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import notification from 'core/notification'; import notification from 'core/notification';
import {get_strings} from 'core/str'; import {get_strings} from 'core/str';
import {load_stringkeys, load_strings, strformat } from './util/string-helper'; import {loadStringKeys, loadStrings, strformat } from './util/string-helper';
import {format_date, add_days, datespaninfo } from './util/date-helper'; import {formatDate, addDays, datespaninfo } from './util/date-helper';
import {objCopy,transportItem} from './studyplan-processor'; import {objCopy,transportItem} from './studyplan-processor';
import Debugger from './util/debugger'; import Debugger from './util/debugger';
import Config from 'core/config'; import Config from 'core/config';
import {download,upload} from './downloader'; import {download,upload} from './downloader';
import {ProcessStudyplan, ProcessStudyplanPage} from './studyplan-processor'; import {processStudyplan, processStudyplanPage} from './studyplan-processor';
/* import {eventTypes as editSwEventTypes} from 'core/edit_switch'; */ /* import {eventTypes as editSwEventTypes} from 'core/edit_switch'; */
import { premiumenabled } from "./util/premium"; import { premiumenabled } from "./util/premium";
import FitTextVue from './util/fittext-vue';
import { settings } from "./util/settings"; import { settings } from "./util/settings";
import TSComponents from './treestudyplan-components'; import TSComponents from './treestudyplan-components';
import mFormComponents from "./util/mform-helper"; import mFormComponents from "./util/mform-helper";
@ -38,7 +39,7 @@ const PERIOD_EDITOR_FIELDS =
const LINE_GRAVITY = 1.3; const LINE_GRAVITY = 1.3;
const datechanger_globals = { const datechanger_globals = {
default: false, 'default': false,
defaultchoice: false, defaultchoice: false,
hidewarn: false, hidewarn: false,
}; };
@ -51,6 +52,7 @@ export default {
Vue.use(TSComponents); Vue.use(TSComponents);
Vue.use(mFormComponents); Vue.use(mFormComponents);
Vue.use(pSideBarComponents); Vue.use(pSideBarComponents);
Vue.use(FitTextVue);
let debug = new Debugger("treestudyplan-editor"); let debug = new Debugger("treestudyplan-editor");
/************************************ /************************************
* * * *
@ -78,14 +80,14 @@ export default {
}); });
*/ */
let string_keys = load_stringkeys({ let string_keys = loadStringKeys({
conditions: [ conditions: [
{ value: 'ALL', textkey: 'condition_all'}, { value: 'ALL', textkey: 'condition_all'},
{ value: 'ANY', textkey: 'condition_any'}, { value: 'ANY', textkey: 'condition_any'},
], ],
}); });
let strings = load_strings({ let strings = loadStrings({
studyplan_text: { studyplan_text: {
studyline_editmode: 'studyline_editmode', studyline_editmode: 'studyline_editmode',
toolbox_toggle: 'toolbox_toggle', toolbox_toggle: 'toolbox_toggle',
@ -125,8 +127,8 @@ export default {
advanced_tools: 'advanced_tools', advanced_tools: 'advanced_tools',
confirm_cancel: 'confirm_cancel', confirm_cancel: 'confirm_cancel',
confirm_ok: 'confirm_ok', confirm_ok: 'confirm_ok',
success$core: 'success$core', success$core: 'success@core',
error$core: 'failed$core', error$core: 'failed@completion',
advanced_converted: 'advanced_converted', advanced_converted: 'advanced_converted',
advanced_skipped: 'advanced_skipped', advanced_skipped: 'advanced_skipped',
advanced_failed: 'advanced_failed', advanced_failed: 'advanced_failed',
@ -628,7 +630,7 @@ export default {
}, },
'contextid': { 'contextid': {
type: Number, type: Number,
default: 1 'default': 1
}, },
}, },
data() { data() {
@ -659,7 +661,7 @@ export default {
methodname: 'local_treestudyplan_get_studyplan_map', methodname: 'local_treestudyplan_get_studyplan_map',
args: { id: self.value.id} args: { id: self.value.id}
}])[0].then(function(response){ }])[0].then(function(response){
self.value = ProcessStudyplan(response,true); self.value = processStudyplan(response,true);
debug.info('studyplan processed'); debug.info('studyplan processed');
self.$emit('input',self.value); self.$emit('input',self.value);
}).catch(function(error){ }).catch(function(error){
@ -733,7 +735,7 @@ export default {
self.$emit("created",updatedpage); self.$emit("created",updatedpage);
} }
else { else {
const page = ProcessStudyplanPage(updatedpage); const page = processStudyplanPage(updatedpage);
debug.info('studyplan page processed'); debug.info('studyplan page processed');
if (self.value.periods < page.periods) { if (self.value.periods < page.periods) {
@ -1282,13 +1284,13 @@ export default {
if( days === undefined ){ if( days === undefined ){
days = 1; days = 1;
} }
return add_days(date,days); return addDays(date,days);
}, },
sub_day(date,days) { sub_day(date,days) {
if( days === undefined ){ if( days === undefined ){
days = 1; days = 1;
} }
return add_days(date,0 - days); return addDays(date,0 - days);
}, },
} }
, ,
@ -1363,7 +1365,7 @@ export default {
}, },
'coaching': { 'coaching': {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
}, },
data() { data() {
@ -1730,13 +1732,13 @@ export default {
if( days === undefined ){ if( days === undefined ){
days = 1; days = 1;
} }
return add_days(date,days); return addDays(date,days);
}, },
sub_day(date,days) { sub_day(date,days) {
if( days === undefined ){ if( days === undefined ){
days = 1; days = 1;
} }
return add_days(date,0 - days); return addDays(date,0 - days);
}, },
toolbox_switched(event){ toolbox_switched(event){
this.$emit('toggletoolbox',event); this.$emit('toggletoolbox',event);
@ -2232,11 +2234,11 @@ export default {
props: { props: {
value : { value : {
type: Object, // Studyline type: Object, // Studyline
default: function(){ return {};}, 'default': function(){ return {};},
}, },
layers: { layers: {
type: Number, type: Number,
default: 1, 'default': 1,
}, },
}, },
data() { data() {
@ -2293,7 +2295,7 @@ export default {
props: { props: {
value : { value : {
type: Object, // Studyline type: Object, // Studyline
default: function(){ return {};}, 'default': function(){ return {};},
} }
}, },
data() { data() {
@ -2367,11 +2369,11 @@ export default {
props: { props: {
type : { type : {
type: String, type: String,
default: 'gradable', 'default': 'gradable',
}, },
slotindex : { slotindex : {
type: Number, type: Number,
default: '', 'default': '',
}, },
line : { line : {
type: Object, type: Object,
@ -2463,7 +2465,7 @@ export default {
datechanger: { datechanger: {
coursespan: null, coursespan: null,
periodspan: null, periodspan: null,
default: false, 'default': false,
defaultchoice: false, defaultchoice: false,
hidewarn: false, hidewarn: false,
} }
@ -2696,7 +2698,7 @@ export default {
}, },
hidden: { hidden: {
type: Boolean, type: Boolean,
default: false, 'default': false,
} }
}, },
computed: { computed: {
@ -3464,7 +3466,7 @@ export default {
props: { props: {
'value' :{ 'value' :{
type: Object, type: Object,
default: function(){ return null;}, 'default': function(){ return null;},
}, },
}, },
data() { data() {
@ -3554,11 +3556,11 @@ export default {
} }
}, },
startdate(){ startdate(){
return format_date(this.value.course.startdate); return formatDate(this.value.course.startdate);
}, },
enddate(){ enddate(){
if(this.value.course.enddate > 0){ if(this.value.course.enddate > 0){
return format_date(this.value.course.enddate); return formatDate(this.value.course.enddate);
} }
else { else {
return this.text.noenddate; return this.text.noenddate;
@ -3637,7 +3639,7 @@ export default {
:class="'h-100 t-timing-indicator timing-'+value.course.timing" :class="'h-100 t-timing-indicator timing-'+value.course.timing"
></div> ></div>
<div class="t-item-course-title card-body h-100"> <div class="t-item-course-title card-body h-100">
<fittext maxsize="12pt" minsize="9pt" <fittext maxsize="12pt" minsize="9pt">
<a v-b-modal="'t-item-course-config-'+value.id" <a v-b-modal="'t-item-course-config-'+value.id"
:id="'t-item-course-details-'+value.id" :id="'t-item-course-details-'+value.id"
:href="wwwroot+'/course/view.php?id='+value.course.id" :href="wwwroot+'/course/view.php?id='+value.course.id"
@ -3821,15 +3823,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
course: { course: {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -3922,15 +3924,15 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
guestmode: { guestmode: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
item: { item: {
type: Object, type: Object,
default: function(){ return { id: null};}, 'default': function(){ return { id: null};},
} }
}, },
data() { data() {
@ -4058,7 +4060,7 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -4080,7 +4082,7 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -4100,7 +4102,7 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -4123,7 +4125,7 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return { badge: {}};}, 'default': function(){ return { badge: {}};},
}, },
}, },
data() { data() {
@ -4193,7 +4195,7 @@ export default {
props: { props: {
value : { value : {
type: Array, type: Array,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -4216,7 +4218,7 @@ export default {
props: { props: {
value : { value : {
type: Object, type: Object,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -4282,7 +4284,7 @@ export default {
props: { props: {
value : { value : {
type: Array, type: Array,
default: function(){ return {};}, 'default': function(){ return {};},
}, },
}, },
data() { data() {
@ -4321,7 +4323,7 @@ export default {
props: { props: {
value : { value : {
type: Boolean, type: Boolean,
default: true, 'default': true,
}, },
activepage: { activepage: {
type: Object, type: Object,
@ -4329,11 +4331,11 @@ export default {
}, },
coaching: { coaching: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
studyplanid: { studyplanid: {
type: Number, type: Number,
default: 0, 'default': 0,
} }
}, },
data() { data() {

View File

@ -1,4 +1,5 @@
/*eslint no-console: "off"*/ /* eslint no-console: "off"*/
/* eslint max-depth: ["error", 6]*/
/** /**
* Copy fields from one object to another * Copy fields from one object to another
* @param {Object} target The target to copy to * @param {Object} target The target to copy to
@ -6,11 +7,11 @@
* @param {Array} fields The field names to copy * @param {Array} fields The field names to copy
* @returns {Object} Reference to target * @returns {Object} Reference to target
*/ */
export function objCopy(target,source,fields){ export function objCopy(target, source, fields) {
if ( fields === undefined || fields === null) { if (fields === undefined || fields === null) {
fields = Object.getOwnPropertyNames(source); fields = Object.getOwnPropertyNames(source);
} }
for(const ix in fields) { for (const ix in fields) {
const field = fields[ix]; const field = fields[ix];
target[field] = source[field]; target[field] = source[field];
} }
@ -24,23 +25,23 @@ export function objCopy(target,source,fields){
* @param {*} identifier The value used to match the item * @param {*} identifier The value used to match the item
* @param {string} param The field name to match on (default: 'value') * @param {string} param The field name to match on (default: 'value')
*/ */
export function transportItem(target,source,identifier,param){ export function transportItem(target, source, identifier, param) {
if(!param){ if (!param) {
param = 'value'; param = 'value';
} }
// find item // Find item
let item; let item;
let itemindex; let itemindex;
for(const ix in source){ for (const ix in source) {
if(source[ix][param] == identifier){ if (source[ix][param] == identifier) {
item = source[ix]; item = source[ix];
itemindex = ix; itemindex = ix;
break; break;
} }
} }
if(item){ if (item) {
target.push(item); target.push(item);
source.splice(itemindex,1); source.splice(itemindex, 1);
} }
} }
@ -49,14 +50,12 @@ export function transportItem(target,source,identifier,param){
* @param {Array} studyplans The list of studyplans to load * @param {Array} studyplans The list of studyplans to load
* @returns {Array} List of updated studyplans * @returns {Array} List of updated studyplans
*/ */
export function ProcessStudyplans(studyplans){ export function processStudyplans(studyplans) {
// Unify object references to connections between items, so there are no duplicates // Unify object references to connections between items, so there are no duplicates
for(const isx in studyplans) for (const isx in studyplans) {
{
const studyplan = studyplans[isx]; const studyplan = studyplans[isx];
ProcessStudyplan(studyplan); processStudyplan(studyplan);
} }
return studyplans; return studyplans;
} }
@ -64,12 +63,12 @@ export function ProcessStudyplans(studyplans){
* Perform initial processing on a downloaded studyplan * Perform initial processing on a downloaded studyplan
* Mainly used to create the proper references between items * Mainly used to create the proper references between items
* @param {Object} studyplan The studyplan to process * @param {Object} studyplan The studyplan to process
* @returns Processed studyplan * @returns {object} Processed studyplan
*/ */
export function ProcessStudyplan(studyplan){ export function processStudyplan(studyplan) {
for(const ip in studyplan.pages){ for (const ip in studyplan.pages) {
const page = studyplan.pages[ip]; const page = studyplan.pages[ip];
ProcessStudyplanPage(page); processStudyplanPage(page);
} }
return studyplan; return studyplan;
} }
@ -78,33 +77,33 @@ export function ProcessStudyplan(studyplan){
* Perform initial processing on a downloaded studyplan'page * Perform initial processing on a downloaded studyplan'page
* Mainly used to create the proper references between items * Mainly used to create the proper references between items
* @param {Object} page The studyplan page to process * @param {Object} page The studyplan page to process
* @returns Processed studyplan * @returns {object} Processed studyplan
*/ */
export function ProcessStudyplanPage(page){ export function processStudyplanPage(page) {
let connections = {}; let connections = {};
for(const il in page.studylines) { for (const il in page.studylines) {
const line = page.studylines[il]; const line = page.studylines[il];
for(const is in line.slots ) { for (const is in line.slots) {
const slot = line.slots[is]; const slot = line.slots[is];
if(slot.courses !== undefined){ if (slot.courses !== undefined) {
for(const ic in slot.courses){ for (const ic in slot.courses) {
const itm = slot.courses[ic]; const itm = slot.courses[ic];
for(const idx in itm.connections.in) { for (const idx in itm.connections.in) {
const conn = itm.connections.in[idx]; const conn = itm.connections.in[idx];
if(conn.id in connections){ if (conn.id in connections) {
itm.connections[idx] = connections[conn.id]; itm.connections[idx] = connections[conn.id];
} else { } else {
connections[conn.id] = conn; connections[conn.id] = conn;
} }
} }
for(const idx in itm.connections.out) { for (const idx in itm.connections.out) {
const conn = itm.connections.out[idx]; const conn = itm.connections.out[idx];
if(conn.id in connections){ if (conn.id in connections) {
itm.connections[idx] = connections[conn.id]; itm.connections[idx] = connections[conn.id];
} else { } else {
connections[conn.id] = conn; connections[conn.id] = conn;
@ -113,23 +112,23 @@ export function ProcessStudyplanPage(page){
} }
} }
if(slot.filters !== undefined){ if (slot.filters !== undefined) {
for(const ix in slot.filters){ for (const ix in slot.filters) {
const itm = slot.filters[ix]; const itm = slot.filters[ix];
for(const idx in itm.connections.in) { for (const idx in itm.connections.in) {
const conn = itm.connections.in[idx]; const conn = itm.connections.in[idx];
if(conn.id in connections){ if (conn.id in connections) {
itm.connections[idx] = connections[conn.id]; itm.connections[idx] = connections[conn.id];
} else { } else {
connections[conn.id] = conn; connections[conn.id] = conn;
} }
} }
for(const idx in itm.connections.out) { for (const idx in itm.connections.out) {
const conn = itm.connections.out[idx]; const conn = itm.connections.out[idx];
if(conn.id in connections){ if (conn.id in connections) {
itm.connections[idx] = connections[conn.id]; itm.connections[idx] = connections[conn.id];
} else { } else {
connections[conn.id] = conn; connections[conn.id] = conn;

View File

@ -1,32 +1,22 @@
/*eslint no-var: "error"*/ /* eslint no-var: "error"*/
/*eslint no-console: "off"*/ /* eslint no-unused-vars: warn */
/*eslint no-unused-vars: warn */ /* eslint max-depth: ["error", 6] */
/*eslint max-len: ["error", { "code": 160 }] */ /* eslint camelcase: "off" */
/*eslint-disable no-trailing-spaces */ /* eslint-env es6*/
/*eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
import {load_strings} from './util/string-helper'; import {loadStrings} from './util/string-helper';
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import notification from 'core/notification'; import notification from 'core/notification';
import Debugger from './util/debugger';
import Config from 'core/config';
import TSComponents from './treestudyplan-components'; import TSComponents from './treestudyplan-components';
import FitTextVue from './util/fittext-vue'; import FitTextVue from './util/fittext-vue';
import {format_datetime} from "./util/date-helper"; import {formatDatetime} from "./util/date-helper";
const debug = new Debugger("treestudyplan-viewer");
// Make π available as a constant
const π = Math.PI;
// Gravity value for arrow lines - determines how much a line is pulled in the direction of the start/end before changing direction
const LINE_GRAVITY = 1.3;
/** /**
* Strip tags from html * Strip tags from html
* @param {*} html * @param {*} html
* @returns * @returns {string}
*/ */
function striptags(html) { function striptags(html) {
const tmp = document.createElement("DIV"); const tmp = document.createElement("DIV");
@ -39,6 +29,7 @@ function striptags(html) {
/** /**
* Retrieve condition headers * Retrieve condition headers
* @param {Object} item * @param {Object} item
* @returns {Array}
*/ */
function conditionHeaders(item) { function conditionHeaders(item) {
const course = item.course; const course = item.course;
@ -46,11 +37,11 @@ function conditionHeaders(item) {
if (course.competency) { if (course.competency) {
for (const cmp of course.competency.competencies) { for (const cmp of course.competency.competencies) {
list.push({ list.push({
name: (cmp.details?`${cmp.title} - ${cmp.details}`:cmp.title), name: (cmp.details ? (`${cmp.title} - ${cmp.details}`) : cmp.title),
tooltip: cmp.description, tooltip: cmp.description,
}); });
} }
} else if(course.completion) { } else if (course.completion) {
for (const cnd of course.completion.conditions) { for (const cnd of course.completion.conditions) {
for (const itm of cnd.items) { for (const itm of cnd.items) {
list.push({ list.push({
@ -59,8 +50,8 @@ function conditionHeaders(item) {
}); });
} }
} }
} else if(course.grades) { } else if (course.grades) {
for(const g of course.grades) { for (const g of course.grades) {
if (g.selected) { if (g.selected) {
list.push({ list.push({
name: g.name, name: g.name,
@ -75,6 +66,7 @@ function conditionHeaders(item) {
/** /**
* Retrieve conditions * Retrieve conditions
* @param {Object} item * @param {Object} item
* @returns {Array}
*/ */
function conditions(item) { function conditions(item) {
const course = item.course; const course = item.course;
@ -83,14 +75,14 @@ function conditions(item) {
for (const cmp of course.competency.competencies) { for (const cmp of course.competency.competencies) {
list.push(cmp); list.push(cmp);
} }
} else if(course.completion) { } else if (course.completion) {
for (const cnd of course.completion.conditions) { for (const cnd of course.completion.conditions) {
for (const itm of cnd.items) { for (const itm of cnd.items) {
list.push(itm); list.push(itm);
} }
} }
} else if(course.grades) { } else if (course.grades) {
for(const g of course.grades) { for (const g of course.grades) {
if (g.selected) { if (g.selected) {
list.push(g); list.push(g);
} }
@ -101,11 +93,11 @@ function conditions(item) {
export default { export default {
install(Vue/*,options*/){ install(Vue /* ,options */) {
Vue.use(TSComponents); Vue.use(TSComponents);
Vue.use(FitTextVue); Vue.use(FitTextVue);
let strings = load_strings({ let strings = loadStrings({
report: { report: {
loading: "loadinghelp@core", loading: "loadinghelp@core",
studyplan_past: "studyplan_past", studyplan_past: "studyplan_past",
@ -138,11 +130,11 @@ export default {
} }
}); });
/************************************ /* **********************************
* * * *
* Treestudyplan Viewer components * * Treestudyplan Viewer components *
* * * *
************************************/ * **********************************/
Vue.component('q-studyplanreport', { Vue.component('q-studyplanreport', {
props: { props: {
@ -168,14 +160,11 @@ export default {
} }
}; };
}, },
created() { watch: {
},
watch:{
structure: { structure: {
immediate: true, immediate: true,
handler (structure) { handler(structure) {
this.loadStudents(); // reload the student list this.loadStudents(); // Reload the student list
// (Re)build expansion info structure // (Re)build expansion info structure
let firstperiod = true; let firstperiod = true;
for (const period of structure.periods) { for (const period of structure.periods) {
@ -186,7 +175,7 @@ export default {
this.expansioninfo.periods, this.expansioninfo.periods,
pid, pid,
{ {
expanded: ((firstperiod && period.lines.length > 0)?true:false), expanded: ((firstperiod && period.lines.length > 0) ? true : false),
} }
); );
this.$set( this.$set(
@ -226,12 +215,11 @@ export default {
} }
}, },
computed: { computed: {
sortedstudents(){ sortedstudents() {
const self=this; // Probably could make a deep copy for purity's sake, but this works just as well.
// Probably could make a deep copy for purity's sake, but this works just as well and is probably more efficient.
const students = this.students; const students = this.students;
for (const group of this.students) { for (const group of this.students) {
group.users.sort((a,b) => { group.users.sort((a, b) => {
let d = a; let d = a;
let e = b; let e = b;
if (!this.sorting.asc) { if (!this.sorting.asc) {
@ -239,18 +227,17 @@ export default {
e = a; e = a;
} }
if (this.sorting.header == "lastaccess") { if (this.sorting.header == "lastaccess") {
const dvalue = (d[this.sorting.header]?d[this.sorting.header]:0); const dvalue = (d[this.sorting.header] ? d[this.sorting.header] : 0);
const evalue = (e[this.sorting.header]?e[this.sorting.header]:0); const evalue = (e[this.sorting.header] ? e[this.sorting.header] : 0);
return dvalue - evalue; return dvalue - evalue;
} else { } else {
return String(d[this.sorting.header]).localeCompare(String(e[this.sorting.header])); return String(d[this.sorting.header]).localeCompare(String(e[this.sorting.header]));
} }
}); });
} }
return students; return students;
}, },
resultColCount(){ resultColCount() {
let count = 0; let count = 0;
for (const period of this.structure.periods) { for (const period of this.structure.periods) {
const pid = period.period.id; const pid = period.period.id;
@ -261,7 +248,7 @@ export default {
for (const line of period.lines) { for (const line of period.lines) {
const lid = line.line.id; const lid = line.line.id;
if (!this.expansioninfo.lines[pid][lid].expanded) { if (!this.expansioninfo.lines[pid][lid].expanded) {
count +=1; count += 1;
} else { } else {
for (const item of line.items) { for (const item of line.items) {
if (!this.expansioninfo.items[item.id].expanded) { if (!this.expansioninfo.items[item.id].expanded) {
@ -280,13 +267,13 @@ export default {
methods: { methods: {
loadStudents() { loadStudents() {
const self = this; const self = this;
self.studentsloading=true; self.studentsloading = true;
call([{ call([{
methodname: 'local_treestudyplan_all_associated_grouped', methodname: 'local_treestudyplan_all_associated_grouped',
args: { studyplan_id: this.structure.studyplan.id} args: {'studyplan_id': this.structure.studyplan.id}
}])[0].then(function(response){ }])[0].then((response) => {
self.students = response; self.students = response;
for(const group of self.students) { for (const group of self.students) {
self.$set( self.$set(
self.groupinfo, self.groupinfo,
group.id, group.id,
@ -295,7 +282,7 @@ export default {
} }
); );
for(const student of group.users){ for (const student of group.users) {
self.$set( self.$set(
self.studentresults, self.studentresults,
student.id, student.id,
@ -306,24 +293,27 @@ export default {
); );
call([{ call([{
methodname: 'local_treestudyplan_get_report_data', methodname: 'local_treestudyplan_get_report_data',
args: { pageid: self.structure.page.id, args: {
pageid: self.structure.page.id,
userid: student.id, userid: student.id,
firstperiod: self.structure.firstperiod, firstperiod: self.structure.firstperiod,
lastperiod: self.structure.lastperiod, lastperiod: self.structure.lastperiod,
} }
}])[0].then(function(response){ }])[0].then((response) => {
self.studentresults[student.id].loading = false; self.studentresults[student.id].loading = false;
self.studentresults[student.id].results = response; self.studentresults[student.id].results = response;
return;
}).catch(notification.exception); }).catch(notification.exception);
} }
} }
self.studentsloading=false; self.studentsloading = false;
return;
}).catch(notification.exception); }).catch(notification.exception);
}, },
expansionChanged(parm, id, val) { expansionChanged(parm, id, val) {
if(parm[0] == 'p') { if (parm[0] == 'p') {
parm = 'periods'; parm = 'periods';
} else if(parm[0] == 'l') { } else if (parm[0] == 'l') {
parm = 'lines'; parm = 'lines';
} else { } else {
parm = 'items'; parm = 'items';
@ -422,14 +412,14 @@ export default {
if (this.expansion.periods[pid].expanded) { if (this.expansion.periods[pid].expanded) {
let sum = 0; let sum = 0;
for (const l of period.lines) { for (const l of period.lines) {
sum += this.colspanLine(period,l); sum += this.colspanLine(period, l);
} }
return sum; return sum;
} else { } else {
return 2; return 2;
} }
}, },
colspanLine(period,line) { colspanLine(period, line) {
const pid = period.period.id; const pid = period.period.id;
const lid = line.line.id; const lid = line.line.id;
@ -446,38 +436,33 @@ export default {
colspanItem(item) { colspanItem(item) {
if (this.expansion.items[item.id].expanded) { if (this.expansion.items[item.id].expanded) {
const cs = this.conditions(item); const cs = this.conditions(item);
return 1+cs.length; return 1 + cs.length;
} else { } else {
return 1; return 1;
} }
}, },
togglePeriod(period,val) { togglePeriod(period, val) {
if ( val === undefined) { if (val === undefined) {
val = !(this.expansion.periods[period.id].expanded); val = !(this.expansion.periods[period.id].expanded);
} }
this.$emit('expansion','periods',period.id,val); this.$emit('expansion', 'periods', period.id, val);
}, },
toggleLine(period,line,val) { toggleLine(period, line, val) {
if ( val === undefined) { if (val === undefined) {
val = !(this.expansion.lines[period.id][line.id].expanded); val = !(this.expansion.lines[period.id][line.id].expanded);
} }
this.$emit('expansion','lines',[period.id,line.id],val); this.$emit('expansion', 'lines', [period.id, line.id], val);
}, },
toggleItem(item,val) { toggleItem(item, val) {
if ( val === undefined) { if (val === undefined) {
val = !(this.expansion.items[item.id].expanded); val = !(this.expansion.items[item.id].expanded);
} }
this.$emit('expansion','items',item.id,val); this.$emit('expansion', 'items', item.id, val);
}, },
toggleSort(heading) { toggleSort(heading) {
this.$emit('togglesort',heading); this.$emit('togglesort', heading);
} }
}, },
mounted() {
},
updated() {
},
/* TODO: https://css-tricks.com/position-sticky-and-table-headers/ */ /* TODO: https://css-tricks.com/position-sticky-and-table-headers/ */
template: ` template: `
<thead class='q-header'> <thead class='q-header'>
@ -499,7 +484,8 @@ export default {
<template v-for="p in structure.periods"> <template v-for="p in structure.periods">
<template v-if="expansion.periods[p.period.id].expanded"> <template v-if="expansion.periods[p.period.id].expanded">
<th v-for="l in p.lines" <th v-for="l in p.lines"
:class="'q-line-heading ' + ((expansion.lines[p.period.id][l.line.id].expanded)?'expanded':'collapsed')" :class="'q-line-heading '
+ ((expansion.lines[p.period.id][l.line.id].expanded)?'expanded':'collapsed')"
:colspan="colspanLine(p,l)" :colspan="colspanLine(p,l)"
:rowspan='(expansion.lines[p.period.id][l.line.id].expanded)?1:4' :rowspan='(expansion.lines[p.period.id][l.line.id].expanded)?1:4'
><span class="q-wrap"><fittext vertical maxsize="18pt" ><span class="q-wrap"><fittext vertical maxsize="18pt"
@ -554,7 +540,8 @@ export default {
<th v-for="c in conditions(item)" <th v-for="c in conditions(item)"
rowspan="2" rowspan="2"
class='q-condition-heading' class='q-condition-heading'
><span class="q-wrap"><fittext vertical maxsize="14pt"><a class='q-label q-condition-label' ><span class="q-wrap"
><fittext vertical maxsize="14pt"><a class='q-label q-condition-label'
:title="c.tooltip" href="#" @click.prevent :title="c.tooltip" href="#" @click.prevent
v-b-tooltip.focus v-b-tooltip.focus
v-html="c.name"></a v-html="c.name"></a
@ -597,11 +584,11 @@ export default {
}, },
resultcolumns: { resultcolumns: {
type: Number, type: Number,
default: 1 'default': 1
}, },
studentinfocolumns: { studentinfocolumns: {
type: Number, type: Number,
default: 1 'default': 1
}, },
expanded: { expanded: {
type: Boolean, type: Boolean,
@ -615,8 +602,8 @@ export default {
computed: { computed: {
}, },
methods: { methods: {
toggleGroup(){ toggleGroup() {
this.$emit('togglegroup',this.group); this.$emit('togglegroup', this.group);
} }
}, },
template: ` template: `
@ -634,11 +621,11 @@ export default {
props: { props: {
resultcolumns: { resultcolumns: {
type: Number, type: Number,
default: 1 'default': 1
}, },
studentinfocolumns: { studentinfocolumns: {
type: Number, type: Number,
default: 1 'default': 1
}, },
}, },
data() { data() {
@ -671,14 +658,14 @@ export default {
}, },
loading: { loading: {
type: Boolean, type: Boolean,
default: false 'default': false
}, },
expansion: { expansion: {
type: Object, type: Object,
}, },
even: { even: {
type: Boolean, type: Boolean,
default: false, 'default': false,
} }
}, },
data() { data() {
@ -689,7 +676,7 @@ export default {
computed: { computed: {
lastaccess() { lastaccess() {
if (this.student.lastaccess) { if (this.student.lastaccess) {
return format_datetime(this.student.lastaccess); // Takes date in milliseconds return formatDatetime(this.student.lastaccess); // Takes date in milliseconds
} else { } else {
return this.text.never; return this.text.never;
} }
@ -715,9 +702,6 @@ export default {
}, },
}, },
/* https://css-tricks.com/position-sticky-and-table-headers/ */ /* https://css-tricks.com/position-sticky-and-table-headers/ */
/* TODO: Rework below to make use of tables. Use <Thead> as main element. Then create multiple <tr> as needed for the headers.
This should create a much better view than using divs overal.
*/
template: ` template: `
<tr :class="'q-student-results userrow ' + (even?'even':'odd')"> <tr :class="'q-student-results userrow ' + (even?'even':'odd')">
<td class='q-studentinfo q-name'><fittext maxsize="12pt">{{student.firstname}} {{student.lastname}}</fittext></td> <td class='q-studentinfo q-name'><fittext maxsize="12pt">{{student.firstname}} {{student.lastname}}</fittext></td>
@ -766,7 +750,7 @@ export default {
}, },
loading: { loading: {
type: Boolean, type: Boolean,
default: false 'default': false
}, },
}, },
data() { data() {
@ -780,13 +764,13 @@ export default {
if (!course.enrolled) { if (!course.enrolled) {
return false; return false;
} else { } else {
return (course.completion || course.competency || course.grades)?true:false; return (course.completion || course.competency || course.grades) ? true : false;
} }
}, },
completion_icon() { completion_icon() {
const completion = this.item.completion; const completion = this.item.completion;
switch(completion){ switch (completion) {
default: // case "incomplete" default: // Case "incomplete"
return "circle-o"; return "circle-o";
case "pending": case "pending":
return "question-circle"; return "question-circle";
@ -835,7 +819,7 @@ export default {
}, },
loading: { loading: {
type: Boolean, type: Boolean,
default: false 'default': false
}, },
conditionidx: { conditionidx: {
type: Number, type: Number,
@ -867,8 +851,8 @@ export default {
}, },
completion_icon() { completion_icon() {
const completion = this.condition_completion(); const completion = this.condition_completion();
switch(completion){ switch (completion) {
default: // case "incomplete" default: // Case "incomplete"
return "circle-o"; return "circle-o";
case "pending": case "pending":
return "question-circle"; return "question-circle";
@ -891,12 +875,12 @@ export default {
// Return grade if possible. // Return grade if possible.
return this.condition.grade; return this.condition.grade;
} }
} else if(course.completion) { } else if (course.completion) {
if (this.condition.grade) { if (this.condition.grade) {
// Return grade if possible. // Return grade if possible.
return this.condition.grade; return this.condition.grade;
} }
} else if(course.grades) { } else if (course.grades) {
return this.condition.grade; return this.condition.grade;
} }
// Fallback to completion icon. // Fallback to completion icon.
@ -919,17 +903,18 @@ export default {
} else { } else {
return "incomplete"; return "incomplete";
} }
} else if(course.completion) { } else if (course.completion) {
return this.condition.status; return this.condition.status;
} else if(course.grades) { } else if (course.grades) {
return this.condition.completion; return this.condition.completion;
} else {
return "incomplete";
} }
} }
}, },
methods: { methods: {
}, },
// TODO: Show actual grades when relevant at all (don;t forget the grade point completion requirement)
template: ` template: `
<span class='q-conditionresult'> <span class='q-conditionresult'>
<fittext v-if="item.lineenrolled" maxsize="10pt" singleline dynamic> <fittext v-if="item.lineenrolled" maxsize="10pt" singleline dynamic>
@ -951,8 +936,5 @@ export default {
</span> </span>
`, `,
}); });
}, },
}; };

View File

@ -1,20 +1,21 @@
/*eslint no-var: "error"*/ /* eslint no-var: "error"*/
/*eslint no-console: "off"*/ /* eslint no-console: "off"*/
/*eslint-disable no-trailing-spaces */ /* eslint camelcase: "off" */
/*eslint-env es6*/ /* eslint-disable no-trailing-spaces */
/* eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
import {load_strings} from './util/string-helper'; import {loadStrings} from './util/string-helper';
import {format_date, studyplanDates, studyplanTiming} from './util/date-helper'; import {formatDate, studyplanDates, studyplanTiming} from './util/date-helper';
import FitTextVue from './util/fittext-vue'; import FitTextVue from './util/fittext-vue';
export default { export default {
install(Vue/*,options*/){ install(Vue /* ,options */) {
Vue.use(FitTextVue); Vue.use(FitTextVue);
let strings = load_strings({ let strings = loadStrings({
studyplancard: { studyplancard: {
open: "open", open: "open",
noenddate: "noenddate", noenddate: "noenddate",
@ -50,7 +51,7 @@ export default {
}, },
ignoresuspend: { ignoresuspend: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
}, },
data() { data() {
@ -67,14 +68,14 @@ export default {
return false; return false;
} }
}, },
timing(){ timing() {
return studyplanTiming(this.value); return studyplanTiming(this.value);
}, },
dates(){ dates() {
const dates = studyplanDates(this.value); const dates = studyplanDates(this.value);
return { return {
start: format_date(dates.start), start: formatDate(dates.start),
end: (dates.end)?format_date(dates.end):this.text.noenddate, end: (dates.end) ? formatDate(dates.end) : this.text.noenddate,
}; };
}, },
suspended() { suspended() {
@ -84,7 +85,7 @@ export default {
}, },
methods: { methods: {
onOpenClick(e) { onOpenClick(e) {
this.$emit('open',e); this.$emit('open', e);
} }
}, },
template: ` template: `
@ -140,11 +141,15 @@ export default {
}, },
min: { min: {
type: Number, type: Number,
default() { return 0;} default() {
return 0;
}
}, },
max: { max: {
type: Number, type: Number,
default() { return 1;} default() {
return 1;
}
} }
}, },
data() { data() {
@ -154,24 +159,24 @@ export default {
}, },
computed: { computed: {
width_completed() { width_completed() {
if(this.value) { if (this.value) {
const v = ( (this.value - this.min) / (this.max - this.min)); const v = ((this.value - this.min) / (this.max - this.min));
return v * 100; return v * 100;
} else { } else {
return 0; return 0;
} }
}, },
width_incomplete() { width_incomplete() {
if(this.value) { if (this.value) {
const v = ( (this.value - this.min) / (this.max - this.min)); const v = ((this.value - this.min) / (this.max - this.min));
return (1-v) * 100; return (1 - v) * 100;
} else { } else {
return 100; return 100;
} }
}, },
percentage_complete() { percentage_complete() {
if(this.value) { if (this.value) {
const v = ( (this.value - this.min) / (this.max - this.min)); const v = ((this.value - this.min) / (this.max - this.min));
return Math.round(v * 100) + "%"; return Math.round(v * 100) + "%";
} else { } else {
return "0%"; return "0%";
@ -196,8 +201,6 @@ export default {
`, `,
}); });
/* /*
* S-STUDYLINE-HEADER-HEADING * S-STUDYLINE-HEADER-HEADING
* The only reasing this is not a simple empty div, is the fact that the header height * The only reasing this is not a simple empty div, is the fact that the header height
@ -207,7 +210,9 @@ export default {
props: { props: {
identifier: { identifier: {
type: Number, // Page reference. type: Number, // Page reference.
default() { return 0;} default() {
return 0;
}
} }
}, },
data() { data() {
@ -224,9 +229,9 @@ export default {
}, },
methods: { methods: {
onHeaderHeightChange(newheight,identifier){ onHeaderHeightChange(newheight, identifier) {
if (this.identifier == identifier) { if (this.identifier == identifier) {
if(this.$refs.main){ if (this.$refs.main) {
this.$refs.main.style.height = `${newheight}px`; this.$refs.main.style.height = `${newheight}px`;
} }
} }
@ -240,22 +245,24 @@ export default {
Vue.component('s-studyline-header-period', { Vue.component('s-studyline-header-period', {
props: { props: {
value: { value: {
type: Object, // dict with layer as index type: Object, // Dict with layer as index
}, },
identifier: { identifier: {
type: Number, // Page reference. type: Number, // Page reference.
default() { return 0;} default() {
return 0;
}
}, },
mode: { mode: {
type: String, type: String,
default: "view", 'default': "view",
} }
}, },
mounted() { mounted() {
const self=this; const self = this;
if(self.value.period == 1){ if (self.value.period == 1) {
self.resizeListener = new ResizeObserver(() => { self.resizeListener = new ResizeObserver(() => {
if(self.$refs.main){ if (self.$refs.main) {
const size = self.$refs.main.getBoundingClientRect(); const size = self.$refs.main.getBoundingClientRect();
ItemEventBus.$emit('headerHeightChange', size.height, self.identifier); ItemEventBus.$emit('headerHeightChange', size.height, self.identifier);
} }
@ -263,25 +270,24 @@ export default {
} }
}, },
unmounted() { unmounted() {
if(this.resizeListener) { if (this.resizeListener) {
this.resizeListener.disconnect(); this.resizeListener.disconnect();
} }
}, },
computed: { computed: {
startdate(){ startdate() {
return format_date(this.value.startdate); return formatDate(this.value.startdate);
}, },
enddate(){ enddate() {
return format_date(this.value.enddate); return formatDate(this.value.enddate);
}, },
current(){ current() {
if( this.value && this.value.startdate && this.value.enddate){ if (this.value && this.value.startdate && this.value.enddate) {
const now = new Date(); const now = new Date();
const pstart = new Date(this.value.startdate); const pstart = new Date(this.value.startdate);
const pend = new Date(this.value.enddate); const pend = new Date(this.value.enddate);
return (now >= pstart && now < pend); return (now >= pstart && now < pend);
} } else {
else {
return false; return false;
} }
} }
@ -320,15 +326,21 @@ export default {
}, },
variant: { variant: {
type: String, type: String,
default() { return "info"; } default() {
return "info";
}
}, },
pill: { pill: {
type: Boolean, type: Boolean,
default() { return false; } default() {
return false;
}
}, },
size: { size: {
type: String, type: String,
default() { return "";} default() {
return "";
}
} }
}, },
data() { data() {
@ -374,15 +386,21 @@ export default {
}, },
variant: { variant: {
type: String, type: String,
default() { return "info"; } default() {
return "info";
}
}, },
position: { position: {
type: String, type: String,
default() { return "below"; } default() {
return "below";
}
}, },
size: { size: {
type: String, type: String,
default() { return "";} default() {
return "";
}
} }
}, },
data() { data() {
@ -404,7 +422,7 @@ export default {
}, },
methods: { methods: {
displaydate(field) { displaydate(field) {
return format_date(field.value,false); return formatDate(field.value, false);
}, },
}, },
template: ` template: `
@ -439,38 +457,40 @@ export default {
props: { props: {
value: { value: {
type: Object, type: Object,
default() { return null;} default() {
return null;
}
}, },
options: { options: {
type: Array, type: Array,
}, },
grouped: { grouped: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
titlefield: { titlefield: {
type: String, type: String,
default: "title", 'default': "title",
}, },
labelfield: { labelfield: {
type: String, type: String,
default: "label", 'default': "label",
}, },
optionsfield: { optionsfield: {
type: String, type: String,
default: "options", 'default': "options",
}, },
defaultselectable: { defaultselectable: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
variant: { variant: {
type: String, type: String,
default: "", 'default': "",
}, },
arrows: { arrows: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
}, },
data() { data() {
@ -481,19 +501,19 @@ export default {
computed: { computed: {
fields() { fields() {
const f = []; const f = [];
if(this.defaultselectable) { if (this.defaultselectable) {
f.push(null); f.push(null);
} }
if (this.grouped) { if (this.grouped) {
for ( const gix in this.options) { for (const gix in this.options) {
const group = this.options[gix]; const group = this.options[gix];
for ( const ix in group[this.optionsfield]) { for (const ix in group[this.optionsfield]) {
const v = group[this.optionsfield][ix]; const v = group[this.optionsfield][ix];
f.push(v); f.push(v);
} }
} }
} else { } else {
for ( const ix in this.options) { for (const ix in this.options) {
const v = this.options[ix]; const v = this.options[ix];
f.push(v); f.push(v);
} }
@ -501,8 +521,12 @@ export default {
return f; return f;
}, },
bubblevalue: { bubblevalue: {
get() { return (this.value)?this.value:null;}, get() {
set(v) { this.$emit('input',(v)?v:null);}, return (this.value) ? this.value : null;
},
set(v) {
this.$emit('input', (v) ? v : null);
},
} }
}, },
methods: { methods: {
@ -514,7 +538,7 @@ export default {
}, },
atLast() { atLast() {
if (this.fields.length > 0) { if (this.fields.length > 0) {
const l = this.fields.length -1; const l = this.fields.length - 1;
return this.fields[l] == this.value; return this.fields[l] == this.value;
} }
return true; // Since it disables the button, do so if pressing it would make no sense. return true; // Since it disables the button, do so if pressing it would make no sense.
@ -523,23 +547,23 @@ export default {
if (this.fields.length > 0) { if (this.fields.length > 0) {
const index = this.fields.indexOf(this.value); const index = this.fields.indexOf(this.value);
if (index > 0) { if (index > 0) {
this.$emit("input",this.fields[index -1]); this.$emit("input", this.fields[index - 1]);
this.$emit("change",this.fields[index -1]); this.$emit("change", this.fields[index - 1]);
} }
} }
}, },
next() { next() {
if (this.fields.length > 0) { if (this.fields.length > 0) {
const index = this.fields.indexOf(this.value); const index = this.fields.indexOf(this.value);
const l = this.fields.length -1; const l = this.fields.length - 1;
if (index >= 0 && index < l) { if (index >= 0 && index < l) {
this.$emit("input",this.fields[index + 1]); this.$emit("input", this.fields[index + 1]);
this.$emit("change",this.fields[index + 1]); this.$emit("change", this.fields[index + 1]);
} }
} }
}, },
selectedchanged(value) { selectedchanged(value) {
this.$emit("change",value); this.$emit("change", value);
} }
}, },
template: ` template: `

View File

@ -1,8 +1,9 @@
/*eslint no-var: "error" */ /* eslint no-var: "error" */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/*eslint linebreak-style: "off" */ /* eslint linebreak-style: "off" */
/*eslint no-trailing-spaces: "off" */ /* eslint no-trailing-spaces: "off" */
/*eslint-env es6*/ /* eslint capitalized-comments: "off" */
/* eslint-env es6 */
import Debugger from './debugger'; import Debugger from './debugger';
const debug = new Debugger("browserbuttonevents"); const debug = new Debugger("browserbuttonevents");
@ -14,25 +15,25 @@ const debug = new Debugger("browserbuttonevents");
* @param {function} reloadCB * @param {function} reloadCB
*/ */
export function addBrowserButtonEvent(backwardCB, forwardCB = null, reloadCB = null) { export function addBrowserButtonEvent(backwardCB, forwardCB = null, reloadCB = null) {
debug.log("Registering navigation events",backwardCB,forwardCB,reloadCB); debug.log("Registering navigation events", backwardCB, forwardCB, reloadCB);
const reorient = (e) => { // After travelling in the history stack const reorient = (e) => { // After travelling in the history stack
const positionLastShown = Number( // If none, then zero const positionLastShown = Number( // If none, then zero
sessionStorage.getItem( 'positionLastShown' )); sessionStorage.getItem('positionLastShown'));
// debug.log("Popstate event",e,positionLastShown,history); // debug.log("Popstate event",e,positionLastShown,history);
let position = history.state; // Absolute position in stack let position = history.state; // Absolute position in stack
if( position === null ) { // Meaning a new entry on the stack if (position === null) { // Meaning a new entry on the stack
position = positionLastShown + 1; // Top of stack position = positionLastShown + 1; // Top of stack
// (1) Stamp the entry with its own position in the stack // (1) Stamp the entry with its own position in the stack
history.replaceState( position, /*no title*/'' ); history.replaceState(position, /* no title */'');
} }
// (2) Keep track of the last position shown // (2) Keep track of the last position shown
sessionStorage.setItem( 'positionLastShown', String(position) ); sessionStorage.setItem('positionLastShown', String(position));
// (3) Discover the direction of travel by comparing the two // (3) Discover the direction of travel by comparing the two
const direction = Math.sign( position - positionLastShown ); const direction = Math.sign(position - positionLastShown);
debug.log( 'Travel direction is ' + direction ); debug.log('Travel direction is ' + direction);
// One of backward (-1), reload (0) and forward (1) // One of backward (-1), reload (0) and forward (1)
if (direction == -1 && backwardCB) { if (direction == -1 && backwardCB) {
backwardCB(); backwardCB();
@ -44,6 +45,6 @@ export function addBrowserButtonEvent(backwardCB, forwardCB = null, reloadCB = n
reloadCB(); reloadCB();
} }
}; };
//addEventListener( 'pageshow', reorient ); // addEventListener( 'pageshow', reorient );
addEventListener( 'popstate', reorient ); // Travel in same page addEventListener('popstate', reorient); // Travel in same page
} }

View File

@ -1,7 +1,8 @@
/*eslint no-trailing-spaces: "off"*/ /* eslint camelcase: "off" */
/*eslint no-eval: "off"*/ /* eslint capitalized-comments: "off" */
/* eslint no-eval: "off" */
/*********************************** /* **********************************
* Licence: MIT * Licence: MIT
* (c) 2023 Morglod/jchnkl * (c) 2023 Morglod/jchnkl
* converted from the typescript @ https://github.com/Morglod/csscalc/ * converted from the typescript @ https://github.com/Morglod/csscalc/
@ -18,7 +19,7 @@ export const Absolute = {
/** One quarter of a millimeter. 1Q = 1/40th of 1cm */ /** One quarter of a millimeter. 1Q = 1/40th of 1cm */
Q: 96 / 101.6, Q: 96 / 101.6,
/** One inch. 1in = 2.54cm = 96px */ /** One inch. 1in = 2.54cm = 96px */
in: 96, 'in': 96,
/** One pica. 1pc = 12pt = 1/6th of 1in */ /** One pica. 1pc = 12pt = 1/6th of 1in */
pc: 96 / 6, pc: 96 / 6,
/** One point. 1pt = 1/72nd of 1in */ /** One point. 1pt = 1/72nd of 1in */
@ -31,6 +32,7 @@ export const Absolute = {
* Equal to 1% of the height of the viewport * Equal to 1% of the height of the viewport
* @param {number} count * @param {number} count
* @param {object} ctx * @param {object} ctx
* @returns {number}
*/ */
vh: (count = 1, ctx) => { vh: (count = 1, ctx) => {
return ((ctx ? ctx.viewportHeight : window.innerHeight) / 100) * count; return ((ctx ? ctx.viewportHeight : window.innerHeight) / 100) * count;
@ -39,6 +41,7 @@ export const Absolute = {
* Equal to 1% of the width of the viewport * Equal to 1% of the width of the viewport
* @param {number} count * @param {number} count
* @param {object} ctx * @param {object} ctx
* @returns {number}
*/ */
vw: (count = 1, ctx) => { vw: (count = 1, ctx) => {
return ((ctx ? ctx.viewportWidth : window.innerWidth) / 100) * count; return ((ctx ? ctx.viewportWidth : window.innerWidth) / 100) * count;
@ -47,6 +50,7 @@ export const Absolute = {
* 1/100th of the smallest viewport side * 1/100th of the smallest viewport side
* @param {number} count * @param {number} count
* @param {object} ctx * @param {object} ctx
* @returns {number}
*/ */
vmin: (count = 1, ctx) => { vmin: (count = 1, ctx) => {
return ( return (
@ -61,6 +65,7 @@ export const Absolute = {
* 1/100th of the largest viewport side * 1/100th of the largest viewport side
* @param {number} count * @param {number} count
* @param {object} ctx * @param {object} ctx
* @returns {number}
*/ */
vmax: (count = 1, ctx) => { vmax: (count = 1, ctx) => {
return ( return (
@ -75,6 +80,7 @@ export const Absolute = {
* Represents the font-size of <html> element * Represents the font-size of <html> element
* @param {number} count * @param {number} count
* @param {object} ctx * @param {object} ctx
* @returns {number}
*/ */
rem: (count = 1, ctx) => { rem: (count = 1, ctx) => {
return ( return (
@ -89,6 +95,7 @@ export const Absolute = {
* percent of width * percent of width
* @param {number} count * @param {number} count
* @param {object} ctx * @param {object} ctx
* @returns {number}
*/ */
"%w": (count = 1, ctx) => { "%w": (count = 1, ctx) => {
return ((ctx ? ctx.width : document.body.clientWidth) / 100) * count; return ((ctx ? ctx.width : document.body.clientWidth) / 100) * count;
@ -97,6 +104,7 @@ export const Absolute = {
* percent of height * percent of height
* @param {number} count * @param {number} count
* @param {object} ctx * @param {object} ctx
* @returns {number}
*/ */
"%h": (count = 1, ctx) => { "%h": (count = 1, ctx) => {
return ((ctx ? ctx.height : document.body.clientHeight) / 100) * count; return ((ctx ? ctx.height : document.body.clientHeight) / 100) * count;
@ -120,7 +128,7 @@ export const Absolute = {
* @param {*} fromUnits * @param {*} fromUnits
* @param {*} toUnits * @param {*} toUnits
* @param {*} ctx * @param {*} ctx
* @returns * @returns {number}
*/ */
export function convert(count, fromUnits, toUnits, ctx = calcCtx()) { export function convert(count, fromUnits, toUnits, ctx = calcCtx()) {
const baseUnit = Units[fromUnits]; const baseUnit = Units[fromUnits];
@ -138,7 +146,7 @@ export const Absolute = {
* @param {*} expr * @param {*} expr
* @param {*} toUnits * @param {*} toUnits
* @param {*} ctx * @param {*} ctx
* @returns * @returns {String}
*/ */
export function convertAllInStr(expr, toUnits, ctx = calcCtx()) { export function convertAllInStr(expr, toUnits, ctx = calcCtx()) {
return expr.replace(UnitRegexpGM, (substr, count, unit) => { return expr.replace(UnitRegexpGM, (substr, count, unit) => {
@ -149,7 +157,7 @@ export const Absolute = {
/** /**
* *
* @param {*} el * @param {*} el
* @returns * @returns {object}
*/ */
export function calcCtx(el) { export function calcCtx(el) {
if (el) { if (el) {
@ -182,13 +190,16 @@ export const Absolute = {
* @param {*} expression * @param {*} expression
* @param {*} el_ctx * @param {*} el_ctx
* @param {*} ctx * @param {*} ctx
* @returns * @returns {String}
*/ */
export function calc(expression, el_ctx, ctx) { export function calc(expression, el_ctx, ctx) {
if (el_ctx === undefined) {ctx = calcCtx(); } if (el_ctx === undefined) {
else { ctx = calcCtx();
} else {
if (el_ctx instanceof HTMLElement) { if (el_ctx instanceof HTMLElement) {
if (!ctx) {ctx = calcCtx(el_ctx); } if (!ctx) {
ctx = calcCtx(el_ctx);
}
} else { } else {
ctx = el_ctx; ctx = el_ctx;
} }

View File

@ -1,11 +1,12 @@
/* eslint capitalized-comments: "off" */
/** /**
* Format a date according to localized custom * Format a date according to localized custom
* @param {Date|string} d The date to convert * @param {Date|string} d The date to convert
* @param {boolean} short Short format (default false) * @param {boolean} short Short format (default false)
* @returns {string} * @returns {string}
*/ */
export function format_date(d,short){ export function formatDate(d, short) {
if(!(d instanceof Date)){ if (!(d instanceof Date)) {
if (typeof d == 'number') { if (typeof d == 'number') {
d *= 1000; // Convert from seconds to milliseconds. d *= 1000; // Convert from seconds to milliseconds.
} }
@ -13,12 +14,12 @@ export function format_date(d,short){
} }
let monthformat = "short"; let monthformat = "short";
if(short === true){ if (short === true) {
monthformat = "numeric"; monthformat = "numeric";
} else if (short === false) { } else if (short === false) {
monthformat = "long"; monthformat = "long";
} }
return d.toLocaleDateString(document.documentElement.lang,{ return d.toLocaleDateString(document.documentElement.lang, {
year: 'numeric', month: monthformat, day: 'numeric' year: 'numeric', month: monthformat, day: 'numeric'
}); });
} }
@ -29,8 +30,8 @@ export function format_date(d,short){
* @param {boolean} short Short format (default false) * @param {boolean} short Short format (default false)
* @returns {string} * @returns {string}
*/ */
export function format_datetime(d,short){ export function formatDatetime(d, short) {
if(!(d instanceof Date)){ if (!(d instanceof Date)) {
if (typeof d == 'number') { if (typeof d == 'number') {
d *= 1000; // Convert from seconds to milliseconds. d *= 1000; // Convert from seconds to milliseconds.
} }
@ -38,14 +39,14 @@ export function format_datetime(d,short){
} }
let monthformat = "short"; let monthformat = "short";
if(short === true){ if (short === true) {
monthformat = "numeric"; monthformat = "numeric";
} else if (short === false) { } else if (short === false) {
monthformat = "long"; monthformat = "long";
} }
return d.toLocaleDateString(document.documentElement.lang,{ return d.toLocaleDateString(document.documentElement.lang, {
year: 'numeric', month: monthformat, day: 'numeric' year: 'numeric', month: monthformat, day: 'numeric'
})+" "+d.toLocaleTimeString(document.documentElement.lang,{ }) + " " + d.toLocaleTimeString(document.documentElement.lang, {
timeStyle: "short", timeStyle: "short",
}); });
} }
@ -57,9 +58,13 @@ export function format_datetime(d,short){
* @param {Date|string} last Last day of the span * @param {Date|string} last Last day of the span
* @returns {Object} Object containing formatted start and end dates and span information * @returns {Object} Object containing formatted start and end dates and span information
*/ */
export function datespaninfo(first,last){ export function datespaninfo(first, last) {
if(!(first instanceof Date)){ first = new Date(first);} if (!(first instanceof Date)) {
if(!(last instanceof Date)){ last = new Date(last);} first = new Date(first);
}
if (!(last instanceof Date)) {
last = new Date(last);
}
// Make sure the end date is at the very end of the day and the start date at the very beginning // Make sure the end date is at the very end of the day and the start date at the very beginning
first.setHours(0); first.setHours(0);
@ -71,11 +76,11 @@ export function datespaninfo(first,last){
last.setSeconds(59); last.setSeconds(59);
last.setMilliseconds(999); last.setMilliseconds(999);
const dayspan = Math.round(((last - first)+1)/(24*60*60*1000)); // Add one millisecond to offset the 999 ms const dayspan = Math.round(((last - first) + 1) / (24 * 60 * 60 * 1000)); // Add one millisecond to offset the 999 ms
const years = Math.floor(dayspan/365); // Yes, we ignore leap years/leap days const years = Math.floor(dayspan / 365); // Yes, we ignore leap years/leap days
const ydaysleft = dayspan % 365; const ydaysleft = dayspan % 365;
const weeks = Math.floor(ydaysleft/7); const weeks = Math.floor(ydaysleft / 7);
const wdaysleft = ydaysleft % 7; const wdaysleft = ydaysleft % 7;
return { return {
@ -86,8 +91,8 @@ export function datespaninfo(first,last){
weeks: weeks, weeks: weeks,
days: wdaysleft, days: wdaysleft,
formatted: { formatted: {
first: format_date(first), first: formatDate(first),
last: format_date(last), last: formatDate(last),
} }
}; };
@ -96,7 +101,7 @@ export function datespaninfo(first,last){
/** /**
* Format a Date object to YYYY-MM-DD format * Format a Date object to YYYY-MM-DD format
* @param {Date} date Date object * @param {Date} date Date object
* @returns Date string in YYYY-MM-DD format * @returns {String} Date string in YYYY-MM-DD format
*/ */
function dateYYYYMMDD(date) { function dateYYYYMMDD(date) {
const d = new Date(date); const d = new Date(date);
@ -117,28 +122,28 @@ function dateYYYYMMDD(date) {
* String formatting function - replaces {name} in string by value of same key in values parameter * String formatting function - replaces {name} in string by value of same key in values parameter
* @param {string} datestr String containing date format in YYYY-MM-DD * @param {string} datestr String containing date format in YYYY-MM-DD
* @param {int} days Object containing keys to replace {key} strings with. Make negative to subtract * @param {int} days Object containing keys to replace {key} strings with. Make negative to subtract
* @returns Date string in YYYY-MM-DD format * @returns {String} Date string in YYYY-MM-DD format
*/ */
export function add_days(datestr,days) { export function addDays(datestr, days) {
const date = new Date(datestr); const date = new Date(datestr);
const newdate = new Date(date.getTime() + (days * 86400000) ); // Add n days in ms. const newdate = new Date(date.getTime() + (days * 86400000)); // Add n days in ms.
return dateYYYYMMDD(newdate); return dateYYYYMMDD(newdate);
} }
/** /**
* Determine start and end dates of a studyplan * Determine start and end dates of a studyplan
* @param {*} plan * @param {*} plan
* @returns * @returns {object}
*/ */
export function studyplanDates(plan) { export function studyplanDates(plan) {
let earliestStart = null; let earliestStart = null;
let latestEnd = null; let latestEnd = null;
let openEnded = false; let openEnded = false;
for(const ix in plan.pages) { for (const ix in plan.pages) {
const page = plan.pages[ix]; const page = plan.pages[ix];
const s = new Date(page.startdate); const s = new Date(page.startdate);
if (! page.enddate) { if (!page.enddate) {
openEnded = true; // One of the pages has no end date set... openEnded = true; // One of the pages has no end date set...
} }
@ -146,7 +151,7 @@ export function studyplanDates(plan) {
earliestStart = s; earliestStart = s;
} }
if ( page.enddate ) { if (page.enddate) {
const e = new Date(page.enddate); const e = new Date(page.enddate);
if (!latestEnd || e > latestEnd) { if (!latestEnd || e > latestEnd) {
latestEnd = e; latestEnd = e;
@ -155,7 +160,7 @@ export function studyplanDates(plan) {
} }
return { return {
start: earliestStart, start: earliestStart,
end: (openEnded)?null:latestEnd, end: (openEnded) ? null : latestEnd,
}; };
} }
@ -174,8 +179,8 @@ export function studyplanTiming(plan) {
const dates = studyplanDates(plan); const dates = studyplanDates(plan);
if(dates.start < now){ if (dates.start < now) {
if( dates.end && now > dates.end) { if (dates.end && now > dates.end) {
return 'past'; return 'past';
} else { } else {
return 'present'; return 'present';
@ -197,10 +202,10 @@ export function studyplanPageTiming(page) {
return "present"; return "present";
} }
const start = new Date(page.startdate); const start = new Date(page.startdate);
const end = (page.enddate)?(new Date(page.enddate)):null; const end = (page.enddate) ? (new Date(page.enddate)) : null;
if(start < now){ if (start < now) {
if( end && now > end) { if (end && now > end) {
return 'past'; return 'past';
} else { } else {
return 'present'; return 'present';

View File

@ -1,6 +1,6 @@
/*eslint no-var: "error"*/ /* eslint no-var: "error"*/
/*eslint no-console: "off"*/ /* eslint no-console: "off"*/
/*eslint-env es6*/ /* eslint-env es6*/
// Put this file in path/to/plugin/amd/src // Put this file in path/to/plugin/amd/src
// You can call it anything you like // You can call it anything you like
@ -14,15 +14,20 @@
function debounce(func, wait, immediate) { function debounce(func, wait, immediate) {
let timeout; let timeout;
return function() { return function() {
let context = this, args = arguments; let context = this;
let args = arguments;
let later = function() { let later = function() {
timeout = null; timeout = null;
if (!immediate){ func.apply(context, args); } if (!immediate) {
func.apply(context, args);
}
}; };
let callNow = immediate && !timeout; let callNow = immediate && !timeout;
clearTimeout(timeout); clearTimeout(timeout);
timeout = setTimeout(later, wait); timeout = setTimeout(later, wait);
if (callNow){ func.apply(context, args); } if (callNow) {
func.apply(context, args);
}
}; };
} }

View File

@ -1,17 +1,17 @@
/*eslint no-var: "error"*/ /* eslint no-var: "error"*/
/*eslint no-console: "off"*/ /* eslint no-console: "off"*/
/*eslint-env es6*/ /* eslint-env es6*/
import Config from "core/config"; import Config from "core/config";
/** /**
* Start a new debugger * Start a new debugger
* @param {*} handle The string to attach to all messages from this debugger * @param {*} handle The string to attach to all messages from this debugger
* @returns Debugger object * @returns {object} Debugger object
*/ */
export default function (handle) { export default function(handle) {
let output_enabled = Config.developerdebug; let outputEnabled = Config.developerdebug;
if(output_enabled){ if (outputEnabled) {
console.warn(`In development environment. Debugger output enabled for ${handle}`); console.warn(`In development environment. Debugger output enabled for ${handle}`);
} else { } else {
console.warn(`In production environment. Debugger output disabled for ${handle}`); console.warn(`In production environment. Debugger output disabled for ${handle}`);
@ -19,74 +19,73 @@ export default function (handle) {
return { return {
write() { write() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.info.apply(console, args); console.info.apply(console, args);
} }
}, },
log() { log() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.log.apply(console, args); console.log.apply(console, args);
} }
}, },
info() { info() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.info.apply(console, args); console.info.apply(console, args);
} }
}, },
warn() { warn() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.warn.apply(console, args); console.warn.apply(console, args);
} }
}, },
error() { error() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.error.apply(console, args); console.error.apply(console, args);
} }
}, },
time() { time() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.time.apply(console, args); console.time.apply(console, args);
} }
}, },
timeEnd() { timeEnd() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.timeEnd.apply(console, args); console.timeEnd.apply(console, args);
} }
}, },
timeLog() { timeLog() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.timeLog.apply(console, args); console.timeLog.apply(console, args);
} }
}, },
timeStamp() { timeStamp() {
if (output_enabled) { if (outputEnabled) {
let args = Array.prototype.slice.call(arguments); let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": "); args.unshift(handle + ": ");
console.timeStamp.apply(console, args); console.timeStamp.apply(console, args);
} }
}, },
enable: function debugger_enable() { enable() {
output_enabled = true; outputEnabled = true;
}, },
disable() {
disable: function debugger_disable() { outputEnabled = false;
output_enabled = false;
} }
}; };

View File

@ -1,23 +1,23 @@
/*eslint no-unused-vars: warn */ /* eslint no-unused-vars: warn */
/*eslint max-len: ["error", { "code": 160 }] */ /* eslint max-len: ["error", { "code": 160 }] */
/*eslint-disable no-trailing-spaces */ /* eslint-disable no-trailing-spaces */
/*eslint-env es6*/ /* eslint capitalized-comments: "off" */
/* eslint-env es6*/
import {calc} from "./css-calc"; import {calc} from "./css-calc";
import fitty from "./fitty"; import fitty from "./fitty";
import {textFit} from "./textfit";
export default { export default {
install(Vue/*,options*/){ install(Vue/* ,options */) {
Vue.component('fittext',{ Vue.component('fittext', {
props: { props: {
maxsize: { maxsize: {
type: String, type: String,
default: "512px", 'default': "512px",
}, },
minsize: { minsize: {
type: String, type: String,
default: "10px", 'default': "10px",
}, },
vertical: Boolean, vertical: Boolean,
singleline: Boolean, singleline: Boolean,
@ -54,10 +54,10 @@ export default {
}); });
}, },
unmounted() { unmounted() {
if(this.mutationObserver) { if (this.mutationObserver) {
this.mutationObserver.disconnect(); this.mutationObserver.disconnect();
} }
if(this.resizeObserver) { if (this.resizeObserver) {
this.resizeObserver.disconnect(); this.resizeObserver.disconnect();
} }
}, },

View File

@ -1,4 +1,4 @@
/*eslint no-console: "off"*/ /* eslint-disable */
/* /*
Copyright (c) 2017-2021 Rik Schennink - All rights reserved. Copyright (c) 2017-2021 Rik Schennink - All rights reserved.

View File

@ -1,31 +1,32 @@
/** /**
* convert a text field into an integer only text field * Convert a text field into an integer only text field
* @param {string} id The Id of the form field * @param {string} id The Id of the form field
* @param {bool} unsigned Allow only unsigned values * @param {bool} unsigned Allow only unsigned values
* @param {bool} nonzero Do not allow zero values * @param {bool} nonzero Do not allow zero values
*/ */
export function text_integer(id,unsigned=false,nonzero=false){ export function textInteger(id, unsigned = false, nonzero = false) {
const element = document.getElementById(id); const element = document.getElementById(id);
if (element) { if (element) {
element.addEventListener("input",() => { element.addEventListener("input", () => {
var val = element.value; var val = element.value;
if (val != '') { if (val != '') {
if ((isNaN(val) && !(!unsigned && val == '-')) || (unsigned && val < 0) || (nonzero && val == 0)) { if ((isNaN(val) && !(!unsigned && val == '-')) || (unsigned && val < 0) || (nonzero && val == 0)) {
// Set input value empty // Set input value empty
if (unsigned) { if (unsigned) {
element.value = val.replace(/[^0-9]/g,''); element.value = val.replace(/[^0-9]/g, '');
if (nonzero && val == 0) { if (nonzero && val == 0) {
element.value = ''; element.value = '';
} }
} else { } else {
element.value = val.replace(/[^0-9-]/g,'').replace(/(.{1})(-)/g,'$1'); element.value = val.replace(/[^0-9-]/g, '').replace(/(.{1})(-)/g, '$1');
} }
return false; return false;
} else { } else {
return true; return true;
} }
} }
return null;
}); });
} }
} }

View File

@ -1,18 +1,19 @@
/*eslint no-var: "error"*/ /* eslint no-var: "error" */
/*eslint no-console: "off"*/ /* eslint no-console: "off" */
/*eslint no-bitwise: "off"*/ /* eslint no-bitwise: "off" */
/*eslint-disable no-trailing-spaces*/ /* eslint-disable no-trailing-spaces */
/*eslint-env es6*/ /* eslint camelcase: "off" */
// Put this file in path/to/plugin/amd/src /* eslint capitalized-comments: "off" */
/* eslint-env es6 */
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import {processCollectedJavascript} from 'core/fragment'; import {processCollectedJavascript} from 'core/fragment';
import {replaceNodeContents} from 'core/templates'; import {replaceNodeContents} from 'core/templates';
import notification from 'core/notification'; import notification from 'core/notification';
import {load_strings} from './string-helper'; import {loadStrings} from './string-helper';
import Debugger from './debugger'; import Debugger from './debugger';
//import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only // import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only
//import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only // import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only
/* Moodle 3.11 safe import for when needed /* Moodle 3.11 safe import for when needed
let markFormSubmitted = () => {}; let markFormSubmitted = () => {};
@ -31,10 +32,10 @@ import('core_form/changechecker').then((ns) => {
/** /**
* Create a random UUID in both secure and insecure contexts * Create a random UUID in both secure and insecure contexts
* @returns UUID * @returns {String} UUID
*/ */
function create_uuid() { function create_uuid() {
if (crypto.randomUUID !== undefined ) { if (crypto.randomUUID !== undefined) {
return crypto.randomUUID(); return crypto.randomUUID();
} else { } else {
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c => return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
@ -44,9 +45,9 @@ function create_uuid() {
} }
export default { export default {
install(Vue/*,options*/){ install(Vue /* ,options */) {
let debug = new Debugger("treestudyplan-mform-helper"); let debug = new Debugger("treestudyplan-mform-helper");
let strings = load_strings({ let strings = loadStrings({
editmod: { editmod: {
save$core: "save$core", save$core: "save$core",
cancel$core: "cancel$core", cancel$core: "cancel$core",
@ -63,15 +64,15 @@ export default {
}, },
title: { title: {
type: String, type: String,
default: "", 'default': "",
}, },
variant: { variant: {
type: String, type: String,
default: "primary", 'default': "primary",
}, },
type: { type: {
type: String, type: String,
default: "link", 'default': "link",
} }
}, },
data() { data() {
@ -90,28 +91,29 @@ export default {
methods: { methods: {
openForm() { openForm() {
const self = this; const self = this;
self.$refs["editormodal"].show(); self.$refs.editormodal.show();
}, },
onShown() { onShown() {
const self = this; const self = this;
debug.info(`Loading form "${self.name}" with params`,self.params); debug.info(`Loading form "${self.name}" with params`, self.params);
self.loading = false; self.loading = false;
call([{ call([{
methodname: 'local_treestudyplan_get_mform', methodname: 'local_treestudyplan_get_mform',
args: {formname: self.name, params: JSON.stringify(self.params)} args: {formname: self.name, params: JSON.stringify(self.params)}
}])[0].then((data)=>{ }])[0].then((data) => {
const html = data.html; const html = data.html;
self.loading = false; self.loading = false;
// Process the collected javascript; // Process the collected javascript;
const js = processCollectedJavascript(data.javascript); const js = processCollectedJavascript(data.javascript);
replaceNodeContents(self.$refs["content"], html, js); replaceNodeContents(self.$refs.content, html, js);
self.initListenChanges(); self.initListenChanges();
return;
}).catch(notification.exception); }).catch(notification.exception);
}, },
onSave() { onSave() {
const self = this; const self = this;
let form = this.$refs["content"].getElementsByTagName("form")[0]; let form = this.$refs.content.getElementsByTagName("form")[0];
// markFormSubmitted(form); // Moodle 4.00+ only // markFormSubmitted(form); // Moodle 4.00+ only
// We call this, so other modules can update the form with the latest state. // We call this, so other modules can update the form with the latest state.
@ -122,13 +124,14 @@ export default {
const formdata = new FormData(form); const formdata = new FormData(form);
const data = new URLSearchParams(formdata).toString(); const data = new URLSearchParams(formdata).toString();
if(this.checkSave()){ if (this.checkSave()) {
call([{ call([{
methodname: 'local_treestudyplan_submit_mform', methodname: 'local_treestudyplan_submit_mform',
args: {formname: self.name, params: JSON.stringify(self.params), formdata: data} args: {formname: self.name, params: JSON.stringify(self.params), formdata: data}
}])[0].then((response)=>{ }])[0].then((response) => {
const updatedplan = JSON.parse(response.data); const updatedplan = JSON.parse(response.data);
self.$emit("saved",updatedplan,formdata); self.$emit("saved", updatedplan, formdata);
return;
}).catch(notification.exception); }).catch(notification.exception);
} }
/* No error if we cannot save, since it would just be to handle the edge case /* No error if we cannot save, since it would just be to handle the edge case
@ -143,24 +146,24 @@ export default {
if (el.classList.contains("is-invalid")) { if (el.classList.contains("is-invalid")) {
canSave = false; canSave = false;
} }
},this); }, this);
this.submitok = canSave; this.submitok = canSave;
return canSave; return canSave;
}, },
initListenChanges() { initListenChanges() {
const content = this.$refs["content"]; const content = this.$refs.content;
this.inputs = content.querySelectorAll("input.form-control"); this.inputs = content.querySelectorAll("input.form-control");
// Check if save needs to be blocked immediately. (delay call by a few ms) // Check if save needs to be blocked immediately. (delay call by a few ms)
setTimeout(this.checkSave, 100); setTimeout(this.checkSave, 100);
// Disconnect any existing observer. // Disconnect any existing observer.
if(this.observer) { if (this.observer) {
this.observer.disconnect(); this.observer.disconnect();
} }
// Initialize new observer and callback. // Initialize new observer and callback.
this.observer = new MutationObserver((mutationList) => { this.observer = new MutationObserver((mutationList) => {
for(const mix in mutationList){ for (const mix in mutationList) {
const mutation = mutationList[mix]; const mutation = mutationList[mix];
if (mutation.type === 'attributes' && mutation.attributeName === 'class') { if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
this.checkSave(); this.checkSave();
@ -170,15 +173,15 @@ export default {
// Connect the observer to the form inputs. // Connect the observer to the form inputs.
this.inputs.forEach(el => { this.inputs.forEach(el => {
this.observer.observe(el,{ attributes: true }); this.observer.observe(el, {attributes: true});
},this); }, this);
}, },
}, },
unmount() { unmount() {
if(this.observer) { if (this.observer) {
this.observer.disconnect(); this.observer.disconnect();
} }
}, },

View File

@ -1,20 +1,20 @@
/*eslint no-var: "error" */ /* eslint no-var: "error" */
/*eslint-env es6*/ /* eslint-env es6*/
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import notification from 'core/notification'; import notification from 'core/notification';
// Prepare default value. // Prepare default value.
let premiumstatus_cache = null; let premiumstatusCache = null;
/** /**
* Check if premium status is enabled. * Check if premium status is enabled.
* @returns {Bool} True/False * @returns {Bool} True/False
*/ */
export function premiumenabled (){ export function premiumenabled() {
const premium = premiumstatus(); const premium = premiumstatus();
if (premium) { if (premium) {
return (premium.enabled)?true:false; return (premium.enabled) ? true : false;
} else { } else {
return true; // Temporarily return true, that is easier than going full async. return true; // Temporarily return true, that is easier than going full async.
} }
@ -25,16 +25,17 @@ export function premiumenabled (){
* @returns {Object} The premium status object * @returns {Object} The premium status object
*/ */
function premiumstatus() { function premiumstatus() {
if (!premiumstatus_cache) { if (!premiumstatusCache) {
// Retrieve premium status if needed. // Retrieve premium status if needed.
call([{ call([{
methodname: 'local_treestudyplan_premiumstatus', methodname: 'local_treestudyplan_premiumstatus',
args: {} args: {}
}])[0].then(function(response){ }])[0].then((response) => {
premiumstatus_cache = response; premiumstatusCache = response;
return;
}).catch(notification.exception); }).catch(notification.exception);
} }
return premiumstatus_cache; return premiumstatusCache;
} }
// Preload premium status. // Preload premium status.

View File

@ -1,35 +1,35 @@
/*eslint no-unused-vars: warn */ /* eslint no-unused-vars: warn */
/*eslint max-len: ["error", { "code": 160 }] */ /* eslint max-len: ["error", { "code": 160 }] */
/*eslint-disable no-trailing-spaces */ /* eslint-disable no-trailing-spaces */
/*eslint-disable no-console */ /* eslint-disable no-console */
/*eslint-env es6*/ /* eslint-env es6*/
import Debugger from './debugger'; import Debugger from './debugger';
let debug = new Debugger("p-sidebar"); let debug = new Debugger("p-sidebar");
export default { export default {
install(Vue/*,options*/){ install(Vue /* ,options */) {
Vue.component('p-sidebar',{ Vue.component('p-sidebar', {
props: { props: {
value: { value: {
type: Boolean, type: Boolean,
default: true, 'default': true,
}, },
right: { right: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
shadow: { shadow: {
type: Boolean, type: Boolean,
default: false, 'default': false,
}, },
target: { target: {
type: String, type: String,
default: 'body', 'default': 'body',
}, },
offsetRef: { offsetRef: {
type: String, type: String,
default: '', 'default': '',
} }
}, },
data() { data() {
@ -51,7 +51,7 @@ export default {
initializeWrapperContent = true; initializeWrapperContent = true;
// Otherwise, create it. // Otherwise, create it.
this.wrapper = document.createElement("div"); this.wrapper = document.createElement("div");
this.wrapper.setAttribute("id","p-sidebar-wrapper"); this.wrapper.setAttribute("id", "p-sidebar-wrapper");
} }
// First check if the contentwrapper already exists // First check if the contentwrapper already exists
this.contentwrapper = document.querySelector("#p-sidebar-contentwrapper"); this.contentwrapper = document.querySelector("#p-sidebar-contentwrapper");
@ -59,20 +59,20 @@ export default {
initializeWrapperContent = true; initializeWrapperContent = true;
// Otherwise, create it. // Otherwise, create it.
this.contentwrapper = document.createElement("div"); this.contentwrapper = document.createElement("div");
this.contentwrapper.setAttribute("id","p-sidebar-contentwrapper"); this.contentwrapper.setAttribute("id", "p-sidebar-contentwrapper");
this.wrapper.appendChild(this.contentwrapper); this.wrapper.appendChild(this.contentwrapper);
} }
if (initializeWrapperContent) { if (initializeWrapperContent) {
// Find containing target (otherwise use body) // Find containing target (otherwise use body)
let targetEl = document.querySelector(target); let targetEl = document.querySelector(target);
console.info(`Targeting '${target}' to `,targetEl); console.info(`Targeting '${target}' to `, targetEl);
if (!targetEl || targetEl.nodeType == "HTML") { if (!targetEl || targetEl.nodeType == "HTML") {
targetEl = document.querySelector("body"); targetEl = document.querySelector("body");
} }
debug.warn(`Initializing wrappers with content of target `,targetEl); debug.warn(`Initializing wrappers with content of target `, targetEl);
// Move all target content parts to content wrapper.... // Move all target content parts to content wrapper....
while (targetEl.childNodes.length >0) { while (targetEl.childNodes.length > 0) {
this.contentwrapper.appendChild(targetEl.childNodes[0]); this.contentwrapper.appendChild(targetEl.childNodes[0]);
} }
// Add sidebar wrapper to target Element // Add sidebar wrapper to target Element
@ -83,20 +83,20 @@ export default {
rePosition(right) { rePosition(right) {
// Place the container elsewhere in the DOM. // Place the container elsewhere in the DOM.
const el = this.$refs.container; const el = this.$refs.container;
if(right) { if (right) {
this.wrapper.insertBefore(el,this.contentwrapper.nextSibling); this.wrapper.insertBefore(el, this.contentwrapper.nextSibling);
} else { } else {
this.wrapper.insertBefore(el,this.contentwrapper); this.wrapper.insertBefore(el, this.contentwrapper);
} }
}, },
setOffset(reference) { setOffset(reference) {
const ref = reference?document.querySelector(reference):null; const ref = reference ? document.querySelector(reference) : null;
console.info(`Setting offset from '${reference}'`,ref); console.info(`Setting offset from '${reference}'`, ref);
let offsetTop = (ref?ref.offsetTop:0); let offsetTop = (ref ? ref.offsetTop : 0);
offsetTop+=(offsetTop!=0)?"px":""; offsetTop += (offsetTop != 0) ? "px" : "";
const el = this.$refs.container; const el = this.$refs.container;
el.style.height=`calc( 100vh - ${offsetTop})`; el.style.height = `calc( 100vh - ${offsetTop})`;
el.style.marginTop=offsetTop; el.style.marginTop = offsetTop;
} }
}, },
@ -113,16 +113,16 @@ export default {
const el = self.$refs.container; const el = self.$refs.container;
this.initWrappers(this.target); this.initWrappers(this.target);
this.setOffset(this.offsetRef); this.setOffset(this.offsetRef);
this.rePosition(this.right,this.besides); this.rePosition(this.right, this.besides);
this.resizeObserver = new ResizeObserver(() => { this.resizeObserver = new ResizeObserver(() => {
let wx = 0 - el.getBoundingClientRect().width; let wx = 0 - el.getBoundingClientRect().width;
wx += (wx!=0)?"px":""; wx += (wx != 0) ? "px" : "";
el.style.setProperty("--p-sidebar-hideoffset",wx); el.style.setProperty("--p-sidebar-hideoffset", wx);
}); });
this.resizeObserver.observe(el); this.resizeObserver.observe(el);
}, },
unmounted() { unmounted() {
if(this.resizeObserver) { if (this.resizeObserver) {
this.resizeObserver.disconnect(); this.resizeObserver.disconnect();
} }
}, },

View File

@ -1,5 +1,5 @@
/*eslint no-var: "error" */ /* eslint no-var: "error" */
/*eslint-env es6*/ /* eslint-env es6*/
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import notification from 'core/notification'; import notification from 'core/notification';
@ -10,11 +10,11 @@ let settingcache = null;
/** /**
* Check if premium status is enabled. * Check if premium status is enabled.
* @param {String} key * @param {String} key
* @returns {} * @returns {*}
*/ */
export function settings ( key ){ export function settings(key) {
const settings = loadsettings(); const settings = loadsettings();
if ( key in settings ) { if (key in settings) {
return settings[key]; return settings[key];
} else { } else {
return null; return null;
@ -31,8 +31,9 @@ function loadsettings() {
call([{ call([{
methodname: 'local_treestudyplan_getsettings', methodname: 'local_treestudyplan_getsettings',
args: {} args: {}
}])[0].then(function(response){ }])[0].then((response) => {
settingcache = response; settingcache = response;
return;
}).catch(notification.exception); }).catch(notification.exception);
} }
return settingcache; return settingcache;

View File

@ -1,8 +1,11 @@
/* eslint camelcase: "off" */
import {get_strings} from 'core/str'; import {get_strings} from 'core/str';
import {getStrings} from 'core/str'; import {getStrings} from 'core/str';
import Debugger from './debugger';
let debug = new Debugger("string-helper");
/* Determine the proper getstrings function to use (MDL4.3+ recommends use of getStrings, which is jquery independent) */ /* Determine the proper getstrings function to use (MDL4.3+ recommends use of getStrings, which is jquery independent) */
const getstr_func = (getStrings !== undefined)?getStrings:get_strings; const getstrFunc = (getStrings !== undefined) ? getStrings : get_strings;
/** /**
* Load the translation of strings from a strings object * Load the translation of strings from a strings object
@ -10,25 +13,28 @@ const getstr_func = (getStrings !== undefined)?getStrings:get_strings;
* @param {String} plugin Name of plugin to load for by default (leave empty for 'local_treestudyplan') * @param {String} plugin Name of plugin to load for by default (leave empty for 'local_treestudyplan')
* @returns {Object} The map with strings loaded in * @returns {Object} The map with strings loaded in
*/ */
export function load_strings(strings,plugin){ export function loadStrings(strings, plugin) {
if (plugin === undefined) { if (plugin === undefined) {
plugin = 'local_treestudyplan'; plugin = 'local_treestudyplan';
} }
for(let idx in strings){ for (let idx in strings) {
let stringkeys = []; let stringkeys = [];
for(const handle in strings[idx]){ for (const handle in strings[idx]) {
const key = strings[idx][handle]; const key = strings[idx][handle];
let parts = key.split(/[$@]/); let parts = key.split(/[$@]/);
let identifier = parts[0]; let identifier = parts[0];
let component = (parts.length > 1)?parts[1]:plugin; let component = (parts.length > 1) ? parts[1] : plugin;
stringkeys.push({ key: identifier, component: component}); stringkeys.push({key: identifier, component: component});
} }
getstr_func(stringkeys).then(function(str){ getstrFunc(stringkeys).then(function(str) {
let i = 0; let i = 0;
for(const handle in strings[idx]){ for (const handle in strings[idx]) {
strings[idx][handle] = str[i]; strings[idx][handle] = str[i];
i++; i++;
} }
return;
}).catch((x) => {
debug.warn(x);
}); });
} }
@ -42,26 +48,29 @@ export function load_strings(strings,plugin){
* @param {String} plugin Name of plugin to load for by default (leave empty for 'local_treestudyplan') * @param {String} plugin Name of plugin to load for by default (leave empty for 'local_treestudyplan')
* @returns {Object} The map with strings loaded in * @returns {Object} The map with strings loaded in
*/ */
export function load_stringkeys(string_keys,plugin){ export function loadStringKeys(string_keys, plugin) {
if (plugin === undefined) { if (plugin === undefined) {
plugin = 'local_treestudyplan'; plugin = 'local_treestudyplan';
} }
for(let idx in string_keys){ for (let idx in string_keys) {
// Get text strings for condition settings // Get text strings for condition settings
let stringkeys = []; let stringkeys = [];
for(const i in string_keys[idx]){ for (const i in string_keys[idx]) {
const key = string_keys[idx][i].textkey; const key = string_keys[idx][i].textkey;
let parts = key.split("$"); let parts = key.split("$");
let identifier = parts[0]; let identifier = parts[0];
let component = (parts.length > 1)?parts[1]:plugin; let component = (parts.length > 1) ? parts[1] : plugin;
stringkeys.push({ key: identifier, component: component}); stringkeys.push({key: identifier, component: component});
} }
getstr_func(stringkeys).then(function(strings){ getstrFunc(stringkeys).then(function(strings) {
for(const i in strings) { for (const i in strings) {
const s = strings[i]; const s = strings[i];
const l = string_keys[idx][i]; const l = string_keys[idx][i];
l.text = s; l.text = s;
} }
return;
}).catch((x) => {
debug.warn(x);
}); });
} }
return string_keys; return string_keys;
@ -71,9 +80,9 @@ export function load_stringkeys(string_keys,plugin){
* String formatting function - replaces {name} in string by value of same key in values parameter * String formatting function - replaces {name} in string by value of same key in values parameter
* @param {string} str String t * @param {string} str String t
* @param {object} values Object containing keys to replace {key} strings with * @param {object} values Object containing keys to replace {key} strings with
* @returns Formatted string * @returns {string} Formatted string
*/ */
export function strformat(str,values) { export function strformat(str, values) {
return str.replace(/\{(\w+)\}/g, (m, m1) => { return str.replace(/\{(\w+)\}/g, (m, m1) => {
if (m1 && values.hasOwnProperty(m1)) { if (m1 && values.hasOwnProperty(m1)) {
return values[m1]; return values[m1];

View File

@ -22,30 +22,30 @@ const cos = Math.cos;
const sin = Math.sin; const sin = Math.sin;
const π = Math.PI; const π = Math.PI;
const f_matrix_times = (( [[a,b], [c,d]], [x,y]) => [ a * x + b * y, c * x + d * y]); const fMatrixTimes = (([[a, b], [c, d]], [x, y]) => [a * x + b * y, c * x + d * y]);
const f_rotate_matrix = (x => [[cos(x),-sin(x)], [sin(x), cos(x)]]); const fRotateMatrix = (x => [[cos(x), -sin(x)], [sin(x), cos(x)]]);
const f_vec_add = (([a1, a2], [b1, b2]) => [a1 + b1, a2 + b2]); const fVecAdd = (([a1, a2], [b1, b2]) => [a1 + b1, a2 + b2]);
// function modified by pmkuipers for text params // Function modified by pmkuipers for text params
/** /**
* Create svg path text for an arc * Create svg path text for an arc
* @param {*} center [cx,cy] center of ellipse * @param {*} center [cx,cy] center of ellipse
* @param {*} radius [rx,ry] major minor radius * @param {*} radius [rx,ry] major minor radius
* @param {*} angle [t1, Δ] start angle, in radian, angle to sweep, in radian. positive. * @param {*} angle [t1, Δ] start angle, in radian, angle to sweep, in radian. positive.
* @param {*} φ rotation on the whole, in radian * @param {*} φ rotation on the whole, in radian
* @returns a SVG path element that represent a ellipse. Text describing the arc path in an svg path element * @returns {string} a SVG path description that represent a ellipse. Text describing the arc path in an svg path element
*/ */
const svgarcpath = (([cx,cy],[rx,ry], [t1, Δ], φ ) => { const svgarcpath = (([cx, cy], [rx, ry], [t1, Δ], φ) => {
Δ = Δ % (2*π); Δ = Δ % (2 * π);
const rotMatrix = f_rotate_matrix (φ); const rotMatrix = fRotateMatrix(φ);
const [sX, sY] = ( f_vec_add ( f_matrix_times ( rotMatrix, [rx * cos(t1), ry * sin(t1)] ), [cx,cy] ) ); const [sX, sY] = (fVecAdd(fMatrixTimes(rotMatrix, [rx * cos(t1), ry * sin(t1)]), [cx, cy]));
const [eX, eY] = ( f_vec_add ( f_matrix_times ( rotMatrix, [rx * cos(t1+Δ), ry * sin(t1+Δ)] ), [cx,cy] ) ); const [eX, eY] = (fVecAdd(fMatrixTimes(rotMatrix, [rx * cos(t1 + Δ), ry * sin(t1 + Δ)]), [cx, cy]));
const fA = ( ( Δ > π ) ? 1 : 0 ); const fA = ((Δ > π) ? 1 : 0);
const fS = ( ( Δ > 0 ) ? 1 : 0 ); const fS = ((Δ > 0) ? 1 : 0);
if ( isNaN(eY) || isNaN(eX) ) { if (isNaN(eY) || isNaN(eX)) {
return ""; return "";
} else { } else {
return "M " + sX + " " + sY + " A " + [ rx , ry , φ / (2*π) *360, fA, fS, eX, eY ].join(" "); return "M " + sX + " " + sY + " A " + [rx, ry, φ / (2 * π) * 360, fA, fS, eX, eY].join(" ");
} }
}); });
@ -55,13 +55,13 @@ const svgarcpath = (([cx,cy],[rx,ry], [t1, Δ], φ ) => {
* @param {*} radius [rx,ry] major minor radius * @param {*} radius [rx,ry] major minor radius
* @param {*} angle [t1, Δ] start angle, in radian, angle to sweep, in radian. positive. * @param {*} angle [t1, Δ] start angle, in radian, angle to sweep, in radian. positive.
* @param {*} φ rotation on the whole, in radian * @param {*} φ rotation on the whole, in radian
* @returns a SVG path element that represent a ellipse. * @returns {string} a SVG path element that represent a ellipse.
*/ */
const svgarc = (([cx,cy],[rx,ry], [t1, Δ], φ ) => { const svgarc = (([cx, cy], [rx, ry], [t1, Δ], φ) => {
const path_2wk2r = document.createElementNS("http://www.w3.org/2000/svg", "path"); const path2wk2r = document.createElementNS("http://www.w3.org/2000/svg", "path");
const d = svgarcpath([cx,cy],[rx,ry], [t1, Δ], φ ); const d = svgarcpath([cx, cy], [rx, ry], [t1, Δ], φ);
path_2wk2r.setAttribute("d", d); path2wk2r.setAttribute("d", d);
return path_2wk2r; return path2wk2r;
}); });
export {svgarc, svgarcpath}; export {svgarc, svgarcpath};

View File

@ -1,251 +0,0 @@
/**
* textFit v2.3.1
* Previously known as jQuery.textFit
* 11/2014 by STRML (strml.github.com)
* MIT License
*
* To use: textFit(document.getElementById('target-div'), options);
*
* Will make the *text* content inside a container scale to fit the container
* The container is required to have a set width and height
* Uses binary search to fit text with minimal layout calls.
* Version 2.0 does not use jQuery.
*/
var defaultSettings = {
alignVert: false, // if true, textFit will align vertically using css tables
alignHoriz: false, // if true, textFit will set text-align: center
multiLine: false, // if true, textFit will not set white-space: no-wrap
detectMultiLine: true, // disable to turn off automatic multi-line sensing
minFontSize: 6,
maxFontSize: 80,
reProcess: true, // if true, textFit will re-process already-fit nodes. Set to 'false' for better performance
widthOnly: false, // if true, textFit will fit text to element width, regardless of text height
alignVertWithFlexbox: false, // if true, textFit will use flexbox for vertical alignment
};
/**
* Create new textFit element(S)
* @param {*} els element or element list
* @param {*} options Options (See default settings in textfit.js)
*/
export function textFit(els, options) {
if (!options) { options = {}; }
// Extend options.
var settings = {};
for(var key in defaultSettings){
if(options.hasOwnProperty(key)){
settings[key] = options[key];
} else {
settings[key] = defaultSettings[key];
}
}
// Convert jQuery objects into arrays
if (typeof els.toArray === "function") {
els = els.toArray();
}
// Support passing a single el
var elType = Object.prototype.toString.call(els);
if (elType !== '[object Array]' && elType !== '[object NodeList]' &&
elType !== '[object HTMLCollection]'){
els = [els];
}
// Process each el we've passed.
for(var i = 0; i < els.length; i++){
processItem(els[i], settings);
}
}
/**
* The meat. Given an el, make the text inside it fit its parent.
* @param {DOMElement} el Child el.
* @param {Object} settings Options for fit.
*/
function processItem(el, settings){
if (!isElement(el) || (!settings.reProcess && el.getAttribute('textFitted'))) {
return false;
}
// Set textFitted attribute so we know this was processed.
if(!settings.reProcess){
el.setAttribute('textFitted', 1);
}
var innerSpan, originalHeight, originalHTML, originalWidth;
var low, mid, high;
// Get element data.
originalHTML = el.innerHTML;
originalWidth = innerWidth(el);
originalHeight = innerHeight(el);
// Don't process if we can't find box dimensions
if (!originalWidth || (!settings.widthOnly && !originalHeight)) {
if(!settings.widthOnly) {
throw new Error('Set a static height and width on the target element ' + el.outerHTML +
' before using textFit!');
} else {
throw new Error('Set a static width on the target element ' + el.outerHTML +
' before using textFit!');
}
}
// Add textFitted span inside this container.
if (originalHTML.indexOf('textFitted') === -1) {
innerSpan = document.createElement('span');
innerSpan.className = 'textFitted';
// Inline block ensure it takes on the size of its contents, even if they are enclosed
// in other tags like <p>
innerSpan.style['display'] = 'inline-block';
innerSpan.innerHTML = originalHTML;
el.innerHTML = '';
el.appendChild(innerSpan);
} else {
// Reprocessing.
innerSpan = el.querySelector('span.textFitted');
// Remove vertical align if we're reprocessing.
if (hasClass(innerSpan, 'textFitAlignVert')){
innerSpan.className = innerSpan.className.replace('textFitAlignVert', '');
innerSpan.style['height'] = '';
el.className.replace('textFitAlignVertFlex', '');
}
}
// Prepare & set alignment
if (settings.alignHoriz) {
el.style['text-align'] = 'center';
innerSpan.style['text-align'] = 'center';
}
// Check if this string is multiple lines
// Not guaranteed to always work if you use wonky line-heights
var multiLine = settings.multiLine;
if (settings.detectMultiLine && !multiLine &&
innerSpan.getBoundingClientRect().height >= parseInt(window.getComputedStyle(innerSpan)['font-size'], 10) * 2){
multiLine = true;
}
// If we're not treating this as a multiline string, don't let it wrap.
if (!multiLine) {
el.style['white-space'] = 'nowrap';
}
low = settings.minFontSize;
high = settings.maxFontSize;
// Binary search for highest best fit
var size = low;
while (low <= high) {
mid = (high + low) / 2;
innerSpan.style.fontSize = mid + 'px';
var innerSpanBoundingClientRect = innerSpan.getBoundingClientRect();
if (
innerSpanBoundingClientRect.width <= originalWidth
&& (settings.widthOnly || innerSpanBoundingClientRect.height <= originalHeight)
) {
size = mid;
low = mid + 1;
} else {
high = mid - 1;
}
// await injection point
}
// found, updating font if differs:
if( innerSpan.style.fontSize != size + 'px' ) { innerSpan.style.fontSize = size + 'px'; }
// Our height is finalized. If we are aligning vertically, set that up.
if (settings.alignVert) {
addStyleSheet();
var height = innerSpan.scrollHeight;
if (window.getComputedStyle(el)['position'] === "static"){
el.style['position'] = 'relative';
}
if (!hasClass(innerSpan, "textFitAlignVert")){
innerSpan.className = innerSpan.className + " textFitAlignVert";
}
innerSpan.style['height'] = height + "px";
if (settings.alignVertWithFlexbox && !hasClass(el, "textFitAlignVertFlex")) {
el.className = el.className + " textFitAlignVertFlex";
}
}
}
/**
* Calculate height without padding.
* @param {*} el
* @returns
*/
function innerHeight(el){
var style = window.getComputedStyle(el, null);
return el.getBoundingClientRect().height -
parseInt(style.getPropertyValue('padding-top'), 10) -
parseInt(style.getPropertyValue('padding-bottom'), 10);
}
/**
* Calculate width without padding.
* @param {*} el
* @returns
*/
function innerWidth(el){
var style = window.getComputedStyle(el, null);
return el.getBoundingClientRect().width -
parseInt(style.getPropertyValue('padding-left'), 10) -
parseInt(style.getPropertyValue('padding-right'), 10);
}
/**
* Returns true if it is a DOM element
* @param {*} o
* @returns
*/
function isElement(o){
return (
typeof HTMLElement === "object" ? o instanceof HTMLElement : //DOM2
o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName==="string"
);
}
/**
* Check if element has a specific class
* @param {*} element
* @param {*} cls
* @returns
*/
function hasClass(element, cls) {
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
}
// Better than a stylesheet dependency
/**
* Add stylesheet to the page for this
* @returns
*/
function addStyleSheet() {
if (document.getElementById("textFitStyleSheet")) { return; }
var style = [
".textFitAlignVert{",
"position: absolute;",
"top: 0; right: 0; bottom: 0; left: 0;",
"margin: auto;",
"display: flex;",
"justify-content: center;",
"flex-direction: column;",
"}",
".textFitAlignVertFlex{",
"display: flex;",
"}",
".textFitAlignVertFlex .textFitAlignVert{",
"position: static;",
"}",].join("");
var css = document.createElement("style");
css.type = "text/css";
css.id = "textFitStyleSheet";
css.innerHTML = style;
document.body.appendChild(css);
}

View File

@ -1,5 +1,5 @@
/* eslint-disable */ /* eslint-disable */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/*! ***************************************************************************** /*! *****************************************************************************
Copyright (C) Microsoft. All rights reserved. Copyright (C) Microsoft. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use Licensed under the Apache License, Version 2.0 (the "License"); you may not use

View File

@ -1,5 +1,5 @@
/* eslint-disable */ /* eslint-disable */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/** /**
* vue-class-component v7.2.6 * vue-class-component v7.2.6
* (c) 2015-present Evan You * (c) 2015-present Evan You

View File

@ -1,5 +1,5 @@
/* eslint-disable */ /* eslint-disable */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/** vue-property-decorator verson 8.5.1 MIT LICENSE copyright 2020 kaorun343 */ /** vue-property-decorator verson 8.5.1 MIT LICENSE copyright 2020 kaorun343 */
/// <reference types='reflect-metadata'/> /// <reference types='reflect-metadata'/>
'use strict'; 'use strict';

View File

@ -1,5 +1,5 @@
/* eslint-disable */ /* eslint-disable */
/*eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
/*! /*!
* Vue.js v2.7.14 * Vue.js v2.7.14
* (c) 2014-2022 Evan You * (c) 2014-2022 Evan You

File diff suppressed because one or more lines are too long

View File

@ -33,8 +33,6 @@ $excludepaths = [
"build/*", "build/*",
"build.*", "build.*",
"vuemode.sh", "vuemode.sh",
"amd/src",
"amd/src/*",
".git", ".git",
".git/*", ".git/*",
".gitignore", ".gitignore",

Some files were not shown because too many files have changed in this diff Show More