awing-library 2.1.102-beta → 2.1.103-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.
@@ -1 +1,3 @@
1
- export default function (): import("react/jsx-runtime").JSX.Element;
1
+ import React from 'react';
2
+ declare const _default: React.FC<unknown>;
3
+ export default _default;
@@ -39,6 +39,7 @@ var Constant_1 = require("../Constant");
39
39
  var i18n_1 = __importDefault(require("../../../i18n"));
40
40
  var TabLabel_1 = __importDefault(require("../../../Commons/Components/TabLabel"));
41
41
  var usePath_1 = __importDefault(require("../../../Commons/Hooks/usePath"));
42
+ var Wrapper_1 = __importDefault(require("../../../AWING/HOC/Wrapper"));
42
43
  var route = [
43
44
  Constant_1.Constants.CAMPAIGN_INFORMATION,
44
45
  Constant_1.Constants.CAMPAIGN_SUBCAMPAIGN,
@@ -221,7 +222,4 @@ var CreateOrEdit = function () {
221
222
  : undefined, errContent: (0, jsx_runtime_1.jsx)("span", { style: { marginLeft: '-5px' }, children: "*" }) }) }, idx)); }) }) }), tabsList.map(function (tab, idx) { return ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, { sx: { padding: '0' }, value: String(idx), children: tab.compoent }, idx)); })] }) })) }) }));
222
223
  };
223
224
  // eslint-disable-next-line import/no-anonymous-default-export
224
- function default_1() {
225
- return ((0, jsx_runtime_1.jsx)(recoil_1.RecoilRoot, { children: (0, jsx_runtime_1.jsx)(CreateOrEdit, {}) }));
226
- }
227
- exports.default = default_1;
225
+ exports.default = (0, Wrapper_1.default)(CreateOrEdit, { component: recoil_1.RecoilRoot });
@@ -46,17 +46,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
47
  }
48
48
  };
49
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
+ if (ar || !(i in from)) {
52
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
+ ar[i] = from[i];
54
+ }
55
+ }
56
+ return to.concat(ar || Array.prototype.slice.call(from));
57
+ };
49
58
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
59
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
60
  };
52
61
  Object.defineProperty(exports, "__esModule", { value: true });
53
62
  var jsx_runtime_1 = require("react/jsx-runtime");
54
63
  var material_1 = require("@mui/material");
64
+ var AWING_1 = require("../../../../AWING");
65
+ var Context_1 = require("../../../../Context");
55
66
  var lodash_1 = require("lodash");
56
67
  var react_1 = __importDefault(require("react"));
57
68
  var recoil_1 = require("recoil");
58
- var AWING_1 = require("../../../../AWING");
59
- var Context_1 = require("../../../../Context");
60
69
  var ViewTemplate_1 = __importDefault(require("../../../ViewTemplate"));
61
70
  var Context_2 = __importDefault(require("../../Context"));
62
71
  var enums_1 = require("../../enums");
