awing-library 2.1.13-beta → 2.1.15-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,6 +1,7 @@
1
- import { CampaignModel, Directory, CampaignGroupModel } from '../Types';
1
+ import { CampaignModel, Directory, CampaignGroupModel, Attribute } from '../Types';
2
2
  import { WeightContainerProps } from './TabSubCampaign/Weight';
3
3
  export declare const directoriesState: import("recoil").RecoilState<Directory[]>;
4
+ export declare const attributesState: import("recoil").RecoilState<Attribute[]>;
4
5
  export declare const isCreateState: import("recoil").RecoilState<boolean>;
5
6
  /**
6
7
  * Đánh dấu việc cần xác nhận lại trước khi đóng (set thành true khi có bất kỳ chỉnh sửa campaign nào)
@@ -17,6 +18,7 @@ export declare const campaignState: import("recoil").RecoilState<import("../Type
17
18
  /**
18
19
  * State lưu thông tin của CampaignAttributes
19
20
  */
21
+ export declare const campaignAttributesState: import("recoil").RecoilState<import("../Types").CampaignAttribute[]>;
20
22
  /**
21
23
  * State lưu thông tin của chiến dịch con
22
24
  */
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.weightState = exports.readyForSubmitState = exports.tabPartnerValidState = exports.tabSubCampaignValidState = exports.tabInfomationValidState = exports.campaignPartnerState = exports.campaignGroupsState = exports.campaignState = exports.campaignModelState = exports.confirmExitState = exports.isCreateState = exports.directoriesState = void 0;
14
+ exports.weightState = exports.readyForSubmitState = exports.tabPartnerValidState = exports.tabSubCampaignValidState = exports.tabInfomationValidState = exports.campaignPartnerState = exports.campaignGroupsState = exports.campaignAttributesState = exports.campaignState = exports.campaignModelState = exports.confirmExitState = exports.isCreateState = exports.attributesState = exports.directoriesState = void 0;
15
15
  var recoil_1 = require("recoil");
16
16
  var Types_1 = require("../Types");
17
17
  var Utils_1 = require("../Utils");
@@ -20,6 +20,10 @@ exports.directoriesState = (0, recoil_1.atom)({
20
20
  key: 'DirectoriesCampaignState',
21
21
  default: [],
22
22
  });
