awing-library 2.1.115-beta → 2.1.117-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 +1 -1
- package/lib/ACM-AXN/PlaceGroup/Context.d.ts +0 -5
- package/lib/ACM-AXN/PlaceGroup/Context.js +0 -5
- 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/translate/en/translation.json +25 -0
- package/lib/translate/vi/translation.json +25 -0
- package/package.json +1 -1
|
@@ -0,0 +1,174 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
var react_1 = require("react");
|
|
19
|
+
var react_i18next_1 = require("react-i18next");
|
|
20
|
+
var Delete_1 = __importDefault(require("@mui/icons-material/Delete"));
|
|
21
|
+
var material_1 = require("@mui/material");
|
|
22
|
+
var Hooks_1 = __importDefault(require("../Hooks"));
|
|
23
|
+
var Utils_1 = require("../Utils");
|
|
24
|
+
var validation_1 = require("../../../AWING/ultis/validation");
|
|
25
|
+
function RowTemplate(props) {
|
|
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;
|
|
28
|
+
var t = (0, react_i18next_1.useTranslation)().t;
|
|
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
|
+
// DATA => Chọn Template
|
|
35
|
+
var _e = (0, react_1.useState)([]), templates = _e[0], setTemplates = _e[1];
|
|
36
|
+
// DATA => Các trường dữ liệu
|
|
37
|
+
var _f = (0, react_1.useState)(), templateModel = _f[0], setTemplateModel = _f[1];
|
|
38
|
+
// DATA ROW TEMPLATE
|
|
39
|
+
var _g = (0, react_1.useState)(function () { return (__assign(__assign({}, template), { templateTypeId: 0 })); }), wizardTemplate = _g[0], setWizardTemplate = _g[1];
|
|
40
|
+
// disabled => Các trường dữ liệu => call API
|
|
41
|
+
var _h = (0, react_1.useState)(true), isLoadingParameter = _h[0], setIsLoadingParameter = _h[1];
|
|
42
|
+
var _j = (0, react_1.useState)({
|
|
43
|
+
status: true,
|
|
44
|
+
message: '',
|
|
45
|
+
}), validFieldName = _j[0], setValidFieldName = _j[1];
|
|
46
|
+
(0, react_1.useEffect)(function () {
|
|
47
|
+
service.templatesGetDirectories().then(function (directories_) {
|
|
48
|
+
// CALL API => DATA => Tên Thư Mục
|
|
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]);
|
|
71
|
+
(0, react_1.useEffect)(function () {
|
|
72
|
+
if (wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.directoryId) {
|
|
73
|
+
setIsLoadingParameter(true);
|
|
74
|
+
service
|
|
75
|
+
.templatesGetByDirectoryId(wizardTemplate.directoryId)
|
|
76
|
+
.then(function (template_) {
|
|
77
|
+
var newTemplates = template_ === null || template_ === void 0 ? void 0 : template_.filter(function (item) {
|
|
78
|
+
return item.pageCode === pageCode &&
|
|
79
|
+
(wizardTemplate.templateTypeId === 0 ||
|
|
80
|
+
item.templateTypeId ===
|
|
81
|
+
wizardTemplate.templateTypeId);
|
|
82
|
+
});
|
|
83
|
+
// Sắp xếp chuỗi theo thứ tự tăng dần (a => z).
|
|
84
|
+
newTemplates.sort(function (a, b) {
|
|
85
|
+
return ((a === null || a === void 0 ? void 0 : a.description) || '').localeCompare((b === null || b === void 0 ? void 0 : b.description) || '');
|
|
86
|
+
});
|
|
87
|
+
setTemplates(newTemplates);
|
|
88
|
+
})
|
|
89
|
+
.finally(function () {
|
|
90
|
+
setIsLoadingParameter(false);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
+
}, [pageCode, wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.directoryId]);
|
|
95
|
+
(0, react_1.useEffect)(function () {
|
|
96
|
+
if (wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateId) {
|
|
97
|
+
service
|
|
98
|
+
.templatesGet(wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateId)
|
|
99
|
+
.then(setTemplateModel);
|
|
100
|
+
}
|
|
101
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
|
+
}, [wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateId]);
|
|
103
|
+
var handleChange = function (fieldName, value) {
|
|
104
|
+
var _a, _b, _c;
|
|
105
|
+
setWizardTemplate(__assign(__assign({}, wizardTemplate), (_a = {}, _a[fieldName] = value, _a)));
|
|
106
|
+
if (fieldName !== 'directoryId' && fieldName !== 'templateTypeId') {
|
|
107
|
+
if (fieldName === 'name') {
|
|
108
|
+
var _d = (0, validation_1.textValidation)(value, 50, true), valid = _d.valid, message = _d.message;
|
|
109
|
+
setValidFieldName({ status: valid, message: message });
|
|
110
|
+
onChangeRow((_b = {},
|
|
111
|
+
_b[fieldName] = typeof value === 'string'
|
|
112
|
+
? valid
|
|
113
|
+
? value.trim()
|
|
114
|
+
: ''
|
|
115
|
+
: value,
|
|
116
|
+
_b), (template === null || template === void 0 ? void 0 : template.sortOrder) || 0);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
onChangeRow((_c = {},
|
|
120
|
+
_c[fieldName] = typeof value === 'string' ? value.trim() : value,
|
|
121
|
+
_c), (template === null || template === void 0 ? void 0 : template.sortOrder) || 0);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var handleDeleteRowTemplate = function () {
|
|
126
|
+
onUpdateWizardLogin &&
|
|
127
|
+
onUpdateWizardLogin(Utils_1.TYPE_LOGIN_TEMPLATE.REMOVE, template.sortOrder);
|
|
128
|
+
};
|
|
129
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { component: "div", sx: {
|
|
130
|
+
flex: 1,
|
|
131
|
+
display: 'flex',
|
|
132
|
+
flexDirection: 'row',
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { id: "name", required: true, fullWidth: true, variant: "standard", label: t('Common.Name'), "data-testid": "Common.Name", value: wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.name, error: !validFieldName.status, sx: { mr: 2, minWidth: '100px', maxWidth: '140px' }, helperText: !validFieldName.status && validFieldName.message, onChange: function (event) { return handleChange('name', event.target.value); } }), (0, jsx_runtime_1.jsx)(material_1.TextField, { select: true, fullWidth: true, id: "directoryId", variant: "standard", label: t('Wizard.Directory'), "data-testid": "Wizard.Directory", disabled: !(directories === null || directories === void 0 ? void 0 : directories.length), value: (wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.directoryId) || '', sx: { mr: 2, minWidth: '140px', maxWidth: '180px' }, onChange: function (event) {
|
|
135
|
+
return handleChange('directoryId', event.target.value);
|
|
136
|
+
}, children: directories.map(function (directory) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { style: {
|
|
137
|
+
paddingLeft: directory.level &&
|
|
138
|
+
directory.level >= 2 &&
|
|
139
|
+
directory.isSystem !== true
|
|
140
|
+
? (directory.level - 2) * 24 + 'px'
|
|
141
|
+
: '8px',
|
|
142
|
+
}, value: directory.directoryId, children: directory.name }, directory.directoryId)); }) }), (0, jsx_runtime_1.jsxs)(material_1.TextField, { select: true, fullWidth: true, variant: "standard", id: "templateTypeId", label: t('Common.TypeTemplate'), "data-testid": "Common.TypeTemplate", value: wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateTypeId, sx: { mr: 2, minWidth: '120px', maxWidth: '140px' }, onChange: function (event) {
|
|
143
|
+
return handleChange('templateTypeId', event.target.value);
|
|
144
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 0, children: t('Common.SelectAll') }), templateTypes.map(function (templateType) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: templateType.id, children: templateType.name }, templateType.id)); })] }), (0, jsx_runtime_1.jsx)(material_1.TextField, { select: true, fullWidth: true, required: true, id: "template", variant: "standard", disabled: !(templates === null || templates === void 0 ? void 0 : templates.length), sx: { mr: 2, minWidth: '140px' }, label: t('Wizard.SelectTemplate'), "data-testid": "Wizard.SelectTemplate", value: (wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateId) || '', onChange: function (event) {
|
|
145
|
+
return handleChange('templateId', event.target.value);
|
|
146
|
+
}, children: templates
|
|
147
|
+
.filter(function (template) {
|
|
148
|
+
return (wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateTypeId) === 0 ||
|
|
149
|
+
template.templateTypeId ===
|
|
150
|
+
(wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateTypeId);
|
|
151
|
+
})
|
|
152
|
+
.map(function (temp) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: temp.id, children: temp.description }, temp.id)); }) }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, variant: "standard", sx: { mr: 2, minWidth: '180px' }, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { htmlFor: "component-simple", "data-testid": "Wizard.FieldNames", children: t('Wizard.FieldNames') }), (0, jsx_runtime_1.jsx)(material_1.Select, { multiple: true, id: "component-simple", value: (wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateParameterDisplayFieldNames) || [], disabled: isLoadingParameter ||
|
|
153
|
+
!(templates === null || templates === void 0 ? void 0 : templates.length) ||
|
|
154
|
+
!(templateModel === null || templateModel === void 0 ? void 0 : templateModel.templateParameters), onChange: function (event) {
|
|
155
|
+
return handleChange('templateParameterDisplayFieldNames', event.target.value);
|
|
156
|
+
}, renderValue: function (selected) {
|
|
157
|
+
var _a;
|
|
158
|
+
var fieldNames = selected;
|
|
159
|
+
return (_a = templateModel === null || templateModel === void 0 ? void 0 : templateModel.templateParameters) === null || _a === void 0 ? void 0 : _a.filter(function (parameter) {
|
|
160
|
+
return fieldNames.includes(parameter.fieldName || '');
|
|
161
|
+
}).map(function (parameter) {
|
|
162
|
+
return parameter.labelName;
|
|
163
|
+
}).join(', ');
|
|
164
|
+
}, MenuProps: {
|
|
165
|
+
PaperProps: {
|
|
166
|
+
style: {
|
|
167
|
+
maxHeight: 224,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
}, children: (_a = templateModel === null || templateModel === void 0 ? void 0 : templateModel.templateParameters) === null || _a === void 0 ? void 0 : _a.map(function (parameter, idx) { return ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { value: parameter.fieldName, children: [(0, jsx_runtime_1.jsx)(material_1.Checkbox, { color: "primary", checked: ((wizardTemplate === null || wizardTemplate === void 0 ? void 0 : wizardTemplate.templateParameterDisplayFieldNames) ||
|
|
171
|
+
[]).indexOf((parameter === null || parameter === void 0 ? void 0 : parameter.fieldName) || '') >
|
|
172
|
+
-1 }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: parameter.labelName })] }, idx)); }) })] }), (0, jsx_runtime_1.jsx)(material_1.IconButton, { edge: "end", "aria-label": "delete", "data-testid": "deleteIcon", disabled: disabledIconDelete, onClick: handleDeleteRowTemplate, children: (0, jsx_runtime_1.jsx)(Delete_1.default, {}) })] }));
|
|
173
|
+
}
|
|
174
|
+
exports.default = (0, react_1.memo)(RowTemplate);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,259 @@
|
|
|
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
|
+
/* eslint-disable testing-library/no-wait-for-side-effects */
|
|
55
|
+
var react_1 = require("@testing-library/react");
|
|
56
|
+
var RowTemplate_1 = __importDefault(require("./RowTemplate"));
|
|
57
|
+
var Utils_1 = require("../Utils");
|
|
58
|
+
var directories = [
|
|
59
|
+
{
|
|
60
|
+
description: null,
|
|
61
|
+
directoryId: '4711650767517730267',
|
|
62
|
+
directoryPath: '.0.99.4711650767517730267.',
|
|
63
|
+
isFile: false,
|
|
64
|
+
isSystem: true,
|
|
65
|
+
level: 2,
|
|
66
|
+
name: 'SYSTEM TEMPLATE',
|
|
67
|
+
objectTypeCode: 'template',
|
|
68
|
+
order: 0,
|
|
69
|
+
parentDirectoryId: '99',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
description: null,
|
|
73
|
+
directoryId: '5084661221099431199',
|
|
74
|
+
directoryPath: '.0.99.4711650767517730267.5084661221099431199.',
|
|
75
|
+
isFile: false,
|
|
76
|
+
isSystem: false,
|
|
77
|
+
level: 3,
|
|
78
|
+
name: 'Beta template',
|
|
79
|
+
objectTypeCode: 'template',
|
|
80
|
+
order: 0,
|
|
81
|
+
parentDirectoryId: '4711650767517730267',
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
var templateTypes = [
|
|
85
|
+
{ id: 1, name: 'Banner', templateTypeCode: 'lgn' },
|
|
86
|
+
{ id: 5, name: 'Customize', templateTypeCode: 'lgn' },
|
|
87
|
+
];
|
|
88
|
+
var templates = [
|
|
89
|
+
{
|
|
90
|
+
autoField: '',
|
|
91
|
+
description: '07.[DEFAULT] Data Collection 1 Page_v1.0',
|
|
92
|
+
directoryId: '5183679953246990989',
|
|
93
|
+
directoryPath: '.0.99.4711650767517730267.5183679953246990989.4619609303918768290.',
|
|
94
|
+
id: '4619609303918768290',
|
|
95
|
+
layoutId: '0',
|
|
96
|
+
name: '',
|
|
97
|
+
pageCode: 'lgn',
|
|
98
|
+
templateHtml: '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=0"/>\r\n<link href="/static/Files/template/5246961620307474338/template_cpa_v1_0.css?432" rel="stylesheet" />\r\n<div id="cpa-container" style="width:100%">\r\n <img id="background_img_1" src="{cpa_1_banner_1}">\r\n <div class="box-wrapper-2">\r\n <table class="form_table formtable-fix form_table_text" id="cpa_field_list">\r\n </table>\r\n <table class="form_table btn-form-label form_table_text form-paddingtop">\r\n <tr>\r\n <td>\r\n <button class="btn_action btn_left btn_form_2" onclick="nextView();">\r\n <strong id="btn_left_text2">KẾT NỐI<br/>INTERNET NGAY</strong>\r\n <br/>\r\n <small class="smallen">(ACCESS INTERNET)</small>\r\n </button>\r\n </td>\r\n <td>\r\n <button class="btn_action btn_right btn_form_2" onclick="doSubmit()">\r\n <strong id="btn_right_text2">ĐĂNG KÝ<br/>& KẾT NỐI INTERNET</strong>\r\n <br/>\r\n <small class="smallen">(REGISTER & ACCESS INTERNET)</small>\r\n </button>\r\n </td>\r\n </tr>\r\n </table>\r\n </div>\r\n</div>\r\n<textarea id="textLeftButtonBanner2" style="display: none;">{cpa_1_banner_2}</textarea>\r\n<textarea id="textRightButtonBanner2" style="display: none;">{cpa_1_banner_3}</textarea>\r\n<div id="continue_scroll" style="display: none;">\r\n <a id="continue_text"><span></span>Còn tiếp</a>\r\n</div>\r\n<script>\r\nvar textLeftButtonBanner2 = $("#textLeftButtonBanner2").text().replace(/(?:\\r\\n|\\r|\\n)/g, \'<br/>\');\r\nvar textRightButtonBanner2 = $("#textRightButtonBanner2").text().replace(/(?:\\r\\n|\\r|\\n)/g, \'<br/>\');\r\nvar colorCodeLeftButton = "#"+"{cpa_1_banner_4}";\r\nvar colorCodeRightButton = "#"+"{cpa_1_banner_5}";\r\nvar colorTextLeftButton = "#"+"{cpa_1_banner_6}";\r\nvar colorTextRightButton = "#"+"{cpa_1_banner_7}";\r\nvar fieldList = [];\r\nvar nameFieldCheckbox = "{cpa_1_banner_8}" == "true" ? fieldList.push("name") : "";\r\nvar phoneFieldCheckbox = "{cpa_1_banner_9}" == "true" ? fieldList.push("phone") : "";\r\nvar emailFieldCheckbox = "{cpa_1_banner_10}" == "true" ? fieldList.push("email") : "";\r\nvar textFieldBackGroundColor = "{cpa_1_banner_11}";\r\nvar textFieldBorderColor = "#"+"{cpa_1_banner_12}";\r\n\r\nfieldList.forEach(function(item){\r\n if(item == "name"){\r\n $("#cpa_field_list").append("<tr><td colspan=\'2\' class=\'tooltip\'><input type=\'text\' id=\'name\' name=\'name\' placeholder=\'Họ và tên\' class=\'input-text input-box-2 input-text-name\'></input><span class=\'tooltiptext\' id=\'tooltipname\'>Họ và tên không đúng, xin vui lòng nhập lại!</span></td></tr>");\r\n }\r\n if(item == "phone"){\r\n $("#cpa_field_list").append("<tr><td colspan=\'2\' class=\'tooltip\'><input type=\'number\' id = \'phone\' placeholder=\'Số điện thoại\' class=\'input-text input-box-2 input-text-phone\'></input><span class=\'tooltiptext\' id=\'tooltipphone\'>Số điện thoại không đúng, xin vui lòng nhập lại!</span></td></tr>");\r\n }\r\n if(item == "email"){\r\n $("#cpa_field_list").append("<tr><td colspan=\'2\' class=\'tooltip\'><input type=\'text\' id=\'email\' placeholder=\'Email\' class=\'input-text input-box-2 input-text-email\' /><span class=\'tooltiptext\' id=\'tooltipemail\'>Email không đúng, xin vui lòng nhập lại!</span></td></tr>");\r\n }\r\n});\r\nif(fieldList.length == 3) {\r\n $(".box-wrapper-2").addClass("three-field-form");\r\n}\r\nvar mInfo = detectDeviceInfo();\r\nvar windowheight = window.innerHeight;\r\nvar browserLang = navigator.language || navigator.userLanguage;\r\nif(browserLang !="vi-VN"){\r\n $("#continue_text").html("<span></span>More</a>");\r\n // $(".wa-button-maxview").addClass("wa-button-en");\r\n $("#continue_scroll").addClass("continue-en");\r\n}\r\nif(textLeftButtonBanner2.length > 0) { $("#btn_left_text2").html(textLeftButtonBanner2); }\r\nif(textRightButtonBanner2.length > 0) { $("#btn_right_text2").html(textRightButtonBanner2); }\r\n$(".btn_left").css({\r\n "background-color": colorCodeLeftButton,\r\n "color": colorTextLeftButton\r\n});\r\n$(".btn_right").css({\r\n "background-color": colorCodeRightButton,\r\n "color": colorTextRightButton\r\n});\r\nif(textFieldBackGroundColor.toLowerCase() == "màu xám") {\r\n $("td > .input-box-2").css("background-color", "#d9d9d9");\r\n}\r\n$("td > .input-box-2").css("border",\'1px solid \' + textFieldBorderColor);\r\n\r\nif(mInfo.os == "iOS" || mInfo.os == "Android"){\r\n $(\'#continue_text\').css(\'color\', colorCodeLeftButton);\r\n $(\'#continue_text span\').css({\r\n "border-left":"5px solid " + colorCodeLeftButton,\r\n "border-bottom": "5px solid " + colorCodeLeftButton\r\n });\r\n}\r\n\r\n$("#continue_scroll").hide();\r\nfunction startAnimation(){\r\n $(\'#layoutHeader\').hide();\r\n if(mInfo.os == "iOS" || mInfo.os == "Android"){\r\n $(window).off(\'scroll\');\r\n // var footerHeight = ($(\'#wa_hotline\').outerHeight() > 0 ) ? $(\'#wa_hotline\').outerHeight() : 32.4;\r\n // $(\'#cpa-container\').css(\'min-height\', windowheight - footerHeight);\r\n // $(\'#cpa-container\').css(\'background\', colorCodeBody);\r\n setTimeout(function(){continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll\'));}, 750);\r\n $(document).on(\'touchend\', function() {\r\n setTimeout(function()\r\n {\r\n continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll\'));\r\n }, 750);\r\n });\r\n }\r\n else {\r\n window.onresize = function(event) {\r\n var rightContinue = ($(window).width() - $("#background_img_1").width())/2 - $("#continue_scroll").width() + 3;\r\n $("#continue_scroll").css(\'right\', rightContinue);\r\n $("#continue_scroll.continue-en").css(\'right\', rightContinue+5);\r\n };\r\n setTimeout(function(){\r\n var rightContinue = ($(window).width() - $("#background_img_1").width())/2 - $("#continue_scroll").width() + 5;\r\n $("#continue_scroll").css(\'right\', rightContinue);\r\n $("#continue_scroll.continue-en").css(\'right\', rightContinue+10);\r\n continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll\'));\r\n }, 750);\r\n }\r\n}\r\n$(".input-text").focus(function(){\r\n $("#tooltipphone").hide();\r\n $("#tooltipname").hide();\r\n $("#tooltipemail").hide();\r\n remove_error($(\'.input-text\'));\r\n});\r\nfunction goToForm(){\r\n $(\'.box-wrapper\').hide();\r\n $(\'.box-wrapper-2\').show();\r\n $(\'#background_img\').hide();\r\n $(\'#background_img_1\').show();\r\n}\r\nfunction doSubmit(){\r\n var phone = $(\'#phone\').val();\r\n var name = $(\'#name\').val();\r\n var email = $(\'#email\').val();\r\n var valObject = {name: name, phone: phone, email: email};\r\n if (validateDataCustomer(name,phone,email)){\r\n var eventObject = {};\r\n fieldList.forEach(function(item) {\r\n eventObject[item] = valObject[item];\r\n });\r\n postAnalyticEvent("eventcpa",JSON.stringify(eventObject));\r\n nextView();\r\n }\r\n}\r\nfunction validateDataCustomer(name,phone,email){\r\n var validate = true;\r\n if(fieldList.indexOf("name") !== -1){\r\n if ((!name)||(ContainNum(name))){\r\n set_error($(\'#name\'));\r\n set_errortooltip($(\'#tooltipname\'));\r\n validate = false;\r\n }\r\n }\r\n if(fieldList.indexOf("phone") !== -1){\r\n phone = phone.replace(\'(+84)\', \'0\');\r\n phone = phone.replace(\'+84\', \'0\');\r\n phone = phone.replace(\'0084\', \'0\');\r\n phone = phone.replace(/ /g, \'\');\r\n if (phone != \'\') {\r\n var firstNumber = phone.substring(0, 2);\r\n if ((firstNumber == \'03\' || firstNumber == \'05\' || firstNumber == \'07\' || firstNumber == \'08\' || firstNumber == \'09\') && phone.length == 10) {\r\n if (phone.match(/^\\d{10}/)) {}\r\n } else if (firstNumber == \'01\' && phone.length == 11) {\r\n if (phone.match(/^\\d{11}/)) {}\r\n }\r\n else{\r\n set_error($(\'#phone\'));\r\n set_errortooltip($(\'#tooltipphone\'));\r\n validate = false;\r\n }\r\n }\r\n else{\r\n set_error($(\'#phone\'));\r\n set_errortooltip($(\'#tooltipphone\'));\r\n validate = false;\r\n }\r\n }\r\n if(fieldList.indexOf("email") !== -1){\r\n if (email != \'\') {\r\n if (!isEmail(email)){\r\n set_error($(\'#email\'));\r\n set_errortooltip($(\'#tooltipemail\'));\r\n validate = false;\r\n }\r\n }\r\n else {\r\n set_error($(\'#email\'));\r\n set_errortooltip($(\'#tooltipemail\'));\r\n validate = false;\r\n }\r\n }\r\n return validate;\r\n}\r\nfunction isEmail(email) {\r\n var regex = /^([a-zA-Z0-9_.+-])+\\@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$/;\r\n return regex.test(email);\r\n}\r\nfunction ContainNum(t)\r\n{\r\n var regex = /\\d/g;\r\n return regex.test(t);\r\n}\r\nfunction set_error(element){\r\n element.addClass(\'_error\');\r\n}\r\nfunction set_errortooltip(element){\r\n element.show();\r\n}\r\nfunction remove_error(element){\r\n element.removeClass(\'_error\');\r\n}\r\nfunction continueScrollHandle(elm, scroll){\r\n if(checkVisible(elm)) {$(\'#continue_scroll\').hide();}\r\n else {$(\'#continue_scroll\').show();}\r\n}\r\nfunction checkVisible(elm){\r\n var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);\r\n if(elm != "" && elm != undefined){\r\n var rect = elm.getBoundingClientRect();\r\n return !(rect.bottom == 0 || rect.top - viewHeight >= -(rect.height - 12));\r\n }else{\r\n return true;\r\n }\r\n}\r\n</script>',
|
|
99
|
+
templateTypeId: 17,
|
|
100
|
+
validation: '',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
autoField: '',
|
|
104
|
+
description: '08.[DEFAULT] Horizontal Video_v1.1',
|
|
105
|
+
directoryId: '5183679953246990989',
|
|
106
|
+
directoryPath: '.0.99.4711650767517730267.5183679953246990989.4631090508536728844.',
|
|
107
|
+
id: '4631090508536728844',
|
|
108
|
+
layoutId: '0',
|
|
109
|
+
name: '',
|
|
110
|
+
pageCode: 'lgn',
|
|
111
|
+
templateHtml: '<link href="/static/Files/template/4631090508536728844/video_horizontal_v1.1.css?01" rel="stylesheet" />\r\n<div id="horizontal-video-container" class="frame1">\r\n\t<div class="video">\r\n\t\t<div class="wpvideo">\r\n\t\t\t<video style="width: 100%" src="{video_1}" playsinline id="mVideo" poster="" preload="auto"></video> \r\n\t\t\t<img src="{video_3}" id="mImg" style="display:none;margin: 0px auto;">\r\n\t\t\t<div class="connection-container">\r\n\t\t\t\t<button id="connectToInternet" class="wa-button wa-button-view blur btn-bif wa-button-video" style="margin-top:0.5em;">BỎ QUA VIDEO TRONG <small class="smallen">(SKIP AD)</small><i id="countdowntimer" style="padding-left: 3px" class="countdown">6S</i></button>\r\n\t\t\t\t<a id="user-not-interest" class="class-user-interest" title="Cảm ơn, tôi muốn kết nối Internet ngay/ No thanks, just take me online" onclick="nextView()" style="display: none;">Cảm ơn, tôi muốn kết nối Internet ngay/ No thanks, just take me online </a>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</div>\r\n</div>\r\n<div id="continue_scroll_video" style="display: none;">\r\n\t<a id="continue_text_video"><span></span>Còn tiếp</a>\r\n</div>\r\n<script>\r\nvar browserLang = navigator.language || navigator.userLanguage;\r\nif(browserLang !="vi-VN"){\r\n\t$("#continue_text_video").html("<span></span>More</a>");\r\n\t$("#continue_scroll_video").addClass("continue-en");\r\n}\r\nvar mInfo = detectDeviceInfo();\r\nvar isShowBanner="{video_2}" == "true";banner="{video_3}";timeSkipAd = "{video_4}" == "" ? 6 : "{video_4}";colorButton = "#"+"{video_5}";colorTextButton = "#"+"{video_6}";textButton = "{video_7}";colorCodeBackgroundBanner = "#"+"{video_8}";isShowUserInterest = "{video_9}" == "true";\r\nif(Number(timeSkipAd) <= 0){\r\n\t$(\'#connectToInternet\').removeClass(\'blur\').html(\'BỎ QUA VIDEO <small class="smallen">(SKIP AD)</small>\').click(function () {\r\n\t\t\tdocument.body.style.backgroundColor = "#f5f5f5";\r\n\t\t\t\tif(isShowBanner){ showBanner();} else{connectToWifi();}\r\n\t});\r\n}\r\nif(Number(timeSkipAd) > 0){$(\'#countdowntimer\').html(timeSkipAd+"S");}\r\nif(mInfo.os == "iOS" || mInfo.os == "Android"){ \r\n\t$(\'.wa-button-video\').css({"background-color": colorButton,"color": colorTextButton});\r\n\t$(\'#continue_text_video\').css(\'color\', colorButton);\r\n\t$(\'#continue_text_video span\').css({\r\n\t\t"border-left":"5px solid " + colorButton,\r\n\t\t"border-bottom": "5px solid " + colorButton\r\n\t});\r\n}\r\nif(textButton =="") textButton ="KẾT NỐI INTERNET";\r\nif(banner == "") {\r\n\t$("#mImg").attr("src", "/static/Files/template/4631090508536728844/default_banner.png");\r\n}\r\nfunction startAnimation() {\r\n\t$(\'#layoutFooter\').hide();\r\n\t$(\'#layoutHeader\').hide();var videoId = document.getElementById(\'mVideo\');\r\n\tplayVideo();\r\n\t$(\'#mVideo\').on(\'pause\', function () {showBanner();});\r\n\t$(\'#mVideo\').on(\'play\', function () {\r\n\t\tdocument.body.style.backgroundColor = "rgb(33, 31, 31)";\r\n\t\tpostAnalyticEvent("View(Video)",JSON.stringify({}));\r\n\t\tif (mInfo.os == "iOS" && mInfo.os_value < 113) {\r\n\t\t\t\tdocument.body.style.backgroundColor = "#F5F5F5";\r\n\t\t} else {\r\n\t\t\t\t$("#connectToInternet").show();\r\n\t\t}\r\n\t\tsetTimeout(function () {if(Number(timeSkipAd) > 0) countDown(); }, 100);\r\n\t});\r\n\t$(\'#mVideo\').on(\'ended\', function () {\r\n\t\tpostAnalyticEvent("Completed_View(Video)",JSON.stringify({}));\r\n\t\tnextView();\r\n\t});\r\n\tfunction playVideo() { mVideo.play(); }\r\n\tif(mInfo.os !== "iOS" || mInfo.os !== "Android"){\r\n\t\t$(window).off(\'scroll\');\r\n\t\tsetTimeout(function(){\r\n\t\t\tvar rightContinue = ($(window).width() - $("#mVideo").width())/2 - $("#continue_scroll_video").width() + 5;\r\n\t\t\t$("#continue_scroll_video").css(\'right\', rightContinue);\r\n\t\t\t$("#continue_scroll_video.continue-en").css(\'right\', rightContinue+10);\r\n\t\t\tcontinueScrollHandle($("#connectToInternet")[0], $(\'#continue_scroll_video\'));\r\n\t\t}, 750);\r\n\t\t$(document).on(\'scroll\', function() {\r\n\t\t\tif($("#wa_hotline").height() > 0) {\r\n\t\t\t\tsetTimeout(function(){continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll_video\'));}, 750);\r\n\t\t\t}\r\n\t\t\telse \r\n\t\t\t\tsetTimeout(function(){continueScrollHandle($("#connectToInternet")[0], $(\'#continue_scroll_video\'));}, 750);\r\n\t\t});\r\n\t}\r\n}\r\nfunction countDown() {\r\n\t\tvar timeleft = 6;\r\n\t\tif(Number(timeSkipAd) > 0) timeleft = Number(timeSkipAd);\r\n\t\tvar downloadTimer = setInterval(function () {\r\n\t\t\t\ttimeleft--;\r\n\t\t\t\tvar x = document.getElementById("countdowntimer");\r\n\t\t\t\tx.textContent = timeleft + "S";\r\n\t\t\t\tif (timeleft <= 0) {\r\n\t\t\t\t\t\tclearInterval(downloadTimer);\r\n\t\t\t\t\t\t$(\'#connectToInternet\').removeClass(\'blur\').html(\'BỎ QUA VIDEO <small class="smallen">(SKIP AD)</small>\').click(function () {\r\n\t\t\t\t\t\t\t\tdocument.body.style.backgroundColor = "#F5F5F5";\r\n\t\t\t\t\t\t\t\t\tif(isShowBanner){ showBanner();} else{connectToWifi();}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t}, 1000);\r\n} \r\nfunction showBanner() {\r\n\t$(\'#layoutFooter\').show();\r\n\tmVideo.pause();\r\n\tdocument.body.style.backgroundColor = "#F5F5F5";\r\n\tcloseFullscreen();\r\n\tdocument.getElementById("mImg").style.display = "block";\r\n\t$("#mVideo").hide();\r\n\t$(\'#mImg\').click(function () { connectToWifi() });\r\n\t$(\'#connectToInternet\').removeClass(\'blur\');\r\n $(\'#connectToInternet\').unbind(\'click\');\r\n\t$(\'#connectToInternet\').addClass(\'connectInternet\').html(textButton+\'<BR/><small class="smallen">(ACCESS INTERNET)</small>\').click(function () {\r\n connectToWifi();\r\n\t});\r\n\tif(isShowUserInterest) $(\'#user-not-interest\').show();\r\n\tif(mInfo.os == "iOS" || mInfo.os == "Android"){\r\n\t\t$(window).off(\'scroll\');\r\n\t\tvar windowheight = window.innerHeight;\r\n\t\tif(windowheight < 700) {\r\n\t\t\t$("#connectToInternet").addClass("wa-button-video-continue");\r\n\t\t}\r\n \thandleFullscreenVideoBanner();\r\n\t\tif(isShowUserInterest){$("#connectToInternet").addClass("wa-button-video-continue-userInterest");}\r\n\t\tvar rightContinue = ($(window).width() - $(".wa-button-video").width())/2 - $("#continue_scroll_video").width();\r\n\t\t$("#continue_scroll_video").css(\'right\', rightContinue-1);\r\n\t\t$("#continue_scroll_video.continue-en").css(\'right\', rightContinue-1);\r\n\t\tsetTimeout(function(){continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll_video\'));}, 750);\r\n\t\t$(document).on(\'touchend\', function() {\r\n\t\t\tsetTimeout(function(){continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll_video\'));}, 750);\r\n\t\t});\r\n\t}\r\n\telse {\r\n\t\twindow.onresize = function(event) {\r\n\t\t\tvar rightContinue = ($(window).width() - $("#mImg").width())/2 - $("#continue_scroll_video").width() + 3;\r\n\t\t\t$("#continue_scroll_video").css(\'right\', rightContinue);\r\n\t\t\t$("#continue_scroll_video.continue-en").css(\'right\', rightContinue+5);\r\n\t\t};\r\n\t\tsetTimeout(function(){\r\n\t\t\tvar rightContinue = ($(window).width() - $("#mImg").width())/2 - $("#continue_scroll_video").width() + 5;\r\n\t\t\t$("#continue_scroll_video").css(\'right\', rightContinue);\r\n\t\t\t$("#continue_scroll_video.continue-en").css(\'right\', rightContinue+10);\r\n\t\t\tcontinueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll_video\'));\r\n\t\t}, 750);\r\n\t}\r\n}\r\nfunction handleFullscreenVideoBanner() {\r\n var footerHeight = ($(\'#wa_hotline\').outerHeight() > 0 ) ? $(\'#wa_hotline\').outerHeight() : 32.4;\r\n $(\'#horizontal-video-container\').css(\'min-height\', window.innerHeight - footerHeight);\r\n $(\'#horizontal-video-container\').css(\'background\', colorCodeBackgroundBanner);\r\n}\r\nfunction connectToWifi(){\r\n\tif(isShowUserInterest) {postAnalyticEvent("user_interest",JSON.stringify({}));}\r\n\tnextView();\r\n}\r\nfunction continueScrollHandle(elm, scroll){\r\n\tif(checkVisible(elm)) { scroll.hide(); }\r\n\telse { scroll.show(); }\r\n}\r\nfunction checkVisible(elm) {\r\n\tvar viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);\r\n\tif(elm != "" && elm != undefined){\r\n\t\tvar rect = elm.getBoundingClientRect();\r\n\t\treturn !(rect.bottom == 0 || rect.top - viewHeight >= -(rect.height - 12));\r\n\t}else{\r\n\t\treturn true;\r\n\t}\r\n}\r\nfunction closeFullscreen() {\r\n\tif (document.getElementById(\'mVideo\').exitFullscreen) {\r\n\t\tdocument.getElementById(\'mVideo\').exitFullscreen();\r\n\t} else if (document.getElementById(\'mVideo\').mozCancelFullScreen) { /* Firefox */\r\n\t\tdocument.getElementById(\'mVideo\').mozCancelFullScreen();\r\n\t} else if (document.getElementById(\'mVideo\').webkitExitFullscreen) { /* Chrome, Safari and Opera */\r\n\t\tdocument.getElementById(\'mVideo\').webkitExitFullscreen();\r\n\t} else if (document.getElementById(\'mVideo\').msExitFullscreen) { /* IE/Edge */\r\n\t\tdocument.getElementById(\'mVideo\').msExitFullscreen();\r\n\t}\r\n}\r\n</script>',
|
|
112
|
+
templateTypeId: 18,
|
|
113
|
+
validation: '',
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
var templateModel = {
|
|
117
|
+
template: {
|
|
118
|
+
autoField: '',
|
|
119
|
+
description: '07.[DEFAULT] Data Collection 1 Page_v1.0',
|
|
120
|
+
directoryId: '5183679953246990989',
|
|
121
|
+
directoryPath: '.0.99.4711650767517730267.5183679953246990989.4619609303918768290.',
|
|
122
|
+
id: '4619609303918768290',
|
|
123
|
+
layoutId: '0',
|
|
124
|
+
name: '',
|
|
125
|
+
pageCode: 'lgn',
|
|
126
|
+
templateHtml: '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=0"/>\r\n<link href="/static/Files/template/5246961620307474338/template_cpa_v1_0.css?432" rel="stylesheet" />\r\n<div id="cpa-container" style="width:100%">\r\n <img id="background_img_1" src="{cpa_1_banner_1}">\r\n <div class="box-wrapper-2">\r\n <table class="form_table formtable-fix form_table_text" id="cpa_field_list">\r\n </table>\r\n <table class="form_table btn-form-label form_table_text form-paddingtop">\r\n <tr>\r\n <td>\r\n <button class="btn_action btn_left btn_form_2" onclick="nextView();">\r\n <strong id="btn_left_text2">KẾT NỐI<br/>INTERNET NGAY</strong>\r\n <br/>\r\n <small class="smallen">(ACCESS INTERNET)</small>\r\n </button>\r\n </td>\r\n <td>\r\n <button class="btn_action btn_right btn_form_2" onclick="doSubmit()">\r\n <strong id="btn_right_text2">ĐĂNG KÝ<br/>& KẾT NỐI INTERNET</strong>\r\n <br/>\r\n <small class="smallen">(REGISTER & ACCESS INTERNET)</small>\r\n </button>\r\n </td>\r\n </tr>\r\n </table>\r\n </div>\r\n</div>\r\n<textarea id="textLeftButtonBanner2" style="display: none;">{cpa_1_banner_2}</textarea>\r\n<textarea id="textRightButtonBanner2" style="display: none;">{cpa_1_banner_3}</textarea>\r\n<div id="continue_scroll" style="display: none;">\r\n <a id="continue_text"><span></span>Còn tiếp</a>\r\n</div>\r\n<script>\r\nvar textLeftButtonBanner2 = $("#textLeftButtonBanner2").text().replace(/(?:\\r\\n|\\r|\\n)/g, \'<br/>\');\r\nvar textRightButtonBanner2 = $("#textRightButtonBanner2").text().replace(/(?:\\r\\n|\\r|\\n)/g, \'<br/>\');\r\nvar colorCodeLeftButton = "#"+"{cpa_1_banner_4}";\r\nvar colorCodeRightButton = "#"+"{cpa_1_banner_5}";\r\nvar colorTextLeftButton = "#"+"{cpa_1_banner_6}";\r\nvar colorTextRightButton = "#"+"{cpa_1_banner_7}";\r\nvar fieldList = [];\r\nvar nameFieldCheckbox = "{cpa_1_banner_8}" == "true" ? fieldList.push("name") : "";\r\nvar phoneFieldCheckbox = "{cpa_1_banner_9}" == "true" ? fieldList.push("phone") : "";\r\nvar emailFieldCheckbox = "{cpa_1_banner_10}" == "true" ? fieldList.push("email") : "";\r\nvar textFieldBackGroundColor = "{cpa_1_banner_11}";\r\nvar textFieldBorderColor = "#"+"{cpa_1_banner_12}";\r\n\r\nfieldList.forEach(function(item){\r\n if(item == "name"){\r\n $("#cpa_field_list").append("<tr><td colspan=\'2\' class=\'tooltip\'><input type=\'text\' id=\'name\' name=\'name\' placeholder=\'Họ và tên\' class=\'input-text input-box-2 input-text-name\'></input><span class=\'tooltiptext\' id=\'tooltipname\'>Họ và tên không đúng, xin vui lòng nhập lại!</span></td></tr>");\r\n }\r\n if(item == "phone"){\r\n $("#cpa_field_list").append("<tr><td colspan=\'2\' class=\'tooltip\'><input type=\'number\' id = \'phone\' placeholder=\'Số điện thoại\' class=\'input-text input-box-2 input-text-phone\'></input><span class=\'tooltiptext\' id=\'tooltipphone\'>Số điện thoại không đúng, xin vui lòng nhập lại!</span></td></tr>");\r\n }\r\n if(item == "email"){\r\n $("#cpa_field_list").append("<tr><td colspan=\'2\' class=\'tooltip\'><input type=\'text\' id=\'email\' placeholder=\'Email\' class=\'input-text input-box-2 input-text-email\' /><span class=\'tooltiptext\' id=\'tooltipemail\'>Email không đúng, xin vui lòng nhập lại!</span></td></tr>");\r\n }\r\n});\r\nif(fieldList.length == 3) {\r\n $(".box-wrapper-2").addClass("three-field-form");\r\n}\r\nvar mInfo = detectDeviceInfo();\r\nvar windowheight = window.innerHeight;\r\nvar browserLang = navigator.language || navigator.userLanguage;\r\nif(browserLang !="vi-VN"){\r\n $("#continue_text").html("<span></span>More</a>");\r\n // $(".wa-button-maxview").addClass("wa-button-en");\r\n $("#continue_scroll").addClass("continue-en");\r\n}\r\nif(textLeftButtonBanner2.length > 0) { $("#btn_left_text2").html(textLeftButtonBanner2); }\r\nif(textRightButtonBanner2.length > 0) { $("#btn_right_text2").html(textRightButtonBanner2); }\r\n$(".btn_left").css({\r\n "background-color": colorCodeLeftButton,\r\n "color": colorTextLeftButton\r\n});\r\n$(".btn_right").css({\r\n "background-color": colorCodeRightButton,\r\n "color": colorTextRightButton\r\n});\r\nif(textFieldBackGroundColor.toLowerCase() == "màu xám") {\r\n $("td > .input-box-2").css("background-color", "#d9d9d9");\r\n}\r\n$("td > .input-box-2").css("border",\'1px solid \' + textFieldBorderColor);\r\n\r\nif(mInfo.os == "iOS" || mInfo.os == "Android"){\r\n $(\'#continue_text\').css(\'color\', colorCodeLeftButton);\r\n $(\'#continue_text span\').css({\r\n "border-left":"5px solid " + colorCodeLeftButton,\r\n "border-bottom": "5px solid " + colorCodeLeftButton\r\n });\r\n}\r\n\r\n$("#continue_scroll").hide();\r\nfunction startAnimation(){\r\n $(\'#layoutHeader\').hide();\r\n if(mInfo.os == "iOS" || mInfo.os == "Android"){\r\n $(window).off(\'scroll\');\r\n // var footerHeight = ($(\'#wa_hotline\').outerHeight() > 0 ) ? $(\'#wa_hotline\').outerHeight() : 32.4;\r\n // $(\'#cpa-container\').css(\'min-height\', windowheight - footerHeight);\r\n // $(\'#cpa-container\').css(\'background\', colorCodeBody);\r\n setTimeout(function(){continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll\'));}, 750);\r\n $(document).on(\'touchend\', function() {\r\n setTimeout(function()\r\n {\r\n continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll\'));\r\n }, 750);\r\n });\r\n }\r\n else {\r\n window.onresize = function(event) {\r\n var rightContinue = ($(window).width() - $("#background_img_1").width())/2 - $("#continue_scroll").width() + 3;\r\n $("#continue_scroll").css(\'right\', rightContinue);\r\n $("#continue_scroll.continue-en").css(\'right\', rightContinue+5);\r\n };\r\n setTimeout(function(){\r\n var rightContinue = ($(window).width() - $("#background_img_1").width())/2 - $("#continue_scroll").width() + 5;\r\n $("#continue_scroll").css(\'right\', rightContinue);\r\n $("#continue_scroll.continue-en").css(\'right\', rightContinue+10);\r\n continueScrollHandle($("#wa_hotline")[0], $(\'#continue_scroll\'));\r\n }, 750);\r\n }\r\n}\r\n$(".input-text").focus(function(){\r\n $("#tooltipphone").hide();\r\n $("#tooltipname").hide();\r\n $("#tooltipemail").hide();\r\n remove_error($(\'.input-text\'));\r\n});\r\nfunction goToForm(){\r\n $(\'.box-wrapper\').hide();\r\n $(\'.box-wrapper-2\').show();\r\n $(\'#background_img\').hide();\r\n $(\'#background_img_1\').show();\r\n}\r\nfunction doSubmit(){\r\n var phone = $(\'#phone\').val();\r\n var name = $(\'#name\').val();\r\n var email = $(\'#email\').val();\r\n var valObject = {name: name, phone: phone, email: email};\r\n if (validateDataCustomer(name,phone,email)){\r\n var eventObject = {};\r\n fieldList.forEach(function(item) {\r\n eventObject[item] = valObject[item];\r\n });\r\n postAnalyticEvent("eventcpa",JSON.stringify(eventObject));\r\n nextView();\r\n }\r\n}\r\nfunction validateDataCustomer(name,phone,email){\r\n var validate = true;\r\n if(fieldList.indexOf("name") !== -1){\r\n if ((!name)||(ContainNum(name))){\r\n set_error($(\'#name\'));\r\n set_errortooltip($(\'#tooltipname\'));\r\n validate = false;\r\n }\r\n }\r\n if(fieldList.indexOf("phone") !== -1){\r\n phone = phone.replace(\'(+84)\', \'0\');\r\n phone = phone.replace(\'+84\', \'0\');\r\n phone = phone.replace(\'0084\', \'0\');\r\n phone = phone.replace(/ /g, \'\');\r\n if (phone != \'\') {\r\n var firstNumber = phone.substring(0, 2);\r\n if ((firstNumber == \'03\' || firstNumber == \'05\' || firstNumber == \'07\' || firstNumber == \'08\' || firstNumber == \'09\') && phone.length == 10) {\r\n if (phone.match(/^\\d{10}/)) {}\r\n } else if (firstNumber == \'01\' && phone.length == 11) {\r\n if (phone.match(/^\\d{11}/)) {}\r\n }\r\n else{\r\n set_error($(\'#phone\'));\r\n set_errortooltip($(\'#tooltipphone\'));\r\n validate = false;\r\n }\r\n }\r\n else{\r\n set_error($(\'#phone\'));\r\n set_errortooltip($(\'#tooltipphone\'));\r\n validate = false;\r\n }\r\n }\r\n if(fieldList.indexOf("email") !== -1){\r\n if (email != \'\') {\r\n if (!isEmail(email)){\r\n set_error($(\'#email\'));\r\n set_errortooltip($(\'#tooltipemail\'));\r\n validate = false;\r\n }\r\n }\r\n else {\r\n set_error($(\'#email\'));\r\n set_errortooltip($(\'#tooltipemail\'));\r\n validate = false;\r\n }\r\n }\r\n return validate;\r\n}\r\nfunction isEmail(email) {\r\n var regex = /^([a-zA-Z0-9_.+-])+\\@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$/;\r\n return regex.test(email);\r\n}\r\nfunction ContainNum(t)\r\n{\r\n var regex = /\\d/g;\r\n return regex.test(t);\r\n}\r\nfunction set_error(element){\r\n element.addClass(\'_error\');\r\n}\r\nfunction set_errortooltip(element){\r\n element.show();\r\n}\r\nfunction remove_error(element){\r\n element.removeClass(\'_error\');\r\n}\r\nfunction continueScrollHandle(elm, scroll){\r\n if(checkVisible(elm)) {$(\'#continue_scroll\').hide();}\r\n else {$(\'#continue_scroll\').show();}\r\n}\r\nfunction checkVisible(elm){\r\n var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);\r\n if(elm != "" && elm != undefined){\r\n var rect = elm.getBoundingClientRect();\r\n return !(rect.bottom == 0 || rect.top - viewHeight >= -(rect.height - 12));\r\n }else{\r\n return true;\r\n }\r\n}\r\n</script>',
|
|
127
|
+
templateTypeId: 17,
|
|
128
|
+
validation: '',
|
|
129
|
+
},
|
|
130
|
+
templateParameters: [
|
|
131
|
+
{
|
|
132
|
+
childrens: [],
|
|
133
|
+
defaultValue: '',
|
|
134
|
+
fieldName: 'cpa_1_banner_1',
|
|
135
|
+
fieldType: 'image',
|
|
136
|
+
id: '22302',
|
|
137
|
+
isRequired: true,
|
|
138
|
+
labelName: 'File Banner',
|
|
139
|
+
templateId: '4619609303918768290',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
childrens: [],
|
|
143
|
+
defaultValue: 'Màu trắng\\nMàu xám',
|
|
144
|
+
fieldName: 'cpa_1_banner_11',
|
|
145
|
+
fieldType: 'dropdownlist',
|
|
146
|
+
id: '22303',
|
|
147
|
+
isRequired: false,
|
|
148
|
+
labelName: 'Mã màu nền trường điền',
|
|
149
|
+
templateId: '4619609303918768290',
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
var clientMethod = {
|
|
154
|
+
templatesGetDirectories: function () { return Promise.resolve(directories); },
|
|
155
|
+
templateTypesGet: function () { return Promise.resolve(templateTypes); },
|
|
156
|
+
templatesGetByDirectoryId: function (_id) {
|
|
157
|
+
return Promise.resolve(templates);
|
|
158
|
+
},
|
|
159
|
+
templatesGet: function () { return function (_id) {
|
|
160
|
+
Promise.resolve(templateModel);
|
|
161
|
+
}; },
|
|
162
|
+
};
|
|
163
|
+
// Mock Hooks
|
|
164
|
+
jest.mock('../Hooks', function () { return ({
|
|
165
|
+
__esModule: true,
|
|
166
|
+
default: function () { return ({
|
|
167
|
+
service: {
|
|
168
|
+
templatesGetDirectories: jest.fn(function () {
|
|
169
|
+
return Promise.resolve(clientMethod.templatesGetDirectories());
|
|
170
|
+
}),
|
|
171
|
+
templateTypesGet: jest.fn(clientMethod.templateTypesGet),
|
|
172
|
+
templatesGetByDirectoryId: jest.fn(function (_id) {
|
|
173
|
+
return Promise.resolve(clientMethod.templatesGetByDirectoryId(_id));
|
|
174
|
+
}),
|
|
175
|
+
templatesGet: jest.fn(function (_id) {
|
|
176
|
+
return Promise.resolve(clientMethod.templatesGet());
|
|
177
|
+
}),
|
|
178
|
+
},
|
|
179
|
+
}); },
|
|
180
|
+
}); });
|
|
181
|
+
// Mock đa ngữ
|
|
182
|
+
jest.mock('react-i18next', function () { return (__assign(__assign({}, jest.requireActual('react-i18next')), { useTranslation: function () { return ({ t: jest.fn(function (key) { return key; }) }); } })); });
|
|
183
|
+
describe('RowTemplate component', function () {
|
|
184
|
+
var mockProps = {
|
|
185
|
+
pageCode: 'lgn',
|
|
186
|
+
template: { sortOrder: 1 },
|
|
187
|
+
disabledIconDelete: false,
|
|
188
|
+
onChangeRow: jest.fn(),
|
|
189
|
+
onUpdateWizardLogin: jest.fn(),
|
|
190
|
+
};
|
|
191
|
+
var renderUi = function () { return (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTemplate_1.default, __assign({}, mockProps))); };
|
|
192
|
+
it('renders component', function () {
|
|
193
|
+
renderUi();
|
|
194
|
+
expect(react_1.screen.getByTestId('Common.Name')).toBeInTheDocument();
|
|
195
|
+
expect(react_1.screen.getByTestId('Wizard.Directory')).toBeInTheDocument();
|
|
196
|
+
expect(react_1.screen.getByTestId('Common.TypeTemplate')).toBeInTheDocument();
|
|
197
|
+
expect(react_1.screen.getByTestId('Wizard.SelectTemplate')).toBeInTheDocument();
|
|
198
|
+
expect(react_1.screen.getByTestId('Wizard.FieldNames')).toBeInTheDocument();
|
|
199
|
+
expect(react_1.screen.getByTestId('deleteIcon')).toBeInTheDocument();
|
|
200
|
+
});
|
|
201
|
+
it('check handleDeleteRowTemplate', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
202
|
+
var deleteIcon;
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
switch (_a.label) {
|
|
205
|
+
case 0:
|
|
206
|
+
renderUi();
|
|
207
|
+
deleteIcon = react_1.screen.getByTestId('deleteIcon');
|
|
208
|
+
react_1.fireEvent.click(deleteIcon);
|
|
209
|
+
return [4 /*yield*/, (0, react_1.waitFor)(function () {
|
|
210
|
+
expect(mockProps.onUpdateWizardLogin).toHaveBeenCalledWith(Utils_1.TYPE_LOGIN_TEMPLATE.REMOVE, 1);
|
|
211
|
+
})];
|
|
212
|
+
case 1:
|
|
213
|
+
_a.sent();
|
|
214
|
+
return [2 /*return*/];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}); });
|
|
218
|
+
it('check handleChange', function () {
|
|
219
|
+
renderUi();
|
|
220
|
+
react_1.fireEvent.change(react_1.screen.getByRole('textbox', { name: /Common.Name/i }), {
|
|
221
|
+
target: { value: 'test1' },
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
it('check handleChange combobox directories', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
225
|
+
var templatesGetByDirectoryIdSpy;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0:
|
|
229
|
+
templatesGetByDirectoryIdSpy = jest.spyOn(clientMethod, 'templatesGetByDirectoryId');
|
|
230
|
+
renderUi();
|
|
231
|
+
// Tên Thư Mục
|
|
232
|
+
return [4 /*yield*/, (0, react_1.waitFor)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
233
|
+
var selectContainer, comboBox;
|
|
234
|
+
return __generator(this, function (_a) {
|
|
235
|
+
switch (_a.label) {
|
|
236
|
+
case 0:
|
|
237
|
+
selectContainer = react_1.screen.getByTestId('Wizard.Directory');
|
|
238
|
+
return [4 /*yield*/, (0, react_1.within)(selectContainer).findByRole('combobox')];
|
|
239
|
+
case 1:
|
|
240
|
+
comboBox = _a.sent();
|
|
241
|
+
if (comboBox) {
|
|
242
|
+
react_1.fireEvent.mouseDown(comboBox);
|
|
243
|
+
react_1.screen.getAllByText('SYSTEM TEMPLATE').forEach(function (el) {
|
|
244
|
+
react_1.fireEvent.click(el);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return [2 /*return*/];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}); })];
|
|
251
|
+
case 1:
|
|
252
|
+
// Tên Thư Mục
|
|
253
|
+
_a.sent();
|
|
254
|
+
expect(templatesGetByDirectoryIdSpy).toHaveBeenCalledWith(directories[0].directoryId);
|
|
255
|
+
return [2 /*return*/];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}); });
|
|
259
|
+
});
|