- Added Delete Record to the CGridTableRec
This commit is contained in:
@@ -21,6 +21,8 @@ import globalroutines from './../../globalroutines/index'
|
||||
import { cfgrouter } from '../../router/route-config'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import { IParamsQuery } from '@src/model/GlobalStore'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
import { IUserState } from '@src/model'
|
||||
// import { static_data } from '@src/db/static_data'
|
||||
|
||||
let stateConnDefault = 'online'
|
||||
@@ -520,6 +522,40 @@ namespace Actions {
|
||||
})
|
||||
}
|
||||
|
||||
async function saveFieldValue(context, mydata: object) {
|
||||
console.log('saveFieldValue', mydata)
|
||||
|
||||
return await Api.SendReq(`/chval`, 'PATCH', { data: mydata })
|
||||
.then((res) => {
|
||||
if (res)
|
||||
return (res.data.code === serv_constants.RIS_CODE_OK)
|
||||
else
|
||||
return false
|
||||
})
|
||||
.catch((error) => {
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
async function DeleteRec(context, { table, id }) {
|
||||
console.log('DeleteRec', id)
|
||||
|
||||
return await Api.SendReq('/delrec/' + table + '/' + id, 'DELETE', null)
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
if (res.data.code === serv_constants.RIS_CODE_OK) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export const actions = {
|
||||
setConta: b.dispatch(setConta),
|
||||
createPushSubscription: b.dispatch(createPushSubscription),
|
||||
@@ -529,7 +565,9 @@ namespace Actions {
|
||||
prova: b.dispatch(prova),
|
||||
saveCfgServerKey: b.dispatch(saveCfgServerKey),
|
||||
checkUpdates: b.dispatch(checkUpdates),
|
||||
loadTable: b.dispatch(loadTable)
|
||||
saveFieldValue: b.dispatch(saveFieldValue),
|
||||
loadTable: b.dispatch(loadTable),
|
||||
DeleteRec: b.dispatch(DeleteRec)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ const state: IUserState = {
|
||||
x_auth_token: '',
|
||||
isLogged: false,
|
||||
isAdmin: false,
|
||||
isManager: false,
|
||||
usersList: [],
|
||||
countusers: 0
|
||||
}
|
||||
@@ -158,8 +159,9 @@ namespace Mutations {
|
||||
mystate.surname = data.surname
|
||||
mystate.perm = data.perm
|
||||
mystate.isAdmin = tools.isBitActive(mystate.perm, shared_consts.Permissions.Admin)
|
||||
mystate.isManager = tools.isBitActive(mystate.perm, shared_consts.Permissions.Manager)
|
||||
|
||||
console.log('authUser', 'state.isAdmin', mystate.isAdmin)
|
||||
// console.log('authUser', 'state.isAdmin', mystate.isAdmin)
|
||||
console.table(mystate)
|
||||
console.table(data)
|
||||
if (data.verified_email) {
|
||||
@@ -324,21 +326,6 @@ namespace Actions {
|
||||
|
||||
}
|
||||
|
||||
async function saveUserChange(context, user: IUserState) {
|
||||
console.log('saveUserChange', user)
|
||||
|
||||
return await Api.SendReq(`/users/${user.userId}`, 'PATCH', { user })
|
||||
.then((res) => {
|
||||
if (res)
|
||||
return (res.data.code === serv_constants.RIS_CODE_OK)
|
||||
else
|
||||
return false
|
||||
})
|
||||
.catch((error) => {
|
||||
return false
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async function requestpwd(context, paramquery: IUserState) {
|
||||
|
||||
@@ -717,7 +704,6 @@ 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)
|
||||
|
||||
@@ -13,7 +13,9 @@ export const lists = {
|
||||
EDIT: 160,
|
||||
ADD_PROJECT: 200,
|
||||
THEME: 210,
|
||||
THEMEBG: 211
|
||||
THEMEBG: 211,
|
||||
|
||||
DELETE_RECTABLE: 300,
|
||||
},
|
||||
|
||||
selectTheme: [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Todos, Projects, UserStore, CalendarStore } from '@store'
|
||||
import { Todos, Projects, UserStore, CalendarStore, GlobalStore } from '@store'
|
||||
import globalroutines from './../../globalroutines/index'
|
||||
import { costanti } from './costanti'
|
||||
import { toolsext } from './toolsext'
|
||||
@@ -1314,7 +1314,7 @@ export const tools = {
|
||||
return result
|
||||
},
|
||||
|
||||
executefunc(myself: any, func: number, par: IParamDialog) {
|
||||
executefunc(myself: any, table, func: number, par: IParamDialog) {
|
||||
if (func === lists.MenuAction.DELETE) {
|
||||
console.log('param1', par.param1)
|
||||
CalendarStore.actions.CancelBookingEvent({ideventbook: par.param1, notify: par.param2 === true ? '1' : '0'}).then((ris) => {
|
||||
@@ -1325,10 +1325,19 @@ export const tools = {
|
||||
} else
|
||||
tools.showNegativeNotif(myself.$q, myself.$t('cal.cancelederrorbooking'))
|
||||
})
|
||||
} else if (func === lists.MenuAction.DELETE_RECTABLE) {
|
||||
console.log('param1', par.param1)
|
||||
GlobalStore.actions.DeleteRec({table, id: par.param1}).then((ris) => {
|
||||
if (ris) {
|
||||
myself.ActionAfterYes(func, par.param2)
|
||||
tools.showPositiveNotif(myself.$q, myself.$t('db.deletedrecord'))
|
||||
} else
|
||||
tools.showNegativeNotif(myself.$q, myself.$t('db.recdelfailed'))
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async askConfirm($q: any, mytitle, mytext, ok, cancel, myself: any, funcok: number, funccancel: number, par: IParamDialog) {
|
||||
async askConfirm($q: any, mytitle, mytext, ok, cancel, myself: any, table, funcok: number, funccancel: number, par: IParamDialog) {
|
||||
return $q.dialog({
|
||||
message: mytext,
|
||||
ok: {
|
||||
@@ -1340,11 +1349,11 @@ export const tools = {
|
||||
persistent: false
|
||||
}).onOk(() => {
|
||||
console.log('OK')
|
||||
tools.executefunc(myself, funcok, par)
|
||||
tools.executefunc(myself, table, funcok, par)
|
||||
return true
|
||||
}).onCancel(() => {
|
||||
console.log('CANCEL')
|
||||
tools.executefunc(myself, funccancel, par)
|
||||
tools.executefunc(myself, table, funccancel, par)
|
||||
return false
|
||||
})
|
||||
},
|
||||
@@ -2241,11 +2250,11 @@ export const tools = {
|
||||
},
|
||||
CancelBookingEvent(mythis, eventparam: IEvents, bookeventid: string, notify: boolean) {
|
||||
console.log('CancelBookingEvent ', eventparam)
|
||||
tools.askConfirm(mythis.$q, translate('cal.titlebooking'), translate('cal.cancelbooking') + ' ' + tools.gettextevent(eventparam) + '?', translate('dialog.yes'), translate('dialog.no'), mythis, lists.MenuAction.DELETE, 0, { param1: bookeventid, param2: notify })
|
||||
tools.askConfirm(mythis.$q, translate('cal.titlebooking'), translate('cal.cancelbooking') + ' ' + tools.gettextevent(eventparam) + '?', translate('dialog.yes'), translate('dialog.no'), mythis, '', lists.MenuAction.DELETE, 0, { param1: bookeventid, param2: notify })
|
||||
},
|
||||
CancelUserRec(mythis, id) {
|
||||
console.log('CancelUserRec', id)
|
||||
tools.askConfirm(mythis.$q, translate('cal.titlebooking'), translate('cal.canceluser') + '?', translate('dialog.yes'), translate('dialog.no'), mythis, lists.MenuAction.DELETE, 0, { param1: id })
|
||||
ActionRecTable(mythis, action, table, id, item?) {
|
||||
console.log('CancelRecTable', id)
|
||||
return tools.askConfirm(mythis.$q, translate('db.deleterecord'), translate('db.deletetherecord'), translate('dialog.yes'), translate('dialog.no'), mythis, table, action, 0, { param1: id, param2: item })
|
||||
},
|
||||
isBitActive(bit, whattofind) {
|
||||
return ((bit & whattofind) === whattofind)
|
||||
|
||||
Reference in New Issue
Block a user