diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index 4700ddfdec..8bd3be2d80 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/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 || null) === 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]); diff --git a/packages/nc-gui/plugins/ncApis/gqlApi.js b/packages/nc-gui/plugins/ncApis/gqlApi.js index 3fa0fe28f5..1009142a07 100644 --- a/packages/nc-gui/plugins/ncApis/gqlApi.js +++ b/packages/nc-gui/plugins/ncApis/gqlApi.js @@ -176,15 +176,17 @@ export default class GqlApi { return { list, count } } - async update(id, data, oldData, cellSaved = false, params = {}) { + async update(id, data, oldData, cellSaved = true, params = {}) { const data1 = await this.post(`/nc/${this.$ctx.projectId}/v1/graphql`, { query: `mutation update($id:String!, $data:${this.tableCamelized}Input){ ${this.gqlMutationUpdateName}(id: $id, data: $data){${this.gqlReqBody}${await this.gqlRelationReqBody(params)}} }`, variables: { id, data - }, - _cellSaved: cellSaved + } + }, + { + params: { ignoreWebhook: !cellSaved } }) const colName = Object.keys(data)[0] diff --git a/packages/nc-gui/plugins/ncApis/restApi.js b/packages/nc-gui/plugins/ncApis/restApi.js index 92efb64579..eafd0df84c 100644 --- a/packages/nc-gui/plugins/ncApis/restApi.js +++ b/packages/nc-gui/plugins/ncApis/restApi.js @@ -64,14 +64,13 @@ export default class RestApi { return { list, count } } - async update(id, data, oldData, cellSaved = false) { - data._cellSaved = cellSaved + async update(id, data, oldData, cellSaved = true) { const res = await this.$axios({ method: 'put', url: `/nc/${this.$ctx.projectId}/api/v1/${this.table}/${encodeURIComponent(id)}`, - data + data, + params: { ignoreWebhook: !cellSaved } }) - return res.data } diff --git a/packages/nocodb/src/lib/noco/common/BaseModel.ts b/packages/nocodb/src/lib/noco/common/BaseModel.ts index d093843e6a..938b66b4e8 100644 --- a/packages/nocodb/src/lib/noco/common/BaseModel.ts +++ b/packages/nocodb/src/lib/noco/common/BaseModel.ts @@ -49,7 +49,15 @@ class BaseModel> extends BaseModelSql { public async beforeUpdate(data: any, _trx: any, req): Promise { req = req || {}; req['oldData'] = await this.readByPk(req['params'].id); - if(req.body?._cellSaved) 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 { @@ -74,7 +82,15 @@ class BaseModel> extends BaseModelSql { user: req.user?.email } ) - if(req.body?._cellSaved) 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) {