@visns-studio/visns-components 4.7.0 → 4.7.2
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/104e5636d8ddb791614c.woff2 +0 -0
- package/dist/11fe6a83d647de5daf95.woff +0 -0
- package/dist/141e2a8c7836495afe2a.woff +0 -0
- package/dist/2ba5877f7079830b5383.woff +0 -0
- package/dist/2d6836f45b2037be41f3.woff +0 -0
- package/dist/399.0a0f3e0d21be1057d599.css +8 -0
- package/dist/399.b8f57fa3f8c0c10119e4.js +1 -0
- package/dist/47d566c3b1293dfd9d77.woff +0 -0
- package/dist/6282a13cbba671a71913.woff2 +0 -0
- package/dist/78266f551031aa9db127.woff +0 -0
- package/dist/7b7da89f1e3fdcbfe36c.woff2 +0 -0
- package/dist/7e78e8338af7efeda712.woff2 +0 -0
- package/dist/7fa387951673abf164b1.woff2 +0 -0
- package/dist/819d59862c2d0640aad8.woff +0 -0
- package/dist/b615e1a6c838ea059a56.woff +0 -0
- package/dist/b9b1aa739c660c4ce67c.woff2 +0 -0
- package/dist/c5f3640b11df9414facb.woff +0 -0
- package/dist/da26d162ff5af71d6590.woff2 +0 -0
- package/dist/dd5b2912dbf896310865.woff2 +0 -0
- package/dist/f282b331272463c1aa6c.woff2 +0 -0
- package/dist/index.css +2902 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +150 -0
- package/dist/main.83b033670d64419bb497.css +1 -0
- package/dist/main.b1723d17cd2d3513ab62.js +1 -0
- package/dist/report.html +39 -0
- package/dist/runtime.33c276593b23f8035b8d.js +1 -0
- package/package.json +26 -6
- package/.idea/codeStyles/Project.xml +0 -50
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/deployment.xml +0 -4
- package/.idea/modules.xml +0 -8
- package/.idea/php.xml +0 -19
- package/.idea/vcs.xml +0 -6
- package/.idea/visns-components.iml +0 -8
- package/.prettierrc.json +0 -7
- package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -541
- package/.yarn/releases/yarn-3.6.1.cjs +0 -874
- package/.yarnrc.yml +0 -7
- package/components/cms/DataGrid.jsx +0 -1461
- package/components/cms/DropZone.jsx +0 -349
- package/components/cms/Field.jsx +0 -802
- package/components/cms/Form.jsx +0 -476
- package/components/cms/generic/CmsDetail.jsx +0 -36
- package/components/cms/generic/CmsIndex.jsx +0 -73
- package/components/cms/generic/CmsSort.jsx +0 -125
- package/components/cms/sorting/Item.jsx +0 -115
- package/components/cms/sorting/List.jsx +0 -30
- package/components/crm/AsyncSelect.jsx +0 -125
- package/components/crm/Autocomplete.jsx +0 -174
- package/components/crm/Breadcrumb.jsx +0 -52
- package/components/crm/Call.jsx +0 -220
- package/components/crm/DataGrid.jsx +0 -2701
- package/components/crm/Download.jsx +0 -101
- package/components/crm/Fetch.jsx +0 -119
- package/components/crm/Field.jsx +0 -1557
- package/components/crm/Form.jsx +0 -1409
- package/components/crm/Loader.jsx +0 -29
- package/components/crm/MultiSelect.jsx +0 -78
- package/components/crm/Navigation.jsx +0 -619
- package/components/crm/Notification.jsx +0 -197
- package/components/crm/QrCode.jsx +0 -83
- package/components/crm/Select.jsx +0 -58
- package/components/crm/SelectList.jsx +0 -21
- package/components/crm/TableFilter.jsx +0 -198
- package/components/crm/auth/Login.jsx +0 -223
- package/components/crm/auth/Profile.jsx +0 -280
- package/components/crm/auth/Reset.jsx +0 -111
- package/components/crm/auth/Verify.jsx +0 -174
- package/components/crm/auth/styles/Login.module.css +0 -243
- package/components/crm/auth/styles/Profile.module.css +0 -222
- package/components/crm/auth/styles/Reset.module.css +0 -216
- package/components/crm/auth/styles/Verify.module.css +0 -216
- package/components/crm/generic/AuditLog.jsx +0 -108
- package/components/crm/generic/AuditLogs.jsx +0 -115
- package/components/crm/generic/GenericAuth.jsx +0 -166
- package/components/crm/generic/GenericDashboard.jsx +0 -42
- package/components/crm/generic/GenericDetail.jsx +0 -1499
- package/components/crm/generic/GenericDynamic.jsx +0 -915
- package/components/crm/generic/GenericFormBuilder.jsx +0 -1765
- package/components/crm/generic/GenericIndex.jsx +0 -376
- package/components/crm/generic/GenericMain.jsx +0 -129
- package/components/crm/generic/GenericSort.jsx +0 -188
- package/components/crm/generic/NotificationList.jsx +0 -64
- package/components/crm/generic/styles/AuditLog.module.css +0 -147
- package/components/crm/generic/styles/AuditLogs.module.css +0 -92
- package/components/crm/generic/styles/GenericDetail.module.css +0 -634
- package/components/crm/generic/styles/GenericDynamic.module.css +0 -932
- package/components/crm/generic/styles/GenericFormBuilder.module.css +0 -944
- package/components/crm/generic/styles/GenericIndex.module.css +0 -247
- package/components/crm/generic/styles/GenericMain.module.css +0 -91
- package/components/crm/generic/styles/GenericSort.module.css +0 -123
- package/components/crm/generic/styles/NotificationList.module.css +0 -67
- package/components/crm/sorting/Item.jsx +0 -117
- package/components/crm/sorting/List.jsx +0 -32
- package/components/crm/sorting/styles/Item.module.css +0 -68
- package/components/crm/sorting/styles/List.module.css +0 -68
- package/components/crm/styles/AsyncSelect.module.css +0 -8
- package/components/crm/styles/Autocomplete.module.css +0 -44
- package/components/crm/styles/DataGrid.module.css +0 -210
- package/components/crm/styles/Field.module.css +0 -311
- package/components/crm/styles/Form.module.css +0 -499
- package/components/crm/styles/Loader.module.css +0 -94
- package/components/crm/styles/MultiSelect.module.css +0 -8
- package/components/crm/styles/Navigation.module.css +0 -978
- package/components/crm/styles/Notification.module.css +0 -147
- package/components/crm/styles/QrCode.module.css +0 -87
- package/components/crm/styles/TableFilter.module.css +0 -52
- package/components/styles/global.css +0 -73
- package/index.js +0 -86
|
@@ -1,619 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
|
2
|
-
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
|
3
|
-
import {
|
|
4
|
-
ArrowCycle,
|
|
5
|
-
BookClose,
|
|
6
|
-
BookOpen,
|
|
7
|
-
Briefcase,
|
|
8
|
-
Bug,
|
|
9
|
-
Calendar,
|
|
10
|
-
ChatDots,
|
|
11
|
-
Clipboard,
|
|
12
|
-
DoubleSword,
|
|
13
|
-
Draft,
|
|
14
|
-
Envelope,
|
|
15
|
-
File,
|
|
16
|
-
Folder,
|
|
17
|
-
FolderAdd,
|
|
18
|
-
Gear,
|
|
19
|
-
Grid,
|
|
20
|
-
Home,
|
|
21
|
-
HomeAlt1,
|
|
22
|
-
Inbox,
|
|
23
|
-
Info,
|
|
24
|
-
LightBulb,
|
|
25
|
-
Microphone,
|
|
26
|
-
Money,
|
|
27
|
-
Newspaper,
|
|
28
|
-
Paper,
|
|
29
|
-
PeopleGroup,
|
|
30
|
-
PeopleMultiple,
|
|
31
|
-
Person,
|
|
32
|
-
Question,
|
|
33
|
-
QuestionFill,
|
|
34
|
-
Search,
|
|
35
|
-
SettingsVertical,
|
|
36
|
-
ShippingBoxV1,
|
|
37
|
-
SignOut,
|
|
38
|
-
Shield,
|
|
39
|
-
StatisticUp,
|
|
40
|
-
TextAlignLeft,
|
|
41
|
-
Ticket,
|
|
42
|
-
Utensils,
|
|
43
|
-
} from 'akar-icons';
|
|
44
|
-
import CustomFetch from './Fetch';
|
|
45
|
-
import Notification from './Notification';
|
|
46
|
-
import styles from './styles/Navigation.module.css';
|
|
47
|
-
|
|
48
|
-
const SearchComponent = ({
|
|
49
|
-
navigate,
|
|
50
|
-
search,
|
|
51
|
-
setSearch,
|
|
52
|
-
searchResultShow,
|
|
53
|
-
searchResult,
|
|
54
|
-
setSearchResultShow,
|
|
55
|
-
setSearchResult,
|
|
56
|
-
navConfig,
|
|
57
|
-
}) => {
|
|
58
|
-
const searchWrapperRef = useRef(null);
|
|
59
|
-
|
|
60
|
-
const handleClickSearch = (url) => {
|
|
61
|
-
if (url) {
|
|
62
|
-
setSearchResultShow(false);
|
|
63
|
-
navigate(url);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const handleKeyPress = (e) => {
|
|
68
|
-
if (e.key === 'Enter') {
|
|
69
|
-
fetchSearchResult();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const handleSearch = (e) => {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
fetchSearchResult();
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const handleSearchChange = (e) => {
|
|
79
|
-
setSearch(e.target.value);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const fetchSearchResult = useCallback(async () => {
|
|
83
|
-
try {
|
|
84
|
-
if (search.trim() === '') {
|
|
85
|
-
setSearchResultShow(false);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const res = await CustomFetch(navConfig.search.url, 'POST', {
|
|
90
|
-
search,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
if (res.data) {
|
|
94
|
-
const updatedSearchResult = searchResult.map((searchItem) => {
|
|
95
|
-
const newData = res.data[searchItem.id] || [];
|
|
96
|
-
return {
|
|
97
|
-
...searchItem,
|
|
98
|
-
data: newData,
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
setSearchResult(updatedSearchResult);
|
|
103
|
-
setSearchResultShow(true);
|
|
104
|
-
}
|
|
105
|
-
} catch (err) {
|
|
106
|
-
console.error(err);
|
|
107
|
-
}
|
|
108
|
-
}, [
|
|
109
|
-
search,
|
|
110
|
-
navConfig.search.url,
|
|
111
|
-
searchResult,
|
|
112
|
-
setSearchResult,
|
|
113
|
-
setSearchResultShow,
|
|
114
|
-
]);
|
|
115
|
-
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
const handleClickOutside = (event) => {
|
|
118
|
-
if (
|
|
119
|
-
searchWrapperRef.current &&
|
|
120
|
-
!searchWrapperRef.current.contains(event.target)
|
|
121
|
-
) {
|
|
122
|
-
setSearchResultShow(false);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
127
|
-
return () => {
|
|
128
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
129
|
-
};
|
|
130
|
-
}, [searchWrapperRef, setSearchResultShow]);
|
|
131
|
-
|
|
132
|
-
const getNestedValues = (obj, keys) => {
|
|
133
|
-
return keys
|
|
134
|
-
.map((key) => obj[key])
|
|
135
|
-
.filter((value) => value)
|
|
136
|
-
.join(' ');
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<div className={styles.globalsearch} ref={searchWrapperRef}>
|
|
141
|
-
<input
|
|
142
|
-
type="text"
|
|
143
|
-
placeholder="Search"
|
|
144
|
-
value={search}
|
|
145
|
-
onChange={handleSearchChange}
|
|
146
|
-
onKeyDown={handleKeyPress}
|
|
147
|
-
/>
|
|
148
|
-
{searchResultShow && (
|
|
149
|
-
<ul
|
|
150
|
-
className={styles['AutocompletePlace-results']}
|
|
151
|
-
style={{ marginTop: '40px' }}
|
|
152
|
-
>
|
|
153
|
-
{searchResult.length > 0 &&
|
|
154
|
-
searchResult.map(
|
|
155
|
-
(searchItem, searchItemKey) =>
|
|
156
|
-
searchItem.data.length > 0 && (
|
|
157
|
-
<React.Fragment
|
|
158
|
-
key={`search-category-${searchItem.id}-${searchItemKey}`}
|
|
159
|
-
>
|
|
160
|
-
<li
|
|
161
|
-
className={
|
|
162
|
-
styles[
|
|
163
|
-
'AutocompletePlace-items'
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
>
|
|
167
|
-
<strong>{searchItem.label}</strong>
|
|
168
|
-
</li>
|
|
169
|
-
<ul>
|
|
170
|
-
{searchItem.data.map((item) => (
|
|
171
|
-
<li
|
|
172
|
-
key={`${searchItemKey}-${item.id}`}
|
|
173
|
-
className={
|
|
174
|
-
styles[
|
|
175
|
-
'AutocompletePlace-items'
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
onClick={() => {
|
|
179
|
-
handleClickSearch(
|
|
180
|
-
`${searchItem.url}${item.id}`
|
|
181
|
-
);
|
|
182
|
-
}}
|
|
183
|
-
data-type={searchItem.id}
|
|
184
|
-
data-id={item.id}
|
|
185
|
-
>
|
|
186
|
-
{getNestedValues(
|
|
187
|
-
item,
|
|
188
|
-
searchItem.key
|
|
189
|
-
)}
|
|
190
|
-
</li>
|
|
191
|
-
))}
|
|
192
|
-
</ul>
|
|
193
|
-
</React.Fragment>
|
|
194
|
-
)
|
|
195
|
-
)}
|
|
196
|
-
</ul>
|
|
197
|
-
)}
|
|
198
|
-
<button onClick={handleSearch}>
|
|
199
|
-
<Search strokeWidth={2} size={36} />
|
|
200
|
-
</button>
|
|
201
|
-
</div>
|
|
202
|
-
);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
function Navigation({
|
|
206
|
-
children,
|
|
207
|
-
layout = 'full',
|
|
208
|
-
logo,
|
|
209
|
-
navConfig,
|
|
210
|
-
setSystemAuth,
|
|
211
|
-
themeType,
|
|
212
|
-
userProfile,
|
|
213
|
-
}) {
|
|
214
|
-
const [search, setSearch] = useState('');
|
|
215
|
-
const [searchResultShow, setSearchResultShow] = useState(false);
|
|
216
|
-
const [searchResult, setSearchResult] = useState(
|
|
217
|
-
navConfig.search?.tables || []
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
const location = useLocation();
|
|
221
|
-
const navigate = useNavigate();
|
|
222
|
-
const currentPage = location.pathname.substr(1) || 'dashboard';
|
|
223
|
-
const [isOpen, setOpen] = useState(false);
|
|
224
|
-
const [isScrolled, setIsScrolled] = useState(false);
|
|
225
|
-
const [navData, setNavData] = useState(navConfig);
|
|
226
|
-
|
|
227
|
-
const appNavClasses = styles['app-nav'];
|
|
228
|
-
|
|
229
|
-
const handleLogout = () => {
|
|
230
|
-
CustomFetch('/logout', 'GET', {}, () => {
|
|
231
|
-
setSystemAuth(false);
|
|
232
|
-
navigate('/login');
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
const renderSetting = (n) => {
|
|
237
|
-
const iconComponents = {
|
|
238
|
-
bug: Bug,
|
|
239
|
-
calendar: Calendar,
|
|
240
|
-
draft: Draft,
|
|
241
|
-
person: Person,
|
|
242
|
-
shield: Shield,
|
|
243
|
-
signOut: SignOut,
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
if (n.id === 'notifications') {
|
|
247
|
-
return (
|
|
248
|
-
<li>
|
|
249
|
-
<Notification setSystemAuth={setSystemAuth} />
|
|
250
|
-
</li>
|
|
251
|
-
);
|
|
252
|
-
} else if (n.id === 'logout') {
|
|
253
|
-
const IconComponent = iconComponents[n.icon];
|
|
254
|
-
return (
|
|
255
|
-
<li>
|
|
256
|
-
<button
|
|
257
|
-
title={n.label}
|
|
258
|
-
data-tooltip-id="system-tooltip"
|
|
259
|
-
data-tooltip-content={n.label}
|
|
260
|
-
onClick={handleLogout}
|
|
261
|
-
>
|
|
262
|
-
<IconComponent size={19} strokeWidth={2} />
|
|
263
|
-
</button>
|
|
264
|
-
</li>
|
|
265
|
-
);
|
|
266
|
-
} else {
|
|
267
|
-
const IconComponent = iconComponents[n.icon];
|
|
268
|
-
|
|
269
|
-
return (
|
|
270
|
-
<li>
|
|
271
|
-
<Link
|
|
272
|
-
to={n.url}
|
|
273
|
-
data-tooltip-id="system-tooltip"
|
|
274
|
-
data-tooltip-content={n.label}
|
|
275
|
-
className="tooltip"
|
|
276
|
-
target={n.target ? n.target : '_self'}
|
|
277
|
-
>
|
|
278
|
-
<IconComponent size={19} strokeWidth={2} />
|
|
279
|
-
</Link>
|
|
280
|
-
</li>
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
const renderNav = (n) => {
|
|
286
|
-
const iconComponents = {
|
|
287
|
-
arrowCycle: ArrowCycle,
|
|
288
|
-
bookClose: BookClose,
|
|
289
|
-
bookOpen: BookOpen,
|
|
290
|
-
briefcase: Briefcase,
|
|
291
|
-
calendar: Calendar,
|
|
292
|
-
chatDots: ChatDots,
|
|
293
|
-
clipboard: Clipboard,
|
|
294
|
-
doubleSword: DoubleSword,
|
|
295
|
-
draft: Draft,
|
|
296
|
-
envelope: Envelope,
|
|
297
|
-
file: File,
|
|
298
|
-
folder: Folder,
|
|
299
|
-
folderAdd: FolderAdd,
|
|
300
|
-
gear: Gear,
|
|
301
|
-
grid: Grid,
|
|
302
|
-
home: Home,
|
|
303
|
-
homeAlt1: HomeAlt1,
|
|
304
|
-
inbox: Inbox,
|
|
305
|
-
info: Info,
|
|
306
|
-
lightBulb: LightBulb,
|
|
307
|
-
microphone: Microphone,
|
|
308
|
-
money: Money,
|
|
309
|
-
newspaper: Newspaper,
|
|
310
|
-
paper: Paper,
|
|
311
|
-
peopleGroup: PeopleGroup,
|
|
312
|
-
peopleMultiple: PeopleMultiple,
|
|
313
|
-
question: Question,
|
|
314
|
-
questionFill: QuestionFill,
|
|
315
|
-
search: Search,
|
|
316
|
-
settingsVertical: SettingsVertical,
|
|
317
|
-
signOut: SignOut,
|
|
318
|
-
shippingBoxV1: ShippingBoxV1,
|
|
319
|
-
statisticUp: StatisticUp,
|
|
320
|
-
textAlignLeft: TextAlignLeft,
|
|
321
|
-
ticket: Ticket,
|
|
322
|
-
utensils: Utensils,
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
const IconComponent = iconComponents[n.icon];
|
|
326
|
-
|
|
327
|
-
let navItemClasses;
|
|
328
|
-
|
|
329
|
-
if (n.class.includes('active')) {
|
|
330
|
-
navItemClasses =
|
|
331
|
-
themeType === 'alternate'
|
|
332
|
-
? `${styles['nav-item-alternate']} ${styles.active}`
|
|
333
|
-
: `${styles['nav-item']} ${styles.active}`;
|
|
334
|
-
} else {
|
|
335
|
-
navItemClasses =
|
|
336
|
-
themeType === 'alternate'
|
|
337
|
-
? styles['nav-item-alternate']
|
|
338
|
-
: styles['nav-item'];
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
const renderChildren = () => {
|
|
342
|
-
if (n.children && n.children.length > 0) {
|
|
343
|
-
return (
|
|
344
|
-
<ul>
|
|
345
|
-
{n.children.map(
|
|
346
|
-
(child, childKey) =>
|
|
347
|
-
child.permission === true && (
|
|
348
|
-
<li key={`nav-child-${childKey}`}>
|
|
349
|
-
<Link
|
|
350
|
-
to={child.url}
|
|
351
|
-
title={child.label}
|
|
352
|
-
>
|
|
353
|
-
{child.label}
|
|
354
|
-
</Link>
|
|
355
|
-
</li>
|
|
356
|
-
)
|
|
357
|
-
)}
|
|
358
|
-
</ul>
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
return null;
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
return (
|
|
365
|
-
<li className={navItemClasses}>
|
|
366
|
-
{n.url ? (
|
|
367
|
-
<Link to={n.url}>
|
|
368
|
-
<IconComponent strokeWidth={2} size={18} />
|
|
369
|
-
{n.label}
|
|
370
|
-
</Link>
|
|
371
|
-
) : (
|
|
372
|
-
<span title={n.label}>
|
|
373
|
-
<IconComponent strokeWidth={2} size={18} />
|
|
374
|
-
{n.label}
|
|
375
|
-
</span>
|
|
376
|
-
)}
|
|
377
|
-
{renderChildren()}
|
|
378
|
-
</li>
|
|
379
|
-
);
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
const getFirstRolePermissions = () => {
|
|
383
|
-
if (
|
|
384
|
-
userProfile.roles &&
|
|
385
|
-
userProfile.roles.length > 0 &&
|
|
386
|
-
userProfile.roles[0].permissions.length > 0
|
|
387
|
-
) {
|
|
388
|
-
return userProfile.roles[0].permissions.map(
|
|
389
|
-
(permission) => permission.name
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
return [];
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
useEffect(() => {
|
|
396
|
-
const permissions = getFirstRolePermissions();
|
|
397
|
-
|
|
398
|
-
setNavData((prevNavData) => {
|
|
399
|
-
const updatePermissions = (nav) => {
|
|
400
|
-
if (nav.children && nav.children.length > 0) {
|
|
401
|
-
const updatedChildren = nav.children
|
|
402
|
-
.map(updatePermissions)
|
|
403
|
-
.filter(Boolean);
|
|
404
|
-
const childPermission = updatedChildren.length > 0;
|
|
405
|
-
|
|
406
|
-
if (nav.permissionKey) {
|
|
407
|
-
const matchingPermission = permissions.includes(
|
|
408
|
-
nav.permissionKey
|
|
409
|
-
);
|
|
410
|
-
return {
|
|
411
|
-
...nav,
|
|
412
|
-
permission: matchingPermission,
|
|
413
|
-
children: updatedChildren,
|
|
414
|
-
};
|
|
415
|
-
} else {
|
|
416
|
-
return {
|
|
417
|
-
...nav,
|
|
418
|
-
permission: childPermission,
|
|
419
|
-
children: updatedChildren,
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
if (nav.permissionKey) {
|
|
425
|
-
const matchingPermission = permissions.includes(
|
|
426
|
-
nav.permissionKey
|
|
427
|
-
);
|
|
428
|
-
return {
|
|
429
|
-
...nav,
|
|
430
|
-
permission: matchingPermission,
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return {
|
|
435
|
-
...nav,
|
|
436
|
-
permission: true,
|
|
437
|
-
};
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
const updatedNavigations = prevNavData.navigations
|
|
441
|
-
.map(updatePermissions)
|
|
442
|
-
.filter(Boolean);
|
|
443
|
-
const updatedSettings = prevNavData.settings
|
|
444
|
-
.map(updatePermissions)
|
|
445
|
-
.filter(Boolean);
|
|
446
|
-
|
|
447
|
-
return {
|
|
448
|
-
...prevNavData,
|
|
449
|
-
navigations: updatedNavigations,
|
|
450
|
-
settings: updatedSettings,
|
|
451
|
-
};
|
|
452
|
-
});
|
|
453
|
-
}, [userProfile]);
|
|
454
|
-
|
|
455
|
-
useEffect(() => {
|
|
456
|
-
setNavData((prevNavData) => {
|
|
457
|
-
const updateNavItems = (nav) => {
|
|
458
|
-
const cleanUrl = (url) =>
|
|
459
|
-
url && url.startsWith('/')
|
|
460
|
-
? url.substr(1).split('/')[0]
|
|
461
|
-
: url
|
|
462
|
-
? url.split('/')[0]
|
|
463
|
-
: '';
|
|
464
|
-
const currentUrl = cleanUrl(currentPage);
|
|
465
|
-
const navUrl = nav.url
|
|
466
|
-
? cleanUrl(nav.url)
|
|
467
|
-
? cleanUrl(nav.url)
|
|
468
|
-
: 'dashboard'
|
|
469
|
-
: '';
|
|
470
|
-
|
|
471
|
-
if (
|
|
472
|
-
navUrl === currentUrl ||
|
|
473
|
-
(nav.children &&
|
|
474
|
-
nav.children.some(
|
|
475
|
-
(child) => child.url === `/${currentPage}`
|
|
476
|
-
))
|
|
477
|
-
) {
|
|
478
|
-
return { ...nav, class: 'nav-item active' };
|
|
479
|
-
} else {
|
|
480
|
-
return { ...nav, class: 'nav-item' };
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
return {
|
|
485
|
-
...prevNavData,
|
|
486
|
-
navigations: prevNavData.navigations.map(updateNavItems),
|
|
487
|
-
};
|
|
488
|
-
});
|
|
489
|
-
}, [currentPage]);
|
|
490
|
-
|
|
491
|
-
useEffect(() => {
|
|
492
|
-
function handleScroll() {
|
|
493
|
-
setIsScrolled(window.scrollY > 0);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
window.addEventListener('scroll', handleScroll);
|
|
497
|
-
return () => {
|
|
498
|
-
window.removeEventListener('scroll', handleScroll);
|
|
499
|
-
};
|
|
500
|
-
}, []);
|
|
501
|
-
|
|
502
|
-
return layout === 'simple' || layout === 'cms' ? (
|
|
503
|
-
<div className={styles.cwrap}>
|
|
504
|
-
<aside
|
|
505
|
-
className={
|
|
506
|
-
isOpen
|
|
507
|
-
? `${styles['aside--cms']} ${styles['aside--cms--open']}`
|
|
508
|
-
: `${styles['aside--cms']}`
|
|
509
|
-
}
|
|
510
|
-
>
|
|
511
|
-
<div className={styles.logo}>
|
|
512
|
-
<Link to="/">
|
|
513
|
-
<img src={logo} alt="System Logo" />
|
|
514
|
-
</Link>
|
|
515
|
-
</div>
|
|
516
|
-
<div className={styles.awrap}>
|
|
517
|
-
<nav className={styles.navwrap}>
|
|
518
|
-
<ul className={appNavClasses}>
|
|
519
|
-
{navData.navigations.map((nav, navKey) =>
|
|
520
|
-
nav.permission === true ||
|
|
521
|
-
nav.permissionKey === '' ? (
|
|
522
|
-
<React.Fragment key={`nav-item-${navKey}`}>
|
|
523
|
-
{renderNav(nav)}
|
|
524
|
-
</React.Fragment>
|
|
525
|
-
) : null
|
|
526
|
-
)}
|
|
527
|
-
</ul>
|
|
528
|
-
</nav>
|
|
529
|
-
</div>
|
|
530
|
-
</aside>
|
|
531
|
-
<main className={styles.content}>
|
|
532
|
-
<div className={styles['content-header']}>
|
|
533
|
-
{navConfig.search?.enable === true && (
|
|
534
|
-
<SearchComponent
|
|
535
|
-
navigate={navigate}
|
|
536
|
-
search={search}
|
|
537
|
-
setSearch={setSearch}
|
|
538
|
-
searchResultShow={searchResultShow}
|
|
539
|
-
searchResult={searchResult}
|
|
540
|
-
setSearchResultShow={setSearchResultShow}
|
|
541
|
-
setSearchResult={setSearchResult}
|
|
542
|
-
navConfig={navConfig}
|
|
543
|
-
/>
|
|
544
|
-
)}
|
|
545
|
-
|
|
546
|
-
<div className={styles['content-title']}>
|
|
547
|
-
<button
|
|
548
|
-
className={
|
|
549
|
-
isOpen
|
|
550
|
-
? `${styles.mobmenu} ${styles['mobmenu--open']}`
|
|
551
|
-
: `${styles.mobmenu}`
|
|
552
|
-
}
|
|
553
|
-
onClick={() => setOpen(!isOpen)}
|
|
554
|
-
>
|
|
555
|
-
<span></span>
|
|
556
|
-
<span></span>
|
|
557
|
-
<span></span>
|
|
558
|
-
<span></span>
|
|
559
|
-
<span></span>
|
|
560
|
-
<span></span>
|
|
561
|
-
</button>
|
|
562
|
-
</div>
|
|
563
|
-
<div className={styles['hactions-alternate']}>
|
|
564
|
-
<ul>
|
|
565
|
-
{navData.settings.map((setting, settingKey) =>
|
|
566
|
-
setting.permission === true ? (
|
|
567
|
-
<React.Fragment
|
|
568
|
-
key={`setting-${settingKey}`}
|
|
569
|
-
>
|
|
570
|
-
{renderSetting(setting)}
|
|
571
|
-
</React.Fragment>
|
|
572
|
-
) : null
|
|
573
|
-
)}
|
|
574
|
-
</ul>
|
|
575
|
-
</div>
|
|
576
|
-
</div>
|
|
577
|
-
{children}
|
|
578
|
-
</main>
|
|
579
|
-
</div>
|
|
580
|
-
) : (
|
|
581
|
-
<div className={styles.hwrap}>
|
|
582
|
-
<div className={styles.logo}>
|
|
583
|
-
<Link to="/">
|
|
584
|
-
<img src={logo} alt="System Logo" />
|
|
585
|
-
</Link>
|
|
586
|
-
</div>
|
|
587
|
-
<div className={styles.navwrap}>
|
|
588
|
-
<ul className={appNavClasses}>
|
|
589
|
-
{navData.navigations.map((nav, navKey) =>
|
|
590
|
-
nav.permission === true || nav.permissionKey === '' ? (
|
|
591
|
-
<React.Fragment key={`nav-item-${navKey}`}>
|
|
592
|
-
{renderNav(nav)}
|
|
593
|
-
</React.Fragment>
|
|
594
|
-
) : null
|
|
595
|
-
)}
|
|
596
|
-
</ul>
|
|
597
|
-
</div>
|
|
598
|
-
<div
|
|
599
|
-
className={
|
|
600
|
-
themeType === 'alternate'
|
|
601
|
-
? styles['hactions-alternate']
|
|
602
|
-
: styles.hactions
|
|
603
|
-
}
|
|
604
|
-
>
|
|
605
|
-
<ul>
|
|
606
|
-
{navData.settings.map((setting, settingKey) =>
|
|
607
|
-
setting.permission === true ? (
|
|
608
|
-
<React.Fragment key={`setting-${settingKey}`}>
|
|
609
|
-
{renderSetting(setting)}
|
|
610
|
-
</React.Fragment>
|
|
611
|
-
) : null
|
|
612
|
-
)}
|
|
613
|
-
</ul>
|
|
614
|
-
</div>
|
|
615
|
-
</div>
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
export default Navigation;
|