@leav/ui 1.12.0-36d55f01 → 1.12.0-38b7d0f2
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/_gqlTypes/index.d.ts +243 -94
- package/dist/_gqlTypes/index.js +190 -48
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/components/Explorer/DataView.js +1 -1
- package/dist/components/Explorer/DataView.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/useEditAttributeMassAction.d.ts +8 -2
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +104 -80
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useMassActions.js +18 -13
- package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
- package/dist/locales/en/shared.json +4 -4
- package/dist/locales/fr/shared.json +5 -5
- package/package.json +3 -3
- 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
|
@@ -127,7 +127,7 @@ export const DataView = memo(({ dataGroupedFilteredSorted, attributesToDisplay,
|
|
|
127
127
|
// TODO: handle columns width based on attribute type/format
|
|
128
128
|
return (_jsxs(DataViewContainerDivStyled, { ref: containerRef, className: cn({ headless: hideTableHeader }), children: [_jsx(StyledTable, { className: cn({
|
|
129
129
|
'row-clickable': itemActionToUseOnRowClick,
|
|
130
|
-
}), showHeader: dataGroupedFilteredSorted.length > 0 && !hideTableHeader, headerLineSize: useSmallHeaderSize ? 's' :
|
|
130
|
+
}), showHeader: dataGroupedFilteredSorted.length > 0 && !hideTableHeader, headerLineSize: useSmallHeaderSize ? 's' : 'm', columns: [whoIAmColumn, ...columns], tableLayout: "fixed", scroll: {
|
|
131
131
|
y: tableBodyHeight ?? (hideTableHeader ? '100%' : scrollHeight),
|
|
132
132
|
x: '100%',
|
|
133
133
|
}, dataSource: dataGroupedFilteredSorted, pagination: false, rowSelection: _rowSelection, onRow: (item) => ({
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,OAAO,CAAC;AACzG,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEnD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,uBAAuB,EAAE,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AA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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' : 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\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"]}
|
|
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,MAAM,OAAO,CAAC;AACzG,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEnD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,uBAAuB,EAAE,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAEhC,MAAM,cAAc,GAAG,EAAE,CAAC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,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"]}
|
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,E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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"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SystemTranslation } from '../../../../types';
|
|
2
|
+
import { type SaveValueBulkMappingValueInput } from '../../../../_gqlTypes';
|
|
3
|
+
export type MassEditableAttribute = {
|
|
4
|
+
id: string;
|
|
5
|
+
label?: SystemTranslation;
|
|
6
|
+
dependencies: Array<{
|
|
7
|
+
id: string;
|
|
8
|
+
label?: SystemTranslation;
|
|
9
|
+
}>;
|
|
10
|
+
hasEmptyDependency: boolean;
|
|
11
|
+
isSimpleWorkflow: boolean;
|
|
12
|
+
isMonoDependencyWorkflow: boolean;
|
|
13
|
+
treeNodes: MassEditTreeNode[];
|
|
14
|
+
};
|
|
15
|
+
export type MassEditTreeNode = {
|
|
16
|
+
id: string | null;
|
|
17
|
+
label: string;
|
|
18
|
+
color?: string | null;
|
|
19
|
+
allowedDependentNodeIds?: string[];
|
|
20
|
+
};
|
|
21
|
+
export type SetAttributeMapping = (mapping: SaveValueBulkMappingValueInput & {
|
|
22
|
+
occurrenceCount: number;
|
|
23
|
+
}) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/_types.ts"],"names":[],"mappings":"","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 SystemTranslation} from '_ui/types';\nimport {type SaveValueBulkMappingValueInput} from '_ui/_gqlTypes';\n\nexport type MassEditableAttribute = {\n id: string;\n label?: SystemTranslation;\n dependencies: Array<{id: string; label?: SystemTranslation}>;\n hasEmptyDependency: boolean;\n isSimpleWorkflow: boolean;\n isMonoDependencyWorkflow: boolean;\n treeNodes: MassEditTreeNode[];\n};\n\nexport type MassEditTreeNode = {\n id: string | null;\n label: string;\n color?: string | null;\n allowedDependentNodeIds?: string[];\n};\n\nexport type SetAttributeMapping = (mapping: SaveValueBulkMappingValueInput & {occurrenceCount: number}) => void;\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
|
+
// This file is released under LGPL V3
|
|
3
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
+
import { useMassEditableAttributesQuery } from '../../../../_gqlTypes';
|
|
5
|
+
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
6
|
+
export const useMassEditableAttributes = ({ libraryId }) => {
|
|
7
|
+
const { t } = useSharedTranslation();
|
|
8
|
+
const { data } = useMassEditableAttributesQuery({
|
|
9
|
+
variables: { libraryId },
|
|
10
|
+
skip: libraryId.length === 0,
|
|
11
|
+
});
|
|
12
|
+
return (data?.attributes?.list
|
|
13
|
+
.map(treeAttribute => {
|
|
14
|
+
let dependencies = [];
|
|
15
|
+
if ('permissions_conf_dependent_values' in treeAttribute) {
|
|
16
|
+
dependencies = treeAttribute.permissions_conf_dependent_values?.dependenciesTreeAttributes ?? [];
|
|
17
|
+
}
|
|
18
|
+
const hasEmptyDependency = dependencies.length === 0;
|
|
19
|
+
const isSimpleWorkflow = dependencies.length === 1 && dependencies[0].id === treeAttribute.id;
|
|
20
|
+
const isMonoDependencyWorkflow = dependencies.length === 2 &&
|
|
21
|
+
dependencies.filter(attribute => attribute.id === treeAttribute.id).length === 1;
|
|
22
|
+
let treeNodes = [];
|
|
23
|
+
if ('tree_values' in treeAttribute) {
|
|
24
|
+
treeNodes =
|
|
25
|
+
treeAttribute.tree_values?.map(treeValue => ({
|
|
26
|
+
id: treeValue.node?.id ?? null,
|
|
27
|
+
label: treeValue.node?.record.whoAmI.label ??
|
|
28
|
+
treeValue.node?.record.id ??
|
|
29
|
+
t('explorer.massAction.editAttribute_value_undefined'),
|
|
30
|
+
color: treeValue.node?.record.whoAmI.color,
|
|
31
|
+
allowedDependentNodeIds: treeValue.allowedDependentValues?.map(({ nodeId }) => nodeId) ?? [],
|
|
32
|
+
})) ?? [];
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
id: treeAttribute.id,
|
|
36
|
+
label: treeAttribute.label,
|
|
37
|
+
dependencies,
|
|
38
|
+
hasEmptyDependency,
|
|
39
|
+
isSimpleWorkflow,
|
|
40
|
+
isMonoDependencyWorkflow,
|
|
41
|
+
treeNodes,
|
|
42
|
+
};
|
|
43
|
+
})
|
|
44
|
+
.filter(({ hasEmptyDependency, isSimpleWorkflow, isMonoDependencyWorkflow }) => hasEmptyDependency || isSimpleWorkflow /*|| isMonoDependencyWorkflow*/) ?? []);
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=useMassEditableAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMassEditableAttributes.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.ts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EAAE,CAAC,CAAC;oBACzC,EAAE,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI;oBAC9B,KAAK,EACD,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;wBACnC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;wBACzB,CAAC,CAAC,mDAAmD,CAAC;oBAC1D,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;oBAC1C,uBAAuB,EAAE,SAAS,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,MAAO,CAAC,IAAI,EAAE;iBAC9F,CAAC,CAAC,IAAI,EAAE,CAAC;QAClB,CAAC;QAED,OAAO;YACH,EAAE,EAAE,aAAa,CAAC,EAAE;YACpB,KAAK,EAAE,aAAa,CAAC,KAAK;YAC1B,YAAY;YACZ,kBAAkB;YAClB,gBAAgB;YAChB,wBAAwB;YACxB,SAAS;SACZ,CAAC;IACN,CAAC,CAAC;SACD,MAAM,CACH,CAAC,EAAC,kBAAkB,EAAE,gBAAgB,EAAE,wBAAwB,EAAC,EAAE,EAAE,CACjE,kBAAkB,IAAI,gBAAgB,CAAC,+BAA+B,CAC7E,IAAI,EAAE,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 {useMassEditableAttributesQuery} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type MassEditableAttribute} from './_types';\n\nexport const useMassEditableAttributes = ({libraryId}: {libraryId: string}): MassEditableAttribute[] => {\n const {t} = useSharedTranslation();\n\n const {data} = useMassEditableAttributesQuery({\n variables: {libraryId},\n skip: libraryId.length === 0,\n });\n\n return (\n data?.attributes?.list\n .map(treeAttribute => {\n let dependencies: MassEditableAttribute['dependencies'] = [];\n if ('permissions_conf_dependent_values' in treeAttribute) {\n dependencies = treeAttribute.permissions_conf_dependent_values?.dependenciesTreeAttributes ?? [];\n }\n\n const hasEmptyDependency = dependencies.length === 0;\n const isSimpleWorkflow = dependencies.length === 1 && dependencies[0].id === treeAttribute.id;\n const isMonoDependencyWorkflow =\n dependencies.length === 2 &&\n dependencies.filter(attribute => attribute.id === treeAttribute.id).length === 1;\n\n let treeNodes: MassEditableAttribute['treeNodes'] = [];\n if ('tree_values' in treeAttribute) {\n treeNodes =\n treeAttribute.tree_values?.map(treeValue => ({\n id: treeValue.node?.id ?? null,\n label:\n treeValue.node?.record.whoAmI.label ??\n treeValue.node?.record.id ??\n t('explorer.massAction.editAttribute_value_undefined'),\n color: treeValue.node?.record.whoAmI.color,\n allowedDependentNodeIds: treeValue.allowedDependentValues?.map(({nodeId}) => nodeId!) ?? [],\n })) ?? [];\n }\n\n return {\n id: treeAttribute.id,\n label: treeAttribute.label,\n dependencies,\n hasEmptyDependency,\n isSimpleWorkflow,\n isMonoDependencyWorkflow,\n treeNodes,\n };\n })\n .filter(\n ({hasEmptyDependency, isSimpleWorkflow, isMonoDependencyWorkflow}) =>\n hasEmptyDependency || isSimpleWorkflow /*|| isMonoDependencyWorkflow*/,\n ) ?? []\n );\n};\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type MassEditTreeNode } from './_types';
|
|
2
|
+
export declare const useTreeNodeRemapping: ({ distribution, editableNodes, }: {
|
|
3
|
+
distribution: Array<{
|
|
4
|
+
count: number;
|
|
5
|
+
treeNodeId: string;
|
|
6
|
+
}>;
|
|
7
|
+
editableNodes: MassEditTreeNode[];
|
|
8
|
+
}) => Array<{
|
|
9
|
+
currentNode: MassEditTreeNode;
|
|
10
|
+
occurrenceCount: number;
|
|
11
|
+
candidateNodes: MassEditTreeNode[];
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
|
+
// This file is released under LGPL V3
|
|
3
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
+
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
5
|
+
export const useTreeNodeRemapping = ({ distribution, editableNodes, }) => {
|
|
6
|
+
const { t } = useSharedTranslation();
|
|
7
|
+
return distribution.map(occurrence => {
|
|
8
|
+
const currentNode = editableNodes.find(({ id }) => id === occurrence.treeNodeId);
|
|
9
|
+
const filteredCandidates = editableNodes
|
|
10
|
+
.filter(({ id }) => id !== currentNode.id)
|
|
11
|
+
.filter(candidate => currentNode.allowedDependentNodeIds &&
|
|
12
|
+
(currentNode.allowedDependentNodeIds.length === 0 ||
|
|
13
|
+
currentNode.allowedDependentNodeIds.includes(candidate.id)));
|
|
14
|
+
return {
|
|
15
|
+
currentNode,
|
|
16
|
+
occurrenceCount: occurrence.count,
|
|
17
|
+
candidateNodes: [
|
|
18
|
+
{ id: occurrence.treeNodeId, label: t('explorer.massAction.editAttribute_value_do_not_change') },
|
|
19
|
+
...filteredCandidates,
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=useTreeNodeRemapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTreeNodeRemapping.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACjC,YAAY,EACZ,aAAa,GAIhB,EAIE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,EAAE,KAAK,UAAU,CAAC,UAAU,CAAE,CAAC;QAEhF,MAAM,kBAAkB,GAAG,aAAa;aACnC,MAAM,CAAC,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,EAAE,KAAK,WAAW,CAAC,EAAE,CAAC;aACvC,MAAM,CACH,SAAS,CAAC,EAAE,CACR,WAAW,CAAC,uBAAuB;YACnC,CAAC,WAAW,CAAC,uBAAuB,CAAC,MAAM,KAAK,CAAC;gBAC7C,WAAW,CAAC,uBAAuB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAG,CAAC,CAAC,CACvE,CAAC;QAEN,OAAO;YACH,WAAW;YACX,eAAe,EAAE,UAAU,CAAC,KAAK;YACjC,cAAc,EAAE;gBACZ,EAAC,EAAE,EAAE,UAAU,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,uDAAuD,CAAC,EAAC;gBAC9F,GAAG,kBAAkB;aACxB;SACJ,CAAC;IACN,CAAC,CAAC,CAAC;AACP,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 {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type MassEditTreeNode} from './_types';\n\nexport const useTreeNodeRemapping = ({\n distribution,\n editableNodes,\n}: {\n distribution: Array<{count: number; treeNodeId: string}>;\n editableNodes: MassEditTreeNode[];\n}): Array<{\n currentNode: MassEditTreeNode;\n occurrenceCount: number;\n candidateNodes: MassEditTreeNode[];\n}> => {\n const {t} = useSharedTranslation();\n\n return distribution.map(occurrence => {\n const currentNode = editableNodes.find(({id}) => id === occurrence.treeNodeId)!;\n\n const filteredCandidates = editableNodes\n .filter(({id}) => id !== currentNode.id)\n .filter(\n candidate =>\n currentNode.allowedDependentNodeIds &&\n (currentNode.allowedDependentNodeIds.length === 0 ||\n currentNode.allowedDependentNodeIds.includes(candidate.id!)),\n );\n\n return {\n currentNode,\n occurrenceCount: occurrence.count,\n candidateNodes: [\n {id: occurrence.treeNodeId, label: t('explorer.massAction.editAttribute_value_do_not_change')},\n ...filteredCandidates,\n ],\n };\n });\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RecordFilterInput } from '../../../../_gqlTypes';
|
|
2
|
+
export declare const useValuesDistribution: ({ attributeId, libraryId, recordFilters, }: {
|
|
3
|
+
attributeId: string;
|
|
4
|
+
libraryId: string;
|
|
5
|
+
recordFilters: RecordFilterInput[];
|
|
6
|
+
}) => {
|
|
7
|
+
noValueCount: number;
|
|
8
|
+
distribution: Array<{
|
|
9
|
+
count: number;
|
|
10
|
+
treeNodeId: string;
|
|
11
|
+
}>;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
|
+
// This file is released under LGPL V3
|
|
3
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
+
import { useValuesOccurrencesQuery } from '../../../../_gqlTypes';
|
|
5
|
+
export const useValuesDistribution = ({ attributeId, libraryId, recordFilters, }) => {
|
|
6
|
+
const { data: valuesOccurrences, loading } = useValuesOccurrencesQuery({
|
|
7
|
+
variables: {
|
|
8
|
+
attributeId,
|
|
9
|
+
libraryId,
|
|
10
|
+
recordFilters,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
const noValueCount = valuesOccurrences?.listDistinctValues?.find(treeOccurrence => !('treeNode' in treeOccurrence && treeOccurrence.treeNode))?.count ?? 0;
|
|
14
|
+
const distribution = valuesOccurrences?.listDistinctValues
|
|
15
|
+
?.map(treeOccurrence => 'treeNode' in treeOccurrence && treeOccurrence.treeNode
|
|
16
|
+
? {
|
|
17
|
+
count: treeOccurrence.count,
|
|
18
|
+
treeNodeId: treeOccurrence.treeNode.id,
|
|
19
|
+
}
|
|
20
|
+
: null)
|
|
21
|
+
.filter(Boolean) ?? [];
|
|
22
|
+
return {
|
|
23
|
+
distribution,
|
|
24
|
+
noValueCount,
|
|
25
|
+
loading,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=useValuesDistribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useValuesDistribution.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAEhF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAClC,WAAW,EACX,SAAS,EACT,aAAa,GAKhB,EAOC,EAAE;IACA,MAAM,EAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAC,GAAG,yBAAyB,CAAC;QACjE,SAAS,EAAE;YACP,WAAW;YACX,SAAS;YACT,aAAa;SAChB;KACJ,CAAC,CAAC;IAEH,MAAM,YAAY,GACd,iBAAiB,EAAE,kBAAkB,EAAE,IAAI,CACvC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,cAAc,IAAI,cAAc,CAAC,QAAQ,CAAC,CAC/E,EAAE,KAAK,IAAI,CAAC,CAAC;IAElB,MAAM,YAAY,GACd,iBAAiB,EAAE,kBAAkB;QACjC,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,CACnB,UAAU,IAAI,cAAc,IAAI,cAAc,CAAC,QAAQ;QACnD,CAAC,CAAC;YACI,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,UAAU,EAAE,cAAc,CAAC,QAAQ,CAAC,EAAE;SACzC;QACH,CAAC,CAAC,IAAI,CACb;SACA,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAE/B,OAAO;QACH,YAAY;QACZ,YAAY;QACZ,OAAO;KACV,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 RecordFilterInput, useValuesOccurrencesQuery} from '_ui/_gqlTypes';\n\nexport const useValuesDistribution = ({\n attributeId,\n libraryId,\n recordFilters,\n}: {\n attributeId: string;\n libraryId: string;\n recordFilters: RecordFilterInput[];\n}): {\n noValueCount: number;\n distribution: Array<{\n count: number;\n treeNodeId: string;\n }>;\n loading: boolean;\n} => {\n const {data: valuesOccurrences, loading} = useValuesOccurrencesQuery({\n variables: {\n attributeId,\n libraryId,\n recordFilters,\n },\n });\n\n const noValueCount =\n valuesOccurrences?.listDistinctValues?.find(\n treeOccurrence => !('treeNode' in treeOccurrence && treeOccurrence.treeNode),\n )?.count ?? 0;\n\n const distribution =\n valuesOccurrences?.listDistinctValues\n ?.map(treeOccurrence =>\n 'treeNode' in treeOccurrence && treeOccurrence.treeNode\n ? {\n count: treeOccurrence.count,\n treeNodeId: treeOccurrence.treeNode.id,\n }\n : null,\n )\n .filter(Boolean) ?? [];\n\n return {\n distribution,\n noValueCount,\n loading,\n };\n};\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RecordFilterInput } from '../../../_gqlTypes';
|
|
2
|
+
import { type FeatureHook } from '../_types';
|
|
2
3
|
import { type IViewSettingsState } from '../manage-view-settings';
|
|
3
4
|
export declare const useEditAttributeMassAction: ({ isEnabled, store: { view }, totalCount, }: FeatureHook<{
|
|
4
5
|
store: {
|
|
@@ -6,6 +7,11 @@ export declare const useEditAttributeMassAction: ({ isEnabled, store: { view },
|
|
|
6
7
|
};
|
|
7
8
|
totalCount: number;
|
|
8
9
|
}>) => {
|
|
9
|
-
editAttributeMassAction:
|
|
10
|
+
editAttributeMassAction: {
|
|
11
|
+
label: string;
|
|
12
|
+
icon: JSX.Element;
|
|
13
|
+
deselectAll: boolean;
|
|
14
|
+
callback: (_massSelectionFilter: RecordFilterInput[]) => void;
|
|
15
|
+
};
|
|
10
16
|
editAttributeMassActionModal: JSX.Element;
|
|
11
17
|
};
|