awing-library 2.1.116-beta → 2.1.118-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/index.js +46 -45
- package/lib/ACM-AXN/PlaceGroup/Context.d.ts +0 -5
- package/lib/ACM-AXN/PlaceGroup/Context.js +0 -5
- package/lib/ACM-AXN/Template/CreateOrEdit/Infomation.js +13 -2
- package/lib/ACM-AXN/Template/CreateOrEdit/Template/Parameter.d.ts +1 -0
- package/lib/ACM-AXN/ViewTemplate/Enum.d.ts +1 -0
- package/lib/ACM-AXN/ViewTemplate/Enum.js +1 -0
- package/lib/ACM-AXN/ViewTemplate/TemplateField/Fields/BasicField/index.js +11 -2
- package/lib/ACM-AXN/ViewTemplate/common.js +3 -2
- package/lib/ACM-AXN/ViewTemplate/constant.d.ts +1 -0
- package/lib/ACM-AXN/ViewTemplate/constant.js +2 -1
- package/lib/ACM-AXN/ViewTemplate/interface.d.ts +1 -1
- package/lib/ACM-AXN/Wizard/Constant.d.ts +4 -0
- package/lib/ACM-AXN/Wizard/Constant.js +7 -0
- package/lib/ACM-AXN/Wizard/Container.d.ts +2 -0
- package/lib/ACM-AXN/Wizard/Container.js +46 -0
- package/lib/ACM-AXN/Wizard/Container.test.d.ts +1 -0
- package/lib/ACM-AXN/Wizard/Container.test.js +162 -0
- package/lib/ACM-AXN/Wizard/Context.d.ts +3 -0
- package/lib/ACM-AXN/Wizard/Context.js +5 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/FormInformationBasic.d.ts +11 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/FormInformationBasic.js +90 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/FormInformationBasic.test.d.ts +1 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/FormInformationBasic.test.js +113 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/PageTemplate.d.ts +12 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/PageTemplate.js +63 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/PageTemplate.test.d.ts +1 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/PageTemplate.test.js +50 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/RowTemplate.d.ts +12 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/RowTemplate.js +174 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/RowTemplate.test.d.ts +1 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/RowTemplate.test.js +259 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/index.d.ts +2 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/index.js +134 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/index.test.d.ts +1 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/index.test.js +223 -0
- package/lib/ACM-AXN/Wizard/Hooks.d.ts +2 -0
- package/lib/ACM-AXN/Wizard/Hooks.js +12 -0
- package/lib/ACM-AXN/Wizard/Types.d.ts +217 -0
- package/lib/ACM-AXN/Wizard/Types.js +22 -0
- package/lib/ACM-AXN/Wizard/Utils.d.ts +23 -0
- package/lib/ACM-AXN/Wizard/Utils.js +27 -0
- package/lib/ACM-AXN/Wizard/index.d.ts +3 -0
- package/lib/ACM-AXN/Wizard/index.js +40 -0
- package/lib/AWING/Form/Utils/Types.d.ts +4 -0
- package/lib/AWING/Form/useForm.d.ts +2 -3
- package/lib/AWING/Form/useForm.js +3 -2
- package/lib/translate/en/translation.json +25 -0
- package/lib/translate/vi/translation.json +25 -0
- package/package.json +1 -1
|
@@ -95,58 +95,59 @@ var CreateOrEdit = function (_a) {
|
|
|
95
95
|
var pageChangedForm = (0, recoil_1.useRecoilValue)(Recoil_1.pageChangedFormState);
|
|
96
96
|
var _e = (0, recoil_1.useRecoilState)(Recoil_1.pageRootState), pageRoot = _e[0], setPageRoot = _e[1];
|
|
97
97
|
(0, react_1.useEffect)(function () {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
setLoading(true);
|
|
99
|
+
fetchDirectories().then(function (directories) { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
if (!(type === enums_1.PathType.CREATE)) return [3 /*break*/, 2];
|
|
104
|
+
return [4 /*yield*/, service.pagesGenerateId().then(function (res) {
|
|
105
|
+
setPageRoot((0, immer_1.default)(function (draf) {
|
|
106
|
+
var _a;
|
|
107
|
+
draf.page.createdDate = (0, Helpers_1.convertDateTimeToTimestamp)(new Date());
|
|
108
|
+
draf.page.directoryId = ((_a = (0, lodash_1.minBy)(directories, 'level')) === null || _a === void 0 ? void 0 : _a.directoryId) || '';
|
|
109
|
+
draf.page.pageId = res;
|
|
110
|
+
draf.page.pageCode = pageCode === enums_1.PageCode.Lgn ? 'lgn' : 'wlc';
|
|
111
|
+
}));
|
|
112
|
+
})];
|
|
113
|
+
case 1:
|
|
114
|
+
_a.sent();
|
|
115
|
+
return [3 /*break*/, 4];
|
|
116
|
+
case 2: return [4 /*yield*/, service[type === enums_1.PathType.CLONE ? 'pagesClone' : 'pagesGet'](pageId).then(function (res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
|
+
var isDeprecated;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0: return [4 /*yield*/, checkDeprecated(res.views.map(function (x) { return x.templateId; }))];
|
|
121
|
+
case 1:
|
|
122
|
+
isDeprecated = _a.sent();
|
|
123
|
+
setDeprecated(isDeprecated);
|
|
124
|
+
if (isDeprecated && type === enums_1.PathType.CLONE) {
|
|
125
|
+
na('..', { replace: true });
|
|
126
|
+
appHelper.snackbar('error', t('Page.DeprecatedTemplate'));
|
|
127
|
+
throw new Error(t('Page.DeprecatedTemplate'));
|
|
128
|
+
}
|
|
129
|
+
Utils_1.updateStateByPageModel.call({ setPageRoot: setPageRoot }, res);
|
|
130
|
+
return [2 /*return*/];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}); })];
|
|
134
|
+
case 3:
|
|
135
|
+
_a.sent();
|
|
136
|
+
_a.label = 4;
|
|
137
|
+
case 4:
|
|
138
|
+
setDirectories(directories);
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
}
|
|
109
141
|
});
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
setLoading(true);
|
|
113
|
-
service[type === enums_1.PathType.CLONE ? 'pagesClone' : 'pagesGet'](pageId)
|
|
114
|
-
.then(function (res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
-
var isDeprecated;
|
|
116
|
-
return __generator(this, function (_a) {
|
|
117
|
-
switch (_a.label) {
|
|
118
|
-
case 0: return [4 /*yield*/, checkDeprecated(res.views.map(function (x) { return x.templateId; }))];
|
|
119
|
-
case 1:
|
|
120
|
-
isDeprecated = _a.sent();
|
|
121
|
-
setDeprecated(isDeprecated);
|
|
122
|
-
if (isDeprecated && type === enums_1.PathType.CLONE) {
|
|
123
|
-
na('..', { replace: true });
|
|
124
|
-
appHelper.snackbar('error', t('Page.DeprecatedTemplate'));
|
|
125
|
-
throw new Error(t('Page.DeprecatedTemplate'));
|
|
126
|
-
}
|
|
127
|
-
Utils_1.updateStateByPageModel.call({ setPageRoot: setPageRoot }, res);
|
|
128
|
-
return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}); })
|
|
132
|
-
.finally(function () { return setLoading(false); });
|
|
133
|
-
}
|
|
142
|
+
}); }).finally(function () { return setLoading(false); });
|
|
134
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
135
144
|
}, []);
|
|
136
145
|
var checkDeprecated = function (templateIds) {
|
|
137
146
|
return Promise.all(templateIds.map(function (id) { return service.templatesGet(id); })).then(function (res) { return res.some(function (x) { return x.template.isDeprecated; }); });
|
|
138
147
|
};
|
|
139
148
|
var fetchDirectories = function () {
|
|
140
|
-
service
|
|
141
|
-
.directoriesGetByObjectTypeCode(Enum_1.DirectoryRoot[pageCode === enums_1.PageCode.Lgn ? 'PageLogin' : 'PageWelcome'])
|
|
142
|
-
.then(function (res) {
|
|
143
|
-
setDirectories(res);
|
|
144
|
-
if (!pageRoot.page.directoryId && !pageRoot.page.pageId)
|
|
145
|
-
setPageRoot((0, immer_1.default)(function (draf) {
|
|
146
|
-
var _a;
|
|
147
|
-
draf.page.directoryId = ((_a = (0, lodash_1.minBy)(res, 'level')) === null || _a === void 0 ? void 0 : _a.directoryId) || '';
|
|
148
|
-
}));
|
|
149
|
-
});
|
|
149
|
+
return service
|
|
150
|
+
.directoriesGetByObjectTypeCode(Enum_1.DirectoryRoot[pageCode === enums_1.PageCode.Lgn ? 'PageLogin' : 'PageWelcome']);
|
|
150
151
|
};
|
|
151
152
|
var handleSubmit = function () {
|
|
152
153
|
if (isDeprecated) {
|
|
@@ -23,6 +23,9 @@ var Infomation = function (props) {
|
|
|
23
23
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
24
24
|
var _a = (0, recoil_1.useRecoilState)(Recoils_1.templateInfoState), templateInfo = _a[0], handleTemplateData = _a[1];
|
|
25
25
|
var handleUpdate = (0, react_1.useCallback)(function (obj, formValid, fieldUpdate) {
|
|
26
|
+
if (fieldUpdate === 'pageCode') {
|
|
27
|
+
handleTemplateData(function (prev) { return (__assign(__assign({}, prev), { templateTypeId: null })); });
|
|
28
|
+
}
|
|
26
29
|
if (fieldUpdate) {
|
|
27
30
|
handleTemplateData(function (prev) { return (__assign(__assign({}, prev), obj)); });
|
|
28
31
|
}
|
|
@@ -44,7 +47,9 @@ var Infomation = function (props) {
|
|
|
44
47
|
type: 'select',
|
|
45
48
|
label: t('Common.TypePage'),
|
|
46
49
|
required: true,
|
|
47
|
-
options: Object.values(enums_1.PageCode)
|
|
50
|
+
options: Object.values(enums_1.PageCode)
|
|
51
|
+
.filter(function (item) { return !isNaN(Number(item)); })
|
|
52
|
+
.map(function (value) { return ({
|
|
48
53
|
value: enums_1.PageCode[value].toLowerCase(),
|
|
49
54
|
text: enums_1.PageCode[value],
|
|
50
55
|
}); }),
|
|
@@ -54,7 +59,13 @@ var Infomation = function (props) {
|
|
|
54
59
|
type: 'select',
|
|
55
60
|
label: t('Common.TypeTemplate'),
|
|
56
61
|
required: true,
|
|
57
|
-
options: templateTypes
|
|
62
|
+
options: templateTypes
|
|
63
|
+
.filter(function (type) {
|
|
64
|
+
var _a;
|
|
65
|
+
return !((_a = type.templateTypeCode) === null || _a === void 0 ? void 0 : _a.localeCompare(templateInfo.pageCode || 'lgn'));
|
|
66
|
+
})
|
|
67
|
+
.sort(function (a, b) { var _a; return ((_a = a.name) === null || _a === void 0 ? void 0 : _a.localeCompare((b === null || b === void 0 ? void 0 : b.name) || '')) || -1; })
|
|
68
|
+
.map(function (type) { return ({
|
|
58
69
|
value: type.id,
|
|
59
70
|
text: type.name,
|
|
60
71
|
}); }),
|
|
@@ -25,6 +25,7 @@ var constant_1 = require("../../../constant");
|
|
|
25
25
|
var Enum_1 = require("../../../Enum");
|
|
26
26
|
var react_1 = require("react");
|
|
27
27
|
var react_i18next_1 = require("react-i18next");
|
|
28
|
+
var validation_1 = require("../../../../../AWING/ultis/validation");
|
|
28
29
|
var debounce = require('lodash/debounce');
|
|
29
30
|
var useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
30
31
|
paper: {
|
|
@@ -101,11 +102,14 @@ function BasicField(props) {
|
|
|
101
102
|
var renderField = function () {
|
|
102
103
|
// const isError = !!getValueByPath(/*errors*/ {}, fieldPath)
|
|
103
104
|
var isError = errors.includes(fieldPath);
|
|
104
|
-
var field = register(fieldPath, { required: isRequired }
|
|
105
|
+
var field = register(fieldPath, __assign({ required: isRequired }, fieldType === Enum_1.TYPE_FIELD_TEMPLATE.URL && {
|
|
106
|
+
onValidate: function (value) { return (0, validation_1.urlValid)(value); }
|
|
107
|
+
}));
|
|
105
108
|
switch (fieldType) {
|
|
106
109
|
case Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD_NUMBER:
|
|
107
110
|
return renderTextField(field, isError);
|
|
108
111
|
case Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD:
|
|
112
|
+
case Enum_1.TYPE_FIELD_TEMPLATE.URL:
|
|
109
113
|
return renderTextField(field, isError);
|
|
110
114
|
case Enum_1.TYPE_FIELD_TEMPLATE.TEXTAREA:
|
|
111
115
|
return renderTextField(field, isError);
|
|
@@ -164,7 +168,12 @@ function BasicField(props) {
|
|
|
164
168
|
? { multiline: true, rows: 4 }
|
|
165
169
|
: {}), { variant: "standard", label: labelName || fieldName, onChange: function (e) {
|
|
166
170
|
handleChange(e.target.value);
|
|
167
|
-
}, error: isError, helperText: isError
|
|
171
|
+
}, error: isError, helperText: isError
|
|
172
|
+
? fieldType === Enum_1.TYPE_FIELD_TEMPLATE.URL &&
|
|
173
|
+
!(0, validation_1.urlValid)(field.value)
|
|
174
|
+
? t('Common.InvalidData')
|
|
175
|
+
: t('Common.Required')
|
|
176
|
+
: '' })));
|
|
168
177
|
};
|
|
169
178
|
var renderDropdownListField = function (field, isError) {
|
|
170
179
|
var opts = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.split('\\n');
|
|
@@ -58,11 +58,12 @@ var runScript = function (params, script) {
|
|
|
58
58
|
};
|
|
59
59
|
exports.runScript = runScript;
|
|
60
60
|
var convertRelativeLink = function (link, pagePath, templateId, configs) {
|
|
61
|
-
var isTemplatePath = link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_TEMPLATE_PATH);
|
|
61
|
+
var isTemplatePath = (link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_TEMPLATE_PATH)) || (link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_PAGE_PATH));
|
|
62
62
|
if (isTemplatePath) {
|
|
63
63
|
return "".concat(configs.TEMPLATE_FILE_PATH, "/").concat(templateId, "/").concat(link.split("/")[link.split("/").length - 1]);
|
|
64
64
|
}
|
|
65
|
-
return
|
|
65
|
+
return link;
|
|
66
|
+
// return `${pagePath}/${link.split("/")[link.split("/").length - 1]}` || "";
|
|
66
67
|
};
|
|
67
68
|
exports.convertRelativeLink = convertRelativeLink;
|
|
68
69
|
var generateRandomInteger = function (max) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DELAY_TIME_RUN_SCRIPT = exports.ACM_TEMPLATE_PATH = void 0;
|
|
3
|
+
exports.DELAY_TIME_RUN_SCRIPT = exports.ACM_PAGE_PATH = exports.ACM_TEMPLATE_PATH = void 0;
|
|
4
4
|
exports.ACM_TEMPLATE_PATH = "{acmTemplatePath}";
|
|
5
|
+
exports.ACM_PAGE_PATH = "{acmPagePath}";
|
|
5
6
|
exports.DELAY_TIME_RUN_SCRIPT = 1500;
|
|
@@ -11,7 +11,7 @@ export interface FieldInfo {
|
|
|
11
11
|
id?: string;
|
|
12
12
|
defaultValue?: string;
|
|
13
13
|
fieldName: string;
|
|
14
|
-
fieldType: "image" | "textfield" | "video" | "textfield_number" | "html" | "checkbox" | "textarea" | "dropdownlist" | "checkboxlist" | "list" | "object" | "color";
|
|
14
|
+
fieldType: "image" | "textfield" | "video" | "textfield_number" | "html" | "checkbox" | "textarea" | "dropdownlist" | "checkboxlist" | "list" | "object" | "color" | "url";
|
|
15
15
|
fieldValue?: any;
|
|
16
16
|
isRequired: boolean;
|
|
17
17
|
labelName?: string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
var react_1 = require("react");
|
|
8
|
+
var react_i18next_1 = require("react-i18next");
|
|
9
|
+
var Hooks_1 = __importDefault(require("./Hooks"));
|
|
10
|
+
var Constant_1 = require("./Constant");
|
|
11
|
+
var Context_1 = require("../../Context");
|
|
12
|
+
var Router_1 = require("../../AWING/Router");
|
|
13
|
+
var AWING_1 = require("../../AWING");
|
|
14
|
+
function Container() {
|
|
15
|
+
var _a;
|
|
16
|
+
var navigate = (0, Router_1.useNavigate)();
|
|
17
|
+
var t = (0, react_i18next_1.useTranslation)().t;
|
|
18
|
+
var service = (0, Hooks_1.default)().service;
|
|
19
|
+
var confirm = (0, Context_1.useAwing)().appHelper.confirm;
|
|
20
|
+
var _b = (0, react_1.useState)(false), loading = _b[0], setLoading = _b[1];
|
|
21
|
+
var _c = (0, react_1.useState)(), wizards = _c[0], setWizards = _c[1];
|
|
22
|
+
var queryData = (0, react_1.useCallback)(function (queryInput) {
|
|
23
|
+
var _a;
|
|
24
|
+
setLoading(true);
|
|
25
|
+
service
|
|
26
|
+
.wizardsPaging(undefined, (_a = queryInput === null || queryInput === void 0 ? void 0 : queryInput.searchString) === null || _a === void 0 ? void 0 : _a.trim(), queryInput.pageIndex, queryInput.pageSize)
|
|
27
|
+
.then(setWizards)
|
|
28
|
+
.finally(function () {
|
|
29
|
+
setLoading(false);
|
|
30
|
+
});
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
}, []);
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(AWING_1.PageManagement, { title: t('Wizard.Title'), onChangeQueryInput: queryData, inputSearchPlaceholder: t('Wizard.SearchPlaceholder'), columns: [
|
|
34
|
+
{
|
|
35
|
+
field: 'id',
|
|
36
|
+
headerName: '#',
|
|
37
|
+
valueGetter: function (row, idx, stt) { return stt; },
|
|
38
|
+
width: 60,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
field: 'name',
|
|
42
|
+
headerName: t('Common.Name'),
|
|
43
|
+
},
|
|
44
|
+
], loading: loading, confirmDelete: confirm, getRowId: function (row) { return row.id; }, rows: (wizards === null || wizards === void 0 ? void 0 : wizards.items) || [], onDelete: (_a = service.wizardsDelete) === null || _a === void 0 ? void 0 : _a.bind(service), totalOfRows: (wizards === null || wizards === void 0 ? void 0 : wizards.totalItemCount) || 0, onRowClick: function (id) { return navigate("".concat(Constant_1.Constants.EDIT_PATH, "/").concat(id)); }, onCreateButtonClick: function () { return navigate("".concat(Constant_1.Constants.CREATE_PATH)); } }));
|
|
45
|
+
}
|
|
46
|
+
exports.default = Container;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
|
+
var react_1 = require("@testing-library/react");
|
|
55
|
+
var Router_1 = require("../../AWING/Router");
|
|
56
|
+
var Container_1 = __importDefault(require("./Container"));
|
|
57
|
+
var Constant_1 = require("./Constant");
|
|
58
|
+
var items = [
|
|
59
|
+
{
|
|
60
|
+
campaignPriority: 0,
|
|
61
|
+
campaignTimeInDays: 1,
|
|
62
|
+
campaignType: 4,
|
|
63
|
+
directoryId: '5168908508924386000',
|
|
64
|
+
directoryPath: '.0.90.4913100144472996590.5168908508924386000.5099244903339020944.',
|
|
65
|
+
id: '5099244903339020944',
|
|
66
|
+
name: 'Data Collect 2',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
campaignPriority: 0,
|
|
70
|
+
campaignTimeInDays: 1111,
|
|
71
|
+
campaignType: 6,
|
|
72
|
+
directoryId: '5168908508924386000',
|
|
73
|
+
directoryPath: '.0.90.4913100144472996590.5168908508924386000.5526032303356207617.',
|
|
74
|
+
id: '5526032303356207617',
|
|
75
|
+
name: 'Video',
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
var clientMethod = {
|
|
79
|
+
wizardsDelete: function () { return function (_id) { }; },
|
|
80
|
+
wizardsPaging: function () {
|
|
81
|
+
return Promise.resolve({ items: items, totalItemCount: items.length });
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
// Mock service
|
|
85
|
+
jest.mock('./Hooks', function () { return ({
|
|
86
|
+
__esModule: true,
|
|
87
|
+
default: function () { return ({
|
|
88
|
+
service: {
|
|
89
|
+
wizardsDelete: jest.fn(function (_id) {
|
|
90
|
+
return Promise.resolve(clientMethod.wizardsDelete());
|
|
91
|
+
}),
|
|
92
|
+
wizardsPaging: jest.fn(function (_param) {
|
|
93
|
+
return Promise.resolve(clientMethod.wizardsPaging());
|
|
94
|
+
}),
|
|
95
|
+
},
|
|
96
|
+
}); },
|
|
97
|
+
}); });
|
|
98
|
+
// Mock đa ngữ
|
|
99
|
+
jest.mock('react-i18next', function () { return (__assign(__assign({}, jest.requireActual('react-i18next')), { useTranslation: function () { return ({ t: jest.fn(function (key) { return key; }) }); } })); });
|
|
100
|
+
// Mock PageManagement
|
|
101
|
+
jest.mock('../../AWING', function () { return ({
|
|
102
|
+
PageManagement: function (props) {
|
|
103
|
+
props.onChangeQueryInput({
|
|
104
|
+
searchString: '',
|
|
105
|
+
pageIndex: 0,
|
|
106
|
+
pageSize: 10,
|
|
107
|
+
});
|
|
108
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { "data-testid": "title", children: "t('AuthenticationProfile.Title')" }), props.columns
|
|
109
|
+
.filter(function (item) { return item.valueGetter; })
|
|
110
|
+
.map(function (getter, idx) { return ((0, jsx_runtime_1.jsx)("span", { children: getter.valueGetter(items[0], idx) }, idx)); }), (0, jsx_runtime_1.jsx)("span", { "data-testid": "rowid", children: props.getRowId(items[0]) }), (0, jsx_runtime_1.jsx)("button", { "data-testid": "Rowclick", onClick: function () {
|
|
111
|
+
props.onRowClick(items[0].id);
|
|
112
|
+
}, children: "Rowclick" }), (0, jsx_runtime_1.jsx)("button", { "data-testid": "CreateBtn", onClick: props.onCreateButtonClick, children: "CreateBtn" }), (0, jsx_runtime_1.jsx)("button", { onClick: function () {
|
|
113
|
+
props.onChangeQueryInput({
|
|
114
|
+
pageIndex: 1,
|
|
115
|
+
pageSize: 10,
|
|
116
|
+
});
|
|
117
|
+
}, children: "ChangeInput" }), (0, jsx_runtime_1.jsx)("button", { "data-testid": "onDelete", onClick: function () {
|
|
118
|
+
props.onDelete('onDelete');
|
|
119
|
+
}, children: "Remove Btn" }), (0, jsx_runtime_1.jsx)("p", { children: JSON.stringify(props.rows) }), (0, jsx_runtime_1.jsxs)("span", { children: ["totalItemCount:", props.totalOfRows] })] }));
|
|
120
|
+
},
|
|
121
|
+
}); });
|
|
122
|
+
var renderUi = function () {
|
|
123
|
+
return (0, react_1.render)((0, jsx_runtime_1.jsx)(Router_1.BrowserRouter, { children: (0, jsx_runtime_1.jsx)(Container_1.default, {}) }));
|
|
124
|
+
};
|
|
125
|
+
describe('AccessPoint container component', function () {
|
|
126
|
+
it('Check renders component(Container).', function () {
|
|
127
|
+
renderUi();
|
|
128
|
+
expect(react_1.screen.getByTestId('title')).toBeInTheDocument();
|
|
129
|
+
expect(react_1.screen.getByTestId('CreateBtn')).toBeInTheDocument();
|
|
130
|
+
});
|
|
131
|
+
it('Chuyển đến trang thêm mới.', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
|
+
return __generator(this, function (_a) {
|
|
133
|
+
switch (_a.label) {
|
|
134
|
+
case 0:
|
|
135
|
+
renderUi();
|
|
136
|
+
expect(react_1.screen.getByTestId('CreateBtn')).toBeInTheDocument();
|
|
137
|
+
react_1.fireEvent.click(react_1.screen.getByTestId('CreateBtn'));
|
|
138
|
+
return [4 /*yield*/, (0, react_1.waitFor)(function () {
|
|
139
|
+
return expect(window.location.href).toContain(['http://localhost', Constant_1.Constants.CREATE_PATH].join('/'));
|
|
140
|
+
})];
|
|
141
|
+
case 1:
|
|
142
|
+
_a.sent();
|
|
143
|
+
return [2 /*return*/];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}); });
|
|
147
|
+
it('Chuyến đến trang Edit.', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
renderUi();
|
|
152
|
+
react_1.fireEvent.click(react_1.screen.getByTestId('Rowclick'));
|
|
153
|
+
return [4 /*yield*/, (0, react_1.waitFor)(function () {
|
|
154
|
+
return expect(window.location.href).toContain(['http://localhost', Constant_1.Constants.EDIT_PATH, items[0].id].join('/'));
|
|
155
|
+
})];
|
|
156
|
+
case 1:
|
|
157
|
+
_a.sent();
|
|
158
|
+
return [2 /*return*/];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}); });
|
|
162
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IWizard, WizardGroup } from '../Types';
|
|
3
|
+
interface PropsFormBasic {
|
|
4
|
+
wizardData: IWizard;
|
|
5
|
+
wizardGroup: WizardGroup[];
|
|
6
|
+
onConfirmExit: () => void;
|
|
7
|
+
onChange: (wizardNew: object) => void;
|
|
8
|
+
}
|
|
9
|
+
declare function FormInformationBasic(props: PropsFormBasic): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare const _default: import("react").MemoExoticComponent<typeof FormInformationBasic>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var react_i18next_1 = require("react-i18next");
|
|
6
|
+
var Utils_1 = require("../Utils");
|
|
7
|
+
var AWING_1 = require("../../../AWING");
|
|
8
|
+
function FormInformationBasic(props) {
|
|
9
|
+
var _a;
|
|
10
|
+
var onChange = props.onChange, onConfirmExit = props.onConfirmExit, wizardData = props.wizardData, wizardGroup = props.wizardGroup;
|
|
11
|
+
var t = (0, react_i18next_1.useTranslation)().t;
|
|
12
|
+
var campaignPriority = (0, react_1.useCallback)(function () {
|
|
13
|
+
var _a;
|
|
14
|
+
var priorityList = (_a = {},
|
|
15
|
+
_a[Utils_1.CAMPAIGN_PRIORITY.CLASS_A] = t('Wizard.PriorityA'),
|
|
16
|
+
_a[Utils_1.CAMPAIGN_PRIORITY.CLASS_B] = t('Wizard.PriorityB'),
|
|
17
|
+
_a[Utils_1.CAMPAIGN_PRIORITY.CLASS_C] = t('Wizard.PriorityC'),
|
|
18
|
+
_a);
|
|
19
|
+
return Object.values(Utils_1.CAMPAIGN_PRIORITY).map(function (item) { return ({
|
|
20
|
+
value: item,
|
|
21
|
+
text: priorityList[item],
|
|
22
|
+
}); });
|
|
23
|
+
}, [t]);
|
|
24
|
+
var campaignType = (0, react_1.useCallback)(function () {
|
|
25
|
+
var _a;
|
|
26
|
+
var typeList = (_a = {},
|
|
27
|
+
_a[Utils_1.CAMPAIGN_TYPE.BANNER_STATIC] = t('Wizard.BANNER_STATIC'),
|
|
28
|
+
_a[Utils_1.CAMPAIGN_TYPE.BANNER_EFFECT] = t('Wizard.BANNER_EFFECT'),
|
|
29
|
+
_a[Utils_1.CAMPAIGN_TYPE.BANNER_SLIDE] = t('Wizard.BANNER_SLIDE'),
|
|
30
|
+
_a[Utils_1.CAMPAIGN_TYPE.CPA] = t('Wizard.CPA'),
|
|
31
|
+
_a[Utils_1.CAMPAIGN_TYPE.SURVEY] = t('Wizard.SURVEY'),
|
|
32
|
+
_a[Utils_1.CAMPAIGN_TYPE.VIDEO] = t('Wizard.VIDEO'),
|
|
33
|
+
_a[Utils_1.CAMPAIGN_TYPE.GAME] = t('Wizard.GAME'),
|
|
34
|
+
_a[Utils_1.CAMPAIGN_TYPE.TEXT_MATCHING] = t('Wizard.TEXT_MATCHING'),
|
|
35
|
+
_a[Utils_1.CAMPAIGN_TYPE.OTHER] = t('Wizard.OTHER'),
|
|
36
|
+
_a);
|
|
37
|
+
return Object.values(Utils_1.CAMPAIGN_TYPE).map(function (item) { return ({
|
|
38
|
+
value: item,
|
|
39
|
+
text: typeList[item],
|
|
40
|
+
}); });
|
|
41
|
+
}, [t]);
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !(wizardGroup === null || wizardGroup === void 0 ? void 0 : wizardGroup.length) ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(AWING_1.BasicDataForm, { fields: [
|
|
43
|
+
{
|
|
44
|
+
fieldName: 'name',
|
|
45
|
+
type: 'text',
|
|
46
|
+
label: t('Common.Name'),
|
|
47
|
+
required: true,
|
|
48
|
+
value: (wizardData === null || wizardData === void 0 ? void 0 : wizardData.name) || '',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
fieldName: 'wizardGroup',
|
|
52
|
+
type: 'autocomplete',
|
|
53
|
+
label: t('Wizard.WizardGroup'),
|
|
54
|
+
required: true,
|
|
55
|
+
options: wizardGroup.map(function (item) { return ({
|
|
56
|
+
text: (item === null || item === void 0 ? void 0 : item.name) || '',
|
|
57
|
+
value: (item === null || item === void 0 ? void 0 : item.id) || '',
|
|
58
|
+
}); }),
|
|
59
|
+
value: ((_a = wizardData === null || wizardData === void 0 ? void 0 : wizardData.wizardGroup) === null || _a === void 0 ? void 0 : _a.id) ||
|
|
60
|
+
(wizardData === null || wizardData === void 0 ? void 0 : wizardData.wizardGroup),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
fieldName: 'campaignPriority',
|
|
64
|
+
type: 'autocomplete',
|
|
65
|
+
label: t('Wizard.Priority'),
|
|
66
|
+
required: true,
|
|
67
|
+
value: wizardData === null || wizardData === void 0 ? void 0 : wizardData.campaignPriority,
|
|
68
|
+
options: campaignPriority(),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
fieldName: 'campaignType',
|
|
72
|
+
type: 'autocomplete',
|
|
73
|
+
label: t('Wizard.Type'),
|
|
74
|
+
required: true,
|
|
75
|
+
value: wizardData === null || wizardData === void 0 ? void 0 : wizardData.campaignType,
|
|
76
|
+
options: campaignType(),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
fieldName: 'campaignTimeInDays',
|
|
80
|
+
type: 'number',
|
|
81
|
+
label: t('Wizard.CampaignTimeInDays'),
|
|
82
|
+
required: true,
|
|
83
|
+
value: wizardData === null || wizardData === void 0 ? void 0 : wizardData.campaignTimeInDays,
|
|
84
|
+
},
|
|
85
|
+
], onUpdate: function (validState, valueForm) {
|
|
86
|
+
onConfirmExit();
|
|
87
|
+
onChange(valueForm);
|
|
88
|
+
} })) }));
|
|
89
|
+
}
|
|
90
|
+
exports.default = (0, react_1.memo)(FormInformationBasic);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|