@topconsultnpm/sdkui-react-beta 6.9.43 → 6.9.45

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.
@@ -51,7 +51,7 @@ export var Descriptors;
51
51
  (function (Descriptors) {
52
52
  Descriptors[Descriptors["Query"] = 3] = "Query";
53
53
  })(Descriptors || (Descriptors = {}));
54
- export function useOrchApplyForm(d, formMode, inputData, onApplied, parameters) {
54
+ export function useQueryApplyForm(d, formMode, inputData, onApplied, parameters) {
55
55
  const newData = () => {
56
56
  switch (d) {
57
57
  case Descriptors.Query: return SearchEngine.NewQueryDescriptor();
@@ -62,10 +62,11 @@ export function useOrchApplyForm(d, formMode, inputData, onApplied, parameters)
62
62
  const [validationItems, setValidationItems] = useState([]);
63
63
  return { formData, setFormData, formDataOrig, validationItems, setValidationItems, exception, applyData };
64
64
  }
65
- const TMQueryEditor = ({ formMode, inputData, onQDChanged, runQdImmediately = false, isModal, showDistinct = false, showToolbar = true, validateSelect = true, validateOrderBy = true, raiseWarningForOnlyMetadataDcmtTypes = false, onApplied, onClose, height = 'auto', borderRadius = '4px', searchText, showApply, showUndo, showBack, onFromTIDChanged }) => {
65
+ const TMQueryEditor = ({ formMode, inputData, onQDChanged, isModal, showDistinct = false, showToolbar = true, validateSelect = true, validateOrderBy = true, raiseWarningForOnlyMetadataDcmtTypes = false, onApplied, onClose, height = 'auto', borderRadius = '4px', searchText, showApply, showUndo, showBack, onFromTIDChanged }) => {
66
66
  const [confirmQueryParams, ConfirmQueryParamsDialog] = useQueryParametersDialog();
67
- const { formData, setFormData, formDataOrig, validationItems, setValidationItems, exception, applyData } = useOrchApplyForm(Descriptors.Query, formMode, inputData, onApplied);
67
+ const { formData, setFormData, formDataOrig, validationItems, setValidationItems, exception, applyData } = useQueryApplyForm(Descriptors.Query, formMode, inputData, onApplied);
68
68
  const [dcmtTypesList, setDcmtTypesList] = useState([]);
69
+ const [lastQdParams, setLastQdParams] = useState([]);
69
70
  const [resultSearch, setResultSearch] = useState();
70
71
  const [elapsedTime, setElapsedTime] = useState(0);
71
72
  const [draggingItem, setDraggingItem] = useState();
@@ -73,7 +74,7 @@ const TMQueryEditor = ({ formMode, inputData, onQDChanged, runQdImmediately = fa
73
74
  const [showCompleteMetadataName, setShowCompleteMetadataName] = useState(false);
74
75
  const [showResultSearch, setShowResultSearch] = useState(false);
75
76
  const [fromCount, setFromCount] = useState(0);
76
- useEffect(() => { setShowResultSearch(false); }, [inputData]);
77
+ useEffect(() => { setShowResultSearch(false); }, [JSON.stringify(inputData)]);
77
78
  useEffect(() => {
78
79
  if (!formData)
79
80
  return;
@@ -84,9 +85,7 @@ const TMQueryEditor = ({ formMode, inputData, onQDChanged, runQdImmediately = fa
84
85
  useEffect(() => { validateQd(); }, [formData.select, formData.where, formData.orderBy, formData.maxDcmtsToBeReturned]);
85
86
  //Se non c'è la toolbar significa che il qd deve essere gestito dall'esterno
86
87
  useEffect(() => { if (!showToolbar)
87
- onQDChanged?.(formData); }, [formData]);
88
- useEffect(() => { if (runQdImmediately)
89
- onSearchAsync().catch((err) => { TMExceptionBoxManager.show({ exception: err }); }); }, [runQdImmediately]);
88
+ onQDChanged?.(formData); }, [JSON.stringify(formData)]);
90
89
  const validateQd = () => {
91
90
  let vil = [];
92
91
  let qvo = new QueryValidatorOptions();
@@ -572,27 +571,28 @@ const TMQueryEditor = ({ formMode, inputData, onQDChanged, runQdImmediately = fa
572
571
  // #endregion
573
572
  // #region Ricerca
574
573
  const renderResultSearchForm = _jsx(TMQueryResultForm, { context: SearchResultContext.METADATA_SEARCH, onClose: () => { setShowResultSearch(false); }, isModal: isModal, result1: resultSearch, elapsedTime: elapsedTime, searchText: searchText });
575
- const onSearchAsync = async () => {
574
+ const onSearchAsync = async (qdInput) => {
576
575
  try {
577
576
  const startTime = new Date().getTime();
578
- let qd = await prepareQdForSearchAsync(formData);
579
- if (IsParametricQuery(qd)) {
580
- const qdParams = await confirmQueryParams(qd);
577
+ let qdSearch = await prepareQdForSearchAsync(qdInput);
578
+ if (IsParametricQuery(qdSearch)) {
579
+ const qdParams = await confirmQueryParams(qdSearch, lastQdParams);
580
+ setLastQdParams(qdParams);
581
581
  if (!qdParams || qdParams.length <= 0)
582
582
  return;
583
583
  for (const qpd of qdParams) {
584
- let wi = qd.where?.find(o => o.value1 == qpd.name);
584
+ let wi = qdSearch.where?.find(o => o.value1 == qpd.name);
585
585
  if (wi)
586
586
  wi.value1 = wi.value1?.replace(wi.value1, !qpd.value ? '' : qpd.value.toString());
587
587
  else {
588
- wi = qd.where?.find(o => o.value2 == qpd.name);
588
+ wi = qdSearch.where?.find(o => o.value2 == qpd.name);
589
589
  if (wi)
590
590
  wi.value2 = wi.value2?.replace(wi.value2, !qpd.value ? '' : qpd.value.toString());
591
591
  }
592
592
  }
593
593
  }
594
594
  TMSpinner.show({ description: `${SDKUI_Localizator.Search} ...`, backgroundColor: 'transparent' });
595
- let result = await SDK_Globals.tmSession?.NewSearchEngine().SearchByIDAsync(qd);
595
+ let result = await SDK_Globals.tmSession?.NewSearchEngine().SearchByIDAsync(qdSearch);
596
596
  let dcmtsFound = result?.dcmtsFound ?? 0;
597
597
  if (dcmtsFound <= 0)
598
598
  ShowAlert({ message: SDKUI_Localizator.NoDcmtFound, mode: 'info', title: SDKUI_Localizator.SearchResult, duration: 3000 });
@@ -677,7 +677,7 @@ const TMQueryEditor = ({ formMode, inputData, onQDChanged, runQdImmediately = fa
677
677
  }
678
678
  };
679
679
  // #endregion
680
- return (_jsxs(_Fragment, { children: [_jsxs(TMApplyForm, { isModal: false, formMode: formMode, isModified: calcIsModified(formData, formDataOrig), exception: exception, validationItems: validationItems, hasNavigation: false, customToolbarElements: _jsxs(_Fragment, { children: [_jsx(TMButton, { btnStyle: 'toolbar', caption: SDKUI_Localizator.Search, color: 'tertiary', icon: _jsx(IconSearch, {}), disabled: errorsCount > 0, onClick: onSearchAsync }), _jsx(TMButton, { btnStyle: 'toolbar', caption: SDKUI_Localizator.Count, icon: _jsx(IconCount, {}), disabled: errorsCount > 0, onClick: () => getQueryCountAsync(formData, true) }), SDK_Globals.tmSession?.SessionDescr?.appModuleID == AppModules.SURFER && _jsx(TMButton, { caption: "Passa ad archiviazione", icon: _jsx(IconArchiveDoc, {}), btnStyle: 'toolbar', fontSize: '1.3rem', onClick: () => { ShowAlert({ message: "TODO Passa ad archiviazione", mode: 'info', title: `${"TODO"}`, duration: 3000 }); } }), SDK_Globals.tmSession?.SessionDescr?.appModuleID == AppModules.SURFER && _jsx(TMButton, { caption: "Vai a risultato", icon: _jsx(IconArrowRight, {}), btnStyle: 'toolbar', fontSize: '1.3rem', onClick: () => { ShowAlert({ message: "TODO Vai a risultato", mode: 'info', title: `${"TODO"}`, duration: 3000 }); } })] }), showToolbar: showToolbar, showApply: showApply, showUndo: showUndo, showBack: showBack, onApply: () => applyData(), onClose: () => onClose?.(), onUndo: () => setFormData(formDataOrig), children: [_jsxs(Accordion, { elementAttr: { class: 'tm-query-dx-accordion' }, height: height, multiple: true, collapsible: true, repaintChangesOnly: true, deferRendering: false, animationDuration: 0, onContentReady: (e) => {
680
+ return (_jsxs(_Fragment, { children: [_jsxs(TMApplyForm, { isModal: false, formMode: formMode, isModified: calcIsModified(formData, formDataOrig), exception: exception, validationItems: validationItems, hasNavigation: false, customToolbarElements: _jsxs(_Fragment, { children: [_jsx(TMButton, { btnStyle: 'toolbar', caption: SDKUI_Localizator.Search, color: 'tertiary', icon: _jsx(IconSearch, {}), disabled: errorsCount > 0, onClick: async () => await onSearchAsync(formData) }), _jsx(TMButton, { btnStyle: 'toolbar', caption: SDKUI_Localizator.Count, icon: _jsx(IconCount, {}), disabled: errorsCount > 0, onClick: () => getQueryCountAsync(formData, true) }), SDK_Globals.tmSession?.SessionDescr?.appModuleID == AppModules.SURFER && _jsx(TMButton, { caption: "Passa ad archiviazione", icon: _jsx(IconArchiveDoc, {}), btnStyle: 'toolbar', fontSize: '1.3rem', onClick: () => { ShowAlert({ message: "TODO Passa ad archiviazione", mode: 'info', title: `${"TODO"}`, duration: 3000 }); } }), SDK_Globals.tmSession?.SessionDescr?.appModuleID == AppModules.SURFER && _jsx(TMButton, { caption: "Vai a risultato", icon: _jsx(IconArrowRight, {}), btnStyle: 'toolbar', fontSize: '1.3rem', onClick: () => { ShowAlert({ message: "TODO Vai a risultato", mode: 'info', title: `${"TODO"}`, duration: 3000 }); } })] }), showToolbar: showToolbar, showApply: showApply, showUndo: showUndo, showBack: showBack, onApply: () => applyData(), onClose: () => onClose?.(), onUndo: () => setFormData(formDataOrig), children: [_jsxs(Accordion, { elementAttr: { class: 'tm-query-dx-accordion' }, height: height, multiple: true, collapsible: true, repaintChangesOnly: true, deferRendering: false, animationDuration: 0, onContentReady: (e) => {
681
681
  let items = e.component.option("items");
682
682
  if (items && items.length > 0) {
683
683
  for (let i = 0; i < items.length; i++) {
@@ -1,10 +1,10 @@
1
1
  import { SearchResultDescriptor } from '@topconsultnpm/sdk-ts-beta';
2
2
  declare const TMQueryResult: ({ result, elapsedTime, showHiddenSelectItems, searchText, onSelectionChanged, onDblClick }: {
3
- onDblClick?: (() => void) | undefined;
4
- onSelectionChanged?: ((e: any[]) => void) | undefined;
3
+ onDblClick?: () => void;
4
+ onSelectionChanged?: (e: any[]) => void;
5
5
  result: SearchResultDescriptor | undefined;
6
- elapsedTime?: number | undefined;
7
- showHiddenSelectItems?: boolean | undefined;
8
- searchText?: string | undefined;
6
+ elapsedTime?: number;
7
+ showHiddenSelectItems?: boolean;
8
+ searchText?: string;
9
9
  }) => import("react/jsx-runtime").JSX.Element;
10
10
  export default TMQueryResult;
@@ -6,17 +6,17 @@ export declare enum SearchResultContext {
6
6
  RECENT = "recent"
7
7
  }
8
8
  declare const TMQueryResultForm: ({ onUpdate, isModal, onClose, context, result1, result2, elapsedTime, searchText, tabIcon1, tabIcon2, tabTitle1, tabTitle2 }: {
9
- tabTitle1?: string | undefined;
10
- tabTitle2?: string | undefined;
9
+ tabTitle1?: string;
10
+ tabTitle2?: string;
11
11
  tabIcon1?: any;
12
12
  tabIcon2?: any;
13
- isModal?: boolean | undefined;
14
- onClose?: (() => void) | undefined;
15
- context?: SearchResultContext | undefined;
16
- result1?: SearchResultDescriptor | SearchResultDescriptor[] | undefined;
17
- result2?: SearchResultDescriptor | SearchResultDescriptor[] | undefined;
18
- elapsedTime?: number | undefined;
19
- searchText?: string | undefined;
20
- onUpdate?: (() => Promise<void>) | undefined;
13
+ isModal?: boolean;
14
+ onClose?: () => void;
15
+ context?: SearchResultContext;
16
+ result1?: SearchResultDescriptor | SearchResultDescriptor[];
17
+ result2?: SearchResultDescriptor | SearchResultDescriptor[];
18
+ elapsedTime?: number;
19
+ searchText?: string;
20
+ onUpdate?: () => Promise<void>;
21
21
  }) => import("react/jsx-runtime").JSX.Element;
22
22
  export default TMQueryResultForm;
@@ -24,8 +24,8 @@ interface ITMHeader {
24
24
  onSettingsClick?: () => void;
25
25
  }
26
26
  export declare const TMSearchBar: ({ searchValue, onSearchValueChanged, maxWidth, marginLeft }: {
27
- maxWidth?: string | undefined;
28
- marginLeft?: string | undefined;
27
+ maxWidth?: string;
28
+ marginLeft?: string;
29
29
  searchValue: string;
30
30
  onSearchValueChanged: (value: string) => void;
31
31
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,9 @@
1
1
  import { DataListViewModes } from '@topconsultnpm/sdk-ts-beta';
2
2
  import { DataGridTypes } from 'devextreme-react/cjs/data-grid';
3
3
  declare const TMDataListItemViewer: ({ dataListId, value, viewMode }: {
4
- dataListId?: number | undefined;
5
- value?: string | undefined;
6
- viewMode?: DataListViewModes | undefined;
4
+ dataListId?: number;
5
+ value?: string;
6
+ viewMode?: DataListViewModes;
7
7
  }) => import("react/jsx-runtime").JSX.Element;
8
8
  export default TMDataListItemViewer;
9
9
  export declare const cellRenderDataListItem: (data: DataGridTypes.ColumnCellTemplateData, dataListId?: number, viewMode?: DataListViewModes) => import("react/jsx-runtime").JSX.Element;
@@ -3,12 +3,12 @@ import { ITopMediaSession, LayoutModes, MetadataDescriptor } from '@topconsultnp
3
3
  import { TID_MID } from '../../ts';
4
4
  import { DataGridTypes } from 'devextreme-react/cjs/data-grid';
5
5
  export declare const TMMidViewer: ({ tmSession, tid_mid, showCompleteName, showIcon, showId, noneSelectionText }: {
6
- tmSession?: ITopMediaSession | undefined;
6
+ tmSession?: ITopMediaSession;
7
7
  tid_mid: TID_MID | undefined;
8
- showCompleteName?: boolean | undefined;
9
- showIcon?: boolean | undefined;
10
- showId?: boolean | undefined;
11
- noneSelectionText?: string | undefined;
8
+ showCompleteName?: boolean;
9
+ showIcon?: boolean;
10
+ showId?: boolean;
11
+ noneSelectionText?: string;
12
12
  }) => import("react/jsx-runtime").JSX.Element;
13
13
  interface ITMMetadataIcon {
14
14
  tid: number | undefined;
@@ -11,11 +11,11 @@ interface ITMDcmtTypeTooltip {
11
11
  }
12
12
  export declare const TMDcmtTypeTooltip: React.FC<ITMDcmtTypeTooltip>;
13
13
  declare const TMTidViewer: ({ tmSession, tid, showIcon, showId, noneSelectionText }: {
14
- tmSession?: ITopMediaSession | undefined;
15
- tid?: number | undefined;
16
- showIcon?: boolean | undefined;
17
- showId?: boolean | undefined;
18
- noneSelectionText?: string | undefined;
14
+ tmSession?: ITopMediaSession;
15
+ tid?: number;
16
+ showIcon?: boolean;
17
+ showId?: boolean;
18
+ noneSelectionText?: string;
19
19
  }) => import("react/jsx-runtime").JSX.Element;
20
20
  export default TMTidViewer;
21
21
  export declare const cellRenderTID: (data: DataGridTypes.ColumnCellTemplateData, noneSelectionText?: string) => import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ import { AppModules, DataColumnDescriptor, ITopMediaSession, QueryDescriptor, Se
4
4
  import { FormModes, moduleTypes } from "../ts";
5
5
  declare const TABLET_WIDTH = 1024;
6
6
  declare const MOBILE_WIDTH = 640;
7
- declare const calcResponsiveDirection: (deviceType: DeviceType, desktopDir: 'horizontal' | 'vertical', tabletDir: 'horizontal' | 'vertical', mobileDir: 'horizontal' | 'vertical') => 'horizontal' | 'vertical';
7
+ declare const calcResponsiveDirection: (deviceType: DeviceType, desktopDir: "horizontal" | "vertical", tabletDir: "horizontal" | "vertical", mobileDir: "horizontal" | "vertical") => "horizontal" | "vertical";
8
8
  declare const openApps: (appModule: AppModules, tmSession: ITopMediaSession, appRoutes?: any[]) => Promise<void>;
9
9
  export declare const setSDK_GlobalsInfoAsync: (tms: ITopMediaSession | undefined) => Promise<ITopMediaSession>;
10
10
  declare const calcResponsiveSizes: (deviceType: DeviceType | undefined, desktopSize: string, tabletSize: string, mobileSize: string) => string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { FormModes } from "../ts";
3
2
  import { JobTypes, ObjectClasses, ValidationItem } from "@topconsultnpm/sdk-ts-beta";
4
3
  export declare class SaveFormOptions {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  export declare const useOutsideClick: (callback: (escPressed?: boolean) => void) => import("react").RefObject<HTMLDivElement>;
3
2
  export declare const useEscapeKeyPress: (callback: () => void) => import("react").RefObject<HTMLDivElement>;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { QueryDescriptor, QueryParameterDescriptor } from '@topconsultnpm/sdk-ts-beta';
3
- export declare const useQueryParametersDialog: () => [(inputQd: QueryDescriptor) => Promise<QueryParameterDescriptor[]>, () => JSX.Element];
2
+ export declare const useQueryParametersDialog: () => [(inputQd: QueryDescriptor, lastQdParams?: QueryParameterDescriptor[]) => Promise<QueryParameterDescriptor[]>, () => JSX.Element];
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState } from "react";
2
+ import { useEffect, useState } from "react";
3
3
  import { QueryParameterDescriptor } from '@topconsultnpm/sdk-ts-beta';
4
4
  import { TMModal, TMTextBox, TMButton } from "../components";
5
5
  import { IconApply, IconCloseOutline, SDKUI_Localizator } from "../helper";
@@ -10,7 +10,12 @@ export const useQueryParametersDialog = () => {
10
10
  const [open, setOpen] = useState(false);
11
11
  const [qdParams, setQdParams] = useState([]);
12
12
  let qdParamsOut = [];
13
- const confirmQueryParams = (inputQd) => new Promise((resolve, reject) => {
13
+ useEffect(() => {
14
+ for (const qdp of qdParams) {
15
+ qdParamsOut.push(qdp);
16
+ }
17
+ }, [qdParams]);
18
+ const confirmQueryParams = (inputQd, lastQdParams) => new Promise((resolve, reject) => {
14
19
  if (inputQd.where) {
15
20
  let newQueryParams = [];
16
21
  let id = 1;
@@ -19,6 +24,7 @@ export const useQueryParametersDialog = () => {
19
24
  let qpd = new QueryParameterDescriptor();
20
25
  qpd.id = id++;
21
26
  qpd.name = wi.value1;
27
+ qpd.value = lastQdParams?.find(o => o.id == qpd.id)?.value;
22
28
  if (newQueryParams.findIndex(o => o.name == wi.value1) < 0)
23
29
  newQueryParams.push(qpd);
24
30
  }
@@ -26,6 +32,7 @@ export const useQueryParametersDialog = () => {
26
32
  let qpd = new QueryParameterDescriptor();
27
33
  qpd.id = id++;
28
34
  qpd.name = wi.value2;
35
+ qpd.value = lastQdParams?.find(o => o.id == qpd.id)?.value;
29
36
  if (newQueryParams.findIndex(o => o.name == wi.value2) < 0)
30
37
  newQueryParams.push(qpd);
31
38
  }
@@ -50,12 +57,12 @@ export const useQueryParametersDialog = () => {
50
57
  const ConfirmQueryParamsDialog = () => {
51
58
  return (open ?
52
59
  _jsx(TMModal, { title: SDKUI_Localizator.QueryParamBind, height: "max-content", width: "400px", onClose: handleClose, children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '5px', padding: '10px', height: '100%' }, children: [qdParams.map((qdp, index) => {
53
- return (_jsx(TMTextBox, { placeHolder: `${SDKUI_Localizator.EnterValue} ...`, label: qdp.name, autoFocus: index == 0, value: qdp.value, onValueChanged: (e) => {
54
- qdParamsOut = qdParams.map((curItem) => {
55
- if (curItem.id != qdp.id)
56
- return curItem;
57
- return { ...curItem, value: e.target.value };
58
- });
60
+ return (_jsx(TMTextBox, { placeHolder: `${SDKUI_Localizator.EnterValue} ...`, label: qdp.name, autoFocus: index == 0, value: qdp.value ?? '', onValueChanged: (e) => {
61
+ let newQdp = qdParamsOut.find(o => o.id == qdp.id);
62
+ if (newQdp)
63
+ newQdp.value = e.target.value;
64
+ else
65
+ qdParamsOut.push({ id: qdp.id, name: qdp.name, value: e.target.value });
59
66
  } }, qdp.id));
60
67
  }), _jsxs("div", { style: { display: 'flex', flexDirection: 'row', gap: '5px', paddingTop: '10px', justifyContent: 'flex-end', alignItems: 'center', height: '50px' }, children: [_jsx(TMButton, { btnStyle: "advanced", showTooltip: false, icon: _jsx(IconApply, {}), caption: "OK", advancedColor: TMColors.tertiary, onClick: handleConfirm }), _jsx(TMButton, { btnStyle: "advanced", showTooltip: false, icon: _jsx(IconCloseOutline, {}), caption: SDKUI_Localizator.Cancel, onClick: handleCancel })] })] }) })
61
68
  : _jsx(_Fragment, {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.9.43",
3
+ "version": "6.9.45",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",