@topconsultnpm/sdkui-react 6.21.0-dev1.25 → 6.21.0-dev1.27
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.
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/query/TMQueryCountButton.d.ts +11 -0
- package/lib/components/query/TMQueryCountButton.js +32 -0
- package/lib/components/query/TMQueryEditor.js +3 -21
- package/lib/components/query/TMQuerySummary.js +3 -2
- package/lib/hooks/useQueryParametersDialog.js +5 -5
- package/package.json +1 -1
|
@@ -62,6 +62,7 @@ export { default as TMBlogAttachments } from './grids/TMBlogAttachments';
|
|
|
62
62
|
export { default as TMBlogCommentForm } from './features/blog/TMBlogCommentForm';
|
|
63
63
|
export * from './query/TMQueryEditor';
|
|
64
64
|
export * from './query/TMQuerySummary';
|
|
65
|
+
export * from './query/TMQueryCountButton';
|
|
65
66
|
export { default as TMToppyDraggableHelpCenter } from './features/assistant/TMToppyDraggableHelpCenter';
|
|
66
67
|
export * from './features/documents/TMDcmtForm';
|
|
67
68
|
export * from './features/documents/TMDcmtIcon';
|
package/lib/components/index.js
CHANGED
|
@@ -68,6 +68,7 @@ export { default as TMBlogCommentForm } from './features/blog/TMBlogCommentForm'
|
|
|
68
68
|
//query
|
|
69
69
|
export * from './query/TMQueryEditor';
|
|
70
70
|
export * from './query/TMQuerySummary';
|
|
71
|
+
export * from './query/TMQueryCountButton';
|
|
71
72
|
//assistant
|
|
72
73
|
export { default as TMToppyDraggableHelpCenter } from './features/assistant/TMToppyDraggableHelpCenter';
|
|
73
74
|
//documents
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QueryDescriptor, QueryParameterDescriptor } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
interface ITMQueryCountButton {
|
|
4
|
+
qd?: QueryDescriptor;
|
|
5
|
+
lastparams: QueryParameterDescriptor[] | undefined;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
showSpinner: boolean;
|
|
8
|
+
onLastQueryParamsChanged?: (params: QueryParameterDescriptor[]) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const TMQueryCountButton: React.FunctionComponent<ITMQueryCountButton>;
|
|
11
|
+
export default TMQueryCountButton;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import TMButton from '../base/TMButton';
|
|
3
|
+
import { getQueryCountAsync, IconCount, IsParametricQuery, SDKUI_Localizator } from '../../helper';
|
|
4
|
+
import { useQueryParametersDialog } from '../../hooks/useQueryParametersDialog';
|
|
5
|
+
const TMQueryCountButton = ({ qd, lastparams, disabled, showSpinner, onLastQueryParamsChanged }) => {
|
|
6
|
+
const [confirmQueryParams, ConfirmQueryParamsDialog] = useQueryParametersDialog();
|
|
7
|
+
const getQueryCountLocalAsync = async () => {
|
|
8
|
+
if (qd == undefined)
|
|
9
|
+
return;
|
|
10
|
+
let qdLocal = { ...qd };
|
|
11
|
+
const whereCopy = qdLocal.where?.map((curItem) => ({ ...curItem }));
|
|
12
|
+
if (IsParametricQuery(qd)) {
|
|
13
|
+
const qdParams = await confirmQueryParams(qdLocal, lastparams);
|
|
14
|
+
if (!qdParams || qdParams.length <= 0)
|
|
15
|
+
return;
|
|
16
|
+
for (const qpd of qdParams) {
|
|
17
|
+
let wi = whereCopy?.find(o => o.value1 == qpd.name);
|
|
18
|
+
if (wi)
|
|
19
|
+
wi.value1 = wi.value1?.replace(wi.value1, !qpd.value ? '' : qpd.value.toString());
|
|
20
|
+
else {
|
|
21
|
+
wi = whereCopy?.find(o => o.value2 == qpd.name);
|
|
22
|
+
if (wi)
|
|
23
|
+
wi.value2 = wi.value2?.replace(wi.value2, !qpd.value ? '' : qpd.value.toString());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
onLastQueryParamsChanged?.(qdParams ?? []);
|
|
27
|
+
}
|
|
28
|
+
await getQueryCountAsync({ ...qdLocal, where: whereCopy }, showSpinner);
|
|
29
|
+
};
|
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsx(TMButton, { btnStyle: 'toolbar', caption: SDKUI_Localizator.Count, icon: _jsx(IconCount, {}), disabled: disabled, onClick: async () => await getQueryCountLocalAsync() }), _jsx(ConfirmQueryParamsDialog, {})] }));
|
|
31
|
+
};
|
|
32
|
+
export default TMQueryCountButton;
|
|
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
3
3
|
import { SDK_Localizator, AccessLevels, OnJoinItem, JoinTypes, PlatformObjectValidator, MetadataDataDomains, DcmtTypeListCacheService, JoinItem, MetadataDataTypes, OrderByItem, QueryFunctions, QueryOperators, ResultTypes, SelectItem, SDK_Globals, UserListCacheService, WhereItem, SearchEngine, SelectItemVisibilities, DataListCacheService, QueryValidatorOptions, TMPropertyNames, AppModules, LayoutModes } from '@topconsultnpm/sdk-ts';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import Accordion, { Item } from 'devextreme-react/accordion';
|
|
6
|
-
import { SDKUI_Localizator, IconSearch,
|
|
6
|
+
import { SDKUI_Localizator, IconSearch, calcIsModified, IconClear, IconAddCircleOutline, IconDotsVerticalCircleOutline, IconHide, IconShow, IconDraggabledots, genUniqueId, LocalizeQueryOperators, LocalizeQueryFunctions, LocalizeQueryJoinTypes, IconArchiveDoc, IconArrowRight, SDKUI_Globals } from '../../helper';
|
|
7
7
|
import { displayMetadataValue, getDcmtTypesByQdAsync, getTIDsByQd, IsParametricQuery, prepareQdForSearchAsync } from '../../helper/queryHelper';
|
|
8
8
|
import { useOutsideClick } from '../../hooks/useOutsideClick';
|
|
9
9
|
import { FormModes, SearchResultContext } from '../../ts';
|
|
@@ -30,6 +30,7 @@ import TMMetadataEditor from '../editors/TMMetadataEditor';
|
|
|
30
30
|
import { ContextMenu } from '../NewComponents/ContextMenu';
|
|
31
31
|
import { useQueryParametersDialog } from '../../hooks/useQueryParametersDialog';
|
|
32
32
|
import TMSearchResult from '../features/search/TMSearchResult';
|
|
33
|
+
import TMQueryCountButton from './TMQueryCountButton';
|
|
33
34
|
export const StyledRowItem = styled.div ` display: flex; flex-direction: row; align-items: center; justify-content: flex-start; margin-bottom: 5px; gap: 3px; `;
|
|
34
35
|
export const StyledItemWrapper = styled.div ` border-radius: ${props => props.$borderRadius ?? '4px'}; padding: 4px; font-size: 1rem; user-select: none; width: max-content; `;
|
|
35
36
|
export const StyledAccordionItemContainer = styled.div ` width: 100%; padding: 2px; display: flex; flex-direction: column; overflow-x: auto; align-items: flex-start; margin-left: 5px; gap: 3px; max-height: 300px; `;
|
|
@@ -732,26 +733,7 @@ const TMQueryEditor = ({ formMode, inputData, onQDChanged, isExpertMode, showDis
|
|
|
732
733
|
}
|
|
733
734
|
};
|
|
734
735
|
// #endregion
|
|
735
|
-
|
|
736
|
-
if (IsParametricQuery(qd)) {
|
|
737
|
-
const qdParams = await confirmQueryParams(qd, lastQdParams);
|
|
738
|
-
setLastQdParams(qdParams);
|
|
739
|
-
if (!qdParams || qdParams.length <= 0)
|
|
740
|
-
return;
|
|
741
|
-
for (const qpd of qdParams) {
|
|
742
|
-
let wi = qd.where?.find(o => o.value1 == qpd.name);
|
|
743
|
-
if (wi)
|
|
744
|
-
wi.value1 = wi.value1?.replace(wi.value1, !qpd.value ? '' : qpd.value.toString());
|
|
745
|
-
else {
|
|
746
|
-
wi = qd.where?.find(o => o.value2 == qpd.name);
|
|
747
|
-
if (wi)
|
|
748
|
-
wi.value2 = wi.value2?.replace(wi.value2, !qpd.value ? '' : qpd.value.toString());
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
await getQueryCountAsync(qd, showSpinner);
|
|
753
|
-
};
|
|
754
|
-
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: () => getQueryCountLocalAsync(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) => {
|
|
736
|
+
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(TMQueryCountButton, { qd: { ...formData }, lastparams: lastQdParams, onLastQueryParamsChanged: (params) => { setLastQdParams(params); }, disabled: errorsCount > 0, showSpinner: 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) => {
|
|
755
737
|
let items = e.component.option("items");
|
|
756
738
|
if (items && items.length > 0) {
|
|
757
739
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -5,10 +5,11 @@ import { QueryDescriptor, ResultTypes, TMScopeNames } from '@topconsultnpm/sdk-t
|
|
|
5
5
|
import { FontSize } from '../../utils/theme';
|
|
6
6
|
import TMQueryEditor from './TMQueryEditor';
|
|
7
7
|
import TMButton from '../base/TMButton';
|
|
8
|
-
import {
|
|
8
|
+
import { IconEraser, IconPencil, SDKUI_Localizator } from '../../helper';
|
|
9
9
|
import TMVilViewer from '../base/TMVilViewer';
|
|
10
10
|
import { FormModes } from '../../ts';
|
|
11
11
|
import TMModal from '../base/TMModal';
|
|
12
|
+
import TMQueryCountButton from './TMQueryCountButton';
|
|
12
13
|
// #region Style
|
|
13
14
|
const StyledWrapper = styled.div `
|
|
14
15
|
display: flex;
|
|
@@ -28,7 +29,7 @@ const TMQuerySummary = ({ children, qd, validateSelect = true, validateOrderBy =
|
|
|
28
29
|
const [showEditor, setShowEditor] = useState(false);
|
|
29
30
|
const validationItemsQd = validationItems.filter(o => o.PropertyScopes.includes(TMScopeNames.qd) || o.PropertyName == TMScopeNames.qd);
|
|
30
31
|
const useInternalEditor = onEditClick === undefined;
|
|
31
|
-
return (_jsxs(StyledWrapper, { children: [_jsxs(StyledQueryToolbar, { children: [_jsx(TMButton, { caption: SDKUI_Localizator.QueryDefine, icon: _jsx(IconPencil, { fontSize: 16 }), btnStyle: 'toolbar', onClick: () => onEditClick ? onEditClick() : setShowEditor(true) }), _jsx(
|
|
32
|
+
return (_jsxs(StyledWrapper, { children: [_jsxs(StyledQueryToolbar, { children: [_jsx(TMButton, { caption: SDKUI_Localizator.QueryDefine, icon: _jsx(IconPencil, { fontSize: 16 }), btnStyle: 'toolbar', onClick: () => onEditClick ? onEditClick() : setShowEditor(true) }), _jsx(TMQueryCountButton, { qd: { ...qd }, lastparams: [], disabled: validationItemsQd.filter(o => o.ResultType == ResultTypes.ERROR).length > 0, showSpinner: true }), _jsx(TMButton, { caption: SDKUI_Localizator.QueryClear, icon: _jsx(IconEraser, { fontSize: 16 }), btnStyle: 'toolbar', onClick: () => onValueChanged?.(new QueryDescriptor()) }), children] }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', width: '100%', overflowX: 'auto' }, children: [qd && qd.from &&
|
|
32
33
|
_jsx(TMQueryEditor, { formMode: FormModes.ReadOnly, inputData: qd, showDistinct: showDistinct, isModal: false, showToolbar: false, validateSelect: validateSelect, validateOrderBy: validateOrderBy, raiseWarningForOnlyMetadataDcmtTypes: raiseWarningForOnlyMetadataDcmtTypes }), _jsx("div", { style: { padding: '0px 5px' }, children: _jsx(TMVilViewer, { vil: validationItemsQd }) })] }), useInternalEditor && showEditor &&
|
|
33
34
|
_jsx(TMModal, { title: SDKUI_Localizator.QueryDefine, children: _jsx(TMQueryEditor, { formMode: FormModes.Update, inputData: qd, isModal: true, showDistinct: showDistinct, raiseWarningForOnlyMetadataDcmtTypes: raiseWarningForOnlyMetadataDcmtTypes, validateSelect: validateSelect, validateOrderBy: validateOrderBy, onApplied: (newValue) => onValueChanged?.(newValue), onClose: () => { setShowEditor(false); } }) })] }));
|
|
34
35
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { QueryParameterDescriptor } from '@topconsultnpm/sdk-ts';
|
|
4
|
-
import { TMModal, TMTextBox, TMButton } from "../components";
|
|
4
|
+
import { TMModal, TMTextBox, TMButton, TMCard, StyledDivHorizontal } from "../components";
|
|
5
5
|
import { IconApply, IconCloseOutline, SDKUI_Localizator } from "../helper";
|
|
6
|
-
import { TMColors } from "../utils/theme";
|
|
6
|
+
import { TMColors, TMMargin } from "../utils/theme";
|
|
7
7
|
const paramPrefix = "{@QueryParam";
|
|
8
8
|
export const useQueryParametersDialog = () => {
|
|
9
9
|
const [promise, setPromise] = useState(null);
|
|
@@ -56,15 +56,15 @@ export const useQueryParametersDialog = () => {
|
|
|
56
56
|
};
|
|
57
57
|
const ConfirmQueryParamsDialog = () => {
|
|
58
58
|
return (open ?
|
|
59
|
-
_jsx(TMModal, { title: SDKUI_Localizator.QueryParamBind, height:
|
|
60
|
-
return (_jsx(TMTextBox, { placeHolder: `${SDKUI_Localizator.EnterValue} ...`, label: qdp.name, autoFocus: index == 0, value: qdp.value ?? '', onValueChanged: (e) => {
|
|
59
|
+
_jsx(TMModal, { title: SDKUI_Localizator.QueryParamBind, height: `${qdParams.length > 0 ? (qdParams.length * 73) + 73 : 100}px`, width: "400px", onClose: handleClose, children: _jsxs(TMCard, { scrollX: true, height: "100%", children: [qdParams.map((qdp, index) => {
|
|
60
|
+
return (_jsx(TMTextBox, { elementStyle: { marginBottom: TMMargin.smallMargin }, placeHolder: `${SDKUI_Localizator.EnterValue} ...`, label: qdp.name, autoFocus: index == 0, value: qdp.value ?? '', onValueChanged: (e) => {
|
|
61
61
|
let newQdp = qdParamsOut.find(o => o.id == qdp.id);
|
|
62
62
|
if (newQdp)
|
|
63
63
|
newQdp.value = e.target.value;
|
|
64
64
|
else
|
|
65
65
|
qdParamsOut.push({ id: qdp.id, name: qdp.name, value: e.target.value });
|
|
66
66
|
} }, qdp.id));
|
|
67
|
-
}), _jsxs(
|
|
67
|
+
}), _jsxs(StyledDivHorizontal, { style: { gap: 10, marginBottom: TMMargin.smallMargin, width: '100%', alignItems: 'center' }, 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 })] })] }) })
|
|
68
68
|
: _jsx(_Fragment, {}));
|
|
69
69
|
};
|
|
70
70
|
return [confirmQueryParams, ConfirmQueryParamsDialog];
|