1 line
9.5 KiB
Plaintext
1 line
9.5 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, format_date} from './string-helper';\n\nexport default {\n studyplanTiming(a) {\n const now = new Date().getTime();\n let timing = 'future';\n if(new Date(a.startdate).getTime() < now){\n if(a.enddate && now > new Date(a.enddate).getTime()) {\n timing = 'past';\n } else {\n timing = 'present';\n }\n }\n return timing;\n },\n\n install(Vue/*,options*/){\n let strings = load_strings({\n studyplancard: {\n open: \"open\",\n noenddate: \"noenddate\",\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 startdate(){\n return format_date(this.value.pages[0].startdate);\n },\n enddate(){\n if(this.value.enddate){\n return format_date(this.value.pages[0].enddate);\n } \n else {\n return this.text.noenddate;\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 <b-card-title>\n <a v-if='open' href='#' @click.prevent='onOpenClick($event)'>{{value.name}}</a>\n <template v-else>{{value.name}}</template>\n <slot name='title'></slot>\n </b-card-title>\n {{ value.description }}\n <slot></slot>\n <template #footer>\n <span :class=\"'t-timing-'+timing\" v-html=\"startdate + ' - '+ enddate\"></span>\n <span class=\"s-studyplan-card-buttons\">\n <slot name='footer'></slot>\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\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){\n if(this.$refs.main){\n this.$refs.main.style.height = `${newheight}px`;\n }\n }\n },\n template: `\n <div class=\"s-studyline-header-heading\" ref=\"main\"></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 },\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);\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\"\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 }\n};"],"names":["studyplanTiming","a","now","Date","getTime","timing","startdate","enddate","install","Vue","strings","studyplancard","open","noenddate","ItemEventBus","component","props","value","type","Object","Boolean","data","text","computed","this","pages","methods","onOpenClick","e","$emit","template","layerHeights","created","$on","onHeaderHeightChange","newheight","$refs","main","style","height","mounted","self","period","resizeListener","ResizeObserver","size","getBoundingClientRect","observe","unmounted","disconnect","current","pstart","pend"],"mappings":"mNAQe,CACXA,yBAAgBC,OACNC,KAAM,IAAIC,MAAOC,UACnBC,OAAS,gBACV,IAAIF,KAAKF,EAAEK,WAAWF,UAAYF,MAE7BG,OADDJ,EAAEM,SAAWL,IAAM,IAAIC,KAAKF,EAAEM,SAASH,UAC7B,OAEA,WAGVC,QAGXG,iBAAQC,SACAC,SAAU,8BAAa,CACvBC,cAAe,CACXC,KAAM,OACNC,UAAW,eAIbC,aAAe,IAAIL,IAEzBA,IAAIM,UAAU,mBAAoB,CAC9BC,MAAO,CACHC,MAAO,CACHC,KAAMC,QAEVP,KAAM,CACFM,KAAME,UAGdC,sBACW,CACHC,KAAMZ,QAAQC,gBAGtBY,SAAU,CACNlB,sBACUH,KAAM,IAAIC,MAAOC,UACjBE,UAAY,IAAIH,KAAKqB,KAAKP,MAAMQ,MAAM,GAAGnB,WAAWF,UACpDG,QAAU,IAAIJ,KAAKqB,KAAKP,MAAMQ,MAAM,GAAGlB,SAASH,UAClDC,OAAS,gBACVC,UAAYJ,MAEPG,OADDmB,KAAKP,MAAMQ,MAAM,GAAGlB,SAAWL,IAAMK,QAC3B,OAEA,WAGVF,QAEXC,4BACW,6BAAYkB,KAAKP,MAAMQ,MAAM,GA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