moodle_local_treestudyplan/amd/build/page-coach.min.js.map
2024-06-02 17:21:30 +02:00

1 line
14 KiB
Plaintext

{"version":3,"file":"page-coach.min.js","sources":["../src/page-coach.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 {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplancoach\");\n\nlet strings = load_strings({\n coach: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n switch_coach_editmode: 'switch_coach_editmode',\n },\n});\n\n/**\n * Initialize the Page\n */\nexport function init() {\n let app = new Vue({\n el: '#root',\n data: {\n selected: {\n planid: 0,\n studentid: 0,\n },\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.coach,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n editmode: false,\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_coaching_studyplans',\n args: {}\n }])[0].then(function(response){\n const timingval = { present: 0, past: 1, future: 2};\n response.sort((a,b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n\n const t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by name if timing is equal\n return a.name.localeCompare(b.name);\n }\n else {\n return t;\n }\n });\n app.studyplans = response;\n // load studyplan from hash if applicable\n const hash = window.location.hash.replace('#','');\n const parts = hash.split(\"-\");\n\n if(!!parts && parts.length > 0 && parts[0] != ''){\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == parts[0]){\n app.selectStudyplan(app.studyplans[idx],parts[1],false);\n break;\n }\n }\n }\n }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n },\n methods: {\n navChanged() {\n const hash = window.location.hash.replace('#','');\n const parts = hash.split(\"-\");\n debug.log(\"Navigation changed\",hash,parts);\n\n if(!!parts && parts.length > 0){\n const planid = Number(parts[0]);\n const studentid = (parts.length > 1)?Number(parts[1]):0;\n\n debug.log(\"Selected ids\",planid,studentid,this.selected.planid,this.selected.studentid);\n if ( planid == 0) {\n if (planid != this.selected.planid) {\n this.closeStudyplan(false);\n }\n } else if ( this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0) ) {\n debug.info (\"Requested plan changed - loading studyplan\");\n for(let idx in app.studyplans){\n const plan = this.studyplans[idx];\n if(Number(plan.id) == planid){\n this.selectStudyplan(plan,studentid,false);\n break;\n }\n }\n } else if (this.selected.studentid != studentid) {\n for(const group of app.associatedstudents) {\n for(const student of group.users){\n if(Number(student.id) == studentid){\n app.showStudentView(student,false);\n break;\n }\n }\n }\n }\n }\n },\n closeStudyplan(updatehash=true) {\n app.selected.planid = 0;\n app.selected.studentid = 0;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n if (updatehash) {\n window.location.hash = '';\n }\n },\n\n selectStudyplan(studyplan,studentid,updatehash=true){\n app.selected.planid = Number(studyplan.id);\n app.selected.studentid = studentid?Number(studentid):0;\n // fetch studyplan\n const self = this;\n self.loadingstudyplan = true;\n self.associatedstudents = [];\n self.selectedstudent = null;\n self.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplan.id}\n }])[0].then(function(response){\n self.activestudyplan = ProcessStudyplan(response,true);\n\n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: { studyplan_id: studyplan.id}\n }])[0].then(function(response){\n self.associatedstudents = response;\n let foundstudent = false;\n if(studentid){\n for(const group of self.associatedstudents) {\n for(const student of group.users){\n if(student.id == studentid){\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n }\n if (!foundstudent) {\n // Select first student available.\n for(const group of self.associatedstudents) {\n for(const student of group.users){\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n if (!foundstudent) { // update hash with just the studyplan if no student was available for display\n app.selected.studentid = 0;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n self.displayedstudyplan = self.activestudyplan;\n self.loadingstudyplan = false;\n }\n }).catch(notification.exception);\n\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student,updatehash=true){\n app.selected.studentid = student?Number(student.id):0;\n if (student) {\n app.selectedstudent = student;\n app.studentstudyplan = null;\n app.loadingstudyplan = true;\n call([{\n methodname: 'local_treestudyplan_get_user_studyplan',\n args: { userid: student.id, studyplanid: app.activestudyplan.id}\n }])[0].then(function(response){\n app.studentstudyplan = ProcessStudyplan(response,false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n } else {\n this.showOverview(updatehash);\n }\n },\n showOverview(updatehash=true){\n debug.info(\"Switch to overview\",updatehash);\n app.selected.studentid = 0;\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n }\n\n },\n });\n}\n"],"names":["app","Vue","el","data","selected","planid","studentid","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","coach","toolbox","right","usedcontexts","editmode","methodname","args","then","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","catch","notification","exception","this","navChanged","computed","methods","debug","log","Number","closeStudyplan","info","plan","group","student","users","showStudentView","updatehash","studyplan","self","studyplan_id","foundstudent","error","userid","studyplanid","showOverview","use","EditorComponents","TSComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","studyplan_select_placeholder","switch_coach_editmode"],"mappings":"ixBAkDQA,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,SAAU,CACNC,OAAQ,EACRC,UAAW,GAEfC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,MACdC,QAAS,CACLC,OAAO,GAEXC,aAAc,GACdC,UAAU,kCAGL,CAAC,CACFC,WAAY,+CACZC,KAAM,MACN,GAAGC,MAAK,SAASC,gBACXC,UAAY,CAAEC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GACjDJ,SAASK,MAAK,CAACC,EAAEC,WACPC,SAAU,+BAAgBF,GAC1BG,SAAU,+BAAgBF,GAE1BG,EAAIT,UAAUO,SAAWP,UAAUQ,gBACjC,GAALC,EAEQJ,EAAEK,KAAKC,cAAcL,EAAEI,MAGvBD,KAGflC,IAAIa,WAAaW,eAGXa,MADOC,OAAOC,SAASC,KAAKC,QAAQ,IAAI,IAC3BC,MAAM,QAEpBL,OAASA,MAAMM,OAAS,GAAiB,IAAZN,MAAM,OAChC,IAAIO,OAAO5C,IAAIa,cACZb,IAAIa,WAAW+B,KAAKC,IAAMR,MAAM,GAAG,CAClCrC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