23
+ exports.attributesState = (0, recoil_1.atom)({
24
+ key: 'attributesState',
25
+ default: [],
26
+ });
23
27
  exports.isCreateState = (0, recoil_1.atom)({
24
28
  key: 'isCreateState',
25
29
  default: false,
@@ -82,25 +86,22 @@ exports.campaignState = (0, recoil_1.selector)({
82
86
  /**
83
87
  * State lưu thông tin của CampaignAttributes
84
88
  */
85
- // export const campaignAttributesState = selector({
86
- // key: 'campaignAttributes',
87
- // get: ({get}) => {
88
- // const campaignModel = get(campaignModelState);
89
- // return campaignModel.campaignAttributes;
90
- // },
91
- // set: ({set, get}, newAttributes) => {
92
- // const campaignModel = get(campaignModelState);
93
- // set(campaignModelState,
94
- // newAttributes instanceof DefaultValue ?
95
- // newAttributes :
96
- // {
97
- // ...campaignModel,
98
- // campaignAttributes: newAttributes
99
- // });
100
- // if (!get(confirmExitState))
101
- // set(confirmExitState, true);
102
- // }
103
- // })
89
+ exports.campaignAttributesState = (0, recoil_1.selector)({
90
+ key: 'campaignAttributes',
91
+ get: function (_a) {
92
+ var get = _a.get;
93
+ var campaignModel = get(exports.campaignModelState);
94
+ return campaignModel.campaignAttributes;
95
+ },
96
+ set: function (_a, campaignAttributes) {
97
+ var set = _a.set, get = _a.get;
98
+ var campaignModel = get(exports.campaignModelState);
99
+ set(exports.campaignModelState, campaignAttributes instanceof recoil_1.DefaultValue ?
100
+ campaignAttributes : __assign(__assign({}, campaignModel), { campaignAttributes: campaignAttributes }));
101
+ if (!get(exports.confirmExitState))
102
+ set(exports.confirmExitState, true);
103
+ }
104
+ });
104
105
  /**
105
106
  * State lưu thông tin của chiến dịch con
106
107
  */
@@ -151,7 +152,7 @@ exports.tabInfomationValidState = (0, recoil_1.atom)({
151
152
  get: function (_a) {
152
153
  var get = _a.get;
153
154
  var campaignModel = get(exports.campaignModelState);
154
- return (0, Utils_1.tabInfomationValid)(campaignModel.campaign, campaignModel.campaignAttributes.length ? campaignModel.campaignAttributes.length : [""]);
155
+ return (0, Utils_1.tabInfomationValid)(campaignModel.campaign, campaignModel.campaignAttributes);
155
156
  },
156
157
  }),
157
158
  });
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  declare const Infomation: React.FC;
3
3
  export default Infomation;
@@ -10,6 +10,29 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
13
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
38
  };
@@ -18,14 +41,18 @@ var jsx_runtime_1 = require("react/jsx-runtime");
18
41
  var material_1 = require("@mui/material");
19
42
  var immer_1 = __importDefault(require("immer"));
20
43
  var lodash_1 = require("lodash");
21
- var react_1 = require("react");
44
+ var react_1 = __importStar(require("react"));
22
45
  var react_i18next_1 = require("react-i18next");
23
46
  var recoil_1 = require("recoil");
24
47
  var AWING_1 = require("../../../AWING");
25
48
  var Recoils_1 = require("./Recoils");
49
+ var Hooks_1 = __importDefault(require("../Hooks"));
26
50
  var Infomation = function () {
51
+ var service = (0, Hooks_1.default)().service;
27
52
  var directories = (0, recoil_1.useRecoilValue)(Recoils_1.directoriesState);
53
+ var attributes = (0, recoil_1.useRecoilValue)(Recoils_1.attributesState);
28
54
  var _a = (0, recoil_1.useRecoilState)(Recoils_1.campaignState), campaign = _a[0], setCampaign = _a[1];
55
+ var _b = (0, recoil_1.useRecoilState)(Recoils_1.campaignAttributesState), campaignAttributes = _b[0], setCampaignAttributes = _b[1];
29
56
  var setCampaignModel = (0, recoil_1.useSetRecoilState)(Recoils_1.campaignModelState);
30
57
  var t = (0, react_i18next_1.useTranslation)().t;
31
58
  (0, react_1.useEffect)(function () {
@@ -37,36 +64,64 @@ var Infomation = function () {
37
64
  }
38
65
  // eslint-disable-next-line react-hooks/exhaustive-deps
39
66
  }, [directories]);
40
- var handleUpdate = (0, react_1.useCallback)(function (obj, formValid) {
41
- if (!(0, lodash_1.isEmpty)(obj)) {
42
- setCampaign(function (prev) { return (__assign(__assign({}, prev), obj)); });
67
+ (0, react_1.useEffect)(function () {
68
+ if (!service.attributesGetByObjectTypeCode) {
69
+ setCampaignAttributes([""]);
70
+ }
71
+ // eslint-disable-next-line react-hooks/exhaustive-deps
72
+ }, [service]);
73
+ var handleUpdate = (0, react_1.useCallback)(function (obj, formValid, fieldUpdate) {
74
+ if (fieldUpdate) {
75
+ if (fieldUpdate === 'attributeIds') {
76
+ setCampaignAttributes(obj['attributeIds'].map(function (item) { return ({ attributeId: item }); }));
77
+ }
78
+ else {
79
+ setCampaign(function (prev) { return (__assign(__assign({}, prev), obj)); });
80
+ }
43
81
  }
44
82
  // eslint-disable-next-line react-hooks/exhaustive-deps
45
83
  }, []);
84
+ var fieldDefine = react_1.default.useMemo(function () {
85
+ var fields = [
86
+ {
87
+ fieldName: 'directoryId',
88
+ type: 'select',
89
+ label: t('Common.Directory'),
90
+ required: true,
91
+ options: directories.map(function (directory) { return ({
92
+ value: directory.directoryId,
93
+ text: directory.name,
94
+ level: directory.level,
95
+ }); }),
96
+ },
97
+ {
98
+ length: 200,
99
+ fieldName: 'name',
100
+ type: 'text',
101
+ label: t('Campaign.Name'),
102
+ required: true,
103
+ },
104
+ ];
105
+ if (attributes.length) {
106
+ fields.push({
107
+ fieldName: 'attributeIds',
108
+ type: 'autocomplete',
109
+ multiple: true,
110
+ label: t('Campaign.Attributes'),
111
+ required: true,
112
+ options: attributes.map(function (attribute) { return ({
113
+ value: attribute.id,
114
+ text: attribute.name,
115
+ }); }),
116
+ });
117
+ }
118
+ return fields;
119
+ }, [attributes, directories, t]);
46
120
  return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
47
121
  '&>div': {
48
122
  padding: 0,
49
123
  boxShadow: 'none',
50
124
  },
51
- }, children: (0, jsx_runtime_1.jsx)(AWING_1.DataForm, { fields: [
52
- {
53
- fieldName: 'directoryId',
54
- type: 'select',
55
- label: t('Common.Directory'),
56
- required: true,
57
- options: directories.map(function (directory) { return ({
58
- value: directory.directoryId,
59
- text: directory.name,
60
- level: directory.level,
61
- }); }),
62
- },
63
- {
64
- length: 200,
65
- fieldName: 'name',
66
- type: 'text',
67
- label: t('Campaign.Name'),
68
- required: true,
69
- },
70
- ], checkAllRequiredFields: !(campaign.directoryId && campaign.name), oldValue: campaign, onUpdate: handleUpdate }) }));
125
+ }, children: (0, jsx_runtime_1.jsx)(AWING_1.DataForm, { fields: fieldDefine, checkAllRequiredFields: !(campaign.directoryId && campaign.name), oldValue: __assign(__assign({}, campaign), { attributeIds: campaignAttributes.map(function (item) { return item.attributeId; }) }), onUpdate: handleUpdate }) }));
71
126
  };
