- Update the way to use the data records on Vuex with Getters!

- Fix: mongodb call passing array todos and categiroes already splitted
This commit is contained in:
Paolo Arena
2019-02-27 02:58:41 +01:00
parent 0e98ac1eaa
commit fa17de24f0
60 changed files with 3133 additions and 1839 deletions

View File

@@ -1,7 +1,7 @@
import Vue from 'vue'
import { Component, Prop, Watch } from 'vue-property-decorator'
import { rescodes } from '../../../store/Modules/rescodes'
import { tools } from '../../../store/Modules/tools'
import { UserStore } from '@modules'
import { ITodo } from '../../../model/index'
@@ -48,21 +48,21 @@ export default class SingleTodo extends Vue {
@Prop({ required: true }) itemtodo: ITodo
@Watch('itemtodo.completed') valueChanged() {
this.watchupdate()
}
// @Watch('itemtodo.completed') valueChanged() {
// this.watchupdate('completed')
// }
@Watch('itemtodo.enableExpiring') valueChanged4() {
this.watchupdate()
this.watchupdate('enableExpiring')
}
@Watch('itemtodo.expiring_at') valueChanged2() {
this.watchupdate()
this.watchupdate('expiring_at')
}
@Watch('itemtodo.priority') valueChanged3() {
this.watchupdate()
}
// @Watch('itemtodo.priority') valueChanged3() {
// this.watchupdate('priority')
// }
@Watch('itemtodo.descr') valueChanged5() {
@@ -91,8 +91,8 @@ export default class SingleTodo extends Vue {
return elem.descr.slice(-1) !== ':'
}
watchupdate() {
this.$emit('eventupdate', this.itemtodo)
watchupdate(field = '') {
this.$emit('eventupdate', {myitem: this.itemtodo, field } )
this.updateicon()
}
@@ -158,10 +158,10 @@ export default class SingleTodo extends Vue {
// console.log('UserStore.state.lang', UserStore.state.lang)
if (this.isTodo())
this.menuPopupTodo = rescodes.menuPopupTodo[UserStore.state.lang]
this.menuPopupTodo = tools.menuPopupTodo[UserStore.state.lang]
else {
this.menuPopupTodo = []
this.menuPopupTodo.push(rescodes.menuPopupTodo[UserStore.state.lang][rescodes.INDEX_MENU_DELETE])
this.menuPopupTodo.push(tools.menuPopupTodo[UserStore.state.lang][tools.INDEX_MENU_DELETE])
}
}
@@ -172,7 +172,7 @@ export default class SingleTodo extends Vue {
this.updateClasses()
this.selectPriority = rescodes.selectPriority[UserStore.state.lang]
this.selectPriority = tools.selectPriority[UserStore.state.lang]
}
@@ -283,7 +283,7 @@ export default class SingleTodo extends Vue {
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
e.preventDefault()
this.deselectRiga()
this.clickMenu(rescodes.MenuAction.DELETE)
this.clickMenu(tools.MenuAction.DELETE)
.then(() => {
this.faiFocus('insertTask', true)
return
@@ -311,7 +311,7 @@ export default class SingleTodo extends Vue {
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
e.preventDefault()
this.deselectRiga()
this.clickMenu(rescodes.MenuAction.DELETE)
this.clickMenu(tools.MenuAction.DELETE)
.then(() => {
this.faiFocus('insertTask', true)
return
@@ -349,7 +349,7 @@ export default class SingleTodo extends Vue {
console.log('itemtodo', this.itemtodo)
console.log('Prec:', this.itemtodoPrec)
this.watchupdate()
this.watchupdate('descr')
this.inEdit = false
// this.precDescr = this.itemtodo.descr
this.updateClasses()
@@ -361,15 +361,15 @@ export default class SingleTodo extends Vue {
this.updateicon()
this.updatedata()
this.updatedata('completed')
this.deselectAndExitEdit()
}
updatedata() {
const myitem = rescodes.jsonCopy(this.itemtodo)
console.log('calling this.$emit(eventupdate)', myitem)
this.$emit('eventupdate', myitem)
updatedata(field: string) {
// const myitem = tools.jsonCopy(this.itemtodo)
console.log('calling this.$emit(eventupdate)', this.itemtodo)
this.$emit('eventupdate', { myitem: this.itemtodo, field } )
}
updateicon() {
@@ -380,11 +380,11 @@ export default class SingleTodo extends Vue {
this.iconCompleted = 'check_circle_outline'
if (this.itemtodo.priority === rescodes.Todos.PRIORITY_HIGH)
if (this.itemtodo.priority === tools.Todos.PRIORITY_HIGH)
this.iconPriority = 'expand_less' // expand_less
else if (this.itemtodo.priority === rescodes.Todos.PRIORITY_NORMAL)
else if (this.itemtodo.priority === tools.Todos.PRIORITY_NORMAL)
this.iconPriority = 'remove'
else if (this.itemtodo.priority === rescodes.Todos.PRIORITY_LOW)
else if (this.itemtodo.priority === tools.Todos.PRIORITY_LOW)
this.iconPriority = 'expand_more' // expand_more
this.updateClasses()
@@ -392,7 +392,7 @@ export default class SingleTodo extends Vue {
removeitem(id) {
this.$emit('deleteitem', id)
this.$emit('deleteItem', id)
}
enableExpiring() {
@@ -402,14 +402,14 @@ export default class SingleTodo extends Vue {
async clickMenu(action) {
console.log('click menu: ', action)
if (action === rescodes.MenuAction.DELETE) {
if (action === tools.MenuAction.DELETE) {
return await this.askConfirmDelete()
} else if (action === rescodes.MenuAction.TOGGLE_EXPIRING) {
} else if (action === tools.MenuAction.TOGGLE_EXPIRING) {
return await this.enableExpiring()
} else if (action === rescodes.MenuAction.COMPLETED) {
} else if (action === tools.MenuAction.COMPLETED) {
return await this.setCompleted()
} else if (action === rescodes.MenuAction.PROGRESS_BAR) {
return await this.updatedata()
} else if (action === tools.MenuAction.PROGRESS_BAR) {
return await this.updatedata('progress')
} else if (action === 0) {
this.deselectAndExitEdit()
}
@@ -418,11 +418,13 @@ export default class SingleTodo extends Vue {
setPriority(newpriority) {
this.itemtodo.priority = newpriority
if (this.itemtodo.priority !== newpriority) {
this.itemtodo.priority = newpriority
this.updatedata()
this.updatedata('priority')
this.updateicon()
this.updateicon()
}
// this.$q.notify('setPriority: ' + elem)
}

View File

@@ -83,9 +83,6 @@
<!--<div class="flex-item btn-item">-->
<!--<q-btn class="mybtn" round color="" icon="delete" @click.native="removeitem(itemtodo._id)"></q-btn>-->
<!--</div>-->
<!--<div class="flex-item">-->
<!--[{{ itemtodo.id_prev}} - {{ itemtodo.id_next}}]-->
<!--</div>-->
</div>
</template>

View File

@@ -2,7 +2,7 @@ import Vue from 'vue'
import { Component, Prop } from 'vue-property-decorator'
import { ITodo } from '../../../model/index'
import { rescodes } from '@src/store/Modules/rescodes'
import { tools } from '@src/store/Modules/tools'
import { UserStore } from '@store'
// Doesn't exist in quasar this ? error TS2305
@@ -16,7 +16,7 @@ import { UserStore } from '@store'
})
export default class SubMenus extends Vue {
public selectPriority: [] = rescodes.selectPriority[UserStore.state.lang]
public selectPriority: [] = tools.selectPriority[UserStore.state.lang]
@Prop({ required: false }) menuPopupTodo: any[]
@Prop({ required: false }) itemtodo: ITodo
@@ -47,7 +47,7 @@ export default class SubMenus extends Vue {
}
create () {
this.selectPriority = rescodes.selectPriority[UserStore.state.lang]
this.selectPriority = tools.selectPriority[UserStore.state.lang]
console.log('CREAZIONE')
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
<p class="caption"></p>
<div class="divtitlecat">
<div class="categorytitle">{{ getCategory() }}</div>
<div class="categorytitle">{{ categoryAtt }}</div>
</div>
<q-input ref="insertTask" v-model="todotop" inverted :float-label="$t('todo.inserttop')"
@@ -19,21 +19,17 @@
<!--<div :id="getmyid(mytodo._id)" v-for="(mytodo, index) in todos_arr" :key="mytodo._id" class="myitemdrag"-->
<!--draggable="true" @dragstart="dragStart(index, $event)" @dragover.prevent @dragenter="dragEnter(index)"-->
<!--@dragleave="dragLeave(index)" @dragend="dragEnd" @drop="dragFinish(index, $event)" >-->
<q-infinite-scroll :handler="loadMoreTodo" :offset="7">
<div class="container" v-dragula="todos_arr" drake="first" :key="compKey3">
<div :id="getmyid(mytodo._id)" :index="index" v-for="(mytodo, index) in showingDataTodo"
<!--<q-infinite-scroll :handler="loadMoreTodo" :offset="7">-->
<div class="container" v-dragula="todos_dacompletare(categoryAtt)" drake="first">
<div :id="getmyid(mytodo._id)" :index="index" v-for="(mytodo, index) in todos_dacompletare(categoryAtt)"
:key="mytodo._id" class="myitemdrag">
<div v-if="(prior !== mytodo.priority) && !mytodo.completed"
:class="getTitlePriority(mytodo.priority)" :key="compKey1">
:class="getTitlePriority(mytodo.priority)">
<label>{{getPriorityByInd(mytodo.priority)}}</label>
</div>
<div v-if="(!priorcomplet && mytodo.completed)" class="titleCompleted" :key="compKey2">
<label>{{$t('todo.completed')}}</label>
<div style="display: none">{{ priorcomplet = true }}</div>
</div>
<SingleTodo ref="single" @deleteitem="deleteitem" @eventupdate="updateitem"
<SingleTodo ref="single" @deleteItem="mydeleteItem" @eventupdate="updateitem"
@deselectAllRows="deselectAllRows" @onEnd="onEnd"
:itemtodo='mytodo'/>
@@ -43,19 +39,40 @@
</div>
</div>
</div>
</q-infinite-scroll>
<!--</q-infinite-scroll>-->
<div v-if="doneTodosCount > 0" class="titleCompleted">
<label>{{$t('todo.completed')}}</label>
</div>
<!--<q-infinite-scroll :handler="loadMoreTodo" :offset="7">-->
<div class="container" v-dragula="todos_completati(categoryAtt)" drake="second">
<div :id="getmyid(mytodo._id)" :index="index" v-for="(mytodo, index) in todos_completati(categoryAtt)"
:key="mytodo._id" class="myitemdrag">
<SingleTodo ref="single" @deleteItem="deleteItem(mytodo._id)" @eventupdate="updateitem"
@deselectAllRows="deselectAllRows" @onEnd="onEnd"
:itemtodo='mytodo'/>
<!--<div :name="`REF${index}`" class="divdrag non-draggato"></div>-->
<div style="display: none">{{ prior = mytodo.priority, priorcomplet = mytodo.completed }}
</div>
</div>
</div>
<!--</q-infinite-scroll>-->
<!--</transition-group>-->
<!--</draggable>-->
</div>
<q-input v-if="todos_arr.length > 0" ref="insertTaskBottom" v-model="todobottom" inverted :float-label="$t('todo.insertbottom')"
<q-input v-if="TodosCount > 0" ref="insertTaskBottom" v-model="todobottom" inverted :float-label="$t('todo.insertbottom')"
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
v-on:keyup.enter="insertTodo(false)"/>
<!--{{ tmpstrTodos }}-->
<!--<br>-->
<br>
<!--&lt;!&ndash;-->
<!--&lt;!&ndash;<div class="flex-item btn-item">&ndash;&gt;-->
<!--<q-btn class="mybtn" round color="" icon="lock" @click="getArrTodos">Get Todo</q-btn>-->
<!--<q-btn class="mybtn" round color="" icon="person" @click="setArrTodos">Set Todo</q-btn>-->
@@ -72,7 +89,10 @@
<!--<q-btn class="mybtn" round color="" icon="person" @click="clicktest2()"></q-btn>-->
<!--<q-btn class="mybtn" round color="" icon="list" @click="checkUpdate()"></q-btn>-->
<!--</div>-->
<!--&ndash;&gt;-->
<!--<span style="white-space: pre;">{{ todos_vista }}</span>-->
</div>
</q-page>