Browse Source

Merge pull request #1565 from mertmit/hotfix-multiple-trigger

fix: hotfix reverting breaking changes on webhook multiple-trigger
pull/1572/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
3ac6bec3e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  2. 8
      packages/nc-gui/plugins/ncApis/gqlApi.js
  3. 7
      packages/nc-gui/plugins/ncApis/restApi.js
  4. 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 || 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]);

8
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]

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

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.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<void> {
@ -74,7 +82,15 @@ class BaseModel<T extends BaseApiBuilder<any>> 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) {

Loading…
Cancel
Save