@adminforth/crud-approve-plugin 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,7 @@ async function sendApproveRequest(approved) {
34
34
  approved: approved
35
35
  }
36
36
  });
37
- if (data.error) {
37
+ if (data.error && data.error !== 'Operation aborted by hook') {
38
38
  adminforth.alert({ message: `Error: ${data.error}`, variant: 'warning' });
39
39
  } else {
40
40
  adminforth.alert({ message: `Successfully ${approved ? 'approved' : 'rejected'} the change.`, variant: 'success' });
@@ -36,7 +36,7 @@ async function sendApproveRequest(approved) {
36
36
  approved: approved
37
37
  }
38
38
  });
39
- if (data.error) {
39
+ if (data.error && data.error !== 'Operation aborted by hook') {
40
40
  adminforth.alert({ message: `Error: ${data.error}`, variant: 'warning' });
41
41
  } else {
42
42
  adminforth.alert({ message: `Successfully ${approved ? 'approved' : 'rejected'} the change.`, variant: 'success' });
package/index.ts CHANGED
@@ -349,10 +349,16 @@ export default class CRUDApprovePlugin extends AdminForthPlugin {
349
349
  const diffData = diffRecord[this.options.resourceColumns.dataColumnName];
350
350
  const extra = diffRecord[this.options.resourceColumns.extraColumnName] || {};
351
351
  extra.body = body;
352
+ let oldRecord = undefined;
353
+ if (action !== AllowedActionsEnum.create) {
354
+ oldRecord = await this.adminforth.connectors[resource.dataSource].getRecordByPrimaryKey(
355
+ resource, diffRecord[this.options.resourceColumns.recordIdColumnName]
356
+ );
357
+ }
352
358
  const beforeSaveResp = await this.callBeforeSaveHooks(
353
359
  resource, action as AllowedActionsEnum, diffData['newRecord'],
354
360
  adminUser, diffRecord[this.options.resourceColumns.recordIdColumnName],
355
- diffData['newRecord'], diffData['oldRecord'], this.adminforth, extra
361
+ diffData['newRecord'], oldRecord, this.adminforth, extra
356
362
  );
357
363
  if (beforeSaveResp.error) {
358
364
  if (beforeSaveResp.error === 'Operation aborted by hook') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/crud-approve-plugin",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },