{"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';\n\nexport default {\n\n install(Vue/*,options*/){\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 },\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 },\n data() {\n return {\n text: strings.studyplancard\n };\n },\n computed: {\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 \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 \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 },\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

\n {{ startdate }} - {{ 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","strings","studyplancard","open","noenddate","idnumber","description","completed","details","extrafields","show","prevnext","prev","previous","next","select","ItemEventBus","component","props","value","type","Object","Boolean","data","text","computed","timing","this","dates","start","end","methods","onOpenClick","e","$emit","template","Number","min","default","max","width_completed","width_incomplete","percentage_complete","v","Math","round","identifier","layerHeights","created","$on","onHeaderHeightChange","newheight","$refs","main","style","height","mounted","self","period","resizeListener","ResizeObserver","size","getBoundingClientRect","observe","unmounted","disconnect","startdate","enddate","current","now","Date","pstart","pend","variant","String","pill","Array","position","fields","ix","field","length","push","displaydate","options","grouped","titlefield","labelfield","optionsfield","defaultselectable","arrows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