@leav/ui 1.9.0-e76b3483 → 1.9.0-e815e87d

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.
Files changed (40) hide show
  1. package/dist/_gqlTypes/index.d.ts +95 -111
  2. package/dist/_gqlTypes/index.js +62 -77
  3. package/dist/_gqlTypes/index.js.map +1 -1
  4. package/dist/_queries/trees/getTreeContentQuery.d.ts +6 -0
  5. package/dist/_queries/trees/getTreeContentQuery.js +70 -0
  6. package/dist/_queries/trees/getTreeContentQuery.js.map +1 -0
  7. package/dist/components/Explorer/Explorer.d.ts +2 -1
  8. package/dist/components/Explorer/Explorer.js +10 -2
  9. package/dist/components/Explorer/Explorer.js.map +1 -1
  10. package/dist/components/Explorer/_queries/useExplorerData.js +18 -20
  11. package/dist/components/Explorer/_queries/useExplorerData.js.map +1 -1
  12. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js +1 -1
  13. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map +1 -1
  14. package/dist/components/Explorer/actions-mass/generate-previews/GeneratePreviewsModal.d.ts +10 -0
  15. package/dist/components/Explorer/actions-mass/generate-previews/GeneratePreviewsModal.js +69 -0
  16. package/dist/components/Explorer/actions-mass/generate-previews/GeneratePreviewsModal.js.map +1 -0
  17. package/dist/components/Explorer/actions-mass/generate-previews/useGetPreviewSizesData.d.ts +18 -0
  18. package/dist/components/Explorer/actions-mass/generate-previews/useGetPreviewSizesData.js +57 -0
  19. package/dist/components/Explorer/actions-mass/generate-previews/useGetPreviewSizesData.js.map +1 -0
  20. package/dist/components/Explorer/actions-mass/useGeneratePreviewsMassAction.d.ts +19 -0
  21. package/dist/components/Explorer/actions-mass/useGeneratePreviewsMassAction.js +94 -0
  22. package/dist/components/Explorer/actions-mass/useGeneratePreviewsMassAction.js.map +1 -0
  23. package/dist/components/Explorer/manage-view-settings/configure-display/view-type/SelectViewType.js +1 -1
  24. package/dist/components/Explorer/manage-view-settings/configure-display/view-type/SelectViewType.js.map +1 -1
  25. package/dist/components/Filters/context/useGetTreeFilters.js +22 -38
  26. package/dist/components/Filters/context/useGetTreeFilters.js.map +1 -1
  27. package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js +22 -41
  28. package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js.map +1 -1
  29. package/dist/components/RecordEdition/EditRecord/EditRecord.d.ts +1 -0
  30. package/dist/components/RecordEdition/EditRecord/EditRecord.js +3 -3
  31. package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
  32. package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.d.ts +1 -0
  33. package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.js +2 -2
  34. package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.js.map +1 -1
  35. package/dist/hooks/useIFrameMessenger/schema.d.ts +2 -2
  36. package/dist/hooks/useIFrameMessenger/schema.js +1 -1
  37. package/dist/hooks/useIFrameMessenger/schema.js.map +1 -1
  38. package/dist/locales/en/shared.json +9 -2
  39. package/dist/locales/fr/shared.json +9 -2
  40. package/package.json +5 -5
@@ -0,0 +1,57 @@
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 { useEffect, useState } from 'react';
5
+ import { useGetLibraryPreviewsSettingsQuery } from '../../../../_gqlTypes';
6
+ import { localizedTranslation } from '@leav/utils';
7
+ import { useLang } from '../../../../hooks';
8
+ import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
9
+ export const SELECT_ALL_KEY = 'select-all';
10
+ /**
11
+ * Hook that fetches library preview settings and transforms them into tree data
12
+ * for the preview sizes selection in the GeneratePreviewsModal
13
+ */
14
+ export const useGetPreviewSizesData = (libraryId) => {
15
+ const { t } = useSharedTranslation();
16
+ const { lang } = useLang();
17
+ const [previewSizesTreeData, setPreviewSizesTreeData] = useState([]);
18
+ const [allPreviewSizes, setAllPreviewSizes] = useState([]);
19
+ const { data: libraryPreviewsSettingsData, error: libraryPreviewsSettingsError, loading: libraryPreviewsSettingsLoading, } = useGetLibraryPreviewsSettingsQuery({
20
+ variables: {
21
+ id: libraryId,
22
+ },
23
+ });
24
+ useEffect(() => {
25
+ if (libraryPreviewsSettingsData?.libraries?.list) {
26
+ const selectAllPreviewSizesNode = {
27
+ title: t('files.previews_generation_select_all'),
28
+ key: SELECT_ALL_KEY,
29
+ };
30
+ const libraryPreviewSettings = libraryPreviewsSettingsData.libraries.list?.[0]?.previewsSettings || [];
31
+ const previewSizes = [];
32
+ const libraryPreviewSizesTreeData = libraryPreviewSettings.map(s => {
33
+ const children = s.versions.sizes.map(vs => ({ title: `${vs.name} (${vs.size}px)`, key: vs.name }));
34
+ previewSizes.push(...children.map(c => c.key));
35
+ return {
36
+ title: localizedTranslation(s.label, lang),
37
+ key: localizedTranslation(s.label, lang) + Math.random(),
38
+ children,
39
+ };
40
+ });
41
+ setPreviewSizesTreeData([
42
+ {
43
+ ...selectAllPreviewSizesNode,
44
+ children: libraryPreviewSizesTreeData,
45
+ },
46
+ ]);
47
+ setAllPreviewSizes(previewSizes);
48
+ }
49
+ }, [libraryPreviewsSettingsData, lang, t]);
50
+ return {
51
+ previewSizesTreeData,
52
+ allPreviewSizes,
53
+ loading: libraryPreviewsSettingsLoading,
54
+ error: libraryPreviewsSettingsError,
55
+ };
56
+ };
57
+ //# sourceMappingURL=useGetPreviewSizesData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetPreviewSizesData.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/generate-previews/useGetPreviewSizesData.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,kCAAkC,EAAC,MAAM,eAAe,CA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AAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,EAAC,CAAC,CAAC,CAAC;gBAClG,YAAY,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBAE/C,OAAO;oBACH,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC;oBAC1C,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE;oBACxD,QAAQ;iBACX,CAAC;YACN,CAAC,CAAC,CAAC;YAEH,uBAAuB,CAAC;gBACpB;oBACI,GAAG,yBAAyB;oBAC5B,QAAQ,EAAE,2BAA2B;iBACxC;aACJ,CAAC,CAAC;YACH,kBAAkB,CAAC,YAAY,CAAC,CAAC;QACrC,CAAC;IACL,CAAC,EAAE,CAAC,2BAA2B,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE3C,OAAO;QACH,oBAAoB;QACpB,eAAe;QACf,OAAO,EAAE,8BAA8B;QACvC,KAAK,EAAE,4BAA4B;KACtC,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 {useEffect, useState} from 'react';\nimport {useGetLibraryPreviewsSettingsQuery} from '_ui/_gqlTypes';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\nexport const SELECT_ALL_KEY = 'select-all';\n\nexport type PreviewSizesTreeNode = {\n title: string;\n key: string;\n children?: PreviewSizesTreeNode[];\n};\n\ninterface IUseGetPreviewSizesDataReturn {\n previewSizesTreeData: PreviewSizesTreeNode[];\n allPreviewSizes: string[];\n loading: boolean;\n error: Error | undefined;\n}\n\n/**\n * Hook that fetches library preview settings and transforms them into tree data\n * for the preview sizes selection in the GeneratePreviewsModal\n */\nexport const useGetPreviewSizesData = (libraryId: string): IUseGetPreviewSizesDataReturn => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n\n const [previewSizesTreeData, setPreviewSizesTreeData] = useState<PreviewSizesTreeNode[]>([]);\n const [allPreviewSizes, setAllPreviewSizes] = useState<string[]>([]);\n\n const {\n data: libraryPreviewsSettingsData,\n error: libraryPreviewsSettingsError,\n loading: libraryPreviewsSettingsLoading,\n } = useGetLibraryPreviewsSettingsQuery({\n variables: {\n id: libraryId,\n },\n });\n\n useEffect(() => {\n if (libraryPreviewsSettingsData?.libraries?.list) {\n const selectAllPreviewSizesNode = {\n title: t('files.previews_generation_select_all'),\n key: SELECT_ALL_KEY,\n };\n const libraryPreviewSettings = libraryPreviewsSettingsData.libraries.list?.[0]?.previewsSettings || [];\n const previewSizes: string[] = [];\n\n const libraryPreviewSizesTreeData = libraryPreviewSettings.map(s => {\n const children = s.versions.sizes.map(vs => ({title: `${vs.name} (${vs.size}px)`, key: vs.name}));\n previewSizes.push(...children.map(c => c.key));\n\n return {\n title: localizedTranslation(s.label, lang),\n key: localizedTranslation(s.label, lang) + Math.random(),\n children,\n };\n });\n\n setPreviewSizesTreeData([\n {\n ...selectAllPreviewSizesNode,\n children: libraryPreviewSizesTreeData,\n },\n ]);\n setAllPreviewSizes(previewSizes);\n }\n }, [libraryPreviewsSettingsData, lang, t]);\n\n return {\n previewSizesTreeData,\n allPreviewSizes,\n loading: libraryPreviewsSettingsLoading,\n error: libraryPreviewsSettingsError,\n };\n};\n"]}
@@ -0,0 +1,19 @@
1
+ import { type ReactElement } from 'react';
2
+ import { type FeatureHook, type IMassActions } from '../_types';
3
+ import { type IViewSettingsState } from '../manage-view-settings';
4
+ interface IUseGeneratePreviewsMassActionReturn {
5
+ generatePreviewsMassAction: IMassActions | null;
6
+ GeneratePreviewsModal: ReactElement | null;
7
+ }
8
+ /**
9
+ * Hook that provides a mass action configuration for generating previews for selected or all items
10
+ * from a view/data set
11
+ */
12
+ export declare const useGeneratePreviewsMassAction: ({ isEnabled, store: { view }, totalCount, onGeneratePreviews, }: FeatureHook<{
13
+ store: {
14
+ view: IViewSettingsState;
15
+ };
16
+ totalCount: number;
17
+ onGeneratePreviews?: IMassActions["callback"];
18
+ }>) => IUseGeneratePreviewsMassActionReturn;
19
+ export {};
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx } 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
+ import { useCallback, useMemo, useState } from 'react';
6
+ import { LibraryBehavior, useForcePreviewsGenerationMutation, useGetLibraryByIdQuery, } from '../../../_gqlTypes';
7
+ import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
8
+ import { MASS_SELECTION_ALL } from '../_constants';
9
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
10
+ import { faImage } from '@fortawesome/free-solid-svg-icons';
11
+ import { GeneratePreviewsModal } from './generate-previews/GeneratePreviewsModal';
12
+ import { KitAlert } from 'aristid-ds';
13
+ import { ERROR_ALERT_DURATION, SUCCESS_NOTIFICATION_DURATION } from '../../../constants';
14
+ /**
15
+ * Hook that provides a mass action configuration for generating previews for selected or all items
16
+ * from a view/data set
17
+ */
18
+ export const useGeneratePreviewsMassAction = ({ isEnabled, store: { view }, totalCount, onGeneratePreviews, }) => {
19
+ const { t } = useSharedTranslation();
20
+ const [isModalOpen, setIsModalOpen] = useState(false);
21
+ const [massSelectionFilter, setMassSelectionFilter] = useState();
22
+ const [startPreviewsGeneration, { loading: isGeneratingPreviews }] = useForcePreviewsGenerationMutation();
23
+ const { data: libraryData } = useGetLibraryByIdQuery({
24
+ variables: {
25
+ id: view.libraryId,
26
+ },
27
+ });
28
+ const _handleConfirmGeneratePreviews = useCallback(async (previewSizes, isFailedOnly) => {
29
+ if (!massSelectionFilter) {
30
+ return;
31
+ }
32
+ const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
33
+ try {
34
+ const result = await startPreviewsGeneration({
35
+ variables: {
36
+ libraryId: view.libraryId,
37
+ filters: massSelectionFilter ?? null,
38
+ failedOnly: isFailedOnly,
39
+ previewVersionSizeNames: previewSizes,
40
+ },
41
+ });
42
+ const isSuccess = result.data?.forcePreviewsGeneration ?? false;
43
+ if (isSuccess) {
44
+ KitAlert.success({
45
+ showIcon: true,
46
+ duration: SUCCESS_NOTIFICATION_DURATION,
47
+ closable: true,
48
+ message: t('files.previews_generation_success'),
49
+ description: null,
50
+ });
51
+ }
52
+ else {
53
+ KitAlert.info({
54
+ showIcon: true,
55
+ duration: ERROR_ALERT_DURATION,
56
+ closable: true,
57
+ message: t('files.previews_generation_nothing_to_do'),
58
+ description: null,
59
+ });
60
+ }
61
+ onGeneratePreviews?.(massSelectionFilter, view.massSelection);
62
+ setIsModalOpen(false);
63
+ }
64
+ catch (e) {
65
+ KitAlert.error({
66
+ showIcon: true,
67
+ duration: ERROR_ALERT_DURATION,
68
+ message: t('error.error_occurred'),
69
+ description: t('explorer.massAction.generate_previews_error_description', { count: total }),
70
+ closable: true,
71
+ });
72
+ }
73
+ }, [view.libraryId, view.massSelection, totalCount, massSelectionFilter, onGeneratePreviews, t]);
74
+ const _handleCloseModal = useCallback(() => {
75
+ setIsModalOpen(false);
76
+ setMassSelectionFilter(undefined);
77
+ }, []);
78
+ const _generatePreviewsMassAction = useMemo(() => ({
79
+ label: t('explorer.massAction.generate_previews'),
80
+ icon: _jsx(FontAwesomeIcon, { icon: faImage }),
81
+ deselectAll: false,
82
+ callback: filter => {
83
+ setMassSelectionFilter(filter);
84
+ setIsModalOpen(true);
85
+ },
86
+ }), [t]);
87
+ const generatePreviewsModal = isEnabled ? (_jsx(GeneratePreviewsModal, { open: isModalOpen, libraryId: view.libraryId, isGeneratingPreviews: isGeneratingPreviews, onClose: _handleCloseModal, onConfirm: _handleConfirmGeneratePreviews })) : null;
88
+ const isLibraryFileBehavior = libraryData?.libraries?.list?.[0]?.behavior === LibraryBehavior.files;
89
+ return {
90
+ generatePreviewsMassAction: isEnabled && isLibraryFileBehavior ? _generatePreviewsMassAction : null,
91
+ GeneratePreviewsModal: isLibraryFileBehavior ? generatePreviewsModal : null,
92
+ };
93
+ };
94
+ //# sourceMappingURL=useGeneratePreviewsMassAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGeneratePreviewsMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useGeneratePreviewsMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAA8B,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClF,OAAO,EACH,eAAe,EACf,kCAAkC,EAClC,sBAAsB,GAEzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAC,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAAC,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAE,6BAA6B,EAAC,MAAM,eAAe,CAAC;AAOlF;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,EAC1C,SAAS,EACT,KAAK,EAAE,EAAC,IAAI,EAAC,EACb,UAAU,EACV,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MAAM,CAAC,EAAE;YACf,sBAAsB,CAAC,MAAM,CAAC,CAAC;YAC/B,cAAc,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;KACJ,CAAC,EACF,CAAC,CAAC,CAAC,CACN,CAAC;IAEF,MAAM,qBAAqB,GAAG,SAAS,CAAC,CAAC,CAAC,CACtC,KAAC,qBAAqB,IAClB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,oBAAoB,EAAE,oBAAoB,EAC1C,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,8BAA8B,GAC3C,CACL,CAAC,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,qBAAqB,GAAG,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,KAAK,eAAe,CAAC,KAAK,CAAC;IAEpG,OAAO;QACH,0BAA0B,EAAE,SAAS,IAAI,qBAAqB,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,IAAI;QACnG,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI;KAC9E,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 Key, type ReactElement, useCallback, useMemo, useState} from 'react';\nimport {\n LibraryBehavior,\n useForcePreviewsGenerationMutation,\n useGetLibraryByIdQuery,\n type RecordFilterInput,\n} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsState} from '../manage-view-settings';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faImage} from '@fortawesome/free-solid-svg-icons';\nimport {GeneratePreviewsModal} from './generate-previews/GeneratePreviewsModal';\nimport {KitAlert} from 'aristid-ds';\nimport {ERROR_ALERT_DURATION, SUCCESS_NOTIFICATION_DURATION} from '_ui/constants';\n\ninterface IUseGeneratePreviewsMassActionReturn {\n generatePreviewsMassAction: IMassActions | null;\n GeneratePreviewsModal: ReactElement | null;\n}\n\n/**\n * Hook that provides a mass action configuration for generating previews for selected or all items\n * from a view/data set\n */\nexport const useGeneratePreviewsMassAction = ({\n isEnabled,\n store: {view},\n totalCount,\n onGeneratePreviews,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n };\n totalCount: number;\n onGeneratePreviews?: IMassActions['callback'];\n}>): IUseGeneratePreviewsMassActionReturn => {\n const {t} = useSharedTranslation();\n\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [massSelectionFilter, setMassSelectionFilter] = useState<RecordFilterInput[] | undefined>();\n const [startPreviewsGeneration, {loading: isGeneratingPreviews}] = useForcePreviewsGenerationMutation();\n const {data: libraryData} = useGetLibraryByIdQuery({\n variables: {\n id: view.libraryId,\n },\n });\n\n const _handleConfirmGeneratePreviews = useCallback(\n async (previewSizes: Key[], isFailedOnly: boolean) => {\n if (!massSelectionFilter) {\n return;\n }\n\n const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n\n try {\n const result = await startPreviewsGeneration({\n variables: {\n libraryId: view.libraryId,\n filters: massSelectionFilter ?? null,\n failedOnly: isFailedOnly,\n previewVersionSizeNames: previewSizes as string[],\n },\n });\n\n const isSuccess = result.data?.forcePreviewsGeneration ?? false;\n\n if (isSuccess) {\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_NOTIFICATION_DURATION,\n closable: true,\n message: t('files.previews_generation_success'),\n description: null,\n });\n } else {\n KitAlert.info({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n closable: true,\n message: t('files.previews_generation_nothing_to_do'),\n description: null,\n });\n }\n\n onGeneratePreviews?.(massSelectionFilter, view.massSelection);\n setIsModalOpen(false);\n } catch (e) {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.generate_previews_error_description', {count: total}),\n closable: true,\n });\n }\n },\n [view.libraryId, view.massSelection, totalCount, massSelectionFilter, onGeneratePreviews, t],\n );\n\n const _handleCloseModal = useCallback(() => {\n setIsModalOpen(false);\n setMassSelectionFilter(undefined);\n }, []);\n\n const _generatePreviewsMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.generate_previews'),\n icon: <FontAwesomeIcon icon={faImage} />,\n deselectAll: false,\n callback: filter => {\n setMassSelectionFilter(filter);\n setIsModalOpen(true);\n },\n }),\n [t],\n );\n\n const generatePreviewsModal = isEnabled ? (\n <GeneratePreviewsModal\n open={isModalOpen}\n libraryId={view.libraryId}\n isGeneratingPreviews={isGeneratingPreviews}\n onClose={_handleCloseModal}\n onConfirm={_handleConfirmGeneratePreviews}\n />\n ) : null;\n\n const isLibraryFileBehavior = libraryData?.libraries?.list?.[0]?.behavior === LibraryBehavior.files;\n\n return {\n generatePreviewsMassAction: isEnabled && isLibraryFileBehavior ? _generatePreviewsMassAction : null,\n GeneratePreviewsModal: isLibraryFileBehavior ? generatePreviewsModal : null,\n };\n};\n"]}
@@ -7,6 +7,6 @@ import { KitIdCard, KitRadio, KitSpace, KitTag } from 'aristid-ds';
7
7
  export const SelectViewType = ({ value, onChange }) => {
8
8
  const { t } = useSharedTranslation();
9
9
  const comingSoonTag = (_jsx(KitTag, { type: "secondary", children: _jsx(KitIdCard, { description: String(t('explorer.coming-soon')) }) }));
10
- return (_jsx(KitRadio.Group, { value: value, onChange: onChange, children: _jsxs(KitSpace, { direction: "vertical", size: 0, children: [_jsx(KitRadio, { value: "list", disabled: true, children: _jsxs(KitSpace, { children: [t('explorer.view-type-list'), " ", comingSoonTag] }) }), _jsx(KitRadio, { value: "table", children: t('explorer.view-type-table') }), _jsx(KitRadio, { value: "mosaic", disabled: true, children: _jsxs(KitSpace, { children: [t('explorer.view-type-mosaic'), " ", comingSoonTag] }) }), _jsx(KitRadio, { value: "planning", disabled: true, children: _jsxs(KitSpace, { children: [t('explorer.view-type-planning'), " ", comingSoonTag] }) })] }) }));
10
+ return (_jsx(KitRadio.Group, { value: value, onChange: onChange, children: _jsxs(KitSpace, { direction: "vertical", size: 0, children: [_jsx(KitRadio, { value: "table", children: t('explorer.view-type-table') }), _jsx(KitRadio, { value: "timeline", children: t('explorer.view-type-planning') }), _jsx(KitRadio, { value: "list", disabled: true, children: _jsxs(KitSpace, { children: [t('explorer.view-type-list'), " ", comingSoonTag] }) }), _jsx(KitRadio, { value: "mosaic", disabled: true, children: _jsxs(KitSpace, { children: [t('explorer.view-type-mosaic'), " ", comingSoonTag] }) })] }) }));
11
11
  };
12
12
  //# sourceMappingURL=SelectViewType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectViewType.js","sourceRoot":"","sources":["../../../../../../src/components/Explorer/manage-view-settings/configure-display/view-type/SelectViewType.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AASjE,MAAM,CAAC,MAAM,cAAc,GAA4C,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,EAAE;IACzF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,aAAa,GAAG,CAClB,KAAC,MAAM,IAAC,IAAI,EAAC,WAAW,YACpB,KAAC,SAAS,IAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,GAAI,GACxD,CACZ,CAAC;IAEF,OAAO,CACH,KAAC,QAAQ,CAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,YAC5C,MAAC,QAAQ,IAAC,SAAS,EAAC,UAAU,EAAC,IAAI,EAAE,CAAC,aAClC,KAAC,QAAQ,IAAC,KAAK,EAAC,MAAM,EAAC,QAAQ,kBAC3B,MAAC,QAAQ,eACJ,CAAC,CAAC,yBAAyB,CAAC,OAAG,aAAa,IACtC,GACJ,EACX,KAAC,QAAQ,IAAC,KAAK,EAAC,OAAO,YAAE,CAAC,CAAC,0BAA0B,CAAC,GAAY,EAClE,KAAC,QAAQ,IAAC,KAAK,EAAC,QAAQ,EAAC,QAAQ,kBAC7B,MAAC,QAAQ,eACJ,CAAC,CAAC,2BAA2B,CAAC,OAAG,aAAa,IACxC,GACJ,EACX,KAAC,QAAQ,IAAC,KAAK,EAAC,UAAU,EAAC,QAAQ,kBAC/B,MAAC,QAAQ,eACJ,CAAC,CAAC,6BAA6B,CAAC,OAAG,aAAa,IAC1C,GACJ,IACJ,GACE,CACpB,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 {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitIdCard, KitRadio, KitSpace, KitTag} from 'aristid-ds';\nimport {type RadioGroupProps} from 'aristid-ds/dist/Kit/DataEntry/Radio';\nimport {type FunctionComponent} from 'react';\n\ninterface ISelectViewTypeProps {\n value: string;\n onChange: RadioGroupProps['onChange'];\n}\n\nexport const SelectViewType: FunctionComponent<ISelectViewTypeProps> = ({value, onChange}) => {\n const {t} = useSharedTranslation();\n\n const comingSoonTag = (\n <KitTag type=\"secondary\">\n <KitIdCard description={String(t('explorer.coming-soon'))} />\n </KitTag>\n );\n\n return (\n <KitRadio.Group value={value} onChange={onChange}>\n <KitSpace direction=\"vertical\" size={0}>\n <KitRadio value=\"list\" disabled>\n <KitSpace>\n {t('explorer.view-type-list')} {comingSoonTag}\n </KitSpace>\n </KitRadio>\n <KitRadio value=\"table\">{t('explorer.view-type-table')}</KitRadio>\n <KitRadio value=\"mosaic\" disabled>\n <KitSpace>\n {t('explorer.view-type-mosaic')} {comingSoonTag}\n </KitSpace>\n </KitRadio>\n <KitRadio value=\"planning\" disabled>\n <KitSpace>\n {t('explorer.view-type-planning')} {comingSoonTag}\n </KitSpace>\n </KitRadio>\n </KitSpace>\n </KitRadio.Group>\n );\n};\n"]}
1
+ {"version":3,"file":"SelectViewType.js","sourceRoot":"","sources":["../../../../../../src/components/Explorer/manage-view-settings/configure-display/view-type/SelectViewType.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AASjE,MAAM,CAAC,MAAM,cAAc,GAA4C,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,EAAE;IACzF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,aAAa,GAAG,CAClB,KAAC,MAAM,IAAC,IAAI,EAAC,WAAW,YACpB,KAAC,SAAS,IAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,GAAI,GACxD,CACZ,CAAC;IAEF,OAAO,CACH,KAAC,QAAQ,CAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,YAC5C,MAAC,QAAQ,IAAC,SAAS,EAAC,UAAU,EAAC,IAAI,EAAE,CAAC,aAClC,KAAC,QAAQ,IAAC,KAAK,EAAC,OAAO,YAAE,CAAC,CAAC,0BAA0B,CAAC,GAAY,EAClE,KAAC,QAAQ,IAAC,KAAK,EAAC,UAAU,YAAE,CAAC,CAAC,6BAA6B,CAAC,GAAY,EACxE,KAAC,QAAQ,IAAC,KAAK,EAAC,MAAM,EAAC,QAAQ,kBAC3B,MAAC,QAAQ,eACJ,CAAC,CAAC,yBAAyB,CAAC,OAAG,aAAa,IACtC,GACJ,EACX,KAAC,QAAQ,IAAC,KAAK,EAAC,QAAQ,EAAC,QAAQ,kBAC7B,MAAC,QAAQ,eACJ,CAAC,CAAC,2BAA2B,CAAC,OAAG,aAAa,IACxC,GACJ,IACJ,GACE,CACpB,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 {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitIdCard, KitRadio, KitSpace, KitTag} from 'aristid-ds';\nimport {type RadioGroupProps} from 'aristid-ds/dist/Kit/DataEntry/Radio';\nimport {type FunctionComponent} from 'react';\n\ninterface ISelectViewTypeProps {\n value: string;\n onChange: RadioGroupProps['onChange'];\n}\n\nexport const SelectViewType: FunctionComponent<ISelectViewTypeProps> = ({value, onChange}) => {\n const {t} = useSharedTranslation();\n\n const comingSoonTag = (\n <KitTag type=\"secondary\">\n <KitIdCard description={String(t('explorer.coming-soon'))} />\n </KitTag>\n );\n\n return (\n <KitRadio.Group value={value} onChange={onChange}>\n <KitSpace direction=\"vertical\" size={0}>\n <KitRadio value=\"table\">{t('explorer.view-type-table')}</KitRadio>\n <KitRadio value=\"timeline\">{t('explorer.view-type-planning')}</KitRadio>\n <KitRadio value=\"list\" disabled>\n <KitSpace>\n {t('explorer.view-type-list')} {comingSoonTag}\n </KitSpace>\n </KitRadio>\n <KitRadio value=\"mosaic\" disabled>\n <KitSpace>\n {t('explorer.view-type-mosaic')} {comingSoonTag}\n </KitSpace>\n </KitRadio>\n </KitSpace>\n </KitRadio.Group>\n );\n};\n"]}
@@ -1,13 +1,27 @@
1
1
  // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
2
2
  // This file is released under LGPL V3
3
3
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
4
- import { useGetLibraryByIdQuery, useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery, } from '../../../_gqlTypes';
4
+ import { useLazyQuery } from '@apollo/client';
5
+ import { useGetLibraryByIdQuery, } from '../../../_gqlTypes';
6
+ import { getTreeContentQuery } from '../../../_queries/trees/getTreeContentQuery';
5
7
  import { useEffect, useState } from 'react';
6
- import { defaultPaginationPageSize } from '../../../constants';
8
+ const _flattenNodes = (nodes) => nodes.flatMap(node => [
9
+ ...(node.accessRecordByDefaultPermission
10
+ ? [
11
+ {
12
+ nodeId: node.id,
13
+ libraryId: node.record.whoAmI.library.id,
14
+ value: node.record.id,
15
+ label: node.record.whoAmI.label,
16
+ },
17
+ ]
18
+ : []),
19
+ ..._flattenNodes(node.children ?? []),
20
+ ]);
7
21
  export const useGetTreeFilters = ({ libraryId, skip }) => {
8
22
  const [treeFilters, setTreeFilters] = useState({});
9
23
  const [treeFiltersLoading, setTreeFiltersLoading] = useState(true);
10
- const [loadTreeContent] = useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery();
24
+ const [loadTreeContent] = useLazyQuery(getTreeContentQuery());
11
25
  const { data: libraryData, loading: libraryLoading } = useGetLibraryByIdQuery({
12
26
  variables: {
13
27
  id: libraryId,
@@ -23,50 +37,20 @@ export const useGetTreeFilters = ({ libraryId, skip }) => {
23
37
  attributeId: attribute.id,
24
38
  treeId: libraryData?.libraries.list[0]?.attributes.find(tree => tree.id === attribute.id)?.linked_tree?.id,
25
39
  })) || [];
26
- const _fetchChildrenPage = async (treeId, attributeId, parentNodeKey, offset) => {
40
+ const treeResponse = await Promise.all(treeAttributesWithExtendedPermissions.map(async (attribute) => {
27
41
  const { data } = await loadTreeContent({
28
42
  variables: {
29
- treeId,
30
- node: parentNodeKey,
31
- pagination: { offset, limit: defaultPaginationPageSize },
43
+ treeId: attribute.treeId,
32
44
  accessRecordByDefaultPermission: {
33
- attributeId,
45
+ attributeId: attribute.attributeId,
34
46
  libraryId,
35
47
  },
36
48
  },
37
49
  });
38
- const { list, totalCount } = data?.treeNodeChildren ?? { list: [], totalCount: 0 };
39
- const records = [];
40
- for (const node of list) {
41
- if (node.accessRecordByDefaultPermission) {
42
- records.push({
43
- nodeId: node.id,
44
- libraryId: node.record.whoAmI.library.id,
45
- value: node.record.id,
46
- label: node.record.whoAmI.label,
47
- });
48
- }
49
- if (node.childrenCount > 0) {
50
- const childrenRecords = await _fetchAllChildren(treeId, attributeId, node.id);
51
- records.push(...childrenRecords);
52
- }
53
- }
54
- return { records, totalCount };
55
- };
56
- const _fetchAllChildren = async (treeId, attributeId, parentNodeKey, offset = 0, accumulated = []) => {
57
- const { records, totalCount } = await _fetchChildrenPage(treeId, attributeId, parentNodeKey, offset);
58
- const allRecords = [...accumulated, ...records];
59
- const nextOffset = offset + defaultPaginationPageSize;
60
- if (nextOffset < totalCount) {
61
- return _fetchAllChildren(treeId, attributeId, parentNodeKey, nextOffset, allRecords);
62
- }
63
- return allRecords;
64
- };
65
- const treeResponse = await Promise.all(treeAttributesWithExtendedPermissions.map(async (attribute) => {
66
- const recordIds = await _fetchAllChildren(attribute.treeId, attribute.attributeId, null);
50
+ const flatNodes = _flattenNodes(data?.treeContent ?? []);
67
51
  return {
68
52
  attributeId: attribute.attributeId,
69
- recordIds,
53
+ recordIds: flatNodes,
70
54
  };
71
55
  }));
72
56
  const attributeRecords = treeResponse.reduce((acc, item) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useGetTreeFilters.js","sourceRoot":"","sources":["../../../../src/components/Filters/context/useGetTreeFilters.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAEH,sBAAsB,EACtB,iEAAiE,GACpE,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAC;A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AAe,CAAC,CAAC,CAAC;IAEpE,OAAO;QACH,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,kBAAkB;KAC9B,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 {\n type TreeAttributeDetailsFragment,\n useGetLibraryByIdQuery,\n useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery,\n} from '_ui/_gqlTypes';\nimport {useEffect, useState} from 'react';\nimport {defaultPaginationPageSize} from '_ui/constants';\n\ninterface ITreeNode {\n nodeId: string;\n libraryId: string;\n value: string;\n label: string;\n}\n\nexport interface ITreeFilters {\n [x: string]: ITreeNode[];\n}\n\nexport const useGetTreeFilters = ({libraryId, skip}: {libraryId: string; skip: boolean}) => {\n const [treeFilters, setTreeFilters] = useState<ITreeFilters>({});\n const [treeFiltersLoading, setTreeFiltersLoading] = useState(true);\n const [loadTreeContent] = useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery();\n\n const {data: libraryData, loading: libraryLoading} = useGetLibraryByIdQuery({\n variables: {\n id: libraryId,\n },\n skip: skip || !libraryId,\n });\n\n useEffect(() => {\n if (skip || !libraryId || libraryLoading || !libraryData) {\n return;\n }\n\n const fetchTreeFilters = async () => {\n const treeAttributesWithExtendedPermissions: Array<{attributeId: string; treeId: string}> =\n libraryData?.libraries.list[0]?.permissions_conf?.permissionTreeAttributes.map(attribute => ({\n attributeId: attribute.id,\n treeId: (\n libraryData?.libraries.list[0]?.attributes.find(\n tree => tree.id === attribute.id,\n ) as TreeAttributeDetailsFragment\n )?.linked_tree?.id,\n })) || [];\n\n const _fetchChildrenPage = async (\n treeId: string,\n attributeId: string,\n parentNodeKey: string | null,\n offset: number,\n ) => {\n const {data} = await loadTreeContent({\n variables: {\n treeId,\n node: parentNodeKey,\n pagination: {offset, limit: defaultPaginationPageSize},\n accessRecordByDefaultPermission: {\n attributeId,\n libraryId,\n },\n },\n });\n\n const {list, totalCount} = data?.treeNodeChildren ?? {list: [], totalCount: 0};\n\n const records: ITreeNode[] = [];\n\n for (const node of list) {\n if (node.accessRecordByDefaultPermission) {\n records.push({\n nodeId: node.id,\n libraryId: node.record.whoAmI.library.id,\n value: node.record.id,\n label: node.record.whoAmI.label,\n });\n }\n\n if (node.childrenCount > 0) {\n const childrenRecords = await _fetchAllChildren(treeId, attributeId, node.id);\n records.push(...childrenRecords);\n }\n }\n\n return {records, totalCount};\n };\n\n const _fetchAllChildren = async (\n treeId: string,\n attributeId: string,\n parentNodeKey: string | null,\n offset = 0,\n accumulated: ITreeNode[] = [],\n ): Promise<ITreeNode[]> => {\n const {records, totalCount} = await _fetchChildrenPage(treeId, attributeId, parentNodeKey, offset);\n const allRecords = [...accumulated, ...records];\n\n const nextOffset = offset + defaultPaginationPageSize;\n if (nextOffset < totalCount) {\n return _fetchAllChildren(treeId, attributeId, parentNodeKey, nextOffset, allRecords);\n }\n\n return allRecords;\n };\n\n const treeResponse = await Promise.all(\n treeAttributesWithExtendedPermissions.map(async attribute => {\n const recordIds = await _fetchAllChildren(attribute.treeId, attribute.attributeId, null);\n\n return {\n attributeId: attribute.attributeId,\n recordIds,\n };\n }),\n );\n\n const attributeRecords = treeResponse.reduce((acc, item) => {\n if (item.recordIds.length > 0) {\n acc[item.attributeId] = item.recordIds;\n }\n return acc;\n }, {});\n\n setTreeFilters(attributeRecords);\n setTreeFiltersLoading(false);\n };\n\n fetchTreeFilters();\n }, [skip, libraryId, libraryLoading, libraryData, loadTreeContent]);\n\n return {\n data: treeFilters,\n loading: treeFiltersLoading,\n };\n};\n"]}
1
+ {"version":3,"file":"useGetTreeFilters.js","sourceRoot":"","sources":["../../../../src/components/Filters/context/useGetTreeFilters.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAA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AAC;oBAC5B,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;gBAC3C,CAAC;gBACD,OAAO,GAAG,CAAC;YACf,CAAC,EAAE,EAAE,CAAC,CAAC;YAEP,cAAc,CAAC,gBAAgB,CAAC,CAAC;YACjC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC;QAEF,gBAAgB,EAAE,CAAC;IACvB,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC;IAEpE,OAAO;QACH,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,kBAAkB;KAC9B,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 {useLazyQuery} from '@apollo/client';\nimport {\n type GetTreeContentQueryQuery,\n type GetTreeContentQueryQueryVariables,\n type TreeAttributeDetailsFragment,\n useGetLibraryByIdQuery,\n} from '_ui/_gqlTypes';\nimport {getTreeContentQuery} from '_ui/_queries/trees/getTreeContentQuery';\nimport {useEffect, useState} from 'react';\n\ninterface ITreeNode {\n nodeId: string;\n libraryId: string;\n value: string;\n label: string;\n}\n\nexport interface ITreeFilters {\n [x: string]: ITreeNode[];\n}\n\nconst _flattenNodes = (\n nodes: Array<\n GetTreeContentQueryQuery['treeContent'][number] & {\n children?: Array<GetTreeContentQueryQuery['treeContent'][number]>;\n }\n >,\n): ITreeNode[] =>\n nodes.flatMap(node => [\n ...(node.accessRecordByDefaultPermission\n ? [\n {\n nodeId: node.id,\n libraryId: node.record.whoAmI.library.id,\n value: node.record.id,\n label: node.record.whoAmI.label,\n },\n ]\n : []),\n ..._flattenNodes(node.children ?? []),\n ]);\n\nexport const useGetTreeFilters = ({libraryId, skip}: {libraryId: string; skip: boolean}) => {\n const [treeFilters, setTreeFilters] = useState<ITreeFilters>({});\n const [treeFiltersLoading, setTreeFiltersLoading] = useState(true);\n const [loadTreeContent] = useLazyQuery<GetTreeContentQueryQuery, GetTreeContentQueryQueryVariables>(\n getTreeContentQuery(),\n );\n\n const {data: libraryData, loading: libraryLoading} = useGetLibraryByIdQuery({\n variables: {\n id: libraryId,\n },\n skip: skip || !libraryId,\n });\n\n useEffect(() => {\n if (skip || !libraryId || libraryLoading || !libraryData) {\n return;\n }\n\n const fetchTreeFilters = async () => {\n const treeAttributesWithExtendedPermissions: Array<{attributeId: string; treeId: string}> =\n libraryData?.libraries.list[0]?.permissions_conf?.permissionTreeAttributes.map(attribute => ({\n attributeId: attribute.id,\n treeId: (\n libraryData?.libraries.list[0]?.attributes.find(\n tree => tree.id === attribute.id,\n ) as TreeAttributeDetailsFragment\n )?.linked_tree?.id,\n })) || [];\n\n const treeResponse = await Promise.all(\n treeAttributesWithExtendedPermissions.map(async attribute => {\n const {data} = await loadTreeContent({\n variables: {\n treeId: attribute.treeId,\n accessRecordByDefaultPermission: {\n attributeId: attribute.attributeId,\n libraryId,\n },\n },\n });\n\n const flatNodes = _flattenNodes(data?.treeContent ?? []);\n\n return {\n attributeId: attribute.attributeId,\n recordIds: flatNodes,\n };\n }),\n );\n\n const attributeRecords = treeResponse.reduce((acc, item) => {\n if (item.recordIds.length > 0) {\n acc[item.attributeId] = item.recordIds;\n }\n return acc;\n }, {});\n\n setTreeFilters(attributeRecords);\n setTreeFiltersLoading(false);\n };\n\n fetchTreeFilters();\n }, [skip, libraryId, libraryLoading, libraryData, loadTreeContent]);\n\n return {\n data: treeFilters,\n loading: treeFiltersLoading,\n };\n};\n"]}
@@ -1,50 +1,23 @@
1
1
  // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
2
2
  // This file is released under LGPL V3
3
3
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
4
+ import { useLazyQuery } from '@apollo/client';
4
5
  import { useEffect, useState } from 'react';
5
- import { useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery } from '../../../../../_gqlTypes';
6
- import { defaultPaginationPageSize } from '../../../../../constants';
6
+ import { getTreeContentQuery } from '../../../../../_queries/trees/getTreeContentQuery';
7
+ const _toTreeNode = (node) => ({
8
+ title: node.record.whoAmI.label ?? node.record.whoAmI.id,
9
+ id: node.id,
10
+ key: node.id,
11
+ children: (node.children ?? []).map(_toTreeNode),
12
+ accessRecordByDefaultPermission: node.accessRecordByDefaultPermission ?? undefined,
13
+ libraryId: node.record.whoAmI.library.id,
14
+ recordId: node.record.id,
15
+ });
7
16
  export const useGetTreeData = ({ treeId, attributeId, libraryId }) => {
8
- const [loadTreeContent] = useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery();
17
+ const [loadTreeContent] = useLazyQuery(getTreeContentQuery());
9
18
  const [treeData, setTreeData] = useState([]);
10
19
  const [isLoading, setIsLoading] = useState(true);
11
20
  const [error, setError] = useState(null);
12
- const _fetchChildrenPage = async (parentNodeKey, offset) => {
13
- const { data } = await loadTreeContent({
14
- variables: {
15
- treeId,
16
- node: parentNodeKey,
17
- pagination: { offset, limit: defaultPaginationPageSize },
18
- accessRecordByDefaultPermission: {
19
- attributeId,
20
- libraryId,
21
- },
22
- },
23
- });
24
- const { list, totalCount } = data?.treeNodeChildren ?? { list: [], totalCount: 0 };
25
- const nodes = await Promise.all(list.map(async (node) => {
26
- const children = node.childrenCount ? await _fetchAllChildren(node.id) : [];
27
- return {
28
- title: node.record.whoAmI.label || node.record.whoAmI.id,
29
- id: node.id,
30
- key: node.id,
31
- children,
32
- accessRecordByDefaultPermission: node.accessRecordByDefaultPermission,
33
- libraryId: node.record.whoAmI.library.id,
34
- recordId: node.record.id,
35
- };
36
- }));
37
- return { nodes, totalCount };
38
- };
39
- const _fetchAllChildren = async (parentNodeKey, offset = 0, accumulated = []) => {
40
- const { nodes, totalCount } = await _fetchChildrenPage(parentNodeKey, offset);
41
- const allNodes = [...accumulated, ...nodes];
42
- const nextOffset = offset + defaultPaginationPageSize;
43
- if (nextOffset < totalCount) {
44
- return _fetchAllChildren(parentNodeKey, nextOffset, allNodes);
45
- }
46
- return allNodes;
47
- };
48
21
  useEffect(() => {
49
22
  if (!treeId) {
50
23
  setTreeData([]);
@@ -55,8 +28,16 @@ export const useGetTreeData = ({ treeId, attributeId, libraryId }) => {
55
28
  setIsLoading(true);
56
29
  setError(null);
57
30
  try {
58
- const children = await _fetchAllChildren(null);
59
- setTreeData(children);
31
+ const { data } = await loadTreeContent({
32
+ variables: {
33
+ treeId,
34
+ accessRecordByDefaultPermission: {
35
+ attributeId,
36
+ libraryId,
37
+ },
38
+ },
39
+ });
40
+ setTreeData((data?.treeContent ?? []).map(node => _toTreeNode(node)));
60
41
  }
61
42
  catch (err) {
62
43
  setError(err instanceof Error ? err : new Error('Failed to load tree'));
@@ -1 +1 @@
1
- {"version":3,"file":"useGetTreeData.js","sourceRoot":"","sources":["../../../../../../src/components/Filters/filter-items/filter-type/tree/useGetTreeData.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,iEAAiE,EAAC,MAAM,eAAe,CAAC;AAChG,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAkBxD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAuB,EAAE,EAAE;IACrF,MAAM,CAAC,eAAe,CAAC,GAAG,iEAAiE,EAAE,CAAC;IAC9F,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAc,EAAE,CAAC,CAAC;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAA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IAErC,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;AACxC,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 {useEffect, useState} from 'react';\nimport {useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery} from '_ui/_gqlTypes';\nimport {defaultPaginationPageSize} from '_ui/constants';\n\nexport interface ITreeNode {\n title: string;\n id: string;\n key: string;\n children: ITreeNode[];\n accessRecordByDefaultPermission?: boolean;\n libraryId: string;\n recordId: string;\n}\n\ninterface IUseGetTreeDataProps {\n treeId: string;\n attributeId: string;\n libraryId: string;\n}\n\nexport const useGetTreeData = ({treeId, attributeId, libraryId}: IUseGetTreeDataProps) => {\n const [loadTreeContent] = useGetTreeNodeChildrenWithAccessByDefaultPermissionQueryLazyQuery();\n const [treeData, setTreeData] = useState<ITreeNode[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const _fetchChildrenPage = async (parentNodeKey: string | null, offset: number) => {\n const {data} = await loadTreeContent({\n variables: {\n treeId,\n node: parentNodeKey,\n pagination: {offset, limit: defaultPaginationPageSize},\n accessRecordByDefaultPermission: {\n attributeId,\n libraryId,\n },\n },\n });\n\n const {list, totalCount} = data?.treeNodeChildren ?? {list: [], totalCount: 0};\n\n const nodes = await Promise.all(\n list.map(async node => {\n const children = node.childrenCount ? await _fetchAllChildren(node.id) : [];\n\n return {\n title: node.record.whoAmI.label || node.record.whoAmI.id,\n id: node.id,\n key: node.id,\n children,\n accessRecordByDefaultPermission: node.accessRecordByDefaultPermission,\n libraryId: node.record.whoAmI.library.id,\n recordId: node.record.id,\n };\n }),\n );\n\n return {nodes, totalCount};\n };\n\n const _fetchAllChildren = async (\n parentNodeKey: string | null,\n offset = 0,\n accumulated: ITreeNode[] = [],\n ): Promise<ITreeNode[]> => {\n const {nodes, totalCount} = await _fetchChildrenPage(parentNodeKey, offset);\n const allNodes = [...accumulated, ...nodes];\n\n const nextOffset = offset + defaultPaginationPageSize;\n if (nextOffset < totalCount) {\n return _fetchAllChildren(parentNodeKey, nextOffset, allNodes);\n }\n\n return allNodes;\n };\n\n useEffect(() => {\n if (!treeId) {\n setTreeData([]);\n setIsLoading(false);\n return;\n }\n\n const loadTree = async () => {\n setIsLoading(true);\n setError(null);\n try {\n const children = await _fetchAllChildren(null);\n setTreeData(children);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to load tree'));\n } finally {\n setIsLoading(false);\n }\n };\n\n loadTree();\n }, [treeId, attributeId, libraryId]);\n\n return {treeData, isLoading, error};\n};\n"]}
1
+ {"version":3,"file":"useGetTreeData.js","sourceRoot":"","sources":["../../../../../../src/components/Filters/filter-items/filter-type/tree/useGetTreeData.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAC,mBAAmB,EAAC,MAAM,wCAAwC,CAAC;AAkB3E,MAAM,WAAW,GAAG,CAChB,IAEC,EACQ,EAAE,CAAC,CAAC;IACb,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;IACxD,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,GAAG,EAAE,IAAI,CAAC,EAAE;IACZ,QAAQ,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC;IAChD,+BAA+B,EAAE,IAAI,CAAC,+BAA+B,IAAI,SAAS;IAClF,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,E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qBAAqB,CAAC,CAAC,CAAC;YAC5E,CAAC;oBAAS,CAAC;gBACP,YAAY,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;QACL,CAAC,CAAC;QAEF,QAAQ,EAAE,CAAC;IACf,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;IAErC,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;AACxC,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 {useLazyQuery} from '@apollo/client';\nimport {useEffect, useState} from 'react';\nimport {type GetTreeContentQueryQuery, type GetTreeContentQueryQueryVariables} from '_ui/_gqlTypes';\nimport {getTreeContentQuery} from '_ui/_queries/trees/getTreeContentQuery';\n\nexport interface ITreeNode {\n title: string;\n id: string;\n key: string;\n children: ITreeNode[];\n accessRecordByDefaultPermission?: boolean;\n libraryId: string;\n recordId: string;\n}\n\ninterface IUseGetTreeDataProps {\n treeId: string;\n attributeId: string;\n libraryId: string;\n}\n\nconst _toTreeNode = (\n node: GetTreeContentQueryQuery['treeContent'][number] & {\n children?: Array<GetTreeContentQueryQuery['treeContent'][number]>;\n },\n): ITreeNode => ({\n title: node.record.whoAmI.label ?? node.record.whoAmI.id,\n id: node.id,\n key: node.id,\n children: (node.children ?? []).map(_toTreeNode),\n accessRecordByDefaultPermission: node.accessRecordByDefaultPermission ?? undefined,\n libraryId: node.record.whoAmI.library.id,\n recordId: node.record.id,\n});\n\nexport const useGetTreeData = ({treeId, attributeId, libraryId}: IUseGetTreeDataProps) => {\n const [loadTreeContent] = useLazyQuery<GetTreeContentQueryQuery, GetTreeContentQueryQueryVariables>(\n getTreeContentQuery(),\n );\n\n const [treeData, setTreeData] = useState<ITreeNode[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n if (!treeId) {\n setTreeData([]);\n setIsLoading(false);\n return;\n }\n\n const loadTree = async () => {\n setIsLoading(true);\n setError(null);\n try {\n const {data} = await loadTreeContent({\n variables: {\n treeId,\n accessRecordByDefaultPermission: {\n attributeId,\n libraryId,\n },\n },\n });\n\n setTreeData((data?.treeContent ?? []).map(node => _toTreeNode(node)));\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to load tree'));\n } finally {\n setIsLoading(false);\n }\n };\n\n loadTree();\n }, [treeId, attributeId, libraryId]);\n\n return {treeData, isLoading, error};\n};\n"]}
@@ -15,6 +15,7 @@ interface IEditRecordProps {
15
15
  showSidebar?: boolean;
16
16
  enableSidebar?: boolean;
17
17
  sidebarContainer?: HTMLElement;
18
+ forceDisableSidebarInAppStudio?: boolean;
18
19
  containerStyle?: CSSObject;
19
20
  withInfoButton: boolean;
20
21
  removePadding?: boolean;
@@ -34,7 +34,7 @@ const Content = styled.div `
34
34
  overflow-y: scroll;
35
35
  border-right: ${props => props.$shouldUseLayoutWithSidebar ? '1px solid var(--general-utilities-border)' : 'none'};
36
36
  `;
37
- export const EditRecord = ({ antdForm, formId, isFormCreationMode, formElementId, record, library: libraryId, onCreate, valuesVersion, enableSidebar = false, showSidebar = false, sidebarContainer, containerStyle, withInfoButton, removePadding = false, }) => {
37
+ export const EditRecord = ({ antdForm, formId, isFormCreationMode, formElementId, record, library: libraryId, onCreate, valuesVersion, enableSidebar = false, showSidebar = false, sidebarContainer, forceDisableSidebarInAppStudio = false, containerStyle, withInfoButton, removePadding = false, }) => {
38
38
  const [state, dispatch] = useReducer(editRecordReducer, {
39
39
  ...initialState,
40
40
  record,
@@ -161,7 +161,7 @@ export const EditRecord = ({ antdForm, formId, isFormCreationMode, formElementId
161
161
  }));
162
162
  return saveValues(record, valuesToSave, version, true);
163
163
  };
164
- const shouldUseLayoutWithSidebar = state.enableSidebar && state.isOpenSidebar && sidebarContainer === undefined;
165
- return (_jsx(ErrorBoundary, { children: _jsx(EditRecordReducerContext.Provider, { value: { state, dispatch }, children: _jsxs(Container, { "$shouldUseLayoutWithSidebar": shouldUseLayoutWithSidebar, style: containerStyle, children: [_jsx(EditRecordButtons, {}), _jsx(Content, { className: "edit-record-content-container", "$shouldUseLayoutWithSidebar": shouldUseLayoutWithSidebar, "$removePadding": removePadding, children: permissionsLoading ? (_jsx(EditRecordSkeleton, { rows: 5 })) : canEdit ? (_jsx(EditRecordContent, { antdForm: antdForm, formId: formId, isFormCreationMode: isFormCreationMode, formElementId: formElementId, record: record, library: libraryId, onRecordSubmit: _handleRecordSubmit, onValueSubmit: _handleValueSubmit, onValueDelete: deleteValue, onDeleteMultipleValues: _handleDeleteAllValues, readonly: isReadOnly })) : (_jsx(ErrorDisplay, { type: ErrorDisplayTypes.PERMISSION_ERROR, showActionButton: false })) }), _jsx(EditRecordSidebar, { onMetadataSubmit: _handleMetadataSubmit, sidebarContainer: sidebarContainer })] }) }) }));
164
+ const shouldUseLayoutWithSidebar = state.enableSidebar && state.isOpenSidebar && sidebarContainer === undefined && !forceDisableSidebarInAppStudio;
165
+ return (_jsx(ErrorBoundary, { children: _jsx(EditRecordReducerContext.Provider, { value: { state, dispatch }, children: _jsxs(Container, { "$shouldUseLayoutWithSidebar": shouldUseLayoutWithSidebar, style: containerStyle, children: [_jsx(EditRecordButtons, {}), _jsx(Content, { className: "edit-record-content-container", "$shouldUseLayoutWithSidebar": shouldUseLayoutWithSidebar, "$removePadding": removePadding, children: permissionsLoading ? (_jsx(EditRecordSkeleton, { rows: 5 })) : canEdit ? (_jsx(EditRecordContent, { antdForm: antdForm, formId: formId, isFormCreationMode: isFormCreationMode, formElementId: formElementId, record: record, library: libraryId, onRecordSubmit: _handleRecordSubmit, onValueSubmit: _handleValueSubmit, onValueDelete: deleteValue, onDeleteMultipleValues: _handleDeleteAllValues, readonly: isReadOnly })) : (_jsx(ErrorDisplay, { type: ErrorDisplayTypes.PERMISSION_ERROR, showActionButton: false })) }), !forceDisableSidebarInAppStudio && (_jsx(EditRecordSidebar, { onMetadataSubmit: _handleMetadataSubmit, sidebarContainer: sidebarContainer }))] }) }) }));
166
166
  };
167
167
  //# sourceMappingURL=EditRecord.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditRecord.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecord/EditRecord.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAyB,SAAS,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AACpE,OAAO,MAAwB,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EACH,aAAa,EAGb,4BAA4B,GAC/B,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,6BAA6B,MAAM,0DAA0D,CAAC;AACrG,OAAO,yBAAyB,MAAM,6DAA6D,CAAC;AAUpG,OAAO,iBAAiB,EAAE,EAAC,6BAA6B,EAAE,YAAY,EAAC,MAAM,wCAAwC,CAAC;AACtH,OAAO,EAAC,wBAAwB,EAAC,MAAM,+CAA+C,CAAC;AAEvF,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,4CAA4C,CAAC;AAC/E,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAmBrD,MAAM,YAAY,GAAG,OAAO,CAAC;AAE7B,MAAM,S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5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,SAAS,EAClB,cAAc,EAAE,mBAAmB,EACnC,aAAa,EAAE,kBAAkB,EACjC,aAAa,EAAE,WAAW,EAC1B,sBAAsB,EAAE,sBAAsB,EAC9C,QAAQ,EAAE,UAAU,GACtB,CACL,CAAC,CAAC,CAAC,CACA,KAAC,YAAY,IAAC,IAAI,EAAE,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,GAAI,CACtF,GACK,EACV,KAAC,iBAAiB,IAAC,gBAAgB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,IAC1F,GACoB,GACxB,CACnB,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 isEqual from 'lodash/isEqual';\nimport {type FunctionComponent, useEffect, useReducer} from 'react';\nimport styled, {type CSSObject} from 'styled-components';\nimport {ErrorDisplayTypes} from '../../../constants';\nimport {useCanEditRecord} from '../../../hooks/useCanEditRecord';\nimport {type IValueVersion} from '../../../types/values';\nimport {\n AttributeType,\n type RecordFormAttributeStandardAttributeFragment,\n type RecordIdentityFragment,\n useActivateNewRecordMutation,\n} from '../../../_gqlTypes';\nimport {\n type IRecordPropertyLink,\n type IRecordPropertyStandard,\n type IRecordPropertyTree,\n} from '../../../_queries/records/getRecordPropertiesQuery';\nimport {ErrorBoundary} from '../../ErrorBoundary';\nimport {ErrorDisplay} from '../../ErrorDisplay';\nimport EditRecordContent from '../EditRecordContent';\nimport useExecuteDeleteValueMutation from '../EditRecordContent/hooks/useExecuteDeleteValueMutation';\nimport useSaveValueBatchMutation from '../EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {\n type DeleteMultipleValuesFunc,\n type ISubmittedValueLink,\n type ISubmittedValueStandard,\n type ISubmittedValueTree,\n type IValueToSubmit,\n type MetadataSubmitValueFunc,\n type SubmitValueFunc,\n} from '../EditRecordContent/_types';\nimport editRecordReducer, {EditRecordReducerActionsTypes, initialState} from '../editRecordReducer/editRecordReducer';\nimport {EditRecordReducerContext} from '../editRecordReducer/editRecordReducerContext';\nimport {type FormInstance} from 'antd/lib/form/Form';\nimport EditRecordSidebar from '../EditRecordSidebar';\nimport EditRecordSkeleton from '../EditRecordSkeleton';\nimport {useQuery} from '@apollo/client';\nimport {getLibraryByIdQuery} from '_ui/_queries/libraries/getLibraryByIdQuery';\nimport EditRecordButtons from '../EditRecordButtons';\n\ninterface IEditRecordProps {\n antdForm: FormInstance;\n formId: string;\n isFormCreationMode: boolean;\n formElementId?: string;\n record: RecordIdentityFragment['whoAmI'] | null;\n library: string;\n onCreate?: (newRecord: RecordIdentityFragment['whoAmI']) => void;\n valuesVersion?: IValueVersion;\n showSidebar?: boolean;\n enableSidebar?: boolean;\n sidebarContainer?: HTMLElement;\n containerStyle?: CSSObject;\n withInfoButton: boolean;\n removePadding?: boolean; // TODO: This prop should be remove when EditRecord will be moved to app-studio or data-studio deleted\n}\n\nconst sidebarWidth = '352px';\n\nconst Container = styled.div<{$shouldUseLayoutWithSidebar: boolean; style: CSSObject}>`\n display: grid;\n grid-template-columns: ${props => (props.$shouldUseLayoutWithSidebar ? `minmax(0, auto) ${sidebarWidth}` : '1fr')};\n grid-template-areas: ${props => (props.$shouldUseLayoutWithSidebar ? '\"content sidebar\"' : '\"content\"')};\n overflow: hidden;\n`;\n\nconst Content = styled.div<{$shouldUseLayoutWithSidebar: boolean; $removePadding: boolean}>`\n grid-area: content;\n padding: ${props => (props.$removePadding ? 'unset' : '24px')};\n overflow-x: hidden;\n overflow-y: scroll;\n border-right: ${props =>\n props.$shouldUseLayoutWithSidebar ? '1px solid var(--general-utilities-border)' : 'none'};\n`;\n\nexport const EditRecord: FunctionComponent<IEditRecordProps> = ({\n antdForm,\n formId,\n isFormCreationMode,\n formElementId,\n record,\n library: libraryId,\n onCreate,\n valuesVersion,\n enableSidebar = false,\n showSidebar = false,\n sidebarContainer,\n containerStyle,\n withInfoButton,\n removePadding = false,\n}) => {\n const [state, dispatch] = useReducer(editRecordReducer, {\n ...initialState,\n record,\n libraryId,\n libraryLabel: null,\n valuesVersion,\n originValuesVersion: valuesVersion,\n withInfoButton,\n });\n\n const {\n loading: permissionsLoading,\n canEdit,\n isReadOnly,\n } = useCanEditRecord({...record?.library, id: libraryId}, record?.id);\n\n const {data: libraryData} = useQuery(getLibraryByIdQuery, {\n variables: {id: [libraryId]},\n });\n\n const {saveValues} = useSaveValueBatchMutation();\n const {deleteValue} = useExecuteDeleteValueMutation(record);\n const [activateNewRecordMutation] = useActivateNewRecordMutation();\n\n // Update record in reducer when it changes. Might happen on record identity change (after value save)\n useEffect(() => {\n if (libraryData) {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_LIBRARY_LABEL,\n label: libraryData.libraries.list[0].label,\n });\n }\n }, [libraryData]);\n\n useEffect(() => {\n if (record && !isEqual(record, state.record)) {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_RECORD,\n record,\n });\n }\n }, [record]);\n\n useEffect(() => {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_ENABLE_SIDEBAR,\n enabled: enableSidebar,\n });\n }, [enableSidebar]);\n\n useEffect(() => {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_SIDEBAR_IS_OPEN,\n isOpen: showSidebar,\n });\n }, [showSidebar]);\n\n const _handleValueSubmit: SubmitValueFunc = async (values, version) =>\n saveValues(\n record,\n values.map(val => {\n const savableValue = {...val, attribute: val.attribute.id, metadata: val.metadata};\n\n if (val.value) {\n switch (val.attribute.type) {\n case AttributeType.advanced_link:\n case AttributeType.simple_link:\n savableValue.value = (val as ISubmittedValueLink).value.id;\n break;\n case AttributeType.tree:\n savableValue.value = (val as ISubmittedValueTree).value.id;\n break;\n default:\n savableValue.value = (val as ISubmittedValueStandard).value;\n break;\n }\n }\n\n return savableValue as IValueToSubmit;\n }),\n version,\n true, // deleteEmpty\n );\n\n const _handleMetadataSubmit: MetadataSubmitValueFunc = (value, attribute, metadata) => {\n let valueContent;\n switch (attribute.type) {\n case AttributeType.simple:\n case AttributeType.advanced:\n valueContent = (value as IRecordPropertyStandard).raw_payload;\n break;\n case AttributeType.advanced_link:\n case AttributeType.simple_link:\n valueContent = (value as IRecordPropertyLink).linkValue;\n break;\n case AttributeType.tree:\n valueContent = (value as IRecordPropertyTree).treeValue;\n break;\n }\n\n return _handleValueSubmit(\n [\n {\n idValue: value.id_value,\n attribute,\n value: valueContent,\n metadata,\n },\n ],\n null,\n );\n };\n\n /**\n * Submit the whole record: create record and batch save all stored values\n */\n const _handleRecordSubmit = async (attributes: RecordFormAttributeStandardAttributeFragment[]) => {\n const activateNewRecordResult = await activateNewRecordMutation({\n fetchPolicy: 'network-only',\n variables: {\n libraryId,\n recordId: record.id,\n formId,\n },\n });\n const errors = activateNewRecordResult?.data?.activateNewRecord.valuesErrors;\n if (errors == null || errors?.length === 0) {\n if (onCreate) {\n onCreate(activateNewRecordResult?.data?.activateNewRecord?.record?.whoAmI);\n }\n return;\n }\n antdForm.setFields(\n errors.map(error => {\n const attributeInError = attributes.find(attribute => attribute.id === error.attribute);\n\n const doesAttributeHaveMultipleFields =\n attributeInError?.multiple_values &&\n ![AttributeType.simple_link, AttributeType.advanced_link].includes(attributeInError.type);\n\n return {\n name:\n doesAttributeHaveMultipleFields && error.type === 'REQUIRED_ATTRIBUTE'\n ? [error.attribute, 0]\n : error.attribute,\n errors: [error.message],\n };\n }),\n );\n };\n\n const _handleDeleteAllValues: DeleteMultipleValuesFunc = async (attribute, values, version) => {\n const valuesToSave = values.map(value => ({\n idValue: value.id_value,\n attribute,\n value: null,\n }));\n\n return saveValues(record, valuesToSave, version, true);\n };\n\n const shouldUseLayoutWithSidebar = state.enableSidebar && state.isOpenSidebar && sidebarContainer === undefined;\n\n return (\n <ErrorBoundary>\n <EditRecordReducerContext.Provider value={{state, dispatch}}>\n <Container $shouldUseLayoutWithSidebar={shouldUseLayoutWithSidebar} style={containerStyle}>\n <EditRecordButtons />\n <Content\n className=\"edit-record-content-container\"\n $shouldUseLayoutWithSidebar={shouldUseLayoutWithSidebar}\n $removePadding={removePadding}\n >\n {permissionsLoading ? (\n <EditRecordSkeleton rows={5} />\n ) : canEdit ? (\n <EditRecordContent\n antdForm={antdForm}\n formId={formId}\n isFormCreationMode={isFormCreationMode}\n formElementId={formElementId}\n record={record}\n library={libraryId}\n onRecordSubmit={_handleRecordSubmit}\n onValueSubmit={_handleValueSubmit}\n onValueDelete={deleteValue}\n onDeleteMultipleValues={_handleDeleteAllValues}\n readonly={isReadOnly}\n />\n ) : (\n <ErrorDisplay type={ErrorDisplayTypes.PERMISSION_ERROR} showActionButton={false} />\n )}\n </Content>\n <EditRecordSidebar onMetadataSubmit={_handleMetadataSubmit} sidebarContainer={sidebarContainer} />\n </Container>\n </EditRecordReducerContext.Provider>\n </ErrorBoundary>\n );\n};\n"]}
1
+ {"version":3,"file":"EditRecord.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecord/EditRecord.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAyB,SAAS,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AACpE,OAAO,MAAwB,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EACH,aAAa,EAGb,4BAA4B,GAC/B,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,6BAA6B,MAAM,0DAA0D,CAA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AAC,aAAa,cACV,KAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAC,KAAK,EAAE,QAAQ,EAAC,YACvD,MAAC,SAAS,mCAA8B,0BAA0B,EAAE,KAAK,EAAE,cAAc,aACrF,KAAC,iBAAiB,KAAG,EACrB,KAAC,OAAO,IACJ,SAAS,EAAC,+BAA+B,iCACZ,0BAA0B,oBACvC,aAAa,YAE5B,kBAAkB,CAAC,CAAC,CAAC,CAClB,KAAC,kBAAkB,IAAC,IAAI,EAAE,CAAC,GAAI,CAClC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CACV,KAAC,iBAAiB,IACd,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,SAAS,EAClB,cAAc,EAAE,mBAAmB,EACnC,aAAa,EAAE,kBAAkB,EACjC,aAAa,EAAE,WAAW,EAC1B,sBAAsB,EAAE,sBAAsB,EAC9C,QAAQ,EAAE,UAAU,GACtB,CACL,CAAC,CAAC,CAAC,CACA,KAAC,YAAY,IAAC,IAAI,EAAE,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,GAAI,CACtF,GACK,EACT,CAAC,8BAA8B,IAAI,CAChC,KAAC,iBAAiB,IACd,gBAAgB,EAAE,qBAAqB,EACvC,gBAAgB,EAAE,gBAAgB,GACpC,CACL,IACO,GACoB,GACxB,CACnB,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 isEqual from 'lodash/isEqual';\nimport {type FunctionComponent, useEffect, useReducer} from 'react';\nimport styled, {type CSSObject} from 'styled-components';\nimport {ErrorDisplayTypes} from '../../../constants';\nimport {useCanEditRecord} from '../../../hooks/useCanEditRecord';\nimport {type IValueVersion} from '../../../types/values';\nimport {\n AttributeType,\n type RecordFormAttributeStandardAttributeFragment,\n type RecordIdentityFragment,\n useActivateNewRecordMutation,\n} from '../../../_gqlTypes';\nimport {\n type IRecordPropertyLink,\n type IRecordPropertyStandard,\n type IRecordPropertyTree,\n} from '../../../_queries/records/getRecordPropertiesQuery';\nimport {ErrorBoundary} from '../../ErrorBoundary';\nimport {ErrorDisplay} from '../../ErrorDisplay';\nimport EditRecordContent from '../EditRecordContent';\nimport useExecuteDeleteValueMutation from '../EditRecordContent/hooks/useExecuteDeleteValueMutation';\nimport useSaveValueBatchMutation from '../EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {\n type DeleteMultipleValuesFunc,\n type ISubmittedValueLink,\n type ISubmittedValueStandard,\n type ISubmittedValueTree,\n type IValueToSubmit,\n type MetadataSubmitValueFunc,\n type SubmitValueFunc,\n} from '../EditRecordContent/_types';\nimport editRecordReducer, {EditRecordReducerActionsTypes, initialState} from '../editRecordReducer/editRecordReducer';\nimport {EditRecordReducerContext} from '../editRecordReducer/editRecordReducerContext';\nimport {type FormInstance} from 'antd/lib/form/Form';\nimport EditRecordSidebar from '../EditRecordSidebar';\nimport EditRecordSkeleton from '../EditRecordSkeleton';\nimport {useQuery} from '@apollo/client';\nimport {getLibraryByIdQuery} from '_ui/_queries/libraries/getLibraryByIdQuery';\nimport EditRecordButtons from '../EditRecordButtons';\n\ninterface IEditRecordProps {\n antdForm: FormInstance;\n formId: string;\n isFormCreationMode: boolean;\n formElementId?: string;\n record: RecordIdentityFragment['whoAmI'] | null;\n library: string;\n onCreate?: (newRecord: RecordIdentityFragment['whoAmI']) => void;\n valuesVersion?: IValueVersion;\n showSidebar?: boolean; // TODO: Should be removed when sidebar is fully removed from EditRecord\n enableSidebar?: boolean; // TODO: Should be removed when sidebar is fully removed from EditRecord\n sidebarContainer?: HTMLElement; // TODO: Should be removed when sidebar is fully removed from EditRecord\n forceDisableSidebarInAppStudio?: boolean; // TODO: Should be removed when sidebar is fully removed from EditRecord\n containerStyle?: CSSObject;\n withInfoButton: boolean;\n removePadding?: boolean; // TODO: This prop should be remove when EditRecord will be moved to app-studio or data-studio deleted\n}\n\nconst sidebarWidth = '352px';\n\nconst Container = styled.div<{$shouldUseLayoutWithSidebar: boolean; style: CSSObject}>`\n display: grid;\n grid-template-columns: ${props => (props.$shouldUseLayoutWithSidebar ? `minmax(0, auto) ${sidebarWidth}` : '1fr')};\n grid-template-areas: ${props => (props.$shouldUseLayoutWithSidebar ? '\"content sidebar\"' : '\"content\"')};\n overflow: hidden;\n`;\n\nconst Content = styled.div<{$shouldUseLayoutWithSidebar: boolean; $removePadding: boolean}>`\n grid-area: content;\n padding: ${props => (props.$removePadding ? 'unset' : '24px')};\n overflow-x: hidden;\n overflow-y: scroll;\n border-right: ${props =>\n props.$shouldUseLayoutWithSidebar ? '1px solid var(--general-utilities-border)' : 'none'};\n`;\n\nexport const EditRecord: FunctionComponent<IEditRecordProps> = ({\n antdForm,\n formId,\n isFormCreationMode,\n formElementId,\n record,\n library: libraryId,\n onCreate,\n valuesVersion,\n enableSidebar = false,\n showSidebar = false,\n sidebarContainer,\n forceDisableSidebarInAppStudio = false,\n containerStyle,\n withInfoButton,\n removePadding = false,\n}) => {\n const [state, dispatch] = useReducer(editRecordReducer, {\n ...initialState,\n record,\n libraryId,\n libraryLabel: null,\n valuesVersion,\n originValuesVersion: valuesVersion,\n withInfoButton,\n });\n\n const {\n loading: permissionsLoading,\n canEdit,\n isReadOnly,\n } = useCanEditRecord({...record?.library, id: libraryId}, record?.id);\n\n const {data: libraryData} = useQuery(getLibraryByIdQuery, {\n variables: {id: [libraryId]},\n });\n\n const {saveValues} = useSaveValueBatchMutation();\n const {deleteValue} = useExecuteDeleteValueMutation(record);\n const [activateNewRecordMutation] = useActivateNewRecordMutation();\n\n // Update record in reducer when it changes. Might happen on record identity change (after value save)\n useEffect(() => {\n if (libraryData) {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_LIBRARY_LABEL,\n label: libraryData.libraries.list[0].label,\n });\n }\n }, [libraryData]);\n\n useEffect(() => {\n if (record && !isEqual(record, state.record)) {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_RECORD,\n record,\n });\n }\n }, [record]);\n\n useEffect(() => {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_ENABLE_SIDEBAR,\n enabled: enableSidebar,\n });\n }, [enableSidebar]);\n\n useEffect(() => {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_SIDEBAR_IS_OPEN,\n isOpen: showSidebar,\n });\n }, [showSidebar]);\n\n const _handleValueSubmit: SubmitValueFunc = async (values, version) =>\n saveValues(\n record,\n values.map(val => {\n const savableValue = {...val, attribute: val.attribute.id, metadata: val.metadata};\n\n if (val.value) {\n switch (val.attribute.type) {\n case AttributeType.advanced_link:\n case AttributeType.simple_link:\n savableValue.value = (val as ISubmittedValueLink).value.id;\n break;\n case AttributeType.tree:\n savableValue.value = (val as ISubmittedValueTree).value.id;\n break;\n default:\n savableValue.value = (val as ISubmittedValueStandard).value;\n break;\n }\n }\n\n return savableValue as IValueToSubmit;\n }),\n version,\n true, // deleteEmpty\n );\n\n const _handleMetadataSubmit: MetadataSubmitValueFunc = (value, attribute, metadata) => {\n let valueContent;\n switch (attribute.type) {\n case AttributeType.simple:\n case AttributeType.advanced:\n valueContent = (value as IRecordPropertyStandard).raw_payload;\n break;\n case AttributeType.advanced_link:\n case AttributeType.simple_link:\n valueContent = (value as IRecordPropertyLink).linkValue;\n break;\n case AttributeType.tree:\n valueContent = (value as IRecordPropertyTree).treeValue;\n break;\n }\n\n return _handleValueSubmit(\n [\n {\n idValue: value.id_value,\n attribute,\n value: valueContent,\n metadata,\n },\n ],\n null,\n );\n };\n\n /**\n * Submit the whole record: create record and batch save all stored values\n */\n const _handleRecordSubmit = async (attributes: RecordFormAttributeStandardAttributeFragment[]) => {\n const activateNewRecordResult = await activateNewRecordMutation({\n fetchPolicy: 'network-only',\n variables: {\n libraryId,\n recordId: record.id,\n formId,\n },\n });\n const errors = activateNewRecordResult?.data?.activateNewRecord.valuesErrors;\n if (errors == null || errors?.length === 0) {\n if (onCreate) {\n onCreate(activateNewRecordResult?.data?.activateNewRecord?.record?.whoAmI);\n }\n return;\n }\n antdForm.setFields(\n errors.map(error => {\n const attributeInError = attributes.find(attribute => attribute.id === error.attribute);\n\n const doesAttributeHaveMultipleFields =\n attributeInError?.multiple_values &&\n ![AttributeType.simple_link, AttributeType.advanced_link].includes(attributeInError.type);\n\n return {\n name:\n doesAttributeHaveMultipleFields && error.type === 'REQUIRED_ATTRIBUTE'\n ? [error.attribute, 0]\n : error.attribute,\n errors: [error.message],\n };\n }),\n );\n };\n\n const _handleDeleteAllValues: DeleteMultipleValuesFunc = async (attribute, values, version) => {\n const valuesToSave = values.map(value => ({\n idValue: value.id_value,\n attribute,\n value: null,\n }));\n\n return saveValues(record, valuesToSave, version, true);\n };\n\n const shouldUseLayoutWithSidebar =\n state.enableSidebar && state.isOpenSidebar && sidebarContainer === undefined && !forceDisableSidebarInAppStudio;\n\n return (\n <ErrorBoundary>\n <EditRecordReducerContext.Provider value={{state, dispatch}}>\n <Container $shouldUseLayoutWithSidebar={shouldUseLayoutWithSidebar} style={containerStyle}>\n <EditRecordButtons />\n <Content\n className=\"edit-record-content-container\"\n $shouldUseLayoutWithSidebar={shouldUseLayoutWithSidebar}\n $removePadding={removePadding}\n >\n {permissionsLoading ? (\n <EditRecordSkeleton rows={5} />\n ) : canEdit ? (\n <EditRecordContent\n antdForm={antdForm}\n formId={formId}\n isFormCreationMode={isFormCreationMode}\n formElementId={formElementId}\n record={record}\n library={libraryId}\n onRecordSubmit={_handleRecordSubmit}\n onValueSubmit={_handleValueSubmit}\n onValueDelete={deleteValue}\n onDeleteMultipleValues={_handleDeleteAllValues}\n readonly={isReadOnly}\n />\n ) : (\n <ErrorDisplay type={ErrorDisplayTypes.PERMISSION_ERROR} showActionButton={false} />\n )}\n </Content>\n {!forceDisableSidebarInAppStudio && (\n <EditRecordSidebar\n onMetadataSubmit={_handleMetadataSubmit}\n sidebarContainer={sidebarContainer}\n />\n )}\n </Container>\n </EditRecordReducerContext.Provider>\n </ErrorBoundary>\n );\n};\n"]}