From fe600f40a6a1a7e9836c66a194720bfff09d259e Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Wed, 3 Apr 2019 02:48:05 +0200 Subject: [PATCH] Added and linked todo list to the project list --- src/components/CDate/CDate.scss | 40 +++++++ src/components/CDate/CDate.ts | 39 +++++++ src/components/CDate/CDate.vue | 19 +++ src/components/CDate/index.ts | 1 + src/components/CProgress/CProgress.scss | 1 + src/components/CProgress/CProgress.vue | 24 ++-- src/components/index.ts | 1 + .../projects/SingleProject/SingleProject.ts | 9 +- .../todos/CTodo/CTodo.scss} | 0 .../todos/CTodo/CTodo.ts} | 53 +++++---- .../todos/CTodo/CTodo.vue} | 16 +-- src/components/todos/CTodo/index.ts | 1 + src/components/todos/SingleTodo/SingleTodo.ts | 7 ++ src/components/todos/index.ts | 2 +- src/model/GlobalStore.ts | 1 + src/router/route-config.ts | 2 +- src/store/Modules/GlobalStore.ts | 9 +- src/store/Modules/Projects.ts | 5 +- src/store/Modules/Todos.ts | 65 ++++++----- src/store/Modules/tools.ts | 15 ++- .../TableData.scss} | 0 .../tabledata.ts => TableData/TableData.ts} | 57 +++++---- .../tabledata.vue => TableData/TableData.vue} | 4 +- src/views/categories/TableData/index.ts | 1 + src/views/categories/index.ts | 6 +- src/views/categories/tabledata/index.ts | 1 - src/views/projects/proj-list/proj-list.scss | 8 +- src/views/projects/proj-list/proj-list.ts | 54 +++++++-- src/views/projects/proj-list/proj-list.vue | 52 +++++---- src/views/todo-list/index.ts | 1 + src/views/todo-list/todo-list.scss | 110 ++++++++++++++++++ src/views/todo-list/todo-list.ts | 29 +++++ src/views/todo-list/todo-list.vue | 12 ++ src/views/todo/index.ts | 1 - 34 files changed, 493 insertions(+), 153 deletions(-) create mode 100644 src/components/CDate/CDate.scss create mode 100644 src/components/CDate/CDate.ts create mode 100644 src/components/CDate/CDate.vue create mode 100644 src/components/CDate/index.ts rename src/{views/todo/todo.scss => components/todos/CTodo/CTodo.scss} (100%) rename src/{views/todo/todo.ts => components/todos/CTodo/CTodo.ts} (79%) rename src/{views/todo/todo.vue => components/todos/CTodo/CTodo.vue} (90%) create mode 100644 src/components/todos/CTodo/index.ts rename src/views/categories/{tabledata/tabledata.scss => TableData/TableData.scss} (100%) rename src/views/categories/{tabledata/tabledata.ts => TableData/TableData.ts} (77%) rename src/views/categories/{tabledata/tabledata.vue => TableData/TableData.vue} (97%) create mode 100644 src/views/categories/TableData/index.ts delete mode 100644 src/views/categories/tabledata/index.ts create mode 100644 src/views/todo-list/index.ts create mode 100644 src/views/todo-list/todo-list.scss create mode 100644 src/views/todo-list/todo-list.ts create mode 100644 src/views/todo-list/todo-list.vue delete mode 100644 src/views/todo/index.ts diff --git a/src/components/CDate/CDate.scss b/src/components/CDate/CDate.scss new file mode 100644 index 0000000..477fd3d --- /dev/null +++ b/src/components/CDate/CDate.scss @@ -0,0 +1,40 @@ +$heightBtn: 100%; + +.flex-item{ + // background-color: #d5e2eb; + display: flex; + padding: 2px; + margin: 2px; + margin-left: 3px; + margin-right: 3px; + color: #000; + font-size: 1rem; + height: $heightBtn; + line-height: $heightBtn; + vertical-align: middle; + //flex: 0 0 100%; +} + +.progress-item { + margin: 1px; + padding: 2px; + padding-top: 4px; + padding-bottom: 4px; + flex: 1; + flex-direction: column; + order: 1; +} + +.cpr-progrbar-item { + //height: 10px + padding-top: 7px; + height:15px; +} + +.cpr-percProgress { + padding-top: 3px; + color: #888; + vertical-align: middle; + text-align: center; + //line-height: $heightitem; +} diff --git a/src/components/CDate/CDate.ts b/src/components/CDate/CDate.ts new file mode 100644 index 0000000..2617d17 --- /dev/null +++ b/src/components/CDate/CDate.ts @@ -0,0 +1,39 @@ +import Vue from 'vue' +import { Component, Emit, Inject, Model, Prop, Provide } from 'vue-property-decorator' +import { tools } from '@src/store/Modules/tools' +import * as moment from 'moment' + +@Component({ + name: 'CDate' +}) + +export default class CDate extends Vue { + // ************* IS NOT WORKING WELL ! ************ + // @Model('input', { + // default: '' + // }) + // public mydate!: Date + @Prop() public myhint: string + @Model('input', { + default: '1999/01/01' + }) + public mydate!: string + + private valueInternal: string = '1988/01/01' + + @Emit('input') + public onValueChanged(value: string) { + this.valueInternal = value + } + + // get getmydate() { + // console.log('getmydate', this.mydate) + // return tools.getstrDate(this.mydate) + // } + // + // public updatedate(mydate) { + // console.log('updatedate', mydate) + // this.mydate = mydate + // } + +} diff --git a/src/components/CDate/CDate.vue b/src/components/CDate/CDate.vue new file mode 100644 index 0000000..a036d35 --- /dev/null +++ b/src/components/CDate/CDate.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/src/components/CDate/index.ts b/src/components/CDate/index.ts new file mode 100644 index 0000000..45ece4a --- /dev/null +++ b/src/components/CDate/index.ts @@ -0,0 +1 @@ +export {default as CDate} from './CDate.vue' diff --git a/src/components/CProgress/CProgress.scss b/src/components/CProgress/CProgress.scss index 8dde2c1..477fd3d 100644 --- a/src/components/CProgress/CProgress.scss +++ b/src/components/CProgress/CProgress.scss @@ -2,6 +2,7 @@ $heightBtn: 100%; .flex-item{ // background-color: #d5e2eb; + display: flex; padding: 2px; margin: 2px; margin-left: 3px; diff --git a/src/components/CProgress/CProgress.vue b/src/components/CProgress/CProgress.vue index 4cf89f4..004c9b3 100644 --- a/src/components/CProgress/CProgress.vue +++ b/src/components/CProgress/CProgress.vue @@ -1,15 +1,17 @@ diff --git a/src/components/index.ts b/src/components/index.ts index 456faf1..79bfc95 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -2,3 +2,4 @@ export * from '../views/categories' export * from './todos' export * from './logo' export * from './CProgress' +export * from './CDate' diff --git a/src/components/projects/SingleProject/SingleProject.ts b/src/components/projects/SingleProject/SingleProject.ts index 80585d5..ad27402 100644 --- a/src/components/projects/SingleProject/SingleProject.ts +++ b/src/components/projects/SingleProject/SingleProject.ts @@ -36,6 +36,10 @@ export default class SingleProject extends Vue { public $q: any + get tools() { + return tools + } + @Prop({ required: true }) public itemproject: IProject // @Watch('itemproject.completed') valueChanged() { @@ -103,6 +107,7 @@ export default class SingleProject extends Vue { } public watchupdate(field = '') { + console.log('watchupdate') this.$emit('eventupdateproj', {myitem: this.itemproject, field } ) this.updateicon() } @@ -172,6 +177,7 @@ export default class SingleProject extends Vue { if (!this.sel) { if (!this.inEdit) { // this.attivaEdit = true + this.$emit('deselectAllRowstodo', null, false) this.$emit('deselectAllRowsproj', this.itemproject, true) if (!this.sel) { @@ -283,6 +289,7 @@ export default class SingleProject extends Vue { this.inEdit = false this.attivaEdit = false this.updateClasses() + this.$emit('deselectAllRowstodo', null, false, false) this.$emit('deselectAllRowsproj', this.itemproject, false, singola) } } @@ -414,7 +421,7 @@ export default class SingleProject extends Vue { } public removeitem(id) { - this.$emit('deleteItem', id) + this.$emit('deleteItemproj', id) } public enableExpiring() { diff --git a/src/views/todo/todo.scss b/src/components/todos/CTodo/CTodo.scss similarity index 100% rename from src/views/todo/todo.scss rename to src/components/todos/CTodo/CTodo.scss diff --git a/src/views/todo/todo.ts b/src/components/todos/CTodo/CTodo.ts similarity index 79% rename from src/views/todo/todo.ts rename to src/components/todos/CTodo/CTodo.ts index 342f8fa..c953579 100644 --- a/src/views/todo/todo.ts +++ b/src/components/todos/CTodo/CTodo.ts @@ -1,42 +1,43 @@ import Vue from 'vue' -import { Component, Watch } from 'vue-property-decorator' +import { Component, Prop, Watch } from 'vue-property-decorator' -import { IDrag, ITodo, ITodosState } from '../../model/index' -import { SingleTodo } from '../../components/todos/SingleTodo/index' +import { IDrag, IProject, ITodo, ITodosState } from '../../../model/index' -import { tools } from '../../store/Modules/tools' -import * as ApiTables from '../../store/Modules/ApiTables' +import { tools } from '../../../store/Modules/tools' +import * as ApiTables from '../../../store/Modules/ApiTables' import { GlobalStore, Todos } from '@store' import { UserStore } from '@store' import { Getter } from 'vuex-class' +import { SingleTodo } from '../SingleTodo' + const namespace: string = 'Todos' @Component({ - components: { SingleTodo }, filters: { capitalize(value) { - if (!value) { - return '' - } - value = value.toString() - return value.charAt(0).toUpperCase() + value.slice(1) + return tools.capitalize(value) } } }) -export default class Todo extends Vue { +export default class CTodo extends Vue { public $q: any public todotop: string = '' public todobottom: string = '' public polling = null public service: any public scrollable = true - public categoryAtt: string = '' public dragname: string = 'first' + @Prop({ required: true }) public categoryAtt: string + @Prop({ required: true }) public title: string + @Prop({ required: false, default: 'blue' }) public forecolor: string + @Prop({ required: false, default: 'lightblue' }) public backcolor: string + @Prop({ required: false, default: true }) public viewtaskTop: boolean + public $refs: { single: SingleTodo[] } @@ -76,11 +77,6 @@ export default class Todo extends Vue { @Getter('todos_completati', { namespace }) public todos_completati: (state: ITodosState, category: string) => ITodo[] - @Watch('$route.params.category') - public changecat() { - this.categoryAtt = this.$route.params.category - } - public showTask(field_value) { return field_value === tools.MenuAction.SHOW_TASK } @@ -115,14 +111,11 @@ export default class Todo extends Vue { } public mounted() { - this.categoryAtt = this.$route.params.category - tools.touchmove(this.scrollable) } - public async load() { + public load() { console.log('LOAD TODO....') - this.categoryAtt = this.$route.params.category // Set last category selected localStorage.setItem(tools.localStorage.categorySel, this.categoryAtt) @@ -193,8 +186,16 @@ export default class Todo extends Vue { } + public deselectAllRowsproj(item: IProject, check, onlythis: boolean = false) { + this.$emit('deselectAllRowsproj', item, check, onlythis) + } + + public setitemsel(item: ITodo) { + this.$emit('setitemsel', item) + } + public deselectAllRowstodo(item: ITodo, check, onlythis: boolean = false) { - // console.log('deselectAllRowstodo : ', item) + console.log('CTODO deselectAllRowstodo : ', item) for (let i = 0; i < this.$refs.single.length; i++) { @@ -206,7 +207,11 @@ export default class Todo extends Vue { if (onlythis) { des = item._id === id } else { - des = ((check && (item._id !== id)) || (!check)) + if (!!check) { + des = ((check && (item._id !== id)) || (!check)) + } else { + des = !check + } } if (des) { // @ts-ignore diff --git a/src/views/todo/todo.vue b/src/components/todos/CTodo/CTodo.vue similarity index 90% rename from src/views/todo/todo.vue rename to src/components/todos/CTodo/CTodo.vue index 0450d69..535429e 100644 --- a/src/views/todo/todo.vue +++ b/src/components/todos/CTodo/CTodo.vue @@ -1,9 +1,9 @@ - diff --git a/src/views/categories/TableData/index.ts b/src/views/categories/TableData/index.ts new file mode 100644 index 0000000..20bd0fe --- /dev/null +++ b/src/views/categories/TableData/index.ts @@ -0,0 +1 @@ +export {default as TableData} from './TableData.vue' diff --git a/src/views/categories/index.ts b/src/views/categories/index.ts index 7501486..97862f7 100644 --- a/src/views/categories/index.ts +++ b/src/views/categories/index.ts @@ -1,3 +1,3 @@ -export * from './SingleCat/index' -export * from './category/index' -export * from './tabledata/index' +export * from './SingleCat' +export * from './category' +export * from './TableData' diff --git a/src/views/categories/tabledata/index.ts b/src/views/categories/tabledata/index.ts deleted file mode 100644 index 5825f39..0000000 --- a/src/views/categories/tabledata/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {default as TableData} from './tabledata.vue' diff --git a/src/views/projects/proj-list/proj-list.scss b/src/views/projects/proj-list/proj-list.scss index b93a31f..00b4dcb 100644 --- a/src/views/projects/proj-list/proj-list.scss +++ b/src/views/projects/proj-list/proj-list.scss @@ -2,9 +2,9 @@ min-width: 350px; } -.flex-container{ +.flex-container, .flex-container_col{ background-color: rgb(250, 250, 250); - padding: 4px; + padding: 2px 4px 2px 4px; margin: 2px; display: flex; align-items: center; @@ -12,6 +12,9 @@ justify-content: space-between; } +.flex-container_col { + flex-direction: column; +} .mycard { @@ -113,6 +116,7 @@ .flex-icon{ padding: 3px; + font-size: 1.5rem; } .titleSubMenu { diff --git a/src/views/projects/proj-list/proj-list.ts b/src/views/projects/proj-list/proj-list.ts index 21a199b..775d30a 100644 --- a/src/views/projects/proj-list/proj-list.ts +++ b/src/views/projects/proj-list/proj-list.ts @@ -1,25 +1,26 @@ import Vue from 'vue' import { Component, Watch } from 'vue-property-decorator' -import { IDrag, IProject, IProjectsState } from '../../../model/index' +import { IDrag, IProject, IProjectsState, ITodo } from '../../../model/index' import { SingleProject } from '../../../components/projects/SingleProject/index' +import { CTodo } from '../../../components/todos/CTodo' import { tools } from '../../../store/Modules/tools' import * as ApiTables from '../../../store/Modules/ApiTables' -import { GlobalStore, Projects } from '@store' +import { GlobalStore, Projects, Todos } from '@store' import { UserStore } from '@store' import { Getter } from 'vuex-class' import { Screen } from 'quasar' -import { CProgress } from '@src/components/CProgress' +import { CProgress } from '@components' const namespace: string = 'Projects' @Component({ - components: { SingleProject, CProgress }, + components: { SingleProject, CProgress, CTodo }, filters: { capitalize(value) { if (!value) { @@ -44,11 +45,14 @@ export default class ProjList extends Vue { public itemproj: IProject = null public idsel: string = '' public itemsel: IProject = Projects.getters.getRecordEmpty() + public itemtodosel: ITodo = Todos.getters.getRecordEmpty() + public whatisSel: number = 0 public colProgress: string = 'blue' public percProgress: string = 'percProgress' public $refs: { - singleproject: SingleProject[] + singleproject: SingleProject[], + ctodo: CTodo } get getrouteup() { @@ -210,8 +214,9 @@ export default class ProjList extends Vue { console.log('this.$refs.singleproject', this.$refs.singleproject) for (const elem of this.$refs.singleproject) { // @ts-ignore - if (elem.itemproject._id === id) + if (elem.itemproject._id === id) { return elem + } } } @@ -232,8 +237,13 @@ export default class ProjList extends Vue { public setidsel(id: string) { this.idsel = id + this.whatisSel = tools.WHAT_PROJECT this.itemsel = Projects.getters.getRecordById(this.idsel) } + public setitemsel(item: ITodo) { + this.whatisSel = tools.WHAT_TODO + this.itemtodosel = item + } public async updateitemproj({ myitem, field }) { console.log('calling MODIFY updateitemproj', myitem, field) @@ -251,10 +261,25 @@ export default class ProjList extends Vue { } - public deselectAllRowsproj(item: IProject, check, onlythis: boolean = false) { - // console.log('deselectAllRowsproj : ', item) + public deselectAllRowstodo(item: ITodo, check, onlythis: boolean = false) { + console.log('PROJ-LIST deselectAllRowstodo : ', item) - for (let i = 0; i < this.$refs.singleproject.length; i++) { + // @ts-ignore + for (const i in this.$refs.ctodo.$refs.single) { + // @ts-ignore + const contr = this.$refs.ctodo.$refs.single[i] as SingleTodo + const des = !check + if (des) { + // @ts-ignore + contr.deselectAndExitEdit() + } + } + } + + public deselectAllRowsproj(item: IProject, check, onlythis: boolean = false) { + console.log('deselectAllRowsproj: ', item) + + for (const i in this.$refs.singleproject) { const contr = this.$refs.singleproject[i] as SingleProject // @ts-ignore @@ -264,7 +289,11 @@ export default class ProjList extends Vue { if (onlythis) { des = item._id === id } else { - des = ((check && (item._id !== id)) || (!check)) + if (!!item) { + des = ((check && (item._id !== id)) || (!check)) + } else { + des = !check + } } if (des) { // @ts-ignore @@ -290,9 +319,10 @@ export default class ProjList extends Vue { } get getCalcHoursWorked() { - if (this.itemsel.hoursplanned <= 0) + if (this.itemsel.hoursplanned <= 0) { return 0 - let myperc = Math.round(this.itemsel.hoursworked / this.itemsel.hoursplanned * 100) + } + const myperc = Math.round(this.itemsel.hoursworked / this.itemsel.hoursplanned * 100) return myperc diff --git a/src/views/projects/proj-list/proj-list.vue b/src/views/projects/proj-list/proj-list.vue index e525d4b..a4f9884 100644 --- a/src/views/projects/proj-list/proj-list.vue +++ b/src/views/projects/proj-list/proj-list.vue @@ -84,30 +84,23 @@ - - - - - - - -
+ + + + + -