@webiny/app-file-manager 6.4.11 → 6.6.0-alpha.1
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/app.js +21 -2
- package/app.js.map +1 -1
- package/domain/tagsHelpers.d.ts +2 -2
- package/domain/types.d.ts +0 -8
- package/features/permissions/abstractions.d.ts +2 -2
- package/features/permissions/feature.d.ts +3 -3
- package/features/shared/FILE_FIELDS.js +4 -0
- package/features/shared/FILE_FIELDS.js.map +1 -1
- package/features/shared/FileFieldsProviderWithWcp.d.ts +5 -5
- package/features/shared/FileFieldsProviderWithWcp.js +7 -7
- package/features/shared/FileFieldsProviderWithWcp.js.map +1 -1
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.d.ts +18 -0
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.js +33 -0
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.js.map +1 -0
- package/modules/AiEnrichment/ReenrichFileGateway.d.ts +12 -0
- package/modules/AiEnrichment/ReenrichFileGateway.js +23 -0
- package/modules/AiEnrichment/ReenrichFileGateway.js.map +1 -0
- package/modules/AiEnrichment/ReenrichWithAi.d.ts +11 -0
- package/modules/AiEnrichment/ReenrichWithAi.js +57 -0
- package/modules/AiEnrichment/ReenrichWithAi.js.map +1 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.d.ts +50 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.js +114 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.js.map +1 -0
- package/modules/AiEnrichment/StreamingPlaceholder.d.ts +15 -0
- package/modules/AiEnrichment/StreamingPlaceholder.js +32 -0
- package/modules/AiEnrichment/StreamingPlaceholder.js.map +1 -0
- package/modules/AiEnrichment/abstractions.d.ts +70 -0
- package/modules/AiEnrichment/abstractions.js +6 -0
- package/modules/AiEnrichment/abstractions.js.map +1 -0
- package/modules/AiEnrichment/feature.d.ts +3 -0
- package/modules/AiEnrichment/feature.js +21 -0
- package/modules/AiEnrichment/feature.js.map +1 -0
- package/modules/AiEnrichment/index.d.ts +2 -0
- package/modules/AiEnrichment/index.js +9 -0
- package/modules/AiEnrichment/index.js.map +1 -0
- package/modules/Enterprise/index.js +3 -3
- package/modules/Enterprise/index.js.map +1 -1
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.d.ts +26 -0
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js +39 -0
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.d.ts +34 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.js +42 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.d.ts +21 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.js +42 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.js +20 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js +20 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.d.ts +16 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js +33 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.d.ts +25 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.js +38 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.js +19 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.js +19 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/feature.d.ts +1 -0
- package/modules/HeadlessCms/fieldType/feature.js +27 -0
- package/modules/HeadlessCms/fieldType/feature.js.map +1 -0
- package/modules/HeadlessCms/fieldType/isAssetField.d.ts +2 -0
- package/modules/HeadlessCms/fieldType/isAssetField.js +4 -0
- package/modules/HeadlessCms/fieldType/isAssetField.js.map +1 -0
- package/package.json +24 -34
- package/presentation/FileActions/FileDetails/EditImage.d.ts +2 -0
- package/presentation/FileActions/FileDetails/EditImage.js +39 -0
- package/presentation/FileActions/FileDetails/EditImage.js.map +1 -0
- package/presentation/FileActions/index.js +8 -0
- package/presentation/FileActions/index.js.map +1 -1
- package/presentation/FileDetails/FileDetailsPresenter.d.ts +5 -4
- package/presentation/FileDetails/FileDetailsPresenter.js +40 -46
- package/presentation/FileDetails/FileDetailsPresenter.js.map +1 -1
- package/presentation/FileDetails/FileDetailsPresenter.test.js +39 -56
- package/presentation/FileDetails/FileDetailsPresenter.test.js.map +1 -1
- package/presentation/FileDetails/abstractions.d.ts +2 -0
- package/presentation/FileDetails/abstractions.js.map +1 -1
- package/presentation/FileDetails/components/Content.d.ts +6 -4
- package/presentation/FileDetails/components/Content.js +2 -2
- package/presentation/FileDetails/components/Content.js.map +1 -1
- package/presentation/FileDetails/components/FileDetailsDrawer.d.ts +2 -2
- package/presentation/FileDetails/components/FileDetailsDrawer.js +11 -5
- package/presentation/FileDetails/components/FileDetailsDrawer.js.map +1 -1
- package/presentation/FileList/FileListDataSource.d.ts +8 -12
- package/presentation/FileList/FileListDataSource.js +47 -87
- package/presentation/FileList/FileListDataSource.js.map +1 -1
- package/presentation/FileList/FileListPresenter.test.js +9 -3
- package/presentation/FileList/FileListPresenter.test.js.map +1 -1
- package/presentation/FileList/FileManagerPresenter.d.ts +1 -0
- package/presentation/FileList/FileManagerPresenter.js +15 -5
- package/presentation/FileList/FileManagerPresenter.js.map +1 -1
- package/presentation/FileList/abstractions.d.ts +3 -0
- package/presentation/FileList/abstractions.js.map +1 -1
- package/presentation/FileList/components/BulkActions/BulkActionBar.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/BulkActionDelete.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/BulkActionMove.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/index.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/index.js +0 -1
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.d.ts +9 -8
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.js +3 -9
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.js.map +1 -1
- package/presentation/FileList/components/Filters/SubFoldersToggle.d.ts +2 -2
- package/presentation/FileList/components/Filters/TagsFilter.d.ts +2 -2
- package/presentation/FileList/components/Filters/TypeFilter.d.ts +2 -2
- package/presentation/FileList/components/Grid/FileGrid.d.ts +2 -2
- package/presentation/FileList/components/Grid/FileGrid.js +1 -1
- package/presentation/FileList/components/Grid/FileGrid.js.map +1 -1
- package/presentation/FileList/components/Grid/FileGrid.test.js +18 -7
- package/presentation/FileList/components/Grid/FileGrid.test.js.map +1 -1
- package/presentation/FileList/components/Header/FileManagerHeader.d.ts +2 -2
- package/presentation/FileList/components/Search/SearchBar.d.ts +2 -2
- package/presentation/FileList/components/Table/FileTable.d.ts +2 -2
- package/presentation/FileList/components/Table/FileTable.js +1 -1
- package/presentation/FileList/components/Table/FileTable.js.map +1 -1
- package/presentation/FileList/components/Table/FileTable.test.js +9 -4
- package/presentation/FileList/components/Table/FileTable.test.js.map +1 -1
- package/presentation/FileList/components/Upload/UploadProgress.d.ts +2 -2
- package/presentation/FileManager/FileManagerBreadcrumbs.d.ts +12 -0
- package/presentation/FileManager/FileManagerBreadcrumbs.js +37 -0
- package/presentation/FileManager/FileManagerBreadcrumbs.js.map +1 -0
- package/presentation/FileManager/FileManagerView.js +36 -2
- package/presentation/FileManager/FileManagerView.js.map +1 -1
- package/presentation/FileManager/RouteParamsSync.d.ts +2 -0
- package/presentation/FileManager/RouteParamsSync.js +30 -0
- package/presentation/FileManager/RouteParamsSync.js.map +1 -0
- package/presentation/Settings/components/SettingsView.d.ts +2 -2
- package/presentation/config/DefaultFileManagerConfig.js +13 -11
- package/presentation/config/DefaultFileManagerConfig.js.map +1 -1
- package/presentation/config/FileManagerViewConfig.d.ts +19 -25
- package/presentation/config/configComponents/Browser/BulkAction.d.ts +10 -8
- package/presentation/config/configComponents/Browser/BulkAction.js +3 -9
- package/presentation/config/configComponents/Browser/BulkAction.js.map +1 -1
- package/presentation/config/configComponents/Browser/FileAction.d.ts +2 -1
- package/presentation/config/configComponents/Browser/FolderAction.d.ts +2 -1
- package/presentation/config/configComponents/Browser/Table/Column.d.ts +9 -8
- package/presentation/config/configComponents/Browser/Table/index.d.ts +9 -9
- package/presentation/config/configComponents/Browser/index.d.ts +20 -20
- package/presentation/config/configComponents/Browser/index.js +0 -8
- package/presentation/config/configComponents/Browser/index.js.map +1 -1
- package/presentation/config/configComponents/FileDetails/index.d.ts +4 -2
- package/presentation/config/thumbnailRenderers/CroppedFileImage.d.ts +18 -0
- package/presentation/config/thumbnailRenderers/CroppedFileImage.js +66 -0
- package/presentation/config/thumbnailRenderers/CroppedFileImage.js.map +1 -0
- package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js.map +1 -1
- package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js.map +1 -1
- package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js.map +1 -1
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.d.ts +22 -0
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.js +56 -0
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.d.ts +13 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.js +36 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.d.ts +7 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.js +32 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.js.map +1 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.d.ts +18 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js +88 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.d.ts +13 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js +60 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.d.ts +15 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.js +25 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.js.map +1 -0
- package/presentation/fieldRenderers/assetValue.d.ts +10 -0
- package/presentation/fieldRenderers/assetValue.js +88 -0
- package/presentation/fieldRenderers/assetValue.js.map +1 -0
- package/presentation/hooks/useCmsImageEditor.d.ts +10 -0
- package/presentation/hooks/useCmsImageEditor.js +76 -0
- package/presentation/hooks/useCmsImageEditor.js.map +1 -0
- package/presentation/hooks/useEditImage.d.ts +14 -0
- package/presentation/hooks/useEditImage.js +67 -0
- package/presentation/hooks/useEditImage.js.map +1 -0
- package/routes.d.ts +1 -0
- package/routes.js +2 -1
- package/routes.js.map +1 -1
- package/modules/HeadlessCms/fileField.d.ts +0 -2
- package/modules/HeadlessCms/fileField.js +0 -44
- package/modules/HeadlessCms/fileField.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/fileField.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/fileField.js +0 -53
- package/modules/HeadlessCms/fileRenderer/fileField.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/fileFields.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/fileFields.js +0 -73
- package/modules/HeadlessCms/fileRenderer/fileFields.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/utils.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/utils.js +0 -15
- package/modules/HeadlessCms/fileRenderer/utils.js.map +0 -1
- package/modules/HeadlessCms/index.d.ts +0 -1
- package/modules/HeadlessCms/index.js +0 -14
- package/modules/HeadlessCms/index.js.map +0 -1
- package/modules/Settings/graphql.d.ts +0 -12
- package/modules/Settings/graphql.js +0 -36
- package/modules/Settings/graphql.js.map +0 -1
- package/modules/Settings/views/FileManagerSettings.d.ts +0 -2
- package/modules/Settings/views/FileManagerSettings.js +0 -134
- package/modules/Settings/views/FileManagerSettings.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.d.ts +0 -7
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.js +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.d.ts +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js +0 -44
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.d.ts +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js +0 -52
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.d.ts +0 -61
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js +0 -111
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js +0 -372
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.d.ts +0 -8
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js +0 -31
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.d.ts +0 -11
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js +0 -33
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/index.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/index.js +0 -1
- package/presentation/FileList/components/BulkActions/BulkActionEdit.d.ts +0 -4
- package/presentation/FileList/components/BulkActions/BulkActionEdit.js +0 -105
- package/presentation/FileList/components/BulkActions/BulkActionEdit.js.map +0 -1
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.d.ts +0 -7
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.js +0 -11
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.js.map +0 -1
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import react, { useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import { Drawer } from "@webiny/admin-ui";
|
|
3
|
-
import { observer } from "mobx-react-lite";
|
|
4
|
-
import { BatchEditorDialogPresenter } from "./BatchEditorDialogPresenter.js";
|
|
5
|
-
import { BatchEditor } from "./BatchEditor.js";
|
|
6
|
-
const BatchEditorDialog = observer((props)=>{
|
|
7
|
-
const presenter = useMemo(()=>new BatchEditorDialogPresenter(), []);
|
|
8
|
-
const ref = useRef(null);
|
|
9
|
-
useEffect(()=>{
|
|
10
|
-
presenter.load(props.batch, props.fields);
|
|
11
|
-
}, [
|
|
12
|
-
props.batch,
|
|
13
|
-
props.fields
|
|
14
|
-
]);
|
|
15
|
-
const onChange = (data)=>{
|
|
16
|
-
presenter.setBatch(data);
|
|
17
|
-
};
|
|
18
|
-
const onApply = ()=>{
|
|
19
|
-
ref.current?.validate().then((isValid)=>{
|
|
20
|
-
if (isValid) presenter.onApply((batch)=>{
|
|
21
|
-
props.onApply(batch);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
return /*#__PURE__*/ react.createElement(Drawer, {
|
|
26
|
-
open: props.vm.isOpen,
|
|
27
|
-
onClose: props.onClose,
|
|
28
|
-
modal: true,
|
|
29
|
-
width: 800,
|
|
30
|
-
headerSeparator: true,
|
|
31
|
-
footerSeparator: true,
|
|
32
|
-
title: "Edit items",
|
|
33
|
-
actions: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Drawer.CancelButton, {
|
|
34
|
-
text: "Cancel",
|
|
35
|
-
onClick: props.onClose
|
|
36
|
-
}), /*#__PURE__*/ react.createElement(Drawer.ConfirmButton, {
|
|
37
|
-
onClick: onApply,
|
|
38
|
-
text: "Submit"
|
|
39
|
-
}))
|
|
40
|
-
}, /*#__PURE__*/ react.createElement(BatchEditor, {
|
|
41
|
-
onForm: (form)=>ref.current = form,
|
|
42
|
-
onChange: (data)=>onChange(data),
|
|
43
|
-
onSubmit: onApply,
|
|
44
|
-
onDelete: (operationIndex)=>presenter.deleteOperation(operationIndex),
|
|
45
|
-
onAdd: ()=>presenter.addOperation(),
|
|
46
|
-
onSetOperationFieldData: (operationIndex, data)=>presenter.setOperationFieldData(operationIndex, data),
|
|
47
|
-
vm: presenter.vm
|
|
48
|
-
}));
|
|
49
|
-
});
|
|
50
|
-
export { BatchEditorDialog };
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=BatchEditorDialog.js.map
|
package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js","sources":["../../../../../../src/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.tsx"],"sourcesContent":["import React, { useMemo, useEffect, useRef } from \"react\";\n\nimport { Drawer } from \"@webiny/admin-ui\";\nimport { observer } from \"mobx-react-lite\";\nimport type { FormAPI } from \"@webiny/form\";\n\nimport type { BatchEditorFormData } from \"./BatchEditorDialogPresenter.js\";\nimport { BatchEditorDialogPresenter } from \"./BatchEditorDialogPresenter.js\";\nimport { BatchEditor } from \"~/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js\";\nimport type {\n BatchDTO,\n FieldDTO\n} from \"~/presentation/FileList/components/BulkActions/domain/index.js\";\n\ninterface BatchEditorDialogProps {\n fields: FieldDTO[];\n batch: BatchDTO;\n vm: {\n isOpen: boolean;\n };\n onApply: (batch: BatchDTO) => void;\n onClose: () => void;\n}\n\nexport const BatchEditorDialog = observer((props: BatchEditorDialogProps) => {\n const presenter = useMemo<BatchEditorDialogPresenter>(() => {\n return new BatchEditorDialogPresenter();\n }, []);\n\n const ref = useRef<FormAPI | null>(null);\n\n useEffect(() => {\n presenter.load(props.batch, props.fields);\n }, [props.batch, props.fields]);\n\n const onChange = (data: BatchEditorFormData) => {\n presenter.setBatch(data);\n };\n\n const onApply = () => {\n ref.current?.validate().then(isValid => {\n if (isValid) {\n presenter.onApply(batch => {\n props.onApply(batch);\n });\n }\n });\n };\n\n return (\n <Drawer\n open={props.vm.isOpen}\n onClose={props.onClose}\n modal={true}\n width={800}\n headerSeparator={true}\n footerSeparator={true}\n title={\"Edit items\"}\n actions={\n <>\n <Drawer.CancelButton text={\"Cancel\"} onClick={props.onClose} />\n <Drawer.ConfirmButton onClick={onApply} text={\"Submit\"} />\n </>\n }\n >\n <BatchEditor\n onForm={form => (ref.current = form)}\n onChange={data => onChange(data)}\n onSubmit={onApply}\n onDelete={operationIndex => presenter.deleteOperation(operationIndex)}\n onAdd={() => presenter.addOperation()}\n onSetOperationFieldData={(operationIndex, data) =>\n presenter.setOperationFieldData(operationIndex, data)\n }\n vm={presenter.vm}\n />\n </Drawer>\n );\n});\n"],"names":["BatchEditorDialog","observer","props","presenter","useMemo","BatchEditorDialogPresenter","ref","useRef","useEffect","onChange","data","onApply","isValid","batch","Drawer","BatchEditor","form","operationIndex"],"mappings":";;;;;AAwBO,MAAMA,oBAAoBC,SAAS,CAACC;IACvC,MAAMC,YAAYC,QAAoC,IAC3C,IAAIC,8BACZ,EAAE;IAEL,MAAMC,MAAMC,OAAuB;IAEnCC,UAAU;QACNL,UAAU,IAAI,CAACD,MAAM,KAAK,EAAEA,MAAM,MAAM;IAC5C,GAAG;QAACA,MAAM,KAAK;QAAEA,MAAM,MAAM;KAAC;IAE9B,MAAMO,WAAW,CAACC;QACdP,UAAU,QAAQ,CAACO;IACvB;IAEA,MAAMC,UAAU;QACZL,IAAI,OAAO,EAAE,WAAW,KAAKM,CAAAA;YACzB,IAAIA,SACAT,UAAU,OAAO,CAACU,CAAAA;gBACdX,MAAM,OAAO,CAACW;YAClB;QAER;IACJ;IAEA,OAAO,WAAP,GACI,oBAACC,QAAMA;QACH,MAAMZ,MAAM,EAAE,CAAC,MAAM;QACrB,SAASA,MAAM,OAAO;QACtB,OAAO;QACP,OAAO;QACP,iBAAiB;QACjB,iBAAiB;QACjB,OAAO;QACP,uBACI,wDACI,oBAACY,OAAO,YAAY;YAAC,MAAM;YAAU,SAASZ,MAAM,OAAO;0BAC3D,oBAACY,OAAO,aAAa;YAAC,SAASH;YAAS,MAAM;;qBAItD,oBAACI,aAAWA;QACR,QAAQC,CAAAA,OAASV,IAAI,OAAO,GAAGU;QAC/B,UAAUN,CAAAA,OAAQD,SAASC;QAC3B,UAAUC;QACV,UAAUM,CAAAA,iBAAkBd,UAAU,eAAe,CAACc;QACtD,OAAO,IAAMd,UAAU,YAAY;QACnC,yBAAyB,CAACc,gBAAgBP,OACtCP,UAAU,qBAAqB,CAACc,gBAAgBP;QAEpD,IAAIP,UAAU,EAAE;;AAIhC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { BatchDTO, FieldDTO, OperationDTO, OperatorDTO } from "../../../../../presentation/FileList/components/BulkActions/domain/index.js";
|
|
2
|
-
import type { FormInvalidFields } from "@webiny/form";
|
|
3
|
-
export interface IBatchEditorDialogPresenter {
|
|
4
|
-
load(batch: BatchDTO, fields: FieldDTO[]): void;
|
|
5
|
-
addOperation(): void;
|
|
6
|
-
deleteOperation(operationIndex: number): void;
|
|
7
|
-
setOperationFieldData(operationIndex: number, data: string): void;
|
|
8
|
-
setBatch(data: any): void;
|
|
9
|
-
onApply(onSuccess?: (batch: BatchDTO) => void, onError?: (batch: BatchDTO) => void): void;
|
|
10
|
-
get vm(): BatchEditorDialogViewModel;
|
|
11
|
-
}
|
|
12
|
-
export interface BatchEditorDialogViewModel {
|
|
13
|
-
invalidFields: FormInvalidFields;
|
|
14
|
-
canAddOperation: boolean;
|
|
15
|
-
data: BatchEditorFormData;
|
|
16
|
-
}
|
|
17
|
-
export interface BatchEditorFormData {
|
|
18
|
-
operations: OperationFormData[];
|
|
19
|
-
}
|
|
20
|
-
export type OperationFormData = OperationDTO & {
|
|
21
|
-
canDelete: boolean;
|
|
22
|
-
title: string;
|
|
23
|
-
open: boolean;
|
|
24
|
-
fieldOptions: FieldDTO[];
|
|
25
|
-
operatorOptions: OperatorDTO[];
|
|
26
|
-
selectedField?: FieldDTO;
|
|
27
|
-
};
|
|
28
|
-
export declare class BatchEditorDialogPresenter implements IBatchEditorDialogPresenter {
|
|
29
|
-
private batch;
|
|
30
|
-
private fields;
|
|
31
|
-
private invalidFields;
|
|
32
|
-
private formWasSubmitted;
|
|
33
|
-
constructor();
|
|
34
|
-
load(batch: BatchDTO, fields: FieldDTO[]): void;
|
|
35
|
-
get vm(): {
|
|
36
|
-
invalidFields: FormInvalidFields;
|
|
37
|
-
canAddOperation: boolean;
|
|
38
|
-
data: {
|
|
39
|
-
operations: {
|
|
40
|
-
title: string;
|
|
41
|
-
open: boolean;
|
|
42
|
-
field: string;
|
|
43
|
-
operator: string;
|
|
44
|
-
value: Record<string, any> | undefined;
|
|
45
|
-
canDelete: boolean;
|
|
46
|
-
fieldOptions: FieldDTO[];
|
|
47
|
-
selectedField: FieldDTO | undefined;
|
|
48
|
-
operatorOptions: OperatorDTO[];
|
|
49
|
-
}[];
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
addOperation(): void;
|
|
53
|
-
deleteOperation(operationIndex: number): void;
|
|
54
|
-
setOperationFieldData(batchIndex: number, data: string): void;
|
|
55
|
-
setBatch(data: BatchEditorFormData): void;
|
|
56
|
-
onApply(onSuccess?: (batch: BatchDTO) => void, onError?: (batch: BatchDTO, invalidFields: BatchEditorDialogViewModel["invalidFields"]) => void): void;
|
|
57
|
-
private getOperations;
|
|
58
|
-
private getOperationTitle;
|
|
59
|
-
private getFieldOptions;
|
|
60
|
-
private validateBatch;
|
|
61
|
-
}
|
package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { makeAutoObservable } from "mobx";
|
|
2
|
-
import { Batch } from "../domain/index.js";
|
|
3
|
-
class BatchEditorDialogPresenter {
|
|
4
|
-
constructor(){
|
|
5
|
-
this.invalidFields = {};
|
|
6
|
-
this.formWasSubmitted = false;
|
|
7
|
-
this.getOperations = ()=>this.batch?.operations.map((operation, operationIndex)=>{
|
|
8
|
-
const fieldOptions = this.getFieldOptions(operation.field);
|
|
9
|
-
const selectedField = fieldOptions.find((field)=>field.value === operation.field);
|
|
10
|
-
const operatorOptions = selectedField?.operators || [];
|
|
11
|
-
return {
|
|
12
|
-
title: this.getOperationTitle(operation.field, operation.operator) ?? `Operation #${operationIndex + 1}`,
|
|
13
|
-
open: true,
|
|
14
|
-
field: operation.field,
|
|
15
|
-
operator: operation.operator,
|
|
16
|
-
value: operation.value,
|
|
17
|
-
canDelete: 0 !== operationIndex,
|
|
18
|
-
fieldOptions,
|
|
19
|
-
selectedField,
|
|
20
|
-
operatorOptions
|
|
21
|
-
};
|
|
22
|
-
}) || [];
|
|
23
|
-
this.batch = void 0;
|
|
24
|
-
this.fields = [];
|
|
25
|
-
makeAutoObservable(this);
|
|
26
|
-
}
|
|
27
|
-
load(batch, fields) {
|
|
28
|
-
this.batch = batch;
|
|
29
|
-
this.fields = fields;
|
|
30
|
-
}
|
|
31
|
-
get vm() {
|
|
32
|
-
const operations = this.getOperations();
|
|
33
|
-
const canAddOperation = operations[operations.length - 1]?.fieldOptions.length > 1 || false;
|
|
34
|
-
return {
|
|
35
|
-
invalidFields: this.invalidFields,
|
|
36
|
-
canAddOperation,
|
|
37
|
-
data: {
|
|
38
|
-
operations
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
addOperation() {
|
|
43
|
-
if (!this.batch) return;
|
|
44
|
-
this.batch.operations.push({
|
|
45
|
-
field: "",
|
|
46
|
-
operator: "",
|
|
47
|
-
value: void 0
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
deleteOperation(operationIndex) {
|
|
51
|
-
if (!this.batch) return;
|
|
52
|
-
this.batch.operations = this.batch.operations.filter((_, index)=>index !== operationIndex);
|
|
53
|
-
if (0 === this.batch.operations.length) this.addOperation();
|
|
54
|
-
}
|
|
55
|
-
setOperationFieldData(batchIndex, data) {
|
|
56
|
-
if (!this.batch) return;
|
|
57
|
-
this.batch.operations = [
|
|
58
|
-
...this.batch.operations.slice(0, batchIndex),
|
|
59
|
-
{
|
|
60
|
-
field: data,
|
|
61
|
-
operator: "",
|
|
62
|
-
value: void 0
|
|
63
|
-
},
|
|
64
|
-
...this.batch.operations.slice(batchIndex + 1)
|
|
65
|
-
];
|
|
66
|
-
}
|
|
67
|
-
setBatch(data) {
|
|
68
|
-
if (!this.batch) return;
|
|
69
|
-
this.batch = {
|
|
70
|
-
...this.batch,
|
|
71
|
-
operations: data.operations.map((operation)=>({
|
|
72
|
-
field: operation.field,
|
|
73
|
-
operator: operation.operator,
|
|
74
|
-
value: operation.value
|
|
75
|
-
}))
|
|
76
|
-
};
|
|
77
|
-
if (this.formWasSubmitted) this.validateBatch(this.batch);
|
|
78
|
-
}
|
|
79
|
-
onApply(onSuccess, onError) {
|
|
80
|
-
if (!this.batch) return;
|
|
81
|
-
const result = this.validateBatch(this.batch);
|
|
82
|
-
if (result.success) onSuccess && onSuccess(this.batch);
|
|
83
|
-
else onError && onError(this.batch, this.invalidFields);
|
|
84
|
-
}
|
|
85
|
-
getOperationTitle(inputField, inputOperation) {
|
|
86
|
-
if (!inputField || !inputOperation) return;
|
|
87
|
-
const field = this.fields.find((field)=>field.value === inputField);
|
|
88
|
-
if (!field) return;
|
|
89
|
-
const operator = field.operators.find((operator)=>operator.value === inputOperation);
|
|
90
|
-
if (!operator) return;
|
|
91
|
-
return `${operator.label} for field "${field.label}"`;
|
|
92
|
-
}
|
|
93
|
-
getFieldOptions(currentFieldId = "") {
|
|
94
|
-
if (!this.batch) return [];
|
|
95
|
-
const existings = this.batch.operations.filter((operation)=>operation.field !== currentFieldId).map((operation)=>operation.field);
|
|
96
|
-
return this.fields.filter((field)=>!existings.includes(field.value));
|
|
97
|
-
}
|
|
98
|
-
validateBatch(data) {
|
|
99
|
-
this.formWasSubmitted = true;
|
|
100
|
-
const validation = Batch.validate(data);
|
|
101
|
-
if (validation.success) this.invalidFields = {};
|
|
102
|
-
else this.invalidFields = validation.error.issues.reduce((acc, issue)=>({
|
|
103
|
-
...acc,
|
|
104
|
-
[issue.path.join(".")]: issue.message
|
|
105
|
-
}), {});
|
|
106
|
-
return validation;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export { BatchEditorDialogPresenter };
|
|
110
|
-
|
|
111
|
-
//# sourceMappingURL=BatchEditorDialogPresenter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js","sources":["../../../../../../src/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.tsx"],"sourcesContent":["import { makeAutoObservable } from \"mobx\";\n\nimport type {\n BatchDTO,\n FieldDTO,\n OperationDTO,\n OperatorDTO\n} from \"~/presentation/FileList/components/BulkActions/domain/index.js\";\nimport { Batch } from \"~/presentation/FileList/components/BulkActions/domain/index.js\";\nimport type { FormInvalidFields } from \"@webiny/form\";\n\nexport interface IBatchEditorDialogPresenter {\n load(batch: BatchDTO, fields: FieldDTO[]): void;\n addOperation(): void;\n deleteOperation(operationIndex: number): void;\n setOperationFieldData(operationIndex: number, data: string): void;\n setBatch(data: any): void;\n onApply(onSuccess?: (batch: BatchDTO) => void, onError?: (batch: BatchDTO) => void): void;\n get vm(): BatchEditorDialogViewModel;\n}\n\nexport interface BatchEditorDialogViewModel {\n invalidFields: FormInvalidFields;\n canAddOperation: boolean;\n data: BatchEditorFormData;\n}\n\nexport interface BatchEditorFormData {\n operations: OperationFormData[];\n}\n\nexport type OperationFormData = OperationDTO & {\n canDelete: boolean;\n title: string;\n open: boolean;\n fieldOptions: FieldDTO[];\n operatorOptions: OperatorDTO[];\n selectedField?: FieldDTO;\n};\n\nexport class BatchEditorDialogPresenter implements IBatchEditorDialogPresenter {\n private batch: BatchDTO | undefined;\n private fields: FieldDTO[];\n private invalidFields: BatchEditorDialogViewModel[\"invalidFields\"] = {};\n private formWasSubmitted = false;\n\n constructor() {\n this.batch = undefined;\n this.fields = [];\n makeAutoObservable(this);\n }\n\n load(batch: BatchDTO, fields: FieldDTO[]) {\n this.batch = batch;\n this.fields = fields;\n }\n\n get vm() {\n const operations = this.getOperations();\n const canAddOperation = operations[operations.length - 1]?.fieldOptions.length > 1 || false;\n\n return {\n invalidFields: this.invalidFields,\n canAddOperation,\n data: {\n operations\n }\n };\n }\n\n addOperation(): void {\n if (!this.batch) {\n return;\n }\n\n this.batch.operations.push({\n field: \"\",\n operator: \"\",\n value: undefined\n });\n }\n\n deleteOperation(operationIndex: number): void {\n if (!this.batch) {\n return;\n }\n\n this.batch.operations = this.batch.operations.filter(\n (_, index) => index !== operationIndex\n );\n\n // Make sure we always have at least 1 operation!\n if (this.batch.operations.length === 0) {\n this.addOperation();\n }\n }\n\n setOperationFieldData(batchIndex: number, data: string) {\n if (!this.batch) {\n return;\n }\n\n this.batch.operations = [\n ...this.batch.operations.slice(0, batchIndex),\n {\n field: data,\n operator: \"\",\n value: undefined\n },\n ...this.batch.operations.slice(batchIndex + 1)\n ];\n }\n\n setBatch(data: BatchEditorFormData): void {\n if (!this.batch) {\n return;\n }\n\n this.batch = {\n ...this.batch,\n operations: data.operations.map(operation => ({\n field: operation.field,\n operator: operation.operator,\n value: operation.value\n }))\n };\n\n if (this.formWasSubmitted) {\n this.validateBatch(this.batch);\n }\n }\n\n onApply(\n onSuccess?: (batch: BatchDTO) => void,\n onError?: (\n batch: BatchDTO,\n invalidFields: BatchEditorDialogViewModel[\"invalidFields\"]\n ) => void\n ) {\n if (!this.batch) {\n return;\n }\n\n const result = this.validateBatch(this.batch);\n if (result.success) {\n onSuccess && onSuccess(this.batch);\n } else {\n onError && onError(this.batch, this.invalidFields);\n }\n }\n\n private getOperations = () => {\n return (\n this.batch?.operations.map((operation: OperationDTO, operationIndex) => {\n const fieldOptions = this.getFieldOptions(operation.field);\n const selectedField = fieldOptions.find(field => field.value === operation.field);\n const operatorOptions = selectedField?.operators || [];\n\n return {\n title:\n this.getOperationTitle(operation.field, operation.operator) ??\n `Operation #${operationIndex + 1}`,\n open: true,\n field: operation.field,\n operator: operation.operator,\n value: operation.value,\n canDelete: operationIndex !== 0,\n fieldOptions,\n selectedField,\n operatorOptions\n };\n }) || []\n );\n };\n\n private getOperationTitle(inputField?: string, inputOperation?: string) {\n if (!inputField || !inputOperation) {\n return undefined;\n }\n\n const field = this.fields.find(field => field.value === inputField);\n\n if (!field) {\n return undefined;\n }\n\n const operator = field.operators.find(operator => operator.value === inputOperation);\n\n if (!operator) {\n return undefined;\n }\n\n return `${operator.label} for field \"${field.label}\"`;\n }\n\n private getFieldOptions(currentFieldId = \"\") {\n if (!this.batch) {\n return [];\n }\n\n const existings = this.batch.operations\n .filter(operation => operation.field !== currentFieldId)\n .map(operation => operation.field);\n\n return this.fields.filter(field => !existings.includes(field.value));\n }\n\n private validateBatch(data: BatchDTO) {\n this.formWasSubmitted = true;\n const validation = Batch.validate(data);\n\n if (!validation.success) {\n this.invalidFields = validation.error.issues.reduce((acc, issue) => {\n return {\n ...acc,\n [issue.path.join(\".\")]: issue.message\n };\n }, {});\n } else {\n this.invalidFields = {};\n }\n\n return validation;\n }\n}\n"],"names":["BatchEditorDialogPresenter","operation","operationIndex","fieldOptions","selectedField","field","operatorOptions","undefined","makeAutoObservable","batch","fields","operations","canAddOperation","_","index","batchIndex","data","onSuccess","onError","result","inputField","inputOperation","operator","currentFieldId","existings","validation","Batch","acc","issue"],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
import { BatchEditorDialogPresenter } from "./BatchEditorDialogPresenter.js";
|
|
2
|
-
import { OperatorType } from "../domain/index.js";
|
|
3
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
-
describe("BatchEditorDialogPresenter", ()=>{
|
|
5
|
-
const batch = {
|
|
6
|
-
operations: [
|
|
7
|
-
{
|
|
8
|
-
field: "",
|
|
9
|
-
operator: "",
|
|
10
|
-
value: void 0
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
};
|
|
14
|
-
const fields = [
|
|
15
|
-
{
|
|
16
|
-
label: "Field 1",
|
|
17
|
-
value: "field1",
|
|
18
|
-
operators: [
|
|
19
|
-
{
|
|
20
|
-
label: "Override existing values",
|
|
21
|
-
value: OperatorType.OVERRIDE
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
label: "Clear all existing values",
|
|
25
|
-
value: OperatorType.REMOVE
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
raw: {
|
|
29
|
-
id: "field1",
|
|
30
|
-
fieldId: "field1",
|
|
31
|
-
label: "Field 1",
|
|
32
|
-
type: "text",
|
|
33
|
-
renderer: {
|
|
34
|
-
name: "text-input"
|
|
35
|
-
},
|
|
36
|
-
tags: [
|
|
37
|
-
"$bulk-edit"
|
|
38
|
-
],
|
|
39
|
-
storageId: "text@field1"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
label: "Field 2",
|
|
44
|
-
value: "field2",
|
|
45
|
-
operators: [
|
|
46
|
-
{
|
|
47
|
-
label: "Override existing values",
|
|
48
|
-
value: OperatorType.OVERRIDE
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
label: "Clear all existing values",
|
|
52
|
-
value: OperatorType.REMOVE
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
raw: {
|
|
56
|
-
id: "field2",
|
|
57
|
-
fieldId: "field2",
|
|
58
|
-
label: "Field 1",
|
|
59
|
-
type: "text",
|
|
60
|
-
renderer: {
|
|
61
|
-
name: "text-input"
|
|
62
|
-
},
|
|
63
|
-
tags: [
|
|
64
|
-
"$bulk-edit"
|
|
65
|
-
],
|
|
66
|
-
storageId: "text@field2"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
];
|
|
70
|
-
const operators = [
|
|
71
|
-
{
|
|
72
|
-
value: OperatorType.OVERRIDE,
|
|
73
|
-
label: "Override existing values"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
value: OperatorType.REMOVE,
|
|
77
|
-
label: "Clear all existing values"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
value: OperatorType.APPEND,
|
|
81
|
-
label: "Append to existing values"
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
|
-
let presenter;
|
|
85
|
-
beforeEach(()=>{
|
|
86
|
-
vi.clearAllMocks();
|
|
87
|
-
presenter = new BatchEditorDialogPresenter();
|
|
88
|
-
});
|
|
89
|
-
it("should load data", ()=>{
|
|
90
|
-
presenter.load(batch, fields);
|
|
91
|
-
expect(presenter.vm.data).toEqual({
|
|
92
|
-
operations: [
|
|
93
|
-
{
|
|
94
|
-
title: "Operation #1",
|
|
95
|
-
open: true,
|
|
96
|
-
canDelete: false,
|
|
97
|
-
field: "",
|
|
98
|
-
operator: "",
|
|
99
|
-
value: void 0,
|
|
100
|
-
fieldOptions: fields,
|
|
101
|
-
operatorOptions: [],
|
|
102
|
-
selectedField: void 0
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
|
-
});
|
|
106
|
-
expect(presenter.vm.invalidFields).toEqual({});
|
|
107
|
-
expect(presenter.vm.canAddOperation).toEqual(true);
|
|
108
|
-
});
|
|
109
|
-
it("should be able to add and delete operations", ()=>{
|
|
110
|
-
presenter.load(batch, fields);
|
|
111
|
-
expect(presenter.vm.data.operations.length).toBe(1);
|
|
112
|
-
expect(presenter.vm.data.operations).toEqual([
|
|
113
|
-
{
|
|
114
|
-
title: "Operation #1",
|
|
115
|
-
open: true,
|
|
116
|
-
field: "",
|
|
117
|
-
operator: "",
|
|
118
|
-
value: void 0,
|
|
119
|
-
canDelete: false,
|
|
120
|
-
fieldOptions: fields,
|
|
121
|
-
operatorOptions: [],
|
|
122
|
-
selectedField: void 0
|
|
123
|
-
}
|
|
124
|
-
]);
|
|
125
|
-
presenter.addOperation();
|
|
126
|
-
expect(presenter.vm.data.operations.length).toBe(2);
|
|
127
|
-
expect(presenter.vm.data.operations).toEqual([
|
|
128
|
-
{
|
|
129
|
-
title: "Operation #1",
|
|
130
|
-
open: true,
|
|
131
|
-
field: "",
|
|
132
|
-
operator: "",
|
|
133
|
-
value: void 0,
|
|
134
|
-
canDelete: false,
|
|
135
|
-
fieldOptions: fields,
|
|
136
|
-
operatorOptions: [],
|
|
137
|
-
selectedField: void 0
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
title: "Operation #2",
|
|
141
|
-
open: true,
|
|
142
|
-
field: "",
|
|
143
|
-
operator: "",
|
|
144
|
-
value: void 0,
|
|
145
|
-
canDelete: true,
|
|
146
|
-
fieldOptions: fields,
|
|
147
|
-
operatorOptions: [],
|
|
148
|
-
selectedField: void 0
|
|
149
|
-
}
|
|
150
|
-
]);
|
|
151
|
-
presenter.deleteOperation(0);
|
|
152
|
-
expect(presenter.vm.data.operations.length).toBe(1);
|
|
153
|
-
expect(presenter.vm.data.operations).toEqual([
|
|
154
|
-
{
|
|
155
|
-
title: "Operation #1",
|
|
156
|
-
open: true,
|
|
157
|
-
field: "",
|
|
158
|
-
operator: "",
|
|
159
|
-
value: void 0,
|
|
160
|
-
canDelete: false,
|
|
161
|
-
fieldOptions: fields,
|
|
162
|
-
operatorOptions: [],
|
|
163
|
-
selectedField: void 0
|
|
164
|
-
}
|
|
165
|
-
]);
|
|
166
|
-
presenter.deleteOperation(0);
|
|
167
|
-
expect(presenter.vm.data.operations.length).toBe(1);
|
|
168
|
-
expect(presenter.vm.data.operations).toEqual([
|
|
169
|
-
{
|
|
170
|
-
title: "Operation #1",
|
|
171
|
-
open: true,
|
|
172
|
-
field: "",
|
|
173
|
-
operator: "",
|
|
174
|
-
value: void 0,
|
|
175
|
-
canDelete: false,
|
|
176
|
-
fieldOptions: fields,
|
|
177
|
-
operatorOptions: [],
|
|
178
|
-
selectedField: void 0
|
|
179
|
-
}
|
|
180
|
-
]);
|
|
181
|
-
});
|
|
182
|
-
it("should be able to handle the `fieldOptions` based operations set in the batch", ()=>{
|
|
183
|
-
presenter.load(batch, fields);
|
|
184
|
-
presenter.setBatch({
|
|
185
|
-
operations: [
|
|
186
|
-
{
|
|
187
|
-
title: `Override existing values for field "${fields[0].label}"`,
|
|
188
|
-
open: true,
|
|
189
|
-
field: fields[0].value,
|
|
190
|
-
operator: OperatorType.OVERRIDE,
|
|
191
|
-
value: {
|
|
192
|
-
[fields[0].value]: "newValue"
|
|
193
|
-
},
|
|
194
|
-
canDelete: false,
|
|
195
|
-
fieldOptions: fields,
|
|
196
|
-
operatorOptions: [
|
|
197
|
-
operators[0],
|
|
198
|
-
operators[1]
|
|
199
|
-
],
|
|
200
|
-
selectedField: fields[0]
|
|
201
|
-
}
|
|
202
|
-
]
|
|
203
|
-
});
|
|
204
|
-
expect(presenter.vm.canAddOperation).toBeTruthy();
|
|
205
|
-
presenter.addOperation();
|
|
206
|
-
expect(presenter.vm.data.operations[1]).toEqual({
|
|
207
|
-
title: "Operation #2",
|
|
208
|
-
open: true,
|
|
209
|
-
field: "",
|
|
210
|
-
operator: "",
|
|
211
|
-
value: void 0,
|
|
212
|
-
canDelete: true,
|
|
213
|
-
fieldOptions: [
|
|
214
|
-
fields[1]
|
|
215
|
-
],
|
|
216
|
-
operatorOptions: [],
|
|
217
|
-
selectedField: void 0
|
|
218
|
-
});
|
|
219
|
-
presenter.setBatch({
|
|
220
|
-
operations: [
|
|
221
|
-
{
|
|
222
|
-
title: `Override existing values for field "${fields[0].label}"`,
|
|
223
|
-
open: true,
|
|
224
|
-
field: fields[0].value,
|
|
225
|
-
operator: OperatorType.OVERRIDE,
|
|
226
|
-
value: {
|
|
227
|
-
[fields[0].value]: "newValue"
|
|
228
|
-
},
|
|
229
|
-
canDelete: false,
|
|
230
|
-
fieldOptions: fields,
|
|
231
|
-
operatorOptions: [
|
|
232
|
-
operators[0],
|
|
233
|
-
operators[1]
|
|
234
|
-
],
|
|
235
|
-
selectedField: fields[0]
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
title: `Remove all values for field "${fields[1].label}"`,
|
|
239
|
-
open: false,
|
|
240
|
-
field: fields[1].value,
|
|
241
|
-
operator: OperatorType.REMOVE,
|
|
242
|
-
value: void 0,
|
|
243
|
-
canDelete: true,
|
|
244
|
-
fieldOptions: [
|
|
245
|
-
fields[1]
|
|
246
|
-
],
|
|
247
|
-
operatorOptions: [
|
|
248
|
-
operators[0],
|
|
249
|
-
operators[1]
|
|
250
|
-
],
|
|
251
|
-
selectedField: fields[1]
|
|
252
|
-
}
|
|
253
|
-
]
|
|
254
|
-
});
|
|
255
|
-
expect(presenter.vm.canAddOperation).toBeFalsy();
|
|
256
|
-
});
|
|
257
|
-
it("should be able to set data back to the operation", ()=>{
|
|
258
|
-
presenter.load(batch, fields);
|
|
259
|
-
presenter.setBatch({
|
|
260
|
-
operations: [
|
|
261
|
-
{
|
|
262
|
-
title: `Remove all values for field "${fields[0].label}"`,
|
|
263
|
-
open: false,
|
|
264
|
-
field: fields[0].value,
|
|
265
|
-
operator: OperatorType.OVERRIDE,
|
|
266
|
-
value: {
|
|
267
|
-
[fields[0].value]: "newValue"
|
|
268
|
-
},
|
|
269
|
-
canDelete: false,
|
|
270
|
-
fieldOptions: fields,
|
|
271
|
-
operatorOptions: [
|
|
272
|
-
operators[0],
|
|
273
|
-
operators[1]
|
|
274
|
-
],
|
|
275
|
-
selectedField: fields[0]
|
|
276
|
-
}
|
|
277
|
-
]
|
|
278
|
-
});
|
|
279
|
-
expect(presenter.vm.data.operations[0].field).toEqual(fields[0].value);
|
|
280
|
-
expect(presenter.vm.data.operations[0].operator).toEqual(OperatorType.OVERRIDE);
|
|
281
|
-
expect(presenter.vm.data.operations[0].value).toEqual({
|
|
282
|
-
[fields[0].value]: "newValue"
|
|
283
|
-
});
|
|
284
|
-
expect(presenter.vm.data.operations[0].fieldOptions).toEqual(fields);
|
|
285
|
-
});
|
|
286
|
-
it("should able to set the operation `field` data", ()=>{
|
|
287
|
-
presenter.load(batch, fields);
|
|
288
|
-
presenter.setBatch({
|
|
289
|
-
operations: [
|
|
290
|
-
{
|
|
291
|
-
title: `Override existing values for field "${fields[0].label}"`,
|
|
292
|
-
open: true,
|
|
293
|
-
field: fields[0].value,
|
|
294
|
-
operator: OperatorType.OVERRIDE,
|
|
295
|
-
value: {
|
|
296
|
-
[fields[0].value]: "newValue"
|
|
297
|
-
},
|
|
298
|
-
canDelete: false,
|
|
299
|
-
fieldOptions: fields,
|
|
300
|
-
operatorOptions: [
|
|
301
|
-
operators[0],
|
|
302
|
-
operators[1]
|
|
303
|
-
],
|
|
304
|
-
selectedField: fields[0]
|
|
305
|
-
}
|
|
306
|
-
]
|
|
307
|
-
});
|
|
308
|
-
presenter.setOperationFieldData(0, "new-field");
|
|
309
|
-
expect(presenter.vm.data.operations[0]).toEqual({
|
|
310
|
-
title: "Operation #1",
|
|
311
|
-
open: true,
|
|
312
|
-
field: "new-field",
|
|
313
|
-
operator: "",
|
|
314
|
-
value: void 0,
|
|
315
|
-
canDelete: false,
|
|
316
|
-
fieldOptions: fields,
|
|
317
|
-
operatorOptions: [],
|
|
318
|
-
selectedField: void 0
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
it("should perform validation and call provided callbacks `onApply`", ()=>{
|
|
322
|
-
presenter.load(batch, fields);
|
|
323
|
-
const onSuccess = vi.fn();
|
|
324
|
-
const onError = vi.fn();
|
|
325
|
-
presenter.setBatch({
|
|
326
|
-
operations: [
|
|
327
|
-
{
|
|
328
|
-
title: `Override existing values for field "${fields[0].label}"`,
|
|
329
|
-
open: true,
|
|
330
|
-
field: fields[0].value,
|
|
331
|
-
operator: "",
|
|
332
|
-
value: void 0,
|
|
333
|
-
canDelete: false,
|
|
334
|
-
fieldOptions: fields,
|
|
335
|
-
operatorOptions: [
|
|
336
|
-
operators[0],
|
|
337
|
-
operators[1]
|
|
338
|
-
],
|
|
339
|
-
selectedField: fields[0]
|
|
340
|
-
}
|
|
341
|
-
]
|
|
342
|
-
});
|
|
343
|
-
presenter.onApply(onSuccess, onError);
|
|
344
|
-
expect(onError).toHaveBeenCalledTimes(1);
|
|
345
|
-
expect(Object.keys(presenter.vm.invalidFields).length).toBe(1);
|
|
346
|
-
presenter.setBatch({
|
|
347
|
-
operations: [
|
|
348
|
-
{
|
|
349
|
-
title: `Override existing values for field "${fields[0].label}"`,
|
|
350
|
-
open: true,
|
|
351
|
-
field: fields[0].value,
|
|
352
|
-
operator: OperatorType.OVERRIDE,
|
|
353
|
-
value: {
|
|
354
|
-
[fields[0].value]: "newValue"
|
|
355
|
-
},
|
|
356
|
-
canDelete: false,
|
|
357
|
-
fieldOptions: fields,
|
|
358
|
-
operatorOptions: [
|
|
359
|
-
operators[0],
|
|
360
|
-
operators[1]
|
|
361
|
-
],
|
|
362
|
-
selectedField: fields[0]
|
|
363
|
-
}
|
|
364
|
-
]
|
|
365
|
-
});
|
|
366
|
-
presenter.onApply(onSuccess, onError);
|
|
367
|
-
expect(onSuccess).toHaveBeenCalledTimes(1);
|
|
368
|
-
expect(presenter.vm.invalidFields).toEqual({});
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
//# sourceMappingURL=BatchEditorDialogPresenter.test.js.map
|