Insert menu: "My Proj Shared" and when I insert a project, put the right property privacy
This commit is contained in:
@@ -138,9 +138,9 @@ namespace Getters {
|
||||
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)
|
||||
arrlistaprojtutti = Projects.getters.listaprojects(RouteNames.projectsall)
|
||||
arrlistaprojmiei = Projects.getters.listaprojects(RouteNames.myprojects)
|
||||
arrlistafavourite = Projects.getters.listaprojects(RouteNames.favouriteprojects)
|
||||
}
|
||||
|
||||
const arrMenu: IMenuList[] = []
|
||||
@@ -158,11 +158,22 @@ namespace Getters {
|
||||
})
|
||||
}
|
||||
|
||||
// PROGETTI -> TUTTI :
|
||||
arrMenu.push({
|
||||
icon: '',
|
||||
nametranslate: 'pages.' + RouteNames.projectsall,
|
||||
urlroute: RouteNames.projectsall,
|
||||
level_parent: 0.0,
|
||||
level_child: 0.5,
|
||||
routes2: [],
|
||||
idelem: process.env.PROJECT_ID_MAIN
|
||||
})
|
||||
|
||||
// PROGETTI -> CONDIVISI :
|
||||
arrMenu.push({
|
||||
icon: '',
|
||||
nametranslate: 'pages.' + RouteNames.projectsshared,
|
||||
urlroute: 'projects',
|
||||
urlroute: RouteNames.projectsshared,
|
||||
level_parent: 0.0,
|
||||
level_child: 0.5,
|
||||
routes2: arrlistaprojtutti,
|
||||
@@ -173,7 +184,7 @@ namespace Getters {
|
||||
arrMenu.push({
|
||||
icon: '',
|
||||
nametranslate: 'pages.' + RouteNames.myprojects,
|
||||
urlroute: 'myprojects',
|
||||
urlroute: RouteNames.myprojects,
|
||||
level_parent: 0.0,
|
||||
level_child: 0.5,
|
||||
routes2: arrlistaprojmiei,
|
||||
@@ -431,11 +442,11 @@ namespace Actions {
|
||||
const mykey = process.env.PUBLICKEY_PUSH
|
||||
const mystate = state
|
||||
return navigator.serviceWorker.ready
|
||||
.then(function (swreg) {
|
||||
.then((swreg) => {
|
||||
reg = swreg
|
||||
return swreg.pushManager.getSubscription()
|
||||
})
|
||||
.then(function (subscription) {
|
||||
.then((subscription) => {
|
||||
mystate.wasAlreadySubscribed = !(subscription === null)
|
||||
|
||||
if (mystate.wasAlreadySubscribed) {
|
||||
@@ -452,10 +463,10 @@ namespace Actions {
|
||||
})
|
||||
}
|
||||
})
|
||||
.then(function (newSub) {
|
||||
.then((newSub) => {
|
||||
saveNewSubscriptionToServer(context, newSub)
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch((err) => {
|
||||
console.log('ERR createPushSubscription:', err)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { GlobalStore, UserStore } from '@store'
|
||||
import globalroutines from './../../globalroutines/index'
|
||||
import objectId from '@src/js/objectId'
|
||||
import { costanti } from '@src/store/Modules/costanti'
|
||||
import { RouteNames } from '@src/router/route-names'
|
||||
|
||||
const nametable = 'projects'
|
||||
|
||||
@@ -51,12 +52,14 @@ function updateDataCalculated(projout, projin) {
|
||||
})
|
||||
}
|
||||
|
||||
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)))
|
||||
}
|
||||
function getproj(projects, idproj, tipoproj: string) {
|
||||
|
||||
if (tipoproj === RouteNames.myprojects)
|
||||
return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId === UserStore.state.userId) && (proj.privacyread === Privacy.onlyme)))
|
||||
else if (tipoproj === RouteNames.projectsshared)
|
||||
return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId === UserStore.state.userId) && (proj.privacyread !== Privacy.onlyme)))
|
||||
else if (tipoproj === RouteNames.projectsall)
|
||||
return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId !== UserStore.state.userId) ))
|
||||
}
|
||||
|
||||
namespace Getters {
|
||||
@@ -101,20 +104,20 @@ namespace Getters {
|
||||
return obj
|
||||
}, 'getRecordEmpty')
|
||||
|
||||
const projs_dacompletare = b.read((state: IProjectsState) => (id_parent: string, miei: boolean): IProject[] => {
|
||||
const projs_dacompletare = b.read((state: IProjectsState) => (id_parent: string, tipoproj: string): IProject[] => {
|
||||
// console.log('projs_dacompletare', miei)
|
||||
if (state.projects) {
|
||||
// console.log('state.projects', state.projects)
|
||||
return getproj(state.projects, id_parent, miei, false)
|
||||
return getproj(state.projects, id_parent, tipoproj)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}, 'projs_dacompletare')
|
||||
|
||||
const listaprojects = b.read((state: IProjectsState) => (miei: boolean, favourite: boolean): IMenuList[] => {
|
||||
const listaprojects = b.read((state: IProjectsState) => (tipoproj: string): IMenuList[] => {
|
||||
if (state.projects) {
|
||||
// console.log('state.projects', state.projects)
|
||||
const listaproj = getproj(state.projects, process.env.PROJECT_ID_MAIN, miei, favourite)
|
||||
const listaproj = getproj(state.projects, process.env.PROJECT_ID_MAIN, tipoproj)
|
||||
const myarr: IMenuList[] = []
|
||||
for (const proj of listaproj) {
|
||||
myarr.push({ nametranslate: '', description: proj.descr, idelem: proj._id })
|
||||
@@ -350,7 +353,7 @@ namespace Actions {
|
||||
} else {
|
||||
console.log('INSERT AT THE BOTTOM')
|
||||
// INSERT AT THE BOTTOM , so GET LAST ITEM
|
||||
const lastelem = tools.getLastListNotCompleted(nametable, objproj.id_parent)
|
||||
const lastelem = tools.getLastListNotCompleted(nametable, objproj.id_parent, this.tipoProj)
|
||||
|
||||
objproj.id_prev = (!!lastelem) ? lastelem._id : ApiTables.LIST_START
|
||||
}
|
||||
@@ -385,7 +388,7 @@ namespace Actions {
|
||||
async function swapElems(context, itemdragend: IDrag) {
|
||||
console.log('PROJECT swapElems', itemdragend, stateglob.projects)
|
||||
|
||||
const myarr = Getters.getters.projs_dacompletare(itemdragend.id_proj, itemdragend.mieiproj)
|
||||
const myarr = Getters.getters.projs_dacompletare(itemdragend.id_proj, itemdragend.tipoproj)
|
||||
|
||||
tools.swapGeneralElem(nametable, myarr, itemdragend, listFieldsToChange)
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace Actions {
|
||||
} else {
|
||||
console.log('INSERT AT THE BOTTOM')
|
||||
// INSERT AT THE BOTTOM , so GET LAST ITEM
|
||||
const lastelem = tools.getLastListNotCompleted(nametable, objtodo.category)
|
||||
const lastelem = tools.getLastListNotCompleted(nametable, objtodo.category, this.tipoProj)
|
||||
|
||||
objtodo.id_prev = (!!lastelem) ? lastelem._id : ApiTables.LIST_START
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import Quasar, { date } from 'quasar'
|
||||
import { IListRoutes, IMenuList, IProject, ITodo, Privacy } from '@src/model'
|
||||
import * as ApiTables from '@src/store/Modules/ApiTables'
|
||||
import translate from '@src/globalroutines/util'
|
||||
import { RouteNames } from '@src/router/route-names'
|
||||
|
||||
export interface INotify {
|
||||
color?: string | 'primary'
|
||||
@@ -1185,17 +1186,19 @@ export const tools = {
|
||||
}
|
||||
,
|
||||
|
||||
getLastListNotCompleted(nametable, cat, isproj = false, miei = false) {
|
||||
getLastListNotCompleted(nametable, cat, tipoproj: string) {
|
||||
// const module = tools.getModulesByTable(nametable)
|
||||
let arr = []
|
||||
if (nametable === 'projects')
|
||||
arr = Projects.getters.projs_dacompletare(cat, miei)
|
||||
arr = Projects.getters.projs_dacompletare(cat, tipoproj)
|
||||
else if (nametable === 'todos')
|
||||
arr = Todos.getters.items_dacompletare(cat)
|
||||
|
||||
return (arr.length > 0) ? arr[arr.length - 1] : null
|
||||
}
|
||||
,
|
||||
if (!!arr)
|
||||
return (arr.length > 0) ? arr[arr.length - 1] : null
|
||||
else
|
||||
return null
|
||||
},
|
||||
|
||||
getElemByIndex(myarr, index) {
|
||||
if (index >= 0 && index < myarr.length) {
|
||||
@@ -1509,14 +1512,11 @@ export const tools = {
|
||||
return idproj === process.env.PROJECT_ID_MAIN
|
||||
},
|
||||
|
||||
getUrlByTipoProj(miei, name?: string) {
|
||||
getUrlByTipoProj(tipoproj, name?: string) {
|
||||
if (!!name)
|
||||
return '/' + name + '/'
|
||||
|
||||
if (miei)
|
||||
return '/myprojects/'
|
||||
else
|
||||
return '/projects/'
|
||||
return '/' + tipoproj + '/'
|
||||
},
|
||||
|
||||
convertMenuListInListRoutes(arrlista: IMenuList[]) {
|
||||
@@ -1540,4 +1540,15 @@ export const tools = {
|
||||
return lista
|
||||
},
|
||||
|
||||
getprivacyreadbytipoproj(tipoproj) {
|
||||
if (tipoproj === RouteNames.myprojects)
|
||||
return Privacy.onlyme
|
||||
else
|
||||
return Privacy.all
|
||||
},
|
||||
|
||||
getprivacywritebytipoproj(tipoproj) {
|
||||
return Privacy.onlyme
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user