mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 15:36:18 -05:00
Adding button to bulk tag file groups for collection items. Always displaying selection column on collection page tables.
This commit is contained in:
parent
4b34d37838
commit
1294b14c10
4 changed files with 63 additions and 36 deletions
|
|
@ -82,6 +82,7 @@ import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
|||
import _ from "lodash";
|
||||
import {Media, ThemeContext} from "../contexts/contexts";
|
||||
import {Button, Card, darkTheme, Header, Loader, Placeholder, Popup, Segment, Statistic, Tab} from "./Theme";
|
||||
import {BulkTagModal} from "./BulkTagModal";
|
||||
import {taggedImageLabel, TagsSelector} from "../Tags";
|
||||
import {toast} from "react-semantic-toasts-2";
|
||||
import {API_ARCHIVE_UPLOAD_URI, Downloaders} from "./Vars";
|
||||
|
|
@ -1080,6 +1081,7 @@ function ArchiveSettingsPage() {
|
|||
|
||||
function ArchivesPage() {
|
||||
const [selectedArchives, setSelectedArchives] = useState([]);
|
||||
const [bulkTagOpen, setBulkTagOpen] = useState(false);
|
||||
const searchInputRef = React.useRef();
|
||||
|
||||
useHotkeys('f', (e) => {
|
||||
|
|
@ -1148,7 +1150,17 @@ function ArchivesPage() {
|
|||
setSelectedArchives([]);
|
||||
}
|
||||
|
||||
const onBulkTagComplete = async () => {
|
||||
await fetchArchives();
|
||||
setSelectedArchives([]);
|
||||
}
|
||||
|
||||
const selectElm = <div style={{marginTop: '0.5em'}}>
|
||||
<Button
|
||||
color='violet'
|
||||
disabled={_.isEmpty(selectedArchives)}
|
||||
onClick={() => setBulkTagOpen(true)}
|
||||
>Tag</Button>
|
||||
<APIButton
|
||||
color='red'
|
||||
disabled={_.isEmpty(selectedArchives)}
|
||||
|
|
@ -1170,9 +1182,15 @@ function ArchivesPage() {
|
|||
>
|
||||
Clear
|
||||
</Button>
|
||||
<BulkTagModal
|
||||
open={bulkTagOpen}
|
||||
onClose={() => setBulkTagOpen(false)}
|
||||
paths={selectedArchives}
|
||||
onComplete={onBulkTagComplete}
|
||||
/>
|
||||
</div>;
|
||||
|
||||
const {body, paginator, selectButton, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
||||
const {body, paginator, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
||||
{
|
||||
files: archives,
|
||||
activePage: activePage,
|
||||
|
|
@ -1222,11 +1240,10 @@ function ArchivesPage() {
|
|||
<Media at='mobile'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={2}>{selectButton}</Grid.Column>
|
||||
<Grid.Column width={2}>{viewButton}</Grid.Column>
|
||||
<Grid.Column width={4}>{limitDropdown}</Grid.Column>
|
||||
<Grid.Column width={2}>{tagQuerySelector}</Grid.Column>
|
||||
<Grid.Column width={6}><SortButton sorts={archiveOrders}/></Grid.Column>
|
||||
<Grid.Column width={8}><SortButton sorts={archiveOrders}/></Grid.Column>
|
||||
</Grid.Row>
|
||||
<Grid.Row width={16}>
|
||||
<Grid.Column>{searchInput}</Grid.Column>
|
||||
|
|
@ -1236,12 +1253,11 @@ function ArchivesPage() {
|
|||
<Media greaterThanOrEqual='tablet'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={1}>{selectButton}</Grid.Column>
|
||||
<Grid.Column width={1}>{viewButton}</Grid.Column>
|
||||
<Grid.Column width={2}>{limitDropdown}</Grid.Column>
|
||||
<Grid.Column width={1}>{tagQuerySelector}</Grid.Column>
|
||||
<Grid.Column width={3}><SortButton sorts={archiveOrders}/></Grid.Column>
|
||||
<Grid.Column width={8}>{searchInput}</Grid.Column>
|
||||
<Grid.Column width={9}>{searchInput}</Grid.Column>
|
||||
</Grid.Row>
|
||||
</Grid>
|
||||
</Media>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
useTitle
|
||||
} from "./Common";
|
||||
import {Button, darkTheme, Header, Icon, Segment, Statistic, Tab} from "./Theme";
|
||||
import {BulkTagModal} from "./BulkTagModal";
|
||||
import {FilesView} from "./Files";
|
||||
import {useAuthors, useDoc, useOneQuery, useSearchDocs, useSubjects} from "../hooks/customHooks";
|
||||
import {TagsSelector} from "../Tags";
|
||||
|
|
@ -45,6 +46,7 @@ function DocsPage() {
|
|||
} = useSearchDocs();
|
||||
|
||||
const [selectedDocs, setSelectedDocs] = useState([]);
|
||||
const [bulkTagOpen, setBulkTagOpen] = useState(false);
|
||||
|
||||
const onSelect = (path, checked) => {
|
||||
if (checked && path) {
|
||||
|
|
@ -71,7 +73,14 @@ function DocsPage() {
|
|||
setSelectedDocs([]);
|
||||
}
|
||||
|
||||
const onBulkTagComplete = async () => {
|
||||
await fetchDocs();
|
||||
setSelectedDocs([]);
|
||||
}
|
||||
|
||||
const selectElm = <div style={{marginTop: '0.5em'}}>
|
||||
<Button color='violet' disabled={_.isEmpty(selectedDocs)}
|
||||
onClick={() => setBulkTagOpen(true)}>Tag</Button>
|
||||
<APIButton
|
||||
color='red'
|
||||
disabled={_.isEmpty(selectedDocs)}
|
||||
|
|
@ -83,6 +92,12 @@ function DocsPage() {
|
|||
<Button color='grey' onClick={invertSelection} disabled={_.isEmpty(docs)}>Invert</Button>
|
||||
<Button color='yellow' onClick={clearSelection}
|
||||
disabled={_.isEmpty(docs) || _.isEmpty(selectedDocs)}>Clear</Button>
|
||||
<BulkTagModal
|
||||
open={bulkTagOpen}
|
||||
onClose={() => setBulkTagOpen(false)}
|
||||
paths={selectedDocs}
|
||||
onComplete={onBulkTagComplete}
|
||||
/>
|
||||
</div>;
|
||||
|
||||
let docOrders = [
|
||||
|
|
@ -94,7 +109,7 @@ function DocsPage() {
|
|||
docOrders = [{value: 'rank', text: 'Rank'}, ...docOrders];
|
||||
}
|
||||
|
||||
const {body, paginator, selectButton, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
||||
const {body, paginator, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
||||
{
|
||||
files: docs,
|
||||
activePage: activePage,
|
||||
|
|
@ -122,11 +137,10 @@ function DocsPage() {
|
|||
<Media at='mobile'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={2}>{selectButton}</Grid.Column>
|
||||
<Grid.Column width={2}>{viewButton}</Grid.Column>
|
||||
<Grid.Column width={4}>{limitDropdown}</Grid.Column>
|
||||
<Grid.Column width={2}>{tagQuerySelector}</Grid.Column>
|
||||
<Grid.Column width={6}><SortButton sorts={docOrders}/></Grid.Column>
|
||||
<Grid.Column width={8}><SortButton sorts={docOrders}/></Grid.Column>
|
||||
</Grid.Row>
|
||||
<Grid.Row width={16}>
|
||||
<Grid.Column>{searchInput}</Grid.Column>
|
||||
|
|
@ -136,12 +150,11 @@ function DocsPage() {
|
|||
<Media greaterThanOrEqual='tablet'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={1}>{selectButton}</Grid.Column>
|
||||
<Grid.Column width={1}>{viewButton}</Grid.Column>
|
||||
<Grid.Column width={2}>{limitDropdown}</Grid.Column>
|
||||
<Grid.Column width={1}>{tagQuerySelector}</Grid.Column>
|
||||
<Grid.Column width={3}><SortButton sorts={docOrders}/></Grid.Column>
|
||||
<Grid.Column width={8}>{searchInput}</Grid.Column>
|
||||
<Grid.Column width={9}>{searchInput}</Grid.Column>
|
||||
</Grid.Row>
|
||||
</Grid>
|
||||
</Media>
|
||||
|
|
|
|||
|
|
@ -353,31 +353,19 @@ export function FilesView(
|
|||
) {
|
||||
const {view} = useSearchView();
|
||||
|
||||
let selectButton;
|
||||
const [selectOn, setSelectOn] = React.useState(false);
|
||||
const toggleSelectOn = () => setSelectOn(!selectOn);
|
||||
const selectButtonDisabled = view !== 'list';
|
||||
if (selectOn) {
|
||||
selectButton = <Button active disabled={selectButtonDisabled} icon='checkmark box'
|
||||
onClick={toggleSelectOn}/>;
|
||||
} else {
|
||||
selectButton = <Button icon='checkmark box' disabled={selectButtonDisabled}
|
||||
onClick={toggleSelectOn}/>;
|
||||
}
|
||||
|
||||
const paginator = <center style={{marginTop: '2em'}}>
|
||||
<Paginator activePage={activePage} totalPages={totalPages} onPageChange={setPage}/>
|
||||
</center>;
|
||||
|
||||
let body;
|
||||
if (view === 'list') {
|
||||
const footer = selectOn && selectElem ?
|
||||
const footer = selectElem ?
|
||||
<>
|
||||
<TableHeaderCell colSpan='3'>{selectElem}</TableHeaderCell>
|
||||
</> : null;
|
||||
body = <FileTable
|
||||
files={files}
|
||||
selectOn={selectOn}
|
||||
selectOn={true}
|
||||
onSelect={onSelect}
|
||||
footer={footer}
|
||||
selectedKeys={selectedKeys || []}
|
||||
|
|
@ -395,7 +383,6 @@ export function FilesView(
|
|||
return {
|
||||
body,
|
||||
paginator,
|
||||
selectButton,
|
||||
viewButton,
|
||||
limitDropdown,
|
||||
tagQuerySelector,
|
||||
|
|
@ -509,14 +496,13 @@ export function FileSearchFilterButton({size = 'medium'}) {
|
|||
|
||||
export function FilesSearchView({
|
||||
showView = true,
|
||||
showSelect = false,
|
||||
emptySearch = false,
|
||||
model,
|
||||
}) {
|
||||
|
||||
const {searchFiles, pages} = useSearchFiles(24, emptySearch, model);
|
||||
|
||||
const {body, paginator, selectButton, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
||||
const {body, paginator, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
||||
{
|
||||
files: searchFiles,
|
||||
activePage: pages.activePage,
|
||||
|
|
@ -534,8 +520,6 @@ export function FilesSearchView({
|
|||
<Media at='mobile'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
{showSelect &&
|
||||
<Grid.Column width={2}>{selectButton}</Grid.Column>}
|
||||
{showView &&
|
||||
<Grid.Column width={2}>{viewButton}</Grid.Column>}
|
||||
<Grid.Column width={4}>{limitDropdown}</Grid.Column>
|
||||
|
|
@ -546,8 +530,6 @@ export function FilesSearchView({
|
|||
<Media greaterThanOrEqual='tablet'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
{showSelect &&
|
||||
<Grid.Column width={1}>{selectButton}</Grid.Column>}
|
||||
{showView &&
|
||||
<Grid.Column width={1}>{viewButton}</Grid.Column>}
|
||||
<Grid.Column width={2}>{limitDropdown}</Grid.Column>
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import {FileRowTagIcon, FilesView} from "./Files";
|
|||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
import {Button, Card, Header, Loader, Modal, Placeholder, Popup, Segment, Statistic} from "./Theme";
|
||||
import {BulkTagModal} from "./BulkTagModal";
|
||||
import {
|
||||
deleteVideos,
|
||||
deleteCookies,
|
||||
|
|
@ -86,6 +87,7 @@ export function VideosPage() {
|
|||
const {channelId} = useParams();
|
||||
const {searchParams} = React.useContext(QueryContext);
|
||||
const [selectedVideos, setSelectedVideos] = useState([]);
|
||||
const [bulkTagOpen, setBulkTagOpen] = useState(false);
|
||||
const searchInputRef = React.useRef();
|
||||
|
||||
useHotkeys('f', (e) => {
|
||||
|
|
@ -171,7 +173,17 @@ export function VideosPage() {
|
|||
setSelectedVideos([]);
|
||||
}
|
||||
|
||||
const onBulkTagComplete = async () => {
|
||||
await fetchVideos();
|
||||
setSelectedVideos([]);
|
||||
}
|
||||
|
||||
const selectElm = <div style={{marginTop: '0.5em'}}>
|
||||
<Button
|
||||
color='violet'
|
||||
disabled={_.isEmpty(selectedVideos)}
|
||||
onClick={() => setBulkTagOpen(true)}
|
||||
>Tag</Button>
|
||||
<APIButton
|
||||
color='red'
|
||||
disabled={_.isEmpty(selectedVideos)}
|
||||
|
|
@ -193,9 +205,15 @@ export function VideosPage() {
|
|||
>
|
||||
Clear
|
||||
</Button>
|
||||
<BulkTagModal
|
||||
open={bulkTagOpen}
|
||||
onClose={() => setBulkTagOpen(false)}
|
||||
paths={selectedVideos}
|
||||
onComplete={onBulkTagComplete}
|
||||
/>
|
||||
</div>;
|
||||
|
||||
const {body, paginator, selectButton, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
||||
const {body, paginator, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
||||
{
|
||||
files: videos,
|
||||
activePage: activePage,
|
||||
|
|
@ -224,11 +242,10 @@ export function VideosPage() {
|
|||
<Media at='mobile'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={2}>{selectButton}</Grid.Column>
|
||||
<Grid.Column width={2}>{viewButton}</Grid.Column>
|
||||
<Grid.Column width={4}>{limitDropdown}</Grid.Column>
|
||||
<Grid.Column width={2}>{tagQuerySelector}</Grid.Column>
|
||||
<Grid.Column width={6}><SortButton sorts={videoOrders}/></Grid.Column>
|
||||
<Grid.Column width={8}><SortButton sorts={videoOrders}/></Grid.Column>
|
||||
</Grid.Row>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={16}>{searchInput}</Grid.Column>
|
||||
|
|
@ -238,12 +255,11 @@ export function VideosPage() {
|
|||
<Media greaterThanOrEqual='tablet'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={1}>{selectButton}</Grid.Column>
|
||||
<Grid.Column width={1}>{viewButton}</Grid.Column>
|
||||
<Grid.Column width={2}>{limitDropdown}</Grid.Column>
|
||||
<Grid.Column width={1}>{tagQuerySelector}</Grid.Column>
|
||||
<Grid.Column width={4}><SortButton sorts={videoOrders}/></Grid.Column>
|
||||
<Grid.Column width={7}>{searchInput}</Grid.Column>
|
||||
<Grid.Column width={8}>{searchInput}</Grid.Column>
|
||||
</Grid.Row>
|
||||
</Grid>
|
||||
</Media>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue