- Projects: Shared / Personal
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user