awing-library 2.1.104-beta → 2.1.105-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.
@@ -87,9 +87,15 @@ var NotificationDetail = function (props) {
87
87
  };
88
88
  }, []);
89
89
  (0, react_1.useEffect)(function () {
90
+ console.log({
91
+ count: count,
92
+ totalItemCount: totalItemCount,
93
+ notificationMessage: notificationMessage
94
+ });
90
95
  if (count >= 0 &&
91
96
  (totalItemCount.current > notificationMessage.length ||
92
97
  notificationMessage.length === 0)) {
98
+ console.log("run");
93
99
  setIsLoading(true);
94
100
  service
95
101
  .notificationsPaging(count, Constant_1.Constants.PAGE_SIZE_DEFAULT, valueFilter.textSearch, valueFilter.status, [])
@@ -73,16 +73,16 @@ var Recoil_1 = require("../Recoil");
73
73
  var Utils_1 = require("../Utils");
74
74
  var Styles_1 = require("./Styles");
75
75
  var ViewContent = function (_a) {
76
- var _b, _c, _d;
76
+ var _b, _c, _d, _e;
77
77
  var viewInfoData = _a.viewInfoData, pageId = _a.pageId, viewNumber = _a.viewNumber, onChange = _a.onChange, isCreate = _a.isCreate;
78
- var _e = (0, Context_2.default)(), service = _e.service, pageCode = _e.pageCode, domainId = _e.domainId, CONFIGS = _e.configs;
78
+ var _f = (0, Context_2.default)(), service = _f.service, pageCode = _f.pageCode, domainId = _f.domainId, CONFIGS = _f.configs;
79
79
  var appHelper = (0, Context_1.useAwing)().appHelper;
80
- var _f = react_1.default.useState(''), scriptValidationTemplate = _f[0], setScriptValidationTemplate = _f[1];
81
- var _g = react_1.default.useState(''), scriptAutoField = _g[0], setScriptAutoField = _g[1];
82
- var _h = react_1.default.useState(false), loading = _h[0], setLoading = _h[1];
80
+ var _g = react_1.default.useState(''), scriptValidationTemplate = _g[0], setScriptValidationTemplate = _g[1];
81
+ var _h = react_1.default.useState(''), scriptAutoField = _h[0], setScriptAutoField = _h[1];
82
+ var _j = react_1.default.useState(false), loading = _j[0], setLoading = _j[1];
83
83
  var isUniq = react_1.default.useRef(false);
84
84
  var rootDirectory = (0, recoil_1.useRecoilValue)(Recoil_1.pageRootDeirectory);
85
- var _j = (0, recoil_1.useRecoilState)(Recoil_1.pageEventState), events = _j[0], setEvent = _j[1];
85
+ var _k = (0, recoil_1.useRecoilState)(Recoil_1.pageEventState), events = _k[0], setEvent = _k[1];
86
86
  react_1.default.useEffect(function () {
87
87
  if (viewInfoData === null || viewInfoData === void 0 ? void 0 : viewInfoData.templateId) {
88
88
  setLoading(true);
@@ -174,9 +174,9 @@ var ViewContent = function (_a) {
174
174
  ? CONFIGS.FILE_TEMP_PATH
175
175
  : CONFIGS.FILE_STATIC_PATH, "/").concat(pageCode === enums_1.PageCode.Lgn
176
176
  ? 'lgn'
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,
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: (_e = viewInfoData.viewDatas) === null || _e === void 0 ? void 0 : _e.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,
178
178
  // validStatus={validStatus}
179
- validStatus: viewInfoData.validStatus, viewEvents: events.filter(function (item) { return item.viewNumber === viewNumber + 1; }), onChange: handleOnChange, onChangeViewValid: function (status) {
179
+ validStatus: viewInfoData.validStatus, viewEvents: events === null || events === void 0 ? void 0 : events.filter(function (item) { return item.viewNumber === viewNumber + 1; }), onChange: handleOnChange, onChangeViewValid: function (status) {
180
180
  onChange(['isValidationFields'], [status]);
181
181
  }, onChangeValidateProcess: function (processValue) {
182
182
  onChange(['validProcessStatus'], processValue);
@@ -1,15 +1,38 @@
1
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
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  var jsx_runtime_1 = require("react/jsx-runtime");
7
- var react_1 = require("react");
30
+ var react_1 = __importStar(require("react"));
8
31
  var styles_1 = require("@mui/styles");
9
32
  var material_1 = require("@mui/material");
10
33
  var Refresh_1 = __importDefault(require("@mui/icons-material/Refresh"));
11
34
  var react_i18next_1 = require("react-i18next");
12
- var debounce = require("lodash/debounce");
35
+ var lodash_1 = require("lodash");
13
36
  var useStyles = (0, styles_1.makeStyles)(function () { return ({
14
37
  root: {
15
38
  width: "100%",
@@ -20,52 +43,43 @@ var Preview = function (props) {
20
43
  var _a;
21
44
  var classes = useStyles();
22
45
  var t = (0, react_i18next_1.useTranslation)().t;
23
- var validStatus = props.validStatus, pagePath = props.pagePath, templateDatas = props.templateDatas, domainId = props.domainId, configs = props.configs, onChangeField = props.onChangeField;
46
+ var validStatus = props.validStatus, pagePath = props.pagePath, templateDatas = props.templateDatas,
47
+ // domainId,
48
+ configs = props.configs;
24
49
  var viewIndex = ((_a = templateDatas[0]) === null || _a === void 0 ? void 0 : _a.viewNumber) || -1;
50
+ var formRef = react_1.default.useRef(null);
25
51
  var iframeSrc = (0, react_1.useMemo)(function () {
26
- var result = "".concat(configs.CAPTIVE_DOMAIN, "/").concat(configs.TEMPLATE_PREVIEW, "?domainId=").concat(domainId);
52
+ var result = "".concat(configs.CAPTIVE_DOMAIN, "/").concat(configs.TEMPLATE_PREVIEW);
27
53
  if (result.startsWith("http://"))
28
54
  result = result.replace("http://", "https://");
29
55
  return result;
30
- }, [configs.CAPTIVE_DOMAIN, configs.TEMPLATE_PREVIEW, domainId]);
31
- var templatePagePath = (0, react_1.useMemo)(function () {
32
- var result = pagePath;
33
- if (pagePath.startsWith("/")) {
34
- result = result.slice(1);
35
- }
36
- return result;
37
- }, [pagePath]);
38
- var handleLoadContent = (0, react_1.useMemo)(function () {
39
- return debounce(function (tempDatas, tempPagePath, status) {
40
- var _a;
41
- if (!status)
42
- return;
43
- var iframe = document.getElementById("iframe-demo-".concat(viewIndex));
44
- var mess = JSON.stringify({
45
- pagePath: tempPagePath,
46
- templateDatas: tempDatas,
47
- });
48
- (_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(mess, "*");
49
- }, 2000);
50
- },
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
- [onChangeField]);
56
+ }, [configs.CAPTIVE_DOMAIN, configs.TEMPLATE_PREVIEW]);
53
57
  (0, react_1.useEffect)(function () {
54
- handleLoadContent(templateDatas, templatePagePath, validStatus);
55
- }, [
56
- onChangeField,
57
- handleLoadContent,
58
- validStatus,
59
- templateDatas,
60
- templatePagePath,
61
- ]);
62
- var handleRefresh = function () {
63
- var iframe = document.getElementById("iframe-demo-".concat(viewIndex));
64
- if (iframe) {
65
- iframe.src = iframeSrc;
58
+ var handleFormdata = function (_a) {
59
+ var formData = _a.formData;
60
+ formData.append('pagePath', pagePath);
61
+ templateDatas.forEach(function (templateData, index) {
62
+ Object.keys(templateData).forEach(function (key) {
63
+ formData.append("templateDatas[".concat(index, "][").concat(key, "]"), templateData[key]);
64
+ });
65
+ });
66
+ };
67
+ if (formRef.current) {
68
+ formRef.current.addEventListener('formdata', handleFormdata);
69
+ handleSubmit();
66
70
  }
67
- handleLoadContent(templateDatas, templatePagePath, validStatus);
68
- };
71
+ return function () {
72
+ if (formRef.current)
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ formRef.current.removeEventListener('formdata', handleFormdata);
75
+ };
76
+ // eslint-disable-next-line react-hooks/exhaustive-deps
77
+ }, [viewIndex, templateDatas, pagePath]);
78
+ // eslint-disable-next-line react-hooks/exhaustive-deps
79
+ var handleSubmit = react_1.default.useCallback((0, lodash_1.debounce)(function () {
80
+ if (formRef.current)
81
+ formRef.current.submit();
82
+ }, 2000), []);
69
83
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { style: {
70
84
  display: "flex",
71
85
  alignItems: "center",
@@ -73,8 +87,6 @@ var Preview = function (props) {
73
87
  }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", style: {
74
88
  fontWeight: "bold",
75
89
  textTransform: "uppercase",
76
- }, children: t("ViewTemplate.PreviewTitle") }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t("Common.Refresh") || "", placement: "top", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: handleRefresh, "aria-label": "refresh", style: { float: "right" }, disabled: !validStatus, children: (0, jsx_runtime_1.jsx)(Refresh_1.default, {}) }) }) })] }), (0, jsx_runtime_1.jsx)("iframe", { title: "iframe-demo-".concat(viewIndex), id: "iframe-demo-".concat(viewIndex), className: classes.root, src: iframeSrc,
77
- // src={"https://httpbin.org/post"}
78
- width: "100%" })] }));
90
+ }, children: t("ViewTemplate.PreviewTitle") }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t("Common.Refresh") || "", placement: "top", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: function () { return formRef.current.submit(); }, "aria-label": "refresh", style: { float: "right" }, disabled: !validStatus, children: (0, jsx_runtime_1.jsx)(Refresh_1.default, {}) }) }) })] }), (0, jsx_runtime_1.jsx)("form", { action: iframeSrc, method: "post", target: "iframe-demo", ref: formRef }), (0, jsx_runtime_1.jsx)("iframe", { title: "iframe-demo-".concat(viewIndex), id: "iframe-demo", name: "iframe-demo", className: classes.root, width: "100%" })] }));
79
91
  };
80
92
  exports.default = Preview;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.104-beta",
3
+ "version": "2.1.105-beta",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",