awing-library 2.1.2-dev.540 → 2.1.2-dev.541
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/dist/AWING/DataForm/container.test.js +3 -3
- package/dist/AWING/DataForm2/containerOptimized.test.js +2 -2
- package/dist/Features/SYSTEM/Group/SearchUser/component.d.ts +2 -0
- package/dist/Features/SYSTEM/Group/SearchUser/component.d.ts.map +1 -1
- package/dist/Features/SYSTEM/Group/SearchUser/component.js +15 -14
- package/dist/Features/SYSTEM/Group/SearchUser/container.d.ts.map +1 -1
- package/dist/Features/SYSTEM/Group/SearchUser/container.js +34 -10
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { fireEvent, render, screen } from "@testing-library/react";
|
|
|
6
6
|
import { Constants } from "../../Commons/Constant.js";
|
|
7
7
|
import container from "./container.js";
|
|
8
8
|
var __webpack_modules__ = {
|
|
9
|
-
"
|
|
9
|
+
"../DataInput": function(module) {
|
|
10
10
|
module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
|
|
11
11
|
},
|
|
12
12
|
"../helper": function(module) {
|
|
@@ -23,7 +23,7 @@ function __webpack_require__(moduleId) {
|
|
|
23
23
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
24
|
return module.exports;
|
|
25
25
|
}
|
|
26
|
-
var index_js_ = __webpack_require__("
|
|
26
|
+
var index_js_ = __webpack_require__("../DataInput");
|
|
27
27
|
jest.mock('../DataInput', ()=>({
|
|
28
28
|
__esModule: true,
|
|
29
29
|
default: jest.fn(),
|
|
@@ -91,7 +91,7 @@ jest.mock('@mui/material', ()=>({
|
|
|
91
91
|
children: children
|
|
92
92
|
})
|
|
93
93
|
}));
|
|
94
|
-
const mockInputFactory = __webpack_require__("
|
|
94
|
+
const mockInputFactory = __webpack_require__("../DataInput")["default"];
|
|
95
95
|
const mockCalculateValue = __webpack_require__("../helper").calculateValue;
|
|
96
96
|
const mockConvertFormulaToBinaryTree = __webpack_require__("../helper").convertFormulaToBinaryTree;
|
|
97
97
|
const mockReplaceFieldsValue = __webpack_require__("../helper").replaceFieldsValue;
|
|
@@ -5,7 +5,7 @@ import { act, fireEvent, render, screen, waitFor } from "@testing-library/react"
|
|
|
5
5
|
import containerOptimized from "./containerOptimized.js";
|
|
6
6
|
import { createFormStateManager } from "./formStateManager.js";
|
|
7
7
|
var __webpack_modules__ = {
|
|
8
|
-
"
|
|
8
|
+
"../DataInput": function(module) {
|
|
9
9
|
module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
|
|
10
10
|
}
|
|
11
11
|
};
|
|
@@ -98,7 +98,7 @@ jest.mock('@mui/material', ()=>({
|
|
|
98
98
|
children: children
|
|
99
99
|
})
|
|
100
100
|
}));
|
|
101
|
-
const mockInputFactory = __webpack_require__("
|
|
101
|
+
const mockInputFactory = __webpack_require__("../DataInput")["default"];
|
|
102
102
|
describe('DataForm Optimized - Performance Tests', ()=>{
|
|
103
103
|
let inputRenderCounts = {};
|
|
104
104
|
const mockFields = [
|
|
@@ -3,6 +3,8 @@ interface SearchUserGroupUserProps {
|
|
|
3
3
|
listUserId: number[];
|
|
4
4
|
onListUserIdChange: (listUserId: number[]) => void;
|
|
5
5
|
users: User[];
|
|
6
|
+
onSearch?: (searchString: string) => void;
|
|
7
|
+
loading?: boolean;
|
|
6
8
|
}
|
|
7
9
|
declare function SearchUserGroupUser(props: SearchUserGroupUserProps): import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export default SearchUserGroupUser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Group/SearchUser/component.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,UAAU,wBAAwB;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACnD,KAAK,EAAE,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Group/SearchUser/component.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,UAAU,wBAAwB;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACnD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,iBAAS,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CAwE3D;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -2,18 +2,11 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { filter, some } from "lodash";
|
|
4
4
|
import { Checkbox, FormControlLabel, Paper } from "@mui/material";
|
|
5
|
-
import { NoData, SearchBox } from "../../../../AWING/index.js";
|
|
5
|
+
import { CircularProgress, NoData, SearchBox } from "../../../../AWING/index.js";
|
|
6
6
|
import Grid from "@mui/material/Grid";
|
|
7
7
|
function SearchUserGroupUser(props) {
|
|
8
|
-
const { listUserId, onListUserIdChange, users } = props;
|
|
9
|
-
const [usersSearchResult, setUsersSearchResult] = useState([]);
|
|
8
|
+
const { listUserId, onListUserIdChange, users, onSearch, loading } = props;
|
|
10
9
|
const [keyWordSearch, setKeyWordSearch] = useState('');
|
|
11
|
-
const handleFilterByFieldName = (list, newSearchString)=>{
|
|
12
|
-
let result = [];
|
|
13
|
-
if ('' === newSearchString) return [];
|
|
14
|
-
result = list?.filter((item)=>item.username === newSearchString) || [];
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
10
|
const handleChangeUserList = (userId, e)=>{
|
|
18
11
|
let newUserIds = listUserId.slice();
|
|
19
12
|
if (e.target.checked) onListUserIdChange([
|
|
@@ -27,13 +20,14 @@ function SearchUserGroupUser(props) {
|
|
|
27
20
|
};
|
|
28
21
|
const handleSearch = (searchString)=>{
|
|
29
22
|
setKeyWordSearch(searchString);
|
|
30
|
-
|
|
31
|
-
setUsersSearchResult(newUsersSearchResult);
|
|
23
|
+
if (onSearch) onSearch(searchString);
|
|
32
24
|
};
|
|
33
25
|
return /*#__PURE__*/ jsxs(Paper, {
|
|
34
26
|
sx: (theme)=>({
|
|
35
27
|
padding: (theme)=>theme.spacing(3),
|
|
36
|
-
border: theme.palette.background.paper
|
|
28
|
+
border: theme.palette.background.paper,
|
|
29
|
+
minHeight: '200px',
|
|
30
|
+
position: 'relative'
|
|
37
31
|
}),
|
|
38
32
|
children: [
|
|
39
33
|
/*#__PURE__*/ jsx(SearchBox, {
|
|
@@ -45,12 +39,19 @@ function SearchUserGroupUser(props) {
|
|
|
45
39
|
handleSearch(searchString);
|
|
46
40
|
}
|
|
47
41
|
}),
|
|
48
|
-
|
|
42
|
+
loading ? /*#__PURE__*/ jsx(Grid, {
|
|
43
|
+
container: true,
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
sx: {
|
|
46
|
+
mt: 3
|
|
47
|
+
},
|
|
48
|
+
children: /*#__PURE__*/ jsx(CircularProgress, {})
|
|
49
|
+
}) : users && users?.length > 0 ? /*#__PURE__*/ jsx(Grid, {
|
|
49
50
|
container: true,
|
|
50
51
|
sx: {
|
|
51
52
|
mt: 3
|
|
52
53
|
},
|
|
53
|
-
children:
|
|
54
|
+
children: users?.map((user, key)=>/*#__PURE__*/ jsx(Grid, {
|
|
54
55
|
size: {
|
|
55
56
|
xs: 12,
|
|
56
57
|
sm: 6,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Group/SearchUser/container.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Group/SearchUser/container.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAQlD,UAAU,YAAY;IAClB,aAAa,EAAE,IAAI,EAAE,CAAC;IACtB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;CAC7C;AAED,QAAA,MAAM,OAAO,UAAW,YAAY,4CA+GnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import lodash from "lodash";
|
|
4
2
|
import Grid from "@mui/material/Grid";
|
|
3
|
+
import lodash from "lodash";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
5
|
import { useTranslation } from "react-i18next";
|
|
6
|
-
import component from "./component.js";
|
|
7
6
|
import { ClassicDrawer } from "../../../../Commons/index.js";
|
|
8
|
-
import { CircularProgress } from "../../../../AWING/index.js";
|
|
9
7
|
import { useContextGroup } from "../context.js";
|
|
8
|
+
import component from "./component.js";
|
|
10
9
|
const AddUser = (props)=>{
|
|
11
10
|
const { t } = useTranslation();
|
|
12
11
|
const { usersSelected, onChangeAddUser = ()=>null } = props;
|
|
13
12
|
const [listUserId, setListUserId] = useState([]);
|
|
14
13
|
const [usersData, setUsersData] = useState([]);
|
|
15
14
|
const [loading, setLoading] = useState(false);
|
|
15
|
+
const usersCache = useRef({});
|
|
16
16
|
const { services } = useContextGroup();
|
|
17
17
|
useEffect(()=>{
|
|
18
18
|
setListUserId(usersSelected.length > 0 ? usersSelected.map((item)=>item.id).filter((id)=>void 0 !== id) : []);
|
|
19
|
+
usersSelected.forEach((user)=>{
|
|
20
|
+
if (void 0 !== user.id) usersCache.current[user.id] = user;
|
|
21
|
+
});
|
|
19
22
|
}, [
|
|
20
23
|
usersSelected
|
|
21
24
|
]);
|
|
@@ -26,7 +29,7 @@ const AddUser = (props)=>{
|
|
|
26
29
|
const newUserIds = lodash.differenceWith(userIds, usersSelected, (a, b)=>a === b.id);
|
|
27
30
|
const newUsers = [
|
|
28
31
|
...newUserIds.map((userId)=>{
|
|
29
|
-
const user =
|
|
32
|
+
const user = usersCache.current[userId];
|
|
30
33
|
return {
|
|
31
34
|
id: userId,
|
|
32
35
|
username: user?.username ?? '',
|
|
@@ -36,14 +39,33 @@ const AddUser = (props)=>{
|
|
|
36
39
|
];
|
|
37
40
|
onChangeAddUser(newUsers);
|
|
38
41
|
};
|
|
39
|
-
|
|
42
|
+
const fetchUsers = (searchString)=>{
|
|
40
43
|
if (services?.getUsers) {
|
|
41
44
|
setLoading(true);
|
|
42
|
-
services.getUsers(
|
|
45
|
+
services.getUsers({
|
|
46
|
+
where: {
|
|
47
|
+
username: {
|
|
48
|
+
eq: searchString
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}).then((data)=>{
|
|
43
52
|
setUsersData(data.users);
|
|
53
|
+
data.users.forEach((user)=>{
|
|
54
|
+
if (void 0 !== user.id) usersCache.current[user.id] = user;
|
|
55
|
+
});
|
|
44
56
|
}).finally(()=>setLoading(false));
|
|
45
57
|
}
|
|
46
|
-
}
|
|
58
|
+
};
|
|
59
|
+
const debouncedFetchUsers = useRef(lodash.debounce((query)=>{
|
|
60
|
+
fetchUsers(query);
|
|
61
|
+
}, 500)).current;
|
|
62
|
+
const handleSearch = (val)=>{
|
|
63
|
+
if ('' !== val) debouncedFetchUsers(val);
|
|
64
|
+
else {
|
|
65
|
+
debouncedFetchUsers.cancel();
|
|
66
|
+
setUsersData([]);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
47
69
|
return /*#__PURE__*/ jsx(ClassicDrawer, {
|
|
48
70
|
title: t('UserGroup.TitleAdd'),
|
|
49
71
|
onSubmit: ()=>new Promise((resolve, _reject)=>{
|
|
@@ -58,10 +80,12 @@ const AddUser = (props)=>{
|
|
|
58
80
|
pl: 1,
|
|
59
81
|
pr: 1
|
|
60
82
|
},
|
|
61
|
-
children:
|
|
83
|
+
children: /*#__PURE__*/ jsx(component, {
|
|
62
84
|
users: usersData?.filter((x)=>null !== x).filter((x)=>!usersSelected?.map((y)=>y.id).includes(x.id)) ?? [],
|
|
63
85
|
listUserId: listUserId,
|
|
64
|
-
onListUserIdChange: handleListUserIdChange
|
|
86
|
+
onListUserIdChange: handleListUserIdChange,
|
|
87
|
+
onSearch: handleSearch,
|
|
88
|
+
loading: loading
|
|
65
89
|
})
|
|
66
90
|
})
|
|
67
91
|
});
|