@@ -71,6 +80,7 @@ var ViewContent = function (_a) {
71
80
  var _f = react_1.default.useState(''), scriptValidationTemplate = _f[0], setScriptValidationTemplate = _f[1];
72
81
  var _g = react_1.default.useState(''), scriptAutoField = _g[0], setScriptAutoField = _g[1];
73
82
  var _h = react_1.default.useState(false), loading = _h[0], setLoading = _h[1];
83
+ var isUniq = react_1.default.useRef(false);
74
84
  var rootDirectory = (0, recoil_1.useRecoilValue)(Recoil_1.pageRootDeirectory);
75
85
  var _j = (0, recoil_1.useRecoilState)(Recoil_1.pageEventState), events = _j[0], setEvent = _j[1];
76
86
  react_1.default.useEffect(function () {
@@ -88,14 +98,26 @@ var ViewContent = function (_a) {
88
98
  }
89
99
  // eslint-disable-next-line react-hooks/exhaustive-deps
90
100
  }, [viewInfoData.templateId, viewInfoData.viewDatas.length]);
101
+ react_1.default.useEffect(function () {
102
+ if (!isUniq.current) {
103
+ console.log("uniq...");
104
+ setEvent(function (prev) {
105
+ return (0, lodash_1.uniqBy)(prev, function (a) {
106
+ return JSON.stringify({
107
+ event: a.event,
108
+ viewNumber: a.viewNumber,
109
+ pageId: a.pageId,
110
+ });
111
+ });
112
+ });
113
+ isUniq.current = true;
114
+ }
115
+ // eslint-disable-next-line react-hooks/exhaustive-deps
116
+ }, [events]);
91
117
  var handleResData = function (res) {
92
- console.log("res", res.templateEvents);
93
118
  onChange(['viewDatas'], (0, Utils_1.getTemplateDatas)(res.templateParameters, viewInfoData, pageId, viewNumber));
94
- setEvent(function (prev) {
95
- var viewEvents = prev.filter(function (item) { return item.viewNumber !== viewNumber; });
96
- viewEvents.concat(res.templateEvents.map(function (item) { return (__assign(__assign({}, item), { viewNumber: viewNumber })); }));
97
- return viewEvents;
98
- });
119
+ setEvent(function (prev) { return __spreadArray(__spreadArray([], res.templateEvents.map(function (item) { return ({ id: item.id, event: item.event, viewNumber: viewNumber + 1, pageId: pageId, protected: true }); }), true), prev, true); });
120
+ isUniq.current = false;
99
121
  onChange(['templateValidation'], res.template.validation);
100
122
  onChange(['templateHandleEvent'], res.template.autoField);
101
123
  setScriptValidationTemplate(res.template.validation || '');
@@ -109,12 +131,10 @@ var ViewContent = function (_a) {
109
131
  var _a;
110
132
  var keys = fieldPath.split('.');
111
133
  var fieldChange = templateDatasUpdated[keys[1]];
112
- console.log(fieldPath, fieldChange);
113
134
  var indexOfFieldChange = (_a = viewInfoData.viewDatas) === null || _a === void 0 ? void 0 : _a.findIndex(function (field) { return field.fieldName === fieldChange.fieldName; });
114
135
  onChange(['viewDatas', String(indexOfFieldChange), 'fieldValue'], fieldChange.fieldValue);
115
136
  setChanged();
116
137
  };
117
- console.log("events", events);
118
138
  var onUploadFile = function (files) { return __awaiter(void 0, void 0, void 0, function () {
119
139
  var fieldName, params;
120
140
  return __generator(this, function (_a) {
@@ -156,14 +176,17 @@ var ViewContent = function (_a) {
156
176
  ? 'lgn'
157
177
  : 'wlc', "/").concat((_d = (_c = viewInfoData.viewDatas) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.pageId), enablePreview: pageCode === enums_1.PageCode.Lgn, advanceFields: viewInfoData.viewDatas.filter(function (item) { return item === null || item === void 0 ? void 0 : item.isAdvanced; }).map(function (field) { return field.fieldName; }), scriptValidate: scriptValidationTemplate, scriptAutoField: scriptAutoField, domainId: domainId, configs: CONFIGS,
158
178
  // validStatus={validStatus}
159
- validStatus: viewInfoData.validStatus,
160
- // viewEvent={}
161
- onChange: handleOnChange, onChangeViewValid: function (status) {
179
+ validStatus: viewInfoData.validStatus, viewEvents: events.filter(function (item) { return item.viewNumber === viewNumber + 1; }), onChange: handleOnChange, onChangeViewValid: function (status) {
162
180
  onChange(['isValidationFields'], [status]);
163
181
  }, onChangeValidateProcess: function (processValue) {
164
182
  onChange(['validProcessStatus'], processValue);
165
183
  }, onNotifyError: function (errorMessage) {
166
184
  appHelper.snackbar('error', errorMessage);
167
- }, onUploadFile: onUploadFile }) }) })) })) }));
185
+ }, onUploadFile: onUploadFile, onChangeEvent: function (values) {
186
+ setEvent(function (prev) {
187
+ return prev.filter(function (item) { return item.viewNumber !== viewNumber + 1; }).concat(values.map(function (value) { return (__assign(__assign({}, value), { viewNumber: viewNumber + 1, pageId: pageId })); }));
188
+ });
189
+ isUniq.current = false;
190
+ } }) }) })) })) }));
168
191
  };
