2019-01-14 22:40:30 +01:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
import { Component, Prop, Watch } from 'vue-property-decorator'
|
|
|
|
|
|
|
|
|
|
import { rescodes } from '../../../store/Modules/rescodes'
|
|
|
|
|
import { UserStore } from '@modules'
|
|
|
|
|
|
|
|
|
|
import { ITodo } from '../../../model/index'
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
name: 'SingleTodo'
|
|
|
|
|
})
|
|
|
|
|
export default class SingleTodo extends Vue {
|
2019-01-16 02:26:43 +01:00
|
|
|
public selectPriority: [] = []
|
|
|
|
|
public iconCompleted: string = ''
|
|
|
|
|
public iconPriority: string = ''
|
|
|
|
|
public popover: boolean = false
|
|
|
|
|
$q: any
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
@Prop({required: true}) itemtodo: ITodo
|
|
|
|
|
|
|
|
|
|
@Watch('itemtodo.completed') valueChanged() {
|
|
|
|
|
this.$emit('eventupdate', this.itemtodo)
|
|
|
|
|
}
|
|
|
|
|
@Watch('itemtodo.expiring_at') valueChanged2() {
|
|
|
|
|
this.$emit('eventupdate', this.itemtodo)
|
|
|
|
|
}
|
|
|
|
|
@Watch('itemtodo.priority') valueChanged3() {
|
|
|
|
|
this.$emit('eventupdate', this.itemtodo)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-16 02:26:43 +01:00
|
|
|
setCompleted () {
|
|
|
|
|
// console.log('setCompleted')
|
|
|
|
|
this.itemtodo.completed = !this.itemtodo.completed
|
|
|
|
|
|
|
|
|
|
this.updateicon()
|
|
|
|
|
|
|
|
|
|
this.updatedata()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatedata() {
|
|
|
|
|
this.$emit('eventupdate', this.itemtodo)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateicon () {
|
|
|
|
|
if (this.itemtodo.completed)
|
|
|
|
|
this.iconCompleted = 'check_circle'
|
|
|
|
|
else
|
|
|
|
|
this.iconCompleted = 'check_circle_outline'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.itemtodo.priority === rescodes.Todos.PRIORITY_HIGH)
|
|
|
|
|
this.iconPriority = 'expand_less' // expand_less
|
|
|
|
|
else if (this.itemtodo.priority === rescodes.Todos.PRIORITY_NORMAL)
|
|
|
|
|
this.iconPriority = 'remove'
|
|
|
|
|
else if (this.itemtodo.priority === rescodes.Todos.PRIORITY_LOW)
|
|
|
|
|
this.iconPriority = 'expand_more' // expand_more
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
created() {
|
2019-01-16 02:26:43 +01:00
|
|
|
this.updateicon()
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
this.selectPriority = rescodes.selectPriority[UserStore.state.lang]
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
remove(id) {
|
|
|
|
|
this.$emit('event', id)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-16 02:26:43 +01:00
|
|
|
setPriority (newpriority) {
|
|
|
|
|
|
|
|
|
|
this.itemtodo.priority = newpriority
|
|
|
|
|
|
|
|
|
|
this.updatedata()
|
|
|
|
|
|
|
|
|
|
// this.$q.notify('setPriority: ' + elem)
|
|
|
|
|
}
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|