From 095634a4ea6e9c32c1ac055ea2d85a156731c1f1 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 12 Sep 2023 21:31:32 -0600 Subject: [PATCH] Combining Tag usage counts in App. Converting Tag edit table to SortableTable. --- app/src/Tags.js | 50 +++++++++++++++------------------------- wrolpi/tags.py | 29 ++++++++++++++--------- wrolpi/test/test_tags.py | 4 ++-- 3 files changed, 39 insertions(+), 44 deletions(-) diff --git a/app/src/Tags.js b/app/src/Tags.js index 288dd394..acca468d 100644 --- a/app/src/Tags.js +++ b/app/src/Tags.js @@ -9,10 +9,7 @@ import { GridRow, Label, LabelGroup, - TableBody, TableCell, - TableHeader, - TableHeaderCell, TableRow, } from "semantic-ui-react"; import {APIButton, contrastingColor, ErrorMessage, scrollToTopOfElement} from "./components/Common"; @@ -25,8 +22,7 @@ import { ModalActions, ModalContent, ModalHeader, - Segment, - Table + Segment } from "./components/Theme"; import _ from "lodash"; import {HexColorPicker} from "react-colorful"; @@ -34,6 +30,7 @@ import {useRecurringTimeout} from "./hooks/customHooks"; import {Media, ThemeContext} from "./contexts/contexts"; import {Link, useNavigate} from "react-router-dom"; import {TagPlaceholder} from "./components/Placeholder"; +import {SortableTable} from "./components/SortableTable"; export const TagsContext = React.createContext({ NameToTagLabel: null, @@ -151,7 +148,7 @@ export const useTagsInterval = () => { function EditTagRow({tag, onDelete, onEdit}) { const {NameToTagLabel} = React.useContext(TagsContext); - const {name, color, id, count} = tag; + const {name, color, id, file_group_count, zim_entry_count} = tag; const deleteConfirm = <> ; - const countLabel = ; + const countColor = (file_group_count + zim_entry_count) > 0 ? 'black' : 'grey'; + const countLabel = ; return {deleteConfirm} @@ -226,11 +224,12 @@ function EditTagsModal() { setTagColor(DEFAULT_TAG_COLOR); } - let content = ; - if (tags && tags.length) { - content = tags.map(i => ); - } + const tableHeaders = [ + {key: 'delete', text: 'Delete', sortBy: null, width: 2}, + {key: 'edit', text: 'Edit', sortBy: null, width: 2}, + {key: 'name', text: 'Name', sortBy: 'name', width: 8}, + {key: 'count', text: 'Count', sortBy: 'file_group_count', width: 2}, + ]; return <> Save - - - - Delete - Edit - Tag - - {(className, renderChildren) => { - return renderChildren ? - Count - : null; - }} - - - - - {content} - -
+ + } + rowKey='name' + tableHeaders={tableHeaders} + />