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: [] = []
|
2019-01-27 19:09:48 +01:00
|
|
|
public menuPopupTodo: [] = []
|
2019-01-16 02:26:43 +01:00
|
|
|
public iconCompleted: string = ''
|
2019-01-27 19:09:48 +01:00
|
|
|
public classCompleted: string = ''
|
|
|
|
|
public classDescr: string = ''
|
|
|
|
|
public classExpiring: string = ''
|
|
|
|
|
public classExpiringEx: string = ''
|
2019-01-16 02:26:43 +01:00
|
|
|
public iconPriority: string = ''
|
|
|
|
|
public popover: boolean = false
|
2019-01-27 19:09:48 +01:00
|
|
|
public popover_menu: boolean = false
|
|
|
|
|
public classRow: string = ''
|
|
|
|
|
public sel: boolean = false
|
2019-01-27 21:49:10 +01:00
|
|
|
public isover: boolean = false
|
|
|
|
|
public classPosItemPopup = 'pos-item-popover'
|
2019-01-16 02:26:43 +01:00
|
|
|
$q: any
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
@Prop({ required: true }) itemtodo: ITodo
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
|
|
|
|
|
@Watch('itemtodo.completed') valueChanged() {
|
|
|
|
|
this.$emit('eventupdate', this.itemtodo)
|
2019-01-27 19:09:48 +01:00
|
|
|
this.updateicon()
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
@Watch('itemtodo.expiring_at') valueChanged2() {
|
|
|
|
|
this.$emit('eventupdate', this.itemtodo)
|
|
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
@Watch('itemtodo.priority') valueChanged3() {
|
|
|
|
|
this.$emit('eventupdate', this.itemtodo)
|
2019-01-27 19:09:48 +01:00
|
|
|
this.updateicon()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateClasses() {
|
2019-01-27 21:49:10 +01:00
|
|
|
// this.classCompleted = 'completed-item'
|
|
|
|
|
this.classCompleted = 'completed-item-popover'
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
this.classDescr = 'flex-item div_descr'
|
|
|
|
|
this.classExpiring = 'flex-item data-item'
|
|
|
|
|
this.classExpiringEx = ''
|
|
|
|
|
if (this.itemtodo.completed) {
|
|
|
|
|
this.classCompleted += ' icon_completed'
|
|
|
|
|
this.classDescr += ' status_completed'
|
|
|
|
|
this.classExpiring += ' status_completed'
|
|
|
|
|
this.classExpiringEx += ' status_completed'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
created() {
|
|
|
|
|
this.updateicon()
|
|
|
|
|
|
|
|
|
|
this.updateClasses()
|
|
|
|
|
|
|
|
|
|
this.selectPriority = rescodes.selectPriority[UserStore.state.lang]
|
|
|
|
|
this.menuPopupTodo = rescodes.menuPopupTodo[UserStore.state.lang]
|
|
|
|
|
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-27 21:49:10 +01:00
|
|
|
setclassPosItemPopup() {
|
|
|
|
|
|
|
|
|
|
if (this.isover)
|
|
|
|
|
this.classPosItemPopup = 'pos-item-popover'
|
|
|
|
|
else
|
|
|
|
|
this.classPosItemPopup = 'pos-item-popover'
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
getClassRow() {
|
|
|
|
|
return 'row flex-container2 ' + this.classRow
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clickRiga () {
|
|
|
|
|
this.sel = false
|
|
|
|
|
if (this.classRow !== 'rowselected') {
|
|
|
|
|
this.sel = true
|
|
|
|
|
} else {
|
|
|
|
|
this.sel = false
|
|
|
|
|
}
|
|
|
|
|
this.$emit('click', this.itemtodo)
|
|
|
|
|
|
|
|
|
|
this.classRow = 'rowselected'
|
|
|
|
|
|
|
|
|
|
this.updateClasses()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mouseUp() {
|
|
|
|
|
|
|
|
|
|
if (this.sel) {
|
|
|
|
|
this.classRow = 'rowselected'
|
|
|
|
|
} else {
|
|
|
|
|
this.classRow = ''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setCompleted() {
|
2019-01-16 02:26:43 +01:00
|
|
|
// console.log('setCompleted')
|
|
|
|
|
this.itemtodo.completed = !this.itemtodo.completed
|
|
|
|
|
|
|
|
|
|
this.updateicon()
|
|
|
|
|
|
|
|
|
|
this.updatedata()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatedata() {
|
2019-01-27 19:09:48 +01:00
|
|
|
console.log('calling this.$emit(eventupdate)')
|
2019-01-16 02:26:43 +01:00
|
|
|
this.$emit('eventupdate', this.itemtodo)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
updateicon() {
|
|
|
|
|
console.log('updateicon')
|
2019-01-16 02:26:43 +01:00
|
|
|
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-27 19:09:48 +01:00
|
|
|
removeitem(id) {
|
|
|
|
|
this.$emit('deleteitem', id)
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
clickMenu(action) {
|
|
|
|
|
console.log('click menu: ', action)
|
|
|
|
|
if (action === rescodes.MenuAction.DELETE)
|
|
|
|
|
this.removeitem(this.itemtodo.id)
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
setPriority(newpriority) {
|
2019-01-16 02:26:43 +01:00
|
|
|
|
|
|
|
|
this.itemtodo.priority = newpriority
|
|
|
|
|
|
|
|
|
|
this.updatedata()
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
this.updateicon()
|
|
|
|
|
|
2019-01-16 02:26:43 +01:00
|
|
|
// this.$q.notify('setPriority: ' + elem)
|
|
|
|
|
}
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|