169
192
  exports.default = ViewContent;
@@ -16,24 +16,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var jsx_runtime_1 = require("react/jsx-runtime");
18
18
  var material_1 = require("@mui/material");
19
+ var Event_1 = __importDefault(require("../../../../ACM-AXN/ViewTemplate/TemplateField/Event"));
19
20
  var MonacoEditor_1 = __importDefault(require("../../../../ACM-AXN/ViewTemplate/TemplateField/Fields/BasicField/MonacoEditor"));
20
21
  var react_1 = require("react");
21
22
  var react_i18next_1 = require("react-i18next");
22
23
  var recoil_1 = require("recoil");
23
24
  var Recoils_1 = require("../Recoils");
24
25
  var Parameter_1 = __importDefault(require("./Parameter"));
25
- var Events_1 = __importDefault(require("./Events"));
26
+ // import Events from './Events'
26
27
  // import MonacoEditor from 'Components/MonacoEditor'
27
28
  var Template = function () {
28
29
  var t = (0, react_i18next_1.useTranslation)().t;
29
- var _a = (0, recoil_1.useRecoilState)(Recoils_1.templateInfoState), info = _a[0], setInfo = _a[1];
30
+ var _a = (0, recoil_1.useRecoilState)(Recoils_1.templateEventState), events = _a[0], setEvent = _a[1];
31
+ var _b = (0, recoil_1.useRecoilState)(Recoils_1.templateInfoState), info = _b[0], setInfo = _b[1];
30
32
  var handleChangeEditor = (0, react_1.useCallback)(function (templateHtml) {
31
33
  setInfo(function (prev) { return (__assign(__assign({}, prev), { templateHtml: templateHtml })); });
32
34
  }, [setInfo]);
33
35
  return ((0, jsx_runtime_1.jsx)(material_1.Grid, { container: true, sx: { flexGrow: 1, padding: function (theme) { return theme.spacing(3); } }, children: (0, jsx_runtime_1.jsxs)(material_1.Grid, { item: true, component: material_1.Paper, sx: { padding: function (theme) { return theme.spacing(2); }, width: '100%' }, children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, { item: true, xs: 12, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle1", sx: {
34
36
  fontWeight: 'bold',
35
37
  color: '#BDC7CC',
36
- }, children: t('Common.Events') }), (0, jsx_runtime_1.jsx)(material_1.Box, { marginBottom: 2, children: (0, jsx_runtime_1.jsx)(Events_1.default, { templateId: info.id || '' }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { item: true, xs: 12, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle1", sx: {
38
+ }, children: t('Common.Events') }), (0, jsx_runtime_1.jsx)(material_1.Box, { marginBottom: 2, children: (0, jsx_runtime_1.jsx)(Event_1.default, { viewEvents: events, disabledLabel: true, onChangeEvent: function (values) {
39
+ setEvent(values.map(function (item, index) { return (__assign(__assign({}, item), { templateId: info.id })); }));
40
+ } }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { item: true, xs: 12, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle1", sx: {
37
41
  fontWeight: 'bold',
38
42
  color: '#BDC7CC',
39
43
  }, children: t('TemplateManagement.TemplateHtml') }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
@@ -0,0 +1,12 @@
1
+ import { PageViewEvent } from '../../../ACM-AXN/Page/Types';
2
+ import React from 'react';
3
+ export interface ViewTemplateEvents extends Omit<PageViewEvent, 'viewNumber' | 'templateId'> {
4
+ protected?: boolean;
5
+ }
6
+ export interface EventsProps {
7
+ viewEvents: ViewTemplateEvents[];
8
+ onChangeEvent: (values: ViewTemplateEvents[]) => void;
9
+ disabledLabel?: boolean;
10
+ }
11
+ declare const Events: React.FC<EventsProps>;
12
+ export default Events;
@@ -0,0 +1,69 @@
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 material_1 = require("@mui/material");
19
+ var validation_1 = require("../../../AWING/ultis/validation");
20
+ var Helpers_1 = require("../../../Utils/Helpers");
21
+ var i18n_1 = __importDefault(require("../../../i18n"));
22
+ var lodash_1 = require("lodash");
23
+ var react_1 = __importDefault(require("react"));
24
+ var react_i18next_1 = require("react-i18next");
25
+ var Events = function (_a) {
26
+ var viewEvents = _a.viewEvents, onChangeEvent = _a.onChangeEvent, disabledLabel = _a.disabledLabel;
27
+ var t = (0, react_i18next_1.useTranslation)(undefined, { i18n: i18n_1.default }).t;
28
+ var _b = react_1.default.useState(''), tempValue = _b[0], setTempValue = _b[1];
29
+ var _c = react_1.default.useState(''), error = _c[0], setError = _c[1];
30
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
31
+ marginBottom: 2,
32
+ width: '100%',
33
+ }, children: (0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ error: !!error, helperText: error, fullWidth: true, variant: "standard", placeholder: "".concat(t('Common.Events'), "...") }, (!disabledLabel && { label: t('Common.Events') }), { inputProps: {
34
+ autoComplete: 'off',
35
+ }, value: tempValue, onKeyDown: function (e) {
36
+ if (e.key === 'Enter') {
37
+ var _a = (0, validation_1.textValidation)(tempValue, 50, false, /^[a-zA-Z0-9đĐ_.()\u0080-\uFFFF]+$/g), valid = _a.valid, message = _a.message;
38
+ var isStartWithNumber = tempValue.match(/^\d/);
39
+ if (viewEvents.map(function (item) { return item.event; }).includes((0, Helpers_1.changeToAlias)(tempValue)) || !valid || isStartWithNumber) {
40
+ setError(!valid ? message : isStartWithNumber ? t('Common.InvalidData') : t('Common.Existed').replace('{0}', tempValue));
41
+ return;
42
+ }
43
+ onChangeEvent((0, lodash_1.uniqBy)(viewEvents.concat({ event: tempValue, id: 0 }), function (item) { return (0, Helpers_1.changeToAlias)(item.event); }));
44
+ setTempValue('');
45
+ }
46
+ }, onChange: function (event) {
47
+ setTempValue(event.target.value);
48
+ setError('');
49
+ }, InputProps: {
50
+ inputProps: {
51
+ autoComplete: 'off',
52
+ sx: {
53
+ width: 'auto!important',
54
+ display: 'flex',
55
+ flex: '1 1 auto',
56
+ },
57
+ },
58
+ sx: {
59
+ flexWrap: 'wrap',
60
+ },
61
+ startAdornment: viewEvents.map(function (option) { return ((0, jsx_runtime_1.jsx)(material_1.Chip, { sx: {
62
+ marginRight: 1,
63
+ marginBottom: 0.5,
64
+ }, label: option.event, title: option.event, disabled: option === null || option === void 0 ? void 0 : option.protected, onDelete: function () {
65
+ onChangeEvent(viewEvents.filter(function (item) { return item.event !== option.event; }));
66
+ } }, option.event)); }),
67
+ } })) }));
68
+ };
69
+ exports.default = Events;
@@ -0,0 +1,84 @@
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
+ /* eslint-disable testing-library/no-wait-for-side-effects */
19
+ var react_1 = require("@testing-library/react");
20
+ var Event_1 = __importDefault(require("./Event"));
21
+ // Mock i18next
22
+ jest.mock('react-i18next', function () { return (__assign(__assign({}, jest.requireActual('react-i18next')), { useTranslation: function () { return ({ t: jest.fn(function (key) { return key; }) }); } })); });
23
+ var props = {
24
+ viewEvents: [
25
+ { id: 1101, event: 'event', pageId: 'pageId' },
26
+ { id: 113, event: 'event-2xxx', pageId: 'pageId' },
27
+ ],
28
+ onChangeEvent: jest.fn(function (values) { }),
29
+ };
30
+ var renderUi = function (p) {
31
+ if (p === void 0) { p = props; }
32
+ return (0, react_1.render)((0, jsx_runtime_1.jsx)(Event_1.default, __assign({}, p)));
33
+ };
34
+ describe('Import Template component', function () {
35
+ it('render without crash', function () {
36
+ // Biên viewEvents
37
+ renderUi(__assign(__assign({}, props), { viewEvents: [] }));
38
+ renderUi();
39
+ expect(react_1.screen.getByText('event-2xxx')).toBeInTheDocument();
40
+ });
41
+ it('Remove event', function () {
42
+ renderUi();
43
+ react_1.screen.getAllByTestId('CancelIcon').forEach(function (removeBtn) {
44
+ expect(removeBtn).toBeInTheDocument();
45
+ react_1.fireEvent.click(removeBtn);
46
+ expect(props.onChangeEvent).toBeCalled();
47
+ });
48
+ });
49
+ it('Add event Lỗi ký tự', function () {
50
+ renderUi();
51
+ var textBox = react_1.screen.getByRole('textbox', { name: 'Common.Events' });
52
+ react_1.fireEvent.change(textBox, { target: { value: 'new-event@$#' } });
53
+ react_1.fireEvent.keyDown(textBox, { key: 'Enter' });
54
+ expect(react_1.screen.getByText('Ký tự không hợp lệ: - @ $ #')).toBeInTheDocument();
55
+ });
56
+ it('Add event Existed', function () {
57
+ renderUi();
58
+ var textBox = react_1.screen.getByRole('textbox', { name: 'Common.Events' });
59
+ react_1.fireEvent.change(textBox, { target: { value: 'event' } });
60
+ react_1.fireEvent.keyDown(textBox, { key: 'Enter' });
61
+ expect(react_1.screen.getByText('Common.Existed')).toBeInTheDocument();
62
+ });
63
+ it('Add event start with number', function () {
64
+ renderUi();
65
+ var textBox = react_1.screen.getByRole('textbox', { name: 'Common.Events' });
66
+ react_1.fireEvent.change(textBox, { target: { value: '123event' } });
67
+ react_1.fireEvent.keyDown(textBox, { key: 'Enter' });
68
+ expect(react_1.screen.getByText('Common.InvalidData')).toBeInTheDocument();
69
+ });
70
+ it('Add event', function () {
71
+ renderUi();
72
+ var textBox = react_1.screen.getByRole('textbox', { name: 'Common.Events' });
73
+ react_1.fireEvent.change(textBox, { target: { value: 'newEvent' } });
74
+ react_1.fireEvent.keyDown(textBox, { key: 'Enter' });
75
+ expect(props.onChangeEvent).toBeCalled();
76
+ });
77
+ it('Add event without Enter', function () {
78
+ renderUi();
79
+ var textBox = react_1.screen.getByRole('textbox', { name: 'Common.Events' });
80
+ react_1.fireEvent.change(textBox, { target: { value: 'newEvent' } });
81
+ react_1.fireEvent.keyDown(textBox, { key: 'Esc' });
82
+ expect(react_1.screen.getByDisplayValue('newEvent')).toBeInTheDocument();
83
+ });
84
+ });
@@ -0,0 +1,5 @@
1
+ import { ViewTemplateEvents } from "./Event";
2
+ export declare const validEvents: (events: ViewTemplateEvents[]) => {
3
+ valid: boolean;
4
+ message: string;
5
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validEvents = void 0;
4
+ var validEvents = function (events) {
5
+ var result = {
6
+ valid: true,
7
+ message: '',
8
+ };
9
+ console.log("aa12aa", events);
10
+ // const aa = uniqWith(events, (a, b) => a.event === b.event)
11
+ // console.log("aa", aa, events)
12
+ return result;
13
+ };
14
+ exports.validEvents = validEvents;
@@ -1,2 +1,2 @@
1
1
  import { ViewTemplateProps } from "./interface";
2
- export default function ViewTemplate({ templateDatas, pagePath, enablePreview, advanceFields, templateLabelName, domainId, validStatus, scriptAutoField, scriptValidate, configs, onChange, onChangeViewValid, onChangeValidateProcess, onNotifyError, onUploadFile, }: ViewTemplateProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function ViewTemplate({ templateDatas, pagePath, enablePreview, advanceFields, templateLabelName, domainId, validStatus, scriptAutoField, scriptValidate, configs, onChange, onChangeViewValid, onChangeValidateProcess, onNotifyError, onUploadFile, ...props }: ViewTemplateProps): import("react/jsx-runtime").JSX.Element;
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
13
24
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
26
  };
@@ -26,6 +37,7 @@ var react_1 = require("react");
26
37
  var react_i18next_1 = require("react-i18next");
27
38
  var i18n_1 = __importDefault(require("../../i18n"));
28
39
  var Form_1 = require("../../AWING/Form");
40
+ var Event_1 = __importDefault(require("./TemplateField/Event"));
29
41
  function ViewTemplate(_a) {
30
42
  var _b = _a.templateDatas, templateDatas = _b === void 0 ? [] : _b, pagePath = _a.pagePath, _c = _a.enablePreview, enablePreview = _c === void 0 ? true : _c, _d = _a.advanceFields, advanceFields = _d === void 0 ? [] : _d, _e = _a.templateLabelName, templateLabelName = _e === void 0 ? "" : _e, _f = _a.domainId, domainId = _f === void 0 ? "" : _f, _g = _a.validStatus, validStatus = _g === void 0 ? true : _g, _h = _a.scriptAutoField, scriptAutoField = _h === void 0 ? "" : _h, _j = _a.scriptValidate, scriptValidate = _j === void 0 ? "" : _j, configs = _a.configs, onChange = _a.onChange, _k = _a.onChangeViewValid, onChangeViewValid = _k === void 0 ? function (status) {
31
43
  console.log(status);
@@ -33,7 +45,7 @@ function ViewTemplate(_a) {
33
45
  console.log(processValue);
34
46
  } : _l, _m = _a.onNotifyError, onNotifyError = _m === void 0 ? function (errorMessage) {
35
47
  console.log(errorMessage);
36
- } : _m, onUploadFile = _a.onUploadFile;
48
+ } : _m, onUploadFile = _a.onUploadFile, props = __rest(_a, ["templateDatas", "pagePath", "enablePreview", "advanceFields", "templateLabelName", "domainId", "validStatus", "scriptAutoField", "scriptValidate", "configs", "onChange", "onChangeViewValid", "onChangeValidateProcess", "onNotifyError", "onUploadFile"]);
37
49
  var t = (0, react_i18next_1.useTranslation)().t;
38
50
  var _o = (0, react_1.useState)(false), advanceOptionExpand = _o[0], setAdvanceOptionExpand = _o[1];
39
51
  var CONFIGS = (0, common_1.fillConfigs)(configs);
@@ -77,7 +89,7 @@ function ViewTemplate(_a) {
77
89
  return ((0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 4, children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, { item: true, xs: enablePreview ? 8 : 12, children: [templateLabelName && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", style: {
78
90
  fontWeight: "bold",
79
91
  textTransform: "uppercase",
80
- }, children: templateLabelName })), fields && renderFields(fields, false), fields && advanceFields.length > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { id: "advance-option", style: {
92
+ }, children: templateLabelName })), fields && renderFields(fields, false), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { id: "advance-option", style: {
81
93
  display: "flex",
82
94
  flexDirection: "row",
83
95
  justifyContent: "space-between",
@@ -85,7 +97,7 @@ function ViewTemplate(_a) {
85
97
  cursor: "pointer",
86
98
  }, onClick: function () {
87
99
  setAdvanceOptionExpand(!advanceOptionExpand);
88
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { style: { fontWeight: "bold" }, children: t("ViewTemplate.AdvanceOption") }), (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: advanceOptionExpand ? ((0, jsx_runtime_1.jsx)(icons_material_1.ExpandLess, {})) : ((0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, {})) })] }), advanceOptionExpand && ((0, jsx_runtime_1.jsx)(material_1.Grid, { container: true, children: renderFields(fields, true) }))] }))] }), enablePreview && ((0, jsx_runtime_1.jsxs)(material_1.Grid, { item: true, xs: 4, children: [(0, jsx_runtime_1.jsx)(Preview_1.default, { domainId: domainId || "", validStatus: validStatus, configs: CONFIGS, pagePath: pagePath, templateDatas: templateDatas }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: t("ViewTemplate.PreviewLoadingNote") })] }))] }));
100
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { style: { fontWeight: "bold" }, children: t("ViewTemplate.AdvanceOption") }), (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: advanceOptionExpand ? ((0, jsx_runtime_1.jsx)(icons_material_1.ExpandLess, {})) : ((0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, {})) })] }), advanceOptionExpand && ((0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, children: [fields && advanceFields.length > 0 && renderFields(fields, true), (0, jsx_runtime_1.jsx)(Event_1.default, __assign({}, props))] }))] })] }), enablePreview && ((0, jsx_runtime_1.jsxs)(material_1.Grid, { item: true, xs: 4, children: [(0, jsx_runtime_1.jsx)(Preview_1.default, { domainId: domainId || "", validStatus: validStatus, configs: CONFIGS, pagePath: pagePath, templateDatas: templateDatas }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: t("ViewTemplate.PreviewLoadingNote") })] }))] }));
89
101
  }
