awing-library 2.1.75-beta → 2.1.77-beta

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.
@@ -91,6 +91,7 @@ var ViewContent = function (_a) {
91
91
  var _a;
92
92
  var keys = fieldPath.split('.');
93
93
  var fieldChange = templateDatasUpdated[keys[1]];
94
+ console.log(fieldPath, fieldChange);
94
95
  var indexOfFieldChange = (_a = viewInfoData.viewDatas) === null || _a === void 0 ? void 0 : _a.findIndex(function (field) { return field.fieldName === fieldChange.fieldName; });
95
96
  onChange(['viewDatas', String(indexOfFieldChange), 'fieldValue'], fieldChange.fieldValue);
96
97
  setChanged();
@@ -52,6 +52,7 @@ var ViewList_1 = __importDefault(require("./Components/ViewList"));
52
52
  var ViewContent_1 = __importDefault(require("./ViewContent"));
53
53
  var ViewInfo_1 = __importDefault(require("./ViewInfo"));
54
54
  var Context_2 = require("../../../../Context");
55
+ var Helpers_1 = require("../../../../Utils/Helpers");
55
56
  var TabView = function (_a) {
56
57
  var isCreate = _a.isCreate;
57
58
  var _b = (0, recoil_1.useRecoilState)((0, Recoil_1.pageState)('views')), _c = _b[0], views = _c.views, page = _c.page, setView = _b[1];
@@ -130,7 +131,7 @@ var TabView = function (_a) {
130
131
  return;
131
132
  }
132
133
  setView((0, immer_1.default)(function (draf) {
133
- (0, Utils_1.setObject)(draf, keys, value);
134
+ (0, Helpers_1.setObject)(draf, keys, value);
134
135
  }));
135
136
  };
136
137
  var handleChange = function (key) {
@@ -4,7 +4,6 @@ export declare const isObjectType: (value: unknown) => value is object;
4
4
  export declare const isObject: <T extends object>(value: unknown) => value is T;
5
5
  export declare const composeKey: <F extends (...p: any[]) => any, G extends (...p: any[]) => any>(f: F, g: G) => F;
6
6
  export declare const concatKey: (parent: string | string[]) => (child: string | string[]) => string[];
7
- export declare const setObject: <O extends {}>(obj: O, arrKey: Array<keyof O>, value: unknown) => void;
8
7
  export declare const convertTreeArrayToFlatArray: (treeArray: DataObject[]) => any[];
9
8
  export declare const convertValueByType: (type: string, val: any) => any;
10
9
  export declare const getFieldsValid: (templateDatas: TemplateData[]) => boolean[];
@@ -15,12 +15,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getTemplateDatas = exports.updateStateByPageModel = exports.getFieldsValid = exports.convertValueByType = exports.convertTreeArrayToFlatArray = exports.setObject = exports.concatKey = exports.composeKey = exports.isObject = exports.isObjectType = void 0;
18
+ exports.getTemplateDatas = exports.updateStateByPageModel = exports.getFieldsValid = exports.convertValueByType = exports.convertTreeArrayToFlatArray = exports.concatKey = exports.composeKey = exports.isObject = exports.isObjectType = void 0;
19
19
  var Enum_1 = require("../../ViewTemplate/Enum");
20
20
  var lodash_1 = require("lodash");
21
21
  var immer_1 = __importDefault(require("immer"));
22
22
  var common_1 = require("../../ViewTemplate/common");
23
23
  var enums_1 = require("../enums");
24
+ var Helpers_1 = require("../../../Utils/Helpers");
24
25
  // }
25
26
  var isDateObject = function (value) { return value instanceof Date; };
26
27
  var isNullOrUndefined = function (value) {
@@ -53,14 +54,22 @@ var concatKey = function (parent) {
53
54
  };
54
55
  };
55
56
  exports.concatKey = concatKey;
56
- var setObject = function (obj, arrKey, value) {
57
- (0, lodash_1.set)(obj, arrKey.reduce(function (acc, val) { return acc + '[' + val + ']'; }, ''), value);
58
- };
59
- exports.setObject = setObject;
60
57
  var convertTreeArrayToFlatArray = function (treeArray) {
61
58
  var result = [];
62
59
  treeArray === null || treeArray === void 0 ? void 0 : treeArray.forEach(function (data) {
63
- getChilds(data, function (item) { return result.push(item); });
60
+ getChilds(data, function (item) {
61
+ if (item.fieldType === Enum_1.TYPE_FIELD_TEMPLATE.OBJECT && !item.fieldName.includes('.')) {
62
+ var child_1 = {};
63
+ getChilds(item, function (el) {
64
+ var keys = el.fieldName.split('.');
65
+ if (keys.length > 1) {
66
+ (0, Helpers_1.setObject)(child_1, keys, el.fieldValue || el.defaultValue);
67
+ }
68
+ });
69
+ item.fieldValue = JSON.stringify((0, lodash_1.get)(child_1, item.fieldName));
70
+ }
71
+ result.push(item);
72
+ });
64
73
  });
65
74
  return result;
66
75
  };
@@ -215,8 +224,6 @@ function updateStateByPageModel(pageModel) {
215
224
  }));
216
225
  }
217
226
  exports.updateStateByPageModel = updateStateByPageModel;
218
- var getFieldsValue = function (template) {
219
- };
220
227
  /**
221
228
  * Retrieves the template data based on the provided template parameters, view information data, page ID, and view number.
222
229
  *
@@ -232,15 +239,6 @@ var getTemplateDatas = function (templateParameters, viewInfoData, pageId, viewN
232
239
  ? viewInfoData.viewDatas.find(function (el) { return el.fieldName === parameter.fieldName; })
233
240
  : null;
234
241
  var valData = tempData ? tempData.fieldValue : null;
235
- var child = {};
236
- getChilds(parameter, function (item) {
237
- var keys = item.fieldName.split('.');
238
- if (keys.length > 1) {
239
- console.log("item.fieldValue", item.fieldValue);
240
- child[keys.at(-1)] = item.fieldValue;
241
- }
242
- });
243
- console.log("child", child);
244
242
  var fieldValue = valData !== null && valData !== void 0 ? valData : (parameter.defaultValue ? parameter.defaultValue : '');
245
243
  fieldValue = (0, exports.convertValueByType)(parameter.fieldType, fieldValue);
246
244
  return {
@@ -49,7 +49,6 @@ var AWING_1 = require("../../AWING");
49
49
  var validation_1 = require("../../AWING/ultis/validation");
50
50
  var ClassicDrawer_1 = __importStar(require("../../Commons/Components/ClassicDrawer"));
51
51
  var Context_1 = require("../../Context");
52
- var Utils_1 = require("../Page/CreateOrEdit/Utils");
53
52
  var BasicInput_1 = __importDefault(require("./Components/BasicInput"));
54
53
  var CornJobInput_1 = __importDefault(require("./Components/CornJobInput"));
55
54
  var InputParameters_1 = __importDefault(require("./Components/InputParameters"));
@@ -57,7 +56,8 @@ var TriggerInput_1 = __importDefault(require("./Components/TriggerInput"));
57
56
  var Constant_1 = require("./Constant");
58
57
  var Context_2 = require("./Context");
59
58
  var Enums_1 = require("./Enums");
60
- var Utils_2 = require("./Utils");
59
+ var Utils_1 = require("./Utils");
60
+ var Helpers_1 = require("../../Utils/Helpers");
61
61
  var JobInput = (_a = {},
62
62
  _a[Enums_1.JobTypeEnum.Cron] = CornJobInput_1.default,
63
63
  _a[Enums_1.JobTypeEnum.Trigger] = TriggerInput_1.default,
@@ -81,7 +81,7 @@ var CreateOrEdit = function () {
81
81
  var _e = react_1.default.useState(), jobActionSelected = _e[0], setJobActionSelected = _e[1];
82
82
  var _f = react_1.default.useState(false), enableSubmit = _f[0], setEnableSubmit = _f[1];
83
83
  react_1.default.useEffect(function () {
84
- setEnableSubmit((0, Utils_2.getFormValidation)(jobModel, jobValid.current));
84
+ setEnableSubmit((0, Utils_1.getFormValidation)(jobModel, jobValid.current));
85
85
  }, [jobModel]);
86
86
  react_1.default.useEffect(function () {
87
87
  setLoading(true);
@@ -95,7 +95,7 @@ var CreateOrEdit = function () {
95
95
  var initJobActions = responses[0];
96
96
  setJobActions(initJobActions);
97
97
  if (responses.length > 1) {
98
- var model_1 = (0, Utils_2.cloneValue)(responses[1]);
98
+ var model_1 = (0, Utils_1.cloneValue)(responses[1]);
99
99
  setJobModel(model_1);
100
100
  setJobActionSelected(initJobActions.find(function (x) { return x.name === model_1.jobAction; }));
101
101
  }
@@ -121,7 +121,7 @@ var CreateOrEdit = function () {
121
121
  setConfirmExit(true);
122
122
  var keys = path.split('.');
123
123
  setJobModel((0, immer_1.default)(function (draft) {
124
- (0, Utils_1.setObject)(draft, keys, value);
124
+ (0, Helpers_1.setObject)(draft, keys, value);
125
125
  // draft.inputParameters[index] = item
126
126
  }));
127
127
  };
@@ -1,3 +1,5 @@
1
1
  import { FieldProps, FieldInfo } from "../../interface";
2
+ import { DataObject } from "../../../../AWING";
2
3
  export default function ObjectField(props: FieldProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare const getChilds: <T extends Record<string, DataObject>>(child: T, action: (p: T) => any) => any;
3
5
  export declare const getObjectDefaultValue: (fieldInfo: FieldInfo) => any;
@@ -14,13 +14,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getObjectDefaultValue = void 0;
17
+ exports.getObjectDefaultValue = exports.getChilds = void 0;
18
18
  var jsx_runtime_1 = require("react/jsx-runtime");
19
19
  var ListField_1 = require("./ListField");
20
20
  var material_1 = require("@mui/material");
21
21
  var styles_1 = require("@mui/styles");
22
22
  var TemplateField_1 = __importDefault(require("../../TemplateField"));
23
23
  var react_1 = require("react");
24
+ var Helpers_1 = require("../../../../Utils/Helpers");
25
+ var lodash_1 = require("lodash");
24
26
  var useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
25
27
  root: {
26
28
  textAlign: "center",
@@ -70,13 +72,27 @@ function ObjectField(props) {
70
72
  fieldChild.fieldName.split(".").slice(-1)[0]) }), index)); }) })] }));
71
73
  }
72
74
  exports.default = ObjectField;
75
+ var getChilds = function (child, action) {
76
+ var _a;
77
+ action(child);
78
+ if (((_a = child === null || child === void 0 ? void 0 : child.childrens) === null || _a === void 0 ? void 0 : _a.length) > 0) {
79
+ return child.childrens.map(function (c) { return (0, exports.getChilds)(c, action); });
80
+ }
81
+ };
82
+ exports.getChilds = getChilds;
73
83
  var getObjectDefaultValue = function (fieldInfo) {
74
84
  var _a;
75
85
  var result = {};
76
86
  (_a = fieldInfo === null || fieldInfo === void 0 ? void 0 : fieldInfo.childrens) === null || _a === void 0 ? void 0 : _a.map(function (child) {
77
87
  if (child.fieldType !== "list") {
78
- var defaultValue = child.defaultValue || "";
79
- result[child.fieldName.split(".").slice(-1)[0]] = defaultValue;
88
+ var item_1 = {};
89
+ (0, exports.getChilds)(child, function (el) {
90
+ var keys = el.fieldName.split('.');
91
+ if (keys.length > 1) {
92
+ (0, Helpers_1.setObject)(item_1, keys, el.defaultValue);
93
+ }
94
+ });
95
+ result[child.fieldName.split(".").slice(-1)[0]] = (0, lodash_1.get)(item_1, child.fieldName);
80
96
  }
81
97
  else {
82
98
  result[child.fieldName.split(".").slice(-1)[0]] =
@@ -106,7 +106,7 @@ var addChilds = function (fields, fieldInfo) {
106
106
  return result;
107
107
  };
108
108
  var convertToTreeData = function (data) {
109
- return data
109
+ var treeData = data
110
110
  .map(function (item) { return addChilds(data, item); })
111
111
  .filter(function (item) { return !item.fieldName.includes("."); })
112
112
  .map(function (item) {
@@ -121,4 +121,5 @@ var convertToTreeData = function (data) {
121
121
  return item;
122
122
  }
123
123
  });
124
+ return treeData;
124
125
  };
@@ -33,8 +33,10 @@ var jsx_runtime_1 = require("react/jsx-runtime");
33
33
  var BasicDataForm_1 = __importDefault(require("./BasicDataForm"));
34
34
  var i18n_1 = __importDefault(require("../../i18n"));
35
35
  var react_i18next_1 = require("react-i18next");
36
+ var x_date_pickers_1 = require("@mui/x-date-pickers");
37
+ var AdapterMoment_1 = require("@mui/x-date-pickers/AdapterMoment");
36
38
  function BasicDataForm(props) {
37
- return ((0, jsx_runtime_1.jsx)(react_i18next_1.I18nextProvider, { i18n: i18n_1.default, children: (0, jsx_runtime_1.jsx)(BasicDataForm_1.default, __assign({}, props)) }));
39
+ return ((0, jsx_runtime_1.jsx)(react_i18next_1.I18nextProvider, { i18n: i18n_1.default, children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.LocalizationProvider, { dateAdapter: AdapterMoment_1.AdapterMoment, children: (0, jsx_runtime_1.jsx)(BasicDataForm_1.default, __assign({}, props)) }) }));
38
40
  }
39
41
  exports.BasicDataForm = BasicDataForm;
40
42
  __exportStar(require("./interface"), exports);
@@ -41,8 +41,8 @@ var BarLineComponent = function (props) {
41
41
  bodySpacing: 8,
42
42
  callbacks: {
43
43
  title: function (tooltipItems) {
44
- //Sửa lại với thời gian theo giờ
45
44
  var _a;
45
+ //Sửa lại với thời gian theo giờ
46
46
  var timeFormat = (_a = tooltipItems[0].raw) === null || _a === void 0 ? void 0 : _a.x;
47
47
  var isTimelineHour = (timeFormat === null || timeFormat === void 0 ? void 0 : timeFormat.length) > 8;
48
48
  if (isTimelineHour) {
@@ -93,16 +93,7 @@ var BarLineComponent = function (props) {
93
93
  },
94
94
  scales: {
95
95
  x: optionsDefault
96
- ? {
97
- type: 'timeseries',
98
- time: {
99
- parser: 'YYYYMMDD',
100
- },
101
- unit: 'month',
102
- displayFormats: {
103
- month: 'DD/MM'
104
- },
105
- }
96
+ ? {}
106
97
  : {
107
98
  type: 'time',
108
99
  display: true,
@@ -104,3 +104,4 @@ export interface IHeadCells {
104
104
  }
105
105
  export declare const updateObjectFields: (originalObj: any, changedValues: any) => any;
106
106
  export declare function formatChartNumber(val: any, language: string): string;
107
+ export declare const setObject: <O extends {}>(obj: O, arrKey: Array<keyof O>, value: unknown) => void;
@@ -23,10 +23,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.formatChartNumber = exports.updateObjectFields = exports.validateNumber = exports.getToday = exports.convertDataSetPattern = exports.convertAnalyticModelToChartDataAdvance = exports.getStartOfDay = exports.timestampToStringDDMMYYYY = exports.dateToStringDDMMYYYY = exports.convertTimelineToDateTime = exports.dateTimeToString = exports.convertTimestampToDateTime = exports.convertDateTimeToTimestamp = exports.checkValidUrl = exports.validateAnalyticTypes = exports.stringToListAccessPoint = exports.checkValidMacAddress = exports.checkValidStringListAP = exports.convertTimeLine = exports.WMAPEcalculator = exports.roundDecimalNumber = exports.convertArrayToObject = exports.offlinePaginate = exports.changeToAlias = exports.calculatorDirectoryIdRoot = exports.getRoutePath = exports.timestampToStringDDMMYYYYHHmm = exports.dateToStringddddDDMMYYYYHHmm = exports.downloadZipFile = exports.downloadFilePattern = exports.generateUUID = exports.displayLongString = exports.getQueryVariable = exports.formatNumber = exports.dateToString = exports.getCookie = exports.TIMELINE_TYPE = void 0;
26
+ exports.setObject = exports.formatChartNumber = exports.updateObjectFields = exports.validateNumber = exports.getToday = exports.convertDataSetPattern = exports.convertAnalyticModelToChartDataAdvance = exports.getStartOfDay = exports.timestampToStringDDMMYYYY = exports.dateToStringDDMMYYYY = exports.convertTimelineToDateTime = exports.dateTimeToString = exports.convertTimestampToDateTime = exports.convertDateTimeToTimestamp = exports.checkValidUrl = exports.validateAnalyticTypes = exports.stringToListAccessPoint = exports.checkValidMacAddress = exports.checkValidStringListAP = exports.convertTimeLine = exports.WMAPEcalculator = exports.roundDecimalNumber = exports.convertArrayToObject = exports.offlinePaginate = exports.changeToAlias = exports.calculatorDirectoryIdRoot = exports.getRoutePath = exports.timestampToStringDDMMYYYYHHmm = exports.dateToStringddddDDMMYYYYHHmm = exports.downloadZipFile = exports.downloadFilePattern = exports.generateUUID = exports.displayLongString = exports.getQueryVariable = exports.formatNumber = exports.dateToString = exports.getCookie = exports.TIMELINE_TYPE = void 0;
27
27
  var moment_1 = __importDefault(require("moment"));
28
28
  var i18n_1 = __importDefault(require("../i18n"));
29
29
  var helper_1 = require("../AWING/helper");
30
+ var lodash_1 = require("lodash");
30
31
  var TIMELINE_TYPE;
31
32
  (function (TIMELINE_TYPE) {
32
33
  TIMELINE_TYPE[TIMELINE_TYPE["HOUR"] = 0] = "HOUR";
@@ -532,3 +533,7 @@ function formatChartNumber(val, language) {
532
533
  return formatValue;
533
534
  }
534
535
  exports.formatChartNumber = formatChartNumber;
536
+ var setObject = function (obj, arrKey, value) {
537
+ (0, lodash_1.set)(obj, arrKey.reduce(function (acc, val) { return acc + '[' + val + ']'; }, ''), value);
538
+ };
539
+ exports.setObject = setObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.75-beta",
3
+ "version": "2.1.77-beta",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",