Insert menu: "My Proj Shared" and when I insert a project, put the right property privacy

This commit is contained in:
Paolo Arena
2019-04-29 02:47:53 +02:00
parent d6d527e1a8
commit 166be747a5
11 changed files with 118 additions and 61 deletions

View File

@@ -11,6 +11,7 @@ import { CDate } from '../../CDate'
import { date } from 'quasar'
import { GlobalStore } from '@store'
import { RouteNames } from '@src/router/route-names'
@Component({
components: { SubMenusProj, CDate },
@@ -283,12 +284,16 @@ export default class SingleProject extends Vue {
return this.itemproject.userId === UserStore.state.userId
}
get tipoProj() {
return this.$route.name
}
get getrouteto() {
return tools.getUrlByTipoProj(this.isMyProject) + this.itemproject._id
return tools.getUrlByTipoProj(this.tipoProj) + this.itemproject._id
}
public goIntoTheProject() {
this.$router.replace(tools.getUrlByTipoProj(this.isMyProject) + this.itemproject._id)
this.$router.replace(tools.getUrlByTipoProj(this.tipoProj) + this.itemproject._id)
}
public editProject() {

View File

@@ -42,7 +42,7 @@ export interface IDrag {
category?: string
id_proj?: string
atfirst?: boolean
mieiproj?: boolean
tipoproj?: string
}
export interface ITodosState {

View File

@@ -97,8 +97,8 @@ export const routesList: IMyRouteConfig[] = [
// component: () => import('@/root/malaga/malaga.vue')
// },
{
path: '/' + RouteNames.projects + '/:idProj',
name: RouteNames.projects,
path: '/' + RouteNames.projectsall + '/:idProj',
name: RouteNames.projectsall,
component: () => import('@/views/projects/proj-list/proj-list.vue'),
meta: {
requiresAuth: false,
@@ -120,6 +120,18 @@ export const routesList: IMyRouteConfig[] = [
// middleware: [auth]
}
},
{
path: '/' + RouteNames.projectsshared + '/:idProj',
name: RouteNames.projectsshared,
component: () => import('@/views/projects/proj-list/proj-list.vue'),
meta: {
requiresAuth: true,
async asyncData() {
await Projects.actions.dbLoad({ checkPending: false, onlyiffirsttime: true })
}
// middleware: [auth]
}
},
{
path: '/' + RouteNames.listprojects,
name: RouteNames.listprojects,

View File

@@ -2,6 +2,7 @@ export const RouteNames = {
home: 'home',
login: 'login',
projects: 'projects',
projectsall: 'projall',
projectsshared: 'projectsShared',
myprojects: 'myprojects',
favouriteprojects: 'favproj',

View File

@@ -129,8 +129,9 @@ const messages = {
Test2: 'Test2',
projects: 'Progetti',
favproj: 'Favoriti',
projectsShared: 'Condivisi',
myprojects: 'Personali'
projall: 'Tutti',
projectsShared: 'Miei Condivisi',
myprojects: 'Miei Personali'
},
components: {
authentication: {
@@ -393,8 +394,9 @@ const messages = {
Test2: 'Test2',
projects: 'Proyectos',
favproj: 'Favoritos',
projectsShared: 'Compartidos',
myprojects: 'Personales',
projall: 'Todos',
projectsShared: 'Mis Compartidos',
myprojects: 'Mis Personales',
},
components: {
authentication: {
@@ -651,8 +653,9 @@ const messages = {
Test2: 'Test2',
projects: 'Projects',
favproj: 'Favorite',
projectsShared: 'Shared',
myprojects: 'Personals',
projall: 'All',
projectsShared: 'My Shared',
myprojects: 'My Personals',
},
components: {
authentication: {

View File

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

View File

@@ -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,13 +52,15 @@ 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 {
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 {
const getRecordEmpty = b.read((state: IProjectsState) => (): IProject => {
@@ -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)

View File

@@ -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
}

View File

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

View File

@@ -63,7 +63,7 @@ export default class ProjList extends Vue {
}
@Getter('projs_dacompletare', { namespace })
public projs_dacompletare: (state: IProjectsState, id_parent: string, miei: boolean) => IProject[]
public projs_dacompletare: (state: IProjectsState, id_parent: string, tipoproj: string) => IProject[]
@Watch('projs_dacompletare')
public changeitems() {
@@ -72,7 +72,7 @@ export default class ProjList extends Vue {
@Watch('$route.name')
public changename() {
console.log('tools.getUrlByTipoProj(this.areMyProjects)', tools.getUrlByTipoProj(this.areMyProjects))
console.log('tools.getUrlByTipoProj(this.tipoProj)', tools.getUrlByTipoProj(this.tipoProj))
this.changeparent()
}
@@ -98,9 +98,9 @@ export default class ProjList extends Vue {
// console.log('idproj', this.idProjAtt, 'params' , this.$route.params)
}
get areMyProjects() {
get tipoProj() {
// console.log('this.$route.name', this.$route.name)
return this.$route.name === RouteNames.myprojects
return this.$route.name
}
get readonly_PanelPrivacy() {
@@ -132,7 +132,7 @@ export default class ProjList extends Vue {
}
get getrouteup() {
return tools.getUrlByTipoProj(this.areMyProjects) + this.itemproj.id_parent
return tools.getUrlByTipoProj(this.tipoProj) + this.itemproj.id_parent
}
get tools() {
@@ -294,7 +294,7 @@ export default class ProjList extends Vue {
id_proj: this.idProjAtt,
newIndex: this.getElementIndex(args.el),
oldIndex: this.getElementOldIndex(args.el),
mieiproj: this.areMyProjects
tipoproj: this.tipoProj
}
// console.log('args', args, itemdragend)
@@ -373,13 +373,13 @@ export default class ProjList extends Vue {
this.projbottom = ''
return this.addProject(descr)
return this.addProject(descr, this.tipoProj)
}
public async clickMenuProjList(action) {
console.log('clickMenuProjList: ', action)
if (action === tools.MenuAction.ADD_PROJECT) {
const idnewelem = await this.addProject('')
const idnewelem = await this.addProject('', this.tipoProj)
// get element by id
const elem = this.getCompProjectById(idnewelem)
// @ts-ignore
@@ -412,15 +412,26 @@ export default class ProjList extends Vue {
// const descr = this.$t('project.newproj').toString()
public async addProject(descr) {
public async addProject(descr, tipoproj: string) {
const projatt = Projects.getters.getRecordById(this.idProjAtt)
const myobj: IProject = {
let myobj: IProject = null
if (this.idProjAtt === process.env.PROJECT_ID_MAIN) {
myobj = {
descr,
id_parent: this.idProjAtt,
privacyread: tools.getprivacyreadbytipoproj(tipoproj),
privacywrite: tools.getprivacywritebytipoproj(tipoproj),
actualphase: projatt.actualphase
}
} else {
myobj = {
descr,
id_parent: this.idProjAtt,
privacyread: projatt.privacyread,
privacywrite: projatt.privacywrite,
actualphase: projatt.actualphase
}
}
if (this.itemproj === undefined)
this.itemproj = projatt

View File

@@ -81,9 +81,9 @@
<div style="display: none">{{ prior = 0, priorcomplet = false }}</div>
<div>
<!--<q-infinite-scroll :handler="loadMoreTodo" :offset="7">-->
<div class="container" v-dragula="projs_dacompletare(idProjAtt, areMyProjects)" drake="second">
<div class="container" v-dragula="projs_dacompletare(idProjAtt, tipoProj)" drake="second">
<div :id="tools.getmyid(myproj._id)" :index="index"
v-for="(myproj, index) in projs_dacompletare(idProjAtt, areMyProjects)"
v-for="(myproj, index) in projs_dacompletare(idProjAtt, tipoProj)"
:key="myproj._id" class="myitemdrag">
<SingleProject ref="singleproject" @deleteItemproj="mydeleteitemproj(myproj._id)"
@@ -105,7 +105,7 @@
color="blue-12"
:label="$t('proj.insertbottom')"
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
v-on:keyup.enter="dbInsert(false)">
v-on:keyup.enter="dbInsert()">
</q-input>