Skip to content

TagSpaces is an offline, open source, document manager with tagging support

add settings for reorder tags (#1534)

Stanimir2f8b2de7baeb
diff --git a/app/components/TagContainer.tsx b/app/components/TagContainer.tsx
index f81b86937..aee73b0c9 100644
--- a/app/components/TagContainer.tsx
+++ b/app/components/TagContainer.tsx
@@ -49,6 +49,7 @@ interface Props {
addTags?: (paths: Array<string>, tags: Array<TS.Tag>) => void;
moveTag?: () => void;
selectedEntries?: Array<TS.FileSystemEntry>;
+ reorderTags?: boolean;
}
const TagContainer = (props: Props) => {
diff --git a/app/components/TagContainerDnd.tsx b/app/components/TagContainerDnd.tsx
index c1e6834f2..c283e8f79 100644
--- a/app/components/TagContainerDnd.tsx
+++ b/app/components/TagContainerDnd.tsx
@@ -134,7 +134,7 @@ const boxTarget = {
// but it's good here for the sake of performance
// to avoid expensive index searches.
dragItem.index = hoverIndex;
- } else if (props.entryPath) {
+ } else if (props.reorderTags && props.entryPath) {
// sort fileSystemEntries tags
const dragIndex = dragItem.index;
const hoverIndex = props.index;
@@ -168,7 +168,7 @@ const boxTarget = {
return;
}
} else {
- //TODO check if sidecar tag exist in file (reorder only if exist)
+ // TODO check if sidecar tag exist in file (reorder only if exist)
}
dragItem.tag.position = hoverIndex;
@@ -203,6 +203,7 @@ interface Props {
deleteIcon?: Object;
selectedEntries: Array<TS.FileSystemEntry>;
tagContainerRef?: string;
+ reorderTags?: boolean;
}
const TagContainerDnd = (props: Props) => {
@@ -218,7 +219,8 @@ const TagContainerDnd = (props: Props) => {
connectDropTarget,
addTags,
tagMode,
- tagContainerRef
+ tagContainerRef,
+ reorderTags
} = props;
// Use empty image as a drag preview so browsers don't draw it
@@ -242,6 +244,7 @@ const TagContainerDnd = (props: Props) => {
entryPath={entryPath}
isDragging={isDragging}
selectedEntries={selectedEntries}
+ reorderTags={reorderTags}
/>
</span>
)
diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsx
index b67093410..41b51bd21 100644
--- a/app/components/dialogs/settings/SettingsGeneral.tsx
+++ b/app/components/dialogs/settings/SettingsGeneral.tsx
@@ -40,8 +40,9 @@ import {
getPersistTagsInSidecarFile,
getSettings
} from '-/reducers/settings';
-import ColorPickerDialog from '../ColorPickerDialog';
-import TransparentBackground from '../../TransparentBackground';
+import ColorPickerDialog from '-/components/dialogs/ColorPickerDialog';
+import TransparentBackground from '-/components/TransparentBackground';
+import { BetaLabel } from '-/components/HelperComponents';
import AppConfig from '-/config';
import PlatformIO from '-/services/platform-io';
@@ -72,6 +73,7 @@ interface Props {
setCurrentTheme: (theme: string) => void;
setLanguage: (language: string) => void;
setCheckForUpdates: (check: boolean) => void;
+ reorderTags: (check: boolean) => void;
setUseTrashCan: (useTrashCan: boolean) => void;
setPersistTagsInSidecarFile: (tagInSidecar: boolean) => void;
setAddTagsToLibrary: (addTagsToLibrary: boolean) => void;
@@ -225,6 +227,21 @@ const SettingsGeneral = (props: Props) => {
checked={props.settings.checkForUpdates}
/>
</ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText
+ primary={
+ <>
+ {i18n.t('core:reorderTags')}
+ <BetaLabel />
+ </>
+ }
+ />
+ <Switch
+ data-tid="reorderTagsTID"
+ onClick={() => props.reorderTags(!props.settings.reorderTags)}
+ checked={props.settings.reorderTags}
+ />
+ </ListItem>
<ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('core:addTagsToLibrary')} />
<Switch
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 3402ab539..e3cf16a93 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -93,6 +93,7 @@
"openFileExternally": "Open File Externally",
"showUnixHiddenFiles": "Show files/directories with a dot(.) in front of the name (e.g. Unix, Linux, OS X hidden files)",
"checkForNewVersionOnStartup": "Check for new version on startup",
+ "reorderTags": "Enable changing the tag order with drag and drop",
"calculateTag": "Extracts the tags used in the current folder",
"tagDelimiter": "Tag delimiter (e.g. Filename[TAG1_TAG2], _ is the delimiter)",
"prefixTagContainer": "Prefix for the tag container (e.g. in 'Filename_[TAG1].txt', '_' is the prefix)",
diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsx
index a318dbbb3..ef932af72 100644
--- a/app/perspectives/grid-perspective/components/CellContent.tsx
+++ b/app/perspectives/grid-perspective/components/CellContent.tsx
@@ -70,6 +70,7 @@ interface Props {
handleGridCellDblClick: (event: Object, fsEntry: TS.FileSystemEntry) => void;
handleGridCellClick: (event: Object, fsEntry: TS.FileSystemEntry) => void;
editTagForEntry?: (path: string, tag: TS.Tag) => void;
+ reorderTags: boolean;
}
const CellContent = (props: Props) => {
@@ -389,6 +390,7 @@ const CellContent = (props: Props) => {
handleTagMenu={handleTagMenu}
selectedEntries={selectedEntries}
editTagForEntry={props.editTagForEntry}
+ reorderTags={props.reorderTags}
/>
);
@@ -443,6 +445,12 @@ const CellContent = (props: Props) => {
);
};
+function mapStateToProps(state) {
+ return {
+ reorderTags: state.settings.reorderTags
+ };
+}
+
function mapActionCreatorsToProps(dispatch) {
return bindActionCreators(
{
@@ -452,4 +460,4 @@ function mapActionCreatorsToProps(dispatch) {
);
}
-export default connect(undefined, mapActionCreatorsToProps)(CellContent);
+export default connect(mapStateToProps, mapActionCreatorsToProps)(CellContent);
diff --git a/app/reducers/settings-default.ts b/app/reducers/settings-default.ts
index e7e7048f1..0ad42e023 100644
--- a/app/reducers/settings-default.ts
+++ b/app/reducers/settings-default.ts
@@ -139,6 +139,7 @@ export default {
'<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">body{overflow:auto;width:100%;height:100%;font:13.34px Ubuntu,arial,clean,sans-serif;color:#000;line-height:1.4em;background-color:#fff;padding:15px}p{margin:1em 0;line-height:1.5em}table{font:100%;margin:1em}table th{border-bottom:1px solid #bbb;padding:.2em 1em}table td{border-bottom:1px solid #ddd;padding:.2em 1em}input[type=image],input[type=password],input[type=text],textarea{font:99% helvetica,arial,freesans,sans-serif}option,select{padding:0 .25em}optgroup{margin-top:.5em}code,pre{font:12px Monaco, Courier ,monospace}pre{margin:1em 0;font-size:12px;background-color:#eee;border:1px solid #ddd;padding:5px;line-height:1.5em;color:#444;overflow:auto;-webkit-box-shadow:rgba(0,0,0,.07) 0 1px 2px inset;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}pre code{padding:0;font-size:12px;background-color:#eee;border:none}code{font-size:12px;background-color:#f8f8ff;color:#444;padding:0 .2em;border:1px solid #dedede}img{border:0;max-width:100%}abbr{border-bottom:none}a{color:#4183c4;text-decoration:none}a:hover{text-decoration:underline}a code,a:link code,a:visited code{color:#4183c4}h2,h3{margin:1em 0}h1,h2,h3,h4,h5,h6{border:0}h1{font-size:170%;border-top:4px solid #aaa;padding-top:.5em;margin-top:1.5em}h1:first-child{margin-top:0;padding-top:.25em;border-top:none}h2{font-size:150%;margin-top:1.5em;border-top:4px solid #e0e0e0;padding-top:.5em}h3{font-size:130%;margin-top:1em}h4{font-size:120%;margin-top:1em}h5{font-size:115%;margin-top:1em}h6{font-size:110%;margin-top:1em}hr{border:1px solid #ddd}ol,ul{margin:1em 0 1em 2em}ol li,ul li{margin-top:.5em;margin-bottom:.5em}ol ol,ol ul,ul ol,ul ul{margin-top:0;margin-bottom:0}blockquote{margin:1em 0;border-left:5px solid #ddd;padding-left:.6em;color:#555}dt{font-weight:700;margin-left:1em}dd{margin-left:2em;margin-bottom:1em}</style></head><body></body></html>',
showUnixHiddenEntries: false,
checkForUpdates: true,
+ reorderTags: false,
coloredFileExtension: false,
loadsLocationMetaData: false,
searchInSubfolders: true,
diff --git a/app/reducers/settings.ts b/app/reducers/settings.ts
index 497283bca..f993b45d4 100644
--- a/app/reducers/settings.ts
+++ b/app/reducers/settings.ts
@@ -38,6 +38,7 @@ export const types = {
SET_TAG_DELIMITER: 'SETTINGS/SET_TAG_DELIMITER',
SET_MAX_SEARCH_RESULT: 'SETTINGS/SET_MAX_SEARCH_RESULT',
SET_CHECKFORUPDATES: 'SETTINGS/SET_CHECKFORUPDATES',
+ SET_REORDER_TAGS: 'SETTINGS/SET_REORDER_TAGS',
SET_USEDEFAULTLOCATION: 'SETTINGS/SET_USEDEFAULTLOCATION',
SET_COLOREDFILEEXTENSION: 'SETTINGS/SET_COLOREDFILEEXTENSION',
SET_SHOWTAGAREAONSTARTUP: 'SETTINGS/SET_SHOWTAGAREAONSTARTUP',
@@ -155,6 +156,9 @@ export default (state: any = defaultSettings, action: any) => {
case types.SET_CHECKFORUPDATES: {
return { ...state, checkForUpdates: action.checkForUpdates };
}
+ case types.SET_REORDER_TAGS: {
+ return { ...state, reorderTags: action.reorderTags };
+ }
case types.SET_USEDEFAULTLOCATION: {
return { ...state, useDefaultLocation: action.useDefaultLocation };
}
@@ -445,6 +449,10 @@ export const actions = {
type: types.SET_CHECKFORUPDATES,
checkForUpdates
}),
+ reorderTags: (reorderTags: boolean) => ({
+ type: types.SET_REORDER_TAGS,
+ reorderTags
+ }),
setLanguage: (language: string) => ({ type: types.SET_LANGUAGE, language }),
setUseDefaultLocation: (useDefaultLocation: boolean) => ({
type: types.SET_USEDEFAULTLOCATION,