@bindu-dashing/dam-solution-v2 5.8.115 → 5.8.118

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.
@@ -1,3 +1,12 @@
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
+ };
1
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
11
  import { Button, Checkbox, Form, Input } from "antd";
3
12
  import TextField from "./fieldProperties/TextField";
@@ -5,28 +14,43 @@ import NumberField from "./fieldProperties/NumberField";
5
14
  import { useEffect, useState } from "react";
6
15
  import DateField from "./fieldProperties/DateField";
7
16
  import OptionsField from "./fieldProperties/OptionsField";
8
- import { InputSupportedTypes, InputTypes, } from "../utilities/constants/interface";
17
+ import { InputSupportedTypes, InputTypes, NotificationStatus, } from "../utilities/constants/interface";
9
18
  import { first, get, includes, isArray, nth } from "lodash";
10
19
  import { useDamConfig } from "../hocs/DamConfigContext";
11
20
  import useAppNavigate from "../utilities/useAppNavigate";
12
21
  import { getFormItem } from "../MyDrive/fileDetails/MetaForm";
13
22
  import dayjs from "dayjs";
14
23
  import { DATE_FORMAT, DATE_WITH_TIME_FORMAT } from "../hocs/appConstants";
24
+ import { showNotification } from "../common/notifications";
25
+ import { UPDATE_SUCCESS } from "../utilities/constants/messages";
15
26
  export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpdateField, currentInputType, index, allFields, }) {
16
27
  const { styles } = useDamConfig();
17
28
  const navigate = useAppNavigate();
18
29
  const [defaultValueInput, setDefaultValueInput] = useState("");
19
- const onUpdate = (values) => {
20
- const allValues = Object.assign({}, values);
21
- if (allValues === null || allValues === void 0 ? void 0 : allValues.defaultValue) {
22
- allValues["defaultValue"] = getFormattedDefaultValue(allValues);
30
+ const [loading, setLoading] = useState(false);
31
+ const onUpdate = (values) => __awaiter(this, void 0, void 0, function* () {
32
+ try {
33
+ setLoading(true);
34
+ const allValues = Object.assign({}, values);
35
+ if (allValues === null || allValues === void 0 ? void 0 : allValues.defaultValue) {
36
+ allValues["defaultValue"] = getFormattedDefaultValue(allValues);
37
+ }
38
+ if (get(field, "_id", null)) {
39
+ allValues["_id"] = get(field, "_id");
40
+ }
41
+ // Small delay to show loading state
42
+ yield new Promise((resolve) => setTimeout(resolve, 300));
43
+ onUpdateField(allValues, currentInputType, index);
44
+ setCurrentFieldIndex(null);
45
+ showNotification(UPDATE_SUCCESS, NotificationStatus.SUCCESS);
23
46
  }
24
- if (get(field, "_id", null)) {
25
- allValues["_id"] = get(field, "_id");
47
+ catch (error) {
48
+ // Handle error if needed
26
49
  }
27
- onUpdateField(allValues, currentInputType, index);
28
- setCurrentFieldIndex(null);
29
- };
50
+ finally {
51
+ setLoading(false);
52
+ }
53
+ });
30
54
  const [form] = Form.useForm();
31
55
  const getFormattedDefaultValue = (values) => {
32
56
  const defaultName = get(field, "defaultName");
@@ -193,5 +217,5 @@ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpda
193
217
  ], get(currentInputType, "defaultName")) && (_jsx(OptionsField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []), currentInputType: currentInputType }))] })] }), _jsxs(Form.Item, { className: "md-lib-flex md-lib-items-center md-lib-justify-end md-lib-absolute md-lib-bottom-0 md-lib-right-0 !md-lib-my-2", children: [_jsx(Button, { color: "primary", variant: "text", onClick: () => {
194
218
  setCurrentFieldIndex(null);
195
219
  // navigate(ASSETS_SCREEN);
196
- }, size: "large", children: "Cancel" }), _jsx(Button, { color: "primary", htmlType: "submit", className: "md-lib-ml-2 md-lib-border-primaryColor md-lib-text-primaryColor", size: "large", children: "Update" })] })] }) })] }));
220
+ }, size: "large", children: "Cancel" }), _jsx(Button, { color: "primary", htmlType: "submit", className: "md-lib-ml-2 md-lib-border-primaryColor md-lib-text-primaryColor", size: "large", loading: loading, children: "Update" })] })] }) })] }));
197
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.115",
3
+ "version": "5.8.118",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",