TagSpaces is an offline, open source, document manager with tagging support
improving search
Ilian Sapundshiev2968fd188d43
diff --git a/app/components/Search.tsx b/app/components/Search.tsxindex 951b51b1d..35eb8a57d 100644--- a/app/components/Search.tsx+++ b/app/components/Search.tsx@@ -30,7 +30,6 @@ import AudioIcon from '@material-ui/icons/MusicVideo';import VideoIcon from '@material-ui/icons/OndemandVideo';import ArchiveIcon from '@material-ui/icons/Archive';import FolderIcon from '@material-ui/icons/FolderOpen';-import LocationIcon from '@material-ui/icons/WorkOutline';import UntaggedIcon from '@material-ui/icons/LabelOffOutlined';import FileIcon from '@material-ui/icons/InsertDriveFileOutlined';import ClearSearchIcon from '@material-ui/icons/Clear';@@ -51,6 +50,7 @@ import ButtonGroup from '@material-ui/core/ButtonGroup';import ToggleButton from '@material-ui/lab/ToggleButton';import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';import OpenLocationCode from 'open-location-code-typescript';+import { FormControlLabel, Switch } from '@material-ui/core';import TagsSelect from './TagsSelect';import CustomLogo from './CustomLogo';import { actions as AppActions, getDirectoryPath } from '../reducers/app';@@ -103,6 +103,7 @@ interface State {tagPlaceLong: number | null;tagPlaceRadius: number;fileSize: string;+ forceIndexing: boolean;searchMenuOpened: boolean;searchMenuAnchorEl: Element | null;}@@ -126,6 +127,7 @@ class Search extends React.Component<Props, State> {tagPlaceLat: null,tagPlaceLong: null,tagPlaceRadius: 0,+ forceIndexing: false,fileSize: '',searchMenuOpened: false,searchMenuAnchorEl: null@@ -282,6 +284,7 @@ class Search extends React.Component<Props, State> {tagPlaceLat: null,tagPlaceLong: null,tagPlaceRadius: 0,+ forceIndexing: false,fileSize: ''},() => this.props.loadDirectoryContent(this.props.currentDirectory)@@ -316,7 +319,8 @@ class Search extends React.Component<Props, State> {tagPlaceLong: this.state.tagPlaceLong,tagPlaceRadius: this.state.tagPlaceRadius,maxSearchResults: this.props.maxSearchResults,- currentDirectory: this.props.currentDirectory+ currentDirectory: this.props.currentDirectory,+ forceIndexing: this.state.forceIndexing};console.log('Search object: ' + JSON.stringify(searchQuery));if (this.state.searchBoxing === 'global') {@@ -381,11 +385,6 @@ class Search extends React.Component<Props, State> {style={{ marginTop: 10 }}disabled={indexing}>- {/* <InputLabel htmlFor="textQuery">- {this.state.searchBoxing === 'location'- ? i18n.t('searchPlaceholder')- : i18n.t('searchCurrentFolderWithSubFolders')}- </InputLabel> */}<Inputid="textQuery"name="textQuery"@@ -395,28 +394,13 @@ class Search extends React.Component<Props, State> {}}onKeyDown={this.startSearch}title={i18n.t('core:searchWordsWithInterval')}- endAdornment={+ endAdornment={(<InputAdornment position="end">- {/* <IconButton- style={{ marginRight: -15 }}- onClick={this.toggleSearchBoxing}- title={- this.state.searchBoxing === 'location'- ? i18n.t('searchCurrentFolderWithSubFolders')- : i18n.t('searchPlaceholder')- }- >- {this.state.searchBoxing === 'location' ? (- <FolderIcon />- ) : (- <LocationIcon />- )}- </IconButton> */}<IconButton onClick={this.clearSearch}><ClearSearchIcon /></IconButton></InputAdornment>- }+ )}/></FormControl><FormControl className={classes.formControl} disabled={indexing}>@@ -431,20 +415,33 @@ class Search extends React.Component<Props, State> {value="location"title={i18n.t('searchPlaceholder')}>- Location+ {i18n.t('location')}</ToggleButton><ToggleButtonvalue="folder"title={i18n.t('searchCurrentFolderWithSubFolders')}>- Folder+ {i18n.t('folder')}</ToggleButton>- <ToggleButton value="global" title="Search in all locations">- Global+ <ToggleButton value="global" title={i18n.t('searchInAllLocations')}>+ {i18n.t('globalSearch')}+ <sub style={{ color: 'red'}}>BETA</sub></ToggleButton></ToggleButtonGroup></FormControl><br />+ {this.state.searchBoxing === 'global' && (+ <FormControlLabel+ control={(+ <Switch+ checked={this.state.forceIndexing}+ onChange={() => this.setState(prevState => ({forceIndexing: !prevState.forceIndexing}))}+ name="forceIndexing"+ />+ )}+ label="Force reindexing all locations"+ />+ )}<FormControl className={classes.formControl} disabled={indexing}><TagsSelectplaceholderText={i18n.t('core:selectTags')}@@ -720,7 +717,6 @@ class Search extends React.Component<Props, State> {disabled={indexing}id="searchButton"variant="outlined"- size="small"color="primary"onClick={this.clickSearchButton}style={{ width: '100%' }}@@ -730,7 +726,6 @@ class Search extends React.Component<Props, State> {: i18n.t('searchTitle')}</Button><Button- size="small"variant="outlined"color="secondary"onClick={this.clearSearch}diff --git a/app/components/TagsSelect.tsx b/app/components/TagsSelect.tsxindex b06f87626..402015f44 100644--- a/app/components/TagsSelect.tsx+++ b/app/components/TagsSelect.tsx@@ -84,7 +84,7 @@ const TagsSelect = (props: Props) => {reason: string) {if (reason === 'select-option') {- props.handleChange(props.tagSearchType, selectedTags);+ props.handleChange(props.tagSearchType, selectedTags, reason);} else if (reason === 'create-option') {if (selectedTags &&@@ -100,12 +100,12 @@ const TagsSelect = (props: Props) => {props.allTags.push(newTag);selectedTags.pop();const newTags = [...selectedTags, newTag];- props.handleChange(props.tagSearchType, newTags);+ props.handleChange(props.tagSearchType, newTags, reason);}} else if (reason === 'remove-value') {- props.handleChange(props.tagSearchType, selectedTags);+ props.handleChange(props.tagSearchType, selectedTags, reason);} else if (reason === 'clear') {- props.handleChange(props.tagSearchType, []);+ props.handleChange(props.tagSearchType, [], reason);}}@@ -127,9 +127,7 @@ const TagsSelect = (props: Props) => {defaultBackgroundColor,defaultTextColor,placeholderText = '',- label,- tagSearchType,- handleChange+ label} = props;return (@@ -147,13 +145,13 @@ const TagsSelect = (props: Props) => {key={tag.title + index}tag={tag}tagMode="remove"- handleRemoveTag={(event, tag) => {+ handleRemoveTag={(event, cTag) => {for (let i = 0; i < tags.length; i += 1) {- if (tags[i].title === tag.title) {+ if (tags[i].title === cTag.title) {tags.splice(i, 1);}}- handleChange(tagSearchType, [...tags]);+ handleTagChange(event, [...tags], 'remove-value' )}}/>))diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 0d0462be0..e292961f6 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -398,7 +398,8 @@"atLeastOneOfTheseTags": "At least one of these tags","noneOfTheseTags": "None of these tags","collectTagsFromLocation": "Collect Tags From Current Location",- "searchCurrentFolderWithSubFolders": "Search in folder with sub folders",+ "searchCurrentFolderWithSubFolders": "Search in the current folder including sub folders",+ "searchInAllLocations": "Search in all locations","dndDisabledReadOnlyMode": "Importing files is disabled because the location is in read-only mode.","lastModifiedSearchTitle": "Last modified date","sizeSearchTitle": "File size",@@ -449,5 +450,8 @@"getLatestVersionPro": "Please download the latest version from the link in the purchase confirmation email.","noFileButFoldersFound": "Some folders found! Turn on the folder visibility from the perspective's toolbar to view them.","selectTags": "Select tags",+ "location": "Location",+ "folder": "Folder",+ "globalSearch": "Global","-": "-"}