ui-soxo-bootstrap-core 2.4.25-dev.8 → 2.4.25
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/.github/workflows/npm-publish.yml +15 -37
- package/core/components/extra-info/extra-info-details.js +126 -109
- package/core/components/landing-api/landing-api.js +30 -22
- package/core/lib/Store.js +18 -20
- package/core/lib/components/index.js +1 -4
- package/core/lib/components/sidemenu/sidemenu.js +256 -153
- package/core/lib/components/sidemenu/sidemenu.scss +26 -39
- package/core/lib/hooks/index.js +12 -2
- package/core/lib/pages/login/login.js +139 -255
- package/core/lib/pages/login/login.scss +32 -140
- package/core/models/dashboard/dashboard.js +0 -14
- package/core/models/menus/components/menu-add/menu-add.js +268 -230
- package/core/models/menus/components/menu-lists/menu-lists.js +89 -126
- package/core/models/menus/components/menu-lists/menu-lists.scss +0 -9
- package/core/models/menus/menus.js +267 -247
- package/core/models/roles/components/role-add/role-add.js +227 -269
- package/core/models/roles/components/role-list/role-list.js +6 -8
- package/core/models/roles/roles.js +174 -182
- package/core/models/users/components/user-add/user-add.js +1 -69
- package/core/models/users/users.js +0 -57
- package/core/modules/index.js +13 -23
- package/core/modules/reporting/components/reporting-dashboard/reporting-dashboard.js +1 -1
- package/package.json +2 -2
- package/README.md +0 -260
- package/core/lib/hooks/use-otp-timer.js +0 -99
- package/core/models/staff/components/staff-add/staff-add.js +0 -352
- package/core/models/staff/components/staff-add/staff-add.scss +0 -0
- package/core/modules/steps/action-buttons.js +0 -79
- package/core/modules/steps/steps.js +0 -553
- package/core/modules/steps/steps.scss +0 -158
- package/core/modules/steps/timeline.js +0 -49
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
-
import { Space, Switch, Popconfirm, Skeleton, Input, Drawer, Collapse } from 'antd';
|
|
3
|
-
import { ReloadOutlined, DeleteOutlined, EditOutlined, CopyOutlined, PlusCircleFilled } from '@ant-design/icons';
|
|
2
|
+
import { Typography, Modal, Space, Switch, Popconfirm, Skeleton, Input, Drawer, Collapse, Button, Card } from 'antd';
|
|
3
|
+
import { ReloadOutlined, OrderedListOutlined, PicCenterOutlined, DeleteOutlined, EditOutlined, CopyOutlined, PlusCircleFilled } from '@ant-design/icons';
|
|
4
4
|
import { Link, useParams, useLocation } from 'react-router-dom';
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
// for draggable menu list import { DndProvider } from "react-dnd";
|
|
7
8
|
import { DndProvider } from 'react-dnd';
|
|
8
9
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
9
10
|
import { DraggableWrapper } from '../../../../lib';
|
|
10
|
-
import './menu-lists.scss'
|
|
11
|
-
import { Button, Card } from '../../../../lib';
|
|
11
|
+
import './menu-lists.scss'
|
|
12
12
|
|
|
13
13
|
const { Search } = Input;
|
|
14
14
|
const { Panel } = Collapse;
|
|
@@ -37,14 +37,12 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
|
|
|
37
37
|
|
|
38
38
|
const [query, setQuery] = useState('');
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
const [dragMode, setDragMode] = useState(
|
|
42
|
-
|
|
43
|
-
// to detect drag changes
|
|
44
|
-
const [orderChanged, setOrderChanged] = useState(false);
|
|
40
|
+
// ... existing states
|
|
41
|
+
const [dragMode, setDragMode] = useState(true); // NEW STATE
|
|
45
42
|
|
|
46
43
|
const toggleDragMode = (checked) => setDragMode(checked);
|
|
47
44
|
|
|
45
|
+
|
|
48
46
|
useEffect(() => {
|
|
49
47
|
loadMenus();
|
|
50
48
|
}, [id]);
|
|
@@ -81,7 +79,7 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
|
|
|
81
79
|
var result = res.result;
|
|
82
80
|
|
|
83
81
|
if (Array.isArray(result)) {
|
|
84
|
-
setRecords(result
|
|
82
|
+
setRecords(result);
|
|
85
83
|
// } else {
|
|
86
84
|
// setRecords([])
|
|
87
85
|
}
|
|
@@ -95,9 +93,9 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
|
|
|
95
93
|
});
|
|
96
94
|
};
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
function changeView(result) {
|
|
97
|
+
setView(result);
|
|
98
|
+
}
|
|
101
99
|
const loadMenus = () => {
|
|
102
100
|
setLoading(true);
|
|
103
101
|
|
|
@@ -106,8 +104,7 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
|
|
|
106
104
|
queries: [...additional_queries, { field: 'step', value: step }, { field: 'header_id', value: null }],
|
|
107
105
|
})
|
|
108
106
|
.then((res) => {
|
|
109
|
-
|
|
110
|
-
setRecords(sorted);
|
|
107
|
+
setRecords(res.result || []);
|
|
111
108
|
setLoading(false);
|
|
112
109
|
})
|
|
113
110
|
.catch(() => setLoading(false));
|
|
@@ -127,47 +124,41 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
|
|
|
127
124
|
// ------------------------
|
|
128
125
|
// Recursive function to build payload
|
|
129
126
|
// ------------------------
|
|
130
|
-
const buildOrderPayload = (menus) =>
|
|
131
|
-
menus.map((menu, index) => {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
const buildOrderPayload = (menus) => {
|
|
128
|
+
return menus.map((menu, index) => {
|
|
129
|
+
const payload = {
|
|
130
|
+
id: menu.id,
|
|
131
|
+
order: index + 1,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
if (menu.sub_menus && menu.sub_menus.length) {
|
|
135
|
+
payload.sub_menus = buildOrderPayload(menu.sub_menus);
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
return
|
|
138
|
+
return payload;
|
|
140
139
|
});
|
|
140
|
+
};
|
|
141
141
|
|
|
142
142
|
// ------------------------
|
|
143
143
|
// Save order function
|
|
144
144
|
// ------------------------
|
|
145
145
|
const saveOrder = () => {
|
|
146
146
|
const payload = { menus: buildOrderPayload(records) };
|
|
147
|
-
|
|
148
147
|
model
|
|
149
|
-
.
|
|
150
|
-
.then((
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
loadMenus(); // force refresh
|
|
148
|
+
.post('/update-order', payload) // Adjust endpoint to your backend
|
|
149
|
+
.then(() => {
|
|
150
|
+
message.success('Order saved successfully');
|
|
151
|
+
loadMenus(); // reload menus with new order
|
|
154
152
|
})
|
|
155
|
-
// const { updated_ids, same_order_ids } = res.result;
|
|
156
|
-
|
|
157
|
-
// Combine the updated order
|
|
158
|
-
// const newOrder = [...updated_ids, ...same_order_ids];
|
|
159
|
-
// const reorderedRecords = newOrder.map((id) => records.find((r) => r.id === id)).filter(Boolean); // remove undefined if not found
|
|
160
|
-
|
|
161
|
-
// setRecords(reorderedRecords);
|
|
162
|
-
// loadMenus(); // <-- reload from backend
|
|
163
|
-
// setOrderChanged(false);
|
|
164
|
-
// })
|
|
165
153
|
.catch((err) => {
|
|
166
154
|
console.error(err);
|
|
167
|
-
|
|
155
|
+
message.error('Failed to save order');
|
|
168
156
|
});
|
|
169
157
|
};
|
|
170
158
|
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
171
162
|
return (
|
|
172
163
|
<Card className="generic-list">
|
|
173
164
|
<div className="table-header">
|
|
@@ -188,29 +179,41 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
|
|
|
188
179
|
<div className="table-actions">
|
|
189
180
|
<div className="button-container">
|
|
190
181
|
<Space size="small">
|
|
191
|
-
<Button onClick={getRecords} size={'small'}
|
|
182
|
+
<Button onClick={getRecords} size={'small'}>
|
|
192
183
|
<ReloadOutlined />
|
|
193
184
|
</Button>
|
|
194
185
|
|
|
186
|
+
{/* <Switch
|
|
187
|
+
defaultChecked
|
|
188
|
+
onChange={changeView}
|
|
189
|
+
checked={view}
|
|
190
|
+
checkedChildren={<OrderedListOutlined />}
|
|
191
|
+
unCheckedChildren={<PicCenterOutlined />}
|
|
192
|
+
/> */}
|
|
195
193
|
{/* NEW SWITCH: Drag Mode */}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
194
|
+
<Switch
|
|
195
|
+
checked={dragMode}
|
|
196
|
+
onChange={toggleDragMode}
|
|
197
|
+
checkedChildren="Order On"
|
|
198
|
+
unCheckedChildren="Order Off"
|
|
199
|
+
/>
|
|
200
|
+
|
|
201
|
+
{dragMode && (
|
|
202
|
+
<Button
|
|
203
|
+
type="primary"
|
|
204
|
+
size="small"
|
|
205
|
+
// onClick={saveOrder}
|
|
206
|
+
>
|
|
207
|
+
Save Order
|
|
208
|
+
</Button>
|
|
209
|
+
)}
|
|
210
|
+
|
|
211
|
+
|
|
209
212
|
|
|
210
213
|
{disableAddModal || !model.ModalAddComponent ? null : (
|
|
211
214
|
<Button
|
|
212
215
|
type="primary"
|
|
213
|
-
size=
|
|
216
|
+
size='small'
|
|
214
217
|
onClick={() => {
|
|
215
218
|
setSelectedRecord({}); // empty record for creation
|
|
216
219
|
setDrawerTitle('Create New Menu');
|
|
@@ -241,20 +244,18 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
|
|
|
241
244
|
className="custom-panel"
|
|
242
245
|
header={
|
|
243
246
|
<DraggableWrapper
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
title={item.name}
|
|
257
|
-
dragEnabled={dragMode} // pass dragMode to wrapper
|
|
247
|
+
id={item.id}
|
|
248
|
+
index={index}
|
|
249
|
+
movePanel={(from, to) => {
|
|
250
|
+
if (!dragMode) return; // prevent moving if drag mode off
|
|
251
|
+
const updated = [...filtered];
|
|
252
|
+
const [moved] = updated.splice(from, 1);
|
|
253
|
+
updated.splice(to, 0, moved);
|
|
254
|
+
setRecords(updated);
|
|
255
|
+
}}
|
|
256
|
+
title={item.name}
|
|
257
|
+
dragEnabled={dragMode} // pass dragMode to wrapper
|
|
258
|
+
|
|
258
259
|
/>
|
|
259
260
|
}
|
|
260
261
|
extra={panelActions(item, model, setSelectedRecord, setDrawerTitle, setDrawerVisible, deleteRecord)}
|
|
@@ -263,16 +264,10 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
|
|
|
263
264
|
parentId={item.id}
|
|
264
265
|
step={step + 1}
|
|
265
266
|
model={model}
|
|
266
|
-
dragMode={dragMode}
|
|
267
267
|
setSelectedRecord={setSelectedRecord}
|
|
268
268
|
setDrawerTitle={setDrawerTitle}
|
|
269
269
|
setDrawerVisible={setDrawerVisible}
|
|
270
270
|
deleteRecord={deleteRecord}
|
|
271
|
-
onChange={(subMenus) => {
|
|
272
|
-
const updated = records.map((r) => (r.id === item.id ? { ...r, sub_menus: subMenus } : r));
|
|
273
|
-
setRecords(updated);
|
|
274
|
-
setOrderChanged(true);
|
|
275
|
-
}}
|
|
276
271
|
/>
|
|
277
272
|
</Panel>
|
|
278
273
|
))}
|
|
@@ -324,7 +319,7 @@ function panelActions(item, model, setSelectedRecord, setDrawerTitle, setDrawerV
|
|
|
324
319
|
setSelectedRecord({
|
|
325
320
|
header_id: item.id, // parent menu id
|
|
326
321
|
step: item.step + 1,
|
|
327
|
-
id: null,
|
|
322
|
+
id: null, // new record
|
|
328
323
|
});
|
|
329
324
|
setDrawerTitle(`Add Submenu to "${item.name}"`);
|
|
330
325
|
setDrawerVisible(true);
|
|
@@ -337,7 +332,6 @@ function panelActions(item, model, setSelectedRecord, setDrawerTitle, setDrawerV
|
|
|
337
332
|
{model.ModalAddComponent && (
|
|
338
333
|
<Button
|
|
339
334
|
size="small"
|
|
340
|
-
type="default"
|
|
341
335
|
onClick={() => {
|
|
342
336
|
setSelectedRecord(item);
|
|
343
337
|
setDrawerTitle('Edit Menu');
|
|
@@ -350,7 +344,6 @@ function panelActions(item, model, setSelectedRecord, setDrawerTitle, setDrawerV
|
|
|
350
344
|
|
|
351
345
|
<Button
|
|
352
346
|
size="small"
|
|
353
|
-
type="default"
|
|
354
347
|
onClick={() => {
|
|
355
348
|
setSelectedRecord({ ...item, id: null, copy: true });
|
|
356
349
|
setDrawerTitle('Copy Menu');
|
|
@@ -361,7 +354,7 @@ function panelActions(item, model, setSelectedRecord, setDrawerTitle, setDrawerV
|
|
|
361
354
|
</Button>
|
|
362
355
|
|
|
363
356
|
<Popconfirm title="Are you sure?" onConfirm={() => deleteRecord(item)}>
|
|
364
|
-
<Button danger size="small"
|
|
357
|
+
<Button danger size="small">
|
|
365
358
|
<DeleteOutlined />
|
|
366
359
|
</Button>
|
|
367
360
|
</Popconfirm>
|
|
@@ -372,27 +365,11 @@ function panelActions(item, model, setSelectedRecord, setDrawerTitle, setDrawerV
|
|
|
372
365
|
// ------------------------
|
|
373
366
|
// NestedMenu: Pass sub_menus recursively
|
|
374
367
|
// ------------------------
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
function NestedMenu({
|
|
378
|
-
parentId,
|
|
379
|
-
step,
|
|
380
|
-
model,
|
|
381
|
-
dragMode,
|
|
382
|
-
|
|
383
|
-
setSelectedRecord,
|
|
384
|
-
setDrawerTitle,
|
|
385
|
-
setDrawerVisible,
|
|
386
|
-
deleteRecord,
|
|
387
|
-
onChange, // callback to propagate changes to parent
|
|
388
|
-
}) {
|
|
368
|
+
function NestedMenu({ parentId, step, model, setSelectedRecord, setDrawerTitle, setDrawerVisible, deleteRecord }) {
|
|
389
369
|
const [items, setItems] = useState([]);
|
|
390
370
|
const [loading, setLoading] = useState(true);
|
|
391
371
|
|
|
392
|
-
// Load child menus
|
|
393
|
-
// NestedMenu
|
|
394
372
|
useEffect(() => {
|
|
395
|
-
setLoading(true);
|
|
396
373
|
model
|
|
397
374
|
.get({
|
|
398
375
|
queries: [
|
|
@@ -401,25 +378,18 @@ function NestedMenu({
|
|
|
401
378
|
],
|
|
402
379
|
})
|
|
403
380
|
.then((res) => {
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
.map((menu) => ({
|
|
407
|
-
...menu,
|
|
408
|
-
sub_menus: menu.sub_menus ? menu.sub_menus.sort((a, b) => a.order - b.order) : [],
|
|
409
|
-
}));
|
|
410
|
-
setItems(sortedMenus);
|
|
381
|
+
const menusWithSub = res.result.map((menu) => ({ ...menu, sub_menus: [] }));
|
|
382
|
+
setItems(menusWithSub || []);
|
|
411
383
|
setLoading(false);
|
|
412
384
|
})
|
|
413
385
|
.catch(() => setLoading(false));
|
|
414
|
-
}, [parentId
|
|
386
|
+
}, [parentId]);
|
|
415
387
|
|
|
416
|
-
// Move submenu
|
|
417
388
|
const moveSubMenu = (from, to) => {
|
|
418
389
|
const updated = [...items];
|
|
419
390
|
const [moved] = updated.splice(from, 1);
|
|
420
391
|
updated.splice(to, 0, moved);
|
|
421
392
|
setItems(updated);
|
|
422
|
-
onChange?.(updated); // propagate to parent
|
|
423
393
|
};
|
|
424
394
|
|
|
425
395
|
if (loading) return <Skeleton active />;
|
|
@@ -434,31 +404,24 @@ function NestedMenu({
|
|
|
434
404
|
<DraggableWrapper
|
|
435
405
|
id={child.id}
|
|
436
406
|
index={index}
|
|
437
|
-
movePanel={
|
|
438
|
-
if (!dragMode) return; // block drag when OFF
|
|
439
|
-
moveSubMenu(from, to);
|
|
440
|
-
}}
|
|
407
|
+
movePanel={moveSubMenu}
|
|
441
408
|
title={child.name}
|
|
442
|
-
dragEnabled={
|
|
409
|
+
dragEnabled={true}
|
|
443
410
|
/>
|
|
444
411
|
}
|
|
445
412
|
extra={panelActions(child, model, setSelectedRecord, setDrawerTitle, setDrawerVisible, deleteRecord)}
|
|
446
413
|
>
|
|
447
|
-
{
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
setItems(updated);
|
|
459
|
-
onChange?.(updated);
|
|
460
|
-
}}
|
|
461
|
-
/>
|
|
414
|
+
{child.hasChildren && (
|
|
415
|
+
<NestedMenu
|
|
416
|
+
parentId={child.id}
|
|
417
|
+
step={step + 1}
|
|
418
|
+
model={model}
|
|
419
|
+
setSelectedRecord={setSelectedRecord}
|
|
420
|
+
setDrawerTitle={setDrawerTitle}
|
|
421
|
+
setDrawerVisible={setDrawerVisible}
|
|
422
|
+
deleteRecord={deleteRecord}
|
|
423
|
+
/>
|
|
424
|
+
)}
|
|
462
425
|
</Panel>
|
|
463
426
|
))}
|
|
464
427
|
</Collapse>
|
|
@@ -38,13 +38,4 @@
|
|
|
38
38
|
padding: 10px 14px;
|
|
39
39
|
box-shadow: 0 1px 4px rgba(0,0,0,0.04);
|
|
40
40
|
}
|
|
41
|
-
/* OFF state */
|
|
42
|
-
.custom-switch.ant-switch {
|
|
43
|
-
background-color: #bfbfbf !important; /* gray */
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/* ON state */
|
|
47
|
-
.custom-switch.ant-switch-checked {
|
|
48
|
-
background-color: #446AA9 !important; /* blue */
|
|
49
|
-
}
|
|
50
41
|
|