@anji-dashing/dam-solution-v2 5.8.173
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/README.md +53 -0
- package/build/AssetType/AddFieldProperties.d.ts +10 -0
- package/build/AssetType/AddFieldProperties.js +359 -0
- package/build/AssetType/AssetTemplatesTable.d.ts +10 -0
- package/build/AssetType/AssetTemplatesTable.js +172 -0
- package/build/AssetType/CreateAssetTemplate.d.ts +3 -0
- package/build/AssetType/CreateAssetTemplate.js +70 -0
- package/build/AssetType/CreateOrEditAssetTemplate.d.ts +1 -0
- package/build/AssetType/CreateOrEditAssetTemplate.js +100 -0
- package/build/AssetType/DraggedField.d.ts +14 -0
- package/build/AssetType/DraggedField.js +58 -0
- package/build/AssetType/EditAssetTemplate.d.ts +5 -0
- package/build/AssetType/EditAssetTemplate.js +257 -0
- package/build/AssetType/FieldsSection.d.ts +14 -0
- package/build/AssetType/FieldsSection.js +268 -0
- package/build/AssetType/assetTemplatesContainer.d.ts +2 -0
- package/build/AssetType/assetTemplatesContainer.js +71 -0
- package/build/AssetType/fieldProperties/DateField.d.ts +5 -0
- package/build/AssetType/fieldProperties/DateField.js +23 -0
- package/build/AssetType/fieldProperties/NumberField.d.ts +5 -0
- package/build/AssetType/fieldProperties/NumberField.js +91 -0
- package/build/AssetType/fieldProperties/OptionsField.d.ts +6 -0
- package/build/AssetType/fieldProperties/OptionsField.js +55 -0
- package/build/AssetType/fieldProperties/TextField.d.ts +5 -0
- package/build/AssetType/fieldProperties/TextField.js +92 -0
- package/build/AssetType/index.d.ts +11 -0
- package/build/AssetType/index.js +25 -0
- package/build/AssetType/routes.d.ts +3 -0
- package/build/AssetType/routes.js +17 -0
- package/build/BookView/ProductDescription.d.ts +4 -0
- package/build/BookView/ProductDescription.js +20 -0
- package/build/BookView/bookDetail.d.ts +4 -0
- package/build/BookView/bookDetail.js +106 -0
- package/build/BookView/bookInfo.d.ts +4 -0
- package/build/BookView/bookInfo.js +17 -0
- package/build/BookView/description.d.ts +4 -0
- package/build/BookView/description.js +5 -0
- package/build/BookView/index.d.ts +10 -0
- package/build/BookView/index.js +23 -0
- package/build/CreateClient/CreateClientBtn.d.ts +14 -0
- package/build/CreateClient/CreateClientBtn.js +54 -0
- package/build/CreateClient/CreateClientForm.d.ts +15 -0
- package/build/CreateClient/CreateClientForm.js +347 -0
- package/build/CreateClient/index.d.ts +20 -0
- package/build/CreateClient/index.js +18 -0
- package/build/ImagePicker/MetaFieldOptions.d.ts +14 -0
- package/build/ImagePicker/MetaFieldOptions.js +75 -0
- package/build/ImagePicker/TestImagePickerModal.d.ts +8 -0
- package/build/ImagePicker/TestImagePickerModal.js +72 -0
- package/build/ImagePicker/TestImgFromMetaData.d.ts +7 -0
- package/build/ImagePicker/TestImgFromMetaData.js +82 -0
- package/build/ImagePicker/imagePickerComponent.d.ts +6 -0
- package/build/ImagePicker/imagePickerComponent.js +63 -0
- package/build/ImagePicker/index.d.ts +13 -0
- package/build/ImagePicker/index.js +24 -0
- package/build/ImagePicker/routes.d.ts +6 -0
- package/build/ImagePicker/routes.js +17 -0
- package/build/ImagePickerFilters/ImagePickerFiltersComponent.d.ts +8 -0
- package/build/ImagePickerFilters/ImagePickerFiltersComponent.js +223 -0
- package/build/ImagePickerFilters/index.d.ts +12 -0
- package/build/ImagePickerFilters/index.js +19 -0
- package/build/MyDrive/ActionBar.d.ts +8 -0
- package/build/MyDrive/ActionBar.js +190 -0
- package/build/MyDrive/AddDrive.d.ts +5 -0
- package/build/MyDrive/AddDrive.js +189 -0
- package/build/MyDrive/AddFolder.d.ts +11 -0
- package/build/MyDrive/AddFolder.js +165 -0
- package/build/MyDrive/BreadCrumbList.d.ts +10 -0
- package/build/MyDrive/BreadCrumbList.js +81 -0
- package/build/MyDrive/BulkUploadModal.d.ts +2 -0
- package/build/MyDrive/BulkUploadModal.js +324 -0
- package/build/MyDrive/DriveContainer.d.ts +14 -0
- package/build/MyDrive/DriveContainer.js +343 -0
- package/build/MyDrive/FileDownloadHistory.d.ts +7 -0
- package/build/MyDrive/FileDownloadHistory.js +107 -0
- package/build/MyDrive/FileMenuOptions.d.ts +11 -0
- package/build/MyDrive/FileMenuOptions.js +450 -0
- package/build/MyDrive/FilesGridView.d.ts +9 -0
- package/build/MyDrive/FilesGridView.js +25 -0
- package/build/MyDrive/FolderGridView.d.ts +20 -0
- package/build/MyDrive/FolderGridView.js +95 -0
- package/build/MyDrive/FolderListView.d.ts +26 -0
- package/build/MyDrive/FolderListView.js +226 -0
- package/build/MyDrive/FolderMenuOptions.d.ts +5 -0
- package/build/MyDrive/FolderMenuOptions.js +350 -0
- package/build/MyDrive/FolderTree.d.ts +8 -0
- package/build/MyDrive/FolderTree.js +479 -0
- package/build/MyDrive/ImageEditor/EditImage.d.ts +6 -0
- package/build/MyDrive/ImageEditor/EditImage.js +97 -0
- package/build/MyDrive/ImageEditor/EditImageModal.d.ts +8 -0
- package/build/MyDrive/ImageEditor/EditImageModal.js +30 -0
- package/build/MyDrive/ImageEditor/TuiImageEditor.d.ts +10 -0
- package/build/MyDrive/ImageEditor/TuiImageEditor.js +99 -0
- package/build/MyDrive/ImagePickerBreadCrumbList.d.ts +8 -0
- package/build/MyDrive/ImagePickerBreadCrumbList.js +35 -0
- package/build/MyDrive/ImagePickerDrive.d.ts +1 -0
- package/build/MyDrive/ImagePickerDrive.js +41 -0
- package/build/MyDrive/MyDriveMainContainer.d.ts +6 -0
- package/build/MyDrive/MyDriveMainContainer.js +63 -0
- package/build/MyDrive/SearchFilter.d.ts +8 -0
- package/build/MyDrive/SearchFilter.js +73 -0
- package/build/MyDrive/ShareBtn.d.ts +5 -0
- package/build/MyDrive/ShareBtn.js +19 -0
- package/build/MyDrive/ToggleView.d.ts +4 -0
- package/build/MyDrive/ToggleView.js +12 -0
- package/build/MyDrive/UploadStatusModal.d.ts +12 -0
- package/build/MyDrive/UploadStatusModal.js +52 -0
- package/build/MyDrive/fileDetails/CommentEntity.d.ts +8 -0
- package/build/MyDrive/fileDetails/CommentEntity.js +102 -0
- package/build/MyDrive/fileDetails/Comments.d.ts +6 -0
- package/build/MyDrive/fileDetails/Comments.js +65 -0
- package/build/MyDrive/fileDetails/Compliance.d.ts +2 -0
- package/build/MyDrive/fileDetails/Compliance.js +18 -0
- package/build/MyDrive/fileDetails/CreateComment.d.ts +7 -0
- package/build/MyDrive/fileDetails/CreateComment.js +48 -0
- package/build/MyDrive/fileDetails/Editor.d.ts +6 -0
- package/build/MyDrive/fileDetails/Editor.js +55 -0
- package/build/MyDrive/fileDetails/EmojiPicker.d.ts +5 -0
- package/build/MyDrive/fileDetails/EmojiPicker.js +6 -0
- package/build/MyDrive/fileDetails/FileDetails.d.ts +11 -0
- package/build/MyDrive/fileDetails/FileDetails.js +125 -0
- package/build/MyDrive/fileDetails/FileHeader.d.ts +7 -0
- package/build/MyDrive/fileDetails/FileHeader.js +27 -0
- package/build/MyDrive/fileDetails/FileViewer.d.ts +10 -0
- package/build/MyDrive/fileDetails/FileViewer.js +17 -0
- package/build/MyDrive/fileDetails/ImageOptions.d.ts +2 -0
- package/build/MyDrive/fileDetails/ImageOptions.js +44 -0
- package/build/MyDrive/fileDetails/ImageViewer.d.ts +6 -0
- package/build/MyDrive/fileDetails/ImageViewer.js +16 -0
- package/build/MyDrive/fileDetails/ManageFile.d.ts +7 -0
- package/build/MyDrive/fileDetails/ManageFile.js +34 -0
- package/build/MyDrive/fileDetails/MetaForm.d.ts +15 -0
- package/build/MyDrive/fileDetails/MetaForm.js +199 -0
- package/build/MyDrive/fileDetails/Metadata.d.ts +8 -0
- package/build/MyDrive/fileDetails/Metadata.js +52 -0
- package/build/MyDrive/fileDetails/PdfOptions.d.ts +9 -0
- package/build/MyDrive/fileDetails/PdfOptions.js +35 -0
- package/build/MyDrive/fileDetails/PdfViewer.d.ts +8 -0
- package/build/MyDrive/fileDetails/PdfViewer.js +18 -0
- package/build/MyDrive/fileDetails/Previewdetails.d.ts +10 -0
- package/build/MyDrive/fileDetails/Previewdetails.js +53 -0
- package/build/MyDrive/fileDetails/VideoPlayer.d.ts +4 -0
- package/build/MyDrive/fileDetails/VideoPlayer.js +21 -0
- package/build/MyDrive/files/AssetSelectionFormItem.d.ts +7 -0
- package/build/MyDrive/files/AssetSelectionFormItem.js +14 -0
- package/build/MyDrive/files/FolderTabs.d.ts +6 -0
- package/build/MyDrive/files/FolderTabs.js +90 -0
- package/build/MyDrive/files/MapFile.d.ts +9 -0
- package/build/MyDrive/files/MapFile.js +239 -0
- package/build/MyDrive/files/MoveToAnotherFolder.d.ts +9 -0
- package/build/MyDrive/files/MoveToAnotherFolder.js +67 -0
- package/build/MyDrive/filesListView.d.ts +2 -0
- package/build/MyDrive/filesListView.js +57 -0
- package/build/MyDrive/index.d.ts +16 -0
- package/build/MyDrive/index.js +50 -0
- package/build/MyDrive/routes.d.ts +10 -0
- package/build/MyDrive/routes.js +12 -0
- package/build/PenView/PenDetails.d.ts +4 -0
- package/build/PenView/PenDetails.js +114 -0
- package/build/PenView/ProductDescription.d.ts +5 -0
- package/build/PenView/ProductDescription.js +51 -0
- package/build/PenView/index.d.ts +10 -0
- package/build/PenView/index.js +23 -0
- package/build/RefreshKey/RefreshKeyBtn.d.ts +1 -0
- package/build/RefreshKey/RefreshKeyBtn.js +42 -0
- package/build/RefreshKey/index.d.ts +9 -0
- package/build/RefreshKey/index.js +23 -0
- package/build/ShoesView/ProductDescription.d.ts +4 -0
- package/build/ShoesView/ProductDescription.js +25 -0
- package/build/ShoesView/ShoeDetails.d.ts +4 -0
- package/build/ShoesView/ShoeDetails.js +96 -0
- package/build/ShoesView/index.d.ts +10 -0
- package/build/ShoesView/index.js +23 -0
- package/build/common/Button.d.ts +2 -0
- package/build/common/Button.js +18 -0
- package/build/common/CustomElements.d.ts +98 -0
- package/build/common/CustomElements.js +77 -0
- package/build/common/LoadMoreItems.d.ts +7 -0
- package/build/common/LoadMoreItems.js +33 -0
- package/build/common/RenderFormItem.d.ts +42 -0
- package/build/common/RenderFormItem.js +98 -0
- package/build/common/RenderThumnail.d.ts +7 -0
- package/build/common/RenderThumnail.js +6 -0
- package/build/common/deleteModal.d.ts +1 -0
- package/build/common/deleteModal.js +12 -0
- package/build/common/folders/TypeAndDateFilters.d.ts +13 -0
- package/build/common/folders/TypeAndDateFilters.js +66 -0
- package/build/common/folders/getFolderOrFileIcon.d.ts +2 -0
- package/build/common/folders/getFolderOrFileIcon.js +41 -0
- package/build/common/loader/CustomLoader.d.ts +7 -0
- package/build/common/loader/CustomLoader.js +8 -0
- package/build/common/loader/loader.d.ts +1 -0
- package/build/common/loader/loader.js +6 -0
- package/build/common/notifications.d.ts +2 -0
- package/build/common/notifications.js +30 -0
- package/build/common/steps.d.ts +4 -0
- package/build/common/steps.js +7 -0
- package/build/hocs/AppProvider.d.ts +3 -0
- package/build/hocs/AppProvider.js +11 -0
- package/build/hocs/DamConfigContext.d.ts +2 -0
- package/build/hocs/DamConfigContext.js +153 -0
- package/build/hocs/ThemeContext.d.ts +15 -0
- package/build/hocs/ThemeContext.js +131 -0
- package/build/hocs/ToastProvider.d.ts +2 -0
- package/build/hocs/ToastProvider.js +6 -0
- package/build/hocs/appConstants.d.ts +124 -0
- package/build/hocs/appConstants.js +211 -0
- package/build/hocs/configureAxios.d.ts +2 -0
- package/build/hocs/configureAxios.js +65 -0
- package/build/hocs/helpers.d.ts +17 -0
- package/build/hocs/helpers.js +201 -0
- package/build/index.d.ts +12 -0
- package/build/index.js +12 -0
- package/build/react-query/hooks/brand-hooks.d.ts +3 -0
- package/build/react-query/hooks/brand-hooks.js +10 -0
- package/build/react-query/hooks/folder-hooks.d.ts +7 -0
- package/build/react-query/hooks/folder-hooks.js +119 -0
- package/build/react-query/services/brand-services.d.ts +4 -0
- package/build/react-query/services/brand-services.js +41 -0
- package/build/react-query/services/file-services.d.ts +43 -0
- package/build/react-query/services/file-services.js +69 -0
- package/build/react-query/services/folder-services.d.ts +46 -0
- package/build/react-query/services/folder-services.js +87 -0
- package/build/react-query/services/image-picker-services.d.ts +5 -0
- package/build/react-query/services/image-picker-services.js +47 -0
- package/build/settings/InviteTeamModal.d.ts +12 -0
- package/build/settings/InviteTeamModal.js +174 -0
- package/build/settings/UpdateInvitationAccessType.d.ts +9 -0
- package/build/settings/UpdateInvitationAccessType.js +96 -0
- package/build/settings/getUserAvatar.d.ts +7 -0
- package/build/settings/getUserAvatar.js +11 -0
- package/build/style.css +1 -0
- package/build/types/assetType.d.ts +8 -0
- package/build/types/assetType.js +1 -0
- package/build/ui/pageTitle.d.ts +3 -0
- package/build/ui/pageTitle.js +4 -0
- package/build/utilities/FoldersContext.d.ts +16 -0
- package/build/utilities/FoldersContext.js +15 -0
- package/build/utilities/NavigatorProvider.d.ts +2 -0
- package/build/utilities/NavigatorProvider.js +10 -0
- package/build/utilities/constants/apiUrls.d.ts +97 -0
- package/build/utilities/constants/apiUrls.js +117 -0
- package/build/utilities/constants/imageUrls.d.ts +6 -0
- package/build/utilities/constants/imageUrls.js +6 -0
- package/build/utilities/constants/interface.d.ts +371 -0
- package/build/utilities/constants/interface.js +142 -0
- package/build/utilities/constants/messages.d.ts +55 -0
- package/build/utilities/constants/messages.js +55 -0
- package/build/utilities/constants/queryKeys.d.ts +16 -0
- package/build/utilities/constants/queryKeys.js +33 -0
- package/build/utilities/constants/routes.d.ts +22 -0
- package/build/utilities/constants/routes.js +22 -0
- package/build/utilities/helpers/validators.d.ts +12 -0
- package/build/utilities/helpers/validators.js +89 -0
- package/build/utilities/useAppNavigate.d.ts +2 -0
- package/build/utilities/useAppNavigate.js +35 -0
- package/build/utilities/useAppParams.d.ts +8 -0
- package/build/utilities/useAppParams.js +72 -0
- package/package.json +93 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { ICON_SIZE } from "../hocs/appConstants";
|
|
12
|
+
import { Form, Input, Modal } from "antd";
|
|
13
|
+
import { useMemo, useState } from "react";
|
|
14
|
+
import { CiCirclePlus } from "react-icons/ci";
|
|
15
|
+
import CustomButton from "../common/Button";
|
|
16
|
+
import { CustomInputFormItem, CustomTextAreaFormItem, } from "../common/RenderFormItem";
|
|
17
|
+
import { CREATE_SUCCESS, ENTITY_REQUIRED, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
|
|
18
|
+
import { showNotification } from "../common/notifications";
|
|
19
|
+
import { NotificationStatus } from "../utilities/constants/interface";
|
|
20
|
+
import { get } from "lodash";
|
|
21
|
+
import { CREATE_ASSETS_URL } from "../utilities/constants/apiUrls";
|
|
22
|
+
import { ASSET_TEMPLATE_SCREEN } from "../utilities/constants/routes";
|
|
23
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
24
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
25
|
+
import useAppNavigate from "../utilities/useAppNavigate";
|
|
26
|
+
const CiCirclePlusIcon = CiCirclePlus;
|
|
27
|
+
const { TextArea } = Input;
|
|
28
|
+
export default function CreateAssetTemplate({ label }) {
|
|
29
|
+
const navigate = useAppNavigate();
|
|
30
|
+
const [state, setState] = useState({ open: false, loading: false });
|
|
31
|
+
const { open, loading } = state;
|
|
32
|
+
const damConfig = useDamConfig();
|
|
33
|
+
const [form] = Form.useForm();
|
|
34
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
35
|
+
const { brand } = damConfig;
|
|
36
|
+
const handleOk = () => {
|
|
37
|
+
form.validateFields().then((values) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
|
|
39
|
+
try {
|
|
40
|
+
const response = yield api.post(CREATE_ASSETS_URL, Object.assign(Object.assign({}, values), { brandId: get(brand, "_id") }));
|
|
41
|
+
// console.log("response", response);
|
|
42
|
+
showNotification(get(response, "data.message", CREATE_SUCCESS), NotificationStatus.SUCCESS);
|
|
43
|
+
toggleModal();
|
|
44
|
+
if (navigate) {
|
|
45
|
+
navigate(ASSET_TEMPLATE_SCREEN.replace(":id", get(response, "data._id")));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
|
|
50
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
const toggleModal = () => {
|
|
55
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { open: !prevState.open, loading: false })));
|
|
56
|
+
};
|
|
57
|
+
return (_jsxs(_Fragment, { children: [_jsx(CustomButton, { type: "primary", icon: _jsx(CiCirclePlusIcon, { size: ICON_SIZE }), onClick: toggleModal, size: "large", label: label }), _jsx(Modal, { title: "Create new template", open: open, onCancel: toggleModal, okText: "Create", width: 400, onOk: handleOk, okButtonProps: { loading }, children: _jsxs(Form, { layout: "vertical", form: form,
|
|
58
|
+
// requiredMark={false}
|
|
59
|
+
scrollToFirstError: true, onFinish: handleOk, children: [_jsx(CustomInputFormItem, { label: "Template name", name: "name", rules: [
|
|
60
|
+
{
|
|
61
|
+
required: true,
|
|
62
|
+
message: ENTITY_REQUIRED.replace(":entity", "Name"),
|
|
63
|
+
},
|
|
64
|
+
], placeholder: "Enter template name", style: { width: "100%" } }), _jsx(CustomTextAreaFormItem, { label: "Template description", name: "description", rules: [
|
|
65
|
+
{
|
|
66
|
+
required: true,
|
|
67
|
+
message: ENTITY_REQUIRED.replace(":entity", "Description"),
|
|
68
|
+
},
|
|
69
|
+
], placeholder: "Enter template description", style: { width: "100%" }, rows: 3 })] }) })] }));
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CreateOrEditAssetTemplate(): JSX.Element;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { useEffect, useMemo, useState } from "react";
|
|
12
|
+
import { FETCH_ASSET_URL, FETCH_INPUT_TYPES_URL, } from "../utilities/constants/apiUrls";
|
|
13
|
+
import { get } from "lodash";
|
|
14
|
+
import EditAssetTemplate from "./EditAssetTemplate";
|
|
15
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
16
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
17
|
+
import { useTheme } from "../hocs/ThemeContext";
|
|
18
|
+
import { InputTypes } from "../utilities/constants/interface";
|
|
19
|
+
import Loader from "../common/loader/loader";
|
|
20
|
+
import useAppParams from "../utilities/useAppParams";
|
|
21
|
+
let useParamsFallback = () => ({});
|
|
22
|
+
try {
|
|
23
|
+
const rrd = require("react-router-dom");
|
|
24
|
+
if (rrd.useParams) {
|
|
25
|
+
useParamsFallback = rrd.useParams;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (_a) {
|
|
29
|
+
}
|
|
30
|
+
export default function CreateOrEditAssetTemplate() {
|
|
31
|
+
const [state, setState] = useState({
|
|
32
|
+
inputTypesLoading: false,
|
|
33
|
+
templatesDataLoading: false,
|
|
34
|
+
templateData: {},
|
|
35
|
+
inputTypesData: [],
|
|
36
|
+
});
|
|
37
|
+
const damConfig = useDamConfig();
|
|
38
|
+
const { styles } = damConfig;
|
|
39
|
+
const { variables } = useTheme();
|
|
40
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
41
|
+
const params = useAppParams();
|
|
42
|
+
const routeParams = useParamsFallback();
|
|
43
|
+
const mergedParams = useMemo(() => (Object.assign(Object.assign({}, params), routeParams)), [params, routeParams]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
getInputTypesData();
|
|
46
|
+
}, []);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
getTemplateData();
|
|
49
|
+
}, [mergedParams]);
|
|
50
|
+
const getInputTypesData = () => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
var _a;
|
|
52
|
+
setState((prevState) => {
|
|
53
|
+
return Object.assign(Object.assign({}, prevState), { inputTypesLoading: true });
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
const response = yield api.get(FETCH_INPUT_TYPES_URL);
|
|
57
|
+
const filteredData = (_a = get(response, "data", [])) === null || _a === void 0 ? void 0 : _a.filter((input) => get(input, "defaultName") !== InputTypes.PERSON);
|
|
58
|
+
const sortedData = filteredData === null || filteredData === void 0 ? void 0 : filteredData.sort((a, b) => {
|
|
59
|
+
const nameA = get(a, "name", "").toLowerCase();
|
|
60
|
+
const nameB = get(b, "name", "").toLowerCase();
|
|
61
|
+
return nameA.localeCompare(nameB);
|
|
62
|
+
});
|
|
63
|
+
setState((prevState) => {
|
|
64
|
+
return Object.assign(Object.assign({}, prevState), { inputTypesData: sortedData || [], inputTypesLoading: false });
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
console.log("Error while fetching input types", err);
|
|
69
|
+
setState((prevState) => {
|
|
70
|
+
return Object.assign(Object.assign({}, prevState), { inputTypesLoading: false });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const getTemplateData = () => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
setState((prevState) => {
|
|
76
|
+
return Object.assign(Object.assign({}, prevState), { templateData: true });
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
const assetId = get(mergedParams, "id") || "";
|
|
80
|
+
if (!assetId) {
|
|
81
|
+
console.error("Asset ID is missing from route parameters");
|
|
82
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { templatesDataLoading: false })));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const response = yield api.get(FETCH_ASSET_URL.replace(":assetId", assetId));
|
|
86
|
+
setState((prevState) => {
|
|
87
|
+
return Object.assign(Object.assign({}, prevState), { templateData: get(response, "data", []), templatesDataLoading: false });
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.log("Error while fetching template data", error);
|
|
92
|
+
setState((prevState) => {
|
|
93
|
+
return Object.assign(Object.assign({}, prevState), { templatesDataLoading: false });
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return (_jsx("div", { className: "md-lib-h-auto", style: {
|
|
98
|
+
backgroundColor: (styles === null || styles === void 0 ? void 0 : styles.secondaryColor) || (variables === null || variables === void 0 ? void 0 : variables.secondaryColor),
|
|
99
|
+
}, children: (state === null || state === void 0 ? void 0 : state.inputTypesLoading) || (state === null || state === void 0 ? void 0 : state.templatesDataLoading) ? (_jsx(Loader, {})) : (_jsx(EditAssetTemplate, { assetTemplate: get(state, "templateData", {}), inputTypes: get(state, "inputTypesData", []) })) }));
|
|
100
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AddFieldNameFunc } from "../types/assetType";
|
|
2
|
+
import { InputTypeEntity } from "../utilities/constants/interface";
|
|
3
|
+
export default function DraggedField({ provided, field, onAddLabel, onDeleteField, setCurrentFieldIndex, currentFieldIndex, index, showOutputFormat, onUpdateOutputFormat, outputFormatField, }: {
|
|
4
|
+
provided: any;
|
|
5
|
+
field: InputTypeEntity;
|
|
6
|
+
onAddLabel: AddFieldNameFunc;
|
|
7
|
+
onDeleteField: (value: number) => void;
|
|
8
|
+
setCurrentFieldIndex: (value: number | null) => void;
|
|
9
|
+
currentFieldIndex: number | null;
|
|
10
|
+
index: number;
|
|
11
|
+
showOutputFormat: boolean;
|
|
12
|
+
onUpdateOutputFormat: (id: number, key: string, value: string | boolean) => void;
|
|
13
|
+
outputFormatField: InputTypeEntity;
|
|
14
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ICON_SIZE } from "../hocs/appConstants";
|
|
3
|
+
import { Checkbox, DatePicker, Input, InputNumber, Radio, Select } from "antd";
|
|
4
|
+
import { MdDragIndicator } from "react-icons/md";
|
|
5
|
+
import { MdOutlineEdit } from "react-icons/md";
|
|
6
|
+
import { IoMdClose } from "react-icons/io";
|
|
7
|
+
import { get } from "lodash";
|
|
8
|
+
import { InputTypes, } from "../utilities/constants/interface";
|
|
9
|
+
import { getWidgetIcon } from "./FieldsSection";
|
|
10
|
+
const { RangePicker } = DatePicker;
|
|
11
|
+
const MdDragIndicatorIcon = MdDragIndicator;
|
|
12
|
+
const MdOutlineEditIcon = MdOutlineEdit;
|
|
13
|
+
const IoMdCloseIcon = IoMdClose;
|
|
14
|
+
export default function DraggedField({ provided, field, onAddLabel, onDeleteField, setCurrentFieldIndex, currentFieldIndex, index, showOutputFormat, onUpdateOutputFormat, outputFormatField, }) {
|
|
15
|
+
// const [fieldName, setFieldName] = useState("");
|
|
16
|
+
// useEffect(() => {
|
|
17
|
+
// const initialName = get(field, "name", "");
|
|
18
|
+
// setFieldName(initialName);
|
|
19
|
+
// }, [field]);
|
|
20
|
+
const defaultName = get(field, "defaultName", null);
|
|
21
|
+
const id = get(field, "_id");
|
|
22
|
+
const IconComponent = getWidgetIcon(defaultName);
|
|
23
|
+
return (_jsxs("div", { className: `md-lib-flex md-lib-relative md-lib-gap-2 md-lib-border md-lib-h-100 md-lib-rounded-md md-lib-cursor-pointer md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-mb-2 ${currentFieldIndex === index && !showOutputFormat
|
|
24
|
+
? "md-lib-border-primaryColor"
|
|
25
|
+
: "md-lib-border-borderColor dark:md-lib-border-darkBorderColor"}`,
|
|
26
|
+
// onBlur={() =>
|
|
27
|
+
// onAddLabel(id, !!fieldName ? fieldName : get(field, "label", ""))
|
|
28
|
+
// }
|
|
29
|
+
onClick: () => {
|
|
30
|
+
if (!showOutputFormat) {
|
|
31
|
+
setCurrentFieldIndex(index);
|
|
32
|
+
}
|
|
33
|
+
}, children: [_jsx("div", Object.assign({
|
|
34
|
+
// style={{ backgroundColor: variables.secondaryColor }}
|
|
35
|
+
className: "md-lib-flex md-lib-items-center md-lib-rounded-s" }, provided.dragHandleProps, { children: _jsx(MdDragIndicatorIcon, { size: ICON_SIZE, className: "md-lib-h-100" }) })), _jsxs("div", { className: "md-lib-flex-1 md-lib-p-2 md-lib-w-100", children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-mb-3", children: [IconComponent && _jsx(IconComponent, {}), _jsx("label", { className: "md-lib-font-semibold", children: get(field, "name", "Field Name") }), !showOutputFormat && (_jsxs("div", { className: `md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-absolute md-lib-right-3 md-lib--top-3 md-lib-border md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-md md-lib-p-1 ${currentFieldIndex === index ? "md-lib-border-primaryColor" : "md-lib-hidden"}`, children: [_jsx(MdOutlineEditIcon, { size: ICON_SIZE, className: "md-lib-cursor-pointer", onClick: () => setCurrentFieldIndex(index), "aria-disabled": showOutputFormat }), _jsx(IoMdCloseIcon, { size: ICON_SIZE, className: "md-lib-cursor-pointer", onClick: (e) => {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
onDeleteField(index);
|
|
38
|
+
}, "aria-disabled": showOutputFormat })] }))] }), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [(defaultName === InputTypes.TEXT || !defaultName) && (() => {
|
|
39
|
+
const charLimitSettings = get(field, "inputTypeSettings.CHARACTER_LIMIT", {});
|
|
40
|
+
const charLimitEnabled = get(charLimitSettings, "allow", false);
|
|
41
|
+
const maxValue = get(charLimitSettings, "maxValue");
|
|
42
|
+
const maxLength = charLimitEnabled && maxValue ? maxValue : 255; // Default to 255
|
|
43
|
+
return (_jsx(Input, { placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none", maxLength: maxLength, showCount: true }));
|
|
44
|
+
})(), defaultName === InputTypes.PARAGRAPH && (() => {
|
|
45
|
+
const charLimitSettings = get(field, "inputTypeSettings.CHARACTER_LIMIT", {});
|
|
46
|
+
const charLimitEnabled = get(charLimitSettings, "allow", false);
|
|
47
|
+
const maxValue = get(charLimitSettings, "maxValue");
|
|
48
|
+
const maxLength = charLimitEnabled && maxValue ? maxValue : 255; // Default to 255
|
|
49
|
+
return (_jsx(Input.TextArea, { rows: 2, placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none", maxLength: maxLength, showCount: true }));
|
|
50
|
+
})(), defaultName === InputTypes.NUMBERS && (_jsx(InputNumber, { placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.DATE && (_jsx(DatePicker, { style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.DATE_RANGE && (_jsx(RangePicker, { placeholder: ["Start", "End"], style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), (defaultName === InputTypes.SELECT ||
|
|
51
|
+
defaultName === InputTypes.TEAM) && (_jsx(Select, { placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none", disabled: true })), defaultName === InputTypes.LINK && (() => {
|
|
52
|
+
const charLimitSettings = get(field, "inputTypeSettings.CHARACTER_LIMIT", {});
|
|
53
|
+
const charLimitEnabled = get(charLimitSettings, "allow", false);
|
|
54
|
+
const maxValue = get(charLimitSettings, "maxValue");
|
|
55
|
+
const maxLength = charLimitEnabled && maxValue ? maxValue : 255; // Default to 255
|
|
56
|
+
return (_jsx(Input, { placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none", maxLength: maxLength, showCount: true }));
|
|
57
|
+
})(), defaultName === InputTypes.RADIO && (_jsx(Radio.Group, { options: [], style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.CHECKBOX && (_jsx(Checkbox.Group, { options: [], style: { width: "100%" }, className: "md-lib-pointer-events-none" })), showOutputFormat && (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [_jsx(Checkbox, { onChange: (e) => onUpdateOutputFormat(index, "required", e.target.checked), checked: get(outputFormatField, "required", false), children: "Required" }), _jsx(Input, { placeholder: "Separator", value: get(outputFormatField, "separator", ""), onChange: (e) => onUpdateOutputFormat(index, "separator", e.target.value) })] }))] })] })] }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { ICON_SIZE } from "../hocs/appConstants";
|
|
12
|
+
import { Tabs, Typography } from "antd";
|
|
13
|
+
import { useEffect, useMemo, useState } from "react";
|
|
14
|
+
import { IoMdClose } from "react-icons/io";
|
|
15
|
+
// import "../../styles/styles.assetTemplates.scss";
|
|
16
|
+
import { FiSave, FiEdit2 } from "react-icons/fi";
|
|
17
|
+
import AddWidgets from "./FieldsSection";
|
|
18
|
+
import { InputSupportedTypes, InputTypes, NotificationStatus, } from "../utilities/constants/interface";
|
|
19
|
+
import { find, get, includes, map } from "lodash";
|
|
20
|
+
import CustomButton from "../common/Button";
|
|
21
|
+
import { showNotification } from "../common/notifications";
|
|
22
|
+
import { SOMETHING_WENT_WRONG, UPDATE_SUCCESS, } from "../utilities/constants/messages";
|
|
23
|
+
import { FETCH_ASSET_URL } from "../utilities/constants/apiUrls";
|
|
24
|
+
import { ASSETS_SCREEN } from "../utilities/constants/routes";
|
|
25
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
26
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
27
|
+
import useAppNavigate from "../utilities/useAppNavigate";
|
|
28
|
+
import useAppParams from "../utilities/useAppParams";
|
|
29
|
+
let useParamsFallback = () => ({});
|
|
30
|
+
try {
|
|
31
|
+
const rrd = require("react-router-dom");
|
|
32
|
+
if (rrd.useParams) {
|
|
33
|
+
useParamsFallback = rrd.useParams;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (_a) {
|
|
37
|
+
}
|
|
38
|
+
const { Paragraph } = Typography;
|
|
39
|
+
const IoMdCloseIcon = IoMdClose;
|
|
40
|
+
const FiEdit2Icon = FiEdit2;
|
|
41
|
+
const FiSaveIcon = FiSave;
|
|
42
|
+
export default function EditAssetTemplate({ assetTemplate, inputTypes, }) {
|
|
43
|
+
const params = useAppParams();
|
|
44
|
+
const routeParams = useParamsFallback();
|
|
45
|
+
const mergedParams = useMemo(() => (Object.assign(Object.assign({}, params), routeParams)), [params, routeParams]);
|
|
46
|
+
const id = mergedParams.id || params.id;
|
|
47
|
+
const navigate = useAppNavigate();
|
|
48
|
+
const damConfig = useDamConfig();
|
|
49
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
50
|
+
const originalName = useMemo(() => get(assetTemplate, "name", ""), [assetTemplate]);
|
|
51
|
+
const originalDescription = useMemo(() => get(assetTemplate, "description", ""), [assetTemplate]);
|
|
52
|
+
const originalFields = useMemo(() => get(assetTemplate, "metadataFields", []), [assetTemplate]);
|
|
53
|
+
const originalImagePickerOutputFormat = useMemo(() => get(assetTemplate, "imagePickerOutputFormat", []), [assetTemplate]);
|
|
54
|
+
const [state, setState] = useState({
|
|
55
|
+
name: get(assetTemplate, "name", ""),
|
|
56
|
+
description: get(assetTemplate, "description", ""),
|
|
57
|
+
currentFieldIndex: null,
|
|
58
|
+
fields: get(assetTemplate, "metadataFields", []),
|
|
59
|
+
loading: false,
|
|
60
|
+
showOutputFormat: false,
|
|
61
|
+
imagePickerOutputFormat: get(assetTemplate, "imagePickerOutputFormat", []),
|
|
62
|
+
imagePickerOutputFormatError: false,
|
|
63
|
+
activeTab: "1",
|
|
64
|
+
});
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
setState((prevState) => {
|
|
67
|
+
return Object.assign(Object.assign({}, prevState), { name: get(assetTemplate, "name", ""), description: get(assetTemplate, "description", ""), fields: get(assetTemplate, "metadataFields", []), imagePickerOutputFormat: get(assetTemplate, "imagePickerOutputFormat", []) });
|
|
68
|
+
});
|
|
69
|
+
}, [assetTemplate]);
|
|
70
|
+
const { name, description, currentFieldIndex, fields, loading, showOutputFormat, imagePickerOutputFormat, imagePickerOutputFormatError, } = state;
|
|
71
|
+
const hasNameOrDescriptionChanges = useMemo(() => {
|
|
72
|
+
return name.trim() !== originalName.trim() ||
|
|
73
|
+
description.trim() !== originalDescription.trim();
|
|
74
|
+
}, [name, description, originalName, originalDescription]);
|
|
75
|
+
const hasFieldChanges = useMemo(() => {
|
|
76
|
+
if (fields.length !== originalFields.length)
|
|
77
|
+
return true;
|
|
78
|
+
return JSON.stringify(fields) !== JSON.stringify(originalFields);
|
|
79
|
+
}, [fields, originalFields]);
|
|
80
|
+
const hasImagePickerOutputFormatChanges = useMemo(() => {
|
|
81
|
+
return JSON.stringify(imagePickerOutputFormat) !== JSON.stringify(originalImagePickerOutputFormat);
|
|
82
|
+
}, [imagePickerOutputFormat, originalImagePickerOutputFormat]);
|
|
83
|
+
const canSave = hasNameOrDescriptionChanges || hasFieldChanges || hasImagePickerOutputFormatChanges;
|
|
84
|
+
const transformInputTypePayload = (updatedValues, field, mapId) => {
|
|
85
|
+
const supportedTypes = get(field, "supportedTypes", []);
|
|
86
|
+
const inputTypeSettings = {};
|
|
87
|
+
supportedTypes.forEach((type) => {
|
|
88
|
+
const defaultName = get(type, "defaultName");
|
|
89
|
+
const valueType = get(type, "valueType");
|
|
90
|
+
const typeValue = get(updatedValues, ["inputTypeSettings", defaultName]);
|
|
91
|
+
if (valueType === "boolean") {
|
|
92
|
+
inputTypeSettings[defaultName] = typeValue === true;
|
|
93
|
+
}
|
|
94
|
+
if (includes([
|
|
95
|
+
InputSupportedTypes.CHARACTER_LIMIT,
|
|
96
|
+
InputSupportedTypes.REGEX,
|
|
97
|
+
InputSupportedTypes.VALUE_RANGE,
|
|
98
|
+
InputSupportedTypes.ALLOW_TIME,
|
|
99
|
+
], defaultName)) {
|
|
100
|
+
if (get(typeValue, "allow")) {
|
|
101
|
+
inputTypeSettings[defaultName] = typeValue;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
inputTypeSettings[defaultName] = { allow: false };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const payload = {
|
|
109
|
+
name: get(updatedValues, "name"),
|
|
110
|
+
placeholder: get(updatedValues, "placeholder"),
|
|
111
|
+
isMandatory: get(updatedValues, "isMandatory", false),
|
|
112
|
+
inputTypeSettings,
|
|
113
|
+
label: get(field, "label", get(field, "name", "")),
|
|
114
|
+
defaultName: get(field, "defaultName"),
|
|
115
|
+
mapId,
|
|
116
|
+
defaultValue: get(updatedValues, "defaultValue"),
|
|
117
|
+
};
|
|
118
|
+
if (get(updatedValues, "_id", null)) {
|
|
119
|
+
payload["_id"] = get(updatedValues, "_id");
|
|
120
|
+
}
|
|
121
|
+
if (includes([InputTypes.CHECKBOX, InputTypes.RADIO, InputTypes.SELECT], get(field, "defaultName"))) {
|
|
122
|
+
payload["options"] = get(updatedValues, "options", []);
|
|
123
|
+
}
|
|
124
|
+
return payload;
|
|
125
|
+
};
|
|
126
|
+
const validateImagePickerOutputFormat = () => {
|
|
127
|
+
const filteredOutput = imagePickerOutputFormat.filter((item) => item.required);
|
|
128
|
+
return filteredOutput.reduce((acc, curr, index) => {
|
|
129
|
+
if (index !== filteredOutput.length - 1 && !curr.separator) {
|
|
130
|
+
acc = true;
|
|
131
|
+
}
|
|
132
|
+
return acc;
|
|
133
|
+
}, false);
|
|
134
|
+
};
|
|
135
|
+
const validateFields = () => {
|
|
136
|
+
// Check if template name is provided
|
|
137
|
+
if (!name || name.trim() === "") {
|
|
138
|
+
showNotification("Template name is required", NotificationStatus.ERROR);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
// Validate all fields have required properties
|
|
142
|
+
for (let i = 0; i < fields.length; i++) {
|
|
143
|
+
const field = fields[i];
|
|
144
|
+
if (!get(field, "name") || get(field, "name", "").trim() === "") {
|
|
145
|
+
showNotification(`Field ${i + 1}: Name is required`, NotificationStatus.ERROR);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (!get(field, "placeholder") || get(field, "placeholder", "").trim() === "") {
|
|
149
|
+
showNotification(`Field ${i + 1}: Placeholder is required`, NotificationStatus.ERROR);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
};
|
|
155
|
+
const handleSaveTemplate = () => __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
// Don't allow saving if a field is currently being edited
|
|
157
|
+
if (currentFieldIndex !== null) {
|
|
158
|
+
showNotification("Please finish editing the current field before saving", NotificationStatus.WARN);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
// Validate fields before saving
|
|
162
|
+
if (!validateFields()) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const imagePickerOutputFormatHasErrors = validateImagePickerOutputFormat();
|
|
166
|
+
if (!imagePickerOutputFormatHasErrors) {
|
|
167
|
+
if (!id) {
|
|
168
|
+
console.error("Asset ID is missing from route parameters");
|
|
169
|
+
showNotification("Asset ID is missing. Please navigate from the assets list.", NotificationStatus.ERROR);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
|
|
173
|
+
try {
|
|
174
|
+
const response = yield api.put(FETCH_ASSET_URL.replace(":assetId", id), {
|
|
175
|
+
name: name,
|
|
176
|
+
description: description,
|
|
177
|
+
metadataFields: map(fields, (field) => {
|
|
178
|
+
const currentInputType = find(inputTypes, (input) => get(field, "defaultName") === get(input, "defaultName"));
|
|
179
|
+
return transformInputTypePayload(field, currentInputType, get(field, "mapId", ""));
|
|
180
|
+
}),
|
|
181
|
+
imagePickerOutputFormat: imagePickerOutputFormat.map((field) => {
|
|
182
|
+
const finalField = {
|
|
183
|
+
name: field.name,
|
|
184
|
+
placeholder: field.placeholder,
|
|
185
|
+
label: field.label,
|
|
186
|
+
defaultName: field.defaultName,
|
|
187
|
+
required: field.required,
|
|
188
|
+
separator: field.separator,
|
|
189
|
+
mapId: field.mapId,
|
|
190
|
+
};
|
|
191
|
+
if (field._id) {
|
|
192
|
+
finalField["_id"] = field._id;
|
|
193
|
+
}
|
|
194
|
+
return finalField;
|
|
195
|
+
}),
|
|
196
|
+
});
|
|
197
|
+
if (navigate) {
|
|
198
|
+
navigate(ASSETS_SCREEN);
|
|
199
|
+
}
|
|
200
|
+
showNotification(get(response, "data.message", UPDATE_SUCCESS), NotificationStatus.SUCCESS);
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { imagePickerOutputFormatError: true })));
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
const toggleShowOutputFormat = () => {
|
|
214
|
+
const hasErrors = validateImagePickerOutputFormat();
|
|
215
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showOutputFormat: !prevState.showOutputFormat, imagePickerOutputFormatError: hasErrors })));
|
|
216
|
+
};
|
|
217
|
+
const tabs = [
|
|
218
|
+
{
|
|
219
|
+
key: "1",
|
|
220
|
+
label: "Fields",
|
|
221
|
+
children: (_jsx(AddWidgets, { name: name, inputTypes: inputTypes, transformInputTypePayload: transformInputTypePayload, currentFieldIndex: currentFieldIndex, setState: setState, fields: fields, imagePickerOutputFormat: imagePickerOutputFormat, setCurrentFieldIndex: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { currentFieldIndex: value }))), showOutputFormat: false })),
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
key: "2",
|
|
225
|
+
label: "Image picker output format",
|
|
226
|
+
disabled: fields.length === 0,
|
|
227
|
+
children: (_jsx(AddWidgets, { name: name, inputTypes: inputTypes, transformInputTypePayload: transformInputTypePayload, currentFieldIndex: currentFieldIndex, setState: setState, fields: fields, imagePickerOutputFormat: imagePickerOutputFormat, setCurrentFieldIndex: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { currentFieldIndex: value }))), showOutputFormat: true })),
|
|
228
|
+
},
|
|
229
|
+
];
|
|
230
|
+
// console.log("edit asset template", fields, imagePickerOutputFormat);
|
|
231
|
+
return (_jsx(_Fragment, { children: _jsx(Tabs, { items: tabs, tabBarStyle: {
|
|
232
|
+
background: "white",
|
|
233
|
+
display: "flex",
|
|
234
|
+
justifyContent: "center",
|
|
235
|
+
alignItems: "center",
|
|
236
|
+
marginBottom: 0,
|
|
237
|
+
}, centered: true, tabBarExtraContent: {
|
|
238
|
+
left: (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-border-b md-lib-p-3 md-lib-border-borderColor dark:md-lib-border-darkBorderColor dark:md-lib-bg-darkPrimary md-lib-bg-white", children: [_jsx(IoMdCloseIcon, { size: ICON_SIZE, onClick: () => {
|
|
239
|
+
if (navigate) {
|
|
240
|
+
navigate(ASSETS_SCREEN);
|
|
241
|
+
}
|
|
242
|
+
}, className: "md-lib-cursor-pointer" }), _jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-border-l md-lib-pl-4 md-lib-ml-4", children: [_jsx(Paragraph, { className: "md-lib-text-xl md-lib-asset-template-title", style: { marginBottom: "0px !important" }, editable: {
|
|
243
|
+
onChange: (val) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { name: val }))),
|
|
244
|
+
icon: _jsx(FiEdit2Icon, { size: 15, className: "md-lib-ml-2" }),
|
|
245
|
+
}, children: name }), _jsx(Paragraph, { className: "md-lib-text-sm md-lib-text-gray-500 dark:md-lib-text-gray-400 md-lib-mt-1", style: { marginBottom: "0px !important" }, editable: {
|
|
246
|
+
onChange: (val) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { description: val }))),
|
|
247
|
+
icon: _jsx(FiEdit2Icon, { size: 15, className: "md-lib-ml-2" }),
|
|
248
|
+
}, children: description || "Add description" })] })] })),
|
|
249
|
+
right: (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-ml-auto", children: [imagePickerOutputFormatError && (_jsx("p", { className: "md-lib-text-sm md-lib-text-red-500", children: "Please ensure that all required fields (except the last one) have separators configured" })), _jsx(CustomButton, { label: "Cancel", onClick: () => {
|
|
250
|
+
if (navigate) {
|
|
251
|
+
navigate(ASSETS_SCREEN);
|
|
252
|
+
}
|
|
253
|
+
} }), _jsx(CustomButton, { label: "Save", type: currentFieldIndex !== null || !canSave ? "default" : "primary", icon: _jsx(FiSaveIcon, {}), disabled: currentFieldIndex !== null || !canSave, onClick: handleSaveTemplate, loading: loading })] })),
|
|
254
|
+
}, onChange: (key) => setState((prevState) => {
|
|
255
|
+
return Object.assign(Object.assign({}, prevState), { activeTab: key, currentFieldIndex: key === "2" ? null : prevState.currentFieldIndex });
|
|
256
|
+
}) }) }));
|
|
257
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SetStateAction } from "react";
|
|
2
|
+
import { InputTypeEntity } from "../utilities/constants/interface";
|
|
3
|
+
export declare const getWidgetIcon: (defaultName: string | undefined | null) => import("react-icons").IconType | null;
|
|
4
|
+
export default function FieldsSection({ name, inputTypes, transformInputTypePayload, currentFieldIndex, setCurrentFieldIndex, fields, setState, showOutputFormat, imagePickerOutputFormat, }: {
|
|
5
|
+
name: string;
|
|
6
|
+
inputTypes: InputTypeEntity[];
|
|
7
|
+
transformInputTypePayload: (values: any, field: InputTypeEntity, mapId: string) => void;
|
|
8
|
+
currentFieldIndex: number | null;
|
|
9
|
+
setCurrentFieldIndex: (value: number | null) => void;
|
|
10
|
+
fields: InputTypeEntity[];
|
|
11
|
+
setState: React.Dispatch<SetStateAction<any>>;
|
|
12
|
+
showOutputFormat: boolean;
|
|
13
|
+
imagePickerOutputFormat: InputTypeEntity[];
|
|
14
|
+
}): JSX.Element;
|