ui-soxo-bootstrap-core 2.4.25-dev.15 → 2.4.25-dev.16
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.
|
@@ -34,7 +34,8 @@ const RoleAdd = ({ model, callback, edit, formContent = {}, match, additional_qu
|
|
|
34
34
|
const [models, setModels] = useState([]);
|
|
35
35
|
const [menuList, setMenuList] = useState([]);
|
|
36
36
|
const [showMenus, setShowMenus] = useState(false);
|
|
37
|
-
|
|
37
|
+
// for deselected menu for editing
|
|
38
|
+
const [originalMenus, setOriginalMenus] = useState([]);
|
|
38
39
|
|
|
39
40
|
// Selected menus (array of IDs)
|
|
40
41
|
const [selectedMenus, setSelectedMenus] = useState([]);
|
|
@@ -57,7 +58,8 @@ const RoleAdd = ({ model, callback, edit, formContent = {}, match, additional_qu
|
|
|
57
58
|
let menus = formContent.menu_ids;
|
|
58
59
|
|
|
59
60
|
setSelectedMenus(menus);
|
|
60
|
-
|
|
61
|
+
// keep original copy for deselect comparison
|
|
62
|
+
setOriginalMenus(menus);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
setLoading(false);
|
|
@@ -174,58 +176,18 @@ const RoleAdd = ({ model, callback, edit, formContent = {}, match, additional_qu
|
|
|
174
176
|
<Input placeholder="Enter description" />
|
|
175
177
|
</Form.Item>
|
|
176
178
|
|
|
177
|
-
{/*
|
|
179
|
+
{/* MENU TREE */}
|
|
178
180
|
{showMenus && menuList.length > 0 && (
|
|
179
181
|
<div style={{ marginTop: 30 }}>
|
|
180
|
-
<Title level={5}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
<Collapse expandIconPosition="left" style={{ marginBottom: '4px' }}>
|
|
186
|
-
{menuList.map((item) => {
|
|
187
|
-
const hasChildren = item.sub_menus && item.sub_menus.length > 0;
|
|
188
|
-
|
|
189
|
-
if (!hasChildren) {
|
|
190
|
-
// 👉 NO collapse icon
|
|
191
|
-
return (
|
|
192
|
-
<div
|
|
193
|
-
key={item.id}
|
|
194
|
-
style={{
|
|
195
|
-
padding: '12px 16px',
|
|
196
|
-
display: 'flex',
|
|
197
|
-
alignItems: 'center',
|
|
198
|
-
gap: 8,
|
|
199
|
-
borderBottom: '1px solid #f0f0f0',
|
|
200
|
-
}}
|
|
201
|
-
>
|
|
202
|
-
<Checkbox checked={selectedMenus.includes(item.id)} onChange={(e) => toggleMenu(item.id, e.target.checked)} />
|
|
203
|
-
<span>{item.title || item.caption}</span>
|
|
204
|
-
</div>
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// 👉 WITH collapse icon
|
|
209
|
-
return (
|
|
210
|
-
<Panel
|
|
211
|
-
key={item.id}
|
|
212
|
-
header={
|
|
213
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 8, borderBottom: '1px solid #f0f0f0' }}>
|
|
214
|
-
<Checkbox checked={selectedMenus.includes(item.id)} onChange={(e) => toggleMenu(item.id, e.target.checked)} />
|
|
215
|
-
<span>{item.title || item.caption}</span>
|
|
216
|
-
</div>
|
|
217
|
-
}
|
|
218
|
-
>
|
|
219
|
-
<NestedMenu parentId={item.id} step={step + 1} selectedMenus={selectedMenus} toggleMenu={toggleMenu} />
|
|
220
|
-
</Panel>
|
|
221
|
-
);
|
|
222
|
-
})}
|
|
223
|
-
</Collapse>
|
|
182
|
+
<Title level={5}>Menu List</Title>
|
|
183
|
+
<p style={{ color: '#999' }}>Choose menus and set permissions</p>
|
|
184
|
+
|
|
185
|
+
<MenuTree menus={menuList} selectedMenus={selectedMenus} toggleMenu={toggleMenu} />
|
|
224
186
|
</div>
|
|
225
187
|
)}
|
|
226
188
|
|
|
227
189
|
{/* Submit Button */}
|
|
228
|
-
<Form.Item>
|
|
190
|
+
<Form.Item style={{ marginTop: 20 }}>
|
|
229
191
|
<Button loading={loading} htmlType="submit" type="primary">
|
|
230
192
|
Save
|
|
231
193
|
</Button>
|
|
@@ -241,45 +203,52 @@ export default RoleAdd;
|
|
|
241
203
|
// ------------------------
|
|
242
204
|
// Recursive Nested Menu Component
|
|
243
205
|
// ------------------------
|
|
244
|
-
const
|
|
245
|
-
const [items, setItems] = useState([]);
|
|
246
|
-
const [loading, setLoading] = useState(true);
|
|
247
|
-
|
|
248
|
-
useEffect(() => {
|
|
249
|
-
MenusAPI.get({
|
|
250
|
-
queries: [
|
|
251
|
-
{ field: 'header_id', value: parentId },
|
|
252
|
-
{ field: 'step', value: step },
|
|
253
|
-
],
|
|
254
|
-
})
|
|
255
|
-
.then((res) => {
|
|
256
|
-
setItems(res.result || []);
|
|
257
|
-
setLoading(false);
|
|
258
|
-
})
|
|
259
|
-
.catch(() => setLoading(false));
|
|
260
|
-
}, [parentId, step]);
|
|
261
|
-
|
|
262
|
-
if (loading) return <Skeleton active />;
|
|
263
|
-
if (!items.length) return null;
|
|
264
|
-
|
|
206
|
+
const MenuTree = ({ menus, selectedMenus, toggleMenu }) => {
|
|
265
207
|
return (
|
|
266
|
-
|
|
267
|
-
{
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
208
|
+
<>
|
|
209
|
+
{menus.map((menu) => {
|
|
210
|
+
const hasChildren = Array.isArray(menu.sub_menus) && menu.sub_menus.length > 0;
|
|
211
|
+
|
|
212
|
+
// NO CHILD → SIMPLE ROW (NO COLLAPSE)
|
|
213
|
+
if (!hasChildren) {
|
|
214
|
+
return (
|
|
215
|
+
<div
|
|
216
|
+
key={menu.id}
|
|
217
|
+
style={{
|
|
218
|
+
padding: '10px 16px',
|
|
219
|
+
display: 'flex',
|
|
220
|
+
alignItems: 'center',
|
|
221
|
+
gap: 8,
|
|
222
|
+
borderBottom: '1px solid #f0f0f0',
|
|
223
|
+
}}
|
|
224
|
+
>
|
|
225
|
+
<Checkbox checked={selectedMenus.includes(menu.id)} onChange={(e) => toggleMenu(menu.id, e.target.checked)} />
|
|
276
226
|
<span>{menu.title || menu.caption}</span>
|
|
277
227
|
</div>
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// HAS CHILD → COLLAPSE WITH ICON
|
|
232
|
+
return (
|
|
233
|
+
<Collapse key={menu.id} collapsible="icon" style={{ marginBottom: '4px' }}>
|
|
234
|
+
<Panel
|
|
235
|
+
key={menu.id}
|
|
236
|
+
header={
|
|
237
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
238
|
+
<Checkbox
|
|
239
|
+
checked={selectedMenus.includes(menu.id)}
|
|
240
|
+
onClick={(e) => e.stopPropagation()}
|
|
241
|
+
onChange={(e) => toggleMenu(menu.id, e.target.checked)}
|
|
242
|
+
/>
|
|
243
|
+
<span>{menu.title || menu.caption}</span>
|
|
244
|
+
</div>
|
|
245
|
+
}
|
|
246
|
+
>
|
|
247
|
+
<MenuTree menus={menu.sub_menus} selectedMenus={selectedMenus} toggleMenu={toggleMenu} />
|
|
248
|
+
</Panel>
|
|
249
|
+
</Collapse>
|
|
250
|
+
);
|
|
251
|
+
})}
|
|
252
|
+
</>
|
|
284
253
|
);
|
|
285
254
|
};
|
|
@@ -1042,7 +1042,8 @@ function GuestList({
|
|
|
1042
1042
|
) : (
|
|
1043
1043
|
<TableComponent
|
|
1044
1044
|
size="small"
|
|
1045
|
-
scroll={{ x: true }}
|
|
1045
|
+
scroll={{ x: true, y: '60vh' }}
|
|
1046
|
+
sticky
|
|
1046
1047
|
rowKey={(record) => record.OpNo}
|
|
1047
1048
|
dataSource={filtered ? filtered : patients} // In case if there is no filtered values we can use patient data
|
|
1048
1049
|
columns={cols}
|