2019-01-14 22:40:30 +01:00
|
|
|
import Vue from 'vue'
|
2019-02-01 04:10:31 +01:00
|
|
|
import { Component, Watch } from 'vue-property-decorator'
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-03-22 15:32:32 +01:00
|
|
|
import { ICfgServer, IDrag, IGlobalState, ITodo, ITodosState } from '../../model/index'
|
|
|
|
|
import { SingleTodo } from '../../components/todos/SingleTodo/index'
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-03-22 15:32:32 +01:00
|
|
|
import { tools } from '../../store/Modules/tools'
|
|
|
|
|
import * as ApiTables from '../../store/Modules/ApiTables'
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-03-04 17:28:29 +01:00
|
|
|
import { GlobalStore, Todos } from '@store'
|
2019-01-31 13:52:52 +01:00
|
|
|
import { UserStore } from '@store'
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-02-20 11:53:56 +01:00
|
|
|
// _.cloneDeep( Per clonare un oggetto
|
2019-02-02 20:13:06 +01:00
|
|
|
|
2019-03-22 15:32:32 +01:00
|
|
|
import { costanti } from '../../store/Modules/costanti'
|
2019-03-13 01:53:53 +01:00
|
|
|
import { Getter, Mutation, State } from 'vuex-class'
|
2019-02-27 02:58:41 +01:00
|
|
|
const namespace: string = 'Todos'
|
2019-02-19 18:44:48 +01:00
|
|
|
|
2019-03-22 15:32:32 +01:00
|
|
|
import globalroutines from '../../globalroutines/index'
|
2019-03-04 18:48:07 +01:00
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
@Component({
|
2019-01-29 03:12:18 +01:00
|
|
|
|
2019-03-04 17:28:29 +01:00
|
|
|
components: { SingleTodo },
|
|
|
|
|
filters: {
|
2019-03-13 01:53:53 +01:00
|
|
|
capitalize(value) {
|
|
|
|
|
if (!value) { return '' }
|
2019-03-04 17:28:29 +01:00
|
|
|
value = value.toString()
|
|
|
|
|
return value.charAt(0).toUpperCase() + value.slice(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-14 22:40:30 +01:00
|
|
|
})
|
|
|
|
|
export default class Todo extends Vue {
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
get showtype() {
|
2019-03-04 17:28:29 +01:00
|
|
|
return Todos.state.showtype
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
set showtype(value) {
|
2019-03-05 23:44:48 +01:00
|
|
|
console.log('showtype', value)
|
2019-03-04 17:28:29 +01:00
|
|
|
GlobalStore.mutations.setShowType(value)
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
get doneTodosCount() {
|
|
|
|
|
return Todos.getters.doneTodosCount(this.categoryAtt)
|
2019-02-03 14:40:20 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-04 17:28:29 +01:00
|
|
|
get menuPopupConfigTodo() {
|
|
|
|
|
return tools.menuPopupConfigTodo[UserStore.state.lang]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get listOptionShowTask() {
|
|
|
|
|
return tools.listOptionShowTask[UserStore.state.lang]
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
get TodosCount() {
|
|
|
|
|
return Todos.getters.TodosCount(this.categoryAtt)
|
2019-02-14 18:38:23 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
get todos_vista() {
|
2019-02-14 18:38:23 +01:00
|
|
|
let mystr = ''
|
2019-02-27 02:58:41 +01:00
|
|
|
const arr = Todos.getters.todos_dacompletare(this.categoryAtt)
|
2019-03-13 01:53:53 +01:00
|
|
|
for (const ind in arr) {
|
2019-02-27 02:58:41 +01:00
|
|
|
mystr += this.getstrelem(arr[ind]) + '\n'
|
|
|
|
|
}
|
2019-02-14 18:38:23 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
return mystr + ''
|
2019-02-14 18:38:23 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
// get mytodos_dacompletare() {
|
|
|
|
|
// return todos_dacompletare(this.categoryAtt)
|
|
|
|
|
// }
|
2019-02-14 18:38:23 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
// @Watch('$route', { immediate: true, deep: true })
|
|
|
|
|
// onUrlChange(newVal: any) {
|
|
|
|
|
// // Some action
|
|
|
|
|
// }
|
2019-02-03 02:40:24 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
// Computed:
|
|
|
|
|
get reload_fromServer() {
|
|
|
|
|
return Todos.state.reload_fromServer
|
2019-01-29 03:12:18 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
set reload_fromServer(value: number) {
|
|
|
|
|
Todos.state.reload_fromServer = value
|
2019-01-16 02:26:43 +01:00
|
|
|
}
|
2019-03-13 01:53:53 +01:00
|
|
|
public $q: any
|
|
|
|
|
public filter: boolean = false
|
|
|
|
|
public title: string = ''
|
|
|
|
|
public todotop: string = ''
|
|
|
|
|
public todobottom: string = ''
|
|
|
|
|
public drag: boolean = true
|
|
|
|
|
public startpos: number = 0
|
|
|
|
|
public listPriorityLabel: number[] = []
|
|
|
|
|
public arrPrior: number[] = []
|
|
|
|
|
public itemDragStart: any = null
|
|
|
|
|
public polling = null
|
|
|
|
|
public loadDone: boolean = false
|
|
|
|
|
public inddragging: number = -1
|
|
|
|
|
public service: any
|
|
|
|
|
public actualMaxPosition: number = 15
|
|
|
|
|
public scrollable = true
|
|
|
|
|
public tmpstrTodos: string = ''
|
|
|
|
|
public categoryAtt: string = ''
|
|
|
|
|
// public showtype: number = Todos.state.showtype
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public $refs: {
|
|
|
|
|
single: SingleTodo[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Getter('todos_dacompletare', { namespace })
|
|
|
|
|
public todos_dacompletare: (state: ITodosState, category: string) => ITodo[]
|
|
|
|
|
|
|
|
|
|
@Getter('todos_completati', { namespace })
|
|
|
|
|
public todos_completati: (state: ITodosState, category: string) => ITodo[]
|
|
|
|
|
|
|
|
|
|
@Watch('$route.params.category') public changecat() {
|
|
|
|
|
this.categoryAtt = this.$route.params.category
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// clickaggshowtype () {
|
|
|
|
|
// console.log('1B) clickaggshowtype Todos.state.showtype=', Todos.state.showtype)
|
|
|
|
|
// Todos.state.showtype = costanti.ShowTypeTask.SHOW_ALL
|
|
|
|
|
// console.log('2B) Dopo: showtype=', this.showtype)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public loadval(e) {
|
|
|
|
|
console.log('1) loadval, showtype=', this.showtype)
|
|
|
|
|
this.showtype = Todos.state.showtype
|
|
|
|
|
console.log('2) Dopo: showtype=', this.showtype)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getmyid(id) {
|
2019-01-27 19:09:48 +01:00
|
|
|
return 'row' + id
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public showTask(field_value) {
|
2019-03-04 17:28:29 +01:00
|
|
|
return field_value === tools.MenuAction.SHOW_TASK
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public onStart() {
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-01-16 02:26:43 +01:00
|
|
|
this.startpos = 0
|
2019-01-27 19:09:48 +01:00
|
|
|
this.itemDragStart = null
|
2019-01-16 02:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public logelem(mystr, elem) {
|
2019-02-27 02:58:41 +01:00
|
|
|
console.log(mystr, 'elem [', elem._id, '] ', elem.descr, ' Pr(', this.getPriorityByInd(elem.priority), ') [', elem.id_prev, '] modif=', elem.modified)
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
2019-01-16 02:26:43 +01:00
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public getstrelem(elem) {
|
2019-02-27 02:58:41 +01:00
|
|
|
return 'elem [' + elem._id + '] ' + elem.descr + ' Pr(' + this.getPriorityByInd(elem.priority) + ') [ID_PREV=' + elem.id_prev + '] modif=' + elem.modified + ' '
|
2019-01-27 21:49:10 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public getTitlePriority(priority) {
|
2019-01-27 21:49:10 +01:00
|
|
|
let cl = ''
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
if (priority === tools.Todos.PRIORITY_HIGH) {
|
2019-01-27 21:49:10 +01:00
|
|
|
cl = 'high_priority'
|
2019-03-13 01:53:53 +01:00
|
|
|
}
|
|
|
|
|
else if (priority === tools.Todos.PRIORITY_NORMAL) {
|
2019-01-27 21:49:10 +01:00
|
|
|
cl = 'medium_priority'
|
2019-03-13 01:53:53 +01:00
|
|
|
}
|
|
|
|
|
else if (priority === tools.Todos.PRIORITY_LOW) {
|
2019-01-27 21:49:10 +01:00
|
|
|
cl = 'low_priority'
|
2019-03-13 01:53:53 +01:00
|
|
|
}
|
2019-01-27 21:49:10 +01:00
|
|
|
|
|
|
|
|
return cl + ' titlePriority'
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public logga_arr(myarr: ITodo[]) {
|
2019-02-20 19:17:29 +01:00
|
|
|
let mystr = '\n'
|
2019-03-13 01:53:53 +01:00
|
|
|
myarr.forEach((item) => {
|
2019-02-27 02:58:41 +01:00
|
|
|
mystr += '[' + item.pos + '] ' + item.descr + ' Pr(' + this.getPriorityByInd(item.priority) + ') [' + item.id_prev + '] modif=' + item.modified + '\n'
|
2019-02-20 19:17:29 +01:00
|
|
|
// mystr += '[' + item.pos + '] ' + item.descr + '\n'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return mystr
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public async onEnd(itemdragend) {
|
2019-02-27 02:58:41 +01:00
|
|
|
console.log('************ END DRAG: ', itemdragend)
|
|
|
|
|
this.inddragging = -1
|
2019-02-20 19:17:29 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
await Todos.actions.swapElems(itemdragend)
|
2019-01-16 02:26:43 +01:00
|
|
|
|
|
|
|
|
}
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public created() {
|
2019-02-20 11:53:56 +01:00
|
|
|
const $service = this.$dragula.$service
|
2019-02-20 17:54:48 +01:00
|
|
|
$service.options('first',
|
|
|
|
|
{
|
2019-02-20 19:17:29 +01:00
|
|
|
// isContainer: function (el) {
|
|
|
|
|
// return el.classList.contains('dragula-container')
|
|
|
|
|
// },
|
2019-03-13 01:53:53 +01:00
|
|
|
moves(el, source, handle, sibling) {
|
2019-02-20 19:17:29 +01:00
|
|
|
// console.log('moves')
|
2019-02-20 17:54:48 +01:00
|
|
|
return !el.classList.contains('donotdrag') // elements are always draggable by default
|
|
|
|
|
},
|
2019-03-13 01:53:53 +01:00
|
|
|
accepts(el, target, source, sibling) {
|
2019-03-22 15:32:32 +01:00
|
|
|
console.log('accepts dragging '+ el.id + ' from ' + source.id + ' to ' + target.id)
|
2019-02-20 17:54:48 +01:00
|
|
|
return true // elements can be dropped in any of the `containers` by default
|
|
|
|
|
},
|
2019-03-13 01:53:53 +01:00
|
|
|
invalid(el, handle) {
|
2019-02-20 19:17:29 +01:00
|
|
|
// console.log('invalid')
|
2019-02-20 17:54:48 +01:00
|
|
|
return el.classList.contains('donotdrag') // don't prevent any drags from initiating by default
|
|
|
|
|
},
|
|
|
|
|
direction: 'vertical'
|
|
|
|
|
})
|
2019-02-20 11:53:56 +01:00
|
|
|
$service.eventBus.$on('dragend', (args) => {
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
const itemdragend: IDrag = {
|
2019-02-27 02:58:41 +01:00
|
|
|
category: this.categoryAtt,
|
2019-02-20 11:53:56 +01:00
|
|
|
newIndex: this.getElementIndex(args.el),
|
|
|
|
|
oldIndex: this.getElementOldIndex(args.el)
|
|
|
|
|
}
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-02-20 11:53:56 +01:00
|
|
|
this.onEnd(itemdragend)
|
|
|
|
|
})
|
|
|
|
|
|
2019-03-08 02:04:56 +01:00
|
|
|
$service.eventBus.$on('drag', (el, source) => {
|
2019-02-27 02:58:41 +01:00
|
|
|
// mythis.inddragging = mythis.getElementIndex(el)
|
2019-03-08 02:04:56 +01:00
|
|
|
console.log('+++ DRAG ind=', this.inddragging)
|
|
|
|
|
this.scrollable = false
|
2019-02-20 20:59:18 +01:00
|
|
|
})
|
2019-03-08 02:04:56 +01:00
|
|
|
$service.eventBus.$on('drop', (el, source) => {
|
2019-02-20 20:59:18 +01:00
|
|
|
console.log('+++ DROP')
|
2019-03-08 02:04:56 +01:00
|
|
|
this.scrollable = true
|
2019-02-20 20:59:18 +01:00
|
|
|
})
|
|
|
|
|
|
2019-02-20 11:53:56 +01:00
|
|
|
this.load()
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public mounted() {
|
2019-02-27 02:58:41 +01:00
|
|
|
// console.log('*** MOUNTED ***')
|
|
|
|
|
|
|
|
|
|
this.categoryAtt = this.$route.params.category
|
2019-02-20 20:59:18 +01:00
|
|
|
|
|
|
|
|
if (window) {
|
2019-03-08 02:04:56 +01:00
|
|
|
window.addEventListener('touchmove', (e) => {
|
2019-02-22 10:23:00 +01:00
|
|
|
// console.log('touchmove')
|
2019-03-08 02:04:56 +01:00
|
|
|
if (!this.scrollable) {
|
2019-02-20 20:59:18 +01:00
|
|
|
e.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
}, { passive: false })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public setarrPriority() {
|
2019-01-27 19:09:48 +01:00
|
|
|
this.arrPrior = []
|
2019-02-27 02:58:41 +01:00
|
|
|
const arr = tools.selectPriority[UserStore.state.lang]
|
2019-02-16 02:01:17 +01:00
|
|
|
if (arr) {
|
2019-03-13 01:53:53 +01:00
|
|
|
arr.forEach((rec) => {
|
2019-02-16 02:01:17 +01:00
|
|
|
this.arrPrior.push(rec.value)
|
|
|
|
|
})
|
|
|
|
|
}
|
2019-01-31 13:52:52 +01:00
|
|
|
// console.log('Array PRIOR:', this.arrPrior)
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public async load() {
|
2019-03-04 17:28:29 +01:00
|
|
|
console.log('LOAD TODO....')
|
2019-02-27 02:58:41 +01:00
|
|
|
this.categoryAtt = this.$route.params.category
|
2019-02-03 02:40:24 +01:00
|
|
|
|
2019-01-30 01:05:31 +01:00
|
|
|
// Set last category selected
|
2019-02-27 02:58:41 +01:00
|
|
|
localStorage.setItem(tools.localStorage.categorySel, this.categoryAtt)
|
2019-01-30 01:05:31 +01:00
|
|
|
|
2019-03-22 15:32:32 +01:00
|
|
|
for (const todosKey in ApiTables.Priority) {
|
|
|
|
|
this.listPriorityLabel.push(ApiTables.Priority[todosKey])
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
2019-01-31 13:52:52 +01:00
|
|
|
// console.log('Priority:' + this.listPriorityLabel)
|
2019-01-27 19:09:48 +01:00
|
|
|
this.setarrPriority()
|
|
|
|
|
|
2019-02-14 20:08:22 +01:00
|
|
|
this.loadDone = true
|
2019-02-04 04:17:50 +01:00
|
|
|
|
|
|
|
|
this.checkUpdate_everytime()
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-04 04:17:50 +01:00
|
|
|
// Call to check if need to refresh
|
2019-03-13 01:53:53 +01:00
|
|
|
public checkUpdate_everytime() {
|
2019-02-04 04:17:50 +01:00
|
|
|
this.polling = setInterval(() => {
|
|
|
|
|
this.checkUpdate()
|
2019-02-22 10:23:00 +01:00
|
|
|
}, 60000)
|
2019-02-04 04:17:50 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public beforeDestroy() {
|
2019-02-27 02:58:41 +01:00
|
|
|
clearInterval(this.polling)
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public getPriorityByInd(index) {
|
2019-02-16 02:01:17 +01:00
|
|
|
// console.log('LANG in PRIOR', UserStore.state.lang)
|
|
|
|
|
try {
|
2019-02-27 02:58:41 +01:00
|
|
|
const arr = tools.selectPriority[UserStore.state.lang]
|
2019-03-13 01:53:53 +01:00
|
|
|
for (const rec of arr) {
|
|
|
|
|
if (rec.value === index) {
|
2019-02-16 02:01:17 +01:00
|
|
|
return rec.label
|
2019-03-13 01:53:53 +01:00
|
|
|
}
|
2019-02-16 02:01:17 +01:00
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
|
|
|
|
return ''
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public isRegistered() {
|
2019-02-27 02:58:41 +01:00
|
|
|
return localStorage.getItem(tools.localStorage.userId) !== ''
|
2019-02-07 00:53:10 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public mydeleteItem(idobj: string) {
|
2019-03-22 01:00:41 +01:00
|
|
|
// console.log('mydeleteItem', idobj)
|
2019-02-27 02:58:41 +01:00
|
|
|
return Todos.actions.deleteItem({ cat: this.categoryAtt, idobj })
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public insertTodo(atfirst: boolean = false) {
|
2019-02-20 17:54:48 +01:00
|
|
|
let descr = this.todobottom.trim()
|
2019-03-13 01:53:53 +01:00
|
|
|
if (atfirst) {
|
2019-02-20 17:54:48 +01:00
|
|
|
descr = this.todotop.trim()
|
2019-03-13 01:53:53 +01:00
|
|
|
}
|
2019-02-20 17:54:48 +01:00
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
if (descr === '') {
|
2019-01-28 03:13:04 +01:00
|
|
|
return
|
2019-03-13 01:53:53 +01:00
|
|
|
}
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
if (UserStore.state.userId === undefined) {
|
2019-03-13 13:40:17 +01:00
|
|
|
tools.showNotif(this.$q, this.$t('todo.usernotdefined'))
|
2019-02-07 00:53:10 +01:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
if (!this.isRegistered()) {
|
|
|
|
|
// Not logged
|
2019-03-13 13:40:17 +01:00
|
|
|
tools.showNotif(this.$q, this.$t('user.notregistered'))
|
2019-01-31 13:52:52 +01:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
const myobj: ITodo = {
|
|
|
|
|
descr,
|
2019-02-27 02:58:41 +01:00
|
|
|
category: this.categoryAtt
|
2019-02-09 18:04:49 +01:00
|
|
|
}
|
2019-02-03 19:28:06 +01:00
|
|
|
|
2019-03-22 15:32:32 +01:00
|
|
|
// empty the field
|
|
|
|
|
if (atfirst) {
|
|
|
|
|
this.todotop = ''
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.todobottom = ''
|
|
|
|
|
}
|
2019-02-02 20:13:06 +01:00
|
|
|
|
2019-03-22 15:32:32 +01:00
|
|
|
return Todos.actions.insertTodo({ myobj, atfirst })
|
2019-02-02 20:13:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public async updateitem({ myitem, field }) {
|
2019-02-27 02:58:41 +01:00
|
|
|
console.log('calling MODIFY updateitem', myitem, field)
|
|
|
|
|
// Update the others components...
|
2019-02-02 20:13:06 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
const itemdragend: IDrag = {
|
|
|
|
|
category: this.categoryAtt,
|
|
|
|
|
field,
|
|
|
|
|
idelemtochange: myitem._id,
|
|
|
|
|
prioritychosen: myitem.priority,
|
|
|
|
|
atfirst: false
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
await Todos.actions.swapElems(itemdragend)
|
2019-01-27 19:09:48 +01:00
|
|
|
|
2019-02-27 02:58:41 +01:00
|
|
|
await Todos.actions.modify({ myitem, field })
|
2019-02-22 10:23:00 +01:00
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public deselectAllRows(item: ITodo, check, onlythis: boolean = false) {
|
2019-01-31 13:52:52 +01:00
|
|
|
// console.log('deselectAllRows : ', item)
|
2019-01-27 19:09:48 +01:00
|
|
|
|
|
|
|
|
for (let i = 0; i < this.$refs.single.length; i++) {
|
2019-01-14 22:40:30 +01:00
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
const contr = this.$refs.single[i] as SingleTodo
|
2019-01-28 03:13:04 +01:00
|
|
|
// @ts-ignore
|
2019-03-13 01:53:53 +01:00
|
|
|
const id = contr.itemtodo._id
|
2019-01-28 03:13:04 +01:00
|
|
|
// Don't deselect the actual clicked!
|
2019-01-28 13:31:41 +01:00
|
|
|
let des = false
|
|
|
|
|
if (onlythis) {
|
2019-02-01 04:10:31 +01:00
|
|
|
des = item._id === id
|
|
|
|
|
} else {
|
|
|
|
|
des = ((check && (item._id !== id)) || (!check))
|
2019-01-28 13:31:41 +01:00
|
|
|
}
|
|
|
|
|
if (des) {
|
2019-01-28 03:13:04 +01:00
|
|
|
// @ts-ignore
|
|
|
|
|
contr.deselectAndExitEdit()
|
|
|
|
|
}
|
2019-01-27 19:09:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public checkUpdate() {
|
2019-03-22 15:32:32 +01:00
|
|
|
ApiTables.waitAndcheckPendingMsg()
|
2019-02-04 03:09:15 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public loadMoreTodo(index, done) {
|
2019-02-20 17:54:48 +01:00
|
|
|
setTimeout(() => {
|
|
|
|
|
this.actualMaxPosition += 15
|
|
|
|
|
done()
|
|
|
|
|
}, 100)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
public getArrTodos() {
|
2019-03-04 18:48:07 +01:00
|
|
|
|
|
|
|
|
let mystr = ''
|
|
|
|
|
|
2019-03-08 02:04:56 +01:00
|
|
|
this.tmpstrTodos = ''
|
2019-03-04 18:48:07 +01:00
|
|
|
return globalroutines(null, 'readall', 'todos', null)
|
2019-03-08 02:04:56 +01:00
|
|
|
.then((alldata) => {
|
2019-03-04 18:48:07 +01:00
|
|
|
const myrecs = [...alldata]
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
myrecs.forEach((rec) => {
|
2019-03-04 18:48:07 +01:00
|
|
|
mystr = mystr + rec.descr + rec.completed + '] ['
|
|
|
|
|
})
|
|
|
|
|
|
2019-03-08 02:04:56 +01:00
|
|
|
this.tmpstrTodos = 'TODOS: ' + mystr
|
2019-03-04 18:48:07 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 01:53:53 +01:00
|
|
|
private getElementIndex(el: any) {
|
|
|
|
|
return [].slice.call(el.parentElement.children).indexOf(el)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private getElementOldIndex(el: any) {
|
|
|
|
|
return parseInt(el.attributes.index.value, 10)
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-04 18:48:07 +01:00
|
|
|
// setArrTodos() {
|
|
|
|
|
//
|
|
|
|
|
// let mystr = ''
|
|
|
|
|
// let mythis = this
|
|
|
|
|
//
|
|
|
|
|
// mythis.tmpstrTodos = ''
|
|
|
|
|
// return globalroutines(null, 'write', 'todos', this.todos_arr[0])
|
|
|
|
|
// .then(function (alldata) {
|
|
|
|
|
// mythis.getArrTodos()
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
|
2019-01-14 22:40:30 +01:00
|
|
|
}
|