awing-library 2.1.153-beta → 2.1.154-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.
- package/lib/ACM-AXN/Page/CreateOrEdit/ListenTemplate.d.ts +6 -0
- package/lib/ACM-AXN/Page/CreateOrEdit/ListenTemplate.js +63 -0
- package/lib/ACM-AXN/Page/CreateOrEdit/Recoil.d.ts +11 -1
- package/lib/ACM-AXN/Page/CreateOrEdit/Recoil.js +16 -1
- package/lib/ACM-AXN/Page/CreateOrEdit/Tabview/ViewContent.js +5 -6
- package/lib/ACM-AXN/Page/CreateOrEdit/Tabview/ViewInfo.d.ts +1 -2
- package/lib/ACM-AXN/Page/CreateOrEdit/Tabview/ViewInfo.js +24 -22
- package/lib/ACM-AXN/Page/CreateOrEdit/Tabview/index.js +17 -23
- package/lib/ACM-AXN/Page/CreateOrEdit/index.js +3 -1
- package/lib/ACM-AXN/Template/CreateOrEdit/Template/Parameter.js +1 -0
- package/lib/ACM-AXN/Template/Types.d.ts +9 -9
- package/lib/ACM-AXN/ViewTemplate/TemplateField/Fields/BasicField/index.js +0 -1
- package/lib/AWING/DataForm/DataInput.js +14 -13
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ITemplateModel } from '../../../ACM-AXN/Template';
|
|
2
|
+
import { Template } from '../Types';
|
|
3
|
+
export declare const usePageCache: () => {
|
|
4
|
+
getTemplate: (templateId: string) => Promise<ITemplateModel>;
|
|
5
|
+
getTemplateList: (directoryId: string) => Promise<Template[]>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.usePageCache = void 0;
|
|
27
|
+
var react_1 = __importDefault(require("react"));
|
|
28
|
+
var Context_1 = __importDefault(require("../Context"));
|
|
29
|
+
var recoil_1 = require("recoil");
|
|
30
|
+
var Recoil_1 = require("./Recoil");
|
|
31
|
+
var usePageCache = function () {
|
|
32
|
+
var _a = (0, recoil_1.useRecoilState)(Recoil_1.pageCacheData), _b = _a[0], directoryTemplate = _b.directoryTemplate, templates = _b.templates, setPageCache = _a[1];
|
|
33
|
+
var service = (0, Context_1.default)().service;
|
|
34
|
+
return {
|
|
35
|
+
getTemplate: react_1.default.useCallback(function (templateId) {
|
|
36
|
+
return new Promise(function (resolve) {
|
|
37
|
+
var template = templates.find(function (item) { return item.template.id === templateId; });
|
|
38
|
+
if (template)
|
|
39
|
+
resolve(template);
|
|
40
|
+
else
|
|
41
|
+
service.templatesGet(templateId).then(function (res) {
|
|
42
|
+
setPageCache(function (p) { return (__assign(__assign({}, p), { templates: __spreadArray(__spreadArray([], p.templates, true), [res], false) })); });
|
|
43
|
+
resolve(res);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
+
[templates]),
|
|
49
|
+
getTemplateList: react_1.default.useCallback(function (directoryId) { return new Promise(function (resolve) {
|
|
50
|
+
var directory = directoryTemplate.find(function (item) { return item.directoryId === directoryId; });
|
|
51
|
+
if (directory)
|
|
52
|
+
resolve(directory.templateList);
|
|
53
|
+
else {
|
|
54
|
+
service.templatesGetByDirectoryId(directoryId).then(function (res) {
|
|
55
|
+
setPageCache(function (p) { return (__assign(__assign({}, p), { directoryTemplate: __spreadArray(__spreadArray([], p.directoryTemplate, true), [{ directoryId: directoryId, templateList: res }], false) })); });
|
|
56
|
+
resolve(res);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
}); }, [directoryTemplate]),
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.usePageCache = usePageCache;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Directory } from '../../Campaign/Types';
|
|
2
|
-
import { FormValid, PageModel, PageViewEvent } from '../Types';
|
|
2
|
+
import { FormValid, PageModel, PageViewEvent, Template } from '../Types';
|
|
3
|
+
import { ITemplateModel, ITemplateType } from '../../../ACM-AXN/Template';
|
|
3
4
|
export declare const pageDirectoriesState: import("recoil").RecoilState<Directory[]>;
|
|
4
5
|
export declare const wiewMounted: import("recoil").RecoilState<boolean>;
|
|
5
6
|
export declare const pageRootDeirectory: import("recoil").RecoilState<string>;
|
|
@@ -9,3 +10,12 @@ export declare const pageEventState: import("recoil").RecoilState<PageViewEvent[
|
|
|
9
10
|
export declare const validForm: import("recoil").RecoilState<FormValid>;
|
|
10
11
|
export declare const pageState: (param: keyof PageModel) => import("recoil").RecoilState<PageModel>;
|
|
11
12
|
export declare const hasDeprecated: import("recoil").RecoilState<boolean>;
|
|
13
|
+
export declare const pageCacheData: import("recoil").RecoilState<{
|
|
14
|
+
directoryTemplate: {
|
|
15
|
+
directoryId: string;
|
|
16
|
+
templateList: Template[];
|
|
17
|
+
}[];
|
|
18
|
+
templates: ITemplateModel[];
|
|
19
|
+
}>;
|
|
20
|
+
export declare const templateTypeState: import("recoil").RecoilState<ITemplateType[]>;
|
|
21
|
+
export declare const templateDirectoriesState: import("recoil").RecoilState<Directory[]>;
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.hasDeprecated = exports.pageState = exports.validForm = exports.pageEventState = exports.pageRootState = exports.pageChangedFormState = exports.pageRootDeirectory = exports.wiewMounted = exports.pageDirectoriesState = void 0;
|
|
14
|
+
exports.templateDirectoriesState = exports.templateTypeState = exports.pageCacheData = exports.hasDeprecated = exports.pageState = exports.validForm = exports.pageEventState = exports.pageRootState = exports.pageChangedFormState = exports.pageRootDeirectory = exports.wiewMounted = exports.pageDirectoriesState = void 0;
|
|
15
15
|
var lodash_1 = require("lodash");
|
|
16
16
|
var recoil_1 = require("recoil");
|
|
17
17
|
var Constant_1 = require("../Constant");
|
|
@@ -130,3 +130,18 @@ exports.hasDeprecated = (0, recoil_1.atom)({
|
|
|
130
130
|
key: 'hasDeprecated',
|
|
131
131
|
default: false,
|
|
132
132
|
});
|
|
133
|
+
exports.pageCacheData = (0, recoil_1.atom)({
|
|
134
|
+
key: 'pageCacheData',
|
|
135
|
+
default: {
|
|
136
|
+
directoryTemplate: [],
|
|
137
|
+
templates: [],
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
exports.templateTypeState = (0, recoil_1.atom)({
|
|
141
|
+
key: 'templateTypeState',
|
|
142
|
+
default: [],
|
|
143
|
+
});
|
|
144
|
+
exports.templateDirectoriesState = (0, recoil_1.atom)({
|
|
145
|
+
key: 'templateDirectoriesState',
|
|
146
|
+
default: [],
|
|
147
|
+
});
|
|
@@ -72,11 +72,13 @@ var enums_1 = require("../../enums");
|
|
|
72
72
|
var Recoil_1 = require("../Recoil");
|
|
73
73
|
var Utils_1 = require("../Utils");
|
|
74
74
|
var Styles_1 = require("./Styles");
|
|
75
|
+
var ListenTemplate_1 = require("../ListenTemplate");
|
|
75
76
|
var ViewContent = function (_a) {
|
|
76
77
|
var _b, _c, _d, _e, _f;
|
|
77
78
|
var viewInfoData = _a.viewInfoData, pageId = _a.pageId, viewNumber = _a.viewNumber, onChange = _a.onChange, isCreate = _a.isCreate;
|
|
78
79
|
var _g = (0, Context_2.default)(), service = _g.service, pageCode = _g.pageCode, domainId = _g.domainId, CONFIGS = _g.configs;
|
|
79
80
|
var appHelper = (0, Context_1.useAwing)().appHelper;
|
|
81
|
+
var getTemplate = (0, ListenTemplate_1.usePageCache)().getTemplate;
|
|
80
82
|
var _h = react_1.default.useState(''), scriptValidationTemplate = _h[0], setScriptValidationTemplate = _h[1];
|
|
81
83
|
var _j = react_1.default.useState(''), scriptAutoField = _j[0], setScriptAutoField = _j[1];
|
|
82
84
|
var _k = react_1.default.useState(false), loading = _k[0], setLoading = _k[1];
|
|
@@ -84,20 +86,17 @@ var ViewContent = function (_a) {
|
|
|
84
86
|
var rootDirectory = (0, recoil_1.useRecoilValue)(Recoil_1.pageRootDeirectory);
|
|
85
87
|
var _l = (0, recoil_1.useRecoilState)(Recoil_1.pageEventState), events = _l[0], setEvent = _l[1];
|
|
86
88
|
react_1.default.useEffect(function () {
|
|
89
|
+
onChange(['viewDatas'], []);
|
|
87
90
|
if (viewInfoData === null || viewInfoData === void 0 ? void 0 : viewInfoData.templateId) {
|
|
88
91
|
setLoading(true);
|
|
89
|
-
|
|
90
|
-
.templatesGet(viewInfoData.templateId)
|
|
92
|
+
getTemplate(viewInfoData.templateId)
|
|
91
93
|
.then(handleResData)
|
|
92
94
|
.finally(function () {
|
|
93
95
|
setLoading(false);
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
|
-
else {
|
|
97
|
-
onChange(['viewDatas'], []);
|
|
98
|
-
}
|
|
99
98
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
|
-
}, [viewInfoData.templateId
|
|
99
|
+
}, [viewInfoData.templateId]);
|
|
101
100
|
react_1.default.useEffect(function () {
|
|
102
101
|
if (!isUniq.current) {
|
|
103
102
|
setEvent(function (prev) {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Directory } from '../../../Campaign/Types';
|
|
3
2
|
import { ViewModel } from '../../Types';
|
|
4
3
|
import { ITemplateType } from '../../../../ACM-AXN/Template/Types';
|
|
5
4
|
interface ViewInfoProps {
|
|
6
5
|
templateTypes: ITemplateType[];
|
|
7
|
-
directories: Directory[];
|
|
8
6
|
onChange: (keys: string[], value: unknown) => void;
|
|
9
7
|
viewInfoData: ViewModel;
|
|
8
|
+
viewNumber: number;
|
|
10
9
|
}
|
|
11
10
|
declare const ViewInfo: React.FC<ViewInfoProps>;
|
|
12
11
|
export default ViewInfo;
|
|
@@ -49,17 +49,21 @@ var Constant_1 = require("../../../../ACM-AXN/Page/Constant");
|
|
|
49
49
|
var react_router_dom_1 = require("react-router-dom");
|
|
50
50
|
var recoil_1 = require("recoil");
|
|
51
51
|
var Recoil_1 = require("../Recoil");
|
|
52
|
+
var Constant_2 = require("../../../../ACM-AXN/Common/Constant");
|
|
53
|
+
var ListenTemplate_1 = require("../ListenTemplate");
|
|
52
54
|
var ViewInfo = function (_a) {
|
|
53
|
-
var
|
|
55
|
+
var templateTypes = _a.templateTypes, onChange = _a.onChange, viewInfoData = _a.viewInfoData, viewNumber = _a.viewNumber;
|
|
54
56
|
var pageId = (0, react_router_dom_1.useParams)().pageId;
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var _b = react_1.default.useState([]), templates = _b[0], setTemplates = _b[1];
|
|
58
|
-
var _c = react_1.default.useState(false), loadingTemplate = _c[0], setLoadingTemplate = _c[1];
|
|
59
|
-
var _d = (0, recoil_1.useRecoilState)(Recoil_1.wiewMounted), isMounted = _d[0], setIsMounted = _d[1];
|
|
60
|
-
var setDeprecated = (0, recoil_1.useSetRecoilState)(Recoil_1.hasDeprecated);
|
|
61
|
-
var _e = (0, Context_1.default)(), service = _e.service, pageCode = _e.pageCode, domainId = _e.domainId;
|
|
57
|
+
var _b = (0, Context_1.default)(), pageCode = _b.pageCode, domainId = _b.domainId;
|
|
58
|
+
var getTemplateList = (0, ListenTemplate_1.usePageCache)().getTemplateList;
|
|
62
59
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
60
|
+
var directories = (0, recoil_1.useRecoilValue)(Recoil_1.templateDirectoriesState);
|
|
61
|
+
var _c = (0, recoil_1.useRecoilState)(Recoil_1.wiewMounted), isMounted = _c[0], setIsMounted = _c[1];
|
|
62
|
+
var setEvent = (0, recoil_1.useSetRecoilState)(Recoil_1.pageEventState);
|
|
63
|
+
var setDeprecated = (0, recoil_1.useSetRecoilState)(Recoil_1.hasDeprecated);
|
|
64
|
+
var _d = react_1.default.useState([]), templates = _d[0], setTemplates = _d[1];
|
|
65
|
+
var _e = react_1.default.useState(false), loadingTemplate = _e[0], setLoadingTemplate = _e[1];
|
|
66
|
+
var defaultDirectory = react_1.default.useMemo(function () { return directories.find(function (item) { return item.parentDirectoryId === '99'; }); }, [directories]);
|
|
63
67
|
(0, react_1.useEffect)(function () {
|
|
64
68
|
var savedDirectoryId = JSON.parse(localStorage.getItem(Constant_1.PAGE_LOGIN_DIRECTORY_SELECTED) || '{}')[Array.isArray(domainId) ? 'awingPge' : domainId];
|
|
65
69
|
if (savedDirectoryId && !pageId && !isMounted) {
|
|
@@ -82,8 +86,9 @@ var ViewInfo = function (_a) {
|
|
|
82
86
|
if (keyUpdate === 'directoryId') {
|
|
83
87
|
localStorage.setItem(Constant_1.PAGE_LOGIN_DIRECTORY_SELECTED, JSON.stringify((_a = {}, _a[Array.isArray(domainId) ? 'awingPge' : domainId] = obj[keyUpdate], _a)));
|
|
84
88
|
}
|
|
85
|
-
overWriteOnChange(['templateId'],
|
|
89
|
+
overWriteOnChange(['templateId'], '');
|
|
86
90
|
}
|
|
91
|
+
setEvent(function (res) { return res.filter(function (x) { return x.viewNumber !== viewNumber; }); });
|
|
87
92
|
overWriteOnChange([keyUpdate], obj[keyUpdate]);
|
|
88
93
|
},
|
|
89
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -98,6 +103,10 @@ var ViewInfo = function (_a) {
|
|
|
98
103
|
var validStatus = !(isValidationFields === null || isValidationFields === void 0 ? void 0 : isValidationFields.includes(false)) &&
|
|
99
104
|
fieldsRequireStatus &&
|
|
100
105
|
validProcessStatus === enums_1.VALID_PROCESS_CODE.VALIDATED;
|
|
106
|
+
var directoryId = viewInfoData.directoryId;
|
|
107
|
+
if (directoryId) {
|
|
108
|
+
getTemplates(directoryId, viewInfoData.templateId);
|
|
109
|
+
}
|
|
101
110
|
onChange(['validStatus'], validStatus);
|
|
102
111
|
// onChangeCompletedTab("1", validStatus);
|
|
103
112
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -108,24 +117,17 @@ var ViewInfo = function (_a) {
|
|
|
108
117
|
}
|
|
109
118
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
119
|
}, [viewInfoData, defaultDirectory]);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
cacheDirectoryId.current = directoryId;
|
|
115
|
-
getTemplates(directoryId);
|
|
116
|
-
}
|
|
117
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
|
-
}, [viewInfoData]);
|
|
119
|
-
var getTemplates = function (directoryId) {
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
+
var getTemplates = react_1.default.useCallback((0, lodash_1.debounce)(function (directoryId, templateId) {
|
|
122
|
+
if (templateId === void 0) { templateId = ''; }
|
|
120
123
|
setLoadingTemplate(true);
|
|
121
|
-
|
|
122
|
-
.templatesGetByDirectoryId(directoryId)
|
|
124
|
+
getTemplateList(directoryId)
|
|
123
125
|
.then(function (res) {
|
|
124
|
-
var viewDeprecate = res.find(function (x) { return x.id ===
|
|
126
|
+
var viewDeprecate = res.find(function (x) { return x.id === templateId && x.isDeprecated; });
|
|
125
127
|
setTemplates(res.filter(function (x) { return !x.isDeprecated; }).concat(viewDeprecate ? [viewDeprecate] : []));
|
|
126
128
|
})
|
|
127
129
|
.finally(function () { return setLoadingTemplate(false); });
|
|
128
|
-
};
|
|
130
|
+
}, Constant_2.Constants.DEBOUNCE_TIME_300), []);
|
|
129
131
|
var templateOptions = react_1.default.useMemo(function () {
|
|
130
132
|
var result = [];
|
|
131
133
|
if (viewInfoData.templateTypeId) {
|
|
@@ -38,12 +38,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
var Helpers_1 = require("../../../../Utils/Helpers");
|
|
41
42
|
var immer_1 = __importDefault(require("immer"));
|
|
43
|
+
var lodash_1 = require("lodash");
|
|
42
44
|
var react_1 = __importStar(require("react"));
|
|
43
45
|
var react_i18next_1 = require("react-i18next");
|
|
44
46
|
var recoil_1 = require("recoil");
|
|
47
|
+
var Context_1 = require("../../../../Context");
|
|
45
48
|
var Constant_1 = require("../../Constant");
|
|
46
|
-
var
|
|
49
|
+
var Context_2 = __importDefault(require("../../Context"));
|
|
47
50
|
var enums_1 = require("../../enums");
|
|
48
51
|
var Recoil_1 = require("../Recoil");
|
|
49
52
|
var Utils_1 = require("../Utils");
|
|
@@ -51,39 +54,30 @@ var Panel_1 = __importDefault(require("./Components/Panel"));
|
|
|
51
54
|
var ViewList_1 = __importDefault(require("./Components/ViewList"));
|
|
52
55
|
var ViewContent_1 = __importDefault(require("./ViewContent"));
|
|
53
56
|
var ViewInfo_1 = __importDefault(require("./ViewInfo"));
|
|
54
|
-
var Context_2 = require("../../../../Context");
|
|
55
|
-
var Helpers_1 = require("../../../../Utils/Helpers");
|
|
56
57
|
var TabView = function (_a) {
|
|
57
58
|
var isCreate = _a.isCreate;
|
|
58
59
|
var _b = (0, recoil_1.useRecoilState)((0, Recoil_1.pageState)('views')), _c = _b[0], views = _c.views, page = _c.page, setView = _b[1];
|
|
59
60
|
var _d = react_1.default.useState(0), activeViewIndex = _d[0], setActiveViewIndex = _d[1];
|
|
60
|
-
var _e =
|
|
61
|
-
var _f =
|
|
62
|
-
var _g = (0,
|
|
63
|
-
var appHelper = (0,
|
|
61
|
+
var _e = (0, recoil_1.useRecoilState)(Recoil_1.templateDirectoriesState), directories = _e[0], setDirectories = _e[1];
|
|
62
|
+
var _f = (0, recoil_1.useRecoilState)(Recoil_1.templateTypeState), templateTypes = _f[0], setTemplateTypes = _f[1];
|
|
63
|
+
var _g = (0, Context_2.default)(), service = _g.service, pageCode = _g.pageCode;
|
|
64
|
+
var appHelper = (0, Context_1.useAwing)().appHelper;
|
|
64
65
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
65
66
|
react_1.default.useEffect(function () {
|
|
66
67
|
fetchData();
|
|
67
68
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
69
|
}, []);
|
|
69
|
-
// React.useLayoutEffect(() => {
|
|
70
|
-
// const tempId = setTimeout(() => {
|
|
71
|
-
// setTempLoading(false)
|
|
72
|
-
// }, 0)
|
|
73
|
-
// return () => {
|
|
74
|
-
// clearTimeout(tempId)
|
|
75
|
-
// setTempLoading(true)
|
|
76
|
-
// }
|
|
77
|
-
// }, [activeViewIndex])
|
|
78
70
|
var fetchData = function () {
|
|
79
71
|
Promise.all([
|
|
80
|
-
service.templatesGetDirectories(),
|
|
81
|
-
service.templateTypesGet(),
|
|
72
|
+
!directories.length ? service.templatesGetDirectories() : Promise.resolve(directories),
|
|
73
|
+
!templateTypes.length ? service.templateTypesGet() : Promise.resolve(templateTypes),
|
|
82
74
|
]).then(function (_a) {
|
|
83
|
-
var
|
|
84
|
-
setDirectories(
|
|
85
|
-
setTemplateTypes(function () {
|
|
86
|
-
|
|
75
|
+
var resDir = _a[0], resTemplateTypes = _a[1];
|
|
76
|
+
setDirectories(function (prev) { return (0, lodash_1.isEqual)(prev, resDir) ? prev : resDir; });
|
|
77
|
+
setTemplateTypes(function (prev) {
|
|
78
|
+
if ((0, lodash_1.isEqual)(prev, resTemplateTypes))
|
|
79
|
+
return prev;
|
|
80
|
+
var result = resTemplateTypes.filter(function (item) {
|
|
87
81
|
return item.templateTypeCode ===
|
|
88
82
|
(pageCode === enums_1.PageCode.Lgn ? 'lgn' : 'wlc');
|
|
89
83
|
});
|
|
@@ -140,6 +134,6 @@ var TabView = function (_a) {
|
|
|
140
134
|
var handleChangeView = react_1.default.useMemo(function () { return handleChange(['views', String(activeViewIndex)]); },
|
|
141
135
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
136
|
[activeViewIndex]);
|
|
143
|
-
return ((0, jsx_runtime_1.jsx)(ViewList_1.default, { isDisableTabHeader: false, activeViewIndex: activeViewIndex, viewCount: views.length, onChangeView: handleChange(), addView: addPageView, deleteView: deletePageView, children: (0, jsx_runtime_1.jsx)(Panel_1.default, { value: activeViewIndex, index: activeViewIndex, children: views.map(function (view, index) { return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: activeViewIndex === index && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ViewInfo_1.default, { onChange: handleChangeView,
|
|
137
|
+
return ((0, jsx_runtime_1.jsx)(ViewList_1.default, { isDisableTabHeader: false, activeViewIndex: activeViewIndex, viewCount: views.length, onChangeView: handleChange(), addView: addPageView, deleteView: deletePageView, children: (0, jsx_runtime_1.jsx)(Panel_1.default, { value: activeViewIndex, index: activeViewIndex, children: views.map(function (view, index) { return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: activeViewIndex === index && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ViewInfo_1.default, { onChange: handleChangeView, templateTypes: templateTypes, viewInfoData: view, viewNumber: index + 1 }), (0, jsx_runtime_1.jsx)(ViewContent_1.default, { viewInfoData: view, pageId: page.pageId, viewNumber: index, onChange: handleChangeView, isCreate: Boolean(isCreate) })] })) }, index)); }) }) }));
|
|
144
138
|
};
|
|
145
139
|
exports.default = TabView;
|
|
@@ -81,12 +81,14 @@ var Helpers_1 = require("../../../Utils/Helpers");
|
|
|
81
81
|
var lodash_1 = require("lodash");
|
|
82
82
|
var Wrapper_1 = __importDefault(require("../../../AWING/HOC/Wrapper"));
|
|
83
83
|
var Context_2 = require("../../../Context");
|
|
84
|
+
var ListenTemplate_1 = require("./ListenTemplate");
|
|
84
85
|
var CreateOrEdit = function (_a) {
|
|
85
86
|
var type = _a.type;
|
|
86
87
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
87
88
|
var pageId = (0, react_router_dom_1.useParams)().pageId;
|
|
88
89
|
var na = (0, react_router_dom_1.useNavigate)();
|
|
89
90
|
var appHelper = (0, Context_2.useAwing)().appHelper;
|
|
91
|
+
var getTemplate = (0, ListenTemplate_1.usePageCache)().getTemplate;
|
|
90
92
|
var _b = (0, Context_1.default)(), service = _b.service, pageCode = _b.pageCode;
|
|
91
93
|
var _c = react_1.default.useState(false), loading = _c[0], setLoading = _c[1];
|
|
92
94
|
var _d = (0, recoil_1.useRecoilState)(Recoil_1.hasDeprecated), isDeprecated = _d[0], setDeprecated = _d[1];
|
|
@@ -143,7 +145,7 @@ var CreateOrEdit = function (_a) {
|
|
|
143
145
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
144
146
|
}, []);
|
|
145
147
|
var checkDeprecated = function (templateIds) {
|
|
146
|
-
return Promise.all(templateIds.map(function (id) { return
|
|
148
|
+
return Promise.all(templateIds.map(function (id) { return getTemplate(id); })).then(function (res) { return res.some(function (x) { return x.template.isDeprecated; }); });
|
|
147
149
|
};
|
|
148
150
|
var fetchDirectories = function () {
|
|
149
151
|
return service
|
|
@@ -74,6 +74,7 @@ var Parameter = function (_a) {
|
|
|
74
74
|
defaultValue: undefined,
|
|
75
75
|
labelName: undefined,
|
|
76
76
|
isRequired: false,
|
|
77
|
+
isAdvanced: false,
|
|
77
78
|
childrens: [],
|
|
78
79
|
};
|
|
79
80
|
var tableRow = react_1.default.useMemo(function () { return (0, Utils_1.flattenParameter)(rows); }, [rows]);
|
|
@@ -10,15 +10,15 @@ export interface ITemplateType {
|
|
|
10
10
|
templateTypeCode?: string;
|
|
11
11
|
}
|
|
12
12
|
export interface ITemplateParameter {
|
|
13
|
-
id
|
|
14
|
-
templateId
|
|
15
|
-
fieldName
|
|
16
|
-
fieldType
|
|
17
|
-
defaultValue
|
|
18
|
-
labelName
|
|
19
|
-
isRequired
|
|
20
|
-
childrens
|
|
21
|
-
isAdvanced
|
|
13
|
+
id: string;
|
|
14
|
+
templateId: string;
|
|
15
|
+
fieldName: string;
|
|
16
|
+
fieldType: string;
|
|
17
|
+
defaultValue: string | number | boolean | undefined;
|
|
18
|
+
labelName: string | undefined;
|
|
19
|
+
isRequired: boolean;
|
|
20
|
+
childrens: ITemplateParameter[];
|
|
21
|
+
isAdvanced: boolean;
|
|
22
22
|
}
|
|
23
23
|
export interface ITemplateEvent {
|
|
24
24
|
id?: number;
|
|
@@ -43,11 +43,11 @@ var GeoFencing_1 = __importDefault(require("../../ACM-AXN/GeoFencing"));
|
|
|
43
43
|
var i18n_1 = __importDefault(require("../../i18n"));
|
|
44
44
|
var omit = require('lodash/omit');
|
|
45
45
|
function DataInput(props) {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
46
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
47
47
|
var t = (0, react_i18next_1.useTranslation)(undefined, { i18n: i18n_1.default }).t;
|
|
48
48
|
var fieldDefinition = props.fieldDefinition, onChange = props.onChange, value = props.value, error = props.error, disableHelperText = props.disableHelperText;
|
|
49
49
|
var fieldName = fieldDefinition.fieldName, type = fieldDefinition.type, onValidate = fieldDefinition.onValidate, min = fieldDefinition.min, max = fieldDefinition.max, pattern = fieldDefinition.pattern, other = __rest(fieldDefinition, ["fieldName", "type", "onValidate", "min", "max", "pattern"]);
|
|
50
|
-
var
|
|
50
|
+
var _m = react_2.default.useState(t('Common.InvalidData')), errorText = _m[0], setErrorText = _m[1];
|
|
51
51
|
var checkValidationValue = function (fieldDefinition, val) {
|
|
52
52
|
if (!fieldDefinition.required &&
|
|
53
53
|
(val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)))
|
|
@@ -108,6 +108,7 @@ function DataInput(props) {
|
|
|
108
108
|
: '' }) }));
|
|
109
109
|
}
|
|
110
110
|
case 'autocomplete': {
|
|
111
|
+
var autocompleteValue_1 = (_b = fieldDefinition.value) !== null && _b !== void 0 ? _b : value;
|
|
111
112
|
return ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { multiple: fieldDefinition.multiple, options: fieldDefinition.options, getOptionLabel: function (option) { var _a, _b; return (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : ''; }, isOptionEqualToValue: function (option, value) {
|
|
112
113
|
return (option === null || option === void 0 ? void 0 : option.value) === (value === null || value === void 0 ? void 0 : value.value);
|
|
113
114
|
}, getOptionKey: function (option) { return option.value; }, disableclearable: fieldDefinition.disableClearable, getOptionDisabled: function (option) { return option === null || option === void 0 ? void 0 : option.disabled; }, onChange: function (e, value) {
|
|
@@ -117,9 +118,9 @@ function DataInput(props) {
|
|
|
117
118
|
onChange(newValue, checkValidationValue(fieldDefinition, newValue));
|
|
118
119
|
}, value: fieldDefinition.multiple
|
|
119
120
|
? fieldDefinition.options.filter(function (x) {
|
|
120
|
-
return (
|
|
121
|
+
return (autocompleteValue_1 !== null && autocompleteValue_1 !== void 0 ? autocompleteValue_1 : []).includes(x.value);
|
|
121
122
|
})
|
|
122
|
-
: fieldDefinition.options.find(function (x) { return x.value ===
|
|
123
|
+
: (_c = fieldDefinition.options.find(function (x) { return x.value === autocompleteValue_1; })) !== null && _c !== void 0 ? _c : '', clearOnEscape: true, fullWidth: true, disableCloseOnSelect: fieldDefinition.multiple, readOnly: fieldDefinition.readOnly, renderInput: function (params) {
|
|
123
124
|
var _a;
|
|
124
125
|
return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({}, params, other, { variant: "standard", error: error, helperText: !disableHelperText && error
|
|
125
126
|
? (_a = fieldDefinition.helperText) !== null && _a !== void 0 ? _a : t('Common.InvalidData')
|
|
@@ -143,7 +144,7 @@ function DataInput(props) {
|
|
|
143
144
|
return onChange(date === null || date === void 0 ? void 0 : date.toDate(), checkValidationValue(fieldDefinition, date === null || date === void 0 ? void 0 : date.toDate()));
|
|
144
145
|
}, readOnly: fieldDefinition.readOnly, slotProps: {
|
|
145
146
|
textField: __assign(__assign({ required: fieldDefinition.required, fullWidth: true, variant: 'standard' }, other), { error: error, helperText: !disableHelperText && error
|
|
146
|
-
? (
|
|
147
|
+
? (_d = fieldDefinition.helperText) !== null && _d !== void 0 ? _d : t('Common.InvalidData')
|
|
147
148
|
: '' }),
|
|
148
149
|
} }));
|
|
149
150
|
}
|
|
@@ -152,12 +153,12 @@ function DataInput(props) {
|
|
|
152
153
|
return onChange(date === null || date === void 0 ? void 0 : date.toDate(), checkValidationValue(fieldDefinition, date === null || date === void 0 ? void 0 : date.toDate()));
|
|
153
154
|
}, slotProps: {
|
|
154
155
|
textField: __assign(__assign({ required: fieldDefinition.required, fullWidth: true, variant: 'standard' }, other), { error: error, helperText: !disableHelperText && error
|
|
155
|
-
? (
|
|
156
|
+
? (_e = fieldDefinition.helperText) !== null && _e !== void 0 ? _e : t('Common.InvalidData')
|
|
156
157
|
: '' }),
|
|
157
158
|
}, readOnly: fieldDefinition.readOnly }));
|
|
158
159
|
}
|
|
159
160
|
case 'date-range': {
|
|
160
|
-
var
|
|
161
|
+
var _o = other, isDayBlocked = _o.isDayBlocked, isOutsideRange = _o.isOutsideRange;
|
|
161
162
|
return ((0, jsx_runtime_1.jsx)(AWING_1.DateRangePicker, { noBorder: true, variant: "standard", textFieldProps: __assign({ fullWidth: true, style: { margin: '8px 0px' } }, omit(other, ['isDayBlocked', 'isOutsideRange'])), value: {
|
|
162
163
|
startDate: (value === null || value === void 0 ? void 0 : value[0]) || null,
|
|
163
164
|
endDate: (value === null || value === void 0 ? void 0 : value[1]) || null,
|
|
@@ -165,7 +166,7 @@ function DataInput(props) {
|
|
|
165
166
|
var newValue = [dateRange.startDate, dateRange.endDate];
|
|
166
167
|
onChange(newValue, checkValidationValue(fieldDefinition, newValue));
|
|
167
168
|
}, label: fieldDefinition.label, error: error, helperText: !disableHelperText && error
|
|
168
|
-
? (
|
|
169
|
+
? (_f = fieldDefinition.helperText) !== null && _f !== void 0 ? _f : t('Common.InvalidData')
|
|
169
170
|
: '', disableHelperText: disableHelperText, isDayBlocked: isDayBlocked, isOutsideRange: isOutsideRange }));
|
|
170
171
|
}
|
|
171
172
|
case 'number': {
|
|
@@ -173,7 +174,7 @@ function DataInput(props) {
|
|
|
173
174
|
var newValue = Number(event.target.value);
|
|
174
175
|
onChange(newValue, checkValidationValue(fieldDefinition, newValue));
|
|
175
176
|
}, error: error, helperText: !disableHelperText && error
|
|
176
|
-
? (
|
|
177
|
+
? (_g = fieldDefinition.helperText) !== null && _g !== void 0 ? _g : t('Common.InvalidData')
|
|
177
178
|
: '' })));
|
|
178
179
|
}
|
|
179
180
|
case 'radio': {
|
|
@@ -188,7 +189,7 @@ function DataInput(props) {
|
|
|
188
189
|
case 'text':
|
|
189
190
|
case 'text-area': {
|
|
190
191
|
return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ id: fieldName.toString(), name: fieldName.toString(), type: 'text', fullWidth: true, variant: "standard", multiline: fieldDefinition.type === 'text-area', error: error, helperText: !disableHelperText && error
|
|
191
|
-
? (
|
|
192
|
+
? (_h = fieldDefinition.helperText) !== null && _h !== void 0 ? _h : errorText
|
|
192
193
|
: '' }, other, { value: value !== null && value !== void 0 ? value : '', onChange: function (event) {
|
|
193
194
|
return onChange(event.target.value, checkValidationValue(fieldDefinition, event.target.value));
|
|
194
195
|
} })));
|
|
@@ -200,7 +201,7 @@ function DataInput(props) {
|
|
|
200
201
|
: event.target.value;
|
|
201
202
|
onChange(event.target.value, checkValidationValue(fieldDefinition, newValue));
|
|
202
203
|
}, error: error, helperText: !disableHelperText && error
|
|
203
|
-
? (
|
|
204
|
+
? (_j = fieldDefinition.helperText) !== null && _j !== void 0 ? _j : t('Common.InvalidData')
|
|
204
205
|
: '' }, other, { children: [!fieldDefinition.required && ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "", children: (0, jsx_runtime_1.jsx)("em", { children: t('Common.None') }) })), fieldDefinition.options.map(function (item, index) {
|
|
205
206
|
var _a;
|
|
206
207
|
return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: item.value, disabled: item.disabled ||
|
|
@@ -214,7 +215,7 @@ function DataInput(props) {
|
|
|
214
215
|
return ((0, jsx_runtime_1.jsx)(AWING_1.MultipleHierarchicalChoice, __assign({}, fieldDefinition, { variant: "standard", value: value, onChange: function (value) {
|
|
215
216
|
onChange(value, checkValidationValue(fieldDefinition, value));
|
|
216
217
|
}, error: error, helperText: !disableHelperText && error
|
|
217
|
-
? (
|
|
218
|
+
? (_k = fieldDefinition.helperText) !== null && _k !== void 0 ? _k : t('Common.InvalidData')
|
|
218
219
|
: '' })));
|
|
219
220
|
}
|
|
220
221
|
case 'geo-fencing': {
|
|
@@ -227,7 +228,7 @@ function DataInput(props) {
|
|
|
227
228
|
return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ id: fieldName.toString(), name: fieldName.toString(), type: fieldDefinition.type, fullWidth: true, variant: "standard" }, other, { value: value !== null && value !== void 0 ? value : '', onChange: function (event) {
|
|
228
229
|
return onChange(event.target.value, checkValidationValue(fieldDefinition, event.target.value));
|
|
229
230
|
}, error: error, helperText: !disableHelperText && error
|
|
230
|
-
? (
|
|
231
|
+
? (_l = fieldDefinition.helperText) !== null && _l !== void 0 ? _l : t('Common.InvalidData')
|
|
231
232
|
: '' })));
|
|
232
233
|
}
|
|
233
234
|
}
|