awing-library 2.1.2-stable.37 → 2.1.2-stable.39

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.
@@ -5,7 +5,7 @@ const CheckBoxInput = (fieldDefinition)=>{
5
5
  const { name, value, onChange, readOnly, disabled, label, onValidateCustom } = fieldDefinition;
6
6
  const onValidate = (val)=>{
7
7
  if (onValidateCustom) return onValidateCustom(val);
8
- return notNullValid(value);
8
+ return notNullValid(val);
9
9
  };
10
10
  const isChecked = Boolean(value);
11
11
  return /*#__PURE__*/ jsx(FormControl, {
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigFilter.d.ts","sourceRoot":"","sources":["../../../../../src/Features/NOTIFICATION/components/ConfigNotification/ConfigFilter.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAqB,MAAM,QAAQ,CAAC;AAG1D,QAAA,MAAM,YAAY,0JAUf,aAAa,4CA+Uf,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ConfigFilter.d.ts","sourceRoot":"","sources":["../../../../../src/Features/NOTIFICATION/components/ConfigNotification/ConfigFilter.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAqB,MAAM,QAAQ,CAAC;AAG1D,QAAA,MAAM,YAAY,0JAUf,aAAa,4CAgVf,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -108,7 +108,8 @@ const ConfigFilter = ({ loading, getUsers, getUserGroups, getTemplates, getDataS
108
108
  type: FIELD_TYPE.TEXT,
109
109
  fieldName: 'email',
110
110
  label: t('NotificationConfig.Email'),
111
- required: true
111
+ required: true,
112
+ length: 100
112
113
  });
113
114
  else if (dataConfigFilter?.changeType === ChannelType.UserIds) emailAppFields.push({
114
115
  type: FIELD_TYPE.ASYNC_AUTOCOMPLETE,
@@ -1 +1 @@
1
- {"version":3,"file":"AddOrEdit.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/Schema/AddOrEdit.tsx"],"names":[],"mappings":"AAqBA,MAAM,MAAM,iBAAiB,GAAG;IAC5B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,QAAA,MAAM,SAAS,UAAW,iBAAiB,4CA2H1C,CAAC;AACF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"AddOrEdit.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/Schema/AddOrEdit.tsx"],"names":[],"mappings":"AAqBA,MAAM,MAAM,iBAAiB,GAAG;IAC5B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,QAAA,MAAM,SAAS,UAAW,iBAAiB,4CAiI1C,CAAC;AACF,eAAe,SAAS,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { textValidation } from "../../../AWING/index.js";
2
+ import { CircularProgress, textValidation } from "../../../AWING/index.js";
3
3
  import { ClassicDrawer } from "../../../Commons/index.js";
4
4
  import { patternFieldText } from "../../constants.js";
5
5
  import { useAtom, useAtomValue, useSetAtom } from "jotai";
@@ -26,6 +26,7 @@ const AddOrEdit_AddOrEdit = (props)=>{
26
26
  const hasValidationErrors = useAtomValue(validationErrorsState);
27
27
  const getResetAllState = useSetAtom(resetAllState);
28
28
  const [loadingCreateSchema, setLoadingCreateSchema] = useState(false);
29
+ const [loading, setLoading] = useState(false);
29
30
  useEffect(()=>{
30
31
  if (services && 0 === objectTypeCodes.length) services.getObjectDefinitions().then((data)=>{
31
32
  const objectDefinitions = data.items;
@@ -33,19 +34,25 @@ const AddOrEdit_AddOrEdit = (props)=>{
33
34
  });
34
35
  }, []);
35
36
  useEffect(()=>{
36
- if (!isCreate && services) services.getSchemaById({
37
- id: Number(chemaId)
38
- }).then((schema)=>{
39
- setSchema(schema);
40
- setCurrentSchema(schema);
41
- if (schema.objectTypeCode) services?.getTypeDefinitions({
42
- objectTypeCode: schema.objectTypeCode
43
- }).then((data)=>{
44
- setFullFields(data.items);
45
- }).catch((error)=>{
46
- console.error('Error fetching type definitions:', error);
37
+ if (!isCreate && services) {
38
+ setLoading(true);
39
+ services.getSchemaById({
40
+ id: Number(chemaId)
41
+ }).then((schema)=>{
42
+ setSchema(schema);
43
+ setCurrentSchema(schema);
44
+ if (schema.objectTypeCode) return services?.getTypeDefinitions({
45
+ objectTypeCode: schema.objectTypeCode
46
+ }).then((data)=>{
47
+ setFullFields(data.items);
48
+ }).catch((error)=>{
49
+ console.error('Error fetching type definitions:', error);
50
+ });
51
+ return null;
52
+ }).finally(()=>{
53
+ setLoading(false);
47
54
  });
48
- });
55
+ }
49
56
  }, [
50
57
  chemaId
51
58
  ]);
@@ -101,7 +108,7 @@ const AddOrEdit_AddOrEdit = (props)=>{
101
108
  childrenWrapperStyle: {
102
109
  padding: 0
103
110
  },
104
- children: /*#__PURE__*/ jsx(TabConfigtion, {
111
+ children: loading ? /*#__PURE__*/ jsx(CircularProgress, {}) : /*#__PURE__*/ jsx(TabConfigtion, {
105
112
  ref: tabConfigtionRef
106
113
  })
107
114
  });
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaInformation.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Schema/components/SchemaInformation.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,oBAAoB;IACjC,qBAAqB,EAAE,MAAM,GAAG,EAAE,CAAC;IACnC,mBAAmB,EAAE,MAAM,OAAO,CAAC;CACtC;AAED,QAAA,MAAM,iBAAiB,gGA4GrB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"SchemaInformation.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Schema/components/SchemaInformation.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,oBAAoB;IACjC,qBAAqB,EAAE,MAAM,GAAG,EAAE,CAAC;IACnC,mBAAmB,EAAE,MAAM,OAAO,CAAC;CACtC;AAED,QAAA,MAAM,iBAAiB,gGA+GrB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Typography } from "@mui/material";
3
- import { DataForm, FIELD_TYPE, textValidation } from "../../../../AWING/index.js";
3
+ import { CircularProgress, DataForm, FIELD_TYPE, textValidation } from "../../../../AWING/index.js";
4
4
  import { patternFieldText } from "../../../constants.js";
5
5
  import { useAtom, useAtomValue, useSetAtom } from "jotai";
6
6
  import { forwardRef, useImperativeHandle, useRef, useState } from "react";
@@ -19,6 +19,7 @@ const SchemaInformation_SchemaInformation = /*#__PURE__*/ forwardRef((_props, re
19
19
  const setConfirmExit = useSetAtom(confirmExitState);
20
20
  const isCreate = !schema?.id;
21
21
  const [isChangeName, setIsChangeName] = useState(false);
22
+ const [loading, setLoading] = useState(false);
22
23
  const handleChangeObjectTypeCode = (e)=>{
23
24
  const value = e.target?.value;
24
25
  setCurrentSchema((prev)=>({
@@ -26,12 +27,15 @@ const SchemaInformation_SchemaInformation = /*#__PURE__*/ forwardRef((_props, re
26
27
  objectTypeCode: value
27
28
  }));
28
29
  isCreate && setConfirmExit(true);
30
+ setLoading(true);
29
31
  services?.getTypeDefinitions({
30
32
  objectTypeCode: value
31
33
  }).then((data)=>{
32
34
  setFullFields(data.items);
35
+ setLoading(false);
33
36
  }).catch((error)=>{
34
37
  console.error('Error fetching type definitions:', error);
38
+ setLoading(false);
35
39
  });
36
40
  };
37
41
  const handleChangeSchemaName = (e)=>{
@@ -95,7 +99,7 @@ const SchemaInformation_SchemaInformation = /*#__PURE__*/ forwardRef((_props, re
95
99
  },
96
100
  children: `${t('Schema.FieldLabel')} *`
97
101
  }),
98
- /*#__PURE__*/ jsx(TreeSchema, {
102
+ loading ? /*#__PURE__*/ jsx(CircularProgress, {}) : /*#__PURE__*/ jsx(TreeSchema, {
99
103
  ref: treeSchemaRef
100
104
  })
101
105
  ]
@@ -225,7 +225,8 @@ const getSchemaInput = (currentSchemaDetails, oldSchemaDetails)=>{
225
225
  function validateJsonString(jsonString, schema, selectedItems) {
226
226
  try {
227
227
  if (jsonString.includes('{workspaceId}')) jsonString = jsonString.replace(/{workspaceId}/g, '0');
228
- const obj = JSON.parse(jsonString);
228
+ const formatJson = jsonString.replace(/([{,]\s*)(\w+)(\s*:)/g, '$1"$2"$3');
229
+ const obj = JSON.parse(formatJson);
229
230
  const allowedKeys = (schema.children ?? []).map((child)=>({
230
231
  fieldName: child?.fieldName ?? '',
231
232
  targetType: child?.targetType ?? '',
@@ -233,13 +234,10 @@ function validateJsonString(jsonString, schema, selectedItems) {
233
234
  isSelected: selectedItems ? selectedItems.includes(String(child?.id)) : true
234
235
  }));
235
236
  const objKeys = Object.keys(obj);
236
- for (const key of objKeys)if (!allowedKeys.some((allowed)=>allowed.fieldName === key && allowed.isSelected)) {
237
- debugger;
238
- return {
239
- isValid: false,
240
- error: `Key không được phép: ${key}`
241
- };
242
- }
237
+ for (const key of objKeys)if (!allowedKeys.some((allowed)=>allowed.fieldName === key && allowed.isSelected)) return {
238
+ isValid: false,
239
+ error: `Key không được phép: ${key}`
240
+ };
243
241
  const hasPrimaryKey = allowedKeys.some(({ fieldName, isPrimaryKey, isSelected })=>isPrimaryKey && isSelected && fieldName in obj);
244
242
  if (!hasPrimaryKey) return {
245
243
  isValid: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.2-stable.37",
3
+ "version": "2.1.2-stable.39",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {