From 3467f1f223d615ee96628e4560f8b97f4e917511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Tom=C3=A1=C5=A1ko?= Date: Mon, 3 Jul 2023 18:25:24 +0200 Subject: [PATCH] Improve plugin infrastructure Allow intercepting actions before potential error is handled in a dialog. Provide blob url (e.g. to be used as iframe src). Improve types to make focusFormViewControl accessible in IDataView interface. --- frontend-html/src/model/actions-ui-tree/actions.ts | 3 ++- frontend-html/src/model/entities/OrigamAPI.ts | 11 +++++------ frontend-html/src/model/entities/types/IApi.ts | 1 + frontend-html/src/model/entities/types/IDataView.ts | 2 ++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend-html/src/model/actions-ui-tree/actions.ts b/frontend-html/src/model/actions-ui-tree/actions.ts index d95acf393a..f24d41b81c 100644 --- a/frontend-html/src/model/actions-ui-tree/actions.ts +++ b/frontend-html/src/model/actions-ui-tree/actions.ts @@ -31,7 +31,7 @@ import { crs_fieldBlur_ActionClick } from "model/actions/actionSync"; export default { onActionClick(ctx: any) { - return flow(function*onActionClick(event: any, action: IAction) { + return flow(function*onActionClick(event: any, action: IAction, beforeHandleError?: () => void) { try { yield*crs_fieldBlur_ActionClick.runGenerator(function*() { if (!action.isEnabled) { @@ -58,6 +58,7 @@ export default { } }); } catch (e) { + beforeHandleError?.(); yield*handleError(ctx)(e); throw e; } diff --git a/frontend-html/src/model/entities/OrigamAPI.ts b/frontend-html/src/model/entities/OrigamAPI.ts index 587a812f63..d563e8970a 100644 --- a/frontend-html/src/model/entities/OrigamAPI.ts +++ b/frontend-html/src/model/entities/OrigamAPI.ts @@ -734,13 +734,12 @@ export class OrigamAPI implements IApi { ).data; } + getBlobUrl(data: { downloadToken: string }) { + return `${this.urlPrefix}/Blob/${data.downloadToken}`; + } + async getBlob(data: { downloadToken: string }) { - window.open(`${this.urlPrefix}/Blob/${data.downloadToken}`); - /*return ( -await axios.get(`${this.urlPrefix}/Blob/${data.downloadToken}`, { - headers: this.httpAuthHeader, -}) -).data;*/ + window.open(this.getBlobUrl(data)); } async getUploadToken(data: { diff --git a/frontend-html/src/model/entities/types/IApi.ts b/frontend-html/src/model/entities/types/IApi.ts index 176d7308a2..e831188add 100644 --- a/frontend-html/src/model/entities/types/IApi.ts +++ b/frontend-html/src/model/entities/types/IApi.ts @@ -381,6 +381,7 @@ export interface IApi { }): Promise; getBlob(data: { downloadToken: string }): Promise; + getBlobUrl(data: { downloadToken: string }): string; getUploadToken(data: { SessionFormIdentifier: string; diff --git a/frontend-html/src/model/entities/types/IDataView.ts b/frontend-html/src/model/entities/types/IDataView.ts index 4f9bd5e8a6..b736405b09 100644 --- a/frontend-html/src/model/entities/types/IDataView.ts +++ b/frontend-html/src/model/entities/types/IDataView.ts @@ -151,6 +151,8 @@ export interface IDataView extends IDataViewData { setSelectedRowId(id: string | undefined): void; + focusFormViewControl(fieldId: string): void; + setRecords(rows: any[][]): Promise; appendRecords(rows: any[][]): void;