diff --git a/amd/build/page-edit-plan.min.js b/amd/build/page-edit-plan.min.js index 03babbe..e559f5f 100644 --- a/amd/build/page-edit-plan.min.js +++ b/amd/build/page-edit-plan.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-edit-plan",["exports","core/str","core/ajax","core/notification","./vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./debugger","./string-helper","./studyplan-processor","./downloader","./portal-vue","./bootstrap-vue","./vue-easy-dnd"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_portalVue,_bootstrapVue,_vueEasyDnd){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(_contextid,categoryid){(void 0===_contextid||!Number.isInteger(_contextid)||_contextid<1)&&(_contextid=1);void 0!==categoryid&&Number.isInteger(categoryid)||(categoryid=0);var app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",slots:4,startdate:"2020-08-01",enddate:"",context:_contextid,aggregation:"bistate",aggregation_config:""}},toolbox:{right:!0},activestudyplan:null,loadingstudyplan:!1,studyplans:[],frameworks:[],badges:[],courses:[],text:strings.studyplan,usedcontexts:[]},created:function(){this.$root.$on("studyplanRemoved",(function(studyplan){app.activestudyplan==studyplan&&(app.activestudyplan=null);var index=null;for(var idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted:function(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:_contextid}}])[0].done((function(response){var timingval={future:0,present:1,past:2};response.sort((function(a,b){var timinga=_treestudyplanComponents.default.studyplanTiming(a),timingb=_treestudyplanComponents.default.studyplanTiming(b),t=timingval[timinga]-timingval[timingb];return 0==t&&0==(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime())&&(t=a.name.localeCompare(b.name)),t})),app.studyplans=response;var hash=location.hash.replace("#","");if(hash)for(var idx in app.studyplans)if(app.studyplans[idx].id==hash){app.selectStudyplan(app.studyplans[idx]);break}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_badges",args:{}}])[0].done((function(response){app.badges=response})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_map_categories",args:{root_id:categoryid}}])[0].done((function(response){app.courses=response})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"edit"}}])[0].done((function(response){app.usedcontexts=response})).fail(_notification.default.exception)},computed:{dropdown_title:function(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:function(){return _contextid},filterComponentType:function(){return{item:!0,component:!1,span:1,type:"filter"}}},methods:{closeStudyplan:function(){app.activestudyplan=null,location.hash=""},movedStudyplan:function(plan,from,to){var params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),window.location.search=params.toString()},onStudyPlanCreated:function(newstudyplan){app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan)},switchContext:function(ctx){var params=new URLSearchParams(location.search);params.set("categoryid",ctx.id),window.location.search=params.toString()},selectStudyplan:function(studyplan){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),debug.info("studyplan processed"),app.loadingstudyplan=!1,location.hash=app.activestudyplan.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},import_studyplan:function(){(0,_downloader.upload)((function(filename,content){(0,_ajax.call)([{methodname:"local_treestudyplan_import_plan",args:{content:content,format:"application/json",context_id:_contextid}}])[0].done((function(response){response.success?location.reload():debug.error("Import failed: ",response.msg)})).fail(_notification.default.exception)}),"application/json")},export_plan:function(plan,format){null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:plan.id,format:format}}])[0].done((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).fail(_notification.default.exception)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_modeditModal.default),_vue.default.component("drag",_vueEasyDnd.Drag),_vue.default.component("drop",_vueEasyDnd.Drop),_vue.default.component("drop-list",_vueEasyDnd.DropList);var debug=new _debugger.default("treestudyplan");debug.enable();var strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); +define("local_treestudyplan/page-edit-plan",["exports","core/str","core/ajax","core/notification","./vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./debugger","./string-helper","./studyplan-processor","./downloader","./portal-vue","./bootstrap-vue","./vue-easy-dnd"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_portalVue,_bootstrapVue,_vueEasyDnd){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(_contextid,categoryid){(void 0===_contextid||!Number.isInteger(_contextid)||_contextid<1)&&(_contextid=1);void 0!==categoryid&&Number.isInteger(categoryid)||(categoryid=0);var app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:_contextid,aggregation:"bistate",aggregation_config:""}},toolbox:{right:!0},activestudyplan:null,loadingstudyplan:!1,studyplans:[],frameworks:[],badges:[],courses:[],text:strings.studyplan,usedcontexts:[]},created:function(){this.$root.$on("studyplanRemoved",(function(studyplan){app.activestudyplan==studyplan&&(app.activestudyplan=null);var index=null;for(var idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted:function(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:_contextid}}])[0].done((function(response){var timingval={future:0,present:1,past:2};response.sort((function(a,b){var timinga=_treestudyplanComponents.default.studyplanTiming(a),timingb=_treestudyplanComponents.default.studyplanTiming(b),t=timingval[timinga]-timingval[timingb];return 0==t&&0==(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime())&&(t=a.name.localeCompare(b.name)),t})),app.studyplans=response;var hash=location.hash.replace("#","");if(hash)for(var idx in app.studyplans)if(app.studyplans[idx].id==hash){app.selectStudyplan(app.studyplans[idx]);break}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_badges",args:{}}])[0].done((function(response){app.badges=response})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_map_categories",args:{root_id:categoryid}}])[0].done((function(response){app.courses=response})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"edit"}}])[0].done((function(response){app.usedcontexts=response})).fail(_notification.default.exception)},computed:{dropdown_title:function(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:function(){return _contextid},filterComponentType:function(){return{item:!0,component:!1,span:1,type:"filter"}}},methods:{closeStudyplan:function(){app.activestudyplan=null,location.hash=""},movedStudyplan:function(plan,from,to){var params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),window.location.search=params.toString()},onStudyPlanCreated:function(newstudyplan){app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan)},switchContext:function(ctx){var params=new URLSearchParams(location.search);params.set("categoryid",ctx.id),window.location.search=params.toString()},selectStudyplan:function(studyplan){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),debug.info("studyplan processed"),app.loadingstudyplan=!1,location.hash=app.activestudyplan.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},import_studyplan:function(){(0,_downloader.upload)((function(filename,content){(0,_ajax.call)([{methodname:"local_treestudyplan_import_plan",args:{content:content,format:"application/json",context_id:_contextid}}])[0].done((function(response){response.success?location.reload():debug.error("Import failed: ",response.msg)})).fail(_notification.default.exception)}),"application/json")},export_plan:function(plan,format){null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:plan.id,format:format}}])[0].done((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).fail(_notification.default.exception)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_modeditModal.default),_vue.default.component("drag",_vueEasyDnd.Drag),_vue.default.component("drop",_vueEasyDnd.Drop),_vue.default.component("drop-list",_vueEasyDnd.DropList);var debug=new _debugger.default("treestudyplan");debug.enable();var strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); //# sourceMappingURL=page-edit-plan.min.js.map \ No newline at end of file diff --git a/amd/build/page-edit-plan.min.js.map b/amd/build/page-edit-plan.min.js.map index fe772d4..a15be20 100644 --- a/amd/build/page-edit-plan.min.js.map +++ b/amd/build/page-edit-plan.min.js.map @@ -1 +1 @@ -{"version":3,"file":"page-edit-plan.min.js","sources":["../src/page-edit-plan.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 notification from 'core/notification';\nimport Vue from './vue';\nimport EditorComponents from './studyplan-editor-components';\nimport TSComponents from './treestudyplan-components';\nimport ModalComponents from './modedit-modal';\nimport Debugger from './debugger';\n\nimport {load_strings} from './string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\n\nimport PortalVue from './portal-vue';\nimport BootstrapVue from './bootstrap-vue';\nimport {Drag, Drop, DropList} from './vue-easy-dnd';\nVue.use(PortalVue);\nVue.use(BootstrapVue);\nVue.use(TSComponents);\nVue.use(EditorComponents);\nvue.use(ModalComponents);\nVue.component('drag',Drag);\nVue.component('drop',Drop);\nVue.component('drop-list',DropList);\n\n\nimport vue from './vue';\n\nconst debug = new Debugger(\"treestudyplan\");\ndebug.enable();\n\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n */\nexport function init(contextid,categoryid) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(contextid) || contextid < 1 ){ contextid = 1;}\n if(undefined === categoryid || !Number.isInteger(categoryid)){ categoryid = 0;}\n\n const in_systemcontext = (contextid <= 1);\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n slots : 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: 'bistate',\n aggregation_config: '',\n }\n },\n toolbox: {\n right: true,\n },\n activestudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n frameworks: [],\n badges: [],\n courses: [],\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved',(studyplan)=>{\n \n if(app.activestudyplan == studyplan){\n app.activestudyplan = null;\n }\n\n // remove studyplan from index list\n let index = null;\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == studyplan.id){\n index = idx;\n break;\n }\n }\n if(index){\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: { context_id: contextid}\n }])[0].done(function(response){\n const timingval = { future: 0, present: 1, past: 2, };\n response.sort((a,b) => {\n const timinga = TSComponents.studyplanTiming(a);\n const timingb = TSComponents.studyplanTiming(b);\n\n let t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n \n if (t == 0) {\n // sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n }); \n app.studyplans = response;\n\n // load studyplan from hash if applicable\n const hash = location.hash.replace('#','');\n if(hash){\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == hash){\n app.selectStudyplan(app.studyplans[idx]);\n break;\n }\n }\n }\n }).fail(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_badges',\n args: {}\n }])[0].done(function(response){\n app.badges = response;\n }).fail(notification.exception); \n call([{\n methodname: 'local_treestudyplan_map_categories',\n args: {root_id: categoryid}\n }])[0].done(function(response){\n app.courses = response;\n }).fail(notification.exception); \n call([{\n methodname: 'local_treestudyplan_list_used_categories',\n args: { operation: 'edit'}\n }])[0].done(function(response){\n app.usedcontexts = response;\n }).fail(notification.exception); \n\n },\n computed: {\n dropdown_title(){\n if(this.activestudyplan && this.activestudyplan.name){\n return this.activestudyplan.name;\n }\n else{\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid(){\n return contextid;\n },\n filterComponentType(){\n return {\n item: true,\n component: false,\n span: 1,\n type: 'filter',\n };\n },\n },\n methods: {\n closeStudyplan() {\n app.activestudyplan = null;\n location.hash = '';\n }, \n movedStudyplan(plan,from,to) {\n // reload the page in the new context (needed, since a number of links are not reactive in the page)\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", to);\n window.location.search = params.toString();\n },\n onStudyPlanCreated(newstudyplan){\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan);\n\n },\n switchContext(ctx){\n const params = new URLSearchParams(location.search);\n params.set('categoryid', ctx.id);\n window.location.search = params.toString();\n \n },\n selectStudyplan(studyplan){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplan.id}\n }])[0].done(function(response){\n app.activestudyplan = ProcessStudyplan(response,true);\n debug.info('studyplan processed');\n app.loadingstudyplan = false;\n location.hash = app.activestudyplan.id;\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n import_studyplan(){\n upload((filename,content)=>{\n call([{\n methodname: 'local_treestudyplan_import_plan',\n args: {\n content: content,\n format: \"application/json\",\n context_id: contextid,\n },\n }])[0].done(function(response){\n if(response.success){\n location.reload();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n \n }).fail(notification.exception); \n }, \"application/json\");\n },\n export_plan(plan,format){\n let self = this;\n if(format == undefined || ![\"json\",\"csv\"].includes(format)){\n format = \"json\";\n }\n call([{\n methodname: 'local_treestudyplan_export_plan',\n args: {\n studyplan_id: plan.id,\n format: format\n },\n }])[0].done(function(response){\n \n download(plan.shortname+\".json\",response.content,response.format);\n }).fail(notification.exception); \n },\n },\n });\n}\n\n"],"names":["contextid","categoryid","undefined","Number","isInteger","app","Vue","el","data","create","studyplan","name","shortname","description","slots","startdate","enddate","context","aggregation","aggregation_config","toolbox","right","activestudyplan","loadingstudyplan","studyplans","frameworks","badges","courses","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","methodname","args","context_id","done","response","timingval","future","present","past","sort","a","b","timinga","TSComponents","studyplanTiming","timingb","t","Date","getTime","localeCompare","hash","location","replace","selectStudyplan","fail","notification","exception","root_id","operation","computed","dropdown_title","this","studyplan_select_placeholder","filterComponentType","item","component","span","type","methods","closeStudyplan","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","window","toString","onStudyPlanCreated","newstudyplan","push","switchContext","ctx","debug","info","error","import_studyplan","filename","content","format","success","reload","msg","export_plan","includes","studyplan_id","use","PortalVue","BootstrapVue","EditorComponents","ModalComponents","Drag","Drop","DropList","Debugger","enable"],"mappings":"oqBAmDqBA,WAAUC,kBAExBC,IAAcF,aAAcG,OAAOC,UAAUJ,aAAcA,WAAY,KAAKA,WAAY,QACxFE,IAAcD,YAAeE,OAAOC,UAAUH,cAAcA,WAAa,OAKxEI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,OAAQ,CACJC,UAAW,CACPC,KAAM,GACNC,UAAW,GACXC,YAAa,GACbC,MAAQ,EACRC,UAAW,aACXC,QAAS,GACTC,QAASjB,WACTkB,YAAa,UACbC,mBAAoB,KAG5BC,QAAS,CACLC,OAAO,GAEXC,gBAAiB,KACjBC,kBAAkB,EAClBC,WAAY,GACZC,WAAY,GACZC,OAAQ,GACRC,QAAS,GACTC,KAAMC,QAAQnB,UACdoB,aAAc,IAElBC,wBACSC,MAAMC,IAAI,oBAAmB,SAACvB,WAE5BL,IAAIiB,iBAAmBZ,YACtBL,IAAIiB,gBAAkB,UAItBY,MAAQ,SACR,IAAIC,OAAO9B,IAAImB,cACZnB,IAAImB,WAAWW,KAAKC,IAAM1B,UA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AQA,WAEZ,GAAG3D,MAAK,SAASC,mCAERqC,KAAKpE,UAAU,QAAQ+B,SAASyD,QAAQzD,SAAS0D,WAC3DtC,KAAKC,sBAAaC,6cAzOrC2C,IAAIC,iCACJD,IAAIE,oCACJF,IAAIxD,+CACJwD,IAAIG,iDACJH,IAAII,oCACJtC,UAAU,OAAOuC,+BACjBvC,UAAU,OAAOwC,+BACjBxC,UAAU,YAAYyC,0BAKpBpB,MAAQ,IAAIqB,kBAAS,iBAC3BrB,MAAMsB,aAGFxF,SAAU,8BAAa,CACvBnB,UAAW,CACP6D,6BAA8B"} \ No newline at end of file +{"version":3,"file":"page-edit-plan.min.js","sources":["../src/page-edit-plan.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 notification from 'core/notification';\nimport Vue from './vue';\nimport EditorComponents from './studyplan-editor-components';\nimport TSComponents from './treestudyplan-components';\nimport ModalComponents from './modedit-modal';\nimport Debugger from './debugger';\n\nimport {load_strings} from './string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\n\nimport PortalVue from './portal-vue';\nimport BootstrapVue from './bootstrap-vue';\nimport {Drag, Drop, DropList} from './vue-easy-dnd';\nVue.use(PortalVue);\nVue.use(BootstrapVue);\nVue.use(TSComponents);\nVue.use(EditorComponents);\nvue.use(ModalComponents);\nVue.component('drag',Drag);\nVue.component('drop',Drop);\nVue.component('drop-list',DropList);\n\n\nimport vue from './vue';\n\nconst debug = new Debugger(\"treestudyplan\");\ndebug.enable();\n\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n */\nexport function init(contextid,categoryid) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(contextid) || contextid < 1 ){ contextid = 1;}\n if(undefined === categoryid || !Number.isInteger(categoryid)){ categoryid = 0;}\n\n const in_systemcontext = (contextid <= 1);\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n idnumber: '',\n slots : 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: 'bistate',\n aggregation_config: '',\n }\n },\n toolbox: {\n right: true,\n },\n activestudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n frameworks: [],\n badges: [],\n courses: [],\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved',(studyplan)=>{\n \n if(app.activestudyplan == studyplan){\n app.activestudyplan = null;\n }\n\n // remove studyplan from index list\n let index = null;\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == studyplan.id){\n index = idx;\n break;\n }\n }\n if(index){\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: { context_id: contextid}\n }])[0].done(function(response){\n const timingval = { future: 0, present: 1, past: 2, };\n response.sort((a,b) => {\n const timinga = TSComponents.studyplanTiming(a);\n const timingb = TSComponents.studyplanTiming(b);\n\n let t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n \n if (t == 0) {\n // sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n }); \n app.studyplans = response;\n\n // load studyplan from hash if applicable\n const hash = location.hash.replace('#','');\n if(hash){\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == hash){\n app.selectStudyplan(app.studyplans[idx]);\n break;\n }\n }\n }\n }).fail(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_badges',\n args: {}\n }])[0].done(function(response){\n app.badges = response;\n }).fail(notification.exception); \n call([{\n methodname: 'local_treestudyplan_map_categories',\n args: {root_id: categoryid}\n }])[0].done(function(response){\n app.courses = response;\n }).fail(notification.exception); \n call([{\n methodname: 'local_treestudyplan_list_used_categories',\n args: { operation: 'edit'}\n }])[0].done(function(response){\n app.usedcontexts = response;\n }).fail(notification.exception); \n\n },\n computed: {\n dropdown_title(){\n if(this.activestudyplan && this.activestudyplan.name){\n return this.activestudyplan.name;\n }\n else{\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid(){\n return contextid;\n },\n filterComponentType(){\n return {\n item: true,\n component: false,\n span: 1,\n type: 'filter',\n };\n },\n },\n methods: {\n closeStudyplan() {\n app.activestudyplan = null;\n location.hash = '';\n }, \n movedStudyplan(plan,from,to) {\n // reload the page in the new context (needed, since a number of links are not reactive in the page)\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", to);\n window.location.search = params.toString();\n },\n onStudyPlanCreated(newstudyplan){\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan);\n\n },\n switchContext(ctx){\n const params = new URLSearchParams(location.search);\n params.set('categoryid', ctx.id);\n window.location.search = params.toString();\n \n },\n selectStudyplan(studyplan){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplan.id}\n }])[0].done(function(response){\n app.activestudyplan = ProcessStudyplan(response,true);\n debug.info('studyplan processed');\n app.loadingstudyplan = false;\n location.hash = app.activestudyplan.id;\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n import_studyplan(){\n upload((filename,content)=>{\n call([{\n methodname: 'local_treestudyplan_import_plan',\n args: {\n content: content,\n format: \"application/json\",\n context_id: contextid,\n },\n }])[0].done(function(response){\n if(response.success){\n location.reload();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n \n }).fail(notification.exception); \n }, \"application/json\");\n },\n export_plan(plan,format){\n let self = this;\n if(format == undefined || ![\"json\",\"csv\"].includes(format)){\n format = \"json\";\n }\n call([{\n methodname: 'local_treestudyplan_export_plan',\n args: {\n studyplan_id: plan.id,\n format: format\n },\n }])[0].done(function(response){\n \n download(plan.shortname+\".json\",response.content,response.format);\n }).fail(notification.exception); \n },\n },\n });\n}\n\n"],"names":["contextid","categoryid","undefined","Number","isInteger","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","aggregation_config","toolbox","right","activestudyplan","loadingstudyplan","studyplans","frameworks","badges","courses","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","methodname","args","context_id","done","response","timingval","future","present","past","sort","a","b","timinga","TSComponents","studyplanTiming","timingb","t","Date","getTime","localeCompare","hash","location","replace","selectStudyplan","fail","notification","exception","root_id","operation","computed","dropdown_title","this","studyplan_select_placeholder","filterComponentType","item","component","span","type","methods","closeStudyplan","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","window","toString","onStudyPlanCreated","newstudyplan","push","switchContext","ctx","debug","info","error","import_studyplan","filename","content","format","success","reload","msg","export_plan","includes","studyplan_id","use","PortalVue","BootstrapVue","EditorComponents","ModalComponents","Drag","Drop","DropList","Debugger","enable"],"mappings":"oqBAmDqBA,WAAUC,kBAExBC,IAAcF,aAAcG,OAAOC,UAAUJ,aAAcA,WAAY,KAAKA,WAAY,QACxFE,IAAcD,YAAeE,OAAOC,UAAUH,cAAcA,WAAa,OAKxEI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,OAAQ,CACJC,UAAW,CACPC,KAAM,GACNC,UAAW,GACXC,YAAa,GACbC,SAAU,GACVC,MAAQ,EACRC,UAAW,aACXC,QAAS,GACTC,QAASlB,WACTmB,YAAa,UACbC,mBAAoB,KAG5BC,QAAS,CACLC,OAAO,GAEXC,gBAAiB,KACjBC,kBAAkB,EAClBC,W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dA,SAAS2D,QACR1C,SAAS2C,SAETR,MAAME,MAAM,kBAAkBtD,SAAS6D,QAG5CzC,KAAKC,sBAAaC,aACtB,qBAEPwC,qBAAYzB,KAAKqB,QAEApG,MAAVoG,QAAwB,CAAC,OAAO,OAAOK,SAASL,UAC/CA,OAAS,uBAER,CAAC,CACE9D,WAAY,kCACZC,KAAM,CACFmE,aAAc3B,KAAK5C,GACnBiE,OAAQA,WAEZ,GAAG3D,MAAK,SAASC,mCAERqC,KAAKrE,UAAU,QAAQgC,SAASyD,QAAQzD,SAAS0D,WAC3DtC,KAAKC,sBAAaC,6cA1OrC2C,IAAIC,iCACJD,IAAIE,oCACJF,IAAIxD,+CACJwD,IAAIG,iDACJH,IAAII,oCACJtC,UAAU,OAAOuC,+BACjBvC,UAAU,OAAOwC,+BACjBxC,UAAU,YAAYyC,0BAKpBpB,MAAQ,IAAIqB,kBAAS,iBAC3BrB,MAAMsB,aAGFxF,SAAU,8BAAa,CACvBpB,UAAW,CACP8D,6BAA8B"} \ No newline at end of file diff --git a/amd/build/studyplan-editor-components.min.js b/amd/build/studyplan-editor-components.min.js index 574b1de..560cbde 100644 --- a/amd/build/studyplan-editor-components.min.js +++ b/amd/build/studyplan-editor-components.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/studyplan-editor-components",["exports","./simpleline","core/ajax","core/notification","core/str","./string-helper","./studyplan-processor","./debugger","./downloader"],(function(_exports,_simpleline,_ajax,_notification,_str,_stringHelper,_studyplanProcessor,_debugger,_downloader){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _createForOfIteratorHelper(o,allowArrayLike){var it="undefined"!=typeof Symbol&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(o))||allowArrayLike&&o&&"number"==typeof o.length){it&&(o=it);var i=0,F=function(){};return{s:F,n:function(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var err,normalCompletion=!0,didErr=!1;return{s:function(){it=it.call(o)},n:function(){var step=it.next();return normalCompletion=step.done,step},e:function(_e2){didErr=!0,err=_e2},f:function(){try{normalCompletion||null==it.return||it.return()}finally{if(didErr)throw err}}}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\n {{text.advanced_tools}}\n \n \n \n \n {{ text.advanced_warning}}\n \n \n \n \n

