- other committ
This commit is contained in:
@@ -46,7 +46,7 @@ async function dbInsertSave(call, item, method) {
|
||||
|
||||
console.log('dbInsertSave', item, method)
|
||||
|
||||
if (UserStore.state.userId === '') {
|
||||
if (UserStore.getters.isUserInvalid) {
|
||||
return false
|
||||
} // Login not made
|
||||
|
||||
@@ -76,7 +76,7 @@ async function dbDeleteItem(call, item) {
|
||||
|
||||
if (!('serviceWorker' in navigator)) {
|
||||
// console.log('dbdeleteItem', item)
|
||||
if (UserStore.state.userId === '') {
|
||||
if (UserStore.getters.isUserInvalid) {
|
||||
return false
|
||||
} // Login not made
|
||||
|
||||
@@ -234,6 +234,7 @@ async function checkPendingMsg() {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// ...
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import globalroutines from './../../globalroutines/index'
|
||||
|
||||
|
||||
import { cfgrouter } from '../../router/route-config'
|
||||
// import { static_data } from '@src/db/static_data'
|
||||
|
||||
let stateConnDefault = 'online'
|
||||
|
||||
@@ -291,6 +292,10 @@ namespace Actions {
|
||||
// return
|
||||
// }
|
||||
|
||||
// if (!static_data.functionality.PWA) {
|
||||
// return
|
||||
// }
|
||||
|
||||
if (!('serviceWorker' in navigator)) {
|
||||
return
|
||||
}
|
||||
@@ -337,11 +342,15 @@ namespace Actions {
|
||||
// Calling the Server to Save in the MongoDB the Subscriber
|
||||
function saveNewSubscriptionToServer(context, newSub) {
|
||||
// If already subscribed, exit
|
||||
if (true) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!newSub) {
|
||||
return
|
||||
}
|
||||
|
||||
if (UserStore.state.userId === undefined || UserStore.state.tokens[0] === undefined) {
|
||||
if (UserStore.getters.isUserInvalid) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -58,14 +58,19 @@ function updateDataCalculated(projout, projin) {
|
||||
}
|
||||
|
||||
function getproj(projects, idproj, tipoproj: string) {
|
||||
console.log('getproj', tipoproj)
|
||||
|
||||
let ris = null
|
||||
|
||||
if (tipoproj === RouteNames.myprojects)
|
||||
return projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId === UserStore.state.userId) && (proj.privacyread === Privacy.onlyme))
|
||||
ris = projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId === UserStore.state.userId) && (proj.privacyread === Privacy.onlyme))
|
||||
else if (tipoproj === RouteNames.projectsshared)
|
||||
return projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId === UserStore.state.userId) && (proj.privacyread !== Privacy.onlyme))
|
||||
ris = projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId === UserStore.state.userId) && (proj.privacyread !== Privacy.onlyme))
|
||||
else if (tipoproj === RouteNames.projectsall)
|
||||
return projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId !== UserStore.state.userId) )
|
||||
ris = projects.filter((proj) => (proj.id_parent === idproj) && (proj.userId !== UserStore.state.userId) )
|
||||
|
||||
// console.log('idproj', idproj, 'projects', projects, 'getproj', tipoproj, 'ris=', ris)
|
||||
|
||||
return ris
|
||||
}
|
||||
|
||||
namespace Getters {
|
||||
@@ -115,7 +120,7 @@ namespace Getters {
|
||||
const projs_dacompletare = b.read((state: IProjectsState) => (id_parent: string, tipoproj: string): IProject[] => {
|
||||
// console.log('projs_dacompletare')
|
||||
if (state.projects) {
|
||||
// console.log('state.projects', state.projects)
|
||||
// console.log('projs_dacompletare', state.projects)
|
||||
return getproj(state.projects, id_parent, tipoproj)
|
||||
} else {
|
||||
return []
|
||||
@@ -130,7 +135,7 @@ namespace Getters {
|
||||
for (const proj of listaproj) {
|
||||
myarr.push({ nametranslate: '', description: proj.descr, idelem: proj._id })
|
||||
}
|
||||
// console.log(' myarr', myarr, listaproj)
|
||||
console.log(' myarr', myarr, listaproj)
|
||||
return myarr
|
||||
|
||||
} else {
|
||||
@@ -274,7 +279,7 @@ namespace Actions {
|
||||
|
||||
async function dbLoad(context, { checkPending, onlyiffirsttime }) {
|
||||
|
||||
if (!static_data.ENABLE_PROJECTS_LOADING)
|
||||
if (!static_data.functionality.ENABLE_PROJECTS_LOADING)
|
||||
return null
|
||||
|
||||
if (onlyiffirsttime) {
|
||||
@@ -442,7 +447,6 @@ namespace Actions {
|
||||
modify: b.dispatch(modify),
|
||||
ActionCutPaste: b.dispatch(ActionCutPaste)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Module
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Api from '@api'
|
||||
import { ICalendarState } from 'model'
|
||||
import { IBookedEvent, ICalendarState, IEvents } from 'model'
|
||||
import { ILinkReg, IResult, IIdToken, IToken } from 'model/other'
|
||||
import { storeBuilder } from '../Store'
|
||||
|
||||
@@ -8,9 +8,15 @@ import { tools } from '../../tools'
|
||||
|
||||
import translate from '../../../../globalroutines/util'
|
||||
import * as Types from '../../../Api/ApiTypes'
|
||||
import { db_data } from '@src/db/db_data'
|
||||
import { UserStore } from '@store'
|
||||
|
||||
// State
|
||||
const state: ICalendarState = {
|
||||
editable: false,
|
||||
eventlist: [],
|
||||
bookedevent: [],
|
||||
// ---------------
|
||||
titlebarHeight: 0,
|
||||
locale: 'it-IT',
|
||||
maxDays: 1,
|
||||
@@ -24,7 +30,7 @@ const state: ICalendarState = {
|
||||
noScroll: false,
|
||||
showMonthLabel: false,
|
||||
showWorkWeeks: false,
|
||||
intervalRange: {min: 9, max: 23},
|
||||
intervalRange: { min: 9, max: 23 },
|
||||
intervalRangeStep: 1,
|
||||
intervalHeight: 35,
|
||||
resourceHeight: 60,
|
||||
@@ -39,19 +45,15 @@ const stateGetter = b.state()
|
||||
|
||||
namespace Getters {
|
||||
|
||||
// const lang = b.read((state) => {
|
||||
// if (state.lang !== '') {
|
||||
// return state.lang
|
||||
// } else {
|
||||
// return process.env.LANG_DEFAULT
|
||||
// }
|
||||
// }, 'lang')
|
||||
//
|
||||
// export const getters = {
|
||||
// get lang() {
|
||||
// return lang()
|
||||
// },
|
||||
// }
|
||||
const findEventBooked = b.read((mystate: ICalendarState) => (myevent: IEvents, isconfirmed: boolean) => {
|
||||
return mystate.bookedevent.find((bookedevent) => (bookedevent.id_bookedevent === myevent._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed)))
|
||||
}, 'findEventBooked')
|
||||
|
||||
export const getters = {
|
||||
get findEventBooked() {
|
||||
return findEventBooked()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +69,110 @@ namespace Mutations {
|
||||
}
|
||||
|
||||
namespace Actions {
|
||||
async function loadAfterLogin(context) {
|
||||
console.log('CalendarStore: loadAfterLogin')
|
||||
// Load local data
|
||||
state.editable = db_data.userdata.calendar_editable
|
||||
state.eventlist = db_data.events
|
||||
// state.bookedevent = db_data.userdata.bookedevent
|
||||
|
||||
if (UserStore.getters.isUserInvalid) {
|
||||
state.bookedevent = []
|
||||
return false
|
||||
}
|
||||
|
||||
// Load local data
|
||||
console.log('CALENDAR loadAfterLogin', 'userid=', UserStore.state.userId)
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/booking/' + UserStore.state.userId + '/' + process.env.APP_ID, 'GET', null)
|
||||
.then((res) => {
|
||||
if (res.data.bookedevent) {
|
||||
state.bookedevent = res.data.bookedevent
|
||||
} else {
|
||||
state.bookedevent = []
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error dbLoad', error)
|
||||
// UserStore.mutations.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, tools.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
return ris
|
||||
|
||||
}
|
||||
|
||||
function getparambyevent(bookevent) {
|
||||
return {
|
||||
id_bookedevent: bookevent.id_bookedevent,
|
||||
infoevent: bookevent.infoevent,
|
||||
numpeople: bookevent.numpeople,
|
||||
msgbooking: bookevent.msgbooking,
|
||||
datebooked: bookevent.datebooked,
|
||||
userId: UserStore.state.userId,
|
||||
booked: bookevent.booked,
|
||||
}
|
||||
}
|
||||
|
||||
async function BookEvent(context, bookevent: IBookedEvent) {
|
||||
console.log('BookEvent', bookevent)
|
||||
|
||||
const param = getparambyevent(bookevent)
|
||||
|
||||
return await Api.SendReq('/booking', 'POST', param)
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
if (res.data.code === serv_constants.RIS_CODE_OK) {
|
||||
state.bookedevent.push(bookevent)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
return false
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async function CancelBookingEvent(context, event: IEvents) {
|
||||
console.log('CALSTORE: CancelBookingEvent', event)
|
||||
|
||||
const myeventtoCancel = state.bookedevent.find((eventbooked) => (eventbooked.id_bookedevent === event._id))
|
||||
|
||||
const param = getparambyevent(myeventtoCancel)
|
||||
param.booked = false // Cancel Booking
|
||||
|
||||
return await Api.SendReq('/booking', 'POST', param)
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
if (res.data.code === serv_constants.RIS_CODE_OK) {
|
||||
|
||||
state.bookedevent = state.bookedevent.filter((eventbooked) => (eventbooked.id_bookedevent !== event._id))
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
// UserStore.mutations.setErrorCatch(error)
|
||||
return false
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
loadAfterLogin: b.dispatch(loadAfterLogin),
|
||||
BookEvent: b.dispatch(BookEvent),
|
||||
CancelBookingEvent: b.dispatch(CancelBookingEvent)
|
||||
}
|
||||
|
||||
// async function resetpwd(context, paramquery: ICalendarState) {
|
||||
// }
|
||||
@@ -80,9 +186,9 @@ namespace Actions {
|
||||
const CalendarModule = {
|
||||
get state() {
|
||||
return stateGetter()
|
||||
}
|
||||
// actions: Actions.actions,
|
||||
// getters: Getters.getters,
|
||||
},
|
||||
actions: Actions.actions,
|
||||
getters: Getters.getters
|
||||
// mutations: Mutations.mutations
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ function getindexbycategory(category: string) {
|
||||
return state.categories.indexOf(category)
|
||||
}
|
||||
|
||||
function gettodosByCategory(category: string): [] {
|
||||
function gettodosByCategory(category: string): any[] {
|
||||
const indcat = state.categories.indexOf(category)
|
||||
if (!state.todos[indcat]) {
|
||||
return []
|
||||
@@ -109,8 +109,8 @@ namespace Getters {
|
||||
}, 'items_dacompletare')
|
||||
|
||||
const todos_completati = b.read((stateparam: ITodosState) => (cat: string): ITodo[] => {
|
||||
console.log('todos_completati')
|
||||
const indcat = getindexbycategory(cat)
|
||||
console.log('todos_completati', cat, 'indcat=', indcat, 'state.categories=', state.categories)
|
||||
if (stateparam.todos[indcat]) {
|
||||
let arrout = []
|
||||
if (stateparam.showtype === costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED) { // Show only the first N completed
|
||||
@@ -126,6 +126,8 @@ namespace Getters {
|
||||
arrout = []
|
||||
}
|
||||
|
||||
console.log('arrout', arrout)
|
||||
|
||||
return arrout
|
||||
// return tools.mapSort(arrout)
|
||||
|
||||
@@ -253,7 +255,7 @@ namespace Actions {
|
||||
|
||||
async function dbLoad(context, { checkPending }) {
|
||||
|
||||
if (!static_data.ENABLE_PROJECTS_LOADING)
|
||||
if (!static_data.functionality.ENABLE_PROJECTS_LOADING)
|
||||
return null
|
||||
|
||||
console.log('dbLoad', nametable, checkPending, 'userid=', UserStore.state.userId)
|
||||
|
||||
@@ -7,9 +7,11 @@ import router from '@router'
|
||||
import { serv_constants } from '../Modules/serv_constants'
|
||||
import { tools } from '../Modules/tools'
|
||||
import { toolsext } from '@src/store/Modules/toolsext'
|
||||
import { GlobalStore, UserStore, Todos, Projects } from '@store'
|
||||
import { GlobalStore, UserStore, Todos, Projects, BookingStore, CalendarStore } from '@store'
|
||||
import globalroutines from './../../globalroutines/index'
|
||||
|
||||
import { static_data } from '@src/db/static_data'
|
||||
|
||||
import translate from './../../globalroutines/util'
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
|
||||
@@ -20,6 +22,8 @@ const state: IUserState = {
|
||||
userId: '',
|
||||
email: '',
|
||||
username: '',
|
||||
name: '',
|
||||
surname: '',
|
||||
password: '',
|
||||
lang: process.env.LANG_DEFAULT,
|
||||
repeatPassword: '',
|
||||
@@ -33,13 +37,22 @@ const state: IUserState = {
|
||||
}
|
||||
|
||||
const b = storeBuilder.module<IUserState>('UserModule', state)
|
||||
const stateGetter = b.state()
|
||||
|
||||
namespace Getters {
|
||||
// const fullName = b.read(function fullName(state): string {
|
||||
// return state.userInfos.firstname?capitalize(state.userInfos.firstname) + " " + capitalize(state.userInfos.lastname):null;
|
||||
// })
|
||||
|
||||
const isUserInvalid = b.read((mystate) => {
|
||||
try {
|
||||
const ris = (mystate.userId === undefined) || (mystate.userId.trim() === '') || (mystate.tokens[0] === undefined)
|
||||
// console.log('state.userId', state.userId, 'ris', ris)
|
||||
return ris
|
||||
} catch (e) {
|
||||
return true
|
||||
}
|
||||
}, 'isUserInvalid')
|
||||
|
||||
const lang = b.read((state) => {
|
||||
if (state.lang !== '') {
|
||||
return state.lang
|
||||
@@ -81,6 +94,9 @@ namespace Getters {
|
||||
}, 'IsMyGroup')
|
||||
|
||||
export const getters = {
|
||||
get isUserInvalid() {
|
||||
return isUserInvalid()
|
||||
},
|
||||
get lang() {
|
||||
return lang()
|
||||
},
|
||||
@@ -108,6 +124,8 @@ namespace Mutations {
|
||||
function authUser(state: IUserState, data: IUserState) {
|
||||
state.userId = data.userId
|
||||
state.username = data.username
|
||||
state.name = data.name
|
||||
state.surname = data.surname
|
||||
if (data.verified_email) {
|
||||
state.verified_email = data.verified_email
|
||||
}
|
||||
@@ -138,6 +156,7 @@ namespace Mutations {
|
||||
function setlang(state: IUserState, newstr: string) {
|
||||
console.log('SETLANG', newstr)
|
||||
state.lang = newstr
|
||||
tools.setLangAtt(newstr)
|
||||
localStorage.setItem(tools.localStorage.lang, state.lang)
|
||||
}
|
||||
|
||||
@@ -176,6 +195,8 @@ namespace Mutations {
|
||||
function clearAuthData(state: IUserState) {
|
||||
state.userId = ''
|
||||
state.username = ''
|
||||
state.name = ''
|
||||
state.surname = ''
|
||||
resetArrToken(state.tokens)
|
||||
state.x_auth_token = ''
|
||||
state.verified_email = false
|
||||
@@ -221,7 +242,6 @@ namespace Mutations {
|
||||
setErrorCatch: b.commit(setErrorCatch),
|
||||
getMsgError: b.commit(getMsgError)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace Actions {
|
||||
@@ -318,6 +338,8 @@ namespace Actions {
|
||||
email: authData.email,
|
||||
password: String(hashedPassword),
|
||||
username: authData.username,
|
||||
name: authData.name,
|
||||
surname: authData.surname
|
||||
}
|
||||
|
||||
console.log(usertosend)
|
||||
@@ -336,6 +358,8 @@ namespace Actions {
|
||||
if (res.status === 200) {
|
||||
const userId = newuser._id
|
||||
const username = authData.username
|
||||
const name = authData.name
|
||||
const surname = authData.surname
|
||||
if (process.env.DEV) {
|
||||
console.log('USERNAME = ' + username)
|
||||
console.log('IDUSER= ' + userId)
|
||||
@@ -344,6 +368,8 @@ namespace Actions {
|
||||
Mutations.mutations.authUser({
|
||||
userId,
|
||||
username,
|
||||
name,
|
||||
surname,
|
||||
verified_email: false
|
||||
})
|
||||
|
||||
@@ -353,6 +379,8 @@ namespace Actions {
|
||||
localStorage.setItem(tools.localStorage.lang, state.lang)
|
||||
localStorage.setItem(tools.localStorage.userId, userId)
|
||||
localStorage.setItem(tools.localStorage.username, username)
|
||||
localStorage.setItem(tools.localStorage.name, name)
|
||||
localStorage.setItem(tools.localStorage.surname, surname)
|
||||
localStorage.setItem(tools.localStorage.token, state.x_auth_token)
|
||||
localStorage.setItem(tools.localStorage.expirationDate, expirationDate.toString())
|
||||
localStorage.setItem(tools.localStorage.verified_email, String(false))
|
||||
@@ -380,16 +408,19 @@ namespace Actions {
|
||||
let sub = null
|
||||
|
||||
try {
|
||||
if ('serviceWorker' in navigator) {
|
||||
sub = await navigator.serviceWorker.ready
|
||||
.then(function (swreg) {
|
||||
console.log('swreg')
|
||||
const sub = swreg.pushManager.getSubscription()
|
||||
return sub
|
||||
})
|
||||
.catch((e) => {
|
||||
sub = null
|
||||
})
|
||||
if (static_data.functionality.PWA) {
|
||||
if ('serviceWorker' in navigator) {
|
||||
sub = await navigator.serviceWorker.ready
|
||||
.then((swreg) => {
|
||||
console.log('swreg')
|
||||
sub = swreg.pushManager.getSubscription()
|
||||
return sub
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(' ERROR ')
|
||||
sub = null
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Err navigator.serviceWorker.ready ... GetSubscription:', e)
|
||||
@@ -409,7 +440,6 @@ namespace Actions {
|
||||
options
|
||||
}
|
||||
|
||||
// console.log('PASSO 4')
|
||||
if (process.env.DEBUG === '1') {
|
||||
console.log(usertosend)
|
||||
}
|
||||
@@ -418,7 +448,7 @@ namespace Actions {
|
||||
|
||||
let myres: any
|
||||
|
||||
console.log('Api.SendReq')
|
||||
// console.log('Api.SendReq')
|
||||
|
||||
return Api.SendReq('/users/login', 'POST', usertosend, true)
|
||||
.then((res) => {
|
||||
@@ -438,11 +468,15 @@ namespace Actions {
|
||||
if (myuser) {
|
||||
const userId = myuser.userId
|
||||
const username = authData.username
|
||||
const name = myuser.name
|
||||
const surname = myuser.surname
|
||||
const verified_email = myuser.verified_email
|
||||
|
||||
Mutations.mutations.authUser({
|
||||
userId,
|
||||
username,
|
||||
name,
|
||||
surname,
|
||||
verified_email
|
||||
})
|
||||
|
||||
@@ -452,6 +486,8 @@ namespace Actions {
|
||||
localStorage.setItem(tools.localStorage.lang, state.lang)
|
||||
localStorage.setItem(tools.localStorage.userId, userId)
|
||||
localStorage.setItem(tools.localStorage.username, username)
|
||||
localStorage.setItem(tools.localStorage.name, name)
|
||||
localStorage.setItem(tools.localStorage.surname, surname)
|
||||
localStorage.setItem(tools.localStorage.token, state.x_auth_token)
|
||||
localStorage.setItem(tools.localStorage.expirationDate, expirationDate.toString())
|
||||
localStorage.setItem(tools.localStorage.isLogged, String(true))
|
||||
@@ -486,6 +522,8 @@ namespace Actions {
|
||||
localStorage.removeItem(tools.localStorage.token)
|
||||
localStorage.removeItem(tools.localStorage.userId)
|
||||
localStorage.removeItem(tools.localStorage.username)
|
||||
localStorage.removeItem(tools.localStorage.name)
|
||||
localStorage.removeItem(tools.localStorage.surname)
|
||||
localStorage.removeItem(tools.localStorage.isLogged)
|
||||
// localStorage.removeItem(rescodes.localStorage.leftDrawerOpen)
|
||||
localStorage.removeItem(tools.localStorage.verified_email)
|
||||
@@ -512,6 +550,7 @@ namespace Actions {
|
||||
}
|
||||
|
||||
async function setGlobal(isLogged: boolean) {
|
||||
console.log('setGlobal')
|
||||
// state.isLogged = true
|
||||
state.isLogged = isLogged
|
||||
if (isLogged) {
|
||||
@@ -522,12 +561,18 @@ namespace Actions {
|
||||
GlobalStore.actions.checkUpdates()
|
||||
}
|
||||
|
||||
return await GlobalStore.actions.loadAfterLogin()
|
||||
.then(() => {
|
||||
return Todos.actions.dbLoad({ checkPending: true })
|
||||
}).then(() => {
|
||||
return Projects.actions.dbLoad({ checkPending: true, onlyiffirsttime: true })
|
||||
})
|
||||
const p = await BookingStore.actions.loadAfterLogin()
|
||||
const p2 = await CalendarStore.actions.loadAfterLogin()
|
||||
|
||||
const p3 = await GlobalStore.actions.loadAfterLogin()
|
||||
|
||||
if (static_data.functionality.ENABLE_TODOS_LOADING)
|
||||
await Todos.actions.dbLoad({ checkPending: true })
|
||||
|
||||
if (static_data.functionality.ENABLE_PROJECTS_LOADING)
|
||||
await Projects.actions.dbLoad({ checkPending: true, onlyiffirsttime: true })
|
||||
|
||||
console.log('setGlobal: END')
|
||||
}
|
||||
|
||||
async function autologin_FromLocalStorage(context) {
|
||||
@@ -547,6 +592,8 @@ namespace Actions {
|
||||
if (now < expirationDate) {
|
||||
const userId = String(localStorage.getItem(tools.localStorage.userId))
|
||||
const username = String(localStorage.getItem(tools.localStorage.username))
|
||||
const name = String(localStorage.getItem(tools.localStorage.name))
|
||||
const surname = String(localStorage.getItem(tools.localStorage.surname))
|
||||
const verified_email = localStorage.getItem(tools.localStorage.verified_email) === 'true'
|
||||
|
||||
GlobalStore.state.wasAlreadySubOnDb = localStorage.getItem(tools.localStorage.wasAlreadySubOnDb) === 'true'
|
||||
@@ -558,6 +605,8 @@ namespace Actions {
|
||||
Mutations.mutations.authUser({
|
||||
userId,
|
||||
username,
|
||||
name,
|
||||
surname,
|
||||
verified_email
|
||||
})
|
||||
|
||||
@@ -603,6 +652,8 @@ namespace Actions {
|
||||
}
|
||||
}
|
||||
|
||||
const stateGetter = b.state()
|
||||
|
||||
// Module
|
||||
const UserModule = {
|
||||
get state() {
|
||||
|
||||
@@ -10,5 +10,9 @@ export const costanti = {
|
||||
CONFIG_ID_STATE_CONN: '2',
|
||||
CONFIG_ID_SHOW_TYPE_TODOS: '3',
|
||||
|
||||
FuncDialog: {
|
||||
CANCEL_BOOKING: 1
|
||||
},
|
||||
|
||||
MAX_PHASES: 5,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export {storeBuilder} from './Store/Store'
|
||||
export {default as GlobalStore} from './GlobalStore'
|
||||
export {default as BookingStore} from './BookingStore'
|
||||
export {default as UserStore} from './UserStore'
|
||||
export {default as Todos} from './Todos'
|
||||
export {default as Projects} from './Projects'
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Todos, Projects, UserStore } from '@store'
|
||||
import { Todos, Projects, UserStore, CalendarStore } from '@store'
|
||||
import globalroutines from './../../globalroutines/index'
|
||||
import { costanti } from './costanti'
|
||||
import { toolsext } from './toolsext'
|
||||
import { translation } from './translation'
|
||||
import Quasar, { date, Screen } from 'quasar'
|
||||
import { ICollaborations, IListRoutes, IMenuList, IProject, ITodo, Privacy } from '@src/model'
|
||||
import { ICollaborations, IListRoutes, IMenuList, IParamDialog, 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'
|
||||
@@ -12,6 +12,7 @@ import { RouteNames } from '@src/router/route-names'
|
||||
import { lists } from './lists'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import { IColl, ITimeLineEntry, ITimeLineMain } from '@src/model/GlobalStore'
|
||||
import { func_tools } from '@src/store/Modules/toolsext'
|
||||
|
||||
export interface INotify {
|
||||
color?: string | 'primary'
|
||||
@@ -55,6 +56,8 @@ export const tools = {
|
||||
userId: 'uid',
|
||||
token: 'tk',
|
||||
username: 'uname',
|
||||
name: 'nm',
|
||||
surname: 'sn',
|
||||
lang: 'lg'
|
||||
},
|
||||
|
||||
@@ -70,6 +73,35 @@ export const tools = {
|
||||
COMPLETED: 10
|
||||
},
|
||||
|
||||
SelectListNumPeople: [
|
||||
{
|
||||
id: 1,
|
||||
label: '1',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: '2',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
label: '3',
|
||||
value: 3
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
label: '4',
|
||||
value: 4
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
label: '5',
|
||||
value: 5
|
||||
}
|
||||
]
|
||||
,
|
||||
|
||||
selectPhase: {
|
||||
it: [
|
||||
{
|
||||
@@ -1267,8 +1299,48 @@ export const tools = {
|
||||
result.push(json[key])
|
||||
})
|
||||
return result
|
||||
}
|
||||
,
|
||||
},
|
||||
|
||||
executefunc(myself: any, myfunc: number, par: IParamDialog) {
|
||||
if (myfunc === costanti.FuncDialog.CANCEL_BOOKING) {
|
||||
console.log(' ENTRATO ! CancelBookingEvent ')
|
||||
CalendarStore.actions.CancelBookingEvent(par.param1).then((ris) => {
|
||||
if (ris)
|
||||
tools.showPositiveNotif(myself.$q, myself.$t('cal.canceledbooking') + ' "' + par.param1.title + '"')
|
||||
else
|
||||
tools.showNegativeNotif(myself.$q, myself.$t('cal.cancelederrorbooking'))
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async askConfirm($q: any, mytitle, mytext, ok, cancel, myself: any, funcok: number, funccancel: number, par: IParamDialog) {
|
||||
return $q.dialog({
|
||||
message: mytext,
|
||||
ok: {
|
||||
label: ok,
|
||||
push: true
|
||||
},
|
||||
title: mytitle,
|
||||
cancel: true,
|
||||
persistent: false
|
||||
}).onOk(() => {
|
||||
console.log('OK')
|
||||
tools.executefunc(myself, funcok, par)
|
||||
return true
|
||||
}).onCancel(() => {
|
||||
console.log('CANCEL')
|
||||
tools.executefunc(myself, funccancel, par)
|
||||
return false
|
||||
})
|
||||
},
|
||||
|
||||
showPositiveNotif(q: any, msg) {
|
||||
tools.showNotif(q, msg, { color: 'positive', icon: 'notifications' })
|
||||
},
|
||||
|
||||
showNegativeNotif(q: any, msg) {
|
||||
tools.showNotif(q, msg, { color: 'negative', icon: 'notifications' })
|
||||
},
|
||||
|
||||
showNotif(q: any, msg, data ?: INotify | null
|
||||
) {
|
||||
@@ -1297,7 +1369,7 @@ export const tools = {
|
||||
|
||||
checkIfUserExist(mythis) {
|
||||
|
||||
if (UserStore.state.userId === undefined) {
|
||||
if (UserStore.getters.isUserInvalid) {
|
||||
tools.showNotif(mythis.$q, mythis.$t('todo.usernotdefined'))
|
||||
return false
|
||||
}
|
||||
@@ -1313,7 +1385,7 @@ export const tools = {
|
||||
,
|
||||
|
||||
checkLangPassed(mylang) {
|
||||
// console.log('checkLangPassed')
|
||||
console.log('checkLangPassed')
|
||||
|
||||
const mybrowserLang = Quasar.lang.isoName
|
||||
|
||||
@@ -1335,7 +1407,7 @@ export const tools = {
|
||||
console.log('non incluso ', mylang)
|
||||
mylang = static_data.arrLangUsed[0]
|
||||
|
||||
// Metti Inglese come default
|
||||
// Metti come default
|
||||
UserStore.mutations.setlang(mylang)
|
||||
}
|
||||
}
|
||||
@@ -1728,7 +1800,6 @@ export const tools = {
|
||||
|
||||
},
|
||||
|
||||
|
||||
heightgallery() {
|
||||
if (Screen.width < 400) {
|
||||
return '200px'
|
||||
@@ -1747,7 +1818,7 @@ export const tools = {
|
||||
if (myheight > 1000) {
|
||||
maxheight = 1000
|
||||
} else {
|
||||
maxheight = parseInt(myheight, 10)
|
||||
maxheight = parseInt(myheight, 10)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1988,15 +2059,55 @@ export const tools = {
|
||||
getimgFullpathbysize(fileimg: string) {
|
||||
const ind = fileimg.lastIndexOf('/')
|
||||
if (ind > 0) {
|
||||
return { path: fileimg.substring(0, ind + 1) , file: fileimg.substring(ind + 1) }
|
||||
return { path: fileimg.substring(0, ind + 1), file: fileimg.substring(ind + 1) }
|
||||
} else {
|
||||
return { path: '', file: fileimg }
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
convertHTMLtoText(myhtml) {
|
||||
let msg = myhtml
|
||||
msg = msg.replace('"', '"')
|
||||
msg = msg.replace('>', '>')
|
||||
msg = msg.replace('<', '<')
|
||||
msg = msg.replace('&', '&')
|
||||
msg = msg.replace('<br>', '\n')
|
||||
|
||||
return msg
|
||||
},
|
||||
gettextevent(myevent) {
|
||||
return '"' + myevent.title + '" (' + this.getDateStr(myevent.date) + ') - ' + myevent.time
|
||||
},
|
||||
|
||||
setLangAtt(mylang) {
|
||||
console.log('setLangAtt =', mylang)
|
||||
// console.log('PRIMA this.$q.lang.isoName', this.$q.lang.isoName)
|
||||
|
||||
// dynamic import, so loading on demand only
|
||||
import(`quasar/lang/${mylang}`).then((lang) => {
|
||||
console.log(' Import dinamically lang =', lang)
|
||||
Quasar.lang.set(lang.default)
|
||||
import(`../../statics/i18n`).then(() => {
|
||||
console.log(' *** MY LANG DOPO=', Quasar.lang.isoName)
|
||||
})
|
||||
})
|
||||
|
||||
// this.$q.lang.set(mylang)
|
||||
|
||||
},
|
||||
getappname(mythis) {
|
||||
if (mythis === undefined)
|
||||
return ''
|
||||
if (mythis.$t === undefined)
|
||||
return ''
|
||||
if (Screen.width < 400) {
|
||||
return mythis.$t('msg.myAppNameShort')
|
||||
} else {
|
||||
return mythis.$t('msg.myAppName')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// getLocale() {
|
||||
// if (navigator.languages && navigator.languages.length > 0) {
|
||||
// return navigator.languages[0]
|
||||
|
||||
@@ -27,7 +27,7 @@ export const func_tools = {
|
||||
|
||||
getDateStr(mydate) {
|
||||
const DateFormatter = new Intl.DateTimeFormat(func_tools.getLocale() || void 0, {
|
||||
weekday: 'long',
|
||||
weekday: 'short',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric'
|
||||
|
||||
Reference in New Issue
Block a user