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

@@ -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()
},