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