Skip to content

Commit

Permalink
Document Component: Show active filters #678
Browse files Browse the repository at this point in the history
  • Loading branch information
ComLock committed Dec 22, 2022
1 parent c954cfd commit 1bb047a
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/main/resources/assets/react/components/HoverPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function HoverPopup ({
trigger={<Button
basic={!open}
circular
color='black'
icon={icon}
size='medium'
/>}
Expand Down
112 changes: 109 additions & 3 deletions src/main/resources/assets/react/document/Documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
import ReactHtmlParser from 'react-html-parser';
import {Slider} from 'react-semantic-ui-range';
import {
Breadcrumb,
Button,
Divider,
Dropdown,
Form,
Grid,
Expand Down Expand Up @@ -37,6 +39,8 @@ import {
} from './useDocumentsState';

// import {FIELD_PATH_META} from '/lib/explorer/constants'; // TODO setup build system so this import works


const FIELD_PATH_META = 'document_metadata';


Expand Down Expand Up @@ -133,6 +137,7 @@ export function Documents({
<Form.Group style={{margin:0}}>
<Input
icon
disabled={loading}
loading={loading}
onChange={(
_event :React.ChangeEvent<HTMLInputElement>,
Expand Down Expand Up @@ -169,6 +174,7 @@ export function Documents({
<Table.Row verticalAlign='middle'>
<Table.Cell collapsing>
<Radio
disabled={loading}
label={operatorState}
onChange={(
_event :React.ChangeEvent<HTMLInputElement>,
Expand Down Expand Up @@ -248,6 +254,7 @@ export function Documents({
style={{marginTop:6}}
value={selectedCollections}
/>}
disabled={loading}
header='Collections'
icon='database'
open={collectionsHoverOpen}
Expand Down Expand Up @@ -275,6 +282,7 @@ export function Documents({
start: 0 // Explicitly reset to 0 when documentTypes changes
});
}}
disabled={loading}
options={documentTypeOptions}
search
selection
Expand All @@ -300,6 +308,7 @@ export function Documents({
style={{marginTop:6}}
value={undefined}
/>}
disabled={loading}
header='Languages'
icon='language'
open={false}
Expand Down Expand Up @@ -327,6 +336,7 @@ export function Documents({
start // Keep start when columns changes
});
}}
disabled={loading}
options={columnOptions}
search
selection
Expand Down Expand Up @@ -360,6 +370,7 @@ export function Documents({
start: 0 // Explicitly reset to 0 when perPage changes
});
}}
disabled={loading}
options={[5,10,25,50,100].map(key => ({key, text: `${key}`, value: key}))}
selection
style={{marginTop:6}}
Expand Down Expand Up @@ -400,9 +411,104 @@ export function Documents({
</Grid.Column>
</Grid.Row>
</Grid>
{searchedString
? <Segment basic>Searched for <b>{searchedString}</b> and found {documentsRes.total} matching documents.</Segment>
: null}
{
searchedString
? <Segment basic>Searched for <b>{searchedString}</b> and found {documentsRes.total} matching documents.</Segment>
: null
}
{
selectedCollections.length || selectedDocumentTypes.length
? <Table basic compact className='bls-n brs-n'>
<Table.Body>
<Table.Row verticalAlign='middle'>
<Table.Cell collapsing><Icon name='filter'/></Table.Cell>
<Table.Cell>
{(() => {
const sections = [];
for (let i = 0; i < selectedCollections.length; i++) {
const collectionName = selectedCollections[i];
sections.push({
content: <Button
className='translucent'
compact
content={collectionName}
icon='database'
onClick={() => {
const newSelectedCollections = JSON.parse(JSON.stringify(selectedCollections)) as typeof selectedCollections;
newSelectedCollections.splice(newSelectedCollections.indexOf(collectionName), 1);
setSelectedCollections(newSelectedCollections);
queryDocuments({
collectionsFilter: newSelectedCollections,
documentsTypesFilter: selectedDocumentTypes,
fragmentSize,
operator: operatorState,
perPage,
query,
selectedColumns,
start,
});
}}
size='small'/>,
key: `collection-${collectionName}`
});
} // for
for (let i = 0; i < selectedDocumentTypes.length; i++) {
const documentTypeName = selectedDocumentTypes[i];
sections.push({
content: <Button
className='translucent'
compact
content={documentTypeName}
icon='code file'
onClick={() => {
const newSelectedDocumentTypes = JSON.parse(JSON.stringify(selectedDocumentTypes)) as typeof selectedDocumentTypes;
newSelectedDocumentTypes.splice(newSelectedDocumentTypes.indexOf(documentTypeName), 1);
setSelectedDocumentTypes(newSelectedDocumentTypes);
queryDocuments({
collectionsFilter: selectedDocumentTypes,
documentsTypesFilter: newSelectedDocumentTypes,
fragmentSize,
operator: operatorState,
perPage,
query,
selectedColumns,
start,
});
}}
size='small'/>,
key: `documentType-${documentTypeName}`
});
} // for
return <Breadcrumb
icon='right angle'
sections={sections}
/>;
})()}
</Table.Cell>
<Table.Cell collapsing><Button
className='translucent'
compact
icon='close'
onClick={() => {
setSelectedCollections([]);
setSelectedDocumentTypes([]);
queryDocuments({
collectionsFilter: [],
documentsTypesFilter: [],
fragmentSize,
operator: operatorState,
perPage,
query,
selectedColumns,
start,
});
}}
size='small'/></Table.Cell>
</Table.Row>
</Table.Body>
</Table>
: null
}
<Table celled collapsing compact selectable singleLine striped>
<Table.Header>
<Table.Row>
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/assets/style/components/_button.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ui.button
&.translucent:not(:active,:focus,:hover)
background-color: transparent
7 changes: 7 additions & 0 deletions src/main/resources/assets/style/components/_table.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.ui.table
&,
&.basic
&.bls-n
border-left-style: none
&.brs-n
border-right-style: none
10 changes: 9 additions & 1 deletion src/main/resources/assets/style/main.sass
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@import '/components/_addOrEditLocalFieldModal.sass'
@import '/components/_button.sass'
@import '/components/_fieldsList.sass'
@import '/components/_menu.sass'
@import '/components/_menuItem.sass'
@import '/components/_form.sass'
@import '/components/_popup.sass'
@import '/components/_page.sass'
@import '/components/_table.sass'
@import '/components/_transition.sass'
@import '/features/_layout.sass'

Expand Down Expand Up @@ -35,9 +37,15 @@ th.disabled
.bgc-y
background-color: yellow

// .bls-n
// border-left-style: none
// .brs-n
// border-right-style: none
// .c-bl
// color: blue
//
// .c-db
// color: darkblue
Expand Down

0 comments on commit 1bb047a

Please sign in to comment.