ui-soxo-bootstrap-core 2.4.25-dev.10 → 2.4.25-dev.11

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.
@@ -6,7 +6,7 @@ import React, { useState, useRef, useEffect, useContext } from 'react';
6
6
 
7
7
  import { Link, useParams, useLocation } from 'react-router-dom';
8
8
 
9
- import { Typography, Modal, Space, Switch, Popconfirm, Skeleton, Input, Drawer,Select} from 'antd';
9
+ import { Typography, Modal, Space, Switch, Popconfirm, Skeleton, Input, Drawer, Select } from 'antd';
10
10
 
11
11
  import { TableComponent, Card, Button } from './../../../../lib';
12
12
 
@@ -15,396 +15,372 @@ import { RolesAPI } from '../../..';
15
15
 
16
16
  const { Title } = Typography;
17
17
 
18
-
19
18
  const RoleList = ({ model, match, relativeAdd = false, additional_queries = [], disableAddModal = model.disableAddModal }) => {
19
+ const actions = [];
20
20
 
21
- const actions = [];
22
-
23
- match = useParams();
24
-
25
- // Block to get the url params #Note Location search is not working
26
- let location = useLocation();
27
-
28
- const query = new URLSearchParams(location.search);
29
-
30
- console.log(query.get('step'));
31
-
32
- let step = parseInt(query.get('step')) || 1;
33
- //
34
-
35
- const [loading, setLoading] = useState(false);
36
-
37
- const [records, setRecords] = useState([]);
38
-
39
- const [view, setView] = useState(false);
40
-
41
- const [visible, setVisible] = useState(false);
42
-
43
- const [single, setSingle] = useState({});
44
-
45
- var [queryValue, setQueryValue] = useState('');
46
-
47
- const { Search } = Input;
48
-
49
- useEffect(() => {
50
-
51
- getRecords();
21
+ match = useParams();
52
22
 
53
- }, []);
23
+ // Block to get the url params #Note Location search is not working
24
+ let location = useLocation();
54
25
 
55
- /**
56
- *
57
- */
58
- const getRecords = () => {
26
+ const query = new URLSearchParams(location.search);
59
27
 
60
- let firstStepQueries = [{
61
- field: 'step',
62
- value: step
63
- }]
28
+ console.log(query.get('step'));
64
29
 
65
- let config = {
66
- queries: [
67
- // ...additional_queries,
68
- // ...firstStepQueries
69
- ],
70
- }
71
-
72
- // if (!additional_queries.length) {
73
-
74
- // config.queries.push({
75
- // field: 'header_id',
76
- // value: null
77
- // })
78
- // }
79
-
80
- setLoading(true);
81
-
82
- // Get the records
83
- return RolesAPI.getRole()
84
-
85
- .then((res) => {
86
-
87
- // setRecords(res.result);
88
- var result = res;
89
-
30
+ let step = parseInt(query.get('step')) || 1;
31
+ //
90
32
 
91
- // if (id) {
33
+ const [loading, setLoading] = useState(false);
92
34
 
93
- // var filtered = res.result.filter((record) => record.header_id = id)
35
+ const [records, setRecords] = useState([]);
94
36
 
95
- // }
37
+ const [view, setView] = useState(false);
96
38
 
39
+ const [visible, setVisible] = useState(false);
97
40
 
98
- setRecords(result.result);
41
+ const [single, setSingle] = useState({});
99
42
 
100
- setLoading(false);
43
+ var [queryValue, setQueryValue] = useState('');
101
44
 
102
- })
103
- .catch((error) => {
45
+ const { Search } = Input;
104
46
 
105
- setLoading(false);
47
+ useEffect(() => {
48
+ getRecords();
49
+ }, []);
106
50
 
107
- console.log(error);
108
- });
51
+ /**
52
+ *
53
+ */
54
+ const getRecords = () => {
55
+ let firstStepQueries = [
56
+ {
57
+ field: 'step',
58
+ value: step,
59
+ },
60
+ ];
109
61
 
62
+ let config = {
63
+ queries: [
64
+ // ...additional_queries,
65
+ // ...firstStepQueries
66
+ ],
110
67
  };
111
68
 
112
- /**
113
- * Function to change view
114
- */
115
- function changeView(result) {
116
- setView(result);
117
- }
69
+ // if (!additional_queries.length) {
118
70
 
119
- /**
120
- * Function to store search value
121
- */
122
- function onSearch(event) {
123
- setQueryValue(event.target.value);
124
- }
71
+ // config.queries.push({
72
+ // field: 'header_id',
73
+ // value: null
74
+ // })
75
+ // }
125
76
 
126
- /**
127
- * Search in candidate visit List
128
- */
129
- let filtered = records.filter(record => {
77
+ setLoading(true);
130
78
 
131
- let searchText = queryValue.toUpperCase();
79
+ // Get the records
80
+ return RolesAPI.getRole()
132
81
 
133
- if (queryValue) {
82
+ .then((res) => {
83
+ // setRecords(res.result);
84
+ var result = res;
134
85
 
135
- if (record.name !== null) {
86
+ // if (id) {
136
87
 
137
- if (record.name.toUpperCase().indexOf(searchText) != -1) {
88
+ // var filtered = res.result.filter((record) => record.header_id = id)
138
89
 
139
- return true;
140
- }
141
- }
142
- } else {
143
-
144
- return true;
90
+ // }
145
91
 
92
+ setRecords(result.result);
93
+
94
+ setLoading(false);
95
+ })
96
+ .catch((error) => {
97
+ setLoading(false);
98
+
99
+ console.log(error);
100
+ });
101
+ };
102
+
103
+ /**
104
+ * Function to change view
105
+ */
106
+ function changeView(result) {
107
+ setView(result);
108
+ }
109
+
110
+ /**
111
+ * Function to store search value
112
+ */
113
+ function onSearch(event) {
114
+ setQueryValue(event.target.value);
115
+ }
116
+
117
+ /**
118
+ * Search in candidate visit List
119
+ */
120
+ let filtered = records.filter((record) => {
121
+ let searchText = queryValue.toUpperCase();
122
+
123
+ if (queryValue) {
124
+ if (record.name !== null) {
125
+ if (record.name.toUpperCase().indexOf(searchText) != -1) {
126
+ return true;
146
127
  }
147
- });
148
-
149
- /**
150
- * Function hides the modal
151
- *
152
- * @param reload
153
- */
154
- function closeModal() {
155
-
156
- setVisible(false);
157
-
158
- // if (reload) {
159
- // getRecords();
160
- // }
128
+ }
129
+ } else {
130
+ return true;
161
131
  }
162
- /**
163
- * On delete of each record
164
- */
165
- function onDelete(id) {
166
-
167
- RolesAPI.deleteRole(id).then((res) => {
168
- if (res) {
169
- getRecords();
170
-
132
+ });
133
+
134
+ /**
135
+ * Function hides the modal
136
+ *
137
+ * @param reload
138
+ */
139
+ function closeModal() {
140
+ setVisible(false);
141
+
142
+ // if (reload) {
143
+ // getRecords();
144
+ // }
145
+ }
146
+ /**
147
+ * On delete of each record
148
+ */
149
+ function onDelete(id) {
150
+ RolesAPI.deleteRole(id)
151
+ .then((res) => {
152
+ if (res) {
153
+ getRecords();
154
+ }
155
+ })
156
+ .catch((error) => {
157
+ setLoading(false);
158
+
159
+ console.log(error);
160
+ });
161
+ }
162
+
163
+ const cols = [
164
+ ...[
165
+ {
166
+ title: '#',
167
+ dataIndex: 'index',
168
+ render: (value, item, index) => index + 1,
169
+ },
170
+ ],
171
+ ...model.columns.map((entry) => {
172
+ if (entry.sort) {
173
+ return {
174
+ render: (record) => {
175
+ if (entry.render) {
176
+ return entry.render(record);
177
+ } else {
178
+ return entry.field.split('.').reduce((acc, part) => acc && acc[part], record);
171
179
  }
172
-
173
-
174
- }).catch((error) => {
175
-
176
- setLoading(false);
177
-
178
- console.log(error);
179
-
180
- })
181
- }
182
-
183
- const cols = [
184
- ...[
185
- {
186
- title: '#',
187
- dataIndex: 'index',
188
- render: (value, item, index) => index + 1,
189
- },
190
- ],
191
- ...model.columns.map((entry) => {
192
- if (entry.sort) {
193
- return {
194
- render: (record) => {
195
- if (entry.render) {
196
- return entry.render(record);
197
- } else {
198
- return entry.field.split('.').reduce((acc, part) => acc && acc[part], record);
199
- }
200
- },
201
- title: entry.caption,
202
- key: entry.field,
203
- // sorter: (a, b) => entry.sort(a, b),
204
- sortDirections: ['ascend', 'descend', 'ascend'],
205
- };
180
+ },
181
+ title: entry.caption,
182
+ key: entry.field,
183
+ // sorter: (a, b) => entry.sort(a, b),
184
+ sortDirections: ['ascend', 'descend', 'ascend'],
185
+ };
186
+ } else {
187
+ return {
188
+ render: (record) => {
189
+ if (entry.render) {
190
+ return entry.render(record);
191
+ // return entry.field.split('.').reduce((acc, part) => acc && acc[part], record);
206
192
  } else {
207
- return {
208
- render: (record) => {
209
- if (entry.render) {
210
- return entry.render(record);
211
- // return entry.field.split('.').reduce((acc, part) => acc && acc[part], record);
212
- } else {
213
- return entry.field.split('.').reduce((acc, part) => acc && acc[part], record);
214
- }
215
- // return record[entry.field]
216
- },
217
- title: entry.caption,
218
- key: entry.field,
219
- // dataIndex: entry.field,
220
- };
193
+ return entry.field.split('.').reduce((acc, part) => acc && acc[part], record);
221
194
  }
222
- }),
223
- ...[
224
- {
225
- title: '',
226
- key: 'action',
227
- render: (text, record) => {
228
- return (
229
- <Space size="middle">
230
-
231
- {/* Edit */}
232
- {!model.ModalAddComponent ? null : (
233
- <Button size={'small'} type="dashed" onClick={() => {
234
-
235
- setSingle({ ...record });
236
-
237
- setVisible(true);
238
- }}>
239
- <EditOutlined />
240
- </Button>
241
- )}
242
- {/* Edit Ends */}
243
-
244
- {/* Copy */}
245
- {!model.ModalAddComponent ? null : (
246
- <Button size={'small'} type="dashed" onClick={() => {
247
-
248
- setSingle({
249
- ...record,
250
- id: null,
251
- copy: true
252
- });
253
-
254
- setVisible(true);
255
- }}>
256
- <CopyOutlined />
257
- </Button>
258
- )}
259
- {/* Copy Ends */}
260
-
261
- {/* Delete Icon */}
262
- <Popconfirm title="Are you sure" onConfirm={() => {
263
-
264
- onDelete(record.id);
265
- }}>
266
- <Button size={'small'} type="dashed">
267
- <DeleteOutlined />
268
- </Button>
269
- </Popconfirm>
270
- {/* Delete Icon */}
271
-
272
-
273
- {/* {!model.hideView && !actions.length ? <Link to={`/${model.name}/${text.id}`}>View</Link> : null} */}
274
-
275
- {/* {!model.hideView && !actions.length ? <Link to={`/users/${record['id']}`}>View</Link> : null} */}
276
-
277
- {/* {actions.map((action) => (
195
+ // return record[entry.field]
196
+ },
197
+ title: entry.caption,
198
+ key: entry.field,
199
+ // dataIndex: entry.field,
200
+ };
201
+ }
202
+ }),
203
+ ...[
204
+ {
205
+ title: '',
206
+ key: 'action',
207
+ render: (text, record) => {
208
+ return (
209
+ <Space size="middle">
210
+ {/* Edit */}
211
+ {!model.ModalAddComponent ? null : (
212
+ <Button
213
+ size={'small'}
214
+ type="dashed"
215
+ onClick={() => {
216
+ setSingle({ ...record });
217
+
218
+ setVisible(true);
219
+ }}
220
+ >
221
+ <EditOutlined />
222
+ </Button>
223
+ )}
224
+ {/* Edit Ends */}
225
+
226
+ {/* Copy */}
227
+ {!model.ModalAddComponent ? null : (
228
+ <Button
229
+ size={'small'}
230
+ type="dashed"
231
+ onClick={() => {
232
+ setSingle({
233
+ ...record,
234
+ id: null,
235
+ copy: true,
236
+ });
237
+
238
+ setVisible(true);
239
+ }}
240
+ >
241
+ <CopyOutlined />
242
+ </Button>
243
+ )}
244
+ {/* Copy Ends */}
245
+
246
+ {/* Delete Icon */}
247
+ <Popconfirm
248
+ title="Are you sure"
249
+ onConfirm={() => {
250
+ onDelete(record.id);
251
+ }}
252
+ >
253
+ <Button size={'small'} type="dashed">
254
+ <DeleteOutlined />
255
+ </Button>
256
+ </Popconfirm>
257
+ {/* Delete Icon */}
258
+
259
+ {/* {!model.hideView && !actions.length ? <Link to={`/${model.name}/${text.id}`}>View</Link> : null} */}
260
+
261
+ {/* {!model.hideView && !actions.length ? <Link to={`/users/${record['id']}`}>View</Link> : null} */}
262
+
263
+ {/* {actions.map((action) => (
278
264
  <Link to={action.url(record)}>{action.caption}</Link>
279
265
  ))} */}
280
- </Space>
281
- );
282
- },
283
- },
284
- ],
285
- ];
286
-
287
-
288
- return (
289
-
290
- <Card className="generic-list">
291
- {/* Table Header */}
292
- <div className="table-header">
293
- <div className="table-title">
294
-
295
- <Search
296
- placeholder="Enter Search Value"
297
- allowClear
298
- // value={query}
299
- style={{ width: 300, marginTop: '10px', marginBottom: '20px' }}
300
- onChange={onSearch}
301
- />
302
- {/* <Title level={4}>{model.name}</Title> */}
303
-
304
- {/* <p>{loading ? 'Loading records' : `${record.length} records`}</p> */}
305
- </div>
306
-
307
- <div className="table-bar">
308
- {/* Table Filters */}
309
- {/* <div className="table-filters">
266
+ </Space>
267
+ );
268
+ },
269
+ },
270
+ ],
271
+ ];
272
+
273
+ return (
274
+ <Card className="generic-list">
275
+ {/* Table Header */}
276
+ <div className="table-header">
277
+ <div className="table-title">
278
+ <Search
279
+ placeholder="Enter Search Value"
280
+ allowClear
281
+ // value={query}
282
+ style={{ width: 300, marginTop: '10px', marginBottom: '20px' }}
283
+ onChange={onSearch}
284
+ />
285
+ {/* <Title level={4}>{model.name}</Title> */}
286
+
287
+ {/* <p>{loading ? 'Loading records' : `${record.length} records`}</p> */}
288
+ </div>
289
+
290
+ <div className="table-bar">
291
+ {/* Table Filters */}
292
+ {/* <div className="table-filters">
310
293
  <Space direction="vertical" size={12}></Space>
311
294
  </div> */}
312
- {/* Table Filters Ends */}
313
-
314
- <div className="table-actions">
315
- <div className="button-container">
316
- <Space size="small">
317
-
318
- <Button onClick={getRecords} size={'small'} type='default'>
319
- <ReloadOutlined />
320
- </Button>
321
-
322
- <Switch
323
- defaultChecked
324
- onChange={changeView}
325
- checked={view}
326
- checkedChildren={<OrderedListOutlined />}
327
- unCheckedChildren={<PicCenterOutlined />}
328
- />
329
-
330
-
331
- {/* {disableAddModal || !model.ModalAddComponent ? null : ( */}
332
- {!model.ModalAddComponent ? null : (
333
- <Button type="primary" onClick={() => {
334
-
335
- setSingle({});
336
-
337
- setVisible(true);
338
- }}>
339
- Create Role
340
- </Button>
341
- )}
342
- </Space>
343
- </div>
344
- </div>
345
- </div>
295
+ {/* Table Filters Ends */}
296
+
297
+ <div className="table-actions">
298
+ <div className="button-container">
299
+ <Space size="small">
300
+ <Button onClick={getRecords} size={'small'} type="default">
301
+ <ReloadOutlined />
302
+ </Button>
303
+
304
+ <Switch
305
+ defaultChecked
306
+ onChange={changeView}
307
+ checked={view}
308
+ checkedChildren={<OrderedListOutlined />}
309
+ unCheckedChildren={<PicCenterOutlined />}
310
+ />
311
+
312
+ {/* {disableAddModal || !model.ModalAddComponent ? null : ( */}
313
+ {!model.ModalAddComponent ? null : (
314
+ <Button
315
+ type="primary"
316
+ onClick={() => {
317
+ setSingle({});
318
+
319
+ setVisible(true);
320
+ }}
321
+ >
322
+ Create Role
323
+ </Button>
324
+ )}
325
+ </Space>
346
326
  </div>
347
-
348
- {/* Table Header Ends */}
349
-
350
- {loading ? (
351
- <Skeleton />
327
+ </div>
328
+ </div>
329
+ </div>
330
+
331
+ {/* Table Header Ends */}
332
+
333
+ {loading ? (
334
+ <Skeleton />
335
+ ) : (
336
+ <>
337
+ <>
338
+ {!view ? (
339
+ <div className="card card-shadow">
340
+ <TableComponent
341
+ // rowKey={obj => obj.id}
342
+ // ref={(ref) => { tableRef = ref }}
343
+ loading={loading}
344
+ dataSource={filtered ? filtered : records}
345
+ columns={cols}
346
+ ></TableComponent>
347
+ </div>
352
348
  ) : (
353
- <>
354
- <>
355
- {!view ? (
356
- <div className='card card-shadow'>
357
- <TableComponent
358
- // rowKey={obj => obj.id}
359
- // ref={(ref) => { tableRef = ref }}
360
- loading={loading}
361
- dataSource={filtered ? filtered : records}
362
- columns={cols}
363
- ></TableComponent>
364
- </div>
365
- ) : (
366
- <CardList model={model} data={filtered ? filtered : records} />
367
- )}
368
- </>
369
- </>
349
+ <CardList model={model} data={filtered ? filtered : records} />
370
350
  )}
371
-
372
- {/* Add Modal */}
373
- <Drawer
374
- title={single?.id ? "Edit Role" : "Create New Role"}
375
- width={780}
376
- open={visible}
377
- destroyOnClose
378
- onClose={closeModal}
379
- bodyStyle={{ paddingBottom: 80 }}
380
- >
381
- <model.ModalAddComponent
382
- match={match}
383
- model={model}
384
- additional_queries={additional_queries}
385
- formContent={single}
386
- callback={(event) => {
351
+ </>
352
+ </>
353
+ )}
354
+
355
+ {/* Add Modal */}
356
+ <Drawer
357
+ title={single?.id ? 'Edit Role' : 'Create New Role'}
358
+ width={850}
359
+ open={visible}
360
+ destroyOnClose
361
+ onClose={closeModal}
362
+ bodyStyle={{ paddingBottom: 80 }}
363
+ >
364
+ <model.ModalAddComponent
365
+ match={match}
366
+ model={model}
367
+ additional_queries={additional_queries}
368
+ formContent={single}
369
+ callback={(event) => {
387
370
  closeModal();
388
371
  getRecords();
389
- }}
390
- />
391
- </Drawer>
392
-
393
-
394
- {/* <FormCreator formContent={{ [model]: {} }} modelIndex="requestId" model={model} onSubmit={createRecord} config={step} /> */}
395
-
396
-
397
-
398
- </Card>
372
+ }}
373
+ />
374
+ </Drawer>
399
375
 
400
-
401
- );
402
- }
376
+ {/* <FormCreator formContent={{ [model]: {} }} modelIndex="requestId" model={model} onSubmit={createRecord} config={step} /> */}
377
+ </Card>
378
+ );
379
+ };
403
380
 
404
381
  function CardList({ model, data, url, ...props }) {
405
- return data.map((record, index) => {
406
- return <model.Card record={record} model={model} index={index} key={index} {...record} {...props} />;
407
- });
382
+ return data.map((record, index) => {
383
+ return <model.Card record={record} model={model} index={index} key={index} {...record} {...props} />;
384
+ });
408
385
  }
409
386
  export default RoleList;
410
-