@bindu-dashing/dam-solution-v2 5.8.189 → 5.8.190
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.
|
@@ -280,6 +280,11 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
280
280
|
if ((defaultName === InputTypes.DATE ||
|
|
281
281
|
defaultName === InputTypes.DATE_RANGE) &&
|
|
282
282
|
settings[InputSupportedTypes.ALLOW_TIME] !== undefined) {
|
|
283
|
+
const hasNonZeroTime = (d) => {
|
|
284
|
+
if (!d || typeof d.hour !== "function")
|
|
285
|
+
return false;
|
|
286
|
+
return d.hour() !== 0 || d.minute() !== 0 || d.second() !== 0;
|
|
287
|
+
};
|
|
283
288
|
rules.push({
|
|
284
289
|
validator: (_, value) => {
|
|
285
290
|
const allowTime = !!get(settings, `${InputSupportedTypes.ALLOW_TIME}.allow`);
|
|
@@ -294,7 +299,8 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
294
299
|
if (allowTime && !hasTimeMethods) {
|
|
295
300
|
return Promise.reject("Please select a date with time (hour/minute/second).");
|
|
296
301
|
}
|
|
297
|
-
if
|
|
302
|
+
// When time is not allowed: reject only if user selected a non-zero time
|
|
303
|
+
if (!allowTime && hasNonZeroTime(value)) {
|
|
298
304
|
return Promise.reject("Time is not allowed. Please select only a date.");
|
|
299
305
|
}
|
|
300
306
|
}
|
|
@@ -312,7 +318,8 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
|
|
|
312
318
|
if (allowTime && (!startHasTimeMethods || !endHasTimeMethods)) {
|
|
313
319
|
return Promise.reject("Please select both start and end dates with time.");
|
|
314
320
|
}
|
|
315
|
-
if
|
|
321
|
+
// When time is not allowed: reject only if user selected a non-zero time
|
|
322
|
+
if (!allowTime && (hasNonZeroTime(start) || hasNonZeroTime(end))) {
|
|
316
323
|
return Promise.reject("Time is not allowed. Please select only dates.");
|
|
317
324
|
}
|
|
318
325
|
}
|
|
@@ -218,13 +218,13 @@ export default function EditAssetTemplate({ assetTemplate, inputTypes, }) {
|
|
|
218
218
|
{
|
|
219
219
|
key: "1",
|
|
220
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 })),
|
|
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, assetId: id || get(assetTemplate, "_id") })),
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
key: "2",
|
|
225
225
|
label: "Image picker output format",
|
|
226
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 })),
|
|
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, assetId: id || get(assetTemplate, "_id") })),
|
|
228
228
|
},
|
|
229
229
|
];
|
|
230
230
|
// console.log("edit asset template", fields, imagePickerOutputFormat);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SetStateAction } from "react";
|
|
2
2
|
import { InputTypeEntity } from "../utilities/constants/interface";
|
|
3
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, }: {
|
|
4
|
+
export default function FieldsSection({ name, inputTypes, transformInputTypePayload, currentFieldIndex, setCurrentFieldIndex, fields, setState, showOutputFormat, imagePickerOutputFormat, assetId: assetIdProp, }: {
|
|
5
5
|
name: string;
|
|
6
6
|
inputTypes: InputTypeEntity[];
|
|
7
7
|
transformInputTypePayload: (values: any, field: InputTypeEntity, mapId: string) => void;
|
|
@@ -11,4 +11,5 @@ export default function FieldsSection({ name, inputTypes, transformInputTypePayl
|
|
|
11
11
|
setState: React.Dispatch<SetStateAction<any>>;
|
|
12
12
|
showOutputFormat: boolean;
|
|
13
13
|
imagePickerOutputFormat: InputTypeEntity[];
|
|
14
|
+
assetId?: string;
|
|
14
15
|
}): JSX.Element;
|
|
@@ -76,8 +76,9 @@ export const getWidgetIcon = (defaultName) => {
|
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
export default function FieldsSection({ name, inputTypes, transformInputTypePayload, currentFieldIndex, setCurrentFieldIndex, fields, setState, showOutputFormat, imagePickerOutputFormat, }) {
|
|
80
|
-
const { id } = useAppParams();
|
|
79
|
+
export default function FieldsSection({ name, inputTypes, transformInputTypePayload, currentFieldIndex, setCurrentFieldIndex, fields, setState, showOutputFormat, imagePickerOutputFormat, assetId: assetIdProp, }) {
|
|
80
|
+
const { id: idFromParams } = useAppParams();
|
|
81
|
+
const assetId = assetIdProp !== null && assetIdProp !== void 0 ? assetIdProp : idFromParams;
|
|
81
82
|
const [fieldState, setFieldState] = useState({
|
|
82
83
|
showConfirmModal: false,
|
|
83
84
|
selectedField: null,
|
|
@@ -166,9 +167,13 @@ export default function FieldsSection({ name, inputTypes, transformInputTypePayl
|
|
|
166
167
|
}
|
|
167
168
|
};
|
|
168
169
|
const onDeleteExistedField = () => __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
if (!assetId) {
|
|
171
|
+
showNotification("Asset ID is missing. Unable to delete field.", NotificationStatus.ERROR);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
169
174
|
setFieldState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
|
|
170
175
|
try {
|
|
171
|
-
const response = yield api.delete(DELETE_ASSET_FIELD_URL.replace(":assetId",
|
|
176
|
+
const response = yield api.delete(DELETE_ASSET_FIELD_URL.replace(":assetId", assetId).replace(":id", get(selectedField, "_id")));
|
|
172
177
|
const updatedFields = filter(fields, (field, index) => get(field, "_id") !== get(selectedField, "_id"));
|
|
173
178
|
const updatedImagePickerOutputFormat = filter(imagePickerOutputFormat, (field, index) => get(field, "mapId") !== get(selectedField, "mapId"));
|
|
174
179
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, currentFieldIndex: null, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
|
|
@@ -231,7 +231,15 @@ function MapFile({ open, handleCancel, filesList, fromUpload, parentFolderId, })
|
|
|
231
231
|
},
|
|
232
232
|
});
|
|
233
233
|
};
|
|
234
|
-
const
|
|
234
|
+
const preventEnterSubmit = (e) => {
|
|
235
|
+
if (e.key === "Enter" && e.target instanceof HTMLElement) {
|
|
236
|
+
const tagName = e.target.tagName.toLowerCase();
|
|
237
|
+
if (tagName !== "textarea") {
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const getMetadataForm = (_jsxs(Form, { layout: "vertical", form: form, scrollToFirstError: true, onFinish: fromUpload ? handleSubmit : handleUpdate, onKeyDown: preventEnterSubmit, className: "md-lib-m-2", children: [_jsx(AssetSelectionFormItem, { handleAssetTemplateChange: handleAssetTemplateChange, assetOptions: assetOptions, assetsLoading: assetsLoading }), selectedAssetTemplate && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { name: "teamIds", label: "Teams", children: _jsx(Select, { options: teamOptions, placeholder: "Select teams", mode: "multiple", onChange: (val) => onChangeTeams(val), style: { width: "100%" }, showSearch: true, optionFilterProp: "key" }) }), _jsx(Form.Item, { name: "expiryDate", label: "Expiry Date", children: _jsx(DatePicker, { placeholder: "Expiry Date", style: { width: "100%" } }) }), _jsx(Metadata, { asset: selectedAssetTemplate, form: form, file: (filesList === null || filesList === void 0 ? void 0 : filesList[0]) || null })] })), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-justify-end md-lib-gap-3", children: [_jsx(Button, { onClick: handleCancelWithConfirmation, children: "Cancel" }), _jsx(Button, { disabled: !selectedAssetTemplate, type: "primary",
|
|
235
243
|
// onClick={handleSubmit}
|
|
236
244
|
loading: loading || updateFileMutation.isLoading, htmlType: "submit", children: "Save" })] })] }));
|
|
237
245
|
return (_jsx(_Fragment, { children: fromUpload ? (_jsx(Drawer, { title: "Metadata", open: open, onClose: handleCancelWithConfirmation, maskClosable: false, children: getMetadataForm })) : (_jsxs("div", { className: "md-lib-p-2 md-lib-overflow-y-scroll md-lib-max-h-[calc(100vh-65px)]", children: [_jsx("p", { className: "md-lib-text-lg md-lib-font-semibold", children: "Metadata" }), getMetadataForm] })) }));
|