1 line
15 KiB
Plaintext
1 line
15 KiB
Plaintext
{"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} from './util/date-helper';\n\nexport default {\n studyplanTiming(plan) {\n const now = new Date().getTime();\n \n const dates = studyplanDates(plan);\n\n if(dates.start < now){\n if( dates.end && now > dates.end) {\n return 'past';\n } else {\n return 'present';\n }\n } else {\n return 'future';\n }\n },\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 });\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 const now = new Date().getTime();\n const startdate = new Date(this.value.pages[0].startdate).getTime();\n const enddate = new Date(this.value.pages[0].enddate).getTime();\n let timing = 'future';\n if(startdate < now){\n if(this.value.pages[0].enddate && now > enddate) {\n timing = 'past';\n } else {\n timing = 'present';\n }\n }\n return timing;\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 width_completed() {\n if(this.value.progress) {\n return this.value.progress * 100;\n } else {\n return 0;\n }\n },\n width_incomplete() {\n if(this.value.progress) {\n return (1-this.value.progress) * 100;\n } else {\n return 100;\n }\n },\n percentage_complete() {\n if(this.value.progress) {\n return Math.round(this.value.progress * 100) + \"%\";\n } else {\n return \"0%\";\n }\n }\n },\n methods: {\n onOpenClick(e) {\n this.$emit('open',e);\n }\n },\n template: `\n <b-card\n :class=\"'s-studyplan-card timing-' + timing\"\n >\n <template #header></template>\n \n <div class='s-studyplan-card-content'>\n <div class='s-studyplan-card-icon'><img :src='value.icon'></div>\n <div class='s-studyplan-card-info'>\n <div class='s-studyplan-card-titlebar'>\n <b-card-title>\n <a v-if='open' href='#' @click.prevent='onOpenClick($event)'>{{value.name}}</a>\n <template v-else>{{value.name}}</template>\n </b-card-title>\n <div class='s-studyplan-card-titleslot'><slot name='title'></slot></div>\n </div> \n <div class='s-studyplan-card-idnumber' v-if='value.idnumber'>\n {{ text.idnumber }}: {{ value.idnumber }}\n </div>\n <div class='s-studyplan-card-progress' v-if='value.progress !== undefined && value.progress !== null'>\n <div class=\"s-studyplan-card-progressbar\"\n ><span v-if=\"width_completed > 0\"\n :style=\"{width: width_completed+'%'}\"\n class='s-studyplan-card-progress-segment s-studyplan-card-progress-completed'\n ></span\n ><span :style=\"{width: width_incomplete+'%'}\"\n class='s-studyplan-card-progress-segment s-studyplan-card-progress-incomplete'\n ></span\n ></div>\n <div class=\"s-studyplan-card-progresstext\">\n {{ percentage_complete}} {{ text.completed.toLowerCase() }} \n </div>\n </div>\n </div>\n \n </div>\n <slot></slot>\n <template #footer>\n <span :class=\"'t-timing-'+timing\" v-html=\"dates.start + ' - '+ dates.end\"></span>\n <span class=\"s-studyplan-card-buttons\">\n <slot name='footer'></slot>\n <s-studyplan-details \n v-model=\"value\" \n v-if=\"value.description\"\n ><i class='fa fa-info-circle'></i></s-studyplan-details>\n <b-button style=\"float:right;\" v-if='open' variant='primary'\n @click.prevent='onOpenClick($event)'>{{ text.open }}</b-button>\n </span>\n </template>\n </b-card>\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 <div class=\"s-studyline-header-heading\" ref=\"main\" :data-id=\"identifier\"></div>\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 <div :class=\"'s-studyline-header-period ' + (current?'current ':' ')\" ref=\"main\" :data-id=\"identifier\"\n ><p><abbr :id=\"'s-period-'+value.id\" :title=\"value.fullname\">{{ value.shortname }}</abbr>\n <b-tooltip\n :target=\"'s-period-'+value.id\" triggers=\"hover\"\n >{{ value.fullname }}<br>\n <span class=\"s-studyline-header-period-datespan\">\n <span class=\"date\">{{ startdate }}</span> - <span class=\"date\">{{ enddate }}</span>\n </span>\n </b-tooltip>\n <slot></slot\n ><p class=\"s-studyline-header-period-datespan small\">\n <span class=\"date\">{{ startdate }}</span> - <span class=\"date\">{{ enddate }}</span>\n </p>\n </div>\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 <span>\n <b-button \n :size=\"size\"\n :pill=\"pill\"\n :variant=\"variant\" \n v-b-modal=\"'modal-description-'+value.id\"\n ><slot><i class='fa fa-info-circle'></i>\n {{ text.details}}</slot>\n </b-button>\n <b-modal\n :title=\"value.name\"\n scrollable\n centered\n ok-only\n content-class=\"s-studyplan-details\"\n :id=\"'modal-description-'+value.id\"\n >\n <b-container>\n <b-row>\n <b-col cols=\"4\"><img :src='value.icon'></b-col>\n <b-col cols=\"8\" class=\"pl-1\">\n <span v-html=\"value.description\"></span>\n </b-col>\n </b-row>\n </b-container>\n </b-modal>\n </span>\n `,\n });\n\n }\n};"],"names":["studyplanTiming","plan","now","Date","getTime","dates","start","end","install","Vue","strings","studyplancard","open","noenddate","idnumber","description","completed","details","ItemEventBus","component","props","value","type","Object","Boolean","data","text","computed","timing","startdate","this","pages","enddate","width_completed","progress","width_incomplete","percentage_complete","Math","round","methods","onOpenClick","e","$emit","template","identifier","Number","default","layerHeights","created","$on","onHeaderHeightChange","newheight","$refs","main","style","height","mounted","self","period","resizeListener","ResizeObserver","size","getBoundingClientRect","observe","unmounted","disconnect","current","pstart","pend","variant","String","pill"],"mappings":"yPASe,CACXA,gBAAgBC,YACNC,KAAM,IAAIC,MAAOC,UAEjBC,OAAQ,8BAAeJ,aAE1BI,MAAMC,MAAQJ,IACTG,MAAME,KAAOL,IAAMG,MAAME,IAClB,OAEA,UAGJ,UAIfC,QAAQC,SACAC,SAAU,8BAAa,CACvBC,cAAe,CACXC,KAAM,OACNC,UAAW,YACXC,SAAU,qBACVC,YAAa,wBACbC,UAAW,YACXC,QAAS,qBAEbA,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