From f60edc1c5b6f958f7d2719f3ee2cf8e802daeeba Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Sat, 6 Apr 2019 21:52:27 +0200 Subject: [PATCH] Updated Project calculation for hours and progress. --- .../projects/SingleProject/SingleProject.ts | 16 ++++------- src/components/todos/CTodo/CTodo.vue | 6 ++-- src/components/todos/SingleTodo/SingleTodo.ts | 28 +++++++++---------- .../todos/SingleTodo/SingleTodo.vue | 4 +-- src/components/todos/SubMenus/SubMenus.vue | 2 +- src/model/Projects.ts | 2 +- src/model/Todos.ts | 2 +- src/store/Modules/Projects.ts | 4 +-- src/store/Modules/Todos.ts | 10 +++---- src/views/projects/proj-list/proj-list.ts | 2 +- src/views/projects/proj-list/proj-list.vue | 16 +++++------ 11 files changed, 42 insertions(+), 50 deletions(-) diff --git a/src/components/projects/SingleProject/SingleProject.ts b/src/components/projects/SingleProject/SingleProject.ts index 14a93ee..7e1a827 100644 --- a/src/components/projects/SingleProject/SingleProject.ts +++ b/src/components/projects/SingleProject/SingleProject.ts @@ -43,10 +43,6 @@ export default class SingleProject extends Vue { @Prop({ required: true }) public itemproject: IProject - // @Watch('itemproject.completed') valueChanged() { - // this.watchupdate('status') - // } - @Watch('itemproject.enableExpiring') public valueChanged4() { this.watchupdate('enableExpiring') } @@ -108,7 +104,7 @@ export default class SingleProject extends Vue { } public watchupdate(field = '') { - console.log('watchupdate', field) + console.log('watchupdate PROJ', field) this.$emit('eventupdateproj', {myitem: this.itemproject, field } ) this.updateicon() } @@ -138,7 +134,7 @@ export default class SingleProject extends Vue { this.clButtPopover = this.sel ? 'pos-item-popover comp_selected' : 'pos-item-popover' - if (this.itemproject.status !== tools.Status.COMPLETED) { + if (this.itemproject.statusproj !== tools.Status.COMPLETED) { this.clButtPopover += ' pos-item-popover_cursor' } @@ -386,16 +382,14 @@ export default class SingleProject extends Vue { public setCompleted() { // console.log('setCompleted') - if (this.itemproject.status === tools.Status.COMPLETED) { - this.itemproject.status = tools.Status.OPENED + if (this.itemproject.statusproj === tools.Status.COMPLETED) { + this.itemproject.statusproj = tools.Status.OPENED } else { - this.itemproject.status = tools.Status.COMPLETED + this.itemproject.statusproj = tools.Status.COMPLETED } this.updateicon() - this.updatedata('status') - this.deselectAndExitEdit() } diff --git a/src/components/todos/CTodo/CTodo.vue b/src/components/todos/CTodo/CTodo.vue index 8d6bdc5..d2f3974 100644 --- a/src/components/todos/CTodo/CTodo.vue +++ b/src/components/todos/CTodo/CTodo.vue @@ -69,7 +69,7 @@ v-for="(mytodo, index) in items_dacompletare(categoryAtt)" :key="mytodo._id" class="myitemdrag"> -
@@ -79,7 +79,7 @@ -
{{ prior = mytodo.priority, priorcomplet = (mytodo.status === tools.Status.COMPLETED) }} +
{{ prior = mytodo.priority, priorcomplet = (mytodo.statustodo === tools.Status.COMPLETED) }}
@@ -101,7 +101,7 @@ -
{{ prior = mytodo.priority, priorcomplet = (mytodo.status === tools.Status.COMPLETED) }} +
{{ prior = mytodo.priority, priorcomplet = (mytodo.statustodo === tools.Status.COMPLETED) }}
diff --git a/src/components/todos/SingleTodo/SingleTodo.ts b/src/components/todos/SingleTodo/SingleTodo.ts index 53aa785..a6d9f2a 100644 --- a/src/components/todos/SingleTodo/SingleTodo.ts +++ b/src/components/todos/SingleTodo/SingleTodo.ts @@ -49,10 +49,6 @@ export default class SingleTodo extends Vue { @Prop({ required: true }) public itemtodo: ITodo - // @Watch('itemtodo.completed') valueChanged() { - // this.watchupdate('status') - // } - @Watch('itemtodo.enableExpiring') public valueChanged4() { this.watchupdate('enableExpiring') } @@ -74,9 +70,10 @@ export default class SingleTodo extends Vue { console.log('itemtodo.hoursplanned', this.itemtodo.hoursplanned) this.watchupdate('hoursplanned') } - @Watch('itemtodo.status') public valueChangedstatus() { - console.log('itemtodo.status', this.itemtodo.status) - this.watchupdate('status') + // ++TODO: FIX! STATUSTODO WILL NOT UPDATE IF I DON'T PUT { immediate: true } parameter. ! WHY??? + @Watch('itemtodo.statustodo', {immediate: true}) public valueChangedstatus() { + console.log('itemtodo.statustodo', this.itemtodo.statustodo) + this.watchupdate('statustodo') } @Watch('itemtodo.completed_at') public valueChangedcompleted_at() { console.log('itemtodo.completed_at', this.itemtodo.completed_at) @@ -145,7 +142,7 @@ export default class SingleTodo extends Vue { this.classExpiring = 'flex-item data-item shadow-1 hide-if-small' this.classExpiringEx = '' - if (this.itemtodo.status === tools.Status.COMPLETED) { + if (this.itemtodo.statustodo === tools.Status.COMPLETED) { this.percentageProgress = 100 this.classCompleted += ' icon_completed' this.classDescr += ' status_completed' @@ -162,7 +159,7 @@ export default class SingleTodo extends Vue { let mycolcl = ' ' + tools.getProgressClassColor(this.itemtodo.progress) this.colProgress = tools.getProgressColor(this.itemtodo.progress) - if (this.itemtodo.status === tools.Status.COMPLETED) { + if (this.itemtodo.statustodo === tools.Status.COMPLETED) { mycolcl = ' percompleted' this.colProgress = 'gray' } @@ -174,7 +171,7 @@ export default class SingleTodo extends Vue { this.clButtPopover = this.sel ? 'pos-item-popover comp_selected' : 'pos-item-popover' - if (this.itemtodo.status !== tools.Status.COMPLETED) { + if (this.itemtodo.statustodo !== tools.Status.COMPLETED) { this.clButtPopover += ' pos-item-popover_cursor' } @@ -271,7 +268,7 @@ export default class SingleTodo extends Vue { } public editTodo() { - if (this.itemtodo.status !== tools.Status.COMPLETED) { + if (this.itemtodo.statustodo !== tools.Status.COMPLETED) { // console.log('INIZIO - editTodo') this.$emit('click') this.precDescr = this.itemtodo.descr @@ -407,11 +404,12 @@ export default class SingleTodo extends Vue { public setCompleted() { // console.log('setCompleted') - if (this.itemtodo.status === tools.Status.COMPLETED) { - this.itemtodo.status = tools.Status.OPENED + if (this.itemtodo.statustodo === tools.Status.COMPLETED) { + this.itemtodo.statustodo = tools.Status.OPENED } else { - this.itemtodo.status = tools.Status.COMPLETED + this.itemtodo.statustodo = tools.Status.COMPLETED } + this.watchupdate('statustodo') this.deselectAndExitEdit() } @@ -424,7 +422,7 @@ export default class SingleTodo extends Vue { public updateicon() { // console.log('updateicon') - if (this.itemtodo.status === tools.Status.COMPLETED) { + if (this.itemtodo.statustodo === tools.Status.COMPLETED) { this.iconCompleted = 'check_circle' } else { diff --git a/src/components/todos/SingleTodo/SingleTodo.vue b/src/components/todos/SingleTodo/SingleTodo.vue index efde4f5..791e735 100644 --- a/src/components/todos/SingleTodo/SingleTodo.vue +++ b/src/components/todos/SingleTodo/SingleTodo.vue @@ -4,12 +4,12 @@ + @click="setCompleted">
- - + ('Projects', stateglob) const stateGetter = b.state() @@ -50,7 +50,7 @@ namespace Getters { longdescr: '', id_parent: '', priority: tools.Priority.PRIORITY_NORMAL, - status: tools.Status.OPENED, + statusproj: tools.Status.OPENED, created_at: tools.getDateNow(), modify_at: tools.getDateNow(), completed_at: tools.getDateNull(), diff --git a/src/store/Modules/Todos.ts b/src/store/Modules/Todos.ts index 64d7f27..a4d97cc 100644 --- a/src/store/Modules/Todos.ts +++ b/src/store/Modules/Todos.ts @@ -27,7 +27,7 @@ const state: ITodosState = { visuLastCompleted: 10 } -const listFieldsToChange: string [] = ['descr', 'status', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progress', 'phase', 'assigned_to_userId', 'hoursplanned', 'hoursworked', 'start_date', 'completed_at'] +const listFieldsToChange: string [] = ['descr', 'statustodo', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progress', 'phase', 'assigned_to_userId', 'hoursplanned', 'hoursworked', 'start_date', 'completed_at'] const b = storeBuilder.module('Todos', state) const stateGetter = b.state() @@ -65,7 +65,7 @@ namespace Getters { userId: UserStore.state.userId, descr: '', priority: tools.Priority.PRIORITY_NORMAL, - status: tools.Status.OPENED, + statustodo: tools.Status.OPENED, created_at: tools.getDateNow(), modify_at: tools.getDateNow(), completed_at: tools.getDateNull(), @@ -89,7 +89,7 @@ namespace Getters { const items_dacompletare = b.read((state: ITodosState) => (cat: string): ITodo[] => { const indcat = getindexbycategory(cat) if (state.todos[indcat]) { - return state.todos[indcat].filter((todo) => todo.status !== tools.Status.COMPLETED) + return state.todos[indcat].filter((todo) => todo.statustodo !== tools.Status.COMPLETED) } else { return [] } @@ -99,13 +99,13 @@ namespace Getters { const indcat = getindexbycategory(cat) if (state.todos[indcat]) { if (state.showtype === costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED) { // Show only the first N completed - return state.todos[indcat].filter((todo) => todo.status === tools.Status.COMPLETED).slice(0, state.visuLastCompleted) + return state.todos[indcat].filter((todo) => todo.statustodo === tools.Status.COMPLETED).slice(0, state.visuLastCompleted) } else if (state.showtype === costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE) { return [] } else if (state.showtype === costanti.ShowTypeTask.SHOW_ALL) { - return state.todos[indcat].filter((todo) => todo.status === tools.Status.COMPLETED) + return state.todos[indcat].filter((todo) => todo.statustodo === tools.Status.COMPLETED) } else { return [] diff --git a/src/views/projects/proj-list/proj-list.ts b/src/views/projects/proj-list/proj-list.ts index 31d95b9..44307ba 100644 --- a/src/views/projects/proj-list/proj-list.ts +++ b/src/views/projects/proj-list/proj-list.ts @@ -64,7 +64,7 @@ export default class ProjList extends Vue { } public watchupdatetodo(field = '') { - console.log('watchupdate', field) + console.log('watchupdatetodo', field) this.$emit('eventupdate', {myitem: this.itemtodosel, field } ) } diff --git a/src/views/projects/proj-list/proj-list.vue b/src/views/projects/proj-list/proj-list.vue index e2c546e..dcf0b53 100644 --- a/src/views/projects/proj-list/proj-list.vue +++ b/src/views/projects/proj-list/proj-list.vue @@ -131,7 +131,7 @@
- + @input="watchupdatetodo('statustodo')">
@@ -209,7 +209,7 @@
-