72
127
  exports.default = Infomation;
@@ -1,4 +1,15 @@
1
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
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
@@ -46,6 +57,7 @@ var CreateOrEdit = function () {
46
57
  var _d = (0, recoil_1.useRecoilState)(Recoils_1.campaignModelState), campaignData = _d[0], setCampaignData = _d[1];
47
58
  var setCampaignPages = (0, recoil_1.useSetRecoilState)(atoms_1.campaignPageIdState);
48
59
  var setDirectories = (0, recoil_1.useSetRecoilState)(Recoils_1.directoriesState);
60
+ var setAttributes = (0, recoil_1.useSetRecoilState)(Recoils_1.attributesState);
49
61
  var confirmExit = (0, recoil_1.useRecoilValue)(Recoils_1.confirmExitState);
50
62
  var readyForSubmit = (0, recoil_1.useRecoilValue)(Recoils_1.readyForSubmitState);
51
63
  var setCreate = (0, recoil_1.useSetRecoilState)(Recoils_1.isCreateState);
@@ -78,7 +90,10 @@ var CreateOrEdit = function () {
78
90
  service
79
91
  .directoriesGetByObjectTypeCode(Enum_1.DirectoryRoot.Campaign)
80
92
  .then(setDirectories);
81
- }, [service, setDirectories]);
93
+ if (service.attributesGetByObjectTypeCode) {
94
+ service.attributesGetByObjectTypeCode(Enum_1.DirectoryRoot.Campaign).then(setAttributes);
95
+ }
96
+ }, [service, setDirectories, setAttributes]);
82
97
  (0, react_1.useLayoutEffect)(function () {
83
98
  if (tabName && route.includes(tabName)) {
84
99
  setValue(String(route.indexOf(tabName)));
@@ -179,11 +194,12 @@ var CreateOrEdit = function () {
179
194
  .flatMap(function (x) { return x.ads; }))) {
180
195
  return Promise.reject(t('Campaign.CClassDuplicatePlace'));
181
196
  }
197
+ var dataSubmit = __assign(__assign({}, campaignData), { campaignAttributes: campaignData.campaignAttributes.filter(Boolean) });
182
198
  if (componentStatus === Constant_1.Constants.CAMPAIGN_DETAIL) {
183
- return service.campaignsPut(campaignId, campaignData);
199
+ return service.campaignsPut(campaignId, dataSubmit);
184
200
  }
185
201
  else {
186
- return service.campaignsPost(campaignData);
202
+ return service.campaignsPost(dataSubmit);
187
203
  }
188
204
  };
189
205
  return ((0, jsx_runtime_1.jsx)(ClassicDrawer_1.default, { title: "".concat(t(['Campaign', campaignId ? 'TitleDetail' : 'Create'].join('.'))).concat(campaignId ? ": ".concat((_a = campaignData === null || campaignData === void 0 ? void 0 : campaignData.campaign) === null || _a === void 0 ? void 0 : _a.name) : '', "\n "), onSubmit: handleSubmit, disableButtonSubmit: !readyForSubmit, confirmExit: confirmExit, childrenWrapperStyle: { padding: 0 }, children: (0, jsx_runtime_1.jsx)(material_1.Grid, { container: true, sx: {
@@ -331,6 +331,14 @@ export interface AnalyticDataProviderModel {
331
331
  click: number;
332
332
  ctr: number;
333
333
  }
334
+ export interface Attribute {
335
+ id: number;
336
+ name: string;
337
+ objectTypeCode: string;
338
+ description: string;
339
+ createdDate: Timestamp;
340
+ attributeTypeId: number;
341
+ }
334
342
  export interface AppHelper {
335
343
  alert: (message: string, title?: string) => void;
336
344
  snackbar: (severity?: AlertColor, message?: string, autoHideDuration?: number) => void;
@@ -354,6 +362,7 @@ interface CampaignService extends PrmissionService {
354
362
  statisticCampaignGetEvents: (body: AnalyticEventModel) => Promise<AnalyticEvent[]>;
355
363
  statisticCampaignGet: (startDate?: string, endDate?: string, timelineType?: TIMELINE_TYPE, body?: Record<string, any>) => Promise<AnalyticDataProviderModel[]>;
356
364
  statisticCampaignGetAnalyticCampaign: (timelineType?: TIMELINE_TYPE, startDate?: string, endDate?: string, body?: Record<string, any>) => Promise<AnalyticCampaignSummary[]>;
365
+ attributesGetByObjectTypeCode?: (objectTypeCode: string) => Promise<Attribute[]>;
357
366
  }
358
367
  export interface CampaignFeatureProps {
359
368
  service: CampaignService & PageService;
@@ -361,6 +370,7 @@ export interface CampaignFeatureProps {
361
370
  tabStatistic: (p?: any) => JSX.Element;
362
371
  domainId: string;
363
372
  configs: any;
373
+ isAxn?: boolean;
364
374
  }
365
375
  export interface AnalyticCampaignSummary {
366
376
  campaignId: string;
@@ -112,7 +112,7 @@ function nameValid(value) {
112
112
  }
113
113
  exports.nameValid = nameValid;
114
114
  function attributesValid(value) {
115
- return value.length > 0;
115
+ return Array.isArray(value) && value.length > 0;
116
116
  }
117
117
  exports.attributesValid = attributesValid;
118
118
  function tabInfomationValid(campaign, campaignAttributes) {
@@ -0,0 +1,2 @@
1
+ declare const index: () => import("react/jsx-runtime").JSX.Element;
2
+ export default index;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var jsx_runtime_1 = require("react/jsx-runtime");
4
+ var index = function () {
5
+ return ((0, jsx_runtime_1.jsx)("div", { children: "index" }));
6
+ };
7
+ exports.default = index;
@@ -37,13 +37,21 @@ var PageContainer = function () {
37
37
  var navigate = (0, react_router_1.useNavigate)();
38
38
  var location = (0, react_router_1.useLocation)();
39
39
  var _d = (0, react_1.useState)(false), loading = _d[0], setLoading = _d[1];
40
- var _e = (0, react_1.useState)([]), directories = _e[0], setDirectories = _e[1];
41
- var _f = (0, react_1.useState)(true), tempLoading = _f[0], setTempLoading = _f[1];
40
+ var _e = (0, react_1.useState)(true), init = _e[0], setInit = _e[1]; // First time render
41
+ var _f = (0, react_1.useState)([]), directories = _f[0], setDirectories = _f[1];
42
+ var _g = (0, react_1.useState)(true), isLoadDirectory = _g[0], setLoadLoadDirectory = _g[1];
43
+ var _h = (0, react_1.useState)(true), tempLoading = _h[0], setTempLoading = _h[1];
44
+ var _j = (0, react_1.useState)(), anchorEl = _j[0], setAnchorEl = _j[1];
45
+ var open = Boolean(anchorEl);
46
+ var handlePreviewPage = function (e) {
47
+ e.stopPropagation();
48
+ setAnchorEl(e.currentTarget);
49
+ };
42
50
  var prevQuery = (0, react_1.useRef)({});
43
- var _g = (0, react_1.useState)({
51
+ var _k = (0, react_1.useState)({
44
52
  items: [],
45
53
  totalItemCount: 0,
46
- }), pageList = _g[0], setPage = _g[1];
54
+ }), pageList = _k[0], setPage = _k[1];
47
55
  var columnDefinitions = (0, react_1.useMemo)(function () { return [
48
56
  {
49
57
  field: 'stt',
@@ -57,12 +65,16 @@ var PageContainer = function () {
57
65
  return params.at(-1);
58
66
  },
59
67
  },
60
- { field: 'pageId', headerName: 'Id', TableCellProps: {
68
+ {
69
+ field: 'pageId',
70
+ headerName: 'Id',
71
+ TableCellProps: {
61
72
  sx: {
62
73
  minWidth: '180px',
63
74
  width: '20%',
64
75
  },
65
- } },
76
+ },
77
+ },
66
78
  {
67
79
  field: 'title',
68
80
  headerName: t('Page.Name'),
@@ -73,10 +85,16 @@ var PageContainer = function () {
73
85
  valueGetter: function (row) {
74
86
  return (0, Helpers_1.timestampToStringDDMMYYYY)(row.createdDate);
75
87
  },
88
+ TableCellProps: {
89
+ sx: {
90
+ width: '250px',
91
+ },
92
+ },
76
93
  },
77
94
  ]; }, [t]);
78
95
  (0, react_1.useLayoutEffect)(function () {
79
96
  setDirectories([]);
97
+ setInit(true);
80
98
  setPage({
81
99
  items: [],
82
100
  totalItemCount: 0,
@@ -91,19 +109,21 @@ var PageContainer = function () {
91
109
  }, [pageCode]);
92
110
  (0, react_1.useEffect)(function () {
93
111
  var _a;
94
- if (((_a = location.state) === null || _a === void 0 ? void 0 : _a.action) === ClassicDrawer_1.CloseAction.ReloadDirectory || !directories.length) {
112
+ if (((_a = location.state) === null || _a === void 0 ? void 0 : _a.action) === ClassicDrawer_1.CloseAction.ReloadDirectory || init) {
95
113
  fetchDirectories();
114
+ setInit(false);
96
115
  }
97
116
  // eslint-disable-next-line react-hooks/exhaustive-deps
98
- }, [location.pathname, directories]);
117
+ }, [location.pathname, init]);
99
118
  var fetchDirectories = function () {
119
+ setLoadLoadDirectory(true);
100
120
  service
101
121
  .directoriesGetByObjectTypeCode(Enum_1.DirectoryRoot[pageCode === enums_1.PageCode.Lgn ? 'PageLogin' : 'PageWelcome'])
102
- .then(function (res) {
103
- var _a;
104
- setDirectories(res);
105
- getPagePaging(prevQuery.current, (_a = (0, lodash_1.minBy)(res, 'level')) === null || _a === void 0 ? void 0 : _a.directoryId);
106
- }).finally(function () { return navigate(location.pathname, { replace: true }); });
122
+ .then(setDirectories)
123
+ .finally(function () {
124
+ // navigate(location.pathname, { replace: true })
125
+ setLoadLoadDirectory(false);
126
+ });
107
127
  };
108
128
  var handleRowClick = function (id) {
109
129
  navigate([Constant_1.pageConstants.EDIT_PAGE, id].join('/'));
@@ -123,7 +143,6 @@ var PageContainer = function () {
123
143
  }, 100), []);
124
144
  var getPagePaging = (0, react_1.useCallback)(function (input, directoryId) {
125
145
  var _a;
126
- console.log("call");
127
146
  var searchString = input.searchString, pageSize = input.pageSize, pageIndex = input.pageIndex, advancedObject = input.advancedObject;
128
147
  handleFetchPaging(searchString, pageSize, pageIndex, directoryId ||
129
148
  (advancedObject === null || advancedObject === void 0 ? void 0 : advancedObject.directoryId) ||
@@ -139,7 +158,11 @@ var PageContainer = function () {
139
158
  (0, Helpers_1.downloadZipFile)(res, "Page_".concat(pageCode === enums_1.PageCode.Lgn ? 'lgn' : 'wlc', "_"));
140
159
  });
141
160
  };
142
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: tempLoading ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(AWING_1.PageManagement, { title: t([
161
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
162
+ '& th:last-of-type': {
163
+ width: '250px!important',
164
+ },
165
+ }, children: tempLoading || isLoadDirectory ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(AWING_1.PageManagement, { title: t([
143
166
  'Page',
144
167
  pageCode === enums_1.PageCode.Lgn
145
168
  ? 'LoginTitle'
@@ -164,8 +187,28 @@ var PageContainer = function () {
164
187
  }, rowActions: [
165
188
  {
166
189
  icon: (0, jsx_runtime_1.jsx)(icons_material_1.Visibility, {}),
190
+ // icon: (() => {
191
+ // return (
192
+ // <Typography
193
+ // component={'p'}
194
+ // // onClick={(e) => handlePreview(e)}
195
+ // title={t('Campaign.Preview')}
196
+ // >
197
+ // <VisibilityOutlined fontSize="small" />
198
+ // <span
199
+ // aria-label="more"
200
+ // aria-controls="long-menu"
201
+ // aria-haspopup="true"
202
+ // onClick={handlePreviewPage}
203
+ // >
204
+ // <ArrowDropDown fontSize="small" />
205
+ // </span>
206
+ // </Typography>
207
+ // )
208
+ // })(),
167
209
  tooltipTitle: t('Common.Preview'),
168
210
  action: handlePreview,
211
+ // action: () => {},
169
212
  sx: {
170
213
  display: pageCode === enums_1.PageCode.Wlc
171
214
  ? 'none'
@@ -1,6 +1,7 @@
1
1
  import { Directory } from '../../Campaign/Types';
2
2
  import { FormValid, PageModel } from '../Types';
3
3
  export declare const pageDirectoriesState: import("recoil").RecoilState<Directory[]>;
4
+ export declare const wiewMounted: import("recoil").RecoilState<boolean>;
4
5
  export declare const pageRootDeirectory: import("recoil").RecoilState<string>;
5
6
  export declare const pageChangedFormState: import("recoil").RecoilState<Record<keyof PageModel, boolean>>;
6
7
  export declare const pageRootState: import("recoil").RecoilState<PageModel>;
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.pageState = exports.validForm = exports.pageRootState = exports.pageChangedFormState = exports.pageRootDeirectory = exports.pageDirectoriesState = void 0;
14
+ exports.pageState = exports.validForm = exports.pageRootState = exports.pageChangedFormState = exports.pageRootDeirectory = exports.wiewMounted = exports.pageDirectoriesState = void 0;
15
15
  var lodash_1 = require("lodash");
16
16
  var recoil_1 = require("recoil");
17
17
  var Constant_1 = require("../Constant");
@@ -21,6 +21,10 @@ exports.pageDirectoriesState = (0, recoil_1.atom)({
21
21
  key: 'pageDirectoriesState',
22
22
  default: [],
23
23
  });
24
+ exports.wiewMounted = (0, recoil_1.atom)({
25
+ key: 'wiewMounted',
26
+ default: false,
27
+ });
24
28
  exports.pageRootDeirectory = (0, recoil_1.atom)({
25
29
  key: 'pageRootDeirectory',
26
30
  default: (0, recoil_1.selector)({
@@ -75,7 +75,7 @@ var ViewContent = function (_a) {
75
75
  onChange(['viewDatas'], []);
76
76
  }
77
77
  // eslint-disable-next-line react-hooks/exhaustive-deps
78
- }, [service, viewInfoData.templateId, viewInfoData.viewDatas.length]);
78
+ }, [viewInfoData.templateId, viewInfoData.viewDatas.length]);
79
79
  var handleResData = function (res) {
80
80
  onChange(['viewDatas'], (0, Utils_1.getTemplateDatas)(res.templateParameters, viewInfoData, pageId, viewNumber));
81
81
  onChange(['templateValidation'], res.template.validation);
@@ -47,6 +47,8 @@ var enums_1 = require("../../enums");
47
47
  var Utils_1 = require("../Utils");
48
48
  var Constant_1 = require("../../../../ACM-AXN/Page/Constant");
49
49
  var react_router_dom_1 = require("react-router-dom");
50
+ var recoil_1 = require("recoil");
51
+ var Recoil_1 = require("../Recoil");
50
52
  var ViewInfo = function (_a) {
51
53
  var directories = _a.directories, templateTypes = _a.templateTypes, onChange = _a.onChange, viewInfoData = _a.viewInfoData;
52
54
  var pageId = (0, react_router_dom_1.useParams)().pageId;
@@ -54,20 +56,24 @@ var ViewInfo = function (_a) {
54
56
  var cacheDirectoryId = react_1.default.useRef('');
55
57
  var _b = react_1.default.useState([]), templates = _b[0], setTemplates = _b[1];
56
58
  var _c = react_1.default.useState(false), loadingTemplate = _c[0], setLoadingTemplate = _c[1];
57
- var _d = (0, Context_1.default)(), service = _d.service, pageCode = _d.pageCode;
59
+ var _d = (0, recoil_1.useRecoilState)(Recoil_1.wiewMounted), isMounted = _d[0], setIsMounted = _d[1];
60
+ var _e = (0, Context_1.default)(), service = _e.service, pageCode = _e.pageCode, domainId = _e.domainId;
58
61
  var t = (0, react_i18next_1.useTranslation)().t;
59
62
  (0, react_1.useEffect)(function () {
60
- var savedDirectoryId = localStorage.getItem(Constant_1.PAGE_LOGIN_DIRECTORY_SELECTED);
61
- if (savedDirectoryId && !pageId) {
63
+ var savedDirectoryId = JSON.parse(localStorage.getItem(Constant_1.PAGE_LOGIN_DIRECTORY_SELECTED) || '{]')[Array.isArray(domainId) ? 'awingPge' : domainId];
64
+ if (savedDirectoryId && !pageId && !isMounted) {
65
+ setIsMounted(true);
62
66
  handleChangeForm({ directoryId: savedDirectoryId }, true, 'directoryId');
63
67
  }
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
69
  }, []);
65
70
  var handleChangeForm = react_1.default.useCallback(function (obj, _valid, keyUpdate) {
71
+ var _a;
66
72
  if ((0, lodash_1.isEmpty)(obj))
67
73
  return;
68
74
  if (['templateTypeId', 'directoryId'].includes(keyUpdate)) {
69
75
  if (keyUpdate === 'directoryId') {
70
- localStorage.setItem(Constant_1.PAGE_LOGIN_DIRECTORY_SELECTED, obj[keyUpdate]);
76
+ localStorage.setItem(Constant_1.PAGE_LOGIN_DIRECTORY_SELECTED, JSON.stringify((_a = {}, _a[Array.isArray(domainId) ? 'awingPge' : domainId] = obj[keyUpdate], _a)));
71
77
  }
72
78
  onChange(['templateId'], null);
73
79
  }
@@ -59,7 +59,7 @@ var setObject = function (obj, arrKey, value) {
59
59
  exports.setObject = setObject;
60
60
  var convertTreeArrayToFlatArray = function (treeArray) {
61
61
  var result = [];
62
- treeArray.forEach(function (data) {
62
+ treeArray === null || treeArray === void 0 ? void 0 : treeArray.forEach(function (data) {
63
63
  getChilds(data, function (item) { return result.push(item); });
64
64
  });
65
65
  return result;
@@ -0,0 +1,9 @@
1
+ interface Props {
2
+ pageId: string;
3
+ open: boolean;
4
+ anchorEl: any;
5
+ onPreviewClose: (event: any) => void;
6
+ onPreviewDomain: (event: any, domainId: string) => void;
7
+ }
8
+ declare const PagePreview: (props: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export default PagePreview;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ var jsx_runtime_1 = require("react/jsx-runtime");
27
+ var react_1 = __importStar(require("react"));
28
+ var react_i18next_1 = require("react-i18next");
29
+ var styles_1 = require("@mui/styles");
30
+ var material_1 = require("@mui/material");
31
+ var icons_material_1 = require("@mui/icons-material");
32
+ var Context_1 = require("../../../Context");
33
+ var useStyles = (0, styles_1.makeStyles)(function () {
34
+ var _a, _b;
35
+ var theme = (0, material_1.useTheme)();
36
+ return {
37
+ circularProgress: {
38
+ width: "10px !important",
39
+ height: "10px !important",
40
+ margin: "0px auto",
41
+ },
42
+ drawer: {
43
+ width: theme.spacing(60),
44
+ },
45
+ search: (_a = {
46
+ position: "relative",
47
+ borderRadius: theme.shape.borderRadius,
48
+ backgroundColor: "rgba(255, 255, 255, 0.15)",
49
+ "&:hover": {
50
+ backgroundColor: "rgba(255, 255, 255, 0.25)",
51
+ },
52
+ marginRight: theme.spacing(2),
53
+ marginLeft: 0,
54
+ width: "100%"
55
+ },
56
+ _a[theme.breakpoints.up("sm")] = {
57
+ marginLeft: theme.spacing(3),
58
+ width: "auto",
59
+ },
60
+ _a),
61
+ searchIcon: {
62
+ padding: theme.spacing(0, 2),
63
+ height: "100%",
64
+ position: "absolute",
65
+ pointerEvents: "none",
66
+ display: "flex",
67
+ alignItems: "center",
68
+ justifyContent: "center",
69
+ },
70
+ inputRoot: {
71
+ color: "inherit",
72
+ },
73
+ inputInput: (_b = {
74
+ padding: theme.spacing(1, 1, 1, 0),
75
+ // vertical padding + font size from searchIcon
76
+ paddingLeft: "calc(1em + ".concat(theme.spacing(4), "px)"),
77
+ transition: theme.transitions.create("width"),
78
+ width: "100%"
79
+ },
80
+ _b[theme.breakpoints.up("md")] = {
81
+ width: "20ch",
82
+ },
83
+ _b),
84
+ };
85
+ });
86
+ var PagePreview = function (props) {
87
+ var pageId = props.pageId, open = props.open, anchorEl = props.anchorEl, onPreviewClose = props.onPreviewClose, onPreviewDomain = props.onPreviewDomain;
88
+ var appHelper = (0, Context_1.useAwing)().appHelper;
89
+ var t = (0, react_i18next_1.useTranslation)().t;
90
+ var _a = (0, react_1.useState)(false), loadingFlags = _a[0], setLoadingFlags = _a[1];
91
+ var classes = useStyles();
92
+ var _b = react_1.default.useState(false), openDrawer = _b[0], setOpenDrawer = _b[1];
93
+ var toggleDrawer = function (open) { return function (event) {
94
+ event.stopPropagation();
95
+ if (event.type === "keydown" &&
96
+ (event.key === "Tab" || event.key === "Shift")) {
97
+ return;
98
+ }
99
+ setOpenDrawer(open);
100
+ }; };
101
+ var _c = react_1.default.useState(""), searchDomainString = _c[0], setSearchDomainString = _c[1];
102
+ var _d = react_1.default.useState([]), allDomains = _d[0], setAllDomains = _d[1];
103
+ (0, react_1.useEffect)(function () {
104
+ setLoadingFlags(true);
105
+ }, []);
106
+ (0, react_1.useEffect)(function () {
107
+ // if (pageId && open === true) {
108
+ // DomainService.getAllDomain()
109
+ // .then((res) => {
110
+ // if (res.data.status === STATUS_CODE.OK) {
111
+ // setAllDomains(res.data.data);
112
+ // setLoadingFlags(false);
113
+ // }
114
+ // })
115
+ // .catch((err) => Snackbar(SNACKBAR_TYPES.ERROR));
116
+ // }
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
118
+ }, []);
119
+ var translationText = {
120
+ searchPlaceholder: t("Common.SearchPlaceholder"),
121
+ copyToClipboard: t("Common.Preview"),
122
+ other: t("Common.Other"),
123
+ };
124
+ return ((0, jsx_runtime_1.jsxs)(material_1.Menu, { id: "domain-menu", anchorEl: anchorEl, keepMounted: true, open: open, onClose: onPreviewClose, PaperProps: {
125
+ style: {
126
+ maxHeight: 48 * 4.5,
127
+ width: "25ch",
128
+ },
129
+ }, children: [loadingFlags ? ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { className: classes.circularProgress, color: "primary" }) })) : (allDomains &&
130
+ allDomains.slice(0, 5).map(function (domain) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { onClick: function (event) {
131
+ onPreviewClose(event);
132
+ onPreviewDomain(event, domain.domainId);
133
+ }, children: domain.name }, domain.domainId)); })), !loadingFlags && ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { onClick: toggleDrawer(true), children: translationText.other })), (0, jsx_runtime_1.jsx)(material_1.Drawer, { anchor: "right", open: openDrawer, onClose: toggleDrawer(false), onClick: function (e) { return e.stopPropagation(); }, children: allDomains.length === 0 ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { className: classes.circularProgress, color: "primary" })) : ((0, jsx_runtime_1.jsxs)(material_1.List, { className: classes.drawer, children: [(0, jsx_runtime_1.jsx)(material_1.ListItem, { component: "div", children: (0, jsx_runtime_1.jsxs)("div", { className: classes.search, children: [(0, jsx_runtime_1.jsx)("div", { className: classes.searchIcon, children: (0, jsx_runtime_1.jsx)(icons_material_1.Search, {}) }), (0, jsx_runtime_1.jsx)(material_1.InputBase, { placeholder: translationText.searchPlaceholder, classes: {
134
+ root: classes.inputRoot,
135
+ input: classes.inputInput,
136
+ }, inputProps: { "aria-label": "search" }, onChange: function (e) { return setSearchDomainString(e.target.value); } })] }) }), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), allDomains &&
137
+ allDomains
138
+ .filter(function (d) {
139
+ return d.name
140
+ .toLowerCase()
141
+ .includes(searchDomainString.toLowerCase());
142
+ })
143
+ .sort(function (a, b) {
144
+ return a.name !== b.name ? (a.name < b.name ? -1 : 1) : 0;
145
+ })
146
+ .map(function (domain) { return ((0, jsx_runtime_1.jsxs)(material_1.ListItem, { button: true, onClick: function (e) { return onPreviewDomain(e, domain.domainId); }, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: domain.name }), (0, jsx_runtime_1.jsx)(material_1.ListItemSecondaryAction, { children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: translationText.copyToClipboard, placement: "left", arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { edge: "end", children: (0, jsx_runtime_1.jsx)(icons_material_1.VisibilityOutlined, { fontSize: "small" }) }) }) })] }, domain.domainId)); })] })) })] }));
147
+ };
148
+ exports.default = PagePreview;
@@ -19,7 +19,7 @@ export declare function logicExpressionValid(value: string | null | undefined):
19
19
  * @param str - The text string to be validated.
20
20
  * @param length - The maximum length of the text string. Default is 50.
21
21
  * @param required - validField required.
22
- * @param pattern - The regular expression pattern to match against the text string. Default is /^[a-zA-Z0-9\/\-_()\[\] ]+$/g.
22
+ * @param pattern - The regular expression pattern to match against the text string. Default is /^[a-zA-Z0-9\/\-_.()\[\] ]+$/g.
23
23
  * @param invertRegex - The inverted regular expression pattern to match against the text string. Default is undefined.
24
24
  * @returns An object containing the validation result and a message describing any validation errors.
25
25
  */
@@ -89,14 +89,14 @@ exports.logicExpressionValid = logicExpressionValid;
89
89
  * @param str - The text string to be validated.
90
90
  * @param length - The maximum length of the text string. Default is 50.
91
91
  * @param required - validField required.
92
- * @param pattern - The regular expression pattern to match against the text string. Default is /^[a-zA-Z0-9\/\-_()\[\] ]+$/g.
92
+ * @param pattern - The regular expression pattern to match against the text string. Default is /^[a-zA-Z0-9\/\-_.()\[\] ]+$/g.
93
93
  * @param invertRegex - The inverted regular expression pattern to match against the text string. Default is undefined.
94
94
  * @returns An object containing the validation result and a message describing any validation errors.
95
95
  */
96
96
  var textValidation = function (str, length, required, pattern, invertRegex) {
97
97
  if (length === void 0) { length = 50; }
98
98
  if (required === void 0) { required = true; }
99
- if (pattern === void 0) { pattern = /^[a-zA-Z0-9\/\-_()\[\] ]+$/g; }
99
+ if (pattern === void 0) { pattern = /^[a-zA-Z0-9\/\-_.()\[\] ]+$/g; }
100
100
  var validRes = {
101
101
  valid: true,
102
102
  message: [],
@@ -113,7 +113,7 @@ var textValidation = function (str, length, required, pattern, invertRegex) {
113
113
  .replace(/[\u0300-\u036f]/g, '')
114
114
  .replace(/đ/g, 'd')
115
115
  .trim();
116
- var invertedRegex = invertRegex || new RegExp("[^".concat(pattern.source.replace(/[.*+?^${}|]/g, ''), "]").replace(/\[\[|\]\]/g, ']'), 'g');
116
+ var invertedRegex = invertRegex || new RegExp("[^".concat(pattern.source.replace(/[*+?^${}|]/g, ''), "]").replace(/\[\[|\]\]/g, ']'), 'g');
117
117
  if (textTransform && pattern && !pattern.test(textTransform)) {
118
118
  validRes.valid = false;
119
119
  validRes.message.push("".concat(i18n_1.default.t('Common.InvalidChars'), ": ").concat(Array.from(new Set(textTransform.match(invertedRegex))).join(' ')));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.13-beta",
3
+ "version": "2.1.15-beta",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",