Revize db3fa00e
Přidáno uživatelem Jaroslav Hrubý před téměř 3 roky(ů)
webapp/pages/documents/admin/index.tsx | ||
---|---|---|
53 | 53 |
const [documents, setDocuments] = useState<TableDocInfo[]>([]); |
54 | 54 |
const [userFilters, setUserFilters] = useState<UserFilter[]>([]); |
55 | 55 |
const [selectedDocs, setSelectedDocs] = useState<string[]>([]); |
56 |
const [selectedRows, setSelectedRows] = useState([]); |
|
56 | 57 |
const [previewDocContent, setPreviewDocContent] = useState<string>(); |
57 | 58 |
const [previewDocName, setPreviewDocName] = useState<string>(); |
58 | 59 |
const [annotationCount, setAnnotationCount] = useState<number>(); |
... | ... | |
232 | 233 |
documentController.documentsDelete(req).then(() => { |
233 | 234 |
ShowToast('Dokumenty byly úspěšně odstraněny'); |
234 | 235 |
fetchData(); |
236 |
clearSelection(); |
|
235 | 237 |
}); |
236 | 238 |
}, 'dokumenty'); |
237 | 239 |
}; |
... | ... | |
241 | 243 |
const res = await documentController.documentsExportPost(req); |
242 | 244 |
if (res?.data) { |
243 | 245 |
download(res.data, 'export.zip'); |
246 |
clearSelection(); |
|
244 | 247 |
} |
245 | 248 |
}; |
246 | 249 |
|
... | ... | |
267 | 270 |
}); |
268 | 271 |
}; |
269 | 272 |
|
270 |
const hideModal = () => { |
|
273 |
const hideModalWithClear = () => {
|
|
271 | 274 |
fetchData(); |
272 |
setVisibleAdd(false); |
|
273 | 275 |
setVisibleAssign(false); |
274 | 276 |
setVisibleSetCount(false); |
277 |
clearSelection(); |
|
278 |
}; |
|
279 |
|
|
280 |
const hideModal = () => { |
|
281 |
fetchData(); |
|
282 |
setVisibleAdd(false); |
|
275 | 283 |
setVisiblePreview(false); |
276 | 284 |
}; |
277 | 285 |
|
... | ... | |
521 | 529 |
}, |
522 | 530 |
]; |
523 | 531 |
|
532 |
const clearSelection = () => { |
|
533 |
setSelectedRows([]); |
|
534 |
}; |
|
535 |
|
|
536 |
const onSelectChange = ( |
|
537 |
selectedRowKeys: React.Key[], |
|
538 |
selectedRows: DocumentListInfo[] |
|
539 |
) => { |
|
540 |
// @ts-ignore |
|
541 |
setSelectedDocs(selectedRows.map((row) => row.id)); |
|
542 |
// @ts-ignore |
|
543 |
setSelectedRows(selectedRowKeys); |
|
544 |
}; |
|
545 |
|
|
524 | 546 |
const rowSelection = { |
525 |
onChange: (selectedRowKeys: React.Key[], selectedRows: DocumentListInfo[]) => { |
|
526 |
// @ts-ignore |
|
527 |
setSelectedDocs(selectedRows.map((row) => row.id)); |
|
528 |
}, |
|
547 |
selectedRowKeys: selectedRows, |
|
548 |
onChange: onSelectChange, |
|
529 | 549 |
}; |
530 | 550 |
|
531 | 551 |
return redirecting || role !== 'ADMINISTRATOR' ? null : ( |
... | ... | |
611 | 631 |
|
612 | 632 |
{visibleAdd && <AddDocumentModal onCancel={hideModal} />} |
613 | 633 |
{visibleAssign && ( |
614 |
<AssignDocumentModal documentsIds={selectedDocs} onCancel={hideModal} /> |
|
634 |
<AssignDocumentModal |
|
635 |
documentsIds={selectedDocs} |
|
636 |
onCancel={hideModalWithClear} |
|
637 |
/> |
|
615 | 638 |
)} |
616 | 639 |
{visiblePreview && ( |
617 | 640 |
<DocPreviewModal |
... | ... | |
625 | 648 |
{visibleSetCount && ( |
626 | 649 |
<SetRequiredAnnotationsCountModal |
627 | 650 |
documentsIds={selectedDocs} |
628 |
onCancel={hideModal} |
|
651 |
onCancel={hideModalWithClear}
|
|
629 | 652 |
/> |
630 | 653 |
)} |
631 | 654 |
|
632 | 655 |
<Table |
633 | 656 |
locale={{ ...getLocaleProps() }} |
634 |
rowSelection={{ |
|
635 |
type: 'checkbox', |
|
636 |
...rowSelection, |
|
637 |
}} |
|
657 |
rowSelection={rowSelection} |
|
638 | 658 |
// @ts-ignore |
639 | 659 |
columns={columns} |
640 | 660 |
dataSource={documents} |
Také k dispozici: Unified diff
Reset documents selection after action