From 9caeecfc0a8b489d4460aafe53450ef9ec416194 Mon Sep 17 00:00:00 2001 From: Olmo del Corral Cano Date: Mon, 29 Nov 2021 23:20:56 +0100 Subject: [PATCH] fix confirmation error using async await (change target to ES2017) --- .../Workflow/Case/CaseFrameModal.tsx | 22 ++++++++++--------- .../Workflow/Case/CaseFramePage.tsx | 20 ++++++++++------- Signum.React.Extensions/tsconfig.json | 2 +- Signum.React/Scripts/Frames/FrameModal.tsx | 15 +++++++------ Signum.React/Scripts/Frames/FramePage.tsx | 10 ++++++--- Signum.React/Scripts/Operations.tsx | 2 +- Signum.React/Scripts/Reflection.ts | 2 +- Signum.React/Scripts/TypeContext.ts | 2 +- Signum.React/tsconfig.json | 2 +- 9 files changed, 44 insertions(+), 33 deletions(-) diff --git a/Signum.React.Extensions/Workflow/Case/CaseFrameModal.tsx b/Signum.React.Extensions/Workflow/Case/CaseFrameModal.tsx index 8c6eab7b63..1efbdefcd1 100644 --- a/Signum.React.Extensions/Workflow/Case/CaseFrameModal.tsx +++ b/Signum.React.Extensions/Workflow/Case/CaseFrameModal.tsx @@ -179,16 +179,17 @@ export default class CaseFrameModal extends React.Component this.state.executing == true, - execute: action => { + execute: async action => { if (this.state.executing) return; this.setState({ executing: true }); - action() - .finally(() => this.setState({ executing: undefined })) - .done(); + try { + await action(); + } finally { + this.setState({ executing: undefined }); + } } - }; var activityPack = { entity: pack.activity, canExecute: pack.canExecuteActivity }; @@ -243,15 +244,16 @@ export default class CaseFrameModal extends React.Component this.state.executing == true, - execute: action => { + execute: async action => { if (this.state.executing) return; this.setState({ executing: true }); - - action() - .finally(() => this.setState({ executing: undefined })) - .done(); + try { + await action(); + } finally { + this.setState({ executing: undefined }) + } } }; diff --git a/Signum.React.Extensions/Workflow/Case/CaseFramePage.tsx b/Signum.React.Extensions/Workflow/Case/CaseFramePage.tsx index f29803d871..c2b47b2d48 100644 --- a/Signum.React.Extensions/Workflow/Case/CaseFramePage.tsx +++ b/Signum.React.Extensions/Workflow/Case/CaseFramePage.tsx @@ -164,14 +164,16 @@ export default class CaseFramePage extends React.Component this.state.executing == true, - execute: action => { + execute: async action => { if (this.state.executing) return; this.setState({ executing: true }); - action() - .finally(() => { this.setState({ executing: undefined }) }) - .done(); + try { + await action(); + } finally { + this.setState({ executing: undefined }); + } } }; @@ -245,14 +247,16 @@ export default class CaseFramePage extends React.Component this.state.executing == true, - execute: action => { + execute: async action => { if (this.state.executing) return; this.setState({ executing: true }); - action() - .finally(() => this.setState({ executing: undefined })) - .done(); + try { + await action(); + } finally { + this.setState({ executing: undefined }); + } } }; diff --git a/Signum.React.Extensions/tsconfig.json b/Signum.React.Extensions/tsconfig.json index e597a1d668..8e8b09b473 100644 --- a/Signum.React.Extensions/tsconfig.json +++ b/Signum.React.Extensions/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "ES2017", "sourceMap": true, "module": "esnext", "moduleResolution": "node", diff --git a/Signum.React/Scripts/Frames/FrameModal.tsx b/Signum.React/Scripts/Frames/FrameModal.tsx index d71ff6423c..7bc57c1c22 100644 --- a/Signum.React/Scripts/Frames/FrameModal.tsx +++ b/Signum.React/Scripts/Frames/FrameModal.tsx @@ -265,18 +265,19 @@ export const FrameModal = React.forwardRef(function FrameModal(p: FrameModalProp allowExchangeEntity: p.buttons == "close" && (p.allowExchangeEntity ?? true), prefix: prefix, isExecuting: () => pc.executing == true, - execute: action => { + execute: async action => { if (pc.executing) return; pc.executing = true; forceUpdate(); - action() - .finally(() => { - pc.executing = undefined; - forceUpdate(); - }) - .done(); + try { + await action(); + + } finally { + pc.executing = undefined; + forceUpdate(); + } } }; diff --git a/Signum.React/Scripts/Frames/FramePage.tsx b/Signum.React/Scripts/Frames/FramePage.tsx index f097216dec..8ddb8b5651 100644 --- a/Signum.React/Scripts/Frames/FramePage.tsx +++ b/Signum.React/Scripts/Frames/FramePage.tsx @@ -182,14 +182,18 @@ export default function FramePage(p: FramePageProps) { entityComponent: entityComponent.current, pack: state.pack, isExecuting: () => state.executing == true, - execute: action => { + execute: async action => { if (state.executing) return; state.executing = true; forceUpdate(); - action() - .finally(() => { state.executing = undefined; forceUpdate(); }).done(); + try { + await action(); + } finally { + state.executing = undefined; + forceUpdate(); + } }, onReload: (pack, reloadComponent, callback) => { diff --git a/Signum.React/Scripts/Operations.tsx b/Signum.React/Scripts/Operations.tsx index 9e486ac9fb..202b3c18d6 100644 --- a/Signum.React/Scripts/Operations.tsx +++ b/Signum.React/Scripts/Operations.tsx @@ -410,7 +410,7 @@ export class EntityOperationContext { return this.settings.onClick(this); else return defaultOnClick(this); - }); + }).done(); } textOrNiceName() { diff --git a/Signum.React/Scripts/Reflection.ts b/Signum.React/Scripts/Reflection.ts index 1d99a27745..68db78dde6 100644 --- a/Signum.React/Scripts/Reflection.ts +++ b/Signum.React/Scripts/Reflection.ts @@ -892,7 +892,7 @@ export function createBinding(parentValue: any, lambdaMembers: LambdaMember[]): const functionRegex = /^function\s*\(\s*([$a-zA-Z_][0-9a-zA-Z_$]*)\s*\)\s*{\s*(\"use strict\"\;)?\s*(var [^;]*;)?\s*return\s*([^;]*)\s*;?\s*}$/; -const lambdaRegex = /^\s*\(?\s*([$a-zA-Z_][0-9a-zA-Z_$]*)\s*\)?\s*=>\s*{?\s*(return\s+)?([^;]*)\s*;?\s*}?$/; +const lambdaRegex = /^\s*\(?\s*([$a-zA-Z_][0-9a-zA-Z_$]*)\s*\)?\s*=>(\s*{?\s*(return\s+)?([^;]*)\s*;?\s*}?)$/; const memberRegex = /^(.*)\.([$a-zA-Z_][0-9a-zA-Z_$]*)$/; const memberIndexerRegex = /^(.*)\["([$a-zA-Z_][0-9a-zA-Z_$]*)"\]$/; const mixinMemberRegex = /^(.*)\.mixins\["([$a-zA-Z_][0-9a-zA-Z_$]*)"\]$/; //Necessary for some crazy minimizers diff --git a/Signum.React/Scripts/TypeContext.ts b/Signum.React/Scripts/TypeContext.ts index a2ae17cee1..2b7e70ea8f 100644 --- a/Signum.React/Scripts/TypeContext.ts +++ b/Signum.React/Scripts/TypeContext.ts @@ -493,7 +493,7 @@ export interface EntityFrame { allowExchangeEntity: boolean; isExecuting(): boolean; - execute: (action: () => Promise) => void; + execute: (action: () => Promise) => Promise; createNew?: (oldPack: EntityPack) => (Promise | undefined>) | undefined; prefix: string; diff --git a/Signum.React/tsconfig.json b/Signum.React/tsconfig.json index 8654a7f28d..faa618778f 100644 --- a/Signum.React/tsconfig.json +++ b/Signum.React/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "ES2017", "sourceMap": false, "module": "esnext", "moduleResolution": "node",