awing-library 2.1.122-beta → 2.1.124-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/Holiday/FormHoliday.js +67 -10
- package/lib/ACM-AXN/Holiday/Types.d.ts +18 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/PageTemplate.js +44 -9
- package/lib/ACM-AXN/Wizard/CreateOrEdit/PageTemplate.test.js +47 -0
- package/lib/ACM-AXN/Wizard/CreateOrEdit/RowTemplate.d.ts +3 -1
- package/lib/ACM-AXN/Wizard/CreateOrEdit/RowTemplate.js +24 -37
- package/lib/ACM-AXN/Wizard/CreateOrEdit/RowTemplate.test.js +2 -6
- package/lib/ACM-AXN/Wizard/Utils.d.ts +4 -0
- package/lib/ACM-AXN/Wizard/Utils.js +5 -1
- package/lib/translate/en/translation.json +1 -0
- package/lib/translate/vi/translation.json +1 -0
- package/package.json +1 -1
|
@@ -1,24 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
var AWING_1 = require("../../AWING");
|
|
5
16
|
var react_i18next_1 = require("react-i18next");
|
|
17
|
+
var react_1 = require("react");
|
|
18
|
+
var Hooks_1 = __importDefault(require("./Hooks"));
|
|
19
|
+
var AWING_1 = require("../../AWING");
|
|
6
20
|
var Utils_1 = require("./Utils");
|
|
7
21
|
var FormHoliday = function (props) {
|
|
8
22
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
23
|
+
var service = (0, Hooks_1.default)().service;
|
|
9
24
|
var holidays = props.holidays, onUpdate = props.onUpdate, isAllFieldReadOnly = props.isAllFieldReadOnly;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
var _a = (0, react_1.useState)([]), domains = _a[0], setDomains = _a[1];
|
|
26
|
+
var _b = (0, react_1.useState)(true), loading = _b[0], setLoading = _b[1];
|
|
27
|
+
(0, react_1.useEffect)(function () {
|
|
28
|
+
if (service === null || service === void 0 ? void 0 : service.isAcmAdmin) {
|
|
29
|
+
service.domainsGetAll &&
|
|
30
|
+
service
|
|
31
|
+
.domainsGetAll()
|
|
32
|
+
.then(setDomains)
|
|
33
|
+
.finally(function () { return setLoading(false); });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
setLoading(false);
|
|
37
|
+
}
|
|
38
|
+
}, [service]);
|
|
39
|
+
var fields = (0, react_1.useMemo)(function () {
|
|
40
|
+
var result = [
|
|
15
41
|
{
|
|
16
42
|
fieldName: 'name',
|
|
17
43
|
label: t('HolidayForm.Name'),
|
|
18
44
|
type: 'text',
|
|
19
45
|
required: true,
|
|
20
46
|
length: 100,
|
|
21
|
-
inputProps: {
|
|
47
|
+
inputProps: {
|
|
48
|
+
readOnly: isAllFieldReadOnly ? true : false,
|
|
49
|
+
},
|
|
22
50
|
},
|
|
23
51
|
{
|
|
24
52
|
fieldName: 'calendarType',
|
|
@@ -32,7 +60,9 @@ var FormHoliday = function (props) {
|
|
|
32
60
|
text: t("CalendarType.".concat(key)),
|
|
33
61
|
});
|
|
34
62
|
}),
|
|
35
|
-
inputProps: {
|
|
63
|
+
inputProps: {
|
|
64
|
+
readOnly: isAllFieldReadOnly ? true : false,
|
|
65
|
+
},
|
|
36
66
|
},
|
|
37
67
|
{
|
|
38
68
|
fieldName: 'recurrenceType',
|
|
@@ -46,8 +76,35 @@ var FormHoliday = function (props) {
|
|
|
46
76
|
text: t("RecurrenceType.".concat(key)),
|
|
47
77
|
});
|
|
48
78
|
}),
|
|
49
|
-
inputProps: {
|
|
79
|
+
inputProps: {
|
|
80
|
+
readOnly: isAllFieldReadOnly ? true : false,
|
|
81
|
+
},
|
|
50
82
|
},
|
|
51
|
-
]
|
|
83
|
+
];
|
|
84
|
+
if (service === null || service === void 0 ? void 0 : service.isAcmAdmin) {
|
|
85
|
+
result.splice(1, 0, {
|
|
86
|
+
fieldName: 'domainId',
|
|
87
|
+
label: t('Holiday.Domain'),
|
|
88
|
+
type: 'autocomplete',
|
|
89
|
+
required: true,
|
|
90
|
+
defaultValue: '99',
|
|
91
|
+
options: __spreadArray([
|
|
92
|
+
{
|
|
93
|
+
value: '99',
|
|
94
|
+
text: t('Common.None'),
|
|
95
|
+
}
|
|
96
|
+
], domains.map(function (item) { return ({
|
|
97
|
+
value: item.domainId,
|
|
98
|
+
text: (item === null || item === void 0 ? void 0 : item.name) || '',
|
|
99
|
+
}); }), true),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}, [domains, service === null || service === void 0 ? void 0 : service.isAcmAdmin, t, isAllFieldReadOnly]);
|
|
104
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: loading ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(AWING_1.BasicDataForm, { oldValue: holidays, onUpdate: onUpdate
|
|
105
|
+
? function (formValid, value) {
|
|
106
|
+
return onUpdate(formValid ? value : {});
|
|
107
|
+
}
|
|
108
|
+
: undefined, fields: fields })) }));
|
|
52
109
|
};
|
|
53
110
|
exports.default = FormHoliday;
|
|
@@ -23,6 +23,24 @@ export interface HolidayService {
|
|
|
23
23
|
holidaysGetDetail: (id: number, cancelToken?: CancelToken) => Promise<HolidayDetail>;
|
|
24
24
|
holidaysGetDetailByHolidayId: (holidayId: number, cancelToken?: CancelToken) => Promise<HolidayDetail[]>;
|
|
25
25
|
holidaysDeleteDetail: (id: number, cancelToken?: CancelToken) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* isAcmAdmin: Kiểm tra xem có phải là trang ACM Admin.
|
|
28
|
+
**/
|
|
29
|
+
isAcmAdmin?: boolean;
|
|
30
|
+
domainsGetAll?: (cancelToken?: CancelToken) => Promise<Domain[]>;
|
|
31
|
+
}
|
|
32
|
+
export interface Domain {
|
|
33
|
+
domainId?: string;
|
|
34
|
+
domainTariffId?: number;
|
|
35
|
+
directoryPath?: string | undefined;
|
|
36
|
+
name?: string | undefined;
|
|
37
|
+
joinNetwork?: boolean;
|
|
38
|
+
description?: string | undefined;
|
|
39
|
+
license?: string | undefined;
|
|
40
|
+
requiredCustomerData?: boolean | undefined;
|
|
41
|
+
url?: string | undefined;
|
|
42
|
+
customizeCustomerFormPath?: string | undefined;
|
|
43
|
+
contactPhoneNumber?: string | undefined;
|
|
26
44
|
}
|
|
27
45
|
export interface Holiday {
|
|
28
46
|
id?: number;
|
|
@@ -19,13 +19,55 @@ var react_1 = require("react");
|
|
|
19
19
|
var react_i18next_1 = require("react-i18next");
|
|
20
20
|
var Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
21
21
|
var material_1 = require("@mui/material");
|
|
22
|
+
var Hooks_1 = __importDefault(require("../Hooks"));
|
|
22
23
|
var RowTemplate_1 = __importDefault(require("./RowTemplate"));
|
|
23
|
-
var
|
|
24
|
+
var AWING_1 = require("../../../AWING");
|
|
24
25
|
var enums_1 = require("../../../ACM-AXN/Page/enums");
|
|
26
|
+
var Utils_1 = require("../Utils");
|
|
25
27
|
function PageTemplate(props) {
|
|
26
28
|
var pageCodeValue = props.pageCodeValue, wizardTemplates = props.wizardTemplates, onChange = props.onChange, onConfirmExit = props.onConfirmExit, _a = props.onUpdateWizardLogin, onUpdateWizardLogin = _a === void 0 ? function () { return null; } : _a;
|
|
27
29
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
30
|
+
var service = (0, Hooks_1.default)().service;
|
|
28
31
|
var isPageCodeLogin = pageCodeValue === enums_1.PageCode.Lgn;
|
|
32
|
+
var pageCode = pageCodeValue === enums_1.PageCode.Lgn ? Utils_1.CPageCode.LGN : Utils_1.CPageCode.WLC;
|
|
33
|
+
var _b = (0, react_1.useState)(true), loadingDirectory = _b[0], setLoadingDirectories = _b[1];
|
|
34
|
+
var _c = (0, react_1.useState)(true), loadingtemplateTypes = _c[0], setLoadingTemplateTypes = _c[1];
|
|
35
|
+
// DATA => Tên Thư Mục
|
|
36
|
+
var _d = (0, react_1.useState)([]), directories = _d[0], setDirectories = _d[1];
|
|
37
|
+
// DATA => Kiểu template
|
|
38
|
+
var _e = (0, react_1.useState)([]), templateTypes = _e[0], setTemplateTypes = _e[1];
|
|
39
|
+
(0, react_1.useEffect)(function () {
|
|
40
|
+
service
|
|
41
|
+
.templatesGetDirectories()
|
|
42
|
+
.then(function (directories_) {
|
|
43
|
+
// CALL API => DATA => Tên Thư Mục
|
|
44
|
+
var systemDirectoryIndex = directories_ === null || directories_ === void 0 ? void 0 : directories_.findIndex(function (directory) {
|
|
45
|
+
return directory.parentDirectoryId ===
|
|
46
|
+
Utils_1.ROOT_DIRECTORY.SYSTEM_DIRECTORY.toString();
|
|
47
|
+
});
|
|
48
|
+
if (systemDirectoryIndex !== -1) {
|
|
49
|
+
directories_[systemDirectoryIndex].name = 'SYSTEM TEMPLATE';
|
|
50
|
+
}
|
|
51
|
+
setDirectories(directories_);
|
|
52
|
+
})
|
|
53
|
+
.finally(function () {
|
|
54
|
+
setLoadingDirectories(false);
|
|
55
|
+
});
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
}, []);
|
|
58
|
+
(0, react_1.useEffect)(function () {
|
|
59
|
+
service
|
|
60
|
+
.templateTypesGet()
|
|
61
|
+
.then(function (templateTypes_) {
|
|
62
|
+
setTemplateTypes(templateTypes_.filter(function (itemTemplate) {
|
|
63
|
+
return itemTemplate.templateTypeCode === pageCode;
|
|
64
|
+
}));
|
|
65
|
+
})
|
|
66
|
+
.finally(function () {
|
|
67
|
+
setLoadingTemplateTypes(false);
|
|
68
|
+
});
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
}, [pageCodeValue]);
|
|
29
71
|
var handleChangeRowTemplate = function (fieldValue, sortOrder) {
|
|
30
72
|
var _a;
|
|
31
73
|
onConfirmExit();
|
|
@@ -39,13 +81,6 @@ function PageTemplate(props) {
|
|
|
39
81
|
}),
|
|
40
82
|
_a));
|
|
41
83
|
};
|
|
42
|
-
var getKeyPageCode = (0, react_1.useCallback)(function () {
|
|
43
|
-
var text = Object.fromEntries(Object.entries(enums_1.PageCode).filter(function (_a) {
|
|
44
|
-
var key = _a[0];
|
|
45
|
-
return !isNaN(Number(key));
|
|
46
|
-
}))[pageCodeValue];
|
|
47
|
-
return text ? text.toLocaleLowerCase() : '';
|
|
48
|
-
}, [pageCodeValue]);
|
|
49
84
|
return ((0, jsx_runtime_1.jsxs)(material_1.Grid, { component: material_1.Paper, sx: {
|
|
50
85
|
p: 3,
|
|
51
86
|
ml: 3,
|
|
@@ -58,6 +93,6 @@ function PageTemplate(props) {
|
|
|
58
93
|
? t('Wizard.LoginTemplate')
|
|
59
94
|
: t('Wizard.WelcomeTemplate') }), isPageCodeLogin && ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", "aria-label": "button-add", title: t('Common.Add'), "data-testid": "button-add", onClick: function () {
|
|
60
95
|
return onUpdateWizardLogin(Utils_1.TYPE_LOGIN_TEMPLATE.ADD);
|
|
61
|
-
}, children: (0, jsx_runtime_1.jsx)(Add_1.default, {}) }))] }), wizardTemplates.map(function (template, idx) { return ((0, jsx_runtime_1.jsx)(RowTemplate_1.default, { template: template, pageCode:
|
|
96
|
+
}, children: (0, jsx_runtime_1.jsx)(Add_1.default, {}) }))] }), loadingDirectory || loadingtemplateTypes ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: wizardTemplates.map(function (template, idx) { return ((0, jsx_runtime_1.jsx)(RowTemplate_1.default, { template: template, pageCode: pageCode, directories: directories, templateTypes: templateTypes, onChangeRow: handleChangeRowTemplate, onUpdateWizardLogin: onUpdateWizardLogin, disabledIconDelete: wizardTemplates.length === 1 }, idx)); }) }))] }));
|
|
62
97
|
}
|
|
63
98
|
exports.default = (0, react_1.memo)(PageTemplate);
|
|
@@ -19,11 +19,58 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
19
19
|
var react_1 = require("@testing-library/react");
|
|
20
20
|
var PageTemplate_1 = __importDefault(require("./PageTemplate"));
|
|
21
21
|
var Utils_1 = require("../Utils");
|
|
22
|
+
var directories = [
|
|
23
|
+
{
|
|
24
|
+
description: null,
|
|
25
|
+
directoryId: '4711650767517730267',
|
|
26
|
+
directoryPath: '.0.99.4711650767517730267.',
|
|
27
|
+
isFile: false,
|
|
28
|
+
isSystem: true,
|
|
29
|
+
level: 2,
|
|
30
|
+
name: 'SYSTEM TEMPLATE',
|
|
31
|
+
objectTypeCode: 'template',
|
|
32
|
+
order: 0,
|
|
33
|
+
parentDirectoryId: '99',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
description: null,
|
|
37
|
+
directoryId: '5084661221099431199',
|
|
38
|
+
directoryPath: '.0.99.4711650767517730267.5084661221099431199.',
|
|
39
|
+
isFile: false,
|
|
40
|
+
isSystem: false,
|
|
41
|
+
level: 3,
|
|
42
|
+
name: 'Beta template',
|
|
43
|
+
objectTypeCode: 'template',
|
|
44
|
+
order: 0,
|
|
45
|
+
parentDirectoryId: '4711650767517730267',
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
var templateTypes = [
|
|
49
|
+
{ id: 1, name: 'Banner', templateTypeCode: 'lgn' },
|
|
50
|
+
{ id: 5, name: 'Customize', templateTypeCode: 'lgn' },
|
|
51
|
+
];
|
|
22
52
|
jest.mock('../Utils', function () { return ({
|
|
23
53
|
TYPE_LOGIN_TEMPLATE: { ADD: 'add', REMOVE: 'remove' },
|
|
24
54
|
}); });
|
|
25
55
|
// Mock đa ngữ
|
|
26
56
|
jest.mock('react-i18next', function () { return (__assign(__assign({}, jest.requireActual('react-i18next')), { useTranslation: function () { return ({ t: jest.fn(function (key) { return key; }) }); } })); });
|
|
57
|
+
var clientMethod = {
|
|
58
|
+
templatesGetDirectories: function () { return Promise.resolve(directories); },
|
|
59
|
+
templateTypesGet: function () { return Promise.resolve(templateTypes); },
|
|
60
|
+
};
|
|
61
|
+
jest.mock('AWING', function () { return (__assign(__assign({}, jest.requireActual('AWING')), { CircularProgress: function () { return ((0, jsx_runtime_1.jsx)("div", { "data-testid": "CircularProgress", children: "CircularProgress" })); } })); });
|
|
62
|
+
// Mock Hooks
|
|
63
|
+
jest.mock('../Hooks', function () { return ({
|
|
64
|
+
__esModule: true,
|
|
65
|
+
default: function () { return ({
|
|
66
|
+
service: {
|
|
67
|
+
templatesGetDirectories: jest.fn(function () {
|
|
68
|
+
return Promise.resolve(clientMethod.templatesGetDirectories());
|
|
69
|
+
}),
|
|
70
|
+
templateTypesGet: jest.fn(clientMethod.templateTypesGet),
|
|
71
|
+
},
|
|
72
|
+
}); },
|
|
73
|
+
}); });
|
|
27
74
|
jest.mock('./RowTemplate', function () { return function (props) { return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("button", { "data-testid": "row-template-change", onClick: props.onChangeRow }) })); }; });
|
|
28
75
|
describe('PageTemplate component', function () {
|
|
29
76
|
var mockData = {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IWizardTemplate } from '../Types';
|
|
2
|
+
import { IDirectory, TemplateType, IWizardTemplate } from '../Types';
|
|
3
3
|
interface PropsRowTemplate {
|
|
4
4
|
pageCode: string;
|
|
5
|
+
directories: IDirectory[];
|
|
6
|
+
templateTypes: TemplateType[];
|
|
5
7
|
template: IWizardTemplate;
|
|
6
8
|
disabledIconDelete: boolean;
|
|
7
9
|
onChangeRow: (fieldValue: any, sortOrder: number) => void;
|
|
@@ -24,50 +24,27 @@ var Utils_1 = require("../Utils");
|
|
|
24
24
|
var validation_1 = require("../../../AWING/ultis/validation");
|
|
25
25
|
function RowTemplate(props) {
|
|
26
26
|
var _a;
|
|
27
|
-
var pageCode = props.pageCode, template = props.template, onChangeRow = props.onChangeRow, onUpdateWizardLogin = props.onUpdateWizardLogin, _b = props.disabledIconDelete, disabledIconDelete = _b === void 0 ? false : _b;
|
|
27
|
+
var pageCode = props.pageCode, template = props.template, onChangeRow = props.onChangeRow, directories = props.directories, templateTypes = props.templateTypes, onUpdateWizardLogin = props.onUpdateWizardLogin, _b = props.disabledIconDelete, disabledIconDelete = _b === void 0 ? false : _b;
|
|
28
28
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
29
29
|
var service = (0, Hooks_1.default)().service;
|
|
30
|
-
// DATA => Tên Thư Mục
|
|
31
|
-
var _c = (0, react_1.useState)([]), directories = _c[0], setDirectories = _c[1];
|
|
32
|
-
// DATA => Kiểu template
|
|
33
|
-
var _d = (0, react_1.useState)([]), templateTypes = _d[0], setTemplateTypes = _d[1];
|
|
34
30
|
// DATA => Chọn Template
|
|
35
|
-
var
|
|
31
|
+
var _c = (0, react_1.useState)([]), templates = _c[0], setTemplates = _c[1];
|
|
36
32
|
// DATA => Các trường dữ liệu
|
|
37
|
-
var
|
|
33
|
+
var _d = (0, react_1.useState)(), templateModel = _d[0], setTemplateModel = _d[1];
|
|
38
34
|
// DATA ROW TEMPLATE
|
|
39
|
-
var
|
|
35
|
+
var _e = (0, react_1.useState)(function () {
|
|
36
|
+
var _a;
|
|
37
|
+
return (__assign(__assign({}, template), { templateTypeId: 0, directoryId: ((_a = directories[0]) === null || _a === void 0 ? void 0 : _a.directoryId) || '' }));
|
|
38
|
+
}), wizardTemplate = _e[0], setWizardTemplate = _e[1];
|
|
40
39
|
// disabled => Các trường dữ liệu => call API
|
|
41
|
-
var
|
|
42
|
-
var
|
|
40
|
+
var _f = (0, react_1.useState)(true), isLoadingParameter = _f[0], setIsLoadingParameter = _f[1];
|
|
41
|
+
var _g = (0, react_1.useState)({
|
|
43
42
|
status: true,
|
|
44
43
|
message: '',
|
|
45
|
-
}), validFieldName =
|
|
46
|
-
(0, react_1.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var systemDirectoryIndex = directories_ === null || directories_ === void 0 ? void 0 : directories_.findIndex(function (directory) {
|
|
50
|
-
return directory.parentDirectoryId ===
|
|
51
|
-
Utils_1.ROOT_DIRECTORY.SYSTEM_DIRECTORY.toString();
|
|
52
|
-
});
|
|
53
|
-
if (systemDirectoryIndex !== -1) {
|
|
54
|
-
directories_[systemDirectoryIndex].name = 'SYSTEM TEMPLATE';
|
|
55
|
-
}
|
|
56
|
-
setDirectories(directories_);
|
|
57
|
-
setWizardTemplate(function (oldWizardTemplate) {
|
|
58
|
-
var _a;
|
|
59
|
-
return (__assign(__assign({}, oldWizardTemplate), { directoryId: ((_a = directories_[0]) === null || _a === void 0 ? void 0 : _a.directoryId) || '' }));
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
-
}, []);
|
|
64
|
-
(0, react_1.useEffect)(function () {
|
|
65
|
-
service.templateTypesGet().then(function (templateTypes_) {
|
|
66
|
-
setTemplateTypes(templateTypes_.filter(function (itemTemplate) {
|
|
67
|
-
return itemTemplate.templateTypeCode === pageCode;
|
|
68
|
-
}));
|
|
69
|
-
});
|
|
70
|
-
}, [pageCode]);
|
|
44
|
+
}), validFieldName = _g[0], setValidFieldName = _g[1];
|
|
45
|
+
(0, react_1.useLayoutEffect)(function () {
|
|
46
|
+
setWizardTemplate(function (oldWizardData) { return (__assign(__assign({}, oldWizardData), template)); });
|
|
47
|
+
}, [template]);
|
|
71
48
|
(0, react_1.useEffect)(function () {
|
|
72
49
|
if (wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.directoryId) {
|
|
73
50
|
setIsLoadingParameter(true);
|
|
@@ -102,7 +79,17 @@ function RowTemplate(props) {
|
|
|
102
79
|
}, [wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateId]);
|
|
103
80
|
var handleChange = function (fieldName, value) {
|
|
104
81
|
var _a, _b, _c;
|
|
105
|
-
|
|
82
|
+
// Update dữ liệu nội bộ
|
|
83
|
+
var newWizardTemplate = __assign(__assign({}, wizardTemplate), (_a = {}, _a[fieldName] = value, _a));
|
|
84
|
+
if (fieldName === 'directoryId' || fieldName === 'templateTypeId') {
|
|
85
|
+
newWizardTemplate.templateId = '';
|
|
86
|
+
newWizardTemplate.templateParameterDisplayFieldNames = [];
|
|
87
|
+
}
|
|
88
|
+
else if (fieldName === 'templateId') {
|
|
89
|
+
newWizardTemplate.templateParameterDisplayFieldNames = [];
|
|
90
|
+
}
|
|
91
|
+
setWizardTemplate(newWizardTemplate);
|
|
92
|
+
// Update dữ liệu API
|
|
106
93
|
if (fieldName !== 'directoryId' && fieldName !== 'templateTypeId') {
|
|
107
94
|
if (fieldName === 'name') {
|
|
108
95
|
var _d = (0, validation_1.textValidation)(value, 50, true), valid = _d.valid, message = _d.message;
|
|
@@ -151,8 +151,6 @@ var templateModel = {
|
|
|
151
151
|
],
|
|
152
152
|
};
|
|
153
153
|
var clientMethod = {
|
|
154
|
-
templatesGetDirectories: function () { return Promise.resolve(directories); },
|
|
155
|
-
templateTypesGet: function () { return Promise.resolve(templateTypes); },
|
|
156
154
|
templatesGetByDirectoryId: function (_id) {
|
|
157
155
|
return Promise.resolve(templates);
|
|
158
156
|
},
|
|
@@ -165,10 +163,6 @@ jest.mock('../Hooks', function () { return ({
|
|
|
165
163
|
__esModule: true,
|
|
166
164
|
default: function () { return ({
|
|
167
165
|
service: {
|
|
168
|
-
templatesGetDirectories: jest.fn(function () {
|
|
169
|
-
return Promise.resolve(clientMethod.templatesGetDirectories());
|
|
170
|
-
}),
|
|
171
|
-
templateTypesGet: jest.fn(clientMethod.templateTypesGet),
|
|
172
166
|
templatesGetByDirectoryId: jest.fn(function (_id) {
|
|
173
167
|
return Promise.resolve(clientMethod.templatesGetByDirectoryId(_id));
|
|
174
168
|
}),
|
|
@@ -187,6 +181,8 @@ describe('RowTemplate component', function () {
|
|
|
187
181
|
disabledIconDelete: false,
|
|
188
182
|
onChangeRow: jest.fn(),
|
|
189
183
|
onUpdateWizardLogin: jest.fn(),
|
|
184
|
+
directories: directories,
|
|
185
|
+
templateTypes: templateTypes,
|
|
190
186
|
};
|
|
191
187
|
var renderUi = function () { return (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTemplate_1.default, __assign({}, mockProps))); };
|
|
192
188
|
it('renders component', function () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CAMPAIGN_PRIORITY = exports.CAMPAIGN_TYPE = exports.TYPE_LOGIN_TEMPLATE = exports.ROOT_DIRECTORY = void 0;
|
|
3
|
+
exports.CAMPAIGN_PRIORITY = exports.CAMPAIGN_TYPE = exports.CPageCode = exports.TYPE_LOGIN_TEMPLATE = exports.ROOT_DIRECTORY = void 0;
|
|
4
4
|
exports.ROOT_DIRECTORY = {
|
|
5
5
|
SYSTEM_DIRECTORY: 99,
|
|
6
6
|
};
|
|
@@ -8,6 +8,10 @@ exports.TYPE_LOGIN_TEMPLATE = {
|
|
|
8
8
|
ADD: 'add',
|
|
9
9
|
REMOVE: 'remove',
|
|
10
10
|
};
|
|
11
|
+
exports.CPageCode = {
|
|
12
|
+
WLC: 'wlc',
|
|
13
|
+
LGN: 'lgn',
|
|
14
|
+
};
|
|
11
15
|
exports.CAMPAIGN_TYPE = {
|
|
12
16
|
// DEFAULT: 0,
|
|
13
17
|
BANNER_STATIC: 1,
|