- Finished Booking an Event

- Starting UsersList (creating CGridTableRec component to view and edit a db table)
This commit is contained in:
Paolo Arena
2019-10-13 20:46:09 +02:00
parent 5803cfb2a4
commit 96b7b7a48b
25 changed files with 27105 additions and 104 deletions

View File

@@ -7,7 +7,7 @@ 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, BookingStore, CalendarStore } from '@store'
import { GlobalStore, UserStore, Todos, Projects, CalendarStore } from '@store'
import globalroutines from './../../globalroutines/index'
import { static_data } from '@src/db/static_data'
@@ -15,6 +15,7 @@ import { db_data } from '@src/db/db_data'
import translate from './../../globalroutines/util'
import * as Types from '@src/store/Api/ApiTypes'
import { ICfgServer } from '@src/model'
const bcrypt = require('bcryptjs')
@@ -91,6 +92,10 @@ namespace Getters {
return '(' + userId + ')'
}, 'getNameSurnameByUserId')
const getUsersList = b.read((mystate: IUserState) => {
return mystate.usersList
}, 'getUsersList')
const IsMyFriend = b.read((state) => (userIdOwner) => {
// ++TODO Check if userIdOwner is my friend
// userIdOwner is my friend ?
@@ -104,7 +109,7 @@ namespace Getters {
}, 'IsMyGroup')
const getUserByUserId = b.read((mystate: IUserState) => (userId): IUserState => {
return mystate.usersList.find((item) => item.userId === userId)
return mystate.usersList.find((item) => item._id === userId)
}, 'getUserByUserId')
export const getters = {
@@ -134,6 +139,9 @@ namespace Getters {
},
get getUserByUserId() {
return getUserByUserId()
},
get getUsersList() {
return getUsersList()
}
// get fullName() { return fullName();},
}
@@ -171,6 +179,11 @@ namespace Mutations {
state.password = newstr
}
function setusersList(mystate: IUserState, usersList: IUserList[]) {
// console.log('setusersList', usersList)
mystate.usersList = [...usersList]
}
function setemail(state: IUserState, newstr: string) {
state.email = newstr
}
@@ -267,7 +280,8 @@ namespace Mutations {
setAuth: b.commit(setAuth),
clearAuthData: b.commit(clearAuthData),
setErrorCatch: b.commit(setErrorCatch),
getMsgError: b.commit(getMsgError)
getMsgError: b.commit(getMsgError),
setusersList: b.commit(setusersList)
}
}
@@ -306,6 +320,15 @@ namespace Actions {
}
async function saveUserChange(context, user: IUserState) {
console.log('saveUserChange', user)
return await Api.SendReq(`/users/${user.userId}`, 'PATCH', { user })
.then((res) => {
return (res.data.code === serv_constants.RIS_CODE_OK)
})
}
async function requestpwd(context, paramquery: IUserState) {
const usertosend = {
@@ -583,14 +606,14 @@ namespace Actions {
// state.isLogged = true
state.isLogged = isLogged
if (isLogged) {
console.log('state.isLogged', state.isLogged)
// console.log('state.isLogged', state.isLogged)
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
GlobalStore.actions.checkUpdates()
}
const p = await BookingStore.actions.loadAfterLogin()
const p2 = await CalendarStore.actions.loadAfterLogin()
const p3 = await GlobalStore.actions.loadAfterLogin()
@@ -601,7 +624,7 @@ namespace Actions {
if (static_data.functionality.ENABLE_PROJECTS_LOADING)
await Projects.actions.dbLoad({ checkPending: true, onlyiffirsttime: true })
console.log('setGlobal: END')
// console.log('setGlobal: END')
}
async function autologin_FromLocalStorage(context) {
@@ -675,6 +698,7 @@ namespace Actions {
logout: b.dispatch(logout),
requestpwd: b.dispatch(requestpwd),
resetpwd: b.dispatch(resetpwd),
saveUserChange: b.dispatch(saveUserChange),
signin: b.dispatch(signin),
signup: b.dispatch(signup),
vreg: b.dispatch(vreg)