@leav/ui 1.12.0 → 1.13.0
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/dist/__mocks__/utils.d.ts +3 -0
- package/dist/__mocks__/utils.js +2 -0
- package/dist/__mocks__/utils.js.map +1 -0
- package/dist/_gqlTypes/index.d.ts +361 -116
- package/dist/_gqlTypes/index.js +261 -51
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/attributes/attributeDetailsFragment.js +3 -0
- package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
- package/dist/components/Explorer/DataView.js +31 -14
- package/dist/components/Explorer/DataView.js.map +1 -1
- package/dist/components/Explorer/_constants.d.ts +0 -1
- package/dist/components/Explorer/_constants.js +0 -1
- package/dist/components/Explorer/_constants.js.map +1 -1
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +5 -9
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/ResultsCount.js +2 -2
- package/dist/components/Explorer/actions-mass/ResultsCount.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.d.ts +4 -9
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js +3 -11
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts +8 -8
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +26 -13
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.d.ts +7 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js +30 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.d.ts +23 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.js +2 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.d.ts +4 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js +46 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.d.ts +12 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js +24 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.d.ts +13 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js +28 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js.map +1 -0
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +6 -10
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +5 -8
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.d.ts +8 -2
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +104 -72
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useMassActions.js +30 -19
- package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
- package/dist/components/Explorer/conditionsHelper.d.ts +2 -1
- package/dist/components/Explorer/conditionsHelper.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js +6 -4
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js.map +1 -1
- package/dist/components/Filters/_types.d.ts +3 -0
- package/dist/components/Filters/_types.js.map +1 -1
- package/dist/components/Filters/conditionsHelper.d.ts +2 -1
- package/dist/components/Filters/conditionsHelper.js.map +1 -1
- package/dist/components/Filters/context/filtersReducer.js +14 -1
- package/dist/components/Filters/context/filtersReducer.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
- package/dist/components/Filters/useFilters.d.ts +198 -0
- package/dist/components/Filters/useTransformFilters.js +4 -2
- package/dist/components/Filters/useTransformFilters.js.map +1 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.js +8 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.d.ts +1 -4
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js +5 -9
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js +4 -8
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
- package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js +4 -8
- package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useConfirmModal/__mocks__/index.d.ts +1 -0
- package/dist/hooks/useConfirmModal/__mocks__/index.js +5 -0
- package/dist/hooks/useConfirmModal/__mocks__/index.js.map +1 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.d.ts +3 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js +7 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js.map +1 -0
- package/dist/hooks/useConfirmModal/index.d.ts +1 -0
- package/dist/hooks/useConfirmModal/index.js +5 -0
- package/dist/hooks/useConfirmModal/index.js.map +1 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.d.ts +7 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.js +25 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.js.map +1 -0
- package/dist/hooks/useGetRecordIdCard/index.d.ts +1 -0
- package/dist/hooks/useGetRecordIdCard/index.js +5 -0
- package/dist/hooks/useGetRecordIdCard/index.js.map +1 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.d.ts +18 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js +20 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.d.ts +6 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js +8 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/types.d.ts +10 -3
- package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +11 -2
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +31 -10
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.d.ts +13 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js +59 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.d.ts +13 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js +29 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js.map +1 -0
- package/dist/hooks/useIFrameMessengerClient/IFrameMessengerClient.js +3 -0
- package/dist/hooks/useIFrameMessengerClient/IFrameMessengerClient.js.map +1 -1
- package/dist/hooks/useIFrameMessengerClient/iFrameMessengerClientContext.d.ts +1 -0
- package/dist/hooks/useIFrameMessengerClient/useIFrameMessengerClient.d.ts +1 -0
- package/dist/hooks/useSharedTranslation/__mocks__/useSharedTranslation.js.map +1 -1
- package/dist/locales/en/shared.json +6 -4
- package/dist/locales/fr/shared.json +8 -6
- package/package.json +17 -17
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +0 -8
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +0 -40
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +0 -17
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +0 -42
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.d.ts +0 -5
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +0 -20
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +0 -12
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +0 -30
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeDetailsFragment.js","sourceRoot":"","sources":["../../../src/_queries/attributes/attributeDetailsFragment.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AAEnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"attributeDetailsFragment.js","sourceRoot":"","sources":["../../../src/_queries/attributes/attributeDetailsFragment.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AAEnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiE1C,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {gql} from '@apollo/client';\n\nexport const attributeDetailsFragment = gql`\n fragment AttributeDetails on Attribute {\n id\n type\n format\n system\n readonly\n label\n description\n required\n multiple_values\n multi_link_display_option\n multi_tree_display_option\n metadata_fields {\n id\n label\n type\n format\n }\n versions_conf {\n versionable\n mode\n profile {\n id\n label\n trees {\n id\n label\n }\n }\n }\n libraries {\n id\n label\n }\n\n ... on StandardAttribute {\n unique\n }\n\n ... on LinkAttribute {\n linked_library {\n id\n label\n }\n reverse_link\n smart_filter {\n enable\n through {\n id\n }\n }\n }\n ... on TreeAttribute {\n linked_tree {\n id\n label\n }\n permissions_conf_dependent_values {\n dependenciesTreeAttributes {\n id\n }\n }\n }\n }\n`;\n"]}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
3
|
// This file is released under LGPL V3
|
|
4
4
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
|
-
import { memo } from 'react';
|
|
5
|
+
import { memo, useCallback, useState } from 'react';
|
|
6
6
|
import { KitPagination, KitTable } from 'aristid-ds';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import isEqual from 'lodash/isEqual';
|
|
@@ -13,7 +13,7 @@ import { useColumnWidth } from './useColumnWidth';
|
|
|
13
13
|
import { WHO_AM_I_COLUMN } from './_constants';
|
|
14
14
|
import { TableNameCell } from './TableNameCell';
|
|
15
15
|
import cn from 'classnames';
|
|
16
|
-
import {
|
|
16
|
+
import { throttle } from 'lodash';
|
|
17
17
|
const tableRowHeight = 56;
|
|
18
18
|
const tableHeaderMinLineHeight = 22;
|
|
19
19
|
const DataViewContainerDivStyled = styled.div `
|
|
@@ -60,11 +60,9 @@ const StyledTable = styled(KitTable) `
|
|
|
60
60
|
.ant-table-cell {
|
|
61
61
|
min-height: ${tableRowHeight}px;
|
|
62
62
|
height: auto !important;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
td:has(+ td) .ant-table-cell .actions-list {
|
|
67
|
-
margin-left: auto;
|
|
63
|
+
.actions-list {
|
|
64
|
+
margin-left: auto;
|
|
65
|
+
}
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
68
|
|
|
@@ -92,19 +90,17 @@ export const DataView = memo(({ dataGroupedFilteredSorted, attributesToDisplay,
|
|
|
92
90
|
title: () => attributesProperties[attributeName].label,
|
|
93
91
|
ellipsis: useSmallHeaderSize,
|
|
94
92
|
width: getFieldColumnWidth(attributesProperties[attributeName]),
|
|
95
|
-
shouldCellUpdate: (record, prevRecord) => isMassSelectionAll ||
|
|
93
|
+
shouldCellUpdate: (record, prevRecord) => isMassSelectionAll ||
|
|
94
|
+
record.propertiesById[attributeName] !== prevRecord.propertiesById[attributeName],
|
|
96
95
|
render: (_, item) => (_jsx(TableCell, { attributeProperties: attributesProperties[attributeName], values: item.propertiesById[attributeName] })),
|
|
97
96
|
});
|
|
98
97
|
const columns = attributesToDisplay.map(getColumnProps);
|
|
99
|
-
const whoIAmColumn = {
|
|
98
|
+
const whoIAmColumn = useWhoAmIColumn({
|
|
100
99
|
...getColumnProps(WHO_AM_I_COLUMN),
|
|
101
|
-
title: () => t('explorer.name'),
|
|
102
100
|
fixed: 'left',
|
|
103
101
|
render: (_, item) => _jsx(TableNameCell, { item: item, itemActions: itemActions }),
|
|
104
102
|
shouldCellUpdate: (record, prevRecord) => isMassSelectionAll || record.whoAmI !== prevRecord.whoAmI,
|
|
105
|
-
};
|
|
106
|
-
// replace `width` by `min-width` for the whoAmI column definition to prevent selection column to expand when all column have a width defined (which is a native table behaviour).
|
|
107
|
-
whoIAmColumn[INTERNAL_COL_DEFINE] = { style: { width: 'unset', minWidth: whoIAmColumn.width } };
|
|
103
|
+
});
|
|
108
104
|
const itemActionToUseOnRowClick = itemActions.find(itemAction => itemAction.useItemActionOnRowClick);
|
|
109
105
|
const _rowSelection = onSelectionChange === null
|
|
110
106
|
? undefined
|
|
@@ -131,11 +127,32 @@ export const DataView = memo(({ dataGroupedFilteredSorted, attributesToDisplay,
|
|
|
131
127
|
// TODO: handle columns width based on attribute type/format
|
|
132
128
|
return (_jsxs(DataViewContainerDivStyled, { ref: containerRef, className: cn({ headless: hideTableHeader }), children: [_jsx(StyledTable, { className: cn({
|
|
133
129
|
'row-clickable': itemActionToUseOnRowClick,
|
|
134
|
-
}), showHeader: dataGroupedFilteredSorted.length > 0 && !hideTableHeader, headerLineSize: useSmallHeaderSize ? 's' :
|
|
130
|
+
}), showHeader: dataGroupedFilteredSorted.length > 0 && !hideTableHeader, headerLineSize: useSmallHeaderSize ? 's' : 'm', columns: [whoIAmColumn, ...columns], tableLayout: "fixed", scroll: {
|
|
135
131
|
y: tableBodyHeight ?? (hideTableHeader ? '100%' : scrollHeight),
|
|
136
132
|
x: '100%',
|
|
137
133
|
}, dataSource: dataGroupedFilteredSorted, pagination: false, rowSelection: _rowSelection, onRow: (item) => ({
|
|
138
134
|
onClick: () => itemActionToUseOnRowClick?.callback(item),
|
|
139
135
|
}) }), paginationProps && (_jsx("div", { className: "pagination", children: _jsx(KitPagination, { "aria-label": "pagination", showSizeChanger: true, showTotal: (total, [from, to]) => t('explorer.pagination-total-number', { from, to, count: total }), total: paginationProps.totalCount, defaultCurrent: paginationProps.currentPage, defaultPageSize: paginationProps.pageSize, pageSizeOptions: paginationProps.pageSizeOptions, onChange: paginationProps.setNewPage, onShowSizeChange: paginationProps.setNewPageSize }) }))] }));
|
|
140
136
|
}, arePropsEqual);
|
|
137
|
+
// This hook exists to change the width of the whoAmI column dynamically.
|
|
138
|
+
// The aimed result is a whoAmI column that always expand and is the only one to expand if there is horizontal space available, but never shrinks under its specifed width.
|
|
139
|
+
// This behaviour is mostly present to prevent the selection column to expand
|
|
140
|
+
function useWhoAmIColumn(props) {
|
|
141
|
+
const { t } = useSharedTranslation();
|
|
142
|
+
const [width, setWidth] = useState(props.width);
|
|
143
|
+
// initialize observer only once using the useState initializer
|
|
144
|
+
const [resizeObserver] = useState(() => new ResizeObserver(throttle(([node]) => setWidth(node.contentRect.width < props.width ? props.width : '100%'), 100)));
|
|
145
|
+
// use the `ref` prop as a callback to retrieve the div element and connect the observer on it
|
|
146
|
+
const onWhoAmIColumnRender = useCallback((node) => {
|
|
147
|
+
resizeObserver.disconnect();
|
|
148
|
+
if (node) {
|
|
149
|
+
resizeObserver.observe(node);
|
|
150
|
+
}
|
|
151
|
+
}, []);
|
|
152
|
+
return {
|
|
153
|
+
...props,
|
|
154
|
+
title: () => _jsx("div", { ref: onWhoAmIColumnRender, children: t('explorer.name') }),
|
|
155
|
+
width,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
141
158
|
//# sourceMappingURL=DataView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataView.js","sourceRoot":"","sources":["../../../src/components/Explorer/DataView.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE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,CAAC,EAAE,EAAE,CAC7B,CAAC,CAAC,kCAAkC,EAAE,EAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,EAEnE,KAAK,EAAE,eAAe,CAAC,UAAU,EACjC,cAAc,EAAE,eAAe,CAAC,WAAW,EAC3C,eAAe,EAAE,eAAe,CAAC,QAAQ,EACzC,eAAe,EAAE,eAAe,CAAC,eAAe,EAChD,QAAQ,EAAE,eAAe,CAAC,UAAU,EACpC,gBAAgB,EAAE,eAAe,CAAC,cAAc,GAClD,GACA,CACT,IACwB,CAChC,CAAC;AACN,CAAC,EACD,aAAa,CAChB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ComponentProps, type FunctionComponent, type Key, memo} from 'react';\nimport {KitPagination, KitTable} from 'aristid-ds';\nimport {type KitTableColumnType} from 'aristid-ds/dist/Kit/DataDisplay/Table/types';\nimport styled from 'styled-components';\nimport isEqual from 'lodash/isEqual';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IExplorerData, type IItemAction, type IItemData} from './_types';\nimport {TableCell} from './TableCell';\nimport {defaultPaginationHeight, useTableScrollableHeight} from './useTableScrollableHeight';\nimport {useColumnWidth} from './useColumnWidth';\nimport {WHO_AM_I_COLUMN} from './_constants';\nimport {TableNameCell} from './TableNameCell';\nimport cn from 'classnames';\nimport {INTERNAL_COL_DEFINE} from 'rc-table';\n\nconst tableRowHeight = 56;\nconst tableHeaderMinLineHeight = 22;\n\nconst DataViewContainerDivStyled = styled.div`\n flex: 1 1 min-content;\n overflow: hidden;\n\n &.headless {\n overflow-y: auto;\n }\n\n .kit-table {\n padding-bottom: ${defaultPaginationHeight}px;\n position: relative;\n }\n\n .pagination {\n flex: 0 0 auto;\n justify-content: center;\n display: flex;\n padding-top: calc(var(--general-spacing-xs) * 1px);\n }\n`;\n\n// TODO: Table component should be updated fix header display\nconst StyledTable = styled(KitTable)`\n .ant-table-thead > tr > th {\n padding-top: calc(var(--general-spacing-xxs) * 1px) !important;\n padding-bottom: calc(var(--general-spacing-xxs) * 1px) !important;\n height: ${tableRowHeight}px;\n\n .ant-table-cell {\n min-height: ${tableHeaderMinLineHeight}px;\n height: auto !important;\n padding: 0 calc(var(--general-spacing-s) * 1px) 0 0;\n }\n }\n\n .ant-table-tbody > tr:hover .ant-table-cell {\n .actions-list {\n display: inline-flex;\n }\n }\n\n .ant-table-tbody > tr {\n .ant-table-cell {\n min-height: ${tableRowHeight}px;\n height: auto !important;\n }\n\n /* Align actions to the right of the cell only if another column is present after */\n td:has(+ td) .ant-table-cell .actions-list {\n margin-left: auto;\n }\n }\n\n &.row-clickable {\n .ant-table-tbody > tr {\n cursor: pointer;\n }\n }\n`;\n\ninterface IDataViewProps {\n dataGroupedFilteredSorted: IItemData[];\n itemActions: IItemAction[];\n attributesProperties: IExplorerData['attributes'];\n attributesToDisplay: string[];\n paginationProps?: {\n pageSizeOptions: number[];\n totalCount: number;\n currentPage: number;\n pageSize: number;\n setNewPage: (page: number, pageSize: number) => void;\n setNewPageSize: (page: number, pageSize: number) => void;\n };\n selection: {\n onSelectItem?: null | ((selectedItem: IItemData) => void);\n onSelectionChange: null | ((keys: Key[]) => void);\n isMassSelectionAll: boolean;\n selectedKeys: Key[];\n mode?: 'simple' | 'multiple';\n };\n hideTableHeader: boolean;\n useSmallHeaderSize?: boolean;\n tableBodyHeight?: string;\n}\n\n// TODO: tests will fail if we don't check attributeToDisplay because we have a render with no attributes but data is present. We should check why there's this behavior\nconst arePropsEqual = (prevProps: IDataViewProps, nextProps: IDataViewProps) =>\n isEqual(\n {\n attributesToDisplay: prevProps.attributesToDisplay,\n data: prevProps.dataGroupedFilteredSorted,\n selectedKeys: prevProps.selection.selectedKeys,\n },\n {\n attributesToDisplay: nextProps.attributesToDisplay,\n data: nextProps.dataGroupedFilteredSorted,\n selectedKeys: nextProps.selection.selectedKeys,\n },\n );\n\nexport const DataView: FunctionComponent<IDataViewProps> = memo(\n ({\n dataGroupedFilteredSorted,\n attributesToDisplay,\n attributesProperties,\n paginationProps,\n itemActions,\n selection: {onSelectItem, onSelectionChange, selectedKeys, isMassSelectionAll, mode},\n hideTableHeader = false,\n useSmallHeaderSize = false,\n tableBodyHeight,\n }) => {\n const {t} = useSharedTranslation();\n\n const {containerRef, scrollHeight} = useTableScrollableHeight(!!paginationProps);\n const {getFieldColumnWidth} = useColumnWidth();\n\n const getColumnProps = (attributeName: string): KitTableColumnType<IItemData> => ({\n title: () => attributesProperties[attributeName].label,\n ellipsis: useSmallHeaderSize,\n width: getFieldColumnWidth(attributesProperties[attributeName]),\n shouldCellUpdate: (record, prevRecord) =>\n isMassSelectionAll || record.propertiesById[attributeName] !== prevRecord.propertiesById[attributeName],\n render: (_, item) => (\n <TableCell\n attributeProperties={attributesProperties[attributeName]}\n values={item.propertiesById[attributeName]}\n />\n ),\n });\n\n const columns = attributesToDisplay.map(getColumnProps);\n\n const whoIAmColumn: KitTableColumnType<IItemData> = {\n ...getColumnProps(WHO_AM_I_COLUMN),\n title: () => t('explorer.name'),\n fixed: 'left',\n render: (_, item) => <TableNameCell item={item} itemActions={itemActions} />,\n shouldCellUpdate: (record, prevRecord) => isMassSelectionAll || record.whoAmI !== prevRecord.whoAmI,\n };\n\n // replace `width` by `min-width` for the whoAmI column definition to prevent selection column to expand when all column have a width defined (which is a native table behaviour).\n whoIAmColumn[INTERNAL_COL_DEFINE] = {style: {width: 'unset', minWidth: whoIAmColumn.width}};\n\n const itemActionToUseOnRowClick = itemActions.find(itemAction => itemAction.useItemActionOnRowClick);\n\n const _rowSelection: ComponentProps<typeof KitTable>['rowSelection'] =\n onSelectionChange === null\n ? undefined\n : {\n type: mode === 'simple' ? 'radio' : 'checkbox',\n columnTitle: ' ', // blank string to hide select all checkbox from <KitTable />\n selectedRowKeys: selectedKeys,\n preserveSelectedRowKeys: true,\n // TODO: review types from antd directly\n onChange: (selectedRowKeys: Key[]) => {\n const lastSelectedKey = selectedRowKeys[selectedRowKeys.length - 1];\n const lastSelectedItem = dataGroupedFilteredSorted.find(data => data.key === lastSelectedKey);\n\n onSelectionChange(selectedRowKeys);\n\n if (lastSelectedItem) {\n onSelectItem?.(lastSelectedItem);\n }\n },\n getCheckboxProps: isMassSelectionAll\n ? () => ({\n disabled: true,\n })\n : undefined,\n };\n\n // TODO: handle columns width based on attribute type/format\n return (\n <DataViewContainerDivStyled ref={containerRef} className={cn({headless: hideTableHeader})}>\n <StyledTable\n className={cn({\n 'row-clickable': itemActionToUseOnRowClick,\n })}\n showHeader={dataGroupedFilteredSorted.length > 0 && !hideTableHeader}\n headerLineSize={useSmallHeaderSize ? 's' : undefined}\n columns={[whoIAmColumn, ...columns]}\n tableLayout=\"fixed\"\n scroll={{\n y: tableBodyHeight ?? (hideTableHeader ? '100%' : scrollHeight),\n x: '100%',\n }}\n dataSource={dataGroupedFilteredSorted}\n pagination={false}\n rowSelection={_rowSelection}\n onRow={(item: IItemData) => ({\n onClick: () => itemActionToUseOnRowClick?.callback(item),\n })}\n />\n {paginationProps && (\n <div className=\"pagination\">\n <KitPagination\n aria-label=\"pagination\"\n showSizeChanger\n showTotal={(total, [from, to]) =>\n t('explorer.pagination-total-number', {from, to, count: total})\n }\n total={paginationProps.totalCount}\n defaultCurrent={paginationProps.currentPage}\n defaultPageSize={paginationProps.pageSize}\n pageSizeOptions={paginationProps.pageSizeOptions}\n onChange={paginationProps.setNewPage}\n onShowSizeChange={paginationProps.setNewPageSize}\n />\n </div>\n )}\n </DataViewContainerDivStyled>\n );\n },\n arePropsEqual,\n);\n"]}
|
|
1
|
+
{"version":3,"file":"DataView.js","sourceRoot":"","sources":["../../../src/components/Explorer/DataView.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AAEtE,OAAO,EAAwD,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAC,MAA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C,eAAe,EAAE,eAAe,CAAC,eAAe,EAChD,QAAQ,EAAE,eAAe,CAAC,UAAU,EACpC,gBAAgB,EAAE,eAAe,CAAC,cAAc,GAClD,GACA,CACT,IACwB,CAChC,CAAC;AACN,CAAC,EACD,aAAa,CAChB,CAAC;AAEF,yEAAyE;AACzE,2KAA2K;AAC3K,6EAA6E;AAC7E,SAAS,eAAe,CAAC,KAAsD;IAC3E,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAkB,KAAK,CAAC,KAAK,CAAC,CAAC;IAEjE,+DAA+D;IAC/D,MAAM,CAAC,cAAc,CAAC,GAAG,QAAQ,CAC7B,GAAG,EAAE,CACD,IAAI,cAAc,CACd,QAAQ,CACJ,CAAC,CAAC,IAAI,CAAwB,EAAE,EAAE,CAC9B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EACzE,GAAG,CACN,CACJ,CACR,CAAC;IAEF,8FAA8F;IAC9F,MAAM,oBAAoB,GAAG,WAAW,CAAC,CAAC,IAAoB,EAAE,EAAE;QAC9D,cAAc,CAAC,UAAU,EAAE,CAAC;QAC5B,IAAI,IAAI,EAAE,CAAC;YACP,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACH,GAAG,KAAK;QACR,KAAK,EAAE,GAAG,EAAE,CAAC,cAAK,GAAG,EAAE,oBAAoB,YAAG,CAAC,CAAC,eAAe,CAAC,GAAO;QACvE,KAAK;KACR,CAAC;AACN,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\n\nimport {type ComponentProps, type FunctionComponent, type Key, memo, useCallback, useState} from 'react';\nimport {KitPagination, KitTable} from 'aristid-ds';\nimport {type KitTableColumnType} from 'aristid-ds/dist/Kit/DataDisplay/Table/types';\nimport styled from 'styled-components';\nimport isEqual from 'lodash/isEqual';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IExplorerData, type IItemAction, type IItemData} from './_types';\nimport {TableCell} from './TableCell';\nimport {defaultPaginationHeight, useTableScrollableHeight} from './useTableScrollableHeight';\nimport {useColumnWidth} from './useColumnWidth';\nimport {WHO_AM_I_COLUMN} from './_constants';\nimport {TableNameCell} from './TableNameCell';\nimport cn from 'classnames';\nimport {throttle} from 'lodash';\n\nconst tableRowHeight = 56;\nconst tableHeaderMinLineHeight = 22;\n\nconst DataViewContainerDivStyled = styled.div`\n flex: 1 1 min-content;\n overflow: hidden;\n\n &.headless {\n overflow-y: auto;\n }\n\n .kit-table {\n padding-bottom: ${defaultPaginationHeight}px;\n position: relative;\n }\n\n .pagination {\n flex: 0 0 auto;\n justify-content: center;\n display: flex;\n padding-top: calc(var(--general-spacing-xs) * 1px);\n }\n`;\n\n// TODO: Table component should be updated fix header display\nconst StyledTable = styled(KitTable)`\n .ant-table-thead > tr > th {\n padding-top: calc(var(--general-spacing-xxs) * 1px) !important;\n padding-bottom: calc(var(--general-spacing-xxs) * 1px) !important;\n height: ${tableRowHeight}px;\n\n .ant-table-cell {\n min-height: ${tableHeaderMinLineHeight}px;\n height: auto !important;\n padding: 0 calc(var(--general-spacing-s) * 1px) 0 0;\n }\n }\n\n .ant-table-tbody > tr:hover .ant-table-cell {\n .actions-list {\n display: inline-flex;\n }\n }\n\n .ant-table-tbody > tr {\n .ant-table-cell {\n min-height: ${tableRowHeight}px;\n height: auto !important;\n .actions-list {\n margin-left: auto;\n }\n }\n }\n\n &.row-clickable {\n .ant-table-tbody > tr {\n cursor: pointer;\n }\n }\n`;\n\ninterface IDataViewProps {\n dataGroupedFilteredSorted: IItemData[];\n itemActions: IItemAction[];\n attributesProperties: IExplorerData['attributes'];\n attributesToDisplay: string[];\n paginationProps?: {\n pageSizeOptions: number[];\n totalCount: number;\n currentPage: number;\n pageSize: number;\n setNewPage: (page: number, pageSize: number) => void;\n setNewPageSize: (page: number, pageSize: number) => void;\n };\n selection: {\n onSelectItem?: null | ((selectedItem: IItemData) => void);\n onSelectionChange: null | ((keys: Key[]) => void);\n isMassSelectionAll: boolean;\n selectedKeys: Key[];\n mode?: 'simple' | 'multiple';\n };\n hideTableHeader: boolean;\n useSmallHeaderSize?: boolean;\n tableBodyHeight?: string;\n}\n\n// TODO: tests will fail if we don't check attributeToDisplay because we have a render with no attributes but data is present. We should check why there's this behavior\nconst arePropsEqual = (prevProps: IDataViewProps, nextProps: IDataViewProps) =>\n isEqual(\n {\n attributesToDisplay: prevProps.attributesToDisplay,\n data: prevProps.dataGroupedFilteredSorted,\n selectedKeys: prevProps.selection.selectedKeys,\n },\n {\n attributesToDisplay: nextProps.attributesToDisplay,\n data: nextProps.dataGroupedFilteredSorted,\n selectedKeys: nextProps.selection.selectedKeys,\n },\n );\n\nexport const DataView: FunctionComponent<IDataViewProps> = memo(\n ({\n dataGroupedFilteredSorted,\n attributesToDisplay,\n attributesProperties,\n paginationProps,\n itemActions,\n selection: {onSelectItem, onSelectionChange, selectedKeys, isMassSelectionAll, mode},\n hideTableHeader = false,\n useSmallHeaderSize = false,\n tableBodyHeight,\n }) => {\n const {t} = useSharedTranslation();\n\n const {containerRef, scrollHeight} = useTableScrollableHeight(!!paginationProps);\n const {getFieldColumnWidth} = useColumnWidth();\n\n const getColumnProps = (attributeName: string) =>\n ({\n title: () => attributesProperties[attributeName].label,\n ellipsis: useSmallHeaderSize,\n width: getFieldColumnWidth(attributesProperties[attributeName]),\n shouldCellUpdate: (record, prevRecord) =>\n isMassSelectionAll ||\n record.propertiesById[attributeName] !== prevRecord.propertiesById[attributeName],\n render: (_, item) => (\n <TableCell\n attributeProperties={attributesProperties[attributeName]}\n values={item.propertiesById[attributeName]}\n />\n ),\n }) satisfies KitTableColumnType<IItemData>;\n\n const columns = attributesToDisplay.map(getColumnProps);\n\n const whoIAmColumn = useWhoAmIColumn({\n ...getColumnProps(WHO_AM_I_COLUMN),\n fixed: 'left',\n render: (_, item) => <TableNameCell item={item} itemActions={itemActions} />,\n shouldCellUpdate: (record, prevRecord) => isMassSelectionAll || record.whoAmI !== prevRecord.whoAmI,\n });\n\n const itemActionToUseOnRowClick = itemActions.find(itemAction => itemAction.useItemActionOnRowClick);\n\n const _rowSelection: ComponentProps<typeof KitTable>['rowSelection'] =\n onSelectionChange === null\n ? undefined\n : {\n type: mode === 'simple' ? 'radio' : 'checkbox',\n columnTitle: ' ', // blank string to hide select all checkbox from <KitTable />\n selectedRowKeys: selectedKeys,\n preserveSelectedRowKeys: true,\n // TODO: review types from antd directly\n onChange: (selectedRowKeys: Key[]) => {\n const lastSelectedKey = selectedRowKeys[selectedRowKeys.length - 1];\n const lastSelectedItem = dataGroupedFilteredSorted.find(data => data.key === lastSelectedKey);\n\n onSelectionChange(selectedRowKeys);\n\n if (lastSelectedItem) {\n onSelectItem?.(lastSelectedItem);\n }\n },\n getCheckboxProps: isMassSelectionAll\n ? () => ({\n disabled: true,\n })\n : undefined,\n };\n\n // TODO: handle columns width based on attribute type/format\n return (\n <DataViewContainerDivStyled ref={containerRef} className={cn({headless: hideTableHeader})}>\n <StyledTable\n className={cn({\n 'row-clickable': itemActionToUseOnRowClick,\n })}\n showHeader={dataGroupedFilteredSorted.length > 0 && !hideTableHeader}\n headerLineSize={useSmallHeaderSize ? 's' : 'm'}\n columns={[whoIAmColumn, ...columns]}\n tableLayout=\"fixed\"\n scroll={{\n y: tableBodyHeight ?? (hideTableHeader ? '100%' : scrollHeight),\n x: '100%',\n }}\n dataSource={dataGroupedFilteredSorted}\n pagination={false}\n rowSelection={_rowSelection}\n onRow={(item: IItemData) => ({\n onClick: () => itemActionToUseOnRowClick?.callback(item),\n })}\n />\n {paginationProps && (\n <div className=\"pagination\">\n <KitPagination\n aria-label=\"pagination\"\n showSizeChanger\n showTotal={(total, [from, to]) =>\n t('explorer.pagination-total-number', {from, to, count: total})\n }\n total={paginationProps.totalCount}\n defaultCurrent={paginationProps.currentPage}\n defaultPageSize={paginationProps.pageSize}\n pageSizeOptions={paginationProps.pageSizeOptions}\n onChange={paginationProps.setNewPage}\n onShowSizeChange={paginationProps.setNewPageSize}\n />\n </div>\n )}\n </DataViewContainerDivStyled>\n );\n },\n arePropsEqual,\n);\n\n// This hook exists to change the width of the whoAmI column dynamically.\n// The aimed result is a whoAmI column that always expand and is the only one to expand if there is horizontal space available, but never shrinks under its specifed width.\n// This behaviour is mostly present to prevent the selection column to expand\nfunction useWhoAmIColumn(props: KitTableColumnType<IItemData> & {width: number}) {\n const {t} = useSharedTranslation();\n\n const [width, setWidth] = useState<number | string>(props.width);\n\n // initialize observer only once using the useState initializer\n const [resizeObserver] = useState(\n () =>\n new ResizeObserver(\n throttle(\n ([node]: ResizeObserverEntry[]) =>\n setWidth(node.contentRect.width < props.width ? props.width : '100%'),\n 100,\n ),\n ),\n );\n\n // use the `ref` prop as a callback to retrieve the div element and connect the observer on it\n const onWhoAmIColumnRender = useCallback((node: HTMLDivElement) => {\n resizeObserver.disconnect();\n if (node) {\n resizeObserver.observe(node);\n }\n }, []);\n\n return {\n ...props,\n title: () => <div ref={onWhoAmIColumnRender}>{t('explorer.name')}</div>,\n width,\n };\n}\n"]}
|
|
@@ -8,4 +8,3 @@ export declare const CREATE_RECORD_MODAL_CLASSNAME = "create-record-modal";
|
|
|
8
8
|
export declare const EDIT_RECORD_MODAL_CLASSNAME = "edit-record-modal";
|
|
9
9
|
export declare const WHO_AM_I_COLUMN = "whoAmI";
|
|
10
10
|
export declare const SNACKBAR_MASS_ID = "SNACKBAR_MASS_ID";
|
|
11
|
-
export declare const BREAK_TWO_LINES = "\n\n";
|
|
@@ -20,5 +20,4 @@ export const CREATE_RECORD_MODAL_CLASSNAME = 'create-record-modal';
|
|
|
20
20
|
export const EDIT_RECORD_MODAL_CLASSNAME = 'edit-record-modal';
|
|
21
21
|
export const WHO_AM_I_COLUMN = 'whoAmI';
|
|
22
22
|
export const SNACKBAR_MASS_ID = 'SNACKBAR_MASS_ID';
|
|
23
|
-
export const BREAK_TWO_LINES = '\n\n';
|
|
24
23
|
//# sourceMappingURL=_constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_constants.js","sourceRoot":"","sources":["../../../src/components/Explorer/_constants.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAGxC,yJAAyJ;AACzJ,MAAM,CAAC,MAAM,+BAA+B,GAAgC;IACxE,KAAK,EAAE,SAAS,CAAC,IAAI;IACrB,MAAM,EAAE,SAAS,CAAC,KAAK;IACvB,QAAQ,EAAE,SAAS,CAAC,QAAQ;IAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAgC;IACxE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO;IACzB,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,QAAQ;IAC3B,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU;CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAExC,MAAM,CAAC,MAAM,4BAA4B,GAAG,YAAY,CAAC;AAEzD,MAAM,CAAC,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AAEnE,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"_constants.js","sourceRoot":"","sources":["../../../src/components/Explorer/_constants.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAGxC,yJAAyJ;AACzJ,MAAM,CAAC,MAAM,+BAA+B,GAAgC;IACxE,KAAK,EAAE,SAAS,CAAC,IAAI;IACrB,MAAM,EAAE,SAAS,CAAC,KAAK;IACvB,QAAQ,EAAE,SAAS,CAAC,QAAQ;IAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAgC;IACxE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO;IACzB,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,QAAQ;IAC3B,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU;CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAExC,MAAM,CAAC,MAAM,4BAA4B,GAAG,YAAY,CAAC;AAEzD,MAAM,CAAC,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AAEnE,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {ViewTypes} from '_ui/_gqlTypes';\nimport {type ViewType} from './manage-view-settings/store-view-settings/viewSettingsReducer';\n\n//TODO: this mapping is here for backward compatibility. When the old explorer is removed, we should updates types on the backend and remove this mapping\nexport const mapViewTypeFromExplorerToLegacy: Record<ViewType, ViewTypes> = {\n table: ViewTypes.list,\n mosaic: ViewTypes.cards,\n timeline: ViewTypes.timeline,\n list: ViewTypes.list,\n};\n\nexport const mapViewTypeFromLegacyToExplorer: Record<ViewTypes, ViewType> = {\n [ViewTypes.list]: 'table',\n [ViewTypes.cards]: 'mosaic',\n [ViewTypes.timeline]: 'timeline',\n};\n\nexport const MASS_SELECTION_ALL = 'all';\n\nexport const LINK_RECORDS_MODAL_CLASSNAME = 'link-modal';\n\nexport const CREATE_RECORD_MODAL_CLASSNAME = 'create-record-modal';\n\nexport const EDIT_RECORD_MODAL_CLASSNAME = 'edit-record-modal';\n\nexport const WHO_AM_I_COLUMN = 'whoAmI';\n\nexport const SNACKBAR_MASS_ID = 'SNACKBAR_MASS_ID';\n"]}
|
|
@@ -3,12 +3,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
// This file is released under LGPL V3
|
|
4
4
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { useConfirmModal } from '../../../hooks/useConfirmModal';
|
|
7
7
|
import { useActivateRecordsMutation, useDeactivateRecordsMutation, useDeleteValueMutation, } from '../../../_gqlTypes';
|
|
8
8
|
import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
|
|
9
9
|
import { useValuesCacheUpdate } from '../../../hooks/useValuesCacheUpdate';
|
|
10
10
|
import { ViewSettingsActionTypes } from '../manage-view-settings';
|
|
11
|
-
import {
|
|
11
|
+
import { MASS_SELECTION_ALL } from '../_constants';
|
|
12
|
+
import { BREAK_TWO_LINES } from '../../../constants';
|
|
12
13
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
13
14
|
import { faTrash, faTrashRestore } from '@fortawesome/free-solid-svg-icons';
|
|
14
15
|
/**
|
|
@@ -25,6 +26,7 @@ import { faTrash, faTrashRestore } from '@fortawesome/free-solid-svg-icons';
|
|
|
25
26
|
*/
|
|
26
27
|
export const useEditStatusItemAction = ({ isEnabled, canDeleteLinkValues, store: { view, dispatch }, onRemove, entrypoint, }) => {
|
|
27
28
|
const { t } = useSharedTranslation();
|
|
29
|
+
const { openConfirmModal } = useConfirmModal();
|
|
28
30
|
const updateValuesCache = useValuesCacheUpdate();
|
|
29
31
|
const [deactivateRecordsMutation] = useDeactivateRecordsMutation({
|
|
30
32
|
update(cache, deactivatedRecords) {
|
|
@@ -127,15 +129,9 @@ export const useEditStatusItemAction = ({ isEnabled, canDeleteLinkValues, store:
|
|
|
127
129
|
? t('explorer.deactivate_item_description_one')
|
|
128
130
|
: t('explorer.activate_item_description_one')
|
|
129
131
|
: t('explorer.delete_link_description_one');
|
|
130
|
-
|
|
131
|
-
width: '100%',
|
|
132
|
-
style: { content: { width: '90vw', maxWidth: '656px' } },
|
|
133
|
-
type: 'confirm',
|
|
134
|
-
icon: false,
|
|
132
|
+
openConfirmModal({
|
|
135
133
|
title,
|
|
136
134
|
content: content + BREAK_TWO_LINES + t('global.are_you_sure'),
|
|
137
|
-
okText: t('global.confirm') ?? undefined,
|
|
138
|
-
cancelText: t('global.cancel') ?? undefined,
|
|
139
135
|
onOk: async () => {
|
|
140
136
|
switch (entrypoint.type) {
|
|
141
137
|
case 'library':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditStatusItemAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-item/useEditStatusItemAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAgB,OAAO,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAGH,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAoD,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAC,eAAe,EAAE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V,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gCACd,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;4BACjC,CAAC;4BAED,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;wBAC/B,KAAK,MAAM;4BACP,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC;gCAC3C,SAAS,EAAE;oCACP,OAAO,EAAE,UAAU,CAAC,eAAe;oCACnC,SAAS,EAAE,UAAU,CAAC,eAAe;oCACrC,QAAQ,EAAE,UAAU,CAAC,cAAc;oCACnC,KAAK,EAAE;wCACH,OAAO,EAAE,MAAM;wCACf,QAAQ;qCACX;iCACJ;6BACJ,CAAC,CAAC;4BACH,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;4BACjB,OAAO,OAAO,CAAC;wBACnB;4BACI,OAAO;oBACf,CAAC;gBACL,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF;QACI,CAAC;QACD,yBAAyB;QACzB,wBAAwB;QACxB,uBAAuB;QACvB,mBAAmB;QACnB,UAAU,CAAC,IAAI;QACf,IAAI,CAAC,aAAa;QAClB,QAAQ;KACX,CACJ,CAAC;IAEF,OAAO;QACH,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI;KACjE,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Dispatch, useMemo} from 'react';\nimport {KitModal} from 'aristid-ds';\nimport {\n type ActivateRecordsMutation,\n type DeactivateRecordsMutation,\n useActivateRecordsMutation,\n useDeactivateRecordsMutation,\n useDeleteValueMutation,\n} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useValuesCacheUpdate} from '_ui/hooks/useValuesCacheUpdate';\nimport {type FeatureHook, type Entrypoint, type IEntrypointLink, type IItemAction, type IItemData} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {type FetchResult} from '@apollo/client';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faTrash, faTrashRestore} from '@fortawesome/free-solid-svg-icons';\n\n/**\n * Hook used to get the action for `<DataView />` component.\n *\n * When the mutation for removing is done, the Apollo cache will be clean (`Record` and `RecordIdentity`)\n * from removed record.\n *\n * @param isEnabled - whether the action is present\n * @param view - represent the current view\n * @param dispatch - method to change the current view\n * @param entrypoint - represent the current entrypoint\n * @param canDeleteLinkValues - check permission to delete link values\n */\nexport const useEditStatusItemAction = ({\n isEnabled,\n canDeleteLinkValues,\n store: {view, dispatch},\n onRemove,\n entrypoint,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n canDeleteLinkValues: boolean;\n onRemove?: IItemAction['callback'];\n entrypoint: Entrypoint;\n}>) => {\n const {t} = useSharedTranslation();\n const updateValuesCache = useValuesCacheUpdate();\n\n const [deactivateRecordsMutation] = useDeactivateRecordsMutation({\n update(cache, deactivatedRecords) {\n deactivatedRecords.data?.deactivateRecords.forEach(record => {\n cache.evict({\n id: cache.identify(record),\n });\n });\n cache.modify({\n fields: {\n records: prev => ({\n ...prev,\n totalCount: prev.totalCount - 1,\n }),\n },\n broadcast: false,\n });\n cache.gc();\n },\n });\n\n const [activateRecordsMutation] = useActivateRecordsMutation({\n update(cache, activatedRecords) {\n activatedRecords.data?.activateRecords.forEach(record => {\n cache.evict({\n id: cache.identify(record),\n });\n });\n cache.modify({\n fields: {\n records: prev => ({\n ...prev,\n totalCount: prev.totalCount - 1,\n }),\n },\n broadcast: false,\n });\n cache.gc();\n },\n });\n\n const [deleteRecordLinkMutation] = useDeleteValueMutation({\n update: (_, deletedRecord) => {\n const parentRecord = {\n id: (entrypoint as IEntrypointLink).parentRecordId,\n library: {\n id: (entrypoint as IEntrypointLink).parentLibraryId,\n },\n };\n updateValuesCache(parentRecord, deletedRecord.data?.deleteValue ?? []);\n },\n });\n\n const _deactivateItem = async (item: IItemData): Promise<FetchResult<DeactivateRecordsMutation>> => {\n const libRes = await deactivateRecordsMutation({\n variables: {\n libraryId: item.libraryId,\n recordsIds: [item.itemId],\n },\n });\n\n if (view.massSelection !== MASS_SELECTION_ALL) {\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: view.massSelection.filter(key => key !== item.itemId),\n });\n }\n\n onRemove?.(item);\n\n return libRes;\n };\n\n const _activateItem = async (item: IItemData): Promise<FetchResult<ActivateRecordsMutation>> => {\n const libRes = await activateRecordsMutation({\n variables: {\n libraryId: item.libraryId,\n recordsIds: [item.itemId],\n },\n });\n\n if (view.massSelection !== MASS_SELECTION_ALL) {\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: view.massSelection.filter(key => key !== item.itemId),\n });\n }\n\n return libRes;\n };\n\n const _editStatusItemAction: IItemAction = useMemo(\n () => ({\n label: (item: IItemData) =>\n entrypoint.type === 'library'\n ? item.active\n ? t('explorer.deactivate-item')\n : t('explorer.activate-item')\n : t('explorer.delete-item'),\n icon: (item: IItemData) => (\n <FontAwesomeIcon icon={entrypoint.type === 'library' && !item.active ? faTrashRestore : faTrash} />\n ),\n isDanger: true,\n disabled: (item: IItemData) =>\n entrypoint.type === 'link' ? !canDeleteLinkValues : item.active ? !item.canDelete : !item.canActivate,\n callback: item => {\n const {itemId, id_value} = item;\n\n const title =\n entrypoint.type === 'library'\n ? item.active\n ? t('explorer.deactivate_item_one')\n : t('explorer.activate_item_one')\n : t('explorer.delete_link_one');\n\n const content =\n entrypoint.type === 'library'\n ? item.active\n ? t('explorer.deactivate_item_description_one')\n : t('explorer.activate_item_description_one')\n : t('explorer.delete_link_description_one');\n\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title,\n content: content + BREAK_TWO_LINES + t('global.are_you_sure'),\n okText: t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n switch (entrypoint.type) {\n case 'library':\n if (item.active) {\n return _deactivateItem(item);\n }\n\n return _activateItem(item);\n case 'link':\n const linkRes = await deleteRecordLinkMutation({\n variables: {\n library: entrypoint.parentLibraryId,\n attribute: entrypoint.linkAttributeId,\n recordId: entrypoint.parentRecordId,\n value: {\n payload: itemId,\n id_value,\n },\n },\n });\n onRemove?.(item);\n return linkRes;\n default:\n return;\n }\n },\n });\n },\n }),\n [\n t,\n deactivateRecordsMutation,\n deleteRecordLinkMutation,\n activateRecordsMutation,\n canDeleteLinkValues,\n entrypoint.type,\n view.massSelection,\n dispatch,\n ],\n );\n\n return {\n editStatusItemAction: isEnabled ? _editStatusItemAction : null,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"useEditStatusItemAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-item/useEditStatusItemAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAgB,OAAO,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAGH,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAoD,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC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UAAU,CAAC,cAAc;oCACnC,KAAK,EAAE;wCACH,OAAO,EAAE,MAAM;wCACf,QAAQ;qCACX;iCACJ;6BACJ,CAAC,CAAC;4BACH,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;4BACjB,OAAO,OAAO,CAAC;wBACnB;4BACI,OAAO;oBACf,CAAC;gBACL,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF;QACI,CAAC;QACD,yBAAyB;QACzB,wBAAwB;QACxB,uBAAuB;QACvB,mBAAmB;QACnB,UAAU,CAAC,IAAI;QACf,IAAI,CAAC,aAAa;QAClB,QAAQ;KACX,CACJ,CAAC;IAEF,OAAO;QACH,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI;KACjE,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Dispatch, useMemo} from 'react';\nimport {useConfirmModal} from '_ui/hooks/useConfirmModal';\nimport {\n type ActivateRecordsMutation,\n type DeactivateRecordsMutation,\n useActivateRecordsMutation,\n useDeactivateRecordsMutation,\n useDeleteValueMutation,\n} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useValuesCacheUpdate} from '_ui/hooks/useValuesCacheUpdate';\nimport {type FeatureHook, type Entrypoint, type IEntrypointLink, type IItemAction, type IItemData} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {BREAK_TWO_LINES} from '_ui/constants';\nimport {type FetchResult} from '@apollo/client';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faTrash, faTrashRestore} from '@fortawesome/free-solid-svg-icons';\n\n/**\n * Hook used to get the action for `<DataView />` component.\n *\n * When the mutation for removing is done, the Apollo cache will be clean (`Record` and `RecordIdentity`)\n * from removed record.\n *\n * @param isEnabled - whether the action is present\n * @param view - represent the current view\n * @param dispatch - method to change the current view\n * @param entrypoint - represent the current entrypoint\n * @param canDeleteLinkValues - check permission to delete link values\n */\nexport const useEditStatusItemAction = ({\n isEnabled,\n canDeleteLinkValues,\n store: {view, dispatch},\n onRemove,\n entrypoint,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n canDeleteLinkValues: boolean;\n onRemove?: IItemAction['callback'];\n entrypoint: Entrypoint;\n}>) => {\n const {t} = useSharedTranslation();\n const {openConfirmModal} = useConfirmModal();\n const updateValuesCache = useValuesCacheUpdate();\n\n const [deactivateRecordsMutation] = useDeactivateRecordsMutation({\n update(cache, deactivatedRecords) {\n deactivatedRecords.data?.deactivateRecords.forEach(record => {\n cache.evict({\n id: cache.identify(record),\n });\n });\n cache.modify({\n fields: {\n records: prev => ({\n ...prev,\n totalCount: prev.totalCount - 1,\n }),\n },\n broadcast: false,\n });\n cache.gc();\n },\n });\n\n const [activateRecordsMutation] = useActivateRecordsMutation({\n update(cache, activatedRecords) {\n activatedRecords.data?.activateRecords.forEach(record => {\n cache.evict({\n id: cache.identify(record),\n });\n });\n cache.modify({\n fields: {\n records: prev => ({\n ...prev,\n totalCount: prev.totalCount - 1,\n }),\n },\n broadcast: false,\n });\n cache.gc();\n },\n });\n\n const [deleteRecordLinkMutation] = useDeleteValueMutation({\n update: (_, deletedRecord) => {\n const parentRecord = {\n id: (entrypoint as IEntrypointLink).parentRecordId,\n library: {\n id: (entrypoint as IEntrypointLink).parentLibraryId,\n },\n };\n updateValuesCache(parentRecord, deletedRecord.data?.deleteValue ?? []);\n },\n });\n\n const _deactivateItem = async (item: IItemData): Promise<FetchResult<DeactivateRecordsMutation>> => {\n const libRes = await deactivateRecordsMutation({\n variables: {\n libraryId: item.libraryId,\n recordsIds: [item.itemId],\n },\n });\n\n if (view.massSelection !== MASS_SELECTION_ALL) {\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: view.massSelection.filter(key => key !== item.itemId),\n });\n }\n\n onRemove?.(item);\n\n return libRes;\n };\n\n const _activateItem = async (item: IItemData): Promise<FetchResult<ActivateRecordsMutation>> => {\n const libRes = await activateRecordsMutation({\n variables: {\n libraryId: item.libraryId,\n recordsIds: [item.itemId],\n },\n });\n\n if (view.massSelection !== MASS_SELECTION_ALL) {\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: view.massSelection.filter(key => key !== item.itemId),\n });\n }\n\n return libRes;\n };\n\n const _editStatusItemAction: IItemAction = useMemo(\n () => ({\n label: (item: IItemData) =>\n entrypoint.type === 'library'\n ? item.active\n ? t('explorer.deactivate-item')\n : t('explorer.activate-item')\n : t('explorer.delete-item'),\n icon: (item: IItemData) => (\n <FontAwesomeIcon icon={entrypoint.type === 'library' && !item.active ? faTrashRestore : faTrash} />\n ),\n isDanger: true,\n disabled: (item: IItemData) =>\n entrypoint.type === 'link' ? !canDeleteLinkValues : item.active ? !item.canDelete : !item.canActivate,\n callback: item => {\n const {itemId, id_value} = item;\n\n const title =\n entrypoint.type === 'library'\n ? item.active\n ? t('explorer.deactivate_item_one')\n : t('explorer.activate_item_one')\n : t('explorer.delete_link_one');\n\n const content =\n entrypoint.type === 'library'\n ? item.active\n ? t('explorer.deactivate_item_description_one')\n : t('explorer.activate_item_description_one')\n : t('explorer.delete_link_description_one');\n\n openConfirmModal({\n title,\n content: content + BREAK_TWO_LINES + t('global.are_you_sure'),\n onOk: async () => {\n switch (entrypoint.type) {\n case 'library':\n if (item.active) {\n return _deactivateItem(item);\n }\n\n return _activateItem(item);\n case 'link':\n const linkRes = await deleteRecordLinkMutation({\n variables: {\n library: entrypoint.parentLibraryId,\n attribute: entrypoint.linkAttributeId,\n recordId: entrypoint.parentRecordId,\n value: {\n payload: itemId,\n id_value,\n },\n },\n });\n onRemove?.(item);\n return linkRes;\n default:\n return;\n }\n },\n });\n },\n }),\n [\n t,\n deactivateRecordsMutation,\n deleteRecordLinkMutation,\n activateRecordsMutation,\n canDeleteLinkValues,\n entrypoint.type,\n view.massSelection,\n dispatch,\n ],\n );\n\n return {\n editStatusItemAction: isEnabled ? _editStatusItemAction : null,\n };\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { KitTypography } from 'aristid-ds';
|
|
3
|
-
export const ResultsCount = ({ t, isInactive, totalCountFiltered, totalCountLibrary, }) => (_jsxs(
|
|
2
|
+
import { KitSpace, KitTypography } from 'aristid-ds';
|
|
3
|
+
export const ResultsCount = ({ t, isInactive, totalCountFiltered, totalCountLibrary, }) => (_jsxs(KitSpace, { direction: "horizontal", size: "xxs", children: [_jsx(KitTypography.Text, { weight: "bold", size: "fontSize7", children: isInactive
|
|
4
4
|
? `${totalCountLibrary} `
|
|
5
5
|
: totalCountFiltered === totalCountLibrary
|
|
6
6
|
? `${totalCountLibrary} `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultsCount.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/ResultsCount.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ResultsCount.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/ResultsCount.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAUnD,MAAM,CAAC,MAAM,YAAY,GAAyC,CAAC,EAC/D,CAAC,EACD,UAAU,EACV,kBAAkB,EAClB,iBAAiB,GACpB,EAAE,EAAE,CAAC,CACF,MAAC,QAAQ,IAAC,SAAS,EAAC,YAAY,EAAC,IAAI,EAAC,KAAK,aACvC,KAAC,aAAa,CAAC,IAAI,IAAC,MAAM,EAAC,MAAM,EAAC,IAAI,EAAC,WAAW,YAC7C,UAAU;gBACP,CAAC,CAAC,GAAG,iBAAiB,GAAG;gBACzB,CAAC,CAAC,kBAAkB,KAAK,iBAAiB;oBACxC,CAAC,CAAC,GAAG,iBAAiB,GAAG;oBACzB,CAAC,CAAC,GAAG,kBAAkB,MAAM,iBAAiB,GAAG,GACtC,EACrB,KAAC,aAAa,CAAC,IAAI,IAAC,MAAM,EAAC,QAAQ,EAAC,IAAI,EAAC,WAAW,YAC/C,CAAC,CAAC,6BAA6B,EAAE,EAAC,KAAK,EAAE,iBAAiB,EAAC,CAAC,GAC5C,IACd,CACd,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitSpace, KitTypography} from 'aristid-ds';\nimport {type FunctionComponent} from 'react';\n\ninterface IResultCountProps {\n t: ReturnType<typeof useSharedTranslation>['t'];\n isInactive: boolean;\n totalCountFiltered: number;\n totalCountLibrary: number;\n}\n\nexport const ResultsCount: FunctionComponent<IResultCountProps> = ({\n t,\n isInactive,\n totalCountFiltered,\n totalCountLibrary,\n}) => (\n <KitSpace direction=\"horizontal\" size=\"xxs\">\n <KitTypography.Text weight=\"bold\" size=\"fontSize7\">\n {isInactive\n ? `${totalCountLibrary} `\n : totalCountFiltered === totalCountLibrary\n ? `${totalCountLibrary} `\n : `${totalCountFiltered} / ${totalCountLibrary} `}\n </KitTypography.Text>\n <KitTypography.Text weight=\"medium\" size=\"fontSize7\">\n {t('explorer.massAction.results', {count: totalCountLibrary})}\n </KitTypography.Text>\n </KitSpace>\n);\n"]}
|
package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
export declare const EditAttributeMassActionModal: FunctionComponent<{
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export declare const EditAttributeMassActionModal: ({ isOpen, children, bulkCount, onOkButtonClick, onCancelButtonClick, }: {
|
|
4
3
|
isOpen: boolean;
|
|
5
4
|
children: ReactNode;
|
|
6
|
-
|
|
7
|
-
setSelectedAttribute: (attr: AttributeDetailsFragment | undefined) => void;
|
|
8
|
-
massSelectionFilter: RecordFilterInput[];
|
|
9
|
-
elementsCount: number;
|
|
10
|
-
disableOkButton: boolean;
|
|
5
|
+
bulkCount: number;
|
|
11
6
|
onOkButtonClick: () => void;
|
|
12
7
|
onCancelButtonClick: () => void;
|
|
13
|
-
}
|
|
8
|
+
}) => JSX.Element;
|
package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
|
-
// This file is released under LGPL V3
|
|
4
|
-
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
2
|
import { faCheck, faXmark } from '@fortawesome/free-solid-svg-icons';
|
|
6
3
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
4
|
+
import { KitButton, KitModal, KitSpace, KitTypography } from 'aristid-ds';
|
|
7
5
|
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
8
|
-
import { KitButton, KitModal, KitSelect, KitSpace, KitTypography } from 'aristid-ds';
|
|
9
6
|
const MODAL_WIDTH = '90vw';
|
|
10
7
|
const MODAL_MAX_WIDTH = '656px';
|
|
11
|
-
export const EditAttributeMassActionModal = ({ isOpen, children,
|
|
8
|
+
export const EditAttributeMassActionModal = ({ isOpen, children, bulkCount, onOkButtonClick, onCancelButtonClick, }) => {
|
|
12
9
|
const { t } = useSharedTranslation();
|
|
13
|
-
return (_jsx(KitModal, { isOpen: isOpen, appElement: document.getElementById('root'), style: { content: { width: MODAL_WIDTH, maxWidth: MODAL_MAX_WIDTH } }, width: "100%", height: "auto", icon: false, title: _jsxs(KitSpace, { direction: "vertical", size: "none", children: [_jsx(KitTypography.Title, { level: "h2", children: t('explorer.massAction.editAttribute') }), _jsx(KitTypography.Text, { size: "fontSize7", children: t('explorer.massAction.editAttribute_description', { count:
|
|
14
|
-
label: attr.label || attr.id,
|
|
15
|
-
value: attr.id,
|
|
16
|
-
})), size: "large", allowClear: false, onChange: value => {
|
|
17
|
-
setSelectedAttribute(attributes.find(att => att.id === value));
|
|
18
|
-
}, placeholder: t('explorer.massAction.editAttribute_attribute_select_placeholder') })] }), children] }) }));
|
|
10
|
+
return (_jsx(KitModal, { isOpen: isOpen, appElement: document.getElementById('root'), style: { content: { width: MODAL_WIDTH, maxWidth: MODAL_MAX_WIDTH } }, width: "100%", height: "auto", icon: false, title: _jsxs(KitSpace, { direction: "vertical", size: "none", children: [_jsx(KitTypography.Title, { level: "h2", children: t('explorer.massAction.editAttribute') }), _jsx(KitTypography.Text, { size: "fontSize7", children: t('explorer.massAction.editAttribute_description', { count: bulkCount }) })] }), footer: _jsxs(_Fragment, { children: [_jsx(KitButton, { size: "m", icon: _jsx(FontAwesomeIcon, { icon: faXmark }), onClick: onCancelButtonClick, children: t('global.cancel') }), _jsx(KitButton, { type: "primary", onClick: onOkButtonClick, size: "m", icon: _jsx(FontAwesomeIcon, { icon: faCheck }), children: t('global.edit') })] }), children: _jsx(KitSpace, { direction: "vertical", size: "s", style: { display: 'flex' }, children: children }) }));
|
|
19
11
|
};
|
|
20
12
|
//# sourceMappingURL=EditAttributeMassActionModal.js.map
|
package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditAttributeMassActionModal.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"EditAttributeMassActionModal.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAExE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EACzC,MAAM,EACN,QAAQ,EACR,SAAS,EACT,eAAe,EACf,mBAAmB,GAOtB,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO,CACH,KAAC,QAAQ,IACL,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAC3C,KAAK,EAAE,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAC,EAAC,EACjE,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,EACb,IAAI,EAAE,KAAK,EACX,KAAK,EACD,MAAC,QAAQ,IAAC,SAAS,EAAC,UAAU,EAAC,IAAI,EAAC,MAAM,aACtC,KAAC,aAAa,CAAC,KAAK,IAAC,KAAK,EAAC,IAAI,YAAE,CAAC,CAAC,mCAAmC,CAAC,GAAuB,EAC9F,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,YAC/B,CAAC,CAAC,+CAA+C,EAAE,EAAC,KAAK,EAAE,SAAS,EAAC,CAAC,GACtD,IACd,EAEf,MAAM,EACF,8BACI,KAAC,SAAS,IAAC,IAAI,EAAC,GAAG,EAAC,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,OAAO,GAAI,EAAE,OAAO,EAAE,mBAAmB,YACrF,CAAC,CAAC,eAAe,CAAC,GACX,EACZ,KAAC,SAAS,IACN,IAAI,EAAC,SAAS,EACd,OAAO,EAAE,eAAe,EACxB,IAAI,EAAC,GAAG,EACR,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,OAAO,GAAI,YAEvC,CAAC,CAAC,aAAa,CAAC,GACT,IACb,YAGP,KAAC,QAAQ,IAAC,SAAS,EAAC,UAAU,EAAC,IAAI,EAAC,GAAG,EAAC,KAAK,EAAE,EAAC,OAAO,EAAE,MAAM,EAAC,YAC3D,QAAQ,GACF,GACJ,CACd,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ReactNode} from 'react';\nimport {faCheck, faXmark} from '@fortawesome/free-solid-svg-icons';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {KitButton, KitModal, KitSpace, KitTypography} from 'aristid-ds';\nimport {type RecordFilterInput} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\nconst MODAL_WIDTH = '90vw';\nconst MODAL_MAX_WIDTH = '656px';\n\nexport const EditAttributeMassActionModal = ({\n isOpen,\n children,\n bulkCount,\n onOkButtonClick,\n onCancelButtonClick,\n}: {\n isOpen: boolean;\n children: ReactNode;\n bulkCount: number;\n onOkButtonClick: () => void;\n onCancelButtonClick: () => void;\n}) => {\n const {t} = useSharedTranslation();\n\n return (\n <KitModal\n isOpen={isOpen}\n appElement={document.getElementById('root')}\n style={{content: {width: MODAL_WIDTH, maxWidth: MODAL_MAX_WIDTH}}}\n width=\"100%\"\n height=\"auto\"\n icon={false}\n title={\n <KitSpace direction=\"vertical\" size=\"none\">\n <KitTypography.Title level=\"h2\">{t('explorer.massAction.editAttribute')}</KitTypography.Title>\n <KitTypography.Text size=\"fontSize7\">\n {t('explorer.massAction.editAttribute_description', {count: bulkCount})}\n </KitTypography.Text>\n </KitSpace>\n }\n footer={\n <>\n <KitButton size=\"m\" icon={<FontAwesomeIcon icon={faXmark} />} onClick={onCancelButtonClick}>\n {t('global.cancel')}\n </KitButton>\n <KitButton\n type=\"primary\"\n onClick={onOkButtonClick}\n size=\"m\"\n icon={<FontAwesomeIcon icon={faCheck} />}\n >\n {t('global.edit')}\n </KitButton>\n </>\n }\n >\n <KitSpace direction=\"vertical\" size=\"s\" style={{display: 'flex'}}>\n {children}\n </KitSpace>\n </KitModal>\n );\n};\n"]}
|
package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
import { type RecordFilterInput } from '../../../../_gqlTypes';
|
|
2
|
+
import { type MassEditableAttribute, type SetAttributeMapping } from './_types';
|
|
3
|
+
export declare const EditTreeAttributeValuesMapping: ({ libraryId, attribute, setAttributeMapping, massSelectionFilters, }: {
|
|
4
|
+
libraryId: string;
|
|
5
|
+
attribute: MassEditableAttribute;
|
|
6
|
+
setAttributeMapping: SetAttributeMapping;
|
|
7
|
+
massSelectionFilters: RecordFilterInput[];
|
|
8
|
+
}) => JSX.Element;
|
package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
|
+
// This file is released under LGPL V3
|
|
4
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
|
+
import { KitLoader, KitSpace } from 'aristid-ds';
|
|
6
|
+
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
7
|
+
import { useValuesDistribution } from './useValuesDistribution';
|
|
8
|
+
import { useTreeNodeRemapping } from './useTreeNodeRemapping';
|
|
9
|
+
import { TreeNodeRemap } from './TreeNodeRemap';
|
|
10
|
+
const UNDEFINED_NODE_ID = null;
|
|
11
|
+
export const EditTreeAttributeValuesMapping = ({ libraryId, attribute, setAttributeMapping, massSelectionFilters, }) => {
|
|
12
|
+
const { t } = useSharedTranslation();
|
|
13
|
+
const { distribution, noValueCount, loading } = useValuesDistribution({
|
|
14
|
+
attributeId: attribute.id,
|
|
15
|
+
libraryId,
|
|
16
|
+
recordFilters: massSelectionFilters,
|
|
17
|
+
});
|
|
18
|
+
const noValueNode = attribute.treeNodes.find(({ id }) => id === UNDEFINED_NODE_ID) ?? null;
|
|
19
|
+
const editableNodes = attribute.treeNodes.filter(({ id }) => id !== UNDEFINED_NODE_ID);
|
|
20
|
+
const remappingList = useTreeNodeRemapping({ distribution, editableNodes });
|
|
21
|
+
if (loading) {
|
|
22
|
+
return _jsx(KitLoader, {});
|
|
23
|
+
}
|
|
24
|
+
return (_jsxs(KitSpace, { direction: "vertical", size: "xs", style: { display: 'flex' }, children: [remappingList.map(remapping => (_jsx(TreeNodeRemap, { ...remapping, setAttributeMapping: setAttributeMapping }, remapping.currentNode.id))), noValueCount > 0 && noValueNode !== null && (_jsx(TreeNodeRemap, { currentNode: noValueNode, occurrenceCount: noValueCount, candidateNodes: [
|
|
25
|
+
{ id: UNDEFINED_NODE_ID, label: t('explorer.massAction.editAttribute_value_do_not_change') },
|
|
26
|
+
...editableNodes,
|
|
27
|
+
], setAttributeMapping: setAttributeMapping }))] }));
|
|
15
28
|
};
|
|
16
29
|
//# sourceMappingURL=EditTreeAttributeValuesMapping.js.map
|
package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditTreeAttributeValuesMapping.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"EditTreeAttributeValuesMapping.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAC3C,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,oBAAoB,GAMvB,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,EAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAC,GAAG,qBAAqB,CAAC;QAChE,WAAW,EAAE,SAAS,CAAC,EAAE;QACzB,SAAS;QACT,aAAa,EAAE,oBAAoB;KACtC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,EAAE,KAAK,iBAAiB,CAAC,IAAI,IAAI,CAAC;IACzF,MAAM,aAAa,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,EAAE,KAAK,iBAAiB,CAAC,CAAC;IAErF,MAAM,aAAa,GAAG,oBAAoB,CAAC,EAAC,YAAY,EAAE,aAAa,EAAC,CAAC,CAAC;IAE1E,IAAI,OAAO,EAAE,CAAC;QACV,OAAO,KAAC,SAAS,KAAG,CAAC;IACzB,CAAC;IAED,OAAO,CACH,MAAC,QAAQ,IAAC,SAAS,EAAC,UAAU,EAAC,IAAI,EAAC,IAAI,EAAC,KAAK,EAAE,EAAC,OAAO,EAAE,MAAM,EAAC,aAC5D,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAC5B,KAAC,aAAa,OAEN,SAAS,EACb,mBAAmB,EAAE,mBAAmB,IAFnC,SAAS,CAAC,WAAW,CAAC,EAAE,CAG/B,CACL,CAAC,EACD,YAAY,GAAG,CAAC,IAAI,WAAW,KAAK,IAAI,IAAI,CACzC,KAAC,aAAa,IACV,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,YAAY,EAC7B,cAAc,EAAE;oBACZ,EAAC,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC,uDAAuD,CAAC,EAAC;oBAC1F,GAAG,aAAa;iBACnB,EACD,mBAAmB,EAAE,mBAAmB,GAC1C,CACL,IACM,CACd,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {KitLoader, KitSpace} from 'aristid-ds';\nimport {type RecordFilterInput} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useValuesDistribution} from './useValuesDistribution';\nimport {useTreeNodeRemapping} from './useTreeNodeRemapping';\nimport {TreeNodeRemap} from './TreeNodeRemap';\nimport {type MassEditableAttribute, type SetAttributeMapping} from './_types';\n\nconst UNDEFINED_NODE_ID = null;\n\nexport const EditTreeAttributeValuesMapping = ({\n libraryId,\n attribute,\n setAttributeMapping,\n massSelectionFilters,\n}: {\n libraryId: string;\n attribute: MassEditableAttribute;\n setAttributeMapping: SetAttributeMapping;\n massSelectionFilters: RecordFilterInput[];\n}) => {\n const {t} = useSharedTranslation();\n\n const {distribution, noValueCount, loading} = useValuesDistribution({\n attributeId: attribute.id,\n libraryId,\n recordFilters: massSelectionFilters,\n });\n\n const noValueNode = attribute.treeNodes.find(({id}) => id === UNDEFINED_NODE_ID) ?? null;\n const editableNodes = attribute.treeNodes.filter(({id}) => id !== UNDEFINED_NODE_ID);\n\n const remappingList = useTreeNodeRemapping({distribution, editableNodes});\n\n if (loading) {\n return <KitLoader />;\n }\n\n return (\n <KitSpace direction=\"vertical\" size=\"xs\" style={{display: 'flex'}}>\n {remappingList.map(remapping => (\n <TreeNodeRemap\n key={remapping.currentNode.id}\n {...remapping}\n setAttributeMapping={setAttributeMapping}\n />\n ))}\n {noValueCount > 0 && noValueNode !== null && (\n <TreeNodeRemap\n currentNode={noValueNode}\n occurrenceCount={noValueCount}\n candidateNodes={[\n {id: UNDEFINED_NODE_ID, label: t('explorer.massAction.editAttribute_value_do_not_change')},\n ...editableNodes,\n ]}\n setAttributeMapping={setAttributeMapping}\n />\n )}\n </KitSpace>\n );\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type MassEditTreeNode, type SetAttributeMapping } from './_types';
|
|
2
|
+
export declare const TreeNodeRemap: ({ currentNode, occurrenceCount, candidateNodes, setAttributeMapping, }: {
|
|
3
|
+
currentNode: MassEditTreeNode;
|
|
4
|
+
occurrenceCount: number;
|
|
5
|
+
candidateNodes: MassEditTreeNode[];
|
|
6
|
+
setAttributeMapping: SetAttributeMapping;
|
|
7
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { KitIdCard, KitSelect, KitTypography } from 'aristid-ds';
|
|
4
|
+
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
5
|
+
const DivContainer = styled.div `
|
|
6
|
+
display: grid;
|
|
7
|
+
align-items: center;
|
|
8
|
+
grid-template-columns: repeat(3, 1fr);
|
|
9
|
+
grid-column-gap: calc(var(--general-spacing-l) * 1px);
|
|
10
|
+
`;
|
|
11
|
+
const UNDEFINED_VALUE = '__null__';
|
|
12
|
+
const DEFAULT_ID_CARD_COLOR = 'rgba(200, 200, 200, 1)';
|
|
13
|
+
export const TreeNodeRemap = ({ currentNode, occurrenceCount, candidateNodes, setAttributeMapping, }) => {
|
|
14
|
+
const { t } = useSharedTranslation();
|
|
15
|
+
const selectOptions = candidateNodes.map(node => ({
|
|
16
|
+
label: node.label,
|
|
17
|
+
value: node.id ?? UNDEFINED_VALUE,
|
|
18
|
+
}));
|
|
19
|
+
const doNotChangeOption = selectOptions[0];
|
|
20
|
+
return (_jsxs(DivContainer, { children: [_jsx(KitIdCard, { title: currentNode.label, color: currentNode.color ?? DEFAULT_ID_CARD_COLOR }), _jsx(KitTypography.Text, { children: t('explorer.massAction.editAttribute_value_occurrences_to_edit', {
|
|
21
|
+
count: occurrenceCount,
|
|
22
|
+
}) }), _jsx(KitSelect, { defaultValue: doNotChangeOption.value, options: selectOptions, size: "middle", allowClear: false, onChange: value => {
|
|
23
|
+
setAttributeMapping({
|
|
24
|
+
before: currentNode.id,
|
|
25
|
+
after: value === UNDEFINED_VALUE ? null : value,
|
|
26
|
+
occurrenceCount,
|
|
27
|
+
});
|
|
28
|
+
} })] }));
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=TreeNodeRemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeNodeRemap.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.tsx"],"names":[],"mappings":";AAIA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAK9B,CAAC;AAEF,MAAM,eAAe,GAAG,UAAU,CAAC;AACnC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC1B,WAAW,EACX,eAAe,EACf,cAAc,EACd,mBAAmB,GAMtB,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,aAAa,GAAgD,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3F,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,eAAe;KACpC,CAAC,CAAC,CAAC;IAEJ,MAAM,iBAAiB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAE3C,OAAO,CACH,MAAC,YAAY,eACT,KAAC,SAAS,IAAC,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,IAAI,qBAAqB,GAAI,EAC1F,KAAC,aAAa,CAAC,IAAI,cACd,CAAC,CAAC,6DAA6D,EAAE;oBAC9D,KAAK,EAAE,eAAe;iBACzB,CAAC,GACe,EACrB,KAAC,SAAS,IACN,YAAY,EAAE,iBAAiB,CAAC,KAAK,EACrC,OAAO,EAAE,aAAa,EACtB,IAAI,EAAC,QAAQ,EACb,UAAU,EAAE,KAAK,EACjB,QAAQ,EAAE,KAAK,CAAC,EAAE;oBACd,mBAAmB,CAAC;wBAChB,MAAM,EAAE,WAAW,CAAC,EAAE;wBACtB,KAAK,EAAE,KAAK,KAAK,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;wBAC/C,eAAe;qBAClB,CAAC,CAAC;gBACP,CAAC,GACH,IACS,CAClB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ComponentProps} from 'react';\nimport styled from 'styled-components';\nimport {KitIdCard, KitSelect, KitTypography} from 'aristid-ds';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type MassEditTreeNode, type SetAttributeMapping} from './_types';\n\nconst DivContainer = styled.div`\n display: grid;\n align-items: center;\n grid-template-columns: repeat(3, 1fr);\n grid-column-gap: calc(var(--general-spacing-l) * 1px);\n`;\n\nconst UNDEFINED_VALUE = '__null__';\nconst DEFAULT_ID_CARD_COLOR = 'rgba(200, 200, 200, 1)';\n\nexport const TreeNodeRemap = ({\n currentNode,\n occurrenceCount,\n candidateNodes,\n setAttributeMapping,\n}: {\n currentNode: MassEditTreeNode;\n occurrenceCount: number;\n candidateNodes: MassEditTreeNode[];\n setAttributeMapping: SetAttributeMapping;\n}) => {\n const {t} = useSharedTranslation();\n\n const selectOptions: ComponentProps<typeof KitSelect>['options'] = candidateNodes.map(node => ({\n label: node.label,\n value: node.id ?? UNDEFINED_VALUE,\n }));\n\n const doNotChangeOption = selectOptions[0];\n\n return (\n <DivContainer>\n <KitIdCard title={currentNode.label} color={currentNode.color ?? DEFAULT_ID_CARD_COLOR} />\n <KitTypography.Text>\n {t('explorer.massAction.editAttribute_value_occurrences_to_edit', {\n count: occurrenceCount,\n })}\n </KitTypography.Text>\n <KitSelect\n defaultValue={doNotChangeOption.value}\n options={selectOptions}\n size=\"middle\"\n allowClear={false}\n onChange={value => {\n setAttributeMapping({\n before: currentNode.id,\n after: value === UNDEFINED_VALUE ? null : value,\n occurrenceCount,\n });\n }}\n />\n </DivContainer>\n );\n};\n"]}
|