- Added Delete Record to the CGridTableRec

This commit is contained in:
Paolo Arena
2019-10-15 20:40:23 +02:00
parent 0ee08f8430
commit 9fd858d33f
16 changed files with 210 additions and 53 deletions

View File

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