{"version":3,"file":"treestudyplan-components.min.js","sources":["../src/treestudyplan-components.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint-disable no-trailing-spaces */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n\nimport {load_strings} from './util/string-helper';\nimport {format_date, studyplanDates, studyplanTiming} from './util/date-helper';\nimport FitTextVue from './util/fittext-vue';\n\n\nexport default {\n\n install(Vue/*,options*/){\n Vue.use(FitTextVue);\n\n let strings = load_strings({\n studyplancard: {\n open: \"open\",\n noenddate: \"noenddate\",\n idnumber: \"studyplan_idnumber\",\n description: \"studyplan_description\",\n completed: \"completed\",\n details: \"studyplan_details\",\n suspended: \"suspended\",\n },\n details: {\n details: \"studyplan_details\",\n },\n extrafields: {\n show: \"show@core\"\n },\n prevnext: {\n prev: \"prev@core\",\n previous: \"previous@core\",\n next: \"next@core\",\n select: \"selectanoptions@core\",\n }\n });\n // Create new eventbus for interaction between item components\n const ItemEventBus = new Vue();\n\n Vue.component('s-studyplan-card', {\n props: {\n value: {\n type: Object,\n },\n open: {\n type: Boolean\n },\n ignoresuspend: {\n type: Boolean,\n default: false,\n },\n },\n data() {\n return {\n text: strings.studyplancard\n };\n },\n computed: {\n timeless() {\n const plan = this.value;\n if (!plan.pages || plan.pages.length == 0 || plan.pages[0].timeless) {\n return true;\n } else {\n return false;\n }\n },\n timing(){\n return studyplanTiming(this.value);\n },\n dates(){\n const dates = studyplanDates(this.value);\n return {\n start: format_date(dates.start),\n end: (dates.end)?format_date(dates.end):this.text.noenddate,\n };\n },\n suspended() {\n return (this.value.suspended && !this.ignoresuspend);\n }\n \n },\n methods: {\n onOpenClick(e) {\n this.$emit('open',e);\n }\n },\n template: `\n \n \n \n
\n
\n
\n
\n \n {{value.name}}\n \n
{{text.suspended}}
\n
\n
\n
\n
\n {{ text.idnumber }}: {{ value.idnumber }}\n
\n \n
\n \n
\n \n \n \n `,\n });\n\n Vue.component('s-progress-bar', {\n props: {\n value: {\n type: Number, \n },\n min: {\n type: Number,\n default() { return 0;}\n },\n max: {\n type: Number,\n default() { return 1;}\n }\n },\n data() {\n return {\n text: strings.studyplancard\n };\n },\n computed: {\n width_completed() {\n if(this.value) {\n const v = ( (this.value - this.min) / (this.max - this.min));\n return v * 100;\n } else {\n return 0;\n }\n },\n width_incomplete() {\n if(this.value) {\n const v = ( (this.value - this.min) / (this.max - this.min));\n return (1-v) * 100;\n } else {\n return 100;\n }\n },\n percentage_complete() {\n if(this.value) {\n const v = ( (this.value - this.min) / (this.max - this.min));\n return Math.round(v * 100) + \"%\";\n } else {\n return \"0%\";\n }\n }\n },\n template: `\n
\n
0\"\n :style=\"{width: width_completed+'%'}\"\n class='s-studyplan-card-progress-segment s-studyplan-card-progress-completed'\n >
\n
\n {{ percentage_complete}} {{ text.completed.toLowerCase() }} \n
\n
\n `,\n });\n\n\n\n /*\n * S-STUDYLINE-HEADER-HEADING\n * The only reasing this is not a simple empty div, is the fact that the header height\n * needs to match that of the period headers\n */\n Vue.component('s-studyline-header-heading', {\n props: {\n identifier: {\n type: Number, // Page reference.\n default() { return 0;}\n }\n },\n data() {\n return {\n layerHeights: {}\n };\n },\n created() {\n // Listener for the signal that a new connection was made and needs to be drawn\n // Sent by the incoming item - By convention, outgoing items are responsible for drawing the lines\n ItemEventBus.$on('headerHeightChange', this.onHeaderHeightChange);\n },\n computed: {\n\n },\n methods: {\n onHeaderHeightChange(newheight,identifier){\n if (this.identifier == identifier) {\n if(this.$refs.main){\n this.$refs.main.style.height = `${newheight}px`;\n }\n }\n }\n },\n template: `\n
\n `,\n });\n\n Vue.component('s-studyline-header-period', {\n props: {\n value: {\n type: Object, // dict with layer as index\n },\n identifier: {\n type: Number, // Page reference.\n default() { return 0;}\n },\n mode: {\n type: String,\n default: \"view\",\n }\n },\n mounted() {\n const self=this;\n if(self.value.period == 1){\n self.resizeListener = new ResizeObserver(() => {\n if(self.$refs.main){\n const size = self.$refs.main.getBoundingClientRect();\n ItemEventBus.$emit('headerHeightChange', size.height, self.identifier);\n }\n }).observe(self.$refs.main);\n }\n },\n unmounted() {\n if(this.resizeListener) {\n this.resizeListener.disconnect();\n }\n },\n computed: {\n startdate(){\n return format_date(this.value.startdate);\n },\n enddate(){\n return format_date(this.value.enddate);\n },\n current(){\n if( this.value && this.value.startdate && this.value.enddate){\n const now = new Date();\n const pstart = new Date(this.value.startdate);\n const pend = new Date(this.value.enddate);\n return (now >= pstart && now < pend);\n }\n else {\n return false;\n }\n }\n\n },\n data() {\n return {\n };\n },\n template: `\n

{{ value.shortname }}\n {{ value.fullname }}
\n \n {{ startdate }} - {{ enddate }}\n \n \n

0\" \n class=\"s-studyline-header-period-datespan small\">\n {{ startdate }}\n - 0\">{{ enddate }}\n

\n
\n
\n `,\n });\n\n\n Vue.component('s-studyplan-details', {\n props: {\n value: {\n type: Object, \n },\n variant: {\n type: String,\n default() { return \"info\"; }\n },\n pill: {\n type: Boolean,\n default() { return false; }\n },\n size: {\n type: String,\n default() { return \"\";}\n }\n },\n data() {\n return {\n text: strings.details,\n };\n },\n template: `\n \n \n {{ text.details}}\n \n \n \n \n \n \n \n \n \n \n \n \n `,\n });\n\n Vue.component('s-course-extrafields', {\n props: {\n value: {\n type: Array, \n },\n variant: {\n type: String,\n default() { return \"info\"; }\n },\n position: {\n type: String,\n default() { return \"below\"; }\n },\n size: {\n type: String,\n default() { return \"\";}\n }\n },\n data() {\n return {\n text: strings.extrafields,\n };\n },\n computed: {\n fields() {\n const fields = [];\n for (const ix in this.value) {\n const field = this.value[ix];\n if (field.position == this.position && field.value && field.value.length > 0) {\n fields.push(field);\n }\n }\n return fields;\n },\n },\n methods: {\n displaydate(field) {\n return format_date(field.value,false);\n },\n },\n template: `\n
0)?position:'empty')\">\n 0\">\n \n \n \n \n
{{ field.title}}\n {{ displaydate(field) }}\n {{ field.value }}\n \n {{text.show}}...\n \n \n \n
\n
\n `,\n });\n\n Vue.component('s-prevnext-selector', {\n props: {\n value: {\n type: Object, \n default() { return null;}\n },\n options: {\n type: Array,\n },\n grouped: {\n type: Boolean,\n default: false,\n },\n titlefield: {\n type: String,\n default: \"title\",\n },\n labelfield: {\n type: String,\n default: \"label\",\n },\n optionsfield: {\n type: String,\n default: \"options\",\n },\n defaultselectable: {\n type: Boolean,\n default: false,\n },\n variant: {\n type: String,\n default: \"\",\n },\n arrows: {\n type: Boolean,\n default: false,\n },\n },\n data() {\n return {\n text: strings.prevnext,\n };\n },\n computed: {\n fields() {\n const f = [];\n if(this.defaultselectable) {\n f.push(null);\n }\n if (this.grouped) {\n for ( const gix in this.options) {\n const group = this.options[gix];\n for ( const ix in group[this.optionsfield]) {\n const v = group[this.optionsfield][ix];\n f.push(v);\n }\n }\n } else {\n for ( const ix in this.options) {\n const v = this.options[ix];\n f.push(v);\n }\n }\n return f;\n },\n bubblevalue: {\n get() { return (this.value)?this.value:null;},\n set(v) { this.$emit('input',(v)?v:null);},\n }\n },\n methods: {\n atFirst() {\n if (this.fields.length > 0) {\n return this.fields[0] == this.value;\n }\n return true; // Since it disables the button, do so if pressing it would make no sense.\n },\n atLast() {\n if (this.fields.length > 0) {\n const l = this.fields.length -1;\n return this.fields[l] == this.value;\n }\n return true; // Since it disables the button, do so if pressing it would make no sense.\n },\n prev() {\n if (this.fields.length > 0) {\n const index = this.fields.indexOf(this.value);\n if (index > 0) {\n this.$emit(\"input\",this.fields[index -1]);\n this.$emit(\"change\",this.fields[index -1]);\n }\n }\n },\n next() {\n if (this.fields.length > 0) {\n const index = this.fields.indexOf(this.value);\n const l = this.fields.length -1;\n if (index >= 0 && index < l) {\n this.$emit(\"input\",this.fields[index + 1]);\n this.$emit(\"change\",this.fields[index + 1]);\n }\n }\n },\n selectedchanged(value) {\n this.$emit(\"change\",value);\n }\n },\n template: `\n
\n \n \n {{text.select}}\n \n \n \n \n \n
\n `,\n });\n\n\n }\n};"],"names":["install","Vue","use","FitTextVue","strings","studyplancard","open","noenddate","idnumber","description","completed","details","suspended","extrafields","show","prevnext","prev","previous","next","select","ItemEventBus","component","props","value","type","Object","Boolean","ignoresuspend","default","data","text","computed","timeless","plan","this","pages","length","timing","dates","start","end","methods","onOpenClick","e","$emit","template","Number","min","max","width_completed","width_incomplete","percentage_complete","v","Math","round","identifier","layerHeights","created","$on","onHeaderHeightChange","newheight","$refs","main","style","height","mode","String","mounted","self","period","resizeListener","ResizeObserver","size","getBoundingClientRect","observe","unmounted","disconnect","startdate","enddate","current","now","Date","pstart","pend","variant","pill","Array","position","fields","ix","field","push","displaydate","options","grouped","titlefield","labelfield","optionsfield","defaultselectable","arrows","f","gix","group","bubblevalue","get","set","atFirst","atLast","l","index","indexOf","selectedchanged"],"mappings":"kWAWe,CAEXA,QAAQC,KACJA,IAAIC,IAAIC,yBAEJC,SAAU,8BAAa,CACvBC,cAAe,CACXC,KAAM,OACNC,UAAW,YACXC,SAAU,qBACVC,YAAa,wBACbC,UAAW,YACXC,QAAS,oBACTC,UAAW,aAEfD,QAAS,CACLA,QAAS,qBAEbE,YAAa,CACTC,KAAM,aAEVC,SAAU,CACNC,KAAM,YACNC,SAAU,gBACVC,KAAM,YACNC,OAAQ,gCAIVC,aAAe,IAAInB,IAEzBA,IAAIoB,UAAU,mBAAoB,CAC9BC,MAAO,CACHC,MAAO,CACHC,KAAMC,QAEVnB,KAAM,CACFkB,KAAME,SAEVC,cAAe,CACXH,KAAME,QACNE,SAAS,IAGjBC,KAAI,KACO,CACHC,KAAM1B,QAAQC,gBAGtB0B,SAAU,CACNC,iBACUC,KAAOC,KAAKX,cACbU,KAAKE,OAA8B,GAArBF,KAAKE,MAAMC,SAAeH,KAAKE,MAAM,GAAGH,WAM/DK,gBACW,+BAAgBH,KAAKX,QAEhCe,cACUA,OAAQ,8BAAeJ,KAAKX,aAC3B,CACHgB,OAAO,2BAAYD,MAAMC,OACzBC,IAAMF,MAAME,KAAK,2BAAYF,MAAME,KAAKN,KAAKJ,KAAKvB,YAG1DK,mBACYsB,KAAKX,MAAMX,YAAcsB,KAAKP,gBAI9C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