TagSpaces is an offline, open source, document manager with tagging support
polish: improve handling location tag groups
Ilian Sapundshiev49ddcfee4e56
diff --git a/app/components/dialogs/CreateTagGroupDialog.tsx b/app/components/dialogs/CreateTagGroupDialog.tsxindex f35de78a1..5d651fa0f 100644--- a/app/components/dialogs/CreateTagGroupDialog.tsx+++ b/app/components/dialogs/CreateTagGroupDialog.tsx@@ -18,6 +18,7 @@import React, { ChangeEvent, useReducer, useRef, useState } from 'react';import uuidv1 from 'uuid';+import withMobileDialog from '@material-ui/core/withMobileDialog';import Button from '@material-ui/core/Button';import TextField from '@material-ui/core/TextField';import DialogActions from '@material-ui/core/DialogActions';@@ -49,6 +50,8 @@ interface Props {saveTagInLocation: boolean;}+const defaultTagGroupLocation = 'TAG_LIBRARY';+const CreateTagGroupDialog = (props: Props) => {const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);const [displayTextColorPicker, setDisplayTextColorPicker] = useState<boolean>(@@ -103,7 +106,10 @@ const CreateTagGroupDialog = (props: Props) => {title: title.current,color: color.current,textcolor: textcolor.current,- locationId: locationId.current,+ locationId:+ locationId.current === defaultTagGroupLocation+ ? undefined+ : locationId.current,children: []});props.onClose();@@ -155,6 +161,7 @@ const CreateTagGroupDialog = (props: Props) => {cursor: 'pointer'},helpText: {+ marginTop: '15px',marginBottom: '5px',fontSize: '1rem'}@@ -182,27 +189,6 @@ const CreateTagGroupDialog = (props: Props) => {<DialogCloseButton onClose={onClose} /></DialogTitle><DialogContent>- {props.saveTagInLocation && (- <FormControl fullWidth={true} error={inputError}>- <Select- defaultValue={locationId.current}- onChange={(event: ChangeEvent<HTMLInputElement>) => {- locationId.current = event.target.value;- // rerender- forceUpdate();- }}- >- {props.locations.map(location => (- <MenuItem key={location.uuid} value={location.uuid}>- {location.name}- </MenuItem>- ))}- </Select>- <FormHelperText>- {i18n.t('core:tagGroupLocationHelper')}- </FormHelperText>- </FormControl>- )}<FormControl fullWidth={true} error={inputError}><TextFieldfullWidth={true}@@ -220,6 +206,33 @@ const CreateTagGroupDialog = (props: Props) => {</FormHelperText>)}</FormControl>+ {props.saveTagInLocation && (+ <FormControl fullWidth={true} error={inputError}>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagGroupLocation')}+ </FormHelperText>+ <Select+ defaultValue={defaultTagGroupLocation}+ onChange={(event: ChangeEvent<HTMLInputElement>) => {+ locationId.current = event.target.value;+ // rerender+ forceUpdate();+ }}+ >+ <MenuItem+ key={defaultTagGroupLocation}+ value={defaultTagGroupLocation}+ >+ {i18n.t('tagLibrary')}+ </MenuItem>+ {props.locations.map(location => (+ <MenuItem key={location.uuid} value={location.uuid}>+ {i18n.t('core:location') + ': ' + location.name}+ </MenuItem>+ ))}+ </Select>+ </FormControl>+ )}<FormControl fullWidth={true}><FormHelperText style={styles.helpText}>{i18n.t('core:tagBackgroundColor')}@@ -292,4 +305,6 @@ function mapStateToProps(state) {};}-export default connect(mapStateToProps)(CreateTagGroupDialog);+export default connect(mapStateToProps)(+ withMobileDialog()(CreateTagGroupDialog)+);diff --git a/app/components/dialogs/EditTagGroupDialog.tsx b/app/components/dialogs/EditTagGroupDialog.tsxindex e0e4ad7c4..8ecbbdb4a 100644--- a/app/components/dialogs/EditTagGroupDialog.tsx+++ b/app/components/dialogs/EditTagGroupDialog.tsx@@ -17,6 +17,7 @@*/import React, { ChangeEvent, useEffect, useState } from 'react';+import withMobileDialog from '@material-ui/core/withMobileDialog';import Button from '@material-ui/core/Button';import TextField from '@material-ui/core/TextField';import DialogActions from '@material-ui/core/DialogActions';@@ -37,6 +38,8 @@ import { getLocations } from '-/reducers/locations';import { Pro } from '-/pro';import DialogCloseButton from '-/components/dialogs/DialogCloseButton';+const defaultTagGroupLocation = 'TAG_LIBRARY';+interface Props {open: boolean;fullScreen?: boolean;@@ -55,7 +58,7 @@ const EditTagGroupDialog = (props: Props) => {const [inputError, setInputError] = useState<boolean>(false);const [applyChanges, setApplyChanges] = useState<boolean>(false);const [locationId, setLocationId] = useState<string>(- props.selectedTagGroupEntry.locationId+ props.selectedTagGroupEntry.locationId ?? defaultTagGroupLocation);const [title, setTitle] = useState<string>(props.selectedTagGroupEntry.title);const [color, setColor] = useState<string>(props.selectedTagGroupEntry.color);@@ -126,7 +129,6 @@ const EditTagGroupDialog = (props: Props) => {const renderTitle = () => (<DialogTitle style={{ overflow: 'visible' }}>{i18n.t('core:editTagGroupTitle')}- {` '${title}'`}<DialogCloseButton onClose={onClose} /></DialogTitle>);@@ -154,6 +156,7 @@ const EditTagGroupDialog = (props: Props) => {background: textcolor},helpText: {+ marginTop: '15px',marginBottom: '5px',fontSize: '1rem'}@@ -161,36 +164,18 @@ const EditTagGroupDialog = (props: Props) => {return (<DialogContent style={{ overflow: 'visible' }}>- {props.saveTagInLocation && (- <FormControl fullWidth={true} error={inputError}>- <Select- defaultValue={locationId}- onChange={(event: ChangeEvent<HTMLInputElement>) => {- setLocationId(event.target.value);- }}- >- {props.locations.map(location => (- <MenuItem key={location.uuid} value={location.uuid}>- {location.name}- </MenuItem>- ))}- </Select>- <FormHelperText>- {i18n.t('core:tagGroupLocationHelper')}- </FormHelperText>- </FormControl>- )}<FormControlfullWidth={true}error={inputError}style={{ overflow: 'visible' }}>+ <FormHelperText>{i18n.t('core:editTagGroupNewName')}</FormHelperText><TextFielderror={inputError}margin="dense"name="title"autoFocus- label={i18n.t('core:editTagGroupNewName')}+ // label={i18n.t('core:editTagGroupNewName')}onChange={handleTagGroupTitleChange}value={title}data-tid="editTagGroupInput"@@ -202,6 +187,31 @@ const EditTagGroupDialog = (props: Props) => {</FormHelperText>)}</FormControl>+ {props.saveTagInLocation && (+ <FormControl fullWidth={true} error={inputError}>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagGroupLocation')}+ </FormHelperText>+ <Select+ defaultValue={locationId}+ onChange={(event: ChangeEvent<HTMLInputElement>) => {+ setLocationId(event.target.value);+ }}+ >+ <MenuItem+ key={defaultTagGroupLocation}+ value={defaultTagGroupLocation}+ >+ {i18n.t('core:tagLibrary')}+ </MenuItem>+ {props.locations.map(location => (+ <MenuItem key={location.uuid} value={location.uuid}>+ {i18n.t('core:location') + ': ' + location.name}+ </MenuItem>+ ))}+ </Select>+ </FormControl>+ )}<FormControl fullWidth={true}><FormHelperText style={styles.helpText}>{i18n.t('core:tagBackgroundColor')}@@ -305,4 +315,4 @@ function mapStateToProps(state) {};}-export default connect(mapStateToProps)(EditTagGroupDialog);+export default connect(mapStateToProps)(withMobileDialog()(EditTagGroupDialog));diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex a58ba69bd..6d33088a5 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -596,5 +596,6 @@"moveFile": "Move","welcomeToTagSpaces": "Welcome to TagSpaces","startUsingTagSpaces": "Start using TagSpaces",+ "tagGroupLocation": "Store Tag Group in","-": "-"}