fix Delete and Insert Todo... (after changed function find, findIndex...)
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
"normalize.css": "^8.0.0",
|
||||
"npm": "^6.9.0",
|
||||
"nprogress": "^0.2.0",
|
||||
"quasar": "^1.0.0-beta.10",
|
||||
"quasar": "^1.0.0-beta.11",
|
||||
"quasar-extras": "^2.0.8",
|
||||
"register-service-worker": "^1.0.0",
|
||||
"vee-validate": "^2.1.2",
|
||||
|
||||
@@ -174,6 +174,7 @@ module.exports = function (ctx) {
|
||||
],
|
||||
directives: [
|
||||
'Ripple',
|
||||
'ClosePopup'
|
||||
],
|
||||
// Quasar plugins
|
||||
plugins: [
|
||||
|
||||
@@ -10,9 +10,11 @@ export async function askConfirm($q: any, mytitle, mytext, ok, cancel) {
|
||||
push: true
|
||||
},
|
||||
title: mytitle
|
||||
}).then((ris) => {
|
||||
return ris
|
||||
}).catch(() => {
|
||||
}).onOk(() => {
|
||||
console.log('OK')
|
||||
return true
|
||||
}).onCancel(() => {
|
||||
console.log('CANCEL')
|
||||
return false
|
||||
})
|
||||
} catch (e) {
|
||||
|
||||
@@ -458,15 +458,35 @@ export default class SingleTodo extends Vue {
|
||||
const cancelstr = this.$t('dialog.cancel')
|
||||
|
||||
const msg = this.$t('dialog.msg.deleteTask', {mytodo : this.itemtodo.descr })
|
||||
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) => {
|
||||
|
||||
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')
|
||||
})
|
||||
|
||||
/*
|
||||
// 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) => {
|
||||
|
||||
})
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<q-list separator no-border class="todo-menu">
|
||||
<div v-for="field in menuPopupTodo" :key="field.value">
|
||||
<q-item clickable v-if="(field.value !== 130) && (field.value !== 100)" :icon="field.icon"
|
||||
@click.native="clickMenu(field.value)">
|
||||
<q-item v-close-popup clickable v-if="(field.value !== 130) && (field.value !== 120)" :icon="field.icon"
|
||||
@click="clickMenu(field.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="field.icon"/>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section v-if="field.value !== 120" label class="item-menu">
|
||||
<q-item-section label class="item-menu">
|
||||
<q-item-label>{{field.label}}</q-item-label>
|
||||
</q-item-section>
|
||||
|
||||
@@ -17,9 +17,14 @@
|
||||
<q-item-section side v-if="field.value === 110">
|
||||
<q-checkbox v-model="itemtodo.completed"/>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-if="(field.value === 120)" :icon="field.icon"
|
||||
@click="clickMenu(field.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="field.icon"/>
|
||||
</q-item-section>
|
||||
|
||||
|
||||
<q-item-section v-if="field.value === 120">
|
||||
<q-item-section>
|
||||
<q-slider label
|
||||
:class="$parent.menuProgress"
|
||||
v-model="itemtodo.progress"
|
||||
@@ -29,21 +34,12 @@
|
||||
/>
|
||||
|
||||
</q-item-section>
|
||||
<q-item-section side v-if="field.value === 120">
|
||||
<q-item-section side>
|
||||
<div>
|
||||
<q-item-label style="color: blue">{{itemtodo.progress}} %</q-item-label>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-if="(field.value === 100)" :icon="field.icon"
|
||||
@click.native="clickMenu(field.value)">
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="field.icon" inverted color="primary"/>
|
||||
</q-item-section>
|
||||
<q-item-section class="item-menu">
|
||||
{{field.label}}
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-if="(field.value === 130)">
|
||||
<q-item-section avatar>
|
||||
<q-icon name="priority_high" inverted color="primary"/>
|
||||
|
||||
@@ -306,7 +306,7 @@ export default class Todo extends Vue {
|
||||
}
|
||||
|
||||
public mydeleteItem(idobj: string) {
|
||||
console.log('mydeleteItem', idobj)
|
||||
// console.log('mydeleteItem', idobj)
|
||||
return Todos.actions.deleteItem({ cat: this.categoryAtt, idobj })
|
||||
}
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ function getIndexById(cat, id) {
|
||||
return myarr.findIndex((elem) => elem._id === id)
|
||||
}
|
||||
|
||||
function getElemPrevById(cat, id_prev) {
|
||||
function getElemPrevById(cat, id) {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
return myarr.find((elem) => elem._id === id_prev)
|
||||
return myarr.find((elem) => elem.id_prev === id)
|
||||
}
|
||||
|
||||
function getLastFirstElemPriority(cat: string, priority: number, atfirst: boolean, escludiId: string) {
|
||||
@@ -230,10 +230,10 @@ namespace Getters {
|
||||
|
||||
namespace Mutations {
|
||||
|
||||
function findTodoById(state: ITodosState, data: IParamTodo) {
|
||||
function findIndTodoById(state: ITodosState, data: IParamTodo) {
|
||||
const indcat = state.categories.indexOf(data.categorySel)
|
||||
if (indcat >= 0) {
|
||||
return state.todos[indcat].find((elem) => elem._id === data.id)
|
||||
return state.todos[indcat].findIndex((elem) => elem._id === data.id)
|
||||
}
|
||||
|
||||
return -1
|
||||
@@ -266,7 +266,7 @@ namespace Mutations {
|
||||
function deletemyitem(state: ITodosState, myitem: ITodo) {
|
||||
// Find record
|
||||
const indcat = state.categories.indexOf(myitem.category)
|
||||
const ind = findTodoById(state, { id: myitem._id, categorySel: myitem.category })
|
||||
const ind = findIndTodoById(state, { id: myitem._id, categorySel: myitem.category })
|
||||
|
||||
console.log('PRIMA state.todos', state.todos)
|
||||
// Delete Item in to Array
|
||||
@@ -373,19 +373,23 @@ namespace Actions {
|
||||
|
||||
async function deleteItem(context, { cat, idobj }) {
|
||||
console.log('deleteItem: KEY = ', idobj)
|
||||
|
||||
const myobjtrov = getElemById(cat, idobj)
|
||||
|
||||
console.log('myobjtrov', myobjtrov.descr)
|
||||
|
||||
if (!!myobjtrov) {
|
||||
const myobjnext = getElemPrevById(cat, myobjtrov._id)
|
||||
|
||||
if (!!myobjnext) {
|
||||
// console.log('myobjnext', myobjnext.descr)
|
||||
myobjnext.id_prev = myobjtrov.id_prev
|
||||
myobjnext.modified = true
|
||||
console.log('calling MODIFY 1')
|
||||
// console.log('calling MODIFY 1 id_prev = ', myobjnext.id_prev)
|
||||
await modify(context, { myitem: myobjnext, field: 'id_prev' })
|
||||
}
|
||||
|
||||
// console.log(' MODIFY 2')
|
||||
|
||||
// 1) Delete from the Todos Array
|
||||
Todos.mutations.deletemyitem(myobjtrov)
|
||||
|
||||
@@ -424,7 +428,7 @@ namespace Actions {
|
||||
|
||||
console.log('lastelem', lastelem)
|
||||
|
||||
objtodo.id_prev = (lastelem !== null) ? lastelem._id : tools.LIST_START
|
||||
objtodo.id_prev = (!!lastelem) ? lastelem._id : tools.LIST_START
|
||||
// objtodo.pos = (elemtochange !== null) ? elemtochange.pos + 1 : 1
|
||||
}
|
||||
console.log('elemtochange TORNATO:', elemtochange)
|
||||
@@ -441,7 +445,7 @@ namespace Actions {
|
||||
let field = ''
|
||||
// update also the last elem
|
||||
if (atfirst) {
|
||||
if (elemtochange !== null) {
|
||||
if (!!elemtochange) {
|
||||
elemtochange.id_prev = id
|
||||
console.log('elemtochange', elemtochange)
|
||||
field = 'id_prev'
|
||||
@@ -518,12 +522,12 @@ namespace Actions {
|
||||
miorec.completed_at = new Date().getDate()
|
||||
}
|
||||
|
||||
fieldtochange.forEach((field) => {
|
||||
setmodifiedIfchanged(miorec, myobjsaved, field)
|
||||
fieldtochange.forEach((myfield) => {
|
||||
setmodifiedIfchanged(miorec, myobjsaved, myfield)
|
||||
})
|
||||
|
||||
if (miorec.modified) {
|
||||
// console.log('Todo MODIFICATO! ', miorec.descr, miorec.pos, 'SALVALO SULLA IndexedDB todos')
|
||||
console.log('Todo MODIFICATO! ', miorec.descr, miorec.pos, 'SALVALO SULLA IndexedDB todos')
|
||||
miorec.modify_at = new Date().getDate()
|
||||
miorec.modified = false
|
||||
|
||||
|
||||
@@ -67,5 +67,5 @@
|
||||
"dist",
|
||||
"node_modules"
|
||||
],
|
||||
"compileOnSave": false
|
||||
"compileOnSave": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user