/*eslint no-var: "error"*/
/*eslint no-console: "off"*/
/*eslint-disable no-trailing-spaces */
/*eslint-env es6*/
// Put this file in path/to/plugin/amd/src
import {load_strings, format_date} from './string-helper';
export default {
studyplanTiming(a) {
const now = new Date().getTime();
let timing = 'future';
if(new Date(a.startdate).getTime() < now){
if(a.enddate && now > new Date(a.enddate).getTime()) {
timing = 'past';
} else {
timing = 'present';
}
}
return timing;
},
install(Vue/*,options*/){
let strings = load_strings({
studyplancard: {
open: "open",
noenddate: "noenddate",
}
});
// Create new eventbus for interaction between item components
const ItemEventBus = new Vue();
Vue.component('s-studyplan-card', {
props: {
value: {
type: Object,
},
open: {
type: Boolean
}
},
data() {
return {
text: strings.studyplancard
};
},
computed: {
timing(){
const now = new Date().getTime();
const startdate = new Date(this.value.pages[0].startdate).getTime();
const enddate = new Date(this.value.pages[0].enddate).getTime();
let timing = 'future';
if(startdate < now){
if(this.value.pages[0].enddate && now > enddate) {
timing = 'past';
} else {
timing = 'present';
}
}
return timing;
},
startdate(){
return format_date(this.value.pages[0].startdate);
},
enddate(){
if(this.value.enddate){
return format_date(this.value.pages[0].enddate);
}
else {
return this.text.noenddate;
}
}
},
methods: {
onOpenClick(e) {
this.$emit('open',e);
}
},
template: `
{{ value.shortname }}
{{ startdate }} - {{ enddate }}
{{ startdate }} - {{ enddate }}