@leav/ui 1.4.1-e9a7d5f9 → 1.4.1-f5c74c27
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/components/Explorer/_types.d.ts +1 -0
- package/dist/components/Explorer/_types.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +1 -0
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +1 -0
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useExportMassAction.js +6 -8
- package/dist/components/Explorer/actions-mass/useExportMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useMassActions.js +7 -5
- package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
- package/dist/components/LibraryItemsList/FiltersPanel/Filter/FilterInput/DateBetweenFilter/DateBetweenFilter.js +2 -2
- package/dist/components/LibraryItemsList/FiltersPanel/Filter/FilterInput/DateBetweenFilter/DateBetweenFilter.js.map +1 -1
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js +1 -0
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js.map +1 -1
- package/dist/locales/en/shared.json +6 -3
- package/dist/locales/fr/shared.json +6 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../src/components/Explorer/_types.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Override} from '@leav/utils';\nimport {\n type AttributePropertiesFragment,\n type PropertyValueFragment,\n type RecordFilterInput,\n type RecordIdentityFragment,\n} from '_ui/_gqlTypes';\nimport {type Key, type ReactElement} from 'react';\nimport {type IViewSettingsState} from './manage-view-settings';\nimport {type IView} from '_ui/types';\nimport {type MASS_SELECTION_ALL} from './_constants';\nimport {type UIFilter, type ValidFilter} from '../Filters/_types';\n\nexport type MassSelection = Key[] | typeof MASS_SELECTION_ALL;\n\nexport interface IExplorerData {\n totalCount: number;\n attributes: {\n [attributeId: string]: Override<AttributePropertiesFragment, {label: string}>;\n };\n records: IItemData[];\n}\n\nexport interface IItemData {\n libraryId: string;\n key: string;\n itemId: string;\n whoAmI: Required<RecordIdentityFragment['whoAmI']>;\n canActivate: boolean;\n canDelete: boolean;\n active: boolean;\n propertiesById: {\n [attributeId: string]: PropertyValueFragment[];\n };\n /**\n * Can be named `linkId` too, but for historical reason we keep old name 👴🏼.\n */\n id_value?: string;\n}\n\nexport interface IItemAction {\n callback: (item: IItemData) => void;\n icon: ReactElement | ((item: IItemData) => ReactElement);\n label: string | ((item: IItemData) => string);\n isDanger?: boolean | ((item: IItemData) => boolean);\n disabled?: boolean | ((item: IItemData) => boolean);\n useItemActionOnRowClick?: boolean;\n}\n\nexport interface IPrimaryAction {\n callback: () => void;\n disabled?: boolean;\n icon: ReactElement;\n label: string;\n}\n\nexport interface IMassActions {\n callback: (massSelectedFilter: RecordFilterInput[], massSelection: MassSelection) => void | Promise<void>;\n icon: ReactElement;\n label: string;\n}\n\nexport type FeatureHook<T = {}> = {isEnabled: boolean; isVisible?: boolean} & T;\n\nexport type DefaultViewSettings = Override<\n Partial<IViewSettingsState>,\n {\n filtersOperator?: 'AND' | 'OR';\n filters?: UIFilter[];\n }\n>;\n\nexport interface IEntrypointTree {\n type: 'tree';\n treeId: string;\n nodeId: string;\n}\n\nexport interface IEntrypointLibrary {\n type: 'library';\n libraryId: string;\n /**\n * Used to display a list of values instead of all library records when adding a link\n */\n valuesList?: string[];\n /**\n * Used to allow free entry when adding a link with values list\n */\n allowFreeEntry?: boolean;\n}\n\nexport interface IEntrypointLink {\n type: 'link';\n parentLibraryId: string;\n parentRecordId: string;\n linkAttributeId: string;\n}\n\nexport type Entrypoint = IEntrypointTree | IEntrypointLibrary | IEntrypointLink;\n\nexport interface IUserView extends Pick<IView, 'shared' | 'display' | 'sort' | 'attributes'> {\n label: Record<string, string>;\n id: IView['id'] | null;\n filters: ValidFilter[];\n ownerId: string | null;\n}\n\nexport interface IDataViewOnAction {\n id: string | null;\n label: Record<string, string> | null;\n}\n\nexport type SetNewPage = (newCurrentPage: number, ignoredPageSize: number) => void;\n"]}
|
|
1
|
+
{"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../src/components/Explorer/_types.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Override} from '@leav/utils';\nimport {\n type AttributePropertiesFragment,\n type PropertyValueFragment,\n type RecordFilterInput,\n type RecordIdentityFragment,\n} from '_ui/_gqlTypes';\nimport {type Key, type ReactElement} from 'react';\nimport {type IViewSettingsState} from './manage-view-settings';\nimport {type IView} from '_ui/types';\nimport {type MASS_SELECTION_ALL} from './_constants';\nimport {type UIFilter, type ValidFilter} from '../Filters/_types';\n\nexport type MassSelection = Key[] | typeof MASS_SELECTION_ALL;\n\nexport interface IExplorerData {\n totalCount: number;\n attributes: {\n [attributeId: string]: Override<AttributePropertiesFragment, {label: string}>;\n };\n records: IItemData[];\n}\n\nexport interface IItemData {\n libraryId: string;\n key: string;\n itemId: string;\n whoAmI: Required<RecordIdentityFragment['whoAmI']>;\n canActivate: boolean;\n canDelete: boolean;\n active: boolean;\n propertiesById: {\n [attributeId: string]: PropertyValueFragment[];\n };\n /**\n * Can be named `linkId` too, but for historical reason we keep old name 👴🏼.\n */\n id_value?: string;\n}\n\nexport interface IItemAction {\n callback: (item: IItemData) => void;\n icon: ReactElement | ((item: IItemData) => ReactElement);\n label: string | ((item: IItemData) => string);\n isDanger?: boolean | ((item: IItemData) => boolean);\n disabled?: boolean | ((item: IItemData) => boolean);\n useItemActionOnRowClick?: boolean;\n}\n\nexport interface IPrimaryAction {\n callback: () => void;\n disabled?: boolean;\n icon: ReactElement;\n label: string;\n}\n\nexport interface IMassActions {\n callback: (massSelectedFilter: RecordFilterInput[], massSelection: MassSelection) => void | Promise<void>;\n deselectAll: boolean;\n icon: ReactElement;\n label: string;\n}\n\nexport type FeatureHook<T = {}> = {isEnabled: boolean; isVisible?: boolean} & T;\n\nexport type DefaultViewSettings = Override<\n Partial<IViewSettingsState>,\n {\n filtersOperator?: 'AND' | 'OR';\n filters?: UIFilter[];\n }\n>;\n\nexport interface IEntrypointTree {\n type: 'tree';\n treeId: string;\n nodeId: string;\n}\n\nexport interface IEntrypointLibrary {\n type: 'library';\n libraryId: string;\n /**\n * Used to display a list of values instead of all library records when adding a link\n */\n valuesList?: string[];\n /**\n * Used to allow free entry when adding a link with values list\n */\n allowFreeEntry?: boolean;\n}\n\nexport interface IEntrypointLink {\n type: 'link';\n parentLibraryId: string;\n parentRecordId: string;\n linkAttributeId: string;\n}\n\nexport type Entrypoint = IEntrypointTree | IEntrypointLibrary | IEntrypointLink;\n\nexport interface IUserView extends Pick<IView, 'shared' | 'display' | 'sort' | 'attributes'> {\n label: Record<string, string>;\n id: IView['id'] | null;\n filters: ValidFilter[];\n ownerId: string | null;\n}\n\nexport interface IDataViewOnAction {\n id: string | null;\n label: Record<string, string> | null;\n}\n\nexport type SetNewPage = (newCurrentPage: number, ignoredPageSize: number) => void;\n"]}
|
|
@@ -29,6 +29,7 @@ export const useDeactivateMassAction = ({ isEnabled, store: { view, dispatch },
|
|
|
29
29
|
const _deactivateMassAction = useMemo(() => ({
|
|
30
30
|
label: t('explorer.massAction.deactivate'),
|
|
31
31
|
icon: _jsx(FaTrash, {}),
|
|
32
|
+
deselectAll: true,
|
|
32
33
|
callback: massSelectionFilter => {
|
|
33
34
|
KitModal.confirm({
|
|
34
35
|
width: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeactivateMassAction.js","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BAAkB;wBACzC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAC/D,CAAC;wBACC,MAAM,OAAO,CAAC;4BACV,UAAU,EAAE;gCACR,KAAK,EAAE,IAAI,CAAC,QAAQ;gCACpB,MAAM,EAAE,CAAC;6BACZ;yBACJ,CAAC,CAAC;oBACP,CAAC;yBAAM,CAAC;wBACJ,MAAM,OAAO,EAAE,CAAC;oBACpB,CAAC;oBACD,YAAY,EAAE,CAAC,mBAAmB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;oBACxD,QAAQ,CAAC;wBACL,IAAI,EAAE,uBAAuB,CAAC,iBAAiB;wBAC/C,OAAO,EAAE,EAAE;qBACd,CAAC,CAAC;gBACP,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF,CAAC,CAAC,EAAE,yBAAyB,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,CACxG,CAAC;IAEF,OAAO;QACH,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI;KACjE,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Dispatch, useMemo} from 'react';\nimport {FaTrash} from 'react-icons/fa';\nimport {KitAlert, KitModal} from 'aristid-ds';\nimport {useDeactivateRecordsMutation} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {type useExplorerData} from '../_queries/useExplorerData';\nimport {SUCCESS_ALERT_DURATION} from '_ui/constants';\n\n/**\n * Hook used to get the action for mass actions only available on selection.\n *\n * When the mutation for deactivation is done, the Apollo cache will be clean (`Record` and `RecordIdentity`)\n * from deactivated record.\n *\n * @param isEnabled - whether the action is present\n * @param view - represent the current view\n * @param dispatch - method to change the current view\n * @param libraryId - concerned library\n * @param allVisibleKeys - list of all visible keys used to know if we need to change page\n * @param refetch - method to get fresh data when we delete last page\n */\nexport const useDeactivateMassAction = ({\n isEnabled,\n store: {view, dispatch},\n allVisibleKeys,\n totalCount,\n onDeactivate,\n refetch,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n allVisibleKeys: string[];\n totalCount: number;\n onDeactivate?: IMassActions['callback'];\n refetch: ReturnType<typeof useExplorerData>['refetch'];\n}>) => {\n const {t} = useSharedTranslation();\n\n const [deactivateRecordsMutation] = useDeactivateRecordsMutation();\n\n const _deactivateMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.deactivate'),\n icon: <FaTrash />,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title:\n t('explorer.deactivate_item', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.deactivate_item_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const {data} = await deactivateRecordsMutation({\n variables: {\n libraryId: view.libraryId,\n filters: massSelectionFilter,\n },\n });\n const total =\n view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_ALERT_DURATION,\n message: t('explorer.massAction.deactivate_message'),\n description: t('explorer.massAction.deactivate_description', {\n count: data?.deactivateRecords.length,\n total,\n }),\n closable: true,\n });\n if (\n view.massSelection === MASS_SELECTION_ALL ||\n allVisibleKeys.every(key => view.massSelection.includes(key))\n ) {\n await refetch({\n pagination: {\n limit: view.pageSize,\n offset: 0,\n },\n });\n } else {\n await refetch();\n }\n onDeactivate?.(massSelectionFilter, view.massSelection);\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n },\n });\n },\n }),\n [t, deactivateRecordsMutation, view.massSelection, dispatch, view.libraryId, allVisibleKeys, refetch],\n );\n\n return {\n deactivateMassAction: isEnabled ? _deactivateMassAction : null,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"useDeactivateMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useDeactivateMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAgB,OAAO,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,4BAA4B,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAoD,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAElE,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACpC,SAAS,EACT,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EACvB,cAAc,EACd,UAAU,EACV,YAAY,EACZ,OAAO,GAUT,EAAE,EA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B,EAAE,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI;KACjE,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Dispatch, useMemo} from 'react';\nimport {FaTrash} from 'react-icons/fa';\nimport {KitAlert, KitModal} from 'aristid-ds';\nimport {useDeactivateRecordsMutation} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {type useExplorerData} from '../_queries/useExplorerData';\nimport {SUCCESS_ALERT_DURATION} from '_ui/constants';\n\n/**\n * Hook used to get the action for mass actions only available on selection.\n *\n * When the mutation for deactivation is done, the Apollo cache will be clean (`Record` and `RecordIdentity`)\n * from deactivated record.\n *\n * @param isEnabled - whether the action is present\n * @param view - represent the current view\n * @param dispatch - method to change the current view\n * @param libraryId - concerned library\n * @param allVisibleKeys - list of all visible keys used to know if we need to change page\n * @param refetch - method to get fresh data when we delete last page\n */\nexport const useDeactivateMassAction = ({\n isEnabled,\n store: {view, dispatch},\n allVisibleKeys,\n totalCount,\n onDeactivate,\n refetch,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n allVisibleKeys: string[];\n totalCount: number;\n onDeactivate?: IMassActions['callback'];\n refetch: ReturnType<typeof useExplorerData>['refetch'];\n}>) => {\n const {t} = useSharedTranslation();\n\n const [deactivateRecordsMutation] = useDeactivateRecordsMutation();\n\n const _deactivateMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.deactivate'),\n icon: <FaTrash />,\n deselectAll: true,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title:\n t('explorer.deactivate_item', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.deactivate_item_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const {data} = await deactivateRecordsMutation({\n variables: {\n libraryId: view.libraryId,\n filters: massSelectionFilter,\n },\n });\n const total =\n view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_ALERT_DURATION,\n message: t('explorer.massAction.deactivate_message'),\n description: t('explorer.massAction.deactivate_description', {\n count: data?.deactivateRecords.length,\n total,\n }),\n closable: true,\n });\n if (\n view.massSelection === MASS_SELECTION_ALL ||\n allVisibleKeys.every(key => view.massSelection.includes(key))\n ) {\n await refetch({\n pagination: {\n limit: view.pageSize,\n offset: 0,\n },\n });\n } else {\n await refetch();\n }\n onDeactivate?.(massSelectionFilter, view.massSelection);\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n },\n });\n },\n }),\n [t, deactivateRecordsMutation, view.massSelection, dispatch, view.libraryId, allVisibleKeys, refetch],\n );\n\n return {\n deactivateMassAction: isEnabled ? _deactivateMassAction : null,\n };\n};\n"]}
|
|
@@ -28,6 +28,7 @@ export const useDeleteLinkValues = ({ isEnabled, store: { view, dispatch }, filt
|
|
|
28
28
|
const _unlinkMassAction = useMemo(() => ({
|
|
29
29
|
label: t('explorer.massAction.deactivate'),
|
|
30
30
|
icon: _jsx(FaTrash, {}),
|
|
31
|
+
deselectAll: true,
|
|
31
32
|
callback: massSelectionFilter => {
|
|
32
33
|
KitModal.confirm({
|
|
33
34
|
width: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeleteLinkValues.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useDeleteLinkValues.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,yBAAyB,MAAM,uFAAuF,CAAC;AAE9H,OAAO,EAAoD,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAA0B,OAAO,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAKlE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAChC,SAAS,EACT,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EACvB,YAAY,EAAE,EAAC,OAAO,EAAE,eAAe,EAAC,EACxC,UAAU,EACV,cAAc,EACd,QAAQ,EACR,OAAO,GAWT,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,EAAC,UAAU,EAAC,GAAG,yBAAyB,EAAE,CAAC;IAEjD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC;IAC/C,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,0BAA0B,EAAE,eAAe,EAAC,GAAG,eAAe,CAAC;QAClF,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,YAAY,EAAE,IAAI,CAAC,aAAa;QAChC,cAAc,EAAE,IAAI,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E,CAAC;oBACpB,CAAC;oBACD,QAAQ,CAAC;wBACL,IAAI,EAAE,uBAAuB,CAAC,iBAAiB;wBAC/C,OAAO,EAAE,EAAE;qBACd,CAAC,CAAC;gBACP,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAChF,CAAC;IAEF,OAAO;QACH,gBAAgB,EAAE,SAAS,IAAI,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;KAC5E,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 useSaveValueBatchMutation from '_ui/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {type FeatureHook, type IEntrypointLink, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {type Dispatch, type Key, useMemo} from 'react';\nimport {useExplorerData} from '../_queries/useExplorerData';\nimport {FaTrash} from 'react-icons/fa';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitModal} from 'aristid-ds';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {type IValueToSubmit} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {FiltersOperator, UIFilter} from '_ui/components/Filters';\nimport {type IUIFiltersState} from '_ui/components/Filters/context/filtersReducer';\n\nexport const useDeleteLinkValues = ({\n isEnabled,\n store: {view, dispatch},\n filtersStore: {filters, filtersOperator},\n pagination,\n allVisibleKeys,\n onDelete,\n refetch,\n}: FeatureHook<{\n pagination: null | {limit: number; offset: number};\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n allVisibleKeys: string[];\n onDelete?: IMassActions['callback'];\n refetch: ReturnType<typeof useExplorerData>['refetch'];\n}>) => {\n const {t} = useSharedTranslation();\n const {saveValues} = useSaveValueBatchMutation();\n\n const isLink = view.entrypoint.type === 'link';\n const {data: linkData, canEditLinkAttributeValues: canUnlinkValues} = useExplorerData({\n entrypoint: view.entrypoint,\n libraryId: view.libraryId,\n attributeIds: view.attributesIds,\n fulltextSearch: view.fulltextSearch,\n pagination,\n sorts: view.sort,\n filtersOperator,\n filters,\n skip: !isLink,\n });\n\n const _unlinkMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.deactivate'),\n icon: <FaTrash />,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title:\n t('explorer.delete_link', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.delete_link_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.submit') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const entrypoint = view.entrypoint as IEntrypointLink;\n let values: IValueToSubmit[];\n if (\n view.massSelection === MASS_SELECTION_ALL ||\n allVisibleKeys.every(key => view.massSelection.includes(key))\n ) {\n values =\n (linkData?.records ?? []).map(({id_value}) => ({\n attribute: entrypoint.linkAttributeId,\n idValue: id_value ?? null,\n value: null,\n })) ?? [];\n } else {\n values = (linkData?.records ?? []).reduce<IValueToSubmit[]>((acc, {id_value, key}) => {\n if (view.massSelection.includes(key)) {\n acc.push({\n attribute: entrypoint.linkAttributeId,\n idValue: id_value ?? null,\n value: null,\n });\n }\n return acc;\n }, []);\n }\n\n if (values.length > 0) {\n await saveValues(\n {\n id: entrypoint.parentRecordId,\n library: {\n id: entrypoint.parentLibraryId,\n },\n },\n values,\n undefined,\n true,\n );\n\n onDelete?.(\n massSelectionFilter,\n values.map(({idValue}) => idValue as Key),\n );\n await refetch();\n }\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n },\n });\n },\n }),\n [t, saveValues, view.massSelection, dispatch, view.libraryId, allVisibleKeys],\n );\n\n return {\n unlinkMassAction: isEnabled && canUnlinkValues ? _unlinkMassAction : null,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"useDeleteLinkValues.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useDeleteLinkValues.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,yBAAyB,MAAM,uFAAuF,CAAC;AAE9H,OAAO,EAAoD,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAA0B,OAAO,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAKlE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAChC,SAAS,EACT,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EACvB,YAAY,EAAE,EAAC,OAAO,EAAE,eAAe,EAAC,EACxC,UAAU,EACV,cAAc,EACd,QAAQ,EACR,OAAO,GAWT,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,EAAC,UAAU,EAAC,GAAG,yBAAyB,EAAE,CAAC;IAEjD,MAAM,MAAM,GAA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EAAE,EAAE,UAAU,CAAC,cAAc;4BAC7B,OAAO,EAAE;gCACL,EAAE,EAAE,UAAU,CAAC,eAAe;6BACjC;yBACJ,EACD,MAAM,EACN,SAAS,EACT,IAAI,CACP,CAAC;wBAEF,QAAQ,EAAE,CACN,mBAAmB,EACnB,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,OAAO,EAAC,EAAE,EAAE,CAAC,OAAc,CAAC,CAC5C,CAAC;wBACF,MAAM,OAAO,EAAE,CAAC;oBACpB,CAAC;oBACD,QAAQ,CAAC;wBACL,IAAI,EAAE,uBAAuB,CAAC,iBAAiB;wBAC/C,OAAO,EAAE,EAAE;qBACd,CAAC,CAAC;gBACP,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAChF,CAAC;IAEF,OAAO;QACH,gBAAgB,EAAE,SAAS,IAAI,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;KAC5E,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 useSaveValueBatchMutation from '_ui/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation';\nimport {type FeatureHook, type IEntrypointLink, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {type Dispatch, type Key, useMemo} from 'react';\nimport {useExplorerData} from '../_queries/useExplorerData';\nimport {FaTrash} from 'react-icons/fa';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitModal} from 'aristid-ds';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {type IValueToSubmit} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {FiltersOperator, UIFilter} from '_ui/components/Filters';\nimport {type IUIFiltersState} from '_ui/components/Filters/context/filtersReducer';\n\nexport const useDeleteLinkValues = ({\n isEnabled,\n store: {view, dispatch},\n filtersStore: {filters, filtersOperator},\n pagination,\n allVisibleKeys,\n onDelete,\n refetch,\n}: FeatureHook<{\n pagination: null | {limit: number; offset: number};\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n allVisibleKeys: string[];\n onDelete?: IMassActions['callback'];\n refetch: ReturnType<typeof useExplorerData>['refetch'];\n}>) => {\n const {t} = useSharedTranslation();\n const {saveValues} = useSaveValueBatchMutation();\n\n const isLink = view.entrypoint.type === 'link';\n const {data: linkData, canEditLinkAttributeValues: canUnlinkValues} = useExplorerData({\n entrypoint: view.entrypoint,\n libraryId: view.libraryId,\n attributeIds: view.attributesIds,\n fulltextSearch: view.fulltextSearch,\n pagination,\n sorts: view.sort,\n filtersOperator,\n filters,\n skip: !isLink,\n });\n\n const _unlinkMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.deactivate'),\n icon: <FaTrash />,\n deselectAll: true,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title:\n t('explorer.delete_link', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.delete_link_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.submit') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const entrypoint = view.entrypoint as IEntrypointLink;\n let values: IValueToSubmit[];\n if (\n view.massSelection === MASS_SELECTION_ALL ||\n allVisibleKeys.every(key => view.massSelection.includes(key))\n ) {\n values =\n (linkData?.records ?? []).map(({id_value}) => ({\n attribute: entrypoint.linkAttributeId,\n idValue: id_value ?? null,\n value: null,\n })) ?? [];\n } else {\n values = (linkData?.records ?? []).reduce<IValueToSubmit[]>((acc, {id_value, key}) => {\n if (view.massSelection.includes(key)) {\n acc.push({\n attribute: entrypoint.linkAttributeId,\n idValue: id_value ?? null,\n value: null,\n });\n }\n return acc;\n }, []);\n }\n\n if (values.length > 0) {\n await saveValues(\n {\n id: entrypoint.parentRecordId,\n library: {\n id: entrypoint.parentLibraryId,\n },\n },\n values,\n undefined,\n true,\n );\n\n onDelete?.(\n massSelectionFilter,\n values.map(({idValue}) => idValue as Key),\n );\n await refetch();\n }\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n },\n });\n },\n }),\n [t, saveValues, view.massSelection, dispatch, view.libraryId, allVisibleKeys],\n );\n\n return {\n unlinkMassAction: isEnabled && canUnlinkValues ? _unlinkMassAction : null,\n };\n};\n"]}
|
|
@@ -7,7 +7,6 @@ import { FaFileExport } from 'react-icons/fa';
|
|
|
7
7
|
import { KitAlert, KitModal } from 'aristid-ds';
|
|
8
8
|
import { useExportLazyQuery } from '../../../_gqlTypes';
|
|
9
9
|
import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
|
|
10
|
-
import { ViewSettingsActionTypes } from '../manage-view-settings';
|
|
11
10
|
import { BREAK_TWO_LINES, MASS_SELECTION_ALL } from '../_constants';
|
|
12
11
|
import { ERROR_ALERT_DURATION, SUCCESS_ALERT_DURATION } from '../../../constants';
|
|
13
12
|
/**
|
|
@@ -20,6 +19,7 @@ export const useExportMassAction = ({ isEnabled, store: { view, dispatch }, tota
|
|
|
20
19
|
const _exportMassAction = useMemo(() => ({
|
|
21
20
|
label: t('explorer.massAction.export'),
|
|
22
21
|
icon: _jsx(FaFileExport, {}),
|
|
22
|
+
deselectAll: false,
|
|
23
23
|
callback: massSelectionFilter => {
|
|
24
24
|
KitModal.confirm({
|
|
25
25
|
width: '100%',
|
|
@@ -37,6 +37,7 @@ export const useExportMassAction = ({ isEnabled, store: { view, dispatch }, tota
|
|
|
37
37
|
okText: t('global.confirm') ?? undefined,
|
|
38
38
|
cancelText: t('global.cancel') ?? undefined,
|
|
39
39
|
onOk: async () => {
|
|
40
|
+
const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
|
|
40
41
|
try {
|
|
41
42
|
const { data, error } = await exportQuery({
|
|
42
43
|
variables: {
|
|
@@ -52,27 +53,24 @@ export const useExportMassAction = ({ isEnabled, store: { view, dispatch }, tota
|
|
|
52
53
|
errorWithExtensions.extensions = graphQLError?.extensions;
|
|
53
54
|
throw errorWithExtensions;
|
|
54
55
|
}
|
|
55
|
-
const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
|
|
56
56
|
KitAlert.success({
|
|
57
57
|
showIcon: true,
|
|
58
58
|
duration: SUCCESS_ALERT_DURATION,
|
|
59
|
-
message: t('explorer.massAction.export_message'),
|
|
59
|
+
message: t('explorer.massAction.export_message', { count: total }),
|
|
60
60
|
description: t('explorer.massAction.export_description', {
|
|
61
|
-
count:
|
|
61
|
+
count: total,
|
|
62
62
|
total,
|
|
63
63
|
}),
|
|
64
64
|
closable: true,
|
|
65
65
|
});
|
|
66
66
|
onExport?.(massSelectionFilter, view.massSelection);
|
|
67
|
-
// Reset selection when export is done
|
|
68
|
-
dispatch({ type: ViewSettingsActionTypes.SET_SELECTED_KEYS, payload: [] });
|
|
69
67
|
}
|
|
70
68
|
catch (e) {
|
|
71
69
|
if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {
|
|
72
70
|
KitAlert.error({
|
|
73
71
|
showIcon: true,
|
|
74
72
|
duration: ERROR_ALERT_DURATION,
|
|
75
|
-
message: t('error.error_occurred'),
|
|
73
|
+
message: t('error.error_occurred', { count: total }),
|
|
76
74
|
description: t('explorer.massAction.export_config_error_description', {
|
|
77
75
|
library: view.libraryId,
|
|
78
76
|
}),
|
|
@@ -84,7 +82,7 @@ export const useExportMassAction = ({ isEnabled, store: { view, dispatch }, tota
|
|
|
84
82
|
showIcon: true,
|
|
85
83
|
duration: ERROR_ALERT_DURATION,
|
|
86
84
|
message: t('error.error_occurred'),
|
|
87
|
-
description: t('explorer.massAction.export_error_description'),
|
|
85
|
+
description: t('explorer.massAction.export_error_description', { count: total }),
|
|
88
86
|
closable: true,
|
|
89
87
|
});
|
|
90
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExportMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useExportMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAgB,OAAO,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"useExportMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useExportMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAgB,OAAO,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAClE,OAAO,EAAC,oBAAoB,EAAE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,CAAC,KAAK,CAAC;gCACX,QAAQ,EAAE,IAAI;gCACd,QAAQ,EAAE,oBAAoB;gCAC9B,OAAO,EAAE,CAAC,CAAC,sBAAsB,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC;gCAClD,WAAW,EAAE,CAAC,CAAC,qDAAqD,EAAE;oCAClE,OAAO,EAAE,IAAI,CAAC,SAAS;iCAC1B,CAAC;gCACF,QAAQ,EAAE,IAAI;6BACjB,CAAC,CAAC;wBACP,CAAC;6BAAM,CAAC;4BACJ,QAAQ,CAAC,KAAK,CAAC;gCACX,QAAQ,EAAE,IAAI;gCACd,QAAQ,EAAE,oBAAoB;gCAC9B,OAAO,EAAE,CAAC,CAAC,sBAAsB,CAAC;gCAClC,WAAW,EAAE,CAAC,CAAC,8CAA8C,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC;gCAC9E,QAAQ,EAAE,IAAI;6BACjB,CAAC,CAAC;wBACP,CAAC;oBACL,CAAC;gBACL,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CACjE,CAAC;IAEF,OAAO;QACH,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;KACzD,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Dispatch, useMemo} from 'react';\nimport {FaFileExport} from 'react-icons/fa';\nimport {KitAlert, KitModal} from 'aristid-ds';\nimport {useExportLazyQuery} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {ERROR_ALERT_DURATION, SUCCESS_ALERT_DURATION} from '_ui/constants';\n\n/**\n * Hook that provides a mass action configuration for exporting selected or all items\n * from a view/data set\n */\nexport const useExportMassAction = ({\n isEnabled,\n store: {view, dispatch},\n totalCount,\n onExport,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n totalCount: number;\n onExport?: IMassActions['callback'];\n}>) => {\n const {t} = useSharedTranslation();\n\n const [exportQuery] = useExportLazyQuery();\n\n const _exportMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.export'),\n icon: <FaFileExport />,\n deselectAll: false,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n icon: false,\n type: 'confirm',\n title:\n t('explorer.export_item', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.export_item_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const total =\n view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n try {\n const {data, error} = await exportQuery({\n variables: {\n library: view.libraryId,\n filters: massSelectionFilter,\n profile: 'default', // Set 'default' by default, it'll change when we can select a profile from the UI\n },\n });\n if (error) {\n // Preserve the extensions property which contains the error code\n const graphQLError = error.graphQLErrors?.[0];\n const errorWithExtensions = new Error(error.message);\n (errorWithExtensions as any).extensions = graphQLError?.extensions;\n throw errorWithExtensions;\n }\n\n KitAlert.success({\n showIcon: true,\n duration: SUCCESS_ALERT_DURATION,\n message: t('explorer.massAction.export_message', {count: total}),\n description: t('explorer.massAction.export_description', {\n count: total,\n total,\n }),\n closable: true,\n });\n onExport?.(massSelectionFilter, view.massSelection);\n } catch (e) {\n if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred', {count: total}),\n description: t('explorer.massAction.export_config_error_description', {\n library: view.libraryId,\n }),\n closable: true,\n });\n } else {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.export_error_description', {count: total}),\n closable: true,\n });\n }\n }\n },\n });\n },\n }),\n [t, exportQuery, view.massSelection, dispatch, view.libraryId],\n );\n\n return {\n exportMassAction: isEnabled ? _exportMassAction : null,\n };\n};\n"]}
|
|
@@ -35,7 +35,7 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
|
|
|
35
35
|
message: t('explorer.massAction.selectedItems', {
|
|
36
36
|
count: view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length,
|
|
37
37
|
}),
|
|
38
|
-
actions: massActions.map(({ label, icon, callback }, index) => ({
|
|
38
|
+
actions: massActions.map(({ label, icon, deselectAll, callback }, index) => ({
|
|
39
39
|
key: index,
|
|
40
40
|
label,
|
|
41
41
|
icon,
|
|
@@ -49,10 +49,12 @@ export const useMassActions = ({ isEnabled, store: { dispatch, view }, filtersSt
|
|
|
49
49
|
value: String(key),
|
|
50
50
|
},
|
|
51
51
|
])), view.massSelection);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (deselectAll) {
|
|
53
|
+
dispatch({
|
|
54
|
+
type: ViewSettingsActionTypes.SET_SELECTED_KEYS,
|
|
55
|
+
payload: [],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
56
58
|
},
|
|
57
59
|
})),
|
|
58
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMassActions.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-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AC,CAAC,IAAI;KACvD,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 {closeKitSnackBar, KitCheckbox, KitDropDown, KitSpace, openKitSnackBar} from 'aristid-ds';\nimport {type Dispatch, useCallback, useEffect, useRef} from 'react';\nimport {FaChevronDown} from 'react-icons/fa';\nimport {RecordFilterCondition, RecordFilterOperator} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {interleaveElement} from '_ui/_utils/interleaveElement';\nimport {type IMassActions, type MassSelection} from '../_types';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {prepareFiltersForRequest} from '_ui/components/Filters';\nimport {type IUIFiltersState} from '_ui/components/Filters/context/filtersReducer';\n\n/**\n * Hook used to manage mass selection as the snackbar and all kind of selection (manual, all in page, all in filters)\n *\n * @param isEnabled - whether the selection is present\n * @param view - represent the current view\n * @param dispatch - method to change the current view\n * @param totalCount - used for display only\n * @param allVisibleKeys - list of all ids currently selected\n * @param massActions - array of all actions available on mass selection\n * @param snackbarId - id of the snackbar displayed\n */\nexport const useMassActions = ({\n isEnabled,\n store: {dispatch, view},\n filtersStore: {filters, filtersOperator},\n totalCount,\n allVisibleKeys,\n massActions,\n snackbarId,\n}: {\n isEnabled: boolean;\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n totalCount: number;\n allVisibleKeys: string[];\n massActions: IMassActions[];\n snackbarId: string;\n}) => {\n const {t} = useSharedTranslation();\n\n useEffect(() => {\n if (view.massSelection === MASS_SELECTION_ALL || view.massSelection.length !== 0) {\n openKitSnackBar({\n duration: 0,\n closable: true,\n snackbarId,\n toasterId: snackbarId,\n onClose: () => _setSelectedKeys([]),\n message: t('explorer.massAction.selectedItems', {\n count: view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length,\n }),\n actions: massActions.map(({label, icon, callback}, index) => ({\n key: index,\n label,\n icon,\n onClick: async () => {\n await callback(\n view.massSelection === MASS_SELECTION_ALL\n ? prepareFiltersForRequest(filters, filtersOperator)\n : interleaveElement(\n {operator: RecordFilterOperator.OR},\n view.massSelection.map(key => [\n {\n field: 'id',\n condition: RecordFilterCondition.EQUAL,\n value: String(key),\n },\n ]),\n ),\n view.massSelection,\n );\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n },\n })),\n });\n } else {\n closeKitSnackBar(snackbarId);\n }\n }, [view.massSelection, filters, totalCount]);\n\n useEffect(() => () => closeKitSnackBar(snackbarId), []);\n\n const isOnePage = view.pageSize > totalCount;\n const hasSelectedAllAvailableItems =\n view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCount;\n const hasSelectedSomeItems =\n view.massSelection !== MASS_SELECTION_ALL &&\n view.massSelection.length > 0 &&\n view.massSelection.length < totalCount;\n\n const _selectAllButton = isOnePage ? (\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n onChange={_ => {\n if (hasSelectedAllAvailableItems) {\n _setSelectedKeys([]);\n } else {\n _setSelectedKeys(allVisibleKeys);\n }\n }}\n >\n {t('explorer.massAction.itemsTotal', {count: totalCount})}\n </KitCheckbox>\n ) : (\n <KitDropDown\n trigger={['click']}\n menu={{\n items: [\n hasSelectedAllAvailableItems\n ? null\n : {\n key: 'toggle_page_selection',\n label: t('explorer.massAction.toggle_selection.select_page', {count: view.pageSize}),\n onClick: () => {\n _setSelectedKeys([...new Set([...view.massSelection, ...allVisibleKeys])]);\n },\n },\n {\n key: 'toggle_all_selection',\n label: hasSelectedAllAvailableItems\n ? t('explorer.massAction.toggle_selection.deselect_all', {count: totalCount})\n : t('explorer.massAction.toggle_selection.select_all', {count: totalCount}),\n onClick: async () => {\n if (hasSelectedAllAvailableItems) {\n _setSelectedKeys([]);\n } else {\n _setSelectedKeys(MASS_SELECTION_ALL);\n }\n },\n },\n ],\n }}\n >\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n >\n <KitSpace size=\"s\">\n {t('explorer.massAction.itemsTotal', {count: totalCount})}\n <FaChevronDown />\n </KitSpace>\n </KitCheckbox>\n </KitDropDown>\n );\n\n const _setSelectedKeys = useCallback(\n (keys: MassSelection) =>\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: keys,\n }),\n [dispatch],\n );\n\n return {\n selectAllButton: isEnabled ? _selectAllButton : null,\n setSelectedKeys: isEnabled ? _setSelectedKeys : null,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"useMassActions.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useMassActions.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACjG,OAAO,EAAgB,WAAW,EAAE,SAAS,EAAS,MAAM,OAAO,CAAC;AACpE,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,qBAAqB,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAoD,uBAA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kBAAkB,CAAC,CAAC;wBACzC,CAAC;oBACL,CAAC;iBACJ;aACJ;SACJ,YAED,KAAC,WAAW,oBACM,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAC9F,aAAa,EAAE,oBAAoB,EACnC,OAAO,EAAE,4BAA4B,YAErC,MAAC,QAAQ,IAAC,IAAI,EAAC,GAAG,aACb,CAAC,CAAC,gCAAgC,EAAE,EAAC,KAAK,EAAE,UAAU,EAAC,CAAC,EACzD,KAAC,aAAa,KAAG,IACV,GACD,GACJ,CACjB,CAAC;IAEF,MAAM,gBAAgB,GAAG,WAAW,CAChC,CAAC,IAAmB,EAAE,EAAE,CACpB,QAAQ,CAAC;QACL,IAAI,EAAE,uBAAuB,CAAC,iBAAiB;QAC/C,OAAO,EAAE,IAAI;KAChB,CAAC,EACN,CAAC,QAAQ,CAAC,CACb,CAAC;IAEF,OAAO;QACH,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;QACpD,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;KACvD,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 {closeKitSnackBar, KitCheckbox, KitDropDown, KitSpace, openKitSnackBar} from 'aristid-ds';\nimport {type Dispatch, useCallback, useEffect, useRef} from 'react';\nimport {FaChevronDown} from 'react-icons/fa';\nimport {RecordFilterCondition, RecordFilterOperator} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {interleaveElement} from '_ui/_utils/interleaveElement';\nimport {type IMassActions, type MassSelection} from '../_types';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type IViewSettingsAction, type IViewSettingsState, ViewSettingsActionTypes} from '../manage-view-settings';\nimport {prepareFiltersForRequest} from '_ui/components/Filters';\nimport {type IUIFiltersState} from '_ui/components/Filters/context/filtersReducer';\n\n/**\n * Hook used to manage mass selection as the snackbar and all kind of selection (manual, all in page, all in filters)\n *\n * @param isEnabled - whether the selection is present\n * @param view - represent the current view\n * @param dispatch - method to change the current view\n * @param totalCount - used for display only\n * @param allVisibleKeys - list of all ids currently selected\n * @param massActions - array of all actions available on mass selection\n * @param snackbarId - id of the snackbar displayed\n */\nexport const useMassActions = ({\n isEnabled,\n store: {dispatch, view},\n filtersStore: {filters, filtersOperator},\n totalCount,\n allVisibleKeys,\n massActions,\n snackbarId,\n}: {\n isEnabled: boolean;\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n filtersStore: IUIFiltersState;\n totalCount: number;\n allVisibleKeys: string[];\n massActions: IMassActions[];\n snackbarId: string;\n}) => {\n const {t} = useSharedTranslation();\n\n useEffect(() => {\n if (view.massSelection === MASS_SELECTION_ALL || view.massSelection.length !== 0) {\n openKitSnackBar({\n duration: 0,\n closable: true,\n snackbarId,\n toasterId: snackbarId,\n onClose: () => _setSelectedKeys([]),\n message: t('explorer.massAction.selectedItems', {\n count: view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length,\n }),\n actions: massActions.map(({label, icon, deselectAll, callback}, index) => ({\n key: index,\n label,\n icon,\n onClick: async () => {\n await callback(\n view.massSelection === MASS_SELECTION_ALL\n ? prepareFiltersForRequest(filters, filtersOperator)\n : interleaveElement(\n {operator: RecordFilterOperator.OR},\n view.massSelection.map(key => [\n {\n field: 'id',\n condition: RecordFilterCondition.EQUAL,\n value: String(key),\n },\n ]),\n ),\n view.massSelection,\n );\n if (deselectAll) {\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: [],\n });\n }\n },\n })),\n });\n } else {\n closeKitSnackBar(snackbarId);\n }\n }, [view.massSelection, filters, totalCount]);\n\n useEffect(() => () => closeKitSnackBar(snackbarId), []);\n\n const isOnePage = view.pageSize > totalCount;\n const hasSelectedAllAvailableItems =\n view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCount;\n const hasSelectedSomeItems =\n view.massSelection !== MASS_SELECTION_ALL &&\n view.massSelection.length > 0 &&\n view.massSelection.length < totalCount;\n\n const _selectAllButton = isOnePage ? (\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n onChange={_ => {\n if (hasSelectedAllAvailableItems) {\n _setSelectedKeys([]);\n } else {\n _setSelectedKeys(allVisibleKeys);\n }\n }}\n >\n {t('explorer.massAction.itemsTotal', {count: totalCount})}\n </KitCheckbox>\n ) : (\n <KitDropDown\n trigger={['click']}\n menu={{\n items: [\n hasSelectedAllAvailableItems\n ? null\n : {\n key: 'toggle_page_selection',\n label: t('explorer.massAction.toggle_selection.select_page', {count: view.pageSize}),\n onClick: () => {\n _setSelectedKeys([...new Set([...view.massSelection, ...allVisibleKeys])]);\n },\n },\n {\n key: 'toggle_all_selection',\n label: hasSelectedAllAvailableItems\n ? t('explorer.massAction.toggle_selection.deselect_all', {count: totalCount})\n : t('explorer.massAction.toggle_selection.select_all', {count: totalCount}),\n onClick: async () => {\n if (hasSelectedAllAvailableItems) {\n _setSelectedKeys([]);\n } else {\n _setSelectedKeys(MASS_SELECTION_ALL);\n }\n },\n },\n ],\n }}\n >\n <KitCheckbox\n aria-checked={hasSelectedSomeItems ? 'mixed' : hasSelectedAllAvailableItems ? 'true' : 'false'}\n indeterminate={hasSelectedSomeItems}\n checked={hasSelectedAllAvailableItems}\n >\n <KitSpace size=\"s\">\n {t('explorer.massAction.itemsTotal', {count: totalCount})}\n <FaChevronDown />\n </KitSpace>\n </KitCheckbox>\n </KitDropDown>\n );\n\n const _setSelectedKeys = useCallback(\n (keys: MassSelection) =>\n dispatch({\n type: ViewSettingsActionTypes.SET_SELECTED_KEYS,\n payload: keys,\n }),\n [dispatch],\n );\n\n return {\n selectAllButton: isEnabled ? _selectAllButton : null,\n setSelectedKeys: isEnabled ? _setSelectedKeys : null,\n };\n};\n"]}
|
|
@@ -17,10 +17,10 @@ const DateBetweenFilter = ({ filter, updateFilterValue }) => {
|
|
|
17
17
|
dateTo.startOf('day');
|
|
18
18
|
updateFilterValue({ ...filter.value, value: { from: String(dateFrom.unix()), to: String(dateTo.unix()) } });
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const dayjsRange = dateRangeValue
|
|
21
21
|
? [dayjs(Number(dateRangeValue.from) * 1000), dayjs(Number(dateRangeValue.to) * 1000)]
|
|
22
22
|
: null;
|
|
23
|
-
return (_jsx(DatePicker.RangePicker, { popupStyle: { background: themeVars.defaultBg }, disabled: !filter.active, onChange: _handleChange, value:
|
|
23
|
+
return (_jsx(DatePicker.RangePicker, { popupStyle: { background: themeVars.defaultBg }, disabled: !filter.active, onChange: _handleChange, value: dayjsRange }));
|
|
24
24
|
};
|
|
25
25
|
export default DateBetweenFilter;
|
|
26
26
|
//# sourceMappingURL=DateBetweenFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateBetweenFilter.js","sourceRoot":"","sources":["../../../../../../../src/components/LibraryItemsList/FiltersPanel/Filter/FilterInput/DateBetweenFilter/DateBetweenFilter.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAGxC,MAAM,iBAAiB,GAAG,CAAC,EAAC,MAAM,EAAE,iBAAiB,EAAoB,EAAE,EAAE;IACzE,MAAM,cAAc,GACf,MAAM,EAAE,KAAK,EAAE,KAAyB,EAAE,IAAI,IAAK,MAAM,EAAE,KAAK,EAAE,KAAyB,EAAE,EAAE;QAC5F,CAAC,CAAE,MAAM,CAAC,KAAK,CAAC,KAAyB;QACzC,CAAC,CAAC,IAAI,CAAC;IACf,MAAM,aAAa,GAAG,CAAC,KAAwC,EAAE,EAAE;QAC/D,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO;QACX,CAAC;QAED,yBAAyB;QACzB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;QACjC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEtB,iBAAiB,CAAC,EAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAC,EAAC,CAAC,CAAC;IAC5G,CAAC,CAAC;IAEF,MAAM,
|
|
1
|
+
{"version":3,"file":"DateBetweenFilter.js","sourceRoot":"","sources":["../../../../../../../src/components/LibraryItemsList/FiltersPanel/Filter/FilterInput/DateBetweenFilter/DateBetweenFilter.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAGxC,MAAM,iBAAiB,GAAG,CAAC,EAAC,MAAM,EAAE,iBAAiB,EAAoB,EAAE,EAAE;IACzE,MAAM,cAAc,GACf,MAAM,EAAE,KAAK,EAAE,KAAyB,EAAE,IAAI,IAAK,MAAM,EAAE,KAAK,EAAE,KAAyB,EAAE,EAAE;QAC5F,CAAC,CAAE,MAAM,CAAC,KAAK,CAAC,KAAyB;QACzC,CAAC,CAAC,IAAI,CAAC;IACf,MAAM,aAAa,GAAG,CAAC,KAAwC,EAAE,EAAE;QAC/D,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO;QACX,CAAC;QAED,yBAAyB;QACzB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;QACjC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEtB,iBAAiB,CAAC,EAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAC,EAAC,CAAC,CAAC;IAC5G,CAAC,CAAC;IAEF,MAAM,UAAU,GAA+B,cAAc;QACzD,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACtF,CAAC,CAAC,IAAI,CAAC;IAEX,OAAO,CACH,KAAC,UAAU,CAAC,WAAW,IACnB,UAAU,EAAE,EAAC,UAAU,EAAE,SAAS,CAAC,SAAS,EAAC,EAC7C,QAAQ,EAAE,CAAC,MAAM,CAAC,MAAM,EACxB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,UAAU,GACnB,CACL,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,iBAAiB,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 IDateRangeValue} from '@leav/utils';\nimport {DatePicker} from 'antd';\nimport dayjs from 'dayjs';\nimport {themeVars} from '_ui/antdTheme';\nimport {type IFilterInputProps} from '../../Filter';\n\nconst DateBetweenFilter = ({filter, updateFilterValue}: IFilterInputProps) => {\n const dateRangeValue: IDateRangeValue =\n (filter?.value?.value as IDateRangeValue)?.from && (filter?.value?.value as IDateRangeValue)?.to\n ? (filter.value.value as IDateRangeValue)\n : null;\n const _handleChange = (value: [dayjs.Dayjs, dayjs.Dayjs] | null) => {\n if (!value) {\n updateFilterValue(null);\n return;\n }\n\n // Force time to 00:00:00\n const [dateFrom, dateTo] = value;\n dateFrom.startOf('day');\n dateTo.startOf('day');\n\n updateFilterValue({...filter.value, value: {from: String(dateFrom.unix()), to: String(dateTo.unix())}});\n };\n\n const dayjsRange: [dayjs.Dayjs, dayjs.Dayjs] = dateRangeValue\n ? [dayjs(Number(dateRangeValue.from) * 1000), dayjs(Number(dateRangeValue.to) * 1000)]\n : null;\n\n return (\n <DatePicker.RangePicker\n popupStyle={{background: themeVars.defaultBg}}\n disabled={!filter.active}\n onChange={_handleChange}\n value={dayjsRange}\n />\n );\n};\n\nexport default DateBetweenFilter;\n"]}
|
|
@@ -72,6 +72,7 @@ export const SelectRecordForLinkModal = ({ className, open, childLibraryId, repl
|
|
|
72
72
|
label: replacementMode
|
|
73
73
|
? t('explorer.massAction.replace-link')
|
|
74
74
|
: t('explorer.massAction.add-link'),
|
|
75
|
+
deselectAll: true,
|
|
75
76
|
icon: replacementMode ? _jsx(FaExchangeAlt, {}) : _jsx(FaPlus, {}),
|
|
76
77
|
callback: async (massSelectionFilter) => {
|
|
77
78
|
await getRecordIdsFromFilters({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectRecordForLinkModal.js","sourceRoot":"","sources":["../../../src/components/SelectRecordForLinkModal/SelectRecordForLinkModal.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAA8C,MAAM,EAAC,MAAM,OAAO,CAAC;AAC1E,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,O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AAC,aAAa,KAAG,CAAC,CAAC,CAAC,KAAC,MAAM,KAAG;gCACtD,QAAQ,EAAE,KAAK,EAAC,mBAAmB,EAAC,EAAE;oCAClC,MAAM,uBAAuB,CAAC;wCAC1B,SAAS,EAAE;4CACP,SAAS,EAAE,cAAc;4CACzB,OAAO,EAAE,mBAAmB;yCAC/B;qCACJ,CAAC,CAAC;gCACP,CAAC;6BACJ;yBACJ,EACD,cAAc,EAAE,EAAE,EAClB,qBAAqB,EAAE,EAAE,EACzB,kBAAkB,EAAE,EAAE,EACtB,WAAW,EAAE;4BACT;gCACI,KAAK,EAAE,CAAC,CAAC,oBAAoB,CAAC;gCAC9B,IAAI,EAAE,KAAC,KAAK,KAAG;gCACf,uBAAuB,EAAE,IAAI;gCAC7B,QAAQ,EAAE,IAAI,CAAC,EAAE;oCACb,mBAAmB,CAAC;wCAChB,OAAO,EAAE,IAAI,CAAC,SAAS;wCACvB,MAAM,EAAE;4CACJ,EAAE,EAAE,IAAI,CAAC,MAAM;4CACf,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK;4CACzB,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ;4CAC/B,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK;4CACzB,OAAO,EAAE,EAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAC;yCAChC;wCACD,aAAa,EAAE,SAAS;qCAC3B,CAAC,CAAC;gCACP,CAAC;6BACJ;yBACJ,EACD,qBAAqB,EAAE,CAAC,QAAQ,CAAC,EACjC,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,QACV,mBAAmB,SACrB,EACD,eAAe,IAEmB,GACtB,GACX,CACjB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ComponentProps, type FunctionComponent, useRef} from 'react';\nimport styled from 'styled-components';\nimport {closeKitSnackBar, KitButton, KitSpace, AntModal} from 'aristid-ds';\n\n// TODO: harmonize icon sources\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faXmark} from '@fortawesome/free-solid-svg-icons';\nimport {FaExchangeAlt, FaEye, FaPlus} from 'react-icons/fa';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {\n type ExplorerSelectionIdsQuery,\n type JoinLibraryContextFragment,\n useExplorerSelectionIdsLazyQuery,\n} from '_ui/_gqlTypes';\nimport {Explorer} from '_ui/components/Explorer';\nimport {useEditRecordModal} from '../RecordEdition/EditRecordModal/useEditRecordModal';\n\nconst modalMaxWidth = 1_200;\n\nconst StyledModal = styled(AntModal)`\n && {\n width: 90vw;\n max-width: ${modalMaxWidth}px;\n\n .ant-modal-body {\n height: 80vh;\n overflow-y: auto;\n }\n\n .ant-modal-content {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n padding: 0;\n }\n\n .ant-modal-footer {\n flex: 0 0 auto;\n margin-top: 0;\n }\n }\n`;\n\nconst ModalFooterStyledDiv = styled.div`\n display: flex;\n justify-content: flex-end;\n padding: calc(var(--general-spacing-xs) * 1px) calc(var(--general-spacing-s) * 1px);\n border-top: 1px solid var(--general-utilities-border);\n`;\n\nconst ModalMainStyledDiv = styled.div`\n padding: calc(var(--general-spacing-m) * 1px);\n height: 100%;\n position: relative;\n`;\n\ninterface ISelectRecordForLinkModalProps {\n className?: string;\n open: boolean;\n childLibraryId: string;\n replacementMode: boolean;\n valuesList?: string[];\n allowFreeEntry: boolean;\n joinLibraryContext?: JoinLibraryContextFragment;\n selectionMode: ComponentProps<typeof Explorer>['selectionMode'];\n hideSelectAllAction: ComponentProps<typeof Explorer>['hideSelectAllAction'];\n onSelectionCompleted: (data: ExplorerSelectionIdsQuery) => void;\n onClose: () => void;\n}\n\nexport const SelectRecordForLinkModal: FunctionComponent<ISelectRecordForLinkModalProps> = ({\n className,\n open,\n childLibraryId,\n replacementMode,\n valuesList,\n allowFreeEntry,\n selectionMode,\n joinLibraryContext,\n hideSelectAllAction,\n onSelectionCompleted,\n onClose,\n}) => {\n const {t} = useSharedTranslation();\n const explorerContainerRef = useRef<HTMLDivElement>(null);\n\n const _handleClose: ComponentProps<typeof KitButton>['onClick'] = () => {\n closeKitSnackBar();\n onClose();\n };\n\n const _closeButtonLabel: ComponentProps<typeof KitButton>['aria-label'] = String(t('global.close'));\n\n const _footer: ComponentProps<typeof AntModal>['footer'] = (\n <ModalFooterStyledDiv>\n <KitSpace>\n <KitButton\n aria-label={_closeButtonLabel}\n key=\"close\"\n icon={<FontAwesomeIcon icon={faXmark} />}\n onClick={_handleClose}\n >\n {_closeButtonLabel}\n </KitButton>\n </KitSpace>\n </ModalFooterStyledDiv>\n );\n\n const [getRecordIdsFromFilters] = useExplorerSelectionIdsLazyQuery({\n fetchPolicy: 'no-cache',\n onCompleted: onSelectionCompleted,\n });\n\n const {EditRecordModal, openEditRecordModal} = useEditRecordModal();\n\n return (\n <StyledModal\n className={className}\n open={open}\n onCancel={_handleClose}\n destroyOnClose\n closable={false}\n cancelText={t('global.cancel')}\n width=\"90vw\"\n centered\n footer={_footer}\n >\n <ModalMainStyledDiv ref={explorerContainerRef}>\n <Explorer.EditSettingsContextProvider\n panelElement={() => explorerContainerRef.current ?? document.body}\n >\n <Explorer\n entrypoint={{\n type: 'library',\n libraryId: childLibraryId,\n valuesList,\n allowFreeEntry,\n }}\n showCreateOnNoResultOnly\n selectionMode={selectionMode}\n hideSelectAllAction={hideSelectAllAction}\n massActions={[\n {\n label: replacementMode\n ? t('explorer.massAction.replace-link')\n : t('explorer.massAction.add-link'),\n icon: replacementMode ? <FaExchangeAlt /> : <FaPlus />,\n callback: async massSelectionFilter => {\n await getRecordIdsFromFilters({\n variables: {\n libraryId: childLibraryId,\n filters: massSelectionFilter,\n },\n });\n },\n },\n ]}\n primaryActions={[]}\n defaultActionsForItem={[]}\n defaultMassActions={[]}\n itemActions={[\n {\n label: t('explorer.edit-item'),\n icon: <FaEye />,\n useItemActionOnRowClick: true,\n callback: item => {\n openEditRecordModal({\n library: item.libraryId,\n record: {\n id: item.itemId,\n label: item.whoAmI?.label,\n subLabel: item.whoAmI?.subLabel,\n color: item.whoAmI?.color,\n library: {id: item.libraryId},\n },\n editionFormId: 'edition',\n });\n },\n },\n ]}\n defaultPrimaryActions={['create']}\n joinLibraryContext={joinLibraryContext}\n showSearch\n ignoreViewByDefault\n />\n {EditRecordModal}\n {/* TODO: avoid getting last view for user */}\n </Explorer.EditSettingsContextProvider>\n </ModalMainStyledDiv>\n </StyledModal>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"SelectRecordForLinkModal.js","sourceRoot":"","sources":["../../../src/components/SelectRecordForLinkModal/SelectRecordForLinkModal.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAA8C,MAAM,EAAC,MAAM,OAAO,CAAC;AAC1E,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE3E,+BAA+B;AAC/B,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAC,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAE,KAAK,EAAE,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAGH,gCAAgC,GACnC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,qDAAqD,CAAC;AAEvF,MAAM,aAAa,GAAG,IAAK,CAAC;AAE5B,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;;;qBAG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AAS;wCACvB,MAAM,EAAE;4CACJ,EAAE,EAAE,IAAI,CAAC,MAAM;4CACf,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK;4CACzB,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ;4CAC/B,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK;4CACzB,OAAO,EAAE,EAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAC;yCAChC;wCACD,aAAa,EAAE,SAAS;qCAC3B,CAAC,CAAC;gCACP,CAAC;6BACJ;yBACJ,EACD,qBAAqB,EAAE,CAAC,QAAQ,CAAC,EACjC,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,QACV,mBAAmB,SACrB,EACD,eAAe,IAEmB,GACtB,GACX,CACjB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ComponentProps, type FunctionComponent, useRef} from 'react';\nimport styled from 'styled-components';\nimport {closeKitSnackBar, KitButton, KitSpace, AntModal} from 'aristid-ds';\n\n// TODO: harmonize icon sources\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faXmark} from '@fortawesome/free-solid-svg-icons';\nimport {FaExchangeAlt, FaEye, FaPlus} from 'react-icons/fa';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {\n type ExplorerSelectionIdsQuery,\n type JoinLibraryContextFragment,\n useExplorerSelectionIdsLazyQuery,\n} from '_ui/_gqlTypes';\nimport {Explorer} from '_ui/components/Explorer';\nimport {useEditRecordModal} from '../RecordEdition/EditRecordModal/useEditRecordModal';\n\nconst modalMaxWidth = 1_200;\n\nconst StyledModal = styled(AntModal)`\n && {\n width: 90vw;\n max-width: ${modalMaxWidth}px;\n\n .ant-modal-body {\n height: 80vh;\n overflow-y: auto;\n }\n\n .ant-modal-content {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n padding: 0;\n }\n\n .ant-modal-footer {\n flex: 0 0 auto;\n margin-top: 0;\n }\n }\n`;\n\nconst ModalFooterStyledDiv = styled.div`\n display: flex;\n justify-content: flex-end;\n padding: calc(var(--general-spacing-xs) * 1px) calc(var(--general-spacing-s) * 1px);\n border-top: 1px solid var(--general-utilities-border);\n`;\n\nconst ModalMainStyledDiv = styled.div`\n padding: calc(var(--general-spacing-m) * 1px);\n height: 100%;\n position: relative;\n`;\n\ninterface ISelectRecordForLinkModalProps {\n className?: string;\n open: boolean;\n childLibraryId: string;\n replacementMode: boolean;\n valuesList?: string[];\n allowFreeEntry: boolean;\n joinLibraryContext?: JoinLibraryContextFragment;\n selectionMode: ComponentProps<typeof Explorer>['selectionMode'];\n hideSelectAllAction: ComponentProps<typeof Explorer>['hideSelectAllAction'];\n onSelectionCompleted: (data: ExplorerSelectionIdsQuery) => void;\n onClose: () => void;\n}\n\nexport const SelectRecordForLinkModal: FunctionComponent<ISelectRecordForLinkModalProps> = ({\n className,\n open,\n childLibraryId,\n replacementMode,\n valuesList,\n allowFreeEntry,\n selectionMode,\n joinLibraryContext,\n hideSelectAllAction,\n onSelectionCompleted,\n onClose,\n}) => {\n const {t} = useSharedTranslation();\n const explorerContainerRef = useRef<HTMLDivElement>(null);\n\n const _handleClose: ComponentProps<typeof KitButton>['onClick'] = () => {\n closeKitSnackBar();\n onClose();\n };\n\n const _closeButtonLabel: ComponentProps<typeof KitButton>['aria-label'] = String(t('global.close'));\n\n const _footer: ComponentProps<typeof AntModal>['footer'] = (\n <ModalFooterStyledDiv>\n <KitSpace>\n <KitButton\n aria-label={_closeButtonLabel}\n key=\"close\"\n icon={<FontAwesomeIcon icon={faXmark} />}\n onClick={_handleClose}\n >\n {_closeButtonLabel}\n </KitButton>\n </KitSpace>\n </ModalFooterStyledDiv>\n );\n\n const [getRecordIdsFromFilters] = useExplorerSelectionIdsLazyQuery({\n fetchPolicy: 'no-cache',\n onCompleted: onSelectionCompleted,\n });\n\n const {EditRecordModal, openEditRecordModal} = useEditRecordModal();\n\n return (\n <StyledModal\n className={className}\n open={open}\n onCancel={_handleClose}\n destroyOnClose\n closable={false}\n cancelText={t('global.cancel')}\n width=\"90vw\"\n centered\n footer={_footer}\n >\n <ModalMainStyledDiv ref={explorerContainerRef}>\n <Explorer.EditSettingsContextProvider\n panelElement={() => explorerContainerRef.current ?? document.body}\n >\n <Explorer\n entrypoint={{\n type: 'library',\n libraryId: childLibraryId,\n valuesList,\n allowFreeEntry,\n }}\n showCreateOnNoResultOnly\n selectionMode={selectionMode}\n hideSelectAllAction={hideSelectAllAction}\n massActions={[\n {\n label: replacementMode\n ? t('explorer.massAction.replace-link')\n : t('explorer.massAction.add-link'),\n deselectAll: true,\n icon: replacementMode ? <FaExchangeAlt /> : <FaPlus />,\n callback: async massSelectionFilter => {\n await getRecordIdsFromFilters({\n variables: {\n libraryId: childLibraryId,\n filters: massSelectionFilter,\n },\n });\n },\n },\n ]}\n primaryActions={[]}\n defaultActionsForItem={[]}\n defaultMassActions={[]}\n itemActions={[\n {\n label: t('explorer.edit-item'),\n icon: <FaEye />,\n useItemActionOnRowClick: true,\n callback: item => {\n openEditRecordModal({\n library: item.libraryId,\n record: {\n id: item.itemId,\n label: item.whoAmI?.label,\n subLabel: item.whoAmI?.subLabel,\n color: item.whoAmI?.color,\n library: {id: item.libraryId},\n },\n editionFormId: 'edition',\n });\n },\n },\n ]}\n defaultPrimaryActions={['create']}\n joinLibraryContext={joinLibraryContext}\n showSearch\n ignoreViewByDefault\n />\n {EditRecordModal}\n {/* TODO: avoid getting last view for user */}\n </Explorer.EditSettingsContextProvider>\n </ModalMainStyledDiv>\n </StyledModal>\n );\n};\n"]}
|
|
@@ -747,9 +747,12 @@
|
|
|
747
747
|
"deactivate_message": "Elements deleted",
|
|
748
748
|
"deactivate_description": "{{count, number}}/{{total, number}} element for which you have permissions have been deleted. Others remain unchanged.",
|
|
749
749
|
"export": "Export",
|
|
750
|
-
"
|
|
751
|
-
"
|
|
752
|
-
"
|
|
750
|
+
"export_message_one": "Element exported",
|
|
751
|
+
"export_message_other": "Elements exported",
|
|
752
|
+
"export_description_one": "{{total, number}} element will be exported.",
|
|
753
|
+
"export_description_other": "{{total, number}} elements will be exported.",
|
|
754
|
+
"export_error_description_one": "An error occurred while exporting the selected record.",
|
|
755
|
+
"export_error_description_other": "An error occurred while exporting the selected records.",
|
|
753
756
|
"export_config_error_description": "No profile configured on {{library}} library. Please contact an administrator.",
|
|
754
757
|
"add-link": "Add",
|
|
755
758
|
"replace-link": "Replace",
|
|
@@ -747,9 +747,12 @@
|
|
|
747
747
|
"deactivate_message": "Élements supprimés",
|
|
748
748
|
"deactivate_description": "{{count, number}}/{{total, number}} éléments pour lesquels vous disposez des permissions nécessaires ont été supprimés. Les autres éléments restent inchangés.",
|
|
749
749
|
"export": "Exporter",
|
|
750
|
-
"
|
|
751
|
-
"
|
|
752
|
-
"
|
|
750
|
+
"export_message_one": "Élement exporté",
|
|
751
|
+
"export_message_other": "Élements exportés",
|
|
752
|
+
"export_description_one": "{{total, number}} éléments va être exporté.",
|
|
753
|
+
"export_description_other": "{{total, number}} éléments vont être exportés.",
|
|
754
|
+
"export_error_description_one": "Une erreur s'est produite lors de l'exportation de l'enregistrements sélectionné.",
|
|
755
|
+
"export_error_description_other": "Une erreur s'est produite lors de l'exportation des enregistrements sélectionnés.",
|
|
753
756
|
"export_config_error_description": "Aucun profil configuré sur la librairie {{library}}. Veuillez contacter un administrateur.",
|
|
754
757
|
"add-link": "Ajouter",
|
|
755
758
|
"replace-link": "Remplacer",
|