From a7a4d224ebee4baede4f638143180ecb644b8cca Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Thu, 25 Apr 2019 00:30:13 +0200 Subject: [PATCH] - Projects: Shared / Personal --- quasar.conf.js | 1 + src/components/Header/Header.ts | 1 + src/components/logo/logo.ts | 1 + .../projects/SingleProject/SingleProject.ts | 152 ++++++++++-------- src/components/todos/CTodo/CTodo.ts | 2 + src/layouts/menuone/menuOne.ts | 1 + src/layouts/menuone/menuOne.vue | 44 ++--- src/model/GlobalStore.ts | 17 +- src/model/Projects.ts | 1 + src/router/route-config.ts | 29 +++- src/router/route-names.ts | 5 +- src/statics/i18n.js | 18 ++- src/store/Modules/GlobalStore.ts | 143 +++++++++++----- src/store/Modules/Projects.ts | 22 +-- src/store/Modules/tools.ts | 29 +++- src/views/projects/proj-list/proj-list.ts | 13 +- src/views/projects/proj-list/proj-list.vue | 8 + 17 files changed, 333 insertions(+), 154 deletions(-) diff --git a/quasar.conf.js b/quasar.conf.js index 0f42405..a2dd8d7 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -172,6 +172,7 @@ module.exports = function (ctx) { 'QAvatar', 'QImg', 'QSplitter', + 'QRating', 'QSeparator' ], directives: [ diff --git a/src/components/Header/Header.ts b/src/components/Header/Header.ts index 4d71747..0546c8a 100644 --- a/src/components/Header/Header.ts +++ b/src/components/Header/Header.ts @@ -12,6 +12,7 @@ import { tools } from '../../store/Modules/tools' import Quasar from 'quasar' @Component({ + name: 'Header', components: { drawer, messagePopover diff --git a/src/components/logo/logo.ts b/src/components/logo/logo.ts index 3a0e596..3ffed69 100644 --- a/src/components/logo/logo.ts +++ b/src/components/logo/logo.ts @@ -3,6 +3,7 @@ import { Component } from 'vue-property-decorator' import { tools } from '@src/store/Modules/tools' @Component({ + name: 'Logo' }) export default class Logo extends Vue { get logoimg() { diff --git a/src/components/projects/SingleProject/SingleProject.ts b/src/components/projects/SingleProject/SingleProject.ts index 0f6e0c3..0450c20 100644 --- a/src/components/projects/SingleProject/SingleProject.ts +++ b/src/components/projects/SingleProject/SingleProject.ts @@ -50,50 +50,73 @@ export default class SingleProject extends Vue { @Prop({ required: true }) public itemproject: IProject - @Watch('itemproject.enableExpiring') public valueChanged4() { + @Watch('itemproject.enableExpiring') + public valueChanged4() { this.watchupdate('enableExpiring') } - @Watch('itemproject.expiring_at') public valueChanged2() { + @Watch('itemproject.expiring_at') + public valueChanged2() { this.watchupdate('expiring_at') } - @Watch('itemproject.descr') public valueChanged5() { + @Watch('itemproject.descr') + public valueChanged5() { this.precDescr = this.itemproject.descr } - @Watch('itemproject.longdescr') public valueChangedlongdescr() { + @Watch('itemproject.longdescr') + public valueChangedlongdescr() { this.watchupdate('longdescr') } - @Watch('itemproject.hoursplanned') public valueChangedhoursplanned() { + @Watch('itemproject.hoursplanned') + public valueChangedhoursplanned() { this.watchupdate('hoursplanned') } - @Watch('itemproject.hoursworked') public valueChangedhoursworked() { + + @Watch('itemproject.hoursworked') + public valueChangedhoursworked() { this.watchupdate('hoursworked') } - @Watch('itemproject.begin_development') public valueChangedbegin_development() { + + @Watch('itemproject.begin_development') + public valueChangedbegin_development() { this.watchupdate('begin_development') } - @Watch('itemproject.hoursweeky_plannedtowork') public valueChangedhoursweeky_plannedtowork() { + + @Watch('itemproject.hoursweeky_plannedtowork') + public valueChangedhoursweeky_plannedtowork() { this.watchupdate('hoursweeky_plannedtowork') } - @Watch('itemproject.begin_test') public valueChangedbegin_test() { + + @Watch('itemproject.begin_test') + public valueChangedbegin_test() { this.watchupdate('begin_test') } - @Watch('itemproject.actualphase') public valueChangedactualphase() { + + @Watch('itemproject.actualphase') + public valueChangedactualphase() { this.watchupdate('actualphase') } - @Watch('itemproject.privacyread') public valueChanged_privacyread() { + + @Watch('itemproject.privacyread') + public valueChanged_privacyread() { this.watchupdate('privacyread') } - @Watch('itemproject.privacywrite') public valueChanged_privacywrite() { + + @Watch('itemproject.privacywrite') + public valueChanged_privacywrite() { this.watchupdate('privacywrite') } - @Watch('itemproject.totalphases') public valueChangedtotalphases() { + + @Watch('itemproject.totalphases') + public valueChangedtotalphases() { this.watchupdate('totalphases') } - @Watch('itemproject.progressCalc') public valueChanged6() { + + @Watch('itemproject.progressCalc') + public valueChanged6() { console.log('itemproject.progressCalc') this.updateClasses() @@ -112,12 +135,12 @@ export default class SingleProject extends Vue { return this.$t('proj.newsubproj') } -/* - public dateToYYYYMMDD(date) { - // may have timezone caveats https://stackoverflow.com/a/29774197/1850609 - return date && date.toISOString().split('T')[0] - } -*/ + /* + public dateToYYYYMMDD(date) { + // may have timezone caveats https://stackoverflow.com/a/29774197/1850609 + return date && date.toISOString().split('T')[0] + } + */ // Computed: get isSel() { @@ -134,7 +157,7 @@ export default class SingleProject extends Vue { public watchupdate(field = '') { console.log('watchupdate PROJ', field) - this.$emit('eventupdateproj', {myitem: this.itemproject, field } ) + this.$emit('eventupdateproj', { myitem: this.itemproject, field }) this.updateicon() } @@ -147,24 +170,26 @@ export default class SingleProject extends Vue { this.classDescrEdit += ' titleLista-item' } - if (this.itemproject.progressCalc > 100) - this.itemproject.progressCalc = 100 + this.percProgress = 'percProgress' this.classExpiring = 'flex-item data-item shadow-1 hide-if-small' this.classExpiringEx = '' - this.percentageProgress = this.itemproject.progressCalc - - this.percProgress = 'percProgress' - - this.colProgress = tools.getProgressColor(this.itemproject.progressCalc) - - this.percProgress += ' ' + tools.getProgressClassColor(this.itemproject.progressCalc) - this.clButtPopover = this.sel ? 'pos-item-popover comp_selected' : 'pos-item-popover' - if (this.itemproject.statusproj !== tools.Status.COMPLETED) { - this.clButtPopover += ' pos-item-popover_cursor' + if (!!this.itemproject) { + if (this.itemproject.statusproj !== tools.Status.COMPLETED) { + this.clButtPopover += ' pos-item-popover_cursor' + } + + if (this.itemproject.progressCalc > 100) + this.itemproject.progressCalc = 100 + + this.percentageProgress = this.itemproject.progressCalc + + this.colProgress = tools.getProgressColor(this.itemproject.progressCalc) + this.percProgress += ' ' + tools.getProgressClassColor(this.itemproject.progressCalc) + } if (this.isProject()) { @@ -192,19 +217,20 @@ export default class SingleProject extends Vue { } public clickRiga(clickmenu: boolean = false) { - console.log('CLICK RIGA PROJ************') + console.log('CLICK RIGA PROJ ************') - if (!this.sel) { - if (!this.inEdit) { - // this.attivaEdit = true - this.$emit('deselectAllRowstodo', null, false) - this.$emit('deselectAllRowsproj', this.itemproject, true) + // if (!this.sel) { - if (!this.sel) { - this.selectRiga() - } else { - this.deselectRiga() - } + if (!this.inEdit) { + console.log('entrato...') + // this.attivaEdit = true + this.$emit('deselectAllRowstodo', null, false) + this.$emit('deselectAllRowsproj', this.itemproject, true) + + if (!this.sel) { + this.selectRiga() + } else { + this.deselectRiga() } } } @@ -246,7 +272,7 @@ export default class SingleProject extends Vue { this.clickRiga() } - public activeEdit(){ + public activeEdit() { console.log('Attiva Edit') this.attivaEdit = true this.editProject() @@ -277,7 +303,7 @@ export default class SingleProject extends Vue { this.updateClasses() } - this.faiFocus('inputprojdescr', false, true) + this.faiFocus('inputprojdescr', false, true) } // console.log('FINE - editProject') } @@ -336,19 +362,19 @@ export default class SingleProject extends Vue { public keyDownArea(e) { console.log('keyDownArea') -/* - if ((e.key === 'ArrowUp') && !e.shiftKey) { - e.key = 'Tab' - e.shiftKey = true - } + /* + if ((e.key === 'ArrowUp') && !e.shiftKey) { + e.key = 'Tab' + e.shiftKey = true + } - if ((e.key === 'ArrowDown') && !e.shiftKey) { - let nextInput = inputs.get(inputs.index(this) + 1) - if (nextInput) { - nextInput.focus() - } - } -*/ + if ((e.key === 'ArrowDown') && !e.shiftKey) { + let nextInput = inputs.get(inputs.index(this) + 1) + if (nextInput) { + nextInput.focus() + } + } + */ // Delete Key or Backspage if (((e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) { e.preventDefault() @@ -399,7 +425,7 @@ export default class SingleProject extends Vue { this.updateClasses() } - public aggiornaProgress(value, initialval){ + public aggiornaProgress(value, initialval) { if (value !== initialval) { this.itemproject.progressCalc = value this.updatedata('progressCalc') @@ -424,7 +450,7 @@ export default class SingleProject extends Vue { public updatedata(field: string) { // const myitem = tools.jsonCopy(this.itemproject) console.log('calling this.$emit(eventupdateproj)', this.itemproject) - this.$emit('eventupdateproj', { myitem: this.itemproject, field } ) + this.$emit('eventupdateproj', { myitem: this.itemproject, field }) } public updateicon() { @@ -435,10 +461,10 @@ export default class SingleProject extends Vue { } // expand_less else if (this.itemproject.priority === tools.Priority.PRIORITY_NORMAL) { this.iconPriority = 'remove' - } + } else if (this.itemproject.priority === tools.Priority.PRIORITY_LOW) { this.iconPriority = 'expand_more' - } // expand_more + } // expand_more this.updateClasses() } @@ -482,7 +508,7 @@ export default class SingleProject extends Vue { const deletestr = this.$t('dialog.delete') const cancelstr = this.$t('dialog.cancel') - const msg = this.$t('dialog.msg.deleteTask', {mytodo : this.itemproject.descr }) + const msg = this.$t('dialog.msg.deleteTask', { mytodo: this.itemproject.descr }) this.$q.dialog({ cancel: { diff --git a/src/components/todos/CTodo/CTodo.ts b/src/components/todos/CTodo/CTodo.ts index 5b2d5bb..d8bf67a 100644 --- a/src/components/todos/CTodo/CTodo.ts +++ b/src/components/todos/CTodo/CTodo.ts @@ -15,6 +15,7 @@ import { SingleTodo } from '../SingleTodo' const namespace: string = 'Todos' @Component({ + name: 'CTodo', components: { SingleTodo }, filters: { capitalize(value) { @@ -22,6 +23,7 @@ const namespace: string = 'Todos' } } }) + export default class CTodo extends Vue { public $q: any public todotop: string = '' diff --git a/src/layouts/menuone/menuOne.ts b/src/layouts/menuone/menuOne.ts index c3dc7d4..3236308 100644 --- a/src/layouts/menuone/menuOne.ts +++ b/src/layouts/menuone/menuOne.ts @@ -1,6 +1,7 @@ import Vue from 'vue' import { Watch } from 'vue-property-decorator' import { GlobalStore } from '../../store/Modules' +import Component from 'vue-class-component' export default class MenuOne extends Vue { diff --git a/src/layouts/menuone/menuOne.vue b/src/layouts/menuone/menuOne.vue index 466f694..61097a1 100644 --- a/src/layouts/menuone/menuOne.vue +++ b/src/layouts/menuone/menuOne.vue @@ -3,25 +3,37 @@ diff --git a/src/model/GlobalStore.ts b/src/model/GlobalStore.ts index f4db9a0..7cdd733 100644 --- a/src/model/GlobalStore.ts +++ b/src/model/GlobalStore.ts @@ -62,18 +62,23 @@ export interface IGlobalState { export interface IMenuList { nametranslate: string - description: string + description?: string idelem?: string icon?: string + name?: string + level_parent?: number + level_child?: number + urlroute?: string + routes2?: IMenuList[] } export interface IListRoutes { route: string - faIcon: string - materialIcon: string + faIcon?: string + materialIcon?: string name: string text?: string - routes2: [] - level_parent: number - level_child: number + routes2?: IListRoutes[] + level_parent?: number + level_child?: number } diff --git a/src/model/Projects.ts b/src/model/Projects.ts index 35f2286..1c54131 100644 --- a/src/model/Projects.ts +++ b/src/model/Projects.ts @@ -20,6 +20,7 @@ export interface IProject { enableExpiring?: boolean id_prev?: string modified?: boolean + favourite?: number pos?: number order?: number live_url?: string diff --git a/src/router/route-config.ts b/src/router/route-config.ts index 6b93019..5d97b1d 100644 --- a/src/router/route-config.ts +++ b/src/router/route-config.ts @@ -97,7 +97,7 @@ export const routesList: IMyRouteConfig[] = [ // component: () => import('@/root/malaga/malaga.vue') // }, { - path: '/projects/:idProj', + path: '/' + RouteNames.projects + '/:idProj', name: RouteNames.projects, component: () => import('@/views/projects/proj-list/proj-list.vue'), meta: { @@ -109,7 +109,7 @@ export const routesList: IMyRouteConfig[] = [ } }, { - path: '/myprojects/:idProj', + path: '/' + RouteNames.myprojects + '/:idProj', name: RouteNames.myprojects, component: () => import('@/views/projects/proj-list/proj-list.vue'), meta: { @@ -119,9 +119,34 @@ export const routesList: IMyRouteConfig[] = [ } // middleware: [auth] } + }, + { + path: '/' + RouteNames.listprojects, + name: RouteNames.listprojects, + component: () => import('@/views/projects/proj-list/proj-list.vue'), + meta: { + requiresAuth: true, + async asyncData() { + await Projects.actions.dbLoad({ checkPending: false, onlyiffirsttime: true }) + } + // middleware: [auth] + } + }, + { + path: '/' + RouteNames.favouriteprojects, + name: RouteNames.favouriteprojects, + component: () => import('@/views/projects/proj-list/proj-list.vue'), + meta: { + requiresAuth: true, + async asyncData() { + await Projects.actions.dbLoad({ checkPending: false, onlyiffirsttime: true }) + } + // middleware: [auth] + } } + /* { diff --git a/src/router/route-names.ts b/src/router/route-names.ts index aa8d147..9e3e72f 100644 --- a/src/router/route-names.ts +++ b/src/router/route-names.ts @@ -2,5 +2,8 @@ export const RouteNames = { home: 'home', login: 'login', projects: 'projects', - myprojects: 'myprojects' + projectsshared: 'projectsShared', + myprojects: 'myprojects', + favouriteprojects: 'favproj', + listprojects: 'listproj' } diff --git a/src/statics/i18n.js b/src/statics/i18n.js index af09566..ba2770a 100644 --- a/src/statics/i18n.js +++ b/src/statics/i18n.js @@ -127,8 +127,10 @@ const messages = { Admin: 'Admin', Test1: 'Test1', Test2: 'Test2', - Projects: 'Progetti Condivisi', - MyProjects: 'Progetti Personali' + projects: 'Progetti', + favproj: 'Favoriti', + projectsShared: 'Condivisi', + myprojects: 'Personali' }, components: { authentication: { @@ -388,8 +390,10 @@ const messages = { Admin: 'Administración', Test1: 'Test1', Test2: 'Test2', - Projects: 'Proyectos Compartidos', - MyProjects: 'Proyectos Personales', + projects: 'Proyectos', + favproj: 'Favoritos', + projectsShared: 'Compartidos', + myprojects: 'Personales', }, components: { authentication: { @@ -642,8 +646,10 @@ const messages = { Admin: 'Admin', Test1: 'Test1', Test2: 'Test2', - Projects: 'Shared Projects', - MyProjects: 'Personal Projects', + projects: 'Projects', + favproj: 'Favorite', + projectsShared: 'Shared', + myprojects: 'Personals', }, components: { authentication: { diff --git a/src/store/Modules/GlobalStore.ts b/src/store/Modules/GlobalStore.ts index ff6d237..2282428 100644 --- a/src/store/Modules/GlobalStore.ts +++ b/src/store/Modules/GlobalStore.ts @@ -15,6 +15,7 @@ import * as ApiTables from '@src/store/Modules/ApiTables' import { GlobalStore, Projects, Todos, UserStore } from '@store' import messages from '../../statics/i18n' import globalroutines from './../../globalroutines/index' +import { RouteNames } from '@src/router/route-names' let stateConnDefault = 'online' @@ -72,7 +73,7 @@ async function getstateConnSaved() { } } -function addRoute(myarr, values) { +function addRoute(myarr, values: IListRoutes) { myarr.push(values) } @@ -114,73 +115,131 @@ namespace Getters { console.log('getmenu') const arrlista = GlobalStore.state.listatodo - const lista = [] + const lista: IListRoutes[] = [] arrlista.forEach((elem: IMenuList) => { - const item = { + const item: IListRoutes = { faIcon: 'fa fa-list-alt', materialIcon: 'todo', name: 'pages.' + elem.description, route: '/todo/' + elem.nametranslate } lista.push(item) - }) - const arrlistaprojtutti = Projects.getters.listaprojects(false) - const arrlistaprojmiei = Projects.getters.listaprojects(true) - const listaprojectstutti = [] - const listaprojectsmiei = [] + const SHOW_PROJINTHEMENU = false - for (const elem of arrlistaprojtutti) { - const item = { - materialIcon: 'next_week', - name: elem.nametranslate, - text: elem.description, - route: tools.getUrlByTipoProj(false) + elem.idelem - } - listaprojectstutti.push(item) + let arrlistafavourite = [] + let arrlistaprojtutti = [] + let arrlistaprojmiei = [] + if (SHOW_PROJINTHEMENU) { + arrlistaprojtutti = Projects.getters.listaprojects(false, false) + arrlistaprojmiei = Projects.getters.listaprojects(true, false) + arrlistafavourite = Projects.getters.listaprojects(false, true) } - for (const elem of arrlistaprojmiei) { - const item = { - materialIcon: 'next_week', - name: elem.nametranslate, - text: elem.description, - route: tools.getUrlByTipoProj(true) + elem.idelem - } - listaprojectsmiei.push(item) + const arrMenu: IMenuList[] = [] + + // PROGETTI -> FAVORITI : + if (arrlistafavourite.length > 0) { + arrMenu.push({ + icon: '', + nametranslate: 'pages.' + RouteNames.favouriteprojects, + urlroute: RouteNames.favouriteprojects, + level_parent: 0.0, + level_child: 0.5, + routes2: arrlistafavourite, + idelem: '' + }) } + // PROGETTI -> CONDIVISI : + arrMenu.push({ + icon: '', + nametranslate: 'pages.' + RouteNames.projectsshared, + urlroute: 'projects', + level_parent: 0.0, + level_child: 0.5, + routes2: arrlistaprojtutti, + idelem: process.env.PROJECT_ID_MAIN + }) + + // PROGETTI -> PERSONALI : + arrMenu.push({ + icon: '', + nametranslate: 'pages.' + RouteNames.myprojects, + urlroute: 'myprojects', + level_parent: 0.0, + level_child: 0.5, + routes2: arrlistaprojmiei, + idelem: process.env.PROJECT_ID_MAIN + }) + + const listaprojectMenu: IListRoutes[] = tools.convertMenuListInListRoutes(arrMenu) + const arrroutes: IListRoutes[] = [] addRoute(arrroutes, { route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' }) // HOME if (!process.env.PROD) { - addRoute(arrroutes, { route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo', + addRoute(arrroutes, { + route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo', routes2: lista, level_parent: 0.5, level_child: 0.5 }) - addRoute(arrroutes,{ route: tools.getUrlByTipoProj(false) + process.env.PROJECT_ID_MAIN, faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.Projects', - routes2: listaprojectstutti, - level_parent: 0, - level_child: 0.5 - }) - - addRoute(arrroutes,{ route: tools.getUrlByTipoProj(true) + process.env.PROJECT_ID_MAIN, faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.MyProjects', - routes2: listaprojectsmiei, - level_parent: 0, - level_child: 0.5 - }) } + const myarrproj = [] + for (const myitem of listaprojectMenu) { + addRoute(myarrproj, myitem) + } + + addRoute(arrroutes, { + route: '', faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.projects', + routes2: myarrproj, + level_parent: 0.0, + level_child: 0.5 + }) + + console.log('arrroutes', arrroutes) + console.log('listaprojectMenu', listaprojectMenu) + // console.log('arrlistaprojmiei', arrlistaprojmiei) + if (UserStore.state.isAdmin) { - addRoute(arrroutes, { route: '/category', faIcon: 'fa fa-list-alt', materialIcon: 'category', name: 'pages.Category' }) - addRoute(arrroutes, { route: '/admin/cfgserv', faIcon: 'fa fa-database', materialIcon: 'event_seat', name: 'pages.Admin' }) - addRoute(arrroutes, { route: '/admin/testp1/par1', faIcon: 'fa fa-database', materialIcon: 'restore', name: 'pages.Test1' }) - addRoute(arrroutes, { route: '/admin/testp1/par2', faIcon: 'fa fa-database', materialIcon: 'restore', name: 'pages.Test2' }) + addRoute(arrroutes, { + route: '/category', + faIcon: 'fa fa-list-alt', + materialIcon: 'category', + name: 'pages.Category', + level_parent: 0.0, + level_child: 0.0 + }) + addRoute(arrroutes, { + route: '/admin/cfgserv', + faIcon: 'fa fa-database', + materialIcon: 'event_seat', + name: 'pages.Admin', + level_parent: 0.0, + level_child: 0.0 + }) + addRoute(arrroutes, { + route: '/admin/testp1/par1', + faIcon: 'fa fa-database', + materialIcon: 'restore', + name: 'pages.Test1', + level_parent: 0.0, + level_child: 0.0 + }) + addRoute(arrroutes, { + route: '/admin/testp1/par2', + faIcon: 'fa fa-database', + materialIcon: 'restore', + name: 'pages.Test2', + level_parent: 0.0, + level_child: 0.0 + }) } state.menulinks = { @@ -192,7 +251,7 @@ namespace Getters { return state.menulinks - console.log('state.menulinks', state.menulinks) + // console.log('state.menulinks', state.menulinks) }, 'getmenu') @@ -480,7 +539,7 @@ namespace Actions { subscription.unsubscribe().then((successful) => { // You've successfully unsubscribed console.log('You\'ve successfully unsubscribed') - }).catch( (e) => { + }).catch((e) => { // Unsubscription failed }) } diff --git a/src/store/Modules/Projects.ts b/src/store/Modules/Projects.ts index 5833a6f..4ffb1aa 100644 --- a/src/store/Modules/Projects.ts +++ b/src/store/Modules/Projects.ts @@ -24,7 +24,7 @@ const stateglob: IProjectsState = { const listFieldsToChange: string [] = ['descr', 'longdescr', 'hoursplanned', 'hoursworked', 'id_parent', 'statusproj', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progressCalc', 'live_url', 'test_url', 'begin_development', 'begin_test', 'actualphase', 'totalphases', 'hoursweeky_plannedtowork', 'endwork_estimate', - 'privacyread', 'privacywrite', 'id_main_project', 'typeproj'] + 'privacyread', 'privacywrite', 'id_main_project', 'typeproj', 'favourite'] const listFieldsUpdateCalculation: string [] = ['hoursplanned', 'hoursworked', 'progressCalc', 'endwork_estimate'] @@ -51,11 +51,11 @@ function updateDataCalculated(projout, projin) { }) } -function getproj(projects, idproj, miei: boolean) { - if (miei) { - return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && proj.userId === UserStore.state.userId)) +function getproj(projects, idproj, miei: boolean, favourite: boolean) { + if (miei && !favourite) { + return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId === UserStore.state.userId))) } else { - return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && proj.userId !== UserStore.state.userId )) + return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId !== UserStore.state.userId))) } } @@ -104,21 +104,21 @@ namespace Getters { // console.log('projs_dacompletare', miei) if (state.projects) { // console.log('state.projects', state.projects) - return getproj(state.projects, id_parent, miei) + return getproj(state.projects, id_parent, miei, false) } else { return [] } }, 'projs_dacompletare') - const listaprojects = b.read((state: IProjectsState) => (miei: boolean): IMenuList[] => { + const listaprojects = b.read((state: IProjectsState) => (miei: boolean, favourite: boolean): IMenuList[] => { if (state.projects) { // console.log('state.projects', state.projects) - const listaproj = getproj(state.projects, process.env.PROJECT_ID_MAIN, miei) + const listaproj = getproj(state.projects, process.env.PROJECT_ID_MAIN, miei, favourite) const myarr: IMenuList[] = [] for (const proj of listaproj) { myarr.push({ nametranslate: '', description: proj.descr, idelem: proj._id }) } - console.log(' myarr', myarr, listaproj) + // console.log(' myarr', myarr, listaproj) return myarr } else { @@ -146,7 +146,7 @@ namespace Getters { }, 'getRecordById') const getifCanISeeProj = b.read((state: IProjectsState) => (proj: IProject): boolean => { - if (proj === undefined) + if ((proj === undefined) || (proj === null)) return false if (!!UserStore.state) { @@ -164,7 +164,7 @@ namespace Getters { }, 'getifCanISeeProj') const CanIModifyPanelPrivacy = b.read((state: IProjectsState) => (proj: IProject): boolean => { - if (proj === undefined) + if ((proj === undefined) || (proj === null)) return false if (!!UserStore) { diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index af40024..4572561 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -3,7 +3,7 @@ import globalroutines from './../../globalroutines/index' import { costanti } from './costanti' import { translation } from './translation' import Quasar, { date } from 'quasar' -import { IProject, ITodo, Privacy } from '@src/model' +import { IListRoutes, IMenuList, IProject, ITodo, Privacy } from '@src/model' import * as ApiTables from '@src/store/Modules/ApiTables' import translate from '@src/globalroutines/util' @@ -27,6 +27,7 @@ export const tools = { FIRST_PROJ: '5ca8f17fcd40dc5012f53346', + WHAT_NOTHING: 0, WHAT_TODO: 1, WHAT_PROJECT: 2, @@ -1375,11 +1376,35 @@ export const tools = { return idproj === process.env.PROJECT_ID_MAIN }, - getUrlByTipoProj(miei) { + getUrlByTipoProj(miei, name?: string) { + if (!!name) + return '/' + name + '/' + if (miei) return '/myprojects/' else return '/projects/' + }, + + convertMenuListInListRoutes(arrlista: IMenuList[]) { + const lista = [] + if (arrlista === undefined) + return lista + for (const elem of arrlista) { + const item: IListRoutes = { + faIcon: 'fa fa-list-alt', + materialIcon: elem.icon, + name: elem.nametranslate, + text: elem.description, + route: tools.getUrlByTipoProj(false, elem.urlroute) + elem.idelem, + routes2: tools.convertMenuListInListRoutes(elem.routes2), + level_parent: elem.level_parent, + level_child: elem.level_child + + } + lista.push(item) + } + return lista } } diff --git a/src/views/projects/proj-list/proj-list.ts b/src/views/projects/proj-list/proj-list.ts index a05bd2f..02db96c 100644 --- a/src/views/projects/proj-list/proj-list.ts +++ b/src/views/projects/proj-list/proj-list.ts @@ -72,6 +72,7 @@ export default class ProjList extends Vue { @Watch('$route.name') public changename() { console.log('tools.getUrlByTipoProj(this.areMyProjects)', tools.getUrlByTipoProj(this.areMyProjects)) + this.changeparent() } @Watch('$route.params.idProj') @@ -403,6 +404,8 @@ export default class ProjList extends Vue { this.idsel = id this.whatisSel = tools.WHAT_PROJECT this.itemselproj = Projects.getters.getRecordById(this.idsel) + if ((this.itemselproj === undefined || this.itemselproj === null)) + this.whatisSel = tools.WHAT_NOTHING } public setitemsel(item: ITodo) { this.whatisSel = tools.WHAT_TODO @@ -422,7 +425,7 @@ export default class ProjList extends Vue { } public deselectAllRowstodo(item: ITodo, check, onlythis: boolean = false) { - // console.log('PROJ-LIST deselectAllRowstodo : ', item) + console.log('PROJ-LIST deselectAllRowstodo : ', item) return false @@ -452,7 +455,7 @@ export default class ProjList extends Vue { } public deselectAllRowsproj(item: IProject, check, onlythis: boolean = false) { - // console.log('deselectAllRowsproj: ', item) + console.log('deselectAllRowsproj: ', item) for (const i in this.$refs.singleproject) { @@ -478,7 +481,11 @@ export default class ProjList extends Vue { } public updateclasses() { - this.colProgress = tools.getProgressColor(this.itemselproj.progressCalc) + if (!!!this.itemselproj) { + this.colProgress = tools.getProgressColor(this.itemselproj.progressCalc) + } else { + this.whatisSel = tools.WHAT_NOTHING + } } public checkUpdate() { diff --git a/src/views/projects/proj-list/proj-list.vue b/src/views/projects/proj-list/proj-list.vue index 69c4b6c..d52c75e 100644 --- a/src/views/projects/proj-list/proj-list.vue +++ b/src/views/projects/proj-list/proj-list.vue @@ -116,6 +116,14 @@
+ + + + + + + +
{{itemselproj.descr}}