Browse Source

fix: refactored code as requested in review

Signed-off-by: Mert Ersoy <mertmit99@gmail.com>
pull/1565/head
Mert Ersoy 3 years ago
parent
commit
e6f2a32f5c
  1. 2
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  2. 20
      packages/nocodb/src/lib/noco/common/BaseModel.ts

2
packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

@ -1097,7 +1097,7 @@ export default {
return
}
// return if there is no change
if (oldRow[column._cn] === rowObj[column._cn] && ((lastSave || rowObj[column._cn]) == rowObj[column._cn])) {
if (oldRow[column._cn] === rowObj[column._cn] && ((lastSave || rowObj[column._cn]) === rowObj[column._cn])) {
return
}
if(saved) this.$set(this.data[row], 'lastSave', oldRow[column._cn]);

20
packages/nocodb/src/lib/noco/common/BaseModel.ts

@ -49,7 +49,15 @@ class BaseModel<T extends BaseApiBuilder<any>> extends BaseModelSql {
public async beforeUpdate(data: any, _trx: any, req): Promise<void> {
req = req || {};
req['oldData'] = await this.readByPk(req['params'].id);
if(req.query?.ignoreWebhook === undefined || req.query?.ignoreWebhook == 'false') await this.handleHooks('before.update', data, req);
const ignoreWebhook = req.query?.ignoreWebhook;
if (ignoreWebhook) {
if (ignoreWebhook != 'true' && ignoreWebhook != 'false') {
throw new Error('ignoreWebhook value can be either true or false');
}
}
if (ignoreWebhook === undefined || ignoreWebhook === 'false') {
await this.handleHooks('before.update', data, req);
}
}
public async afterUpdate(data: any, _trx: any, req): Promise<void> {
@ -74,7 +82,15 @@ class BaseModel<T extends BaseApiBuilder<any>> extends BaseModelSql {
user: req.user?.email
}
)
if(req.query?.ignoreWebhook === undefined || req.query?.ignoreWebhook == 'false') await this.handleHooks('after.update', data, req);
const ignoreWebhook = req.query?.ignoreWebhook;
if (ignoreWebhook) {
if (ignoreWebhook != 'true' && ignoreWebhook != 'false') {
throw new Error('ignoreWebhook value can be either true or false');
}
}
if (ignoreWebhook === undefined || ignoreWebhook === 'false') {
await this.handleHooks('after.update', data, req);
}
}
private _updateAuditDescription(id, oldData: any, data: any) {

Loading…
Cancel
Save