End "project and Todos": what could modify or readonly.
This commit is contained in:
@@ -127,17 +127,29 @@ namespace Getters {
|
||||
|
||||
})
|
||||
|
||||
const arrlistaproj = Projects.getters.listaprojects()
|
||||
const listaprojects = []
|
||||
const arrlistaprojtutti = Projects.getters.listaprojects(false)
|
||||
const arrlistaprojmiei = Projects.getters.listaprojects(true)
|
||||
const listaprojectstutti = []
|
||||
const listaprojectsmiei = []
|
||||
|
||||
for (const elem of arrlistaproj) {
|
||||
for (const elem of arrlistaprojtutti) {
|
||||
const item = {
|
||||
materialIcon: 'next_week',
|
||||
name: elem.nametranslate,
|
||||
text: elem.description,
|
||||
route: '/projects/' + elem.idelem
|
||||
route: tools.getUrlByTipoProj(false) + elem.idelem
|
||||
}
|
||||
listaprojects.push(item)
|
||||
listaprojectstutti.push(item)
|
||||
}
|
||||
|
||||
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 arrroutes: IListRoutes[] = []
|
||||
@@ -151,8 +163,14 @@ namespace Getters {
|
||||
level_child: 0.5
|
||||
})
|
||||
|
||||
addRoute(arrroutes,{ route: '/projects/' + process.env.PROJECT_ID_MAIN, faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.Projects',
|
||||
routes2: listaprojects,
|
||||
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
|
||||
})
|
||||
|
||||
@@ -51,6 +51,14 @@ 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))
|
||||
} else {
|
||||
return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && proj.userId !== UserStore.state.userId ))
|
||||
}
|
||||
}
|
||||
|
||||
namespace Getters {
|
||||
const getRecordEmpty = b.read((state: IProjectsState) => (): IProject => {
|
||||
// const tomorrow = tools.getDateNow()
|
||||
@@ -92,19 +100,20 @@ namespace Getters {
|
||||
return obj
|
||||
}, 'getRecordEmpty')
|
||||
|
||||
const items_dacompletare = b.read((state: IProjectsState) => (id_parent: string): IProject[] => {
|
||||
const projs_dacompletare = b.read((state: IProjectsState) => (id_parent: string, miei: boolean): IProject[] => {
|
||||
// console.log('projs_dacompletare', miei)
|
||||
if (state.projects) {
|
||||
// console.log('state.projects', state.projects)
|
||||
return tools.mapSort(state.projects.filter((proj) => proj.id_parent === id_parent))
|
||||
return getproj(state.projects, id_parent, miei)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}, 'items_dacompletare')
|
||||
}, 'projs_dacompletare')
|
||||
|
||||
const listaprojects = b.read((state: IProjectsState) => (): IMenuList[] => {
|
||||
const listaprojects = b.read((state: IProjectsState) => (miei: boolean): IMenuList[] => {
|
||||
if (state.projects) {
|
||||
// console.log('state.projects', state.projects)
|
||||
const listaproj = tools.mapSort(state.projects.filter((proj) => proj.id_parent === process.env.PROJECT_ID_MAIN))
|
||||
const listaproj = getproj(state.projects, process.env.PROJECT_ID_MAIN, miei)
|
||||
const myarr: IMenuList[] = []
|
||||
for (const proj of listaproj) {
|
||||
myarr.push({ nametranslate: '', description: proj.descr, idelem: proj._id })
|
||||
@@ -137,20 +146,34 @@ namespace Getters {
|
||||
}, 'getRecordById')
|
||||
|
||||
const getifCanISeeProj = b.read((state: IProjectsState) => (proj: IProject): boolean => {
|
||||
if (proj === null)
|
||||
if (proj === undefined)
|
||||
return false
|
||||
|
||||
if (UserStore.state.userId === proj.userId) // If it's the owner
|
||||
return true
|
||||
if (!!UserStore.state) {
|
||||
|
||||
return (proj.privacyread === Privacy.all) ||
|
||||
(proj.privacyread === Privacy.friends) && (UserStore.getters.IsMyFriend(proj.userId))
|
||||
|| ((proj.privacyread === Privacy.mygroup) && (UserStore.getters.IsMyGroup(proj.userId)))
|
||||
if (UserStore.state.userId === proj.userId) // If it's the owner
|
||||
return true
|
||||
|
||||
return (proj.privacyread === Privacy.all) ||
|
||||
(proj.privacyread === Privacy.friends) && (UserStore.getters.IsMyFriend(proj.userId))
|
||||
|| ((proj.privacyread === Privacy.mygroup) && (UserStore.getters.IsMyGroup(proj.userId)))
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
}, 'getifCanISeeProj')
|
||||
|
||||
const CanIModifyPanelPrivacy = b.read((state: IProjectsState) => (proj: IProject): boolean => {
|
||||
return ((UserStore.state.userId === proj.userId) || (proj.privacywrite === Privacy.all)) // If it's the owner
|
||||
if (proj === undefined)
|
||||
return false
|
||||
|
||||
if (!!UserStore) {
|
||||
if (!!UserStore.state)
|
||||
return ((UserStore.state.userId === proj.userId) || (proj.privacywrite === Privacy.all)) // If it's the owner
|
||||
else
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}, 'CanIModifyPanelPrivacy')
|
||||
|
||||
export const getters = {
|
||||
@@ -163,8 +186,8 @@ namespace Getters {
|
||||
get getRecordEmpty() {
|
||||
return getRecordEmpty()
|
||||
},
|
||||
get items_dacompletare() {
|
||||
return items_dacompletare()
|
||||
get projs_dacompletare() {
|
||||
return projs_dacompletare()
|
||||
},
|
||||
get listaprojects() {
|
||||
return listaprojects()
|
||||
@@ -348,7 +371,7 @@ namespace Actions {
|
||||
async function swapElems(context, itemdragend: IDrag) {
|
||||
console.log('PROJECT swapElems', itemdragend, stateglob.projects)
|
||||
|
||||
const myarr = Getters.getters.items_dacompletare(itemdragend.id_proj)
|
||||
const myarr = Getters.getters.projs_dacompletare(itemdragend.id_proj, itemdragend.mieiproj)
|
||||
|
||||
tools.swapGeneralElem(nametable, myarr, itemdragend, listFieldsToChange)
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ namespace Getters {
|
||||
}, 'getRecordEmpty')
|
||||
const items_dacompletare = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
||||
const indcat = getindexbycategory(cat)
|
||||
// console.log('items_dacompletare', 'indcat', indcat, state.todos[indcat])
|
||||
if (state.todos[indcat]) {
|
||||
return state.todos[indcat].filter((todo) => todo.statustodo !== tools.Status.COMPLETED)
|
||||
} else {
|
||||
|
||||
@@ -963,29 +963,28 @@ export const tools = {
|
||||
,
|
||||
|
||||
getIndexById(myarr, id) {
|
||||
if (myarr === undefined)
|
||||
return -1
|
||||
return myarr.indexOf(tools.getElemById(myarr, id))
|
||||
}
|
||||
,
|
||||
|
||||
getElemById(myarr, id) {
|
||||
if (myarr === undefined)
|
||||
return null
|
||||
// console.log('getElemById', myarr, id)
|
||||
return myarr.find((elem) => elem._id === id)
|
||||
}
|
||||
,
|
||||
|
||||
getElemPrevById(myarr, id) {
|
||||
if (myarr === undefined)
|
||||
return null
|
||||
return myarr.find((elem) => elem.id_prev === id)
|
||||
}
|
||||
,
|
||||
|
||||
getLastFirstElemPriority(myarr, priority
|
||||
:
|
||||
number, atfirst
|
||||
:
|
||||
boolean, escludiId
|
||||
:
|
||||
string
|
||||
) {
|
||||
getLastFirstElemPriority(myarr, priority: number, atfirst: boolean, escludiId: string) {
|
||||
if (myarr === null) {
|
||||
return -1
|
||||
}
|
||||
@@ -1052,9 +1051,13 @@ export const tools = {
|
||||
}
|
||||
,
|
||||
|
||||
getLastListNotCompleted(nametable, cat) {
|
||||
const module = tools.getModulesByTable(nametable)
|
||||
const arr = module.getters.items_dacompletare(cat)
|
||||
getLastListNotCompleted(nametable, cat, isproj = false, miei = false) {
|
||||
// const module = tools.getModulesByTable(nametable)
|
||||
let arr = []
|
||||
if (nametable === 'projects')
|
||||
arr = Projects.getters.projs_dacompletare(cat, miei)
|
||||
else if (nametable === 'todos')
|
||||
arr = Todos.getters.items_dacompletare(cat)
|
||||
|
||||
return (arr.length > 0) ? arr[arr.length - 1] : null
|
||||
}
|
||||
@@ -1272,9 +1275,10 @@ export const tools = {
|
||||
if (sortedList.length < linkedList.length) {
|
||||
console.log('!!!!! NON CI SONO TUTTI !!!!!', sortedList.length, linkedList.length)
|
||||
// Forget something not in a List !
|
||||
for (const itemsorted of sortedList) {
|
||||
if (linkedList.filter((item) => item._id === itemsorted._id)) {
|
||||
|
||||
for (const itemlinked of linkedList) {
|
||||
const elemtrov = sortedList.find((item) => item._id === itemlinked._id)
|
||||
if (elemtrov === undefined) {
|
||||
sortedList.push(itemlinked)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1308,7 +1312,7 @@ export const tools = {
|
||||
,
|
||||
|
||||
getstrDate(mytimestamp) {
|
||||
console.log('getstrDate', mytimestamp)
|
||||
// console.log('getstrDate', mytimestamp)
|
||||
if (!!mytimestamp)
|
||||
return date.formatDate(mytimestamp, 'DD/MM/YYYY')
|
||||
else
|
||||
@@ -1369,6 +1373,13 @@ export const tools = {
|
||||
|
||||
isMainProject(idproj) {
|
||||
return idproj === process.env.PROJECT_ID_MAIN
|
||||
},
|
||||
|
||||
getUrlByTipoProj(miei) {
|
||||
if (miei)
|
||||
return '/myprojects/'
|
||||
else
|
||||
return '/projects/'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user