Added Main Projects to Menu (dynamically)

This commit is contained in:
Paolo Arena
2019-03-31 14:27:27 +02:00
parent 38b3405664
commit cea5dd118a
8 changed files with 98 additions and 78 deletions

View File

@@ -278,9 +278,9 @@ export default class SingleProject extends Vue {
}
public keyDownRow(e) {
console.log('keyDownRow')
console.log('keyDownRow', e.keyCode)
// Delete Key or Backspage
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
if (((e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
e.preventDefault()
this.deselectRiga()
this.clickMenu(tools.MenuAction.DELETE)
@@ -308,7 +308,7 @@ export default class SingleProject extends Vue {
}
*/
// Delete Key or Backspage
if (((e.keyCode === 8) || (e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
if (((e.keyCode === 46)) && (this.precDescr === '') && !e.shiftKey) {
e.preventDefault()
this.deselectRiga()
this.clickMenu(tools.MenuAction.DELETE)

View File

@@ -1,5 +1,5 @@
<template>
<div :class="getClassRow()" @click="clickProject">
<div :class="getClassRow()" @click="clickProject" >
<q-btn class="flex-item donotdrag " size="sm" push color="primary" round icon="arrow_forward"
:to="getrouteto" />
@@ -63,7 +63,6 @@
<SubMenusProj :menuPopupProj="menuPopupProj" :itemproject="itemproject" @clickMenu="clickMenu"
@setPriority="setPriority"></SubMenusProj>
</q-menu>
</q-btn>
</div>
<!--clButtPopover: {{ clButtPopover }}-->

View File

@@ -6,8 +6,8 @@
<div v-for="item in parent.routes">
<div v-if="item.routes2">
<q-expansion-item
:header-inset-level="0.5"
:content-inset-level="0.5"
:header-inset-level="item.level_parent"
:content-inset-level="item.level_parent"
:label="$t(item.name)"
:icon="item.materialIcon"
expand-icon-class="my-menu-separat"
@@ -16,7 +16,7 @@
>
<q-expansion-item v-for="(child2, index) in item.routes2" :to="child2.route" :key="index"
:header-inset-level="0.5"
:header-inset-level="item.level_child"
:duration="300"
expand-icon="map"
active-class="my-menu-active"

View File

@@ -55,13 +55,23 @@ export interface IGlobalState {
connData: IConnData
posts: IPost[]
menulinks: {}
listatodo: ITodoList[]
listatodo: IMenuList[]
arrConfig: IConfig[]
}
export interface ITodoList {
namecat: string
export interface IMenuList {
name: string
description: string
idelem?: string
icon?: string
}
export interface IListRoutes {
route: string
faIcon: string
materialIcon: string
name: string
routes2: []
level_parent: string
level_child: string
}

View File

@@ -88,7 +88,7 @@ async function dbDeleteItem(call, item) {
})
.catch((error) => {
UserStore.mutations.setErrorCatch(error)
return UserStore.getters.getServerCode
return UserStore.getters.getServerCode()
})
return res
@@ -188,7 +188,7 @@ export async function aftercalling(ris, checkPending: boolean, nametabindex: str
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
tools.consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
} else {
tools.consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)', UserStore.getters.getServerCode, ris.status)
tools.consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)', UserStore.getters.getServerCode(), ris.status)
}
if ('serviceWorker' in navigator) {
// Read all data from IndexedDB Store into Memory

View File

@@ -1,4 +1,4 @@
import { ICfgServer, IConfig, IGlobalState, ITodoList, StateConnection } from 'model'
import { ICfgServer, IConfig, IGlobalState, IListRoutes, IMenuList, StateConnection } from 'model'
import { storeBuilder } from './Store/Store'
import Vue from 'vue'
@@ -12,7 +12,7 @@ import * as Types from '@src/store/Api/ApiTypes'
import { costanti } from '@src/store/Modules/costanti'
import { tools } from '@src/store/Modules/tools'
import * as ApiTables from '@src/store/Modules/ApiTables'
import { GlobalStore, Todos, UserStore } from '@store'
import { GlobalStore, Projects, Todos, UserStore } from '@store'
import messages from '../../statics/i18n'
import globalroutines from './../../globalroutines/index'
@@ -40,9 +40,9 @@ const state: IGlobalState = {
posts: [],
menulinks: {},
listatodo: [
{ namecat: 'personal', description: 'personal' },
{ namecat: 'work', description: 'work' },
{ namecat: 'shopping', description: 'shopping' }
{ name: 'personal', description: 'personal' },
{ name: 'work', description: 'work' },
{ name: 'shopping', description: 'shopping' }
],
connData: {
uploading_server: 0,
@@ -72,6 +72,10 @@ async function getstateConnSaved() {
}
}
function addRoute(myarr, values) {
myarr.push(values)
}
const b = storeBuilder.module<IGlobalState>('GlobalModule', state)
// Getters
@@ -109,72 +113,62 @@ namespace Getters {
const getmenu = b.read((state) => {
const arrlista = GlobalStore.state.listatodo
let listatodo = []
const listatodo = []
arrlista.forEach((elem: ITodoList) => {
arrlista.forEach((elem: IMenuList) => {
const item = {
faIcon: 'fa fa-list-alt',
materialIcon: 'todo',
name: 'pages.' + elem.description,
route: '/todo/' + elem.namecat
route: '/todo/' + elem.name
}
listatodo.push(item)
})
const arrlistaproj = Projects.getters.listaprojects()
const listaprojects = []
for (const elem of arrlistaproj) {
const item = {
materialIcon: 'next_week',
name: elem.description,
route: '/projects/' + elem.idelem
}
listaprojects.push(item)
}
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',
routes2: listatodo,
level_parent: '0.5',
level_child: '0.5'
})
addRoute(arrroutes,{ route: '/projects/' + tools.FIRST_PROJ, faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.Projects',
routes2: listaprojects,
level_parent: '0',
level_child: '0.5'
})
}
if (UserStore.state.isAdmin) {
state.menulinks = {
Dashboard: {
routes: [
{ route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' },
{
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo',
routes2: listatodo
},
{ route: '/projects/' + tools.FIRST_PROJ, faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.Projects' },
{ route: '/category', faIcon: 'fa fa-list-alt', materialIcon: 'category', name: 'pages.Category' },
{ route: '/admin/cfgserv', faIcon: 'fa fa-database', materialIcon: 'event_seat', name: 'pages.Admin' },
{ route: '/admin/testp1/par1', faIcon: 'fa fa-database', materialIcon: 'restore', name: 'pages.Test1' },
{ route: '/admin/testp1/par2', faIcon: 'fa fa-database', materialIcon: 'restore', name: 'pages.Test2' }
/* {route: '/vreg?idlink=aaa', faIcon: 'fa fa-login', materialIcon: 'login', name: 'pages.vreg'},*/
],
show: true
}
}
} else {
// PRODUCTION USER:
if (process.env.PROD) {
state.menulinks = {
Dashboard: {
routes: [
{ route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' }
],
show: true
}
}
} else {
// SERVER TEST
state.menulinks = {
Dashboard: {
routes: [
{ route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' },
{
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo',
routes2: listatodo
},
{ route: '/category', faIcon: 'fa fa-list-alt', materialIcon: 'category', name: 'pages.Category' }
// { route: '/signup', faIcon: 'fa fa-registered', materialIcon: 'home', name: 'pages.SignUp' },
// { route: '/signin', faIcon: 'fa fa-anchor', materialIcon: 'home', name: 'pages.SignIn' },
/* {route: '/vreg?idlink=aaa', faIcon: 'fa fa-login', materialIcon: 'login', name: 'pages.vreg'},*/
],
show: true
}
}
}
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' })
}
console.log('___ return getMenu ', state.menulinks)
state.menulinks = {
Dashboard: {
routes: arrroutes,
show: true
}
}
return state.menulinks

View File

@@ -1,4 +1,4 @@
import { IProject, IProjectsState, IDrag } from 'model'
import { IProject, IProjectsState, IDrag, IMenuList } from 'model'
import { storeBuilder } from './Store/Store'
import Api from '@api'
@@ -81,6 +81,20 @@ namespace Getters {
}
}, 'items_dacompletare')
const listaprojects = b.read((state: IProjectsState) => (): IMenuList[] => {
if (state.projects) {
const listaproj = tools.mapSort(state.projects.filter((proj) => proj.id_parent === tools.FIRST_PROJ))
const myarr: IMenuList[] = []
for (const proj of listaproj) {
myarr.push({name: proj.descr, description: proj.descr, idelem: proj._id})
}
return myarr
} else {
return []
}
}, 'listaprojects')
const getDescrById = b.read((state: IProjectsState) => (id: string): string => {
if (id === tools.FIRST_PROJ)
return 'Projects'
@@ -117,6 +131,9 @@ namespace Getters {
get items_dacompletare() {
return items_dacompletare()
},
get listaprojects() {
return listaprojects()
},
get getDescrById() {
return getDescrById()
},

View File

@@ -235,7 +235,7 @@ namespace Actions {
})
.catch((error: Types.AxiosError) => {
UserStore.mutations.setErrorCatch(error)
return { code: UserStore.getters.getServerCode, msg: error.getMsgError() }
return { code: UserStore.getters.getServerCode(), msg: error.getMsgError() }
})
}
@@ -254,7 +254,7 @@ namespace Actions {
return { code: res.data.code, msg: res.data.msg }
}).catch((error) => {
UserStore.mutations.setErrorCatch(error)
return UserStore.getters.getServerCode
return UserStore.getters.getServerCode()
})
}
@@ -280,7 +280,7 @@ namespace Actions {
return { code: res.data.code, msg: res.data.msg }
}).catch((error) => {
UserStore.mutations.setErrorCatch(error)
return UserStore.getters.getServerCode
return UserStore.getters.getServerCode()
})
}
@@ -348,7 +348,7 @@ namespace Actions {
})
.catch((error) => {
UserStore.mutations.setErrorCatch(error)
return UserStore.getters.getServerCode
return UserStore.getters.getServerCode()
})
})
}
@@ -456,7 +456,7 @@ namespace Actions {
})
.catch((error) => {
UserStore.mutations.setErrorCatch(error)
return UserStore.getters.getServerCode
return UserStore.getters.getServerCode()
})
}
@@ -484,7 +484,7 @@ namespace Actions {
Mutations.mutations.clearAuthData()
}).catch((error) => {
UserStore.mutations.setErrorCatch(error)
return UserStore.getters.getServerCode
return UserStore.getters.getServerCode()
})
return riscall