@leav/ui 1.12.0-c87727ff → 1.12.0-ce39d7e4
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 +243 -94
- package/dist/_gqlTypes/index.js +190 -48
- package/dist/_gqlTypes/index.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/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 -80
- 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/Filters/conditionsHelper.d.ts +2 -1
- package/dist/components/Filters/conditionsHelper.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/useTransformFilters.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 +1 -0
- package/dist/hooks/index.js +1 -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/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 +6 -6
- 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
|
@@ -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,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAElE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,mCAAmC,CAAC;AAE1E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACpC,SAAS,EACT,mBAAmB,EACnB,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EACvB,QAAQ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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,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,mCAAmC,CAAC;AAE1E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACpC,SAAS,EACT,mBAAmB,EACnB,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EACvB,QAAQ,EACR,UAAU,GASZ,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EA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;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"]}
|
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"]}
|
|
@@ -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.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,8BAA8B,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EAAC,SAAS,EAAsB,EAA2B,EAAE;IACnG,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,EAAC,IAAI,EAAC,GAAG,8BAA8B,CAAC;QAC1C,SAAS,EAAE,EAAC,SAAS,EAAC;QACtB,IAAI,EAAE,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,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"]}
|