{{ text.advanced_cascade_cohortsync_title}}

\n {{ text.advanced_cascade_cohortsync_desc}}\n
\n \n {{ text.advanced_cascade_cohortsync}}\n \n \n

{{ text.advanced_force_scale_title}}

\n {{ text.advanced_force_scale_desc}}\n
\n \n \n \n \n \n {{ text.advanced_force_scale_button}}\n \n\n \n \n
    \n
  • \n {{c.course.fullname}}\n
      \n
    • \n {{g.name}}\n {{text.advanced_converted}}{{text.advanced_skipped}}\n {{text.advanced_error}}\n
    • \n
    \n
  • \n
\n
\n \n

{{ text.advanced_disable_autoenddate_title}}

\n {{ text.advanced_disable_autoenddate_desc}}\n
\n \n {{ text.advanced_disable_autoenddate_button}}\n \n
\n
\n \n {{ text.advanced_export}}\n {{ text.advanced_import}}\n {{ text.advanced_export_csv}}\n \n \n

{{text.advanced_purge_expl}}

\n

{{ text.advanced_purge}}

\n
\n
\n
\n \n '}),Vue.component("t-studyplan-edit",{props:{value:{type:Object,default:function(){return null}},mode:{type:String,default:function(){return"edit"}},type:{type:String,default:function(){return"link"}},variant:{type:String,default:function(){return""}},contextid:{type:Number,default:1}},data:function(){return{show:!1,config:{userfields:[{key:"selected"},{key:"firstname",sortable:!0},{key:"lastname",sortable:!0}],cohortfields:[{key:"selected"},{key:"name",sortable:!0},{key:"context",sortable:!0}]},editdata:{name:"",shortname:"",description:"",context_id:this.contextid,periods:4,startdate:(new Date).getFullYear()+"-08-01",enddate:(new Date).getFullYear()+1+"-08-01",aggregation:"bistate",aggregation_config:""},aggregation_parsed:{},aggregators:[],categories:[{context_id:1,category:{path:"System"}}],text:strings.studyplan_edit}},created:function(){var self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_list_aggregators",args:[]}])[0].done((function(response){for(var ix in self.aggregators=response,self.aggregators){var ag=self.aggregators[ix];try{ag.defaultconfig&&ag.defaultconfig.length>0&&(self.aggregation_parsed[ag.id]=JSON.parse(ag.defaultconfig))}catch(e){debug.warn(e)}}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_accessible_categories",args:{operation:"edit"}}])[0].done((function(response){for(var ix in response){var cat=response[ix];cat.category.pathname=cat.category.path.join(" / ")}self.categories=response})).fail(_notification.default.exception)},mounted:function(){},updated:function(){},computed:{},methods:{editPlanStart:function(){if("create"!=this.mode&&((0,_studyplanProcessor.objCopy)(this.editdata,this.value.pages[0],STUDYPLAN_EDITOR_PAGE_FIELDS),(0,_studyplanProcessor.objCopy)(this.editdata,this.value,STUDYPLAN_EDITOR_FIELDS)),this.editdata.aggregation_config&&this.editdata.aggregation_config.length>0)try{this.aggregation_parsed[this.editdata.aggregation]=JSON.parse(this.editdata.aggregation_config)}catch(e){debug.warn(e)}this.show=!0},editPlanFinish:function(){var self=this,args={},method="local_treestudyplan_edit_studyplan";"create"==this.mode?method="local_treestudyplan_add_studyplan":args.id=this.value.id,this.aggregation_parsed[this.editdata.aggregation]&&(this.editdata.aggregation_config=JSON.stringify(this.aggregation_parsed[this.editdata.aggregation])),(0,_studyplanProcessor.objCopy)(args,this.editdata,STUDYPLAN_EDITOR_FIELDS),(0,_studyplanProcessor.objCopy)(args,this.editdata,STUDYPLAN_EDITOR_PAGE_FIELDS),(0,_ajax.call)([{methodname:method,args:args}])[0].done((function(response){if("create"==self.mode)self.$emit("created",response),self.editdata={name:"",shortname:"",description:"",context_id:1,periods:4,startdate:(new Date).getFullYear()+"-08-01",enddate:(new Date).getFullYear()+1+"-08-01",aggregation:"bistate",aggregation_config:""};else{var moved_from=self.value.context_id,moved_to=response.context_id,moved=moved_from!=moved_to;(0,_studyplanProcessor.objCopy)(self.value,response,STUDYPLAN_EDITOR_FIELDS),self.$emit("input",self.value),moved&&self.$emit("moved",self.value,moved_from,moved_to)}})).fail(_notification.default.exception)},numberFilter:function(value){return value}},template:'\n \n \n \n \n \n \n {{ text.studyplan_name}}\n \n 0\'\n :placeholder="text.studyplan_name_ph">\n \n \n \n {{ text.studyplan_shortname}}\n \n 0\'\n :placeholder="text.studyplan_shortname_ph">\n \n \n \n {{ text.studyplan_description}}\n \n \n \n \n \n {{ text.studyplan_context}}\n \n \n \n \n \n {{ text.studyplan_slots}}\n \n \n \n \n \n {{ text.studyplan_startdate}}\n \n \n \n \n \n {{ text.studyplan_enddate}}\n \n \n \n \n \n {{ text.choose_aggregation_style}}\n \n \n \n \n \n \n \n \n '}),Vue.component("t-studyplan-associate",{props:["value"],data:function(){return{show:!1,config:{userfields:[{key:"selected"},{key:"firstname",sortable:!0},{key:"lastname",sortable:!0}],cohortfields:[{key:"selected"},{key:"name",sortable:!0},{key:"context",sortable:!0}]},association:{cohorts:[],users:[]},loading:{cohorts:!1,users:!1},search:{users:[],cohorts:[]},selected:{search:{users:[],cohorts:[]},associated:{users:[],cohorts:[]}},text:strings.studyplan_associate}},created:function(){},mounted:function(){},updated:function(){},methods:{showModal:function(){this.show=!0,this.loadAssociations()},cohortOptionModel:function(c){return{value:c.id,text:c.name+" ("+c.context.path.join(" / ")+")"}},userOptionModel:function(u){return{value:u.id,text:u.firstname+" "+u.lastname}},loadAssociations:function(){var self=this;self.loading.cohorts=!0,self.loading.users=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_associated_users",args:{studyplan_id:self.value.id}}])[0].done((function(response){self.association.users=response.map(self.userOptionModel),self.loading.users=!1})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_associated_cohorts",args:{studyplan_id:self.value.id}}])[0].done((function(response){self.association.cohorts=response.map(self.cohortOptionModel),self.loading.cohorts=!1})).fail(_notification.default.exception)},searchCohorts:function(searchtext){var self=this;searchtext.length>0?(0,_ajax.call)([{methodname:"local_treestudyplan_list_cohort",args:{like:searchtext,exclude_id:self.value.id}}])[0].done((function(response){self.search.cohorts=response.map(self.cohortOptionModel)})).fail(_notification.default.exception):self.search.cohorts=[]},cohortAssociate:function(){var self=this,requests=[],associated=self.association.cohorts,search=self.search.cohorts,searchselected=self.selected.search.cohorts,_loop=function(i){var r=searchselected[i];requests.push({methodname:"local_treestudyplan_connect_cohort",args:{studyplan_id:self.value.id,cohort_id:r},fail:_notification.default.exception,done:function(response){response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)}})};for(var i in searchselected)_loop(i);(0,_ajax.call)(requests)},cohortDisassociate:function(){var self=this,requests=[],associatedselected=self.selected.associated.cohorts,associated=self.association.cohorts,search=self.search.cohorts,_loop2=function(i){var r=associatedselected[i];requests.push({methodname:"local_treestudyplan_disconnect_cohort",args:{studyplan_id:self.value.id,cohort_id:r},fail:_notification.default.exception,done:function(response){response.success&&(0,_studyplanProcessor.transportItem)(search,associated,r)}})};for(var i in associatedselected)_loop2(i);(0,_ajax.call)(requests)},searchUsers:function(searchtext){var self=this;searchtext.length>0?(0,_ajax.call)([{methodname:"local_treestudyplan_find_user",args:{like:searchtext,exclude_id:self.value.id}}])[0].done((function(response){self.search.users=response.map(self.userOptionModel)})).fail(_notification.default.exception):self.search.users=[]},userAssociate:function(){var self=this,requests=[],associated=self.association.users,search=self.search.users,searchselected=self.selected.search.users,_loop3=function(i){var r=searchselected[i];requests.push({methodname:"local_treestudyplan_connect_user",args:{studyplan_id:self.value.id,user_id:r},fail:_notification.default.exception,done:function(response){response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)}})};for(var i in searchselected)_loop3(i);(0,_ajax.call)(requests)},userDisassociate:function(){var self=this,requests=[],associated=self.association.users,associatedselected=self.selected.associated.users,search=self.search.users,_loop4=function(i){var r=associatedselected[i];requests.push({methodname:"local_treestudyplan_disconnect_user",args:{studyplan_id:self.value.id,user_id:r},fail:_notification.default.exception,done:function(response){response.success&&(0,_studyplanProcessor.transportItem)(search,associated,r)}})};for(var i in associatedselected)_loop4(i);(0,_ajax.call)(requests)}},template:'\n\n \n \n \n \n \n {{text.associated_cohorts}}\n {{text.associate_cohorts}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n  {{text.delete_association}}\n \n \n  {{text.add_association}} \n \n \n \n \n \n \n \n {{text.associated_users}}\n {{text.associate_users}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n  {{text.delete_association}}\n \n \n  {{text.add_association}} \n \n \n \n \n \n \n \n'}),Vue.component("t-period-edit",{props:{value:{type:Object,default:function(){return null}},type:{type:String,default:function(){return"link"}},variant:{type:String,default:function(){return""}}},data:function(){return{show:!1,editdata:{fullname:"",shortname:"",startdate:(new Date).getFullYear()+"-08-01",enddate:(new Date).getFullYear()+1+"-08-01"},text:strings.period_edit}},created:function(){},mounted:function(){},updated:function(){},computed:{},methods:{editStart:function(){(0,_studyplanProcessor.objCopy)(this.editdata,this.value,PERIOD_EDITOR_FIELDS),this.show=!0},editFinish:function(){var self=this,args={id:this.value.id};(0,_studyplanProcessor.objCopy)(args,this.editdata,PERIOD_EDITOR_FIELDS),(0,_ajax.call)([{methodname:"local_treestudyplan_edit_period",args:args}])[0].done((function(response){(0,_studyplanProcessor.objCopy)(self.value,response,PERIOD_EDITOR_FIELDS),self.$emit("input",self.value)})).fail(_notification.default.exception)}},template:'\n \n \n \n \n \n \n {{ text.fullname}}\n \n 0\'\n >\n \n \n \n {{ text.shortname}}\n \n 0\'\n >\n \n \n \n {{ text.studyplan_startdate}}\n \n \n \n \n \n {{ text.studyplan_enddate}}\n \n \n \n \n \n \n \n '}),Vue.component("t-studyplan",{props:["value","index"],data:function(){return{config:{userfields:[{key:"selected"},{key:"firstname",sortable:!0},{key:"lastname",sortable:!0}],cohortfields:[{key:"selected"},{key:"name",sortable:!0},{key:"context",sortable:!0}]},create:{studyline:{name:"",shortname:"",color:"#DDDDDD"}},edit:{studyline:{editmode:!1,data:{name:"",shortname:"",color:"#DDDDDD"},original:{}},studyplan:{data:{name:"",shortname:"",description:"",slots:4,startdate:"2020-08-01",enddate:"",aggregation:"",aggregation_config:"",aggregation_info:{useRequiredGrades:!0,useItemCondition:!1}},original:{}}},text:strings.studyplan_text,cache:{linelayers:{}}}},created:function(){},mounted:function(){0==this.page.studylines.length&&(this.edit.studyline.editmode=!0),this.$root.$emit("redrawLines")},updated:function(){this.$root.$emit("redrawLines"),ItemEventBus.$emit("redrawLines")},computed:{columns:function(){return 1+2*this.page.periods},columns_stylerule:function(){for(var s="grid-template-columns: var(--studyplan-filter-width)",i=0;imaxLayer&&(maxLayer=item.layer)}for(var _ix in line.slots[i].filters){var _item=line.slots[i].filters[_ix];_item.layer>maxLayer&&(maxLayer=_item.layer)}}return this.cache.linelayers[line.id]={value:maxLayer+1,timestamp:new Date},maxLayer+1},slotsempty:function(slots){if(Array.isArray(slots)){for(var count=0,i=0;i0&&item.span-i>0&&(show=!1):item.span-i>1&&(show=!1))}}return show}},template:'\n
\n
\n {{ text.studyline_editmode }}\n \n \n \n \n \n \n {{text.edit$core}} \n \n \n {{text.associations}}\n \n \n \n \n
\n
\n \n \n \n
\n
\n\n \x3c!-- Now paint the headings column --\x3e\n
\n \n \n
\n \x3c!-- Next, paint all the cells in the scrollable --\x3e\n
\n
\n \x3c!-- add period information --\x3e\n \n \n \x3c!-- Line by line add the items --\x3e\n \x3c!-- The grid layout handles putting it in rows and columns --\x3e\n