2019-01-14 22:40:30 +01:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
import { Component, Prop, Watch } from 'vue-property-decorator'
|
|
|
|
|
|
|
|
|
|
import { UserStore } from '@modules'
|
2019-03-11 19:16:39 +01:00
|
|
|
import { tools } from '../../../store/Modules/tools'
|
2019-01-14 22:40:30 +01:00
|
|
|
|
|
|
|
|
import { ITodo } from '../../../model/index'
|
|
|
|
|
|
2019-01-30 01:05:31 +01:00
|
|
|
import { SubMenus } from '../SubMenus'
|
2019-01-29 23:13:28 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
import { date } from 'quasar'
|
2019-01-29 23:13:28 +01:00
|
|
|
import { askConfirm } from '../../../classes/routinestd'
|
2019-01-29 03:12:18 +01:00
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
@Component({
|
2019-03-11 19:16:39 +01:00
|
|
|
components: { SubMenus },
|
|
|
|
|
name: 'SingleTodo'
|
2019-01-14 22:40:30 +01:00
|
|
|
})
|
|
|
|
|
export default class SingleTodo extends Vue {
|
2019-01-16 02:26:43 +01:00
|
|
|
public selectPriority: [] = []
|
2019-01-28 03:13:04 +01:00
|
|
|
public menuPopupTodo: any[] = []
|
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 = ''
|
2019-01-28 20:39:40 +01:00
|
|
|
public classDescrEdit: string = ''
|
2019-03-13 01:53:53 +01:00
|
|
|
public classExpiring: string = 'flex-item data-item shadow-1'
|
2019-01-27 19:09:48 +01:00
|
|
|
public classExpiringEx: string = ''
|
2019-01-16 02:26:43 +01:00
|
|
|
public iconPriority: string = ''
|
|
|
|
|
public popover: boolean = false
|
2019-01-29 03:12:18 +01:00
|
|
|
public popover_menu: boolean = false // Serve
|
2019-01-27 19:09:48 +01:00
|
|
|
public classRow: string = ''
|
|
|
|
|
public sel: boolean = false
|
2019-01-28 03:13:04 +01:00
|
|
|
public inEdit: boolean = false
|
2019-01-28 20:39:40 +01:00
|
|
|
public precDescr: string = ''
|
2019-01-29 00:48:04 +01:00
|
|
|
public menuProgress: string = 'menuprogress'
|
|
|
|
|
public percProgress: string = 'percProgress'
|
|
|
|
|
public colProgress: string = 'blue'
|
2019-01-29 23:13:28 +01:00
|
|
|
public togglemenu: boolean = false
|
2019-01-30 02:01:04 +01:00
|
|
|
public percentageProgress: number = 0
|
2019-02-12 12:06:01 +01:00
|
|
|
public itemtodoPrec: ITodo
|
2019-02-15 01:25:44 +01:00
|
|
|
public clButtPopover: string = 'pos-item-popover'
|
2019-02-16 03:49:16 +01:00
|
|
|
public numpos: number = 0
|
2019-02-15 01:25:44 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public $q: any
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
@Prop({ required: true }) public itemtodo: ITodo
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
// @Watch('itemtodo.completed') valueChanged() {
|
|
|
|
|
// this.watchupdate('completed')
|
|
|
|
|
// }
|
2019-01-28 03:13:04 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
@Watch('itemtodo.enableExpiring') public valueChanged4() {
|
2019-02-27 02:58:41 +01:00
|
|
|
this.watchupdate('enableExpiring')
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
@Watch('itemtodo.expiring_at') public valueChanged2() {
|
2019-02-27 02:58:41 +01:00
|
|
|
this.watchupdate('expiring_at')
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
// @Watch('itemtodo.priority') valueChanged3() {
|
|
|
|
|
// this.watchupdate('priority')
|
|
|
|
|
// }
|
2019-01-28 03:13:04 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
@Watch('itemtodo.descr') public valueChanged5() {
|
2019-01-28 20:39:40 +01:00
|
|
|
this.precDescr = this.itemtodo.descr
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
@Watch('itemtodo.progress') public valueChanged6() {
|
2019-03-13 01:53:53 +01:00
|
|
|
console.log('itemtodo.progress')
|
2019-01-29 00:48:04 +01:00
|
|
|
this.updateClasses()
|
2019-03-13 01:53:53 +01:00
|
|
|
|
|
|
|
|
console.log('this.percentageProgress', this.percentageProgress, 'this.itemtodo.progress', this.itemtodo.progress)
|
2019-03-13 19:35:02 +01:00
|
|
|
this.watchupdate('progress')
|
2019-01-29 00:48:04 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
/*
|
|
|
|
|
public dateToYYYYMMDD(date) {
|
2019-02-11 02:58:53 +01:00
|
|
|
// may have timezone caveats https://stackoverflow.com/a/29774197/1850609
|
|
|
|
|
return date && date.toISOString().split('T')[0]
|
|
|
|
|
}
|
2019-03-11 19:16:39 +01:00
|
|
|
*/
|
2019-02-11 02:58:53 +01:00
|
|
|
|
2019-02-22 10:23:00 +01:00
|
|
|
// Computed:
|
|
|
|
|
get isSel() {
|
|
|
|
|
return this.sel
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public isTodo() {
|
2019-01-28 03:13:04 +01:00
|
|
|
return this.isTodoByElem(this.itemtodo)
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public isTodoByElem(elem) {
|
2019-01-28 03:13:04 +01:00
|
|
|
return elem.descr.slice(-1) !== ':'
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public watchupdate(field = '') {
|
2019-02-27 02:58:41 +01:00
|
|
|
this.$emit('eventupdate', {myitem: this.itemtodo, field } )
|
2019-01-27 19:09:48 +01:00
|
|
|
this.updateicon()
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public updateClasses() {
|
2019-01-27 21:49:10 +01:00
|
|
|
// this.classCompleted = 'completed-item'
|
|
|
|
|
this.classCompleted = 'completed-item-popover'
|
2019-02-20 17:54:48 +01:00
|
|
|
this.classDescr = 'flex-item div_descr show donotdrag'
|
2019-02-20 20:59:18 +01:00
|
|
|
this.classDescrEdit = 'flex-item div_descr_edit donotdrag'
|
2019-02-16 03:49:16 +01:00
|
|
|
if (!this.isTodo()) {
|
2019-01-28 03:13:04 +01:00
|
|
|
this.classDescr += ' titleLista-item'
|
2019-02-16 03:49:16 +01:00
|
|
|
this.classDescrEdit += ' titleLista-item'
|
|
|
|
|
}
|
2019-01-28 03:13:04 +01:00
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
if (this.itemtodo.progress > 100)
|
|
|
|
|
this.itemtodo.progress = 100
|
|
|
|
|
|
2019-02-19 18:44:48 +01:00
|
|
|
this.classExpiring = 'flex-item data-item shadow-1'
|
2019-01-27 19:09:48 +01:00
|
|
|
this.classExpiringEx = ''
|
|
|
|
|
if (this.itemtodo.completed) {
|
2019-01-30 02:01:04 +01:00
|
|
|
this.percentageProgress = 100
|
2019-01-27 19:09:48 +01:00
|
|
|
this.classCompleted += ' icon_completed'
|
|
|
|
|
this.classDescr += ' status_completed'
|
2019-02-16 03:49:16 +01:00
|
|
|
this.classDescrEdit += ' status_completed'
|
2019-01-27 19:09:48 +01:00
|
|
|
this.classExpiring += ' status_completed'
|
|
|
|
|
this.classExpiringEx += ' status_completed'
|
2019-01-30 02:01:04 +01:00
|
|
|
} else {
|
|
|
|
|
this.percentageProgress = this.itemtodo.progress
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-29 00:48:04 +01:00
|
|
|
this.menuProgress = 'menuProgress'
|
|
|
|
|
this.percProgress = 'percProgress'
|
|
|
|
|
|
|
|
|
|
let mycolcl = ''
|
|
|
|
|
if (this.itemtodo.progress < 33) {
|
|
|
|
|
mycolcl = ' lowperc'
|
|
|
|
|
} else if (this.itemtodo.progress < 66) {
|
|
|
|
|
mycolcl = ' medperc'
|
|
|
|
|
} else {
|
|
|
|
|
mycolcl = ' highperc'
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-19 18:44:48 +01:00
|
|
|
if (this.itemtodo.completed) {
|
2019-01-29 03:12:18 +01:00
|
|
|
mycolcl = ' percompleted'
|
2019-02-19 18:44:48 +01:00
|
|
|
}
|
2019-01-29 03:12:18 +01:00
|
|
|
|
2019-01-29 00:48:04 +01:00
|
|
|
this.colProgress = mycolcl
|
|
|
|
|
|
|
|
|
|
this.menuProgress += mycolcl
|
|
|
|
|
this.percProgress += mycolcl
|
|
|
|
|
|
2019-02-15 01:25:44 +01:00
|
|
|
this.clButtPopover = this.sel ? 'pos-item-popover comp_selected' : 'pos-item-popover'
|
|
|
|
|
|
2019-03-04 18:48:07 +01:00
|
|
|
if (!this.itemtodo.completed) {
|
|
|
|
|
this.clButtPopover += ' pos-item-popover_cursor'
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 13:31:41 +01:00
|
|
|
// if (this.inEdit) {
|
|
|
|
|
// this.classDescr += ' hide'
|
|
|
|
|
// this.classDescrEdit += ' show'
|
|
|
|
|
// } else {
|
|
|
|
|
// this.classDescrEdit += ' hide'
|
|
|
|
|
// this.classDescr += ' show'
|
|
|
|
|
// }
|
2019-01-28 03:13:04 +01:00
|
|
|
|
2019-02-01 04:10:31 +01:00
|
|
|
// this.getinputdescr = 'inputdescr' + this.itemtodo._id
|
2019-01-28 03:13:04 +01:00
|
|
|
|
2019-01-28 20:39:40 +01:00
|
|
|
// console.log('classDescrEdit = ', this.classDescrEdit)
|
|
|
|
|
// console.log('classDescr', this.classDescr)
|
2019-01-28 03:13:04 +01:00
|
|
|
|
2019-02-20 11:53:56 +01:00
|
|
|
// console.log('UserStore.state.lang', UserStore.state.lang)
|
2019-03-11 19:16:39 +01:00
|
|
|
if (this.isTodo()) {
|
2019-02-27 02:58:41 +01:00
|
|
|
this.menuPopupTodo = tools.menuPopupTodo[UserStore.state.lang]
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
2019-01-28 03:13:04 +01:00
|
|
|
else {
|
|
|
|
|
this.menuPopupTodo = []
|
2019-02-27 02:58:41 +01:00
|
|
|
this.menuPopupTodo.push(tools.menuPopupTodo[UserStore.state.lang][tools.INDEX_MENU_DELETE])
|
2019-01-28 03:13:04 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public getstrDate(mytimestamp) {
|
|
|
|
|
return date.formatDate(mytimestamp, 'DD-MM-YY')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public created() {
|
2019-01-28 20:39:40 +01:00
|
|
|
this.precDescr = this.itemtodo.descr
|
2019-01-27 19:09:48 +01:00
|
|
|
this.updateicon()
|
|
|
|
|
|
|
|
|
|
this.updateClasses()
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
this.selectPriority = tools.selectPriority[UserStore.state.lang]
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-01-27 21:49:10 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public getClassRow() {
|
2019-01-27 19:09:48 +01:00
|
|
|
return 'row flex-container2 ' + this.classRow
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public clickRiga(clickmenu: boolean = false) {
|
2019-01-28 20:39:40 +01:00
|
|
|
// console.log('CLICK RIGA ************')
|
2019-02-22 10:23:00 +01:00
|
|
|
|
2019-02-16 03:49:16 +01:00
|
|
|
if (!this.sel) {
|
|
|
|
|
if (!this.inEdit) {
|
|
|
|
|
this.$emit('deselectAllRows', this.itemtodo, true)
|
|
|
|
|
|
|
|
|
|
if (!this.sel) {
|
|
|
|
|
this.selectRiga()
|
|
|
|
|
} else {
|
|
|
|
|
this.deselectRiga()
|
|
|
|
|
}
|
2019-01-28 03:13:04 +01:00
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
2019-01-28 03:13:04 +01:00
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public selectRiga() {
|
2019-01-28 20:39:40 +01:00
|
|
|
// console.log('selectRiga', this.itemtodo.descr)
|
2019-01-28 03:13:04 +01:00
|
|
|
this.sel = true
|
2019-01-27 19:09:48 +01:00
|
|
|
this.classRow = 'rowselected'
|
2019-01-28 03:13:04 +01:00
|
|
|
this.updateClasses()
|
2019-01-28 20:39:40 +01:00
|
|
|
// console.log('FINE selectRiga', this.itemtodo.descr)
|
2019-01-28 03:13:04 +01:00
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public deselectRiga() {
|
2019-01-28 20:39:40 +01:00
|
|
|
// console.log('DeselectRiga', this.itemtodo.descr)
|
2019-01-28 03:13:04 +01:00
|
|
|
this.sel = false
|
|
|
|
|
this.classRow = ''
|
|
|
|
|
this.inEdit = false
|
2019-01-27 19:09:48 +01:00
|
|
|
this.updateClasses()
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public deselectAndExitEdit() {
|
2019-01-28 03:13:04 +01:00
|
|
|
this.deselectRiga()
|
|
|
|
|
this.exitEdit()
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public mouseUp() {
|
2019-01-28 03:13:04 +01:00
|
|
|
if (!this.inEdit) {
|
|
|
|
|
if (this.sel) {
|
|
|
|
|
this.selectRiga()
|
|
|
|
|
} else {
|
|
|
|
|
this.deselectRiga()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public clickRow() {
|
2019-02-16 03:49:16 +01:00
|
|
|
this.clickRiga()
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public editTodo() {
|
2019-02-16 03:49:16 +01:00
|
|
|
if (!this.itemtodo.completed) {
|
|
|
|
|
// console.log('INIZIO - editTodo')
|
|
|
|
|
this.$emit('click')
|
|
|
|
|
this.precDescr = this.itemtodo.descr
|
|
|
|
|
this.inEdit = true
|
2019-03-11 19:16:39 +01:00
|
|
|
if (!this.sel) {
|
2019-02-16 03:49:16 +01:00
|
|
|
this.selectRiga()
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2019-02-16 03:49:16 +01:00
|
|
|
this.updateClasses()
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
2019-01-28 03:13:04 +01:00
|
|
|
|
2019-02-16 03:49:16 +01:00
|
|
|
this.faiFocus('inputdescr')
|
|
|
|
|
}
|
2019-01-28 20:39:40 +01:00
|
|
|
// console.log('FINE - editTodo')
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public faiFocus(elem, isparent: boolean = false) {
|
2019-01-28 11:39:02 +01:00
|
|
|
setTimeout(() => {
|
2019-01-28 20:39:40 +01:00
|
|
|
let theField = null
|
2019-03-11 19:16:39 +01:00
|
|
|
if (isparent) {
|
|
|
|
|
theField = this.$parent.$parent.$parent.$parent.$refs[elem] as HTMLInputElement
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
theField = this.$refs[elem] as HTMLInputElement
|
|
|
|
|
}
|
2019-02-19 18:44:48 +01:00
|
|
|
|
2019-03-21 20:43:15 +01:00
|
|
|
if (!!theField) {
|
2019-02-19 18:44:48 +01:00
|
|
|
theField.focus()
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
2019-01-28 20:39:40 +01:00
|
|
|
// console.log('focus()')
|
2019-01-28 13:31:41 +01:00
|
|
|
}, 100)
|
2019-01-28 03:13:04 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public exitEdit(singola: boolean = false) {
|
2019-01-28 03:13:04 +01:00
|
|
|
if (this.inEdit) {
|
2019-03-11 19:16:39 +01:00
|
|
|
if (this.precDescr !== this.itemtodo.descr) {
|
2019-02-04 04:17:50 +01:00
|
|
|
this.updateTodo()
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
2019-01-28 20:39:40 +01:00
|
|
|
// console.log('exitEdit')
|
2019-01-28 03:13:04 +01:00
|
|
|
this.inEdit = false
|
2019-03-22 15:32:32 +01:00
|
|
|
this.updateClasses()
|
2019-01-28 13:31:41 +01:00
|
|
|
this.$emit('deselectAllRows', this.itemtodo, false, singola)
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
2019-01-28 03:13:04 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public keyDownRow(e) {
|
2019-02-16 03:49:16 +01:00
|
|
|
console.log('keyDownRow')
|
|
|
|
|
// Delete Key or Backspage
|
|
|
|
|
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
this.deselectRiga()
|
2019-02-27 02:58:41 +01:00
|
|
|
this.clickMenu(tools.MenuAction.DELETE)
|
2019-02-16 03:49:16 +01:00
|
|
|
.then(() => {
|
|
|
|
|
this.faiFocus('insertTask', true)
|
|
|
|
|
return
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public keyDownArea(e) {
|
2019-02-16 03:49:16 +01:00
|
|
|
console.log('keyDownArea')
|
2019-02-04 04:17:50 +01:00
|
|
|
/*
|
|
|
|
|
if ((e.key === 'ArrowUp') && !e.shiftKey) {
|
|
|
|
|
e.key = 'Tab'
|
|
|
|
|
e.shiftKey = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((e.key === 'ArrowDown') && !e.shiftKey) {
|
|
|
|
|
let nextInput = inputs.get(inputs.index(this) + 1)
|
|
|
|
|
if (nextInput) {
|
|
|
|
|
nextInput.focus()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
2019-02-15 01:25:44 +01:00
|
|
|
// Delete Key or Backspage
|
2019-02-12 19:09:43 +01:00
|
|
|
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
|
|
|
|
|
e.preventDefault()
|
2019-02-14 18:38:23 +01:00
|
|
|
this.deselectRiga()
|
2019-02-27 02:58:41 +01:00
|
|
|
this.clickMenu(tools.MenuAction.DELETE)
|
2019-02-12 19:09:43 +01:00
|
|
|
.then(() => {
|
|
|
|
|
this.faiFocus('insertTask', true)
|
|
|
|
|
return
|
|
|
|
|
})
|
|
|
|
|
}
|
2019-02-04 04:17:50 +01:00
|
|
|
|
|
|
|
|
if (((e.key === 'Enter') || (e.key === 'Tab')) && !e.shiftKey) {
|
2019-01-28 20:39:40 +01:00
|
|
|
this.updateTodo()
|
2019-02-04 04:17:50 +01:00
|
|
|
|
|
|
|
|
if ((e.key === 'Tab') && !e.shiftKey) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
this.deselectRiga()
|
2019-02-19 18:44:48 +01:00
|
|
|
this.faiFocus('insertTask', false)
|
2019-02-04 04:17:50 +01:00
|
|
|
}
|
2019-01-28 20:39:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// console.log('keyDownArea', e)
|
|
|
|
|
if (e.key === 'Escape') {
|
|
|
|
|
this.deselectRiga()
|
2019-02-16 03:49:16 +01:00
|
|
|
// this.faiFocus('insertTask', true)
|
2019-01-28 20:39:40 +01:00
|
|
|
console.log('LOAD this.precDescr', this.precDescr)
|
|
|
|
|
this.precDescr = this.itemtodo.descr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public updateTodo() {
|
|
|
|
|
if (this.itemtodo.descr === this.precDescr) {
|
2019-02-04 04:17:50 +01:00
|
|
|
return
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
2019-02-04 04:17:50 +01:00
|
|
|
|
2019-01-28 20:39:40 +01:00
|
|
|
this.itemtodo.descr = this.precDescr
|
|
|
|
|
console.log('updateTodo', this.precDescr, this.itemtodo.descr)
|
2019-02-12 12:06:01 +01:00
|
|
|
console.log('itemtodo', this.itemtodo)
|
|
|
|
|
console.log('Prec:', this.itemtodoPrec)
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
this.watchupdate('descr')
|
2019-01-28 03:13:04 +01:00
|
|
|
this.inEdit = false
|
2019-01-28 20:39:40 +01:00
|
|
|
// this.precDescr = this.itemtodo.descr
|
2019-01-28 03:13:04 +01:00
|
|
|
this.updateClasses()
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public aggiornaProgress(value, initialval){
|
|
|
|
|
if (value !== initialval) {
|
|
|
|
|
this.itemtodo.progress = value
|
|
|
|
|
this.updatedata('progress')
|
|
|
|
|
this.deselectAndExitEdit()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public setCompleted() {
|
2019-01-16 02:26:43 +01:00
|
|
|
// console.log('setCompleted')
|
|
|
|
|
this.itemtodo.completed = !this.itemtodo.completed
|
|
|
|
|
|
|
|
|
|
this.updateicon()
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
this.updatedata('completed')
|
2019-02-16 03:49:16 +01:00
|
|
|
|
|
|
|
|
this.deselectAndExitEdit()
|
2019-01-16 02:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public updatedata(field: string) {
|
2019-02-27 02:58:41 +01:00
|
|
|
// const myitem = tools.jsonCopy(this.itemtodo)
|
|
|
|
|
console.log('calling this.$emit(eventupdate)', this.itemtodo)
|
|
|
|
|
this.$emit('eventupdate', { myitem: this.itemtodo, field } )
|
2019-01-16 02:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public updateicon() {
|
2019-01-31 13:52:52 +01:00
|
|
|
// console.log('updateicon')
|
2019-03-11 19:16:39 +01:00
|
|
|
if (this.itemtodo.completed) {
|
2019-01-16 02:26:43 +01:00
|
|
|
this.iconCompleted = 'check_circle'
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2019-01-16 02:26:43 +01:00
|
|
|
this.iconCompleted = 'check_circle_outline'
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
if (this.itemtodo.priority === tools.Todos.PRIORITY_HIGH) {
|
|
|
|
|
this.iconPriority = 'expand_less'
|
|
|
|
|
} // expand_less
|
|
|
|
|
else if (this.itemtodo.priority === tools.Todos.PRIORITY_NORMAL) {
|
2019-01-16 02:26:43 +01:00
|
|
|
this.iconPriority = 'remove'
|
2019-03-11 19:16:39 +01:00
|
|
|
}
|
|
|
|
|
else if (this.itemtodo.priority === tools.Todos.PRIORITY_LOW) {
|
|
|
|
|
this.iconPriority = 'expand_more'
|
|
|
|
|
} // expand_more
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-01-28 03:13:04 +01:00
|
|
|
this.updateClasses()
|
2019-01-16 02:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public removeitem(id) {
|
2019-02-27 02:58:41 +01:00
|
|
|
this.$emit('deleteItem', id)
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public enableExpiring() {
|
2019-01-28 03:13:04 +01:00
|
|
|
this.itemtodo.enableExpiring = !this.itemtodo.enableExpiring
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public async clickMenu(action) {
|
2019-01-27 19:09:48 +01:00
|
|
|
console.log('click menu: ', action)
|
2019-02-27 02:58:41 +01:00
|
|
|
if (action === tools.MenuAction.DELETE) {
|
2019-02-14 18:38:23 +01:00
|
|
|
return await this.askConfirmDelete()
|
2019-02-27 02:58:41 +01:00
|
|
|
} else if (action === tools.MenuAction.TOGGLE_EXPIRING) {
|
2019-02-14 18:38:23 +01:00
|
|
|
return await this.enableExpiring()
|
2019-02-27 02:58:41 +01:00
|
|
|
} else if (action === tools.MenuAction.COMPLETED) {
|
2019-02-14 18:38:23 +01:00
|
|
|
return await this.setCompleted()
|
2019-02-27 02:58:41 +01:00
|
|
|
} else if (action === tools.MenuAction.PROGRESS_BAR) {
|
|
|
|
|
return await this.updatedata('progress')
|
2019-02-19 18:44:48 +01:00
|
|
|
} else if (action === 0) {
|
|
|
|
|
this.deselectAndExitEdit()
|
2019-01-28 03:13:04 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public setPriority(newpriority) {
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
if (this.itemtodo.priority !== newpriority) {
|
|
|
|
|
this.itemtodo.priority = newpriority
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
this.updatedata('priority')
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
this.updateicon()
|
|
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-01-16 02:26:43 +01:00
|
|
|
}
|
2019-01-29 00:48:04 +01:00
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
public async askConfirmDelete() {
|
2019-01-29 23:13:28 +01:00
|
|
|
const deletestr = this.$t('dialog.delete')
|
|
|
|
|
const cancelstr = this.$t('dialog.cancel')
|
|
|
|
|
|
2019-03-11 19:16:39 +01:00
|
|
|
const msg = this.$t('dialog.msg.deleteTask', {mytodo : this.itemtodo.descr })
|
2019-01-29 23:13:28 +01:00
|
|
|
|
2019-03-22 01:00:41 +01:00
|
|
|
this.$q.dialog({
|
|
|
|
|
cancel: {
|
|
|
|
|
label: cancelstr
|
|
|
|
|
},
|
|
|
|
|
message: msg,
|
|
|
|
|
ok: {
|
|
|
|
|
label: deletestr,
|
|
|
|
|
push: true
|
|
|
|
|
},
|
|
|
|
|
title: this.$t('dialog.msg.titledeleteTask')
|
|
|
|
|
}).onOk(() => {
|
|
|
|
|
console.log('OK')
|
|
|
|
|
this.removeitem(this.itemtodo._id)
|
|
|
|
|
}).onCancel(() => {
|
|
|
|
|
console.log('CANCEL')
|
2019-01-29 23:13:28 +01:00
|
|
|
})
|
2019-03-22 01:00:41 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// return await askConfirm(this.$q, this.$t('dialog.msg.titledeleteTask'), msg, deletestr, cancelstr)
|
|
|
|
|
.then((ris) => {
|
|
|
|
|
console.log('ris', ris)
|
|
|
|
|
if (ris) {
|
|
|
|
|
this.removeitem(this.itemtodo._id)
|
|
|
|
|
}
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
*/
|
2019-01-29 23:13:28 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|