90
102
  exports.default = ViewTemplate;
91
103
  var getChilds = function (fields, fieldInfo) {
@@ -1,4 +1,4 @@
1
- import { PageViewEvent } from "../../ACM-AXN/Page/Types";
1
+ import { EventsProps } from "./TemplateField/Event";
2
2
  export interface Configs {
3
3
  TEMPLATE_FILE_PATH?: string;
4
4
  FILE_TEMP_PATH?: string;
@@ -49,10 +49,7 @@ export interface FieldProps {
49
49
  onNotifyError: (errorMessage: string) => void;
50
50
  onUploadFile: (files: any[]) => Promise<string>;
51
51
  }
52
- export interface ViewTemplateEvents extends Omit<PageViewEvent, 'viewNumber'> {
53
- protected?: boolean;
54
- }
55
- export interface ViewTemplateProps {
52
+ export interface ViewTemplateProps extends EventsProps {
56
53
  templateDatas: FieldInfo[];
57
54
  /**
58
55
  * Đường dẫn tuyệt đối các file của page
@@ -95,5 +92,4 @@ export interface ViewTemplateProps {
95
92
  */
96
93
  onNotifyError?: (errorMessage: string) => void;
97
94
  onUploadFile: (files: any[]) => Promise<any>;
98
- viewEvents?: ViewTemplateEvents[];
99
95
  }
@@ -27,7 +27,7 @@ export declare function timestampToStringDDMMYYYYHHmm(date: {
27
27
  }): string | null;
28
28
  export declare const getRoutePath: (location: Location, params: Params) => string;
29
29
  export declare function calculatorDirectoryIdRoot(directoriesTree: any): number;
30
- export declare function changeToAlias(str: string): string;
30
+ export declare function changeToAlias(str?: string): string;
31
31
  export declare const offlinePaginate: (array: DataObject[], pageIndex: number, pageSize: number) => DataObject[];
32
32
  export declare function convertArrayToObject(array: any, keyName: string): any;
33
33
  export declare function roundDecimalNumber(number: any): string | null;
@@ -197,6 +197,7 @@ function calculatorDirectoryIdRoot(directoriesTree) {
197
197
  }
198
198
  exports.calculatorDirectoryIdRoot = calculatorDirectoryIdRoot;
199
199
  function changeToAlias(str) {
200
+ if (str === void 0) { str = ''; }
200
201
  // Chuyển toàn bộ Tiếng Việt sang không dấu viết thường và các kí tự đặc biệt thành dấu "-"
201
202
  return str
202
203
  .trim()
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "Common": {
3
+ "Existed": "{0} is already existed!",
3
4
  "lg": "en",
4
5
  "InvalidData": "Invalid data",
5
6
  "Required": "This field is required",
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "Common": {
3
+ "Existed": "{0} đã tồn tại!",
3
4
  "lg": "vn",
4
5
  "InvalidData": "Dữ liệu không hợp lệ",
5
6
  "Required": "Đây là trường bắt buộc",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.102-beta",
3
+ "version": "2.1.103-beta",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- declare const Events: React.FC<{
3
- templateId: string;
4
- }>;
5
- export default Events;
@@ -1,41 +0,0 @@
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 material_1 = require("@mui/material");
19
- var react_i18next_1 = require("react-i18next");
20
- var i18n_1 = __importDefault(require("../../../../i18n"));
21
- var recoil_1 = require("recoil");
22
- var Recoils_1 = require("../Recoils");
23
- var lodash_1 = require("lodash");
24
- // id?: number
25
- // templateId?: string
26
- // event?: string
27
- var Events = function (_a) {
28
- var templateId = _a.templateId;
29
- var t = (0, react_i18next_1.useTranslation)(undefined, { i18n: i18n_1.default }).t;
30
- var _b = (0, recoil_1.useRecoilState)(Recoils_1.templateEventState), events = _b[0], setEvent = _b[1];
31
- var renderTags = function (options, getTagProps, ownerState) {
32
- return options.map(function (option, i) {
33
- console.log("ownerState", ownerState, options);
34
- return ((0, jsx_runtime_1.jsx)(material_1.Chip, __assign({ label: option.text, title: option.text, size: "small" }, getTagProps({ index: i }))));
35
- });
36
- };
37
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { marginBottom: 2, children: (0, jsx_runtime_1.jsx)(material_1.Autocomplete, { fullWidth: true, multiple: true, autoComplete: true, options: [], onChange: function (reseaon, values) {
38
- setEvent((0, lodash_1.uniqBy)(values.map(function (value) { return typeof value === 'string' ? { id: 0, templateId: templateId, event: value } : value; }), 'event'));
39
- }, freeSolo: true, disableClearable: true, value: events, getOptionLabel: function (option) { return option === null || option === void 0 ? void 0 : option.event; }, isOptionEqualToValue: function (option, value) { return (option === null || option === void 0 ? void 0 : option.event) === (value === null || value === void 0 ? void 0 : value.event); }, renderInput: function (params) { return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ variant: 'standard' }, params, { placeholder: "".concat(t('Common.Events'), "..."), inputProps: __assign(__assign({}, params.inputProps), { autoComplete: 'off' }) }))); } }) }));
40
- };
41
- exports.default = Events;