@leav/ui 1.9.0-ce48a072 → 1.9.0-e09e8fd5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_gqlTypes/index.d.ts +103 -20
- package/dist/_gqlTypes/index.js +46 -11
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/records/createRecordMutation.js +2 -2
- package/dist/_queries/records/createRecordMutation.js.map +1 -1
- package/dist/components/Explorer/Explorer.js +21 -11
- package/dist/components/Explorer/Explorer.js.map +1 -1
- package/dist/components/Explorer/ExplorerToolbar.js +2 -1
- package/dist/components/Explorer/ExplorerToolbar.js.map +1 -1
- package/dist/components/Explorer/_queries/useExplorerCountData.d.ts +16 -0
- package/dist/components/Explorer/_queries/useExplorerCountData.js +26 -0
- package/dist/components/Explorer/_queries/useExplorerCountData.js.map +1 -0
- package/dist/components/Explorer/actions-mass/ResultsCount.d.ts +10 -0
- package/dist/components/Explorer/actions-mass/ResultsCount.js +8 -0
- package/dist/components/Explorer/actions-mass/ResultsCount.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +9 -2
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +18 -4
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useMassActions.d.ts +5 -3
- package/dist/components/Explorer/actions-mass/useMassActions.js +19 -13
- package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.d.ts +3 -1
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js +5 -1
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/_types.d.ts +4 -0
- package/dist/components/RecordEdition/EditRecordContent/_types.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +27 -16
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.js +28 -16
- package/dist/components/RecordEdition/EditRecordPage/EditRecordPage.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordPage/ErrorComponent.d.ts +2 -0
- package/dist/components/RecordEdition/EditRecordPage/ErrorComponent.js +11 -0
- package/dist/components/RecordEdition/EditRecordPage/ErrorComponent.js.map +1 -0
- package/dist/components/RecordEdition/EditRecordPage/getInitialRecordValues.d.ts +2 -0
- package/dist/components/RecordEdition/EditRecordPage/getInitialRecordValues.js +35 -0
- package/dist/components/RecordEdition/EditRecordPage/getInitialRecordValues.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/types.d.ts +5 -0
- package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
- package/dist/locales/en/shared.json +2 -2
- package/dist/locales/fr/shared.json +2 -2
- package/package.json +3 -3
|
@@ -5,8 +5,8 @@ import { gql } from '@apollo/client';
|
|
|
5
5
|
import { recordIdentityFragment } from '../../gqlFragments';
|
|
6
6
|
const createRecordMutation = gql `
|
|
7
7
|
${recordIdentityFragment}
|
|
8
|
-
mutation CREATE_RECORD($library: ID!, $data: CreateRecordDataInput) {
|
|
9
|
-
createRecord(library: $library, data: $data) {
|
|
8
|
+
mutation CREATE_RECORD($library: ID!, $skipActivate: Boolean, $data: CreateRecordDataInput) {
|
|
9
|
+
createRecord(library: $library, skipActivate: $skipActivate, data: $data) {
|
|
10
10
|
record {
|
|
11
11
|
...RecordIdentity
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRecordMutation.js","sourceRoot":"","sources":["../../../src/_queries/records/createRecordMutation.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AAEtE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAE1D,MAAM,oBAAoB,GAAG,GAAG,CAAA;MAC1B,sBAAsB;;;;;;;;;;;;;;CAc3B,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\n\nimport {gql} from '@apollo/client';\nimport {recordIdentityFragment} from '../../gqlFragments';\n\nconst createRecordMutation = gql`\n ${recordIdentityFragment}\n mutation CREATE_RECORD($library: ID!, $data: CreateRecordDataInput) {\n createRecord(library: $library, data: $data) {\n record {\n ...RecordIdentity\n }\n valuesErrors {\n type\n attribute\n input\n message\n }\n }\n }\n`;\n\nexport default createRecordMutation;\n"]}
|
|
1
|
+
{"version":3,"file":"createRecordMutation.js","sourceRoot":"","sources":["../../../src/_queries/records/createRecordMutation.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AAEtE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAE1D,MAAM,oBAAoB,GAAG,GAAG,CAAA;MAC1B,sBAAsB;;;;;;;;;;;;;;CAc3B,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\n\nimport {gql} from '@apollo/client';\nimport {recordIdentityFragment} from '../../gqlFragments';\n\nconst createRecordMutation = gql`\n ${recordIdentityFragment}\n mutation CREATE_RECORD($library: ID!, $skipActivate: Boolean, $data: CreateRecordDataInput) {\n createRecord(library: $library, skipActivate: $skipActivate, data: $data) {\n record {\n ...RecordIdentity\n }\n valuesErrors {\n type\n attribute\n input\n message\n }\n }\n }\n`;\n\nexport default createRecordMutation;\n"]}
|
|
@@ -29,6 +29,7 @@ import { useFiltersReducer } from '../../components/Filters/context/useFiltersRe
|
|
|
29
29
|
import { FiltersContext } from '../../components/Filters/context/filtersContext';
|
|
30
30
|
import { useExportMassAction } from './actions-mass/useExportMassAction';
|
|
31
31
|
import { useEditAttributeMassAction } from './actions-mass/useEditAttributeMassAction';
|
|
32
|
+
import { useExplorerCountData } from './_queries/useExplorerCountData';
|
|
32
33
|
const isNotEmpty = (union) => union.length > 0;
|
|
33
34
|
const emptyArray = [];
|
|
34
35
|
const emptyObject = {};
|
|
@@ -91,7 +92,14 @@ export const Explorer = forwardRef(({ entrypoint, itemActions = [], primaryActio
|
|
|
91
92
|
canReplaceLinkValues: canEditLinkAttributeValues,
|
|
92
93
|
columnsToDisplay: !joinLibraryContext ? view.attributesIds : [],
|
|
93
94
|
});
|
|
94
|
-
const
|
|
95
|
+
const totalCountFiltered = data?.totalCount ?? 0;
|
|
96
|
+
const { countData: totalCountLibrary, refetchCount } = useExplorerCountData({
|
|
97
|
+
entrypoint,
|
|
98
|
+
libraryId: view.libraryId,
|
|
99
|
+
defaultFilters: defaultViewSettings?.filters ?? [],
|
|
100
|
+
filters: filtersData.filters,
|
|
101
|
+
skip: viewSettingsLoading,
|
|
102
|
+
});
|
|
95
103
|
const hasNoResults = data === null || data.totalCount === 0;
|
|
96
104
|
const isAllowedFreeEntry = !(entrypoint.type === 'library' && !entrypoint.allowFreeEntry);
|
|
97
105
|
const showCreatePrimaryButton = showCreateOnNoResultOnly
|
|
@@ -106,9 +114,10 @@ export const Explorer = forwardRef(({ entrypoint, itemActions = [], primaryActio
|
|
|
106
114
|
joinLibraryContext,
|
|
107
115
|
entrypoint,
|
|
108
116
|
isMultivalue,
|
|
109
|
-
totalCount,
|
|
117
|
+
totalCount: totalCountFiltered,
|
|
110
118
|
formId: creationFormId,
|
|
111
119
|
refetch,
|
|
120
|
+
refetchCount,
|
|
112
121
|
});
|
|
113
122
|
const { linkPrimaryAction, linkModal } = useLinkPrimaryAction({
|
|
114
123
|
isEnabled: isLink,
|
|
@@ -125,19 +134,19 @@ export const Explorer = forwardRef(({ entrypoint, itemActions = [], primaryActio
|
|
|
125
134
|
const { exportMassAction, ExportModal } = useExportMassAction({
|
|
126
135
|
isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('export'),
|
|
127
136
|
store: { view, dispatch: viewSettingsDispatch },
|
|
128
|
-
totalCount,
|
|
137
|
+
totalCount: totalCountFiltered,
|
|
129
138
|
onExport: defaultCallbacks?.mass?.export,
|
|
130
139
|
});
|
|
131
140
|
const { editAttributeMassAction, editAttributeMassActionModal } = useEditAttributeMassAction({
|
|
132
141
|
isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('editAttribute'),
|
|
133
142
|
store: { view },
|
|
134
|
-
totalCount,
|
|
143
|
+
totalCount: totalCountFiltered,
|
|
135
144
|
});
|
|
136
145
|
const { deactivateMassAction } = useDeactivateMassAction({
|
|
137
146
|
isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),
|
|
138
147
|
store: { view, dispatch: viewSettingsDispatch },
|
|
139
148
|
allVisibleKeys,
|
|
140
|
-
totalCount,
|
|
149
|
+
totalCount: totalCountFiltered,
|
|
141
150
|
onDeactivate: defaultCallbacks?.mass?.deactivate,
|
|
142
151
|
refetch,
|
|
143
152
|
});
|
|
@@ -150,15 +159,16 @@ export const Explorer = forwardRef(({ entrypoint, itemActions = [], primaryActio
|
|
|
150
159
|
onDelete: defaultCallbacks?.mass?.deactivate,
|
|
151
160
|
refetch,
|
|
152
161
|
});
|
|
153
|
-
const _isSelectionDisable = disableSelection || (isLink && !isMultivalue &&
|
|
162
|
+
const _isSelectionDisable = disableSelection || (isLink && !isMultivalue && totalCountFiltered > 0);
|
|
154
163
|
const massActionSnackbarId = useMemo(() => `${SNACKBAR_MASS_ID}_${Date.now()}`, []);
|
|
155
164
|
const { setSelectedKeys, selectAllButton } = useMassActions({
|
|
156
|
-
isEnabled:
|
|
165
|
+
isEnabled: totalCountFiltered > 0 &&
|
|
157
166
|
!_isSelectionDisable &&
|
|
158
167
|
(isNotEmpty(defaultMassActions) || isNotEmpty(massActions) || !!defaultCallbacks?.item?.select),
|
|
159
168
|
store: { view, dispatch: viewSettingsDispatch },
|
|
160
169
|
filtersStore: filtersData,
|
|
161
|
-
|
|
170
|
+
totalCountFiltered,
|
|
171
|
+
totalCountLibrary,
|
|
162
172
|
allVisibleKeys,
|
|
163
173
|
massActions: [
|
|
164
174
|
exportMassAction,
|
|
@@ -179,8 +189,8 @@ export const Explorer = forwardRef(({ entrypoint, itemActions = [], primaryActio
|
|
|
179
189
|
useImperativeHandle(ref, () => ({
|
|
180
190
|
createAction: createPrimaryAction,
|
|
181
191
|
linkAction: linkPrimaryAction,
|
|
182
|
-
totalCount,
|
|
183
|
-
}), [createPrimaryAction?.disabled, linkPrimaryAction?.disabled,
|
|
192
|
+
totalCount: totalCountFiltered,
|
|
193
|
+
}), [createPrimaryAction?.disabled, linkPrimaryAction?.disabled, totalCountFiltered]);
|
|
184
194
|
return (_jsxs(_Fragment, { children: [_jsx(FiltersContext.Provider, { value: { filtersData, dispatch: filtersDispatch }, children: _jsxs(ViewSettingsContext.Provider, { value: { view, dispatch: viewSettingsDispatch }, children: [_jsxs(ExplorerPageDivStyled, { children: [showTitle && (_jsx(ExplorerHeaderDivStyled, { children: _jsx(KitTypography.Title, { level: "h3", children: !viewSettingsLoading && (_jsx(ExplorerTitle, { library: view.libraryId, title: title, entrypoint: entrypoint })) /*TODO: manage loading*/ }) })), _jsxs(ExplorerToolbar, { showFilters: showFilters, showSorts: showSorts, isMassSelectionAll: isMassSelectionAll, headless: hideTableHeader, canRemoveFilters: view?.enableConfigureView ?? false, selectAllButton: hideSelectAllAction ? null : selectAllButton, viewSettingsLoading: viewSettingsLoading, children: [view?.enableConfigureView ? viewListButton : null, showSearch ? searchInput : null, view?.enableConfigureView ? viewSettingsButton : null, hidePrimaryActions ? null : primaryButton] }), loadingData || viewSettingsLoading ? (_jsx(Loading, {})) : hasNoResults ? (_jsx(ExplorerEmptyDataStyled, { children: emptyPlaceholder || _jsx(KitEmpty, { title: t('explorer.empty-data') }) })) : (_jsx(DataView, { dataGroupedFilteredSorted: data?.records ?? emptyArray, attributesProperties: data?.attributes ?? emptyObject, attributesToDisplay: [WHO_AM_I_COLUMN, ...view.attributesIds], hideTableHeader: hideTableHeader, useSmallHeaderSize: useSmallHeaderSize, paginationProps: entrypoint.type === 'library' && !noPagination
|
|
185
195
|
? {
|
|
186
196
|
pageSizeOptions: defaultPageSizeOptions,
|
|
@@ -188,7 +198,7 @@ export const Explorer = forwardRef(({ entrypoint, itemActions = [], primaryActio
|
|
|
188
198
|
pageSize: view.pageSize,
|
|
189
199
|
setNewPageSize,
|
|
190
200
|
setNewPage,
|
|
191
|
-
totalCount,
|
|
201
|
+
totalCount: totalCountFiltered,
|
|
192
202
|
}
|
|
193
203
|
: undefined, itemActions: [...itemActions, replaceItemAction, editStatusItemAction]
|
|
194
204
|
.filter(Boolean)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Explorer.js","sourceRoot":"","sources":["../../../src/components/Explorer/Explorer.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,UAAU,EAAkB,mBAAmB,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACxE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,OAAO,EAAC,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AASpE,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM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AA0B;wCACtC,IAAI,EAAE,aAAa;qCACtB,EACD,eAAe,EAAE,eAAe,GAClC,CACL,IACmB,EACvB,oBAAoB,IAAI,YAAY,CAAC,KAAC,SAAS,KAAG,EAAE,oBAAoB,EAAE,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,EAC9F,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,4BAA4B,EAC5B,WAAW,IACe,GACT,EAC1B,KAAC,mBAAmB,IAAC,EAAE,EAAE,oBAAoB,GAAI,IAClD,CACN,CAAC;AACN,CAAC,CACJ,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 {forwardRef, type ReactNode, useImperativeHandle, useMemo} from 'react';\nimport {createPortal} from 'react-dom';\nimport {KitEmpty, KitSnackBarProvider, KitTypography} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {Loading} from '_ui/components/Loading';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {\n type DefaultViewSettings,\n type Entrypoint,\n type IItemAction,\n type IMassActions,\n type IPrimaryAction,\n} from './_types';\nimport {useExplorerData} from './_queries/useExplorerData';\nimport {DataView} from './DataView';\nimport {ExplorerTitle} from './ExplorerTitle';\nimport {ExplorerToolbar} from './ExplorerToolbar';\nimport {useEditStatusItemAction} from './actions-item/useEditStatusItemAction';\nimport {usePrimaryActionsButton} from './actions-primary/usePrimaryActions';\nimport {useCreatePrimaryAction} from './actions-primary/useCreatePrimaryAction';\nimport {useLinkPrimaryAction} from './actions-primary/useLinkPrimaryAction';\nimport {useMassActions} from './actions-mass/useMassActions';\nimport {useDeactivateMassAction} from './actions-mass/useDeactivateMassAction';\nimport {\n defaultPageSizeOptions,\n SidePanel,\n useEditSettings,\n useOpenViewSettings,\n ViewSettingsContext,\n} from './manage-view-settings';\nimport {useSearchInput} from './useSearchInput';\nimport {usePagination} from './usePagination';\nimport {useViewSettingsReducer} from './useViewSettingsReducer';\nimport {MASS_SELECTION_ALL, SNACKBAR_MASS_ID, WHO_AM_I_COLUMN} from './_constants';\nimport {useDeleteLinkValues} from './actions-mass/useDeleteLinkValues';\nimport {useReplaceItemAction} from './actions-item/useReplaceItemAction';\nimport {type JoinLibraryContextFragment} from '_ui/_gqlTypes';\nimport {useFiltersReducer} from '_ui/components/Filters/context/useFiltersReducer';\nimport {FiltersContext} from '_ui/components/Filters/context/filtersContext';\nimport {useExportMassAction} from './actions-mass/useExportMassAction';\nimport {useEditAttributeMassAction} from './actions-mass/useEditAttributeMassAction';\n\nconst isNotEmpty = <T extends unknown[]>(union: T): union is Exclude<T, []> => union.length > 0;\n\nconst emptyArray = [];\nconst emptyObject = {};\n\nconst ExplorerHeaderDivStyled = styled.div`\n display: flex;\n align-items: flex-start;\n padding: calc(var(--general-spacing-xs) * 1px);\n`;\n\nconst ExplorerPageDivStyled = styled.div`\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n`;\n\nconst ExplorerEmptyDataStyled = styled.div`\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n`;\n\nexport interface IExplorerProps {\n entrypoint: Entrypoint;\n noPagination?: true;\n itemActions?: IItemAction[];\n primaryActions?: IPrimaryAction[];\n massActions?: IMassActions[];\n title?: string;\n selectionMode?: 'multiple' | 'simple';\n emptyPlaceholder?: ReactNode;\n defaultActionsForItem?: Array<'replaceLink' | 'remove' | 'activate'>;\n defaultPrimaryActions?: Array<'create'>;\n defaultMassActions?: Array<'deactivate' | 'export' | 'editAttribute'>;\n defaultViewSettings?: DefaultViewSettings;\n defaultCallbacks?: {\n item?: {\n edit?: IItemAction['callback'];\n replaceLink?: (replaceValuesResult: ISubmitMultipleResult) => void;\n remove?: IItemAction['callback'];\n select?: IItemAction['callback'];\n };\n primary?: {\n create?: ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => void;\n link?: (saveValuesResult: ISubmitMultipleResult) => void;\n };\n mass?: {\n deactivate?: IMassActions['callback'];\n export?: IMassActions['callback'];\n };\n };\n showCreateOnNoResultOnly?: boolean;\n showFilters?: boolean;\n showSorts?: boolean;\n hideFirstActionLabel?: boolean;\n /**\n * Optional to `false` load the last added view when `props.defaultViewSettings.viewId` is `undefined`,\n * if set to `true` load default view.\n */\n ignoreViewByDefault?: boolean;\n showTitle?: boolean;\n showSearch?: boolean;\n disableSelection?: boolean;\n hideSelectAllAction?: boolean;\n hidePrimaryActions?: boolean;\n hideTableHeader?: boolean;\n useSmallHeaderSize?: boolean;\n tableBodyHeight?: string;\n creationFormId?: string;\n joinLibraryContext?: JoinLibraryContextFragment;\n}\n\nexport interface IExplorerRef {\n createAction: IPrimaryAction | null;\n linkAction: IPrimaryAction | null;\n totalCount: number;\n}\n\nexport const Explorer = forwardRef<IExplorerRef, IExplorerProps>(\n (\n {\n entrypoint,\n itemActions = [],\n primaryActions = [],\n massActions = [],\n title,\n selectionMode = 'multiple',\n emptyPlaceholder,\n noPagination,\n creationFormId,\n showCreateOnNoResultOnly = false,\n showFilters = false,\n showSorts = false,\n hideFirstActionLabel = false,\n disableSelection = false,\n hideSelectAllAction = false,\n showTitle = false,\n showSearch = false,\n hidePrimaryActions = false,\n hideTableHeader = false,\n useSmallHeaderSize = false,\n tableBodyHeight,\n ignoreViewByDefault = false,\n defaultActionsForItem = ['replaceLink', 'remove', 'activate'],\n defaultPrimaryActions = ['create'],\n defaultMassActions = ['deactivate', 'editAttribute'],\n defaultCallbacks,\n defaultViewSettings,\n joinLibraryContext,\n },\n ref,\n ) => {\n const {t} = useSharedTranslation();\n\n const {panelElement: settingsPanelElement} = useEditSettings();\n\n const {\n loading: viewSettingsLoading,\n view,\n dispatch: viewSettingsDispatch,\n } = useViewSettingsReducer(entrypoint, defaultViewSettings, ignoreViewByDefault);\n\n const {filtersData, dispatch: filtersDispatch} = useFiltersReducer({\n libraryId: view.libraryId,\n viewId: view.viewId ?? undefined,\n filters: defaultViewSettings?.filters ?? undefined,\n filtersOperator: defaultViewSettings?.filtersOperator ?? undefined,\n ignoreViewByDefault,\n skip: viewSettingsLoading,\n });\n\n const {currentPage, setNewPageSize, setNewPage} = usePagination(viewSettingsDispatch);\n\n const {\n data,\n isMultivalue,\n canEditLinkAttributeValues,\n loading: loadingData,\n refetch,\n } = useExplorerData({\n entrypoint,\n libraryId: view.libraryId,\n attributeIds: view.attributesIds,\n fulltextSearch: view.fulltextSearch,\n pagination: noPagination ? null : {limit: view.pageSize, offset: view.pageSize * (currentPage - 1)},\n sorts: view.sort,\n filters: filtersData.filters,\n filtersOperator: filtersData.filtersOperator,\n skip: viewSettingsLoading,\n }); // TODO: refresh when go back on page\n const isMassSelectionAll = view.massSelection === MASS_SELECTION_ALL;\n const isLink = entrypoint.type === 'link';\n\n const {editStatusItemAction} = useEditStatusItemAction({\n isEnabled:\n isNotEmpty(defaultActionsForItem) &&\n (defaultActionsForItem.includes('remove') || defaultActionsForItem.includes('activate')),\n onRemove: defaultCallbacks?.item?.remove,\n canDeleteLinkValues: canEditLinkAttributeValues,\n store: {view, dispatch: viewSettingsDispatch},\n entrypoint,\n });\n\n const {replaceItemAction, replaceItemModal} = useReplaceItemAction({\n isEnabled: isLink && isNotEmpty(defaultActionsForItem) && defaultActionsForItem.includes('replaceLink'),\n isMultivalue,\n onReplace: defaultCallbacks?.item?.replaceLink,\n canReplaceLinkValues: canEditLinkAttributeValues,\n columnsToDisplay: !joinLibraryContext ? view.attributesIds : [],\n });\n\n const totalCount = data?.totalCount ?? 0;\n\n const hasNoResults = data === null || data.totalCount === 0;\n\n const isAllowedFreeEntry = !(entrypoint.type === 'library' && !entrypoint.allowFreeEntry);\n\n const showCreatePrimaryButton = showCreateOnNoResultOnly\n ? !hidePrimaryActions && !loadingData && hasNoResults && isAllowedFreeEntry\n : true;\n\n const {createPrimaryAction, createModal} = useCreatePrimaryAction({\n isEnabled: isNotEmpty(defaultPrimaryActions) && defaultPrimaryActions.includes('create'),\n isVisible: showCreatePrimaryButton,\n libraryId: view.libraryId,\n canCreateAndLinkValue: canEditLinkAttributeValues,\n onCreate: defaultCallbacks?.primary?.create,\n joinLibraryContext,\n entrypoint,\n isMultivalue,\n totalCount,\n formId: creationFormId,\n refetch,\n });\n const {linkPrimaryAction, linkModal} = useLinkPrimaryAction({\n isEnabled: isLink,\n joinLibraryContext,\n isVisible: showCreatePrimaryButton,\n canAddLinkValue: canEditLinkAttributeValues,\n onLink: defaultCallbacks?.primary?.link,\n linkId: data?.totalCount === 0 ? undefined : data?.records[0]?.id_value,\n isMultivalue,\n maxItemsLeft: null, // TODO: use KitTable.row,\n columnsToDisplay: !joinLibraryContext ? view.attributesIds : [],\n });\n\n const allVisibleKeys = data?.records.map(({key}) => key) ?? [];\n\n const {exportMassAction, ExportModal} = useExportMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('export'),\n store: {view, dispatch: viewSettingsDispatch},\n totalCount,\n onExport: defaultCallbacks?.mass?.export,\n });\n\n const {editAttributeMassAction, editAttributeMassActionModal} = useEditAttributeMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('editAttribute'),\n store: {view},\n totalCount,\n });\n\n const {deactivateMassAction} = useDeactivateMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),\n store: {view, dispatch: viewSettingsDispatch},\n allVisibleKeys,\n totalCount,\n onDeactivate: defaultCallbacks?.mass?.deactivate,\n refetch,\n });\n\n const {unlinkMassAction} = useDeleteLinkValues({\n isEnabled: isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),\n store: {view, dispatch: viewSettingsDispatch},\n filtersStore: filtersData,\n pagination: noPagination ? null : {limit: view.pageSize, offset: view.pageSize * (currentPage - 1)},\n allVisibleKeys,\n onDelete: defaultCallbacks?.mass?.deactivate,\n refetch,\n });\n\n const _isSelectionDisable = disableSelection || (isLink && !isMultivalue && totalCount > 0);\n\n const massActionSnackbarId = useMemo(() => `${SNACKBAR_MASS_ID}_${Date.now()}`, []);\n\n const {setSelectedKeys, selectAllButton} = useMassActions({\n isEnabled:\n totalCount > 0 &&\n !_isSelectionDisable &&\n (isNotEmpty(defaultMassActions) || isNotEmpty(massActions) || !!defaultCallbacks?.item?.select),\n store: {view, dispatch: viewSettingsDispatch},\n filtersStore: filtersData,\n totalCount,\n allVisibleKeys,\n massActions: [\n exportMassAction,\n editAttributeMassAction,\n deactivateMassAction,\n unlinkMassAction,\n ...massActions,\n ].filter(Boolean),\n snackbarId: massActionSnackbarId,\n });\n\n const {primaryButton} = usePrimaryActionsButton({\n view,\n actions: [createPrimaryAction, linkPrimaryAction, ...primaryActions].filter(Boolean),\n hideFirstActionLabel,\n });\n\n const {viewSettingsButton, viewListButton} = useOpenViewSettings({view, isEnabled: !isMassSelectionAll});\n\n const {searchInput} = useSearchInput({view, dispatch: viewSettingsDispatch, setNewPage});\n\n useImperativeHandle(\n ref,\n () => ({\n createAction: createPrimaryAction,\n linkAction: linkPrimaryAction,\n totalCount,\n }),\n [createPrimaryAction?.disabled, linkPrimaryAction?.disabled, totalCount],\n );\n\n return (\n <>\n <FiltersContext.Provider value={{filtersData, dispatch: filtersDispatch}}>\n <ViewSettingsContext.Provider value={{view, dispatch: viewSettingsDispatch}}>\n <ExplorerPageDivStyled>\n {showTitle && (\n <ExplorerHeaderDivStyled>\n <KitTypography.Title level=\"h3\">\n {\n !viewSettingsLoading && (\n <ExplorerTitle\n library={view.libraryId}\n title={title}\n entrypoint={entrypoint}\n />\n ) /*TODO: manage loading*/\n }\n </KitTypography.Title>\n </ExplorerHeaderDivStyled>\n )}\n <ExplorerToolbar\n showFilters={showFilters}\n showSorts={showSorts}\n isMassSelectionAll={isMassSelectionAll}\n headless={hideTableHeader}\n canRemoveFilters={view?.enableConfigureView ?? false}\n selectAllButton={hideSelectAllAction ? null : selectAllButton}\n viewSettingsLoading={viewSettingsLoading}\n >\n {view?.enableConfigureView ? viewListButton : null}\n {showSearch ? searchInput : null}\n {view?.enableConfigureView ? viewSettingsButton : null}\n {hidePrimaryActions ? null : primaryButton}\n </ExplorerToolbar>\n {loadingData || viewSettingsLoading ? (\n <Loading />\n ) : hasNoResults ? (\n <ExplorerEmptyDataStyled>\n {emptyPlaceholder || <KitEmpty title={t('explorer.empty-data')} />}\n </ExplorerEmptyDataStyled>\n ) : (\n <DataView\n dataGroupedFilteredSorted={data?.records ?? emptyArray}\n attributesProperties={data?.attributes ?? emptyObject}\n attributesToDisplay={[WHO_AM_I_COLUMN, ...view.attributesIds]}\n hideTableHeader={hideTableHeader}\n useSmallHeaderSize={useSmallHeaderSize}\n paginationProps={\n entrypoint.type === 'library' && !noPagination\n ? {\n pageSizeOptions: defaultPageSizeOptions,\n currentPage,\n pageSize: view.pageSize,\n setNewPageSize,\n setNewPage,\n totalCount,\n }\n : undefined\n }\n itemActions={[...itemActions, replaceItemAction, editStatusItemAction]\n .filter(Boolean)\n .map(action => ({\n ...action,\n disabled: isMassSelectionAll || action.disabled,\n }))}\n selection={{\n onSelectItem: _isSelectionDisable ? null : defaultCallbacks?.item?.select,\n onSelectionChange: _isSelectionDisable ? null : setSelectedKeys,\n isMassSelectionAll,\n selectedKeys: isMassSelectionAll\n ? data?.records.map(({whoAmI}) => whoAmI.id)\n : (view.massSelection as string[]),\n mode: selectionMode,\n }}\n tableBodyHeight={tableBodyHeight}\n />\n )}\n </ExplorerPageDivStyled>\n {settingsPanelElement && createPortal(<SidePanel />, settingsPanelElement?.() ?? document.body)}\n {replaceItemModal}\n {createModal}\n {linkModal}\n {editAttributeMassActionModal}\n {ExportModal}\n </ViewSettingsContext.Provider>\n </FiltersContext.Provider>\n <KitSnackBarProvider id={massActionSnackbarId} />\n </>\n );\n },\n);\n"]}
|
|
1
|
+
{"version":3,"file":"Explorer.js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e,GACT,EAC1B,KAAC,mBAAmB,IAAC,EAAE,EAAE,oBAAoB,GAAI,IAClD,CACN,CAAC;AACN,CAAC,CACJ,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 {forwardRef, type ReactNode, useImperativeHandle, useMemo} from 'react';\nimport {createPortal} from 'react-dom';\nimport {KitEmpty, KitSnackBarProvider, KitTypography} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {Loading} from '_ui/components/Loading';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {\n type DefaultViewSettings,\n type Entrypoint,\n type IItemAction,\n type IMassActions,\n type IPrimaryAction,\n} from './_types';\nimport {useExplorerData} from './_queries/useExplorerData';\nimport {DataView} from './DataView';\nimport {ExplorerTitle} from './ExplorerTitle';\nimport {ExplorerToolbar} from './ExplorerToolbar';\nimport {useEditStatusItemAction} from './actions-item/useEditStatusItemAction';\nimport {usePrimaryActionsButton} from './actions-primary/usePrimaryActions';\nimport {useCreatePrimaryAction} from './actions-primary/useCreatePrimaryAction';\nimport {useLinkPrimaryAction} from './actions-primary/useLinkPrimaryAction';\nimport {useMassActions} from './actions-mass/useMassActions';\nimport {useDeactivateMassAction} from './actions-mass/useDeactivateMassAction';\nimport {\n defaultPageSizeOptions,\n SidePanel,\n useEditSettings,\n useOpenViewSettings,\n ViewSettingsContext,\n} from './manage-view-settings';\nimport {useSearchInput} from './useSearchInput';\nimport {usePagination} from './usePagination';\nimport {useViewSettingsReducer} from './useViewSettingsReducer';\nimport {MASS_SELECTION_ALL, SNACKBAR_MASS_ID, WHO_AM_I_COLUMN} from './_constants';\nimport {useDeleteLinkValues} from './actions-mass/useDeleteLinkValues';\nimport {useReplaceItemAction} from './actions-item/useReplaceItemAction';\nimport {type JoinLibraryContextFragment} from '_ui/_gqlTypes';\nimport {useFiltersReducer} from '_ui/components/Filters/context/useFiltersReducer';\nimport {FiltersContext} from '_ui/components/Filters/context/filtersContext';\nimport {useExportMassAction} from './actions-mass/useExportMassAction';\nimport {useEditAttributeMassAction} from './actions-mass/useEditAttributeMassAction';\nimport {useExplorerCountData} from './_queries/useExplorerCountData';\n\nconst isNotEmpty = <T extends unknown[]>(union: T): union is Exclude<T, []> => union.length > 0;\n\nconst emptyArray = [];\nconst emptyObject = {};\n\nconst ExplorerHeaderDivStyled = styled.div`\n display: flex;\n align-items: flex-start;\n padding: calc(var(--general-spacing-xs) * 1px);\n`;\n\nconst ExplorerPageDivStyled = styled.div`\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n`;\n\nconst ExplorerEmptyDataStyled = styled.div`\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n`;\n\nexport interface IExplorerProps {\n entrypoint: Entrypoint;\n noPagination?: true;\n itemActions?: IItemAction[];\n primaryActions?: IPrimaryAction[];\n massActions?: IMassActions[];\n title?: string;\n selectionMode?: 'multiple' | 'simple';\n emptyPlaceholder?: ReactNode;\n defaultActionsForItem?: Array<'replaceLink' | 'remove' | 'activate'>;\n defaultPrimaryActions?: Array<'create'>;\n defaultMassActions?: Array<'deactivate' | 'export' | 'editAttribute'>;\n defaultViewSettings?: DefaultViewSettings;\n defaultCallbacks?: {\n item?: {\n edit?: IItemAction['callback'];\n replaceLink?: (replaceValuesResult: ISubmitMultipleResult) => void;\n remove?: IItemAction['callback'];\n select?: IItemAction['callback'];\n };\n primary?: {\n create?: ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => void;\n link?: (saveValuesResult: ISubmitMultipleResult) => void;\n };\n mass?: {\n deactivate?: IMassActions['callback'];\n export?: IMassActions['callback'];\n };\n };\n showCreateOnNoResultOnly?: boolean;\n showFilters?: boolean;\n showSorts?: boolean;\n hideFirstActionLabel?: boolean;\n /**\n * Optional to `false` load the last added view when `props.defaultViewSettings.viewId` is `undefined`,\n * if set to `true` load default view.\n */\n ignoreViewByDefault?: boolean;\n showTitle?: boolean;\n showSearch?: boolean;\n disableSelection?: boolean;\n hideSelectAllAction?: boolean;\n hidePrimaryActions?: boolean;\n hideTableHeader?: boolean;\n useSmallHeaderSize?: boolean;\n tableBodyHeight?: string;\n creationFormId?: string;\n joinLibraryContext?: JoinLibraryContextFragment;\n}\n\nexport interface IExplorerRef {\n createAction: IPrimaryAction | null;\n linkAction: IPrimaryAction | null;\n totalCount: number;\n}\n\nexport const Explorer = forwardRef<IExplorerRef, IExplorerProps>(\n (\n {\n entrypoint,\n itemActions = [],\n primaryActions = [],\n massActions = [],\n title,\n selectionMode = 'multiple',\n emptyPlaceholder,\n noPagination,\n creationFormId,\n showCreateOnNoResultOnly = false,\n showFilters = false,\n showSorts = false,\n hideFirstActionLabel = false,\n disableSelection = false,\n hideSelectAllAction = false,\n showTitle = false,\n showSearch = false,\n hidePrimaryActions = false,\n hideTableHeader = false,\n useSmallHeaderSize = false,\n tableBodyHeight,\n ignoreViewByDefault = false,\n defaultActionsForItem = ['replaceLink', 'remove', 'activate'],\n defaultPrimaryActions = ['create'],\n defaultMassActions = ['deactivate', 'editAttribute'],\n defaultCallbacks,\n defaultViewSettings,\n joinLibraryContext,\n },\n ref,\n ) => {\n const {t} = useSharedTranslation();\n\n const {panelElement: settingsPanelElement} = useEditSettings();\n\n const {\n loading: viewSettingsLoading,\n view,\n dispatch: viewSettingsDispatch,\n } = useViewSettingsReducer(entrypoint, defaultViewSettings, ignoreViewByDefault);\n\n const {filtersData, dispatch: filtersDispatch} = useFiltersReducer({\n libraryId: view.libraryId,\n viewId: view.viewId ?? undefined,\n filters: defaultViewSettings?.filters ?? undefined,\n filtersOperator: defaultViewSettings?.filtersOperator ?? undefined,\n ignoreViewByDefault,\n skip: viewSettingsLoading,\n });\n\n const {currentPage, setNewPageSize, setNewPage} = usePagination(viewSettingsDispatch);\n\n const {\n data,\n isMultivalue,\n canEditLinkAttributeValues,\n loading: loadingData,\n refetch,\n } = useExplorerData({\n entrypoint,\n libraryId: view.libraryId,\n attributeIds: view.attributesIds,\n fulltextSearch: view.fulltextSearch,\n pagination: noPagination ? null : {limit: view.pageSize, offset: view.pageSize * (currentPage - 1)},\n sorts: view.sort,\n filters: filtersData.filters,\n filtersOperator: filtersData.filtersOperator,\n skip: viewSettingsLoading,\n }); // TODO: refresh when go back on page\n const isMassSelectionAll = view.massSelection === MASS_SELECTION_ALL;\n const isLink = entrypoint.type === 'link';\n\n const {editStatusItemAction} = useEditStatusItemAction({\n isEnabled:\n isNotEmpty(defaultActionsForItem) &&\n (defaultActionsForItem.includes('remove') || defaultActionsForItem.includes('activate')),\n onRemove: defaultCallbacks?.item?.remove,\n canDeleteLinkValues: canEditLinkAttributeValues,\n store: {view, dispatch: viewSettingsDispatch},\n entrypoint,\n });\n\n const {replaceItemAction, replaceItemModal} = useReplaceItemAction({\n isEnabled: isLink && isNotEmpty(defaultActionsForItem) && defaultActionsForItem.includes('replaceLink'),\n isMultivalue,\n onReplace: defaultCallbacks?.item?.replaceLink,\n canReplaceLinkValues: canEditLinkAttributeValues,\n columnsToDisplay: !joinLibraryContext ? view.attributesIds : [],\n });\n\n const totalCountFiltered = data?.totalCount ?? 0;\n\n const {countData: totalCountLibrary, refetchCount} = useExplorerCountData({\n entrypoint,\n libraryId: view.libraryId,\n defaultFilters: defaultViewSettings?.filters ?? [],\n filters: filtersData.filters,\n skip: viewSettingsLoading,\n });\n\n const hasNoResults = data === null || data.totalCount === 0;\n\n const isAllowedFreeEntry = !(entrypoint.type === 'library' && !entrypoint.allowFreeEntry);\n\n const showCreatePrimaryButton = showCreateOnNoResultOnly\n ? !hidePrimaryActions && !loadingData && hasNoResults && isAllowedFreeEntry\n : true;\n\n const {createPrimaryAction, createModal} = useCreatePrimaryAction({\n isEnabled: isNotEmpty(defaultPrimaryActions) && defaultPrimaryActions.includes('create'),\n isVisible: showCreatePrimaryButton,\n libraryId: view.libraryId,\n canCreateAndLinkValue: canEditLinkAttributeValues,\n onCreate: defaultCallbacks?.primary?.create,\n joinLibraryContext,\n entrypoint,\n isMultivalue,\n totalCount: totalCountFiltered,\n formId: creationFormId,\n refetch,\n refetchCount,\n });\n const {linkPrimaryAction, linkModal} = useLinkPrimaryAction({\n isEnabled: isLink,\n joinLibraryContext,\n isVisible: showCreatePrimaryButton,\n canAddLinkValue: canEditLinkAttributeValues,\n onLink: defaultCallbacks?.primary?.link,\n linkId: data?.totalCount === 0 ? undefined : data?.records[0]?.id_value,\n isMultivalue,\n maxItemsLeft: null, // TODO: use KitTable.row,\n columnsToDisplay: !joinLibraryContext ? view.attributesIds : [],\n });\n\n const allVisibleKeys = data?.records.map(({key}) => key) ?? [];\n\n const {exportMassAction, ExportModal} = useExportMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('export'),\n store: {view, dispatch: viewSettingsDispatch},\n totalCount: totalCountFiltered,\n onExport: defaultCallbacks?.mass?.export,\n });\n\n const {editAttributeMassAction, editAttributeMassActionModal} = useEditAttributeMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('editAttribute'),\n store: {view},\n totalCount: totalCountFiltered,\n });\n\n const {deactivateMassAction} = useDeactivateMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),\n store: {view, dispatch: viewSettingsDispatch},\n allVisibleKeys,\n totalCount: totalCountFiltered,\n onDeactivate: defaultCallbacks?.mass?.deactivate,\n refetch,\n });\n\n const {unlinkMassAction} = useDeleteLinkValues({\n isEnabled: isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),\n store: {view, dispatch: viewSettingsDispatch},\n filtersStore: filtersData,\n pagination: noPagination ? null : {limit: view.pageSize, offset: view.pageSize * (currentPage - 1)},\n allVisibleKeys,\n onDelete: defaultCallbacks?.mass?.deactivate,\n refetch,\n });\n\n const _isSelectionDisable = disableSelection || (isLink && !isMultivalue && totalCountFiltered > 0);\n\n const massActionSnackbarId = useMemo(() => `${SNACKBAR_MASS_ID}_${Date.now()}`, []);\n\n const {setSelectedKeys, selectAllButton} = useMassActions({\n isEnabled:\n totalCountFiltered > 0 &&\n !_isSelectionDisable &&\n (isNotEmpty(defaultMassActions) || isNotEmpty(massActions) || !!defaultCallbacks?.item?.select),\n store: {view, dispatch: viewSettingsDispatch},\n filtersStore: filtersData,\n totalCountFiltered,\n totalCountLibrary,\n allVisibleKeys,\n massActions: [\n exportMassAction,\n editAttributeMassAction,\n deactivateMassAction,\n unlinkMassAction,\n ...massActions,\n ].filter(Boolean),\n snackbarId: massActionSnackbarId,\n });\n\n const {primaryButton} = usePrimaryActionsButton({\n view,\n actions: [createPrimaryAction, linkPrimaryAction, ...primaryActions].filter(Boolean),\n hideFirstActionLabel,\n });\n\n const {viewSettingsButton, viewListButton} = useOpenViewSettings({view, isEnabled: !isMassSelectionAll});\n\n const {searchInput} = useSearchInput({view, dispatch: viewSettingsDispatch, setNewPage});\n\n useImperativeHandle(\n ref,\n () => ({\n createAction: createPrimaryAction,\n linkAction: linkPrimaryAction,\n totalCount: totalCountFiltered,\n }),\n [createPrimaryAction?.disabled, linkPrimaryAction?.disabled, totalCountFiltered],\n );\n\n return (\n <>\n <FiltersContext.Provider value={{filtersData, dispatch: filtersDispatch}}>\n <ViewSettingsContext.Provider value={{view, dispatch: viewSettingsDispatch}}>\n <ExplorerPageDivStyled>\n {showTitle && (\n <ExplorerHeaderDivStyled>\n <KitTypography.Title level=\"h3\">\n {\n !viewSettingsLoading && (\n <ExplorerTitle\n library={view.libraryId}\n title={title}\n entrypoint={entrypoint}\n />\n ) /*TODO: manage loading*/\n }\n </KitTypography.Title>\n </ExplorerHeaderDivStyled>\n )}\n <ExplorerToolbar\n showFilters={showFilters}\n showSorts={showSorts}\n isMassSelectionAll={isMassSelectionAll}\n headless={hideTableHeader}\n canRemoveFilters={view?.enableConfigureView ?? false}\n selectAllButton={hideSelectAllAction ? null : selectAllButton}\n viewSettingsLoading={viewSettingsLoading}\n >\n {view?.enableConfigureView ? viewListButton : null}\n {showSearch ? searchInput : null}\n {view?.enableConfigureView ? viewSettingsButton : null}\n {hidePrimaryActions ? null : primaryButton}\n </ExplorerToolbar>\n {loadingData || viewSettingsLoading ? (\n <Loading />\n ) : hasNoResults ? (\n <ExplorerEmptyDataStyled>\n {emptyPlaceholder || <KitEmpty title={t('explorer.empty-data')} />}\n </ExplorerEmptyDataStyled>\n ) : (\n <DataView\n dataGroupedFilteredSorted={data?.records ?? emptyArray}\n attributesProperties={data?.attributes ?? emptyObject}\n attributesToDisplay={[WHO_AM_I_COLUMN, ...view.attributesIds]}\n hideTableHeader={hideTableHeader}\n useSmallHeaderSize={useSmallHeaderSize}\n paginationProps={\n entrypoint.type === 'library' && !noPagination\n ? {\n pageSizeOptions: defaultPageSizeOptions,\n currentPage,\n pageSize: view.pageSize,\n setNewPageSize,\n setNewPage,\n totalCount: totalCountFiltered,\n }\n : undefined\n }\n itemActions={[...itemActions, replaceItemAction, editStatusItemAction]\n .filter(Boolean)\n .map(action => ({\n ...action,\n disabled: isMassSelectionAll || action.disabled,\n }))}\n selection={{\n onSelectItem: _isSelectionDisable ? null : defaultCallbacks?.item?.select,\n onSelectionChange: _isSelectionDisable ? null : setSelectedKeys,\n isMassSelectionAll,\n selectedKeys: isMassSelectionAll\n ? data?.records.map(({whoAmI}) => whoAmI.id)\n : (view.massSelection as string[]),\n mode: selectionMode,\n }}\n tableBodyHeight={tableBodyHeight}\n />\n )}\n </ExplorerPageDivStyled>\n {settingsPanelElement && createPortal(<SidePanel />, settingsPanelElement?.() ?? document.body)}\n {replaceItemModal}\n {createModal}\n {linkModal}\n {editAttributeMassActionModal}\n {ExportModal}\n </ViewSettingsContext.Provider>\n </FiltersContext.Provider>\n <KitSnackBarProvider id={massActionSnackbarId} />\n </>\n );\n },\n);\n"]}
|
|
@@ -3,7 +3,8 @@ import { useSharedTranslation } from '../../hooks/useSharedTranslation';
|
|
|
3
3
|
import { ExplorerFiltersAndSorts } from './ExplorerFiltersAndSorts';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
const ExplorerToolbarListStyled = styled.ul `
|
|
6
|
-
padding: calc(var(--general-spacing-xs) * 1px)
|
|
6
|
+
padding: calc(var(--general-spacing-xs) * 1px) calc(var(--general-spacing-xs) * 1px)
|
|
7
|
+
calc(var(--general-spacing-xs) * 1px) calc(var(--general-spacing-s) * 1px);
|
|
7
8
|
margin: 0;
|
|
8
9
|
margin-bottom: calc(var(--general-spacing-s) * 1px);
|
|
9
10
|
background: var(--general-colors-neutral-grey-100);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExplorerToolbar.js","sourceRoot":"","sources":["../../../src/components/Explorer/ExplorerToolbar.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,yBAAyB,GAAG,MAAM,CAAC,EAAE,CAAA
|
|
1
|
+
{"version":3,"file":"ExplorerToolbar.js","sourceRoot":"","sources":["../../../src/components/Explorer/ExplorerToolbar.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,yBAAyB,GAAG,MAAM,CAAC,EAAE,CAAA;;;;;;;;;;;;;;;;;;;;;;;;CAwB1C,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAKzB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAQvB,CAAC,EACF,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,QAAQ,GACX,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO,CACH,MAAC,yBAAyB,kBAAa,CAAC,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,aAC/F,KAAC,OAAO,cACH,CAAC,mBAAmB,IAAI,CACrB,KAAC,uBAAuB,IACpB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,GACxC,CACL,GACK,EACV,KAAC,OAAO,cAAE,QAAQ,GAAW,IACL,CAC/B,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, type FunctionComponent} from 'react';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {ExplorerFiltersAndSorts} from './ExplorerFiltersAndSorts';\nimport styled from 'styled-components';\n\nconst ExplorerToolbarListStyled = styled.ul`\n padding: calc(var(--general-spacing-xs) * 1px) calc(var(--general-spacing-xs) * 1px)\n calc(var(--general-spacing-xs) * 1px) calc(var(--general-spacing-s) * 1px);\n margin: 0;\n margin-bottom: calc(var(--general-spacing-s) * 1px);\n background: var(--general-colors-neutral-grey-100);\n border-radius: calc(var(--general-border-radius-s) * 1px);\n list-style: none;\n display: flex;\n overflow: auto;\n align-items: center;\n gap: calc(var(--general-spacing-xxs) * 1px);\n white-space: nowrap;\n min-height: 26px; // height of the filter chip\n justify-content: space-between;\n\n &.headless {\n margin-bottom: 0;\n }\n\n & > div:last-of-type {\n flex-shrink: 0;\n align-self: start;\n }\n`;\n\nconst Section = styled.div`\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: calc(var(--general-spacing-xxs) * 1px);\n`;\n\nexport const ExplorerToolbar: FunctionComponent<{\n isMassSelectionAll: boolean;\n showFilters: boolean;\n showSorts: boolean;\n headless: boolean;\n canRemoveFilters: boolean;\n selectAllButton: ReactNode | null;\n viewSettingsLoading: boolean;\n}> = ({\n isMassSelectionAll,\n showFilters,\n showSorts,\n headless,\n canRemoveFilters,\n selectAllButton,\n viewSettingsLoading,\n children,\n}) => {\n const {t} = useSharedTranslation();\n\n return (\n <ExplorerToolbarListStyled aria-label={t('explorer.toolbar')} className={headless ? 'headless' : ''}>\n <Section>\n {!viewSettingsLoading && (\n <ExplorerFiltersAndSorts\n selectAllButton={selectAllButton}\n showFilters={showFilters}\n showSorts={showSorts}\n canRemoveFilters={canRemoveFilters}\n isMassSelectionAll={isMassSelectionAll}\n />\n )}\n </Section>\n <Section>{children}</Section>\n </ExplorerToolbarListStyled>\n );\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RecordFilterInput } from '../../../_gqlTypes';
|
|
2
|
+
import { type UIFilter } from '../../../components/Filters';
|
|
3
|
+
import { type Entrypoint } from '../_types';
|
|
4
|
+
export declare const useExplorerCountData: ({ entrypoint, libraryId, defaultFilters, filters, skip, }: {
|
|
5
|
+
entrypoint: Entrypoint;
|
|
6
|
+
libraryId: string;
|
|
7
|
+
defaultFilters: UIFilter[];
|
|
8
|
+
filters: UIFilter[];
|
|
9
|
+
skip?: boolean;
|
|
10
|
+
}) => {
|
|
11
|
+
countData: number;
|
|
12
|
+
refetchCount: (variables?: Partial<import("../../../_gqlTypes").Exact<{
|
|
13
|
+
libraryId: import("../../../_gqlTypes").Scalars["ID"]["input"];
|
|
14
|
+
filters?: import("../../../_gqlTypes").InputMaybe<Array<import("../../../_gqlTypes").InputMaybe<RecordFilterInput>> | import("../../../_gqlTypes").InputMaybe<RecordFilterInput>>;
|
|
15
|
+
}>>) => Promise<import("@apollo/client").ApolloQueryResult<import("../../../_gqlTypes").ExplorerLibraryCountDataQuery>>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { useExplorerLibraryCountDataQuery } from '../../../_gqlTypes';
|
|
5
|
+
import { prepareFiltersForRequest } from '../../../components/Filters';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
export const useExplorerCountData = ({ entrypoint, libraryId, defaultFilters, filters, skip, }) => {
|
|
8
|
+
const isLibrary = entrypoint.type === 'library';
|
|
9
|
+
const activeFilters = prepareFiltersForRequest(filters.filter(f => f.field === 'active'));
|
|
10
|
+
const defaultPreparedFilters = prepareFiltersForRequest(defaultFilters);
|
|
11
|
+
const appliedFilters = [...activeFilters, ...defaultPreparedFilters];
|
|
12
|
+
const { data: countData, refetch: refetchCount } = useExplorerLibraryCountDataQuery({
|
|
13
|
+
fetchPolicy: 'network-only',
|
|
14
|
+
skip: skip || !isLibrary,
|
|
15
|
+
variables: {
|
|
16
|
+
libraryId,
|
|
17
|
+
filters: appliedFilters,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const memoizedCountData = useMemo(() => countData?.records?.totalCount ?? 0, [countData]);
|
|
21
|
+
return {
|
|
22
|
+
countData: memoizedCountData,
|
|
23
|
+
refetchCount,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useExplorerCountData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExplorerCountData.js","sourceRoot":"","sources":["../../../../src/components/Explorer/_queries/useExplorerCountData.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,gCAAgC,EAAC,MAAM,eAAe,CAAC;AACvF,OAAO,EAAgB,wBAAwB,EAAC,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACjC,UAAU,EACV,SAAS,EACT,cAAc,EACd,OAAO,EACP,IAAI,GAOP,EAAE,EAAE;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC;IAChD,MAAM,aAAa,GAAG,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC;IAC1F,MAAM,sBAAsB,GAAG,wBAAwB,CAAC,cAAc,CAAC,CAAC;IAExE,MAAM,cAAc,GAAwB,CAAC,GAAG,aAAa,EAAE,GAAG,sBAAsB,CAAC,CAAC;IAE1F,MAAM,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAC,GAAG,gCAAgC,CAAC;QAC9E,WAAW,EAAE,cAAc;QAC3B,IAAI,EAAE,IAAI,IAAI,CAAC,SAAS;QACxB,SAAS,EAAE;YACP,SAAS;YACT,OAAO,EAAE,cAAc;SAC1B;KACJ,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAE1F,OAAO;QACH,SAAS,EAAE,iBAAiB;QAC5B,YAAY;KACf,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, useExplorerLibraryCountDataQuery} from '_ui/_gqlTypes';\nimport {type UIFilter, prepareFiltersForRequest} from '_ui/components/Filters';\nimport {type Entrypoint} from '../_types';\nimport {useMemo} from 'react';\n\nexport const useExplorerCountData = ({\n entrypoint,\n libraryId,\n defaultFilters,\n filters,\n skip,\n}: {\n entrypoint: Entrypoint;\n libraryId: string;\n defaultFilters: UIFilter[];\n filters: UIFilter[];\n skip?: boolean;\n}) => {\n const isLibrary = entrypoint.type === 'library';\n const activeFilters = prepareFiltersForRequest(filters.filter(f => f.field === 'active'));\n const defaultPreparedFilters = prepareFiltersForRequest(defaultFilters);\n\n const appliedFilters: RecordFilterInput[] = [...activeFilters, ...defaultPreparedFilters];\n\n const {data: countData, refetch: refetchCount} = useExplorerLibraryCountDataQuery({\n fetchPolicy: 'network-only',\n skip: skip || !isLibrary,\n variables: {\n libraryId,\n filters: appliedFilters,\n },\n });\n\n const memoizedCountData = useMemo(() => countData?.records?.totalCount ?? 0, [countData]);\n\n return {\n countData: memoizedCountData,\n refetchCount,\n };\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type useSharedTranslation } from '../../../hooks/useSharedTranslation';
|
|
2
|
+
import { type FunctionComponent } from 'react';
|
|
3
|
+
interface IResultCountProps {
|
|
4
|
+
t: ReturnType<typeof useSharedTranslation>['t'];
|
|
5
|
+
isInactive: boolean;
|
|
6
|
+
totalCountFiltered: number;
|
|
7
|
+
totalCountLibrary: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const ResultsCount: FunctionComponent<IResultCountProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { KitTypography } from 'aristid-ds';
|
|
3
|
+
export const ResultsCount = ({ t, isInactive, totalCountFiltered, totalCountLibrary, }) => (_jsxs(KitTypography.Paragraph, { children: [_jsx(KitTypography.Text, { weight: "bold", size: "fontSize7", children: isInactive
|
|
4
|
+
? `${totalCountLibrary} `
|
|
5
|
+
: totalCountFiltered === totalCountLibrary
|
|
6
|
+
? `${totalCountLibrary} `
|
|
7
|
+
: `${totalCountFiltered} / ${totalCountLibrary} ` }), _jsx(KitTypography.Text, { weight: "medium", size: "fontSize7", children: t('explorer.massAction.results', { count: totalCountLibrary }) })] }));
|
|
8
|
+
//# sourceMappingURL=ResultsCount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultsCount.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/ResultsCount.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAUzC,MAAM,CAAC,MAAM,YAAY,GAAyC,CAAC,EAC/D,CAAC,EACD,UAAU,EACV,kBAAkB,EAClB,iBAAiB,GACpB,EAAE,EAAE,CAAC,CACF,MAAC,aAAa,CAAC,SAAS,eACpB,KAAC,aAAa,CAAC,IAAI,IAAC,MAAM,EAAC,MAAM,EAAC,IAAI,EAAC,WAAW,YAC7C,UAAU;gBACP,CAAC,CAAC,GAAG,iBAAiB,GAAG;gBACzB,CAAC,CAAC,kBAAkB,KAAK,iBAAiB;oBACxC,CAAC,CAAC,GAAG,iBAAiB,GAAG;oBACzB,CAAC,CAAC,GAAG,kBAAkB,MAAM,iBAAiB,GAAG,GACtC,EACrB,KAAC,aAAa,CAAC,IAAI,IAAC,MAAM,EAAC,QAAQ,EAAC,IAAI,EAAC,WAAW,YAC/C,CAAC,CAAC,6BAA6B,EAAE,EAAC,KAAK,EAAE,iBAAiB,EAAC,CAAC,GAC5C,IACC,CAC7B,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitTypography} from 'aristid-ds';\nimport {type FunctionComponent} from 'react';\n\ninterface IResultCountProps {\n t: ReturnType<typeof useSharedTranslation>['t'];\n isInactive: boolean;\n totalCountFiltered: number;\n totalCountLibrary: number;\n}\n\nexport const ResultsCount: FunctionComponent<IResultCountProps> = ({\n t,\n isInactive,\n totalCountFiltered,\n totalCountLibrary,\n}) => (\n <KitTypography.Paragraph>\n <KitTypography.Text weight=\"bold\" size=\"fontSize7\">\n {isInactive\n ? `${totalCountLibrary} `\n : totalCountFiltered === totalCountLibrary\n ? `${totalCountLibrary} `\n : `${totalCountFiltered} / ${totalCountLibrary} `}\n </KitTypography.Text>\n <KitTypography.Text weight=\"medium\" size=\"fontSize7\">\n {t('explorer.massAction.results', {count: totalCountLibrary})}\n </KitTypography.Text>\n </KitTypography.Paragraph>\n);\n"]}
|
package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export type ValuesOccurrences =
|
|
1
|
+
import { type RecordFilterInput } from '../../../../_gqlTypes';
|
|
2
|
+
export type ValuesOccurrences = {
|
|
3
|
+
noValueCount: number;
|
|
4
|
+
occurrences: Array<{
|
|
5
|
+
count: number;
|
|
6
|
+
value: {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
3
10
|
loading?: boolean;
|
|
4
11
|
};
|
|
5
12
|
export type ValueOccurrence = ValuesOccurrences['occurrences'][0];
|
package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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 { useCountValuesOccurrencesLazyQuery
|
|
5
|
-
import { useEffect } from 'react';
|
|
4
|
+
import { useCountValuesOccurrencesLazyQuery } from '../../../../_gqlTypes';
|
|
5
|
+
import { useEffect, useMemo } from 'react';
|
|
6
6
|
export const useCountValuesOccurrencesHook = ({ attributeId, libraryId, recordFilters, }) => {
|
|
7
7
|
const [countValuesOccurrences, { data: valuesOccurrences, loading }] = useCountValuesOccurrencesLazyQuery({
|
|
8
8
|
fetchPolicy: 'no-cache',
|
|
@@ -19,9 +19,23 @@ export const useCountValuesOccurrencesHook = ({ attributeId, libraryId, recordFi
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
}, [attributeId, libraryId, recordFilters]);
|
|
22
|
+
const noValueCount = useMemo(() => {
|
|
23
|
+
if (!valuesOccurrences) {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
return valuesOccurrences.listDistinctValues?.find(v => !('treeNode' in v) || v.treeNode === null)?.count || 0;
|
|
27
|
+
}, [valuesOccurrences]);
|
|
28
|
+
const occurrences = useMemo(() => {
|
|
29
|
+
if (!valuesOccurrences) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
return (valuesOccurrences.listDistinctValues
|
|
33
|
+
?.filter(v => 'treeNode' in v && v.treeNode !== null)
|
|
34
|
+
.map(v => ({ count: v.count, value: { id: v.treeNode.id } })) || []);
|
|
35
|
+
}, [valuesOccurrences]);
|
|
22
36
|
return {
|
|
23
|
-
occurrences
|
|
24
|
-
noValueCount
|
|
37
|
+
occurrences,
|
|
38
|
+
noValueCount,
|
|
25
39
|
loading,
|
|
26
40
|
};
|
|
27
41
|
};
|
package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCountValuesOccurrencesHook.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,
|
|
1
|
+
{"version":3,"file":"useCountValuesOccurrencesHook.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useCountValu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CAAC,kBAAkB;YAChC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC;aACpD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAC,EAAE,EAAG,CAA8B,CAAC,QAAQ,CAAC,EAAE,EAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CACpG,CAAC;IACN,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,OAAO;QACH,WAAW;QACX,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, useCountValuesOccurrencesLazyQuery} from '_ui/_gqlTypes';\nimport {useEffect, useMemo} from 'react';\n\nexport type ValuesOccurrences = {\n noValueCount: number;\n occurrences: Array<{count: number; value: {id: string}}>;\n loading?: boolean;\n};\nexport type ValueOccurrence = ValuesOccurrences['occurrences'][0];\nexport const useCountValuesOccurrencesHook = ({\n attributeId,\n libraryId,\n recordFilters,\n}: {\n attributeId?: string;\n libraryId: string;\n recordFilters: RecordFilterInput[];\n}): ValuesOccurrences => {\n const [countValuesOccurrences, {data: valuesOccurrences, loading}] = useCountValuesOccurrencesLazyQuery({\n fetchPolicy: 'no-cache',\n nextFetchPolicy: 'no-cache',\n });\n\n useEffect(() => {\n if (attributeId) {\n countValuesOccurrences({\n variables: {\n attribute: attributeId,\n library: libraryId,\n recordFilters,\n },\n });\n }\n }, [attributeId, libraryId, recordFilters]);\n\n const noValueCount = useMemo(() => {\n if (!valuesOccurrences) {\n return 0;\n }\n return valuesOccurrences.listDistinctValues?.find(v => !('treeNode' in v) || v.treeNode === null)?.count || 0;\n }, [valuesOccurrences]);\n\n const occurrences = useMemo(() => {\n if (!valuesOccurrences) {\n return [];\n }\n return (\n valuesOccurrences.listDistinctValues\n ?.filter(v => 'treeNode' in v && v.treeNode !== null)\n .map(v => ({count: v.count, value: {id: (v as {treeNode: {id: string}}).treeNode.id}})) || []\n );\n }, [valuesOccurrences]);\n\n return {\n occurrences,\n noValueCount,\n loading,\n };\n};\n"]}
|
|
@@ -8,19 +8,21 @@ import { type IUIFiltersState } from '../../../components/Filters/context/filter
|
|
|
8
8
|
* @param isEnabled - whether the selection is present
|
|
9
9
|
* @param view - represent the current view
|
|
10
10
|
* @param dispatch - method to change the current view
|
|
11
|
-
* @param
|
|
11
|
+
* @param totalCountFiltered - number of results with the current filters
|
|
12
|
+
* @param totalCountLibrary - number of total items in the library (without filters)
|
|
12
13
|
* @param allVisibleKeys - list of all ids currently selected
|
|
13
14
|
* @param massActions - array of all actions available on mass selection
|
|
14
15
|
* @param snackbarId - id of the snackbar displayed
|
|
15
16
|
*/
|
|
16
|
-
export declare const useMassActions: ({ isEnabled, store: { dispatch, view }, filtersStore: { filters, filtersOperator },
|
|
17
|
+
export declare const useMassActions: ({ isEnabled, store: { dispatch, view }, filtersStore: { filters, filtersOperator }, totalCountFiltered, totalCountLibrary, allVisibleKeys, massActions, snackbarId, }: {
|
|
17
18
|
isEnabled: boolean;
|
|
18
19
|
store: {
|
|
19
20
|
view: IViewSettingsState;
|
|
20
21
|
dispatch: Dispatch<IViewSettingsAction>;
|
|
21
22
|
};
|
|
22
23
|
filtersStore: IUIFiltersState;
|
|
23
|
-
|
|
24
|
+
totalCountFiltered: number;
|
|
25
|
+
totalCountLibrary: number;
|
|
24
26
|
allVisibleKeys: string[];
|
|
25
27
|
massActions: IMassActions[];
|
|
26
28
|
snackbarId: string;
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } 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 { closeKitSnackBar, KitCheckbox, KitDropDown, KitSpace, openKitSnackBar } from 'aristid-ds';
|
|
6
|
-
import { useCallback, useEffect } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
7
7
|
import { RecordFilterCondition, RecordFilterOperator } from '../../../_gqlTypes';
|
|
8
8
|
import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
|
|
9
9
|
import { interleaveElement } from '../../../_utils/interleaveElement';
|
|
@@ -11,20 +11,26 @@ import { MASS_SELECTION_ALL } from '../_constants';
|
|
|
11
11
|
import { ViewSettingsActionTypes } from '../manage-view-settings';
|
|
12
12
|
import { prepareFiltersForRequest } from '../../../components/Filters';
|
|
13
13
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
14
|
-
import {
|
|
14
|
+
import { faCaretDown } from '@fortawesome/free-solid-svg-icons';
|
|
15
|
+
import { ResultsCount } from './ResultsCount';
|
|
15
16
|
/**
|
|
16
17
|
* Hook used to manage mass selection as the snackbar and all kind of selection (manual, all in page, all in filters)
|
|
17
18
|
*
|
|
18
19
|
* @param isEnabled - whether the selection is present
|
|
19
20
|
* @param view - represent the current view
|
|
20
21
|
* @param dispatch - method to change the current view
|
|
21
|
-
* @param
|
|
22
|
+
* @param totalCountFiltered - number of results with the current filters
|
|
23
|
+
* @param totalCountLibrary - number of total items in the library (without filters)
|
|
22
24
|
* @param allVisibleKeys - list of all ids currently selected
|
|
23
25
|
* @param massActions - array of all actions available on mass selection
|
|
24
26
|
* @param snackbarId - id of the snackbar displayed
|
|
25
27
|
*/
|
|
26
|
-
export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersStore: { filters, filtersOperator },
|
|
28
|
+
export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersStore: { filters, filtersOperator }, totalCountFiltered, totalCountLibrary, allVisibleKeys, massActions, snackbarId, }) => {
|
|
27
29
|
const { t } = useSharedTranslation();
|
|
30
|
+
const [isInactive, setIsInactive] = useState(false);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setIsInactive(filters.filter(f => f.field === 'active')?.[0]?.value === 'false');
|
|
33
|
+
}, [filters]);
|
|
28
34
|
useEffect(() => {
|
|
29
35
|
if (view.massSelection === MASS_SELECTION_ALL || view.massSelection.length !== 0) {
|
|
30
36
|
openKitSnackBar({
|
|
@@ -34,7 +40,7 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
|
|
|
34
40
|
toasterId: snackbarId,
|
|
35
41
|
onClose: () => _setSelectedKeys([]),
|
|
36
42
|
message: t('explorer.massAction.selectedItems', {
|
|
37
|
-
count: view.massSelection === MASS_SELECTION_ALL ?
|
|
43
|
+
count: view.massSelection === MASS_SELECTION_ALL ? totalCountFiltered : view.massSelection.length,
|
|
38
44
|
}),
|
|
39
45
|
actions: massActions.map(({ label, icon, deselectAll, callback }, index) => ({
|
|
40
46
|
key: index,
|
|
@@ -63,13 +69,13 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
|
|
|
63
69
|
else {
|
|
64
70
|
closeKitSnackBar(snackbarId);
|
|
65
71
|
}
|
|
66
|
-
}, [view.massSelection, filters,
|
|
72
|
+
}, [view.massSelection, filters, totalCountFiltered]);
|
|
67
73
|
useEffect(() => () => closeKitSnackBar(snackbarId), []);
|
|
68
|
-
const isOnePage = view.pageSize >
|
|
69
|
-
const hasSelectedAllAvailableItems = view.massSelection === MASS_SELECTION_ALL || view.massSelection.length ===
|
|
74
|
+
const isOnePage = view.pageSize > totalCountFiltered;
|
|
75
|
+
const hasSelectedAllAvailableItems = view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCountFiltered;
|
|
70
76
|
const hasSelectedSomeItems = view.massSelection !== MASS_SELECTION_ALL &&
|
|
71
77
|
view.massSelection.length > 0 &&
|
|
72
|
-
view.massSelection.length <
|
|
78
|
+
view.massSelection.length < totalCountFiltered;
|
|
73
79
|
const _selectAllButton = isOnePage ? (_jsx(KitCheckbox, { "aria-checked": hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false', indeterminate: hasSelectedSomeItems, checked: hasSelectedAllAvailableItems, onChange: _ => {
|
|
74
80
|
if (hasSelectedAllAvailableItems) {
|
|
75
81
|
_setSelectedKeys([]);
|
|
@@ -77,7 +83,7 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
|
|
|
77
83
|
else {
|
|
78
84
|
_setSelectedKeys(allVisibleKeys);
|
|
79
85
|
}
|
|
80
|
-
}, children:
|
|
86
|
+
}, children: _jsx(ResultsCount, { t: t, isInactive: isInactive, totalCountFiltered: totalCountFiltered, totalCountLibrary: totalCountLibrary }) })) : (_jsx(KitDropDown, { trigger: ['click'], menu: {
|
|
81
87
|
items: [
|
|
82
88
|
hasSelectedAllAvailableItems
|
|
83
89
|
? null
|
|
@@ -91,8 +97,8 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
|
|
|
91
97
|
{
|
|
92
98
|
key: 'toggle_all_selection',
|
|
93
99
|
label: hasSelectedAllAvailableItems
|
|
94
|
-
? t('explorer.massAction.toggle_selection.deselect_all', { count:
|
|
95
|
-
: t('explorer.massAction.toggle_selection.select_all', { count:
|
|
100
|
+
? t('explorer.massAction.toggle_selection.deselect_all', { count: totalCountFiltered })
|
|
101
|
+
: t('explorer.massAction.toggle_selection.select_all', { count: totalCountFiltered }),
|
|
96
102
|
onClick: async () => {
|
|
97
103
|
if (hasSelectedAllAvailableItems) {
|
|
98
104
|
_setSelectedKeys([]);
|
|
@@ -103,7 +109,7 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
|
|
|
103
109
|
},
|
|
104
110
|
},
|
|
105
111
|
],
|
|
106
|
-
}, children: _jsx(KitCheckbox, { "aria-checked": hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false', indeterminate: hasSelectedSomeItems, checked: hasSelectedAllAvailableItems, children: _jsxs(KitSpace, { size: "
|
|
112
|
+
}, children: _jsx(KitCheckbox, { "aria-checked": hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false', indeterminate: hasSelectedSomeItems, checked: hasSelectedAllAvailableItems, children: _jsxs(KitSpace, { size: "xs", children: [_jsx(ResultsCount, { t: t, isInactive: isInactive, totalCountFiltered: totalCountFiltered, totalCountLibrary: totalCountLibrary }), _jsx(FontAwesomeIcon, { icon: faCaretDown, size: "2xs" })] }) }) }));
|
|
107
113
|
const _setSelectedKeys = useCallback((keys) => dispatch({
|
|
108
114
|
type: ViewSettingsActionTypes.SET_SELECTED_KEYS,
|
|
109
115
|
payload: keys,
|