TagSpaces is an offline, open source, document manager with tagging support
fix: various issues in the tag library
Ilian Sapundshievb3e75a5a5c2b
diff --git a/app/components/TagContainerDnd.tsx b/app/components/TagContainerDnd.tsxindex d2da00b99..47431f4e7 100644--- a/app/components/TagContainerDnd.tsx+++ b/app/components/TagContainerDnd.tsx@@ -28,7 +28,7 @@ const boxSource = {beginDrag(props) {// console.log('beginDrag', props);return {- tagId: props.tag.id,+ tagTitle: props.tag.title,tag: props.tag,sourceTagGroupId: props.tagGroup ? props.tagGroup.uuid : undefined};@@ -47,7 +47,11 @@ const boxSource = {props.moveTag) {// console.log(`Dropped ${item.tagId} from ${item.sourceTagGroupId} into ${dropResult.tagGroupId}!`);- props.moveTag(item.tagId, item.sourceTagGroupId, dropResult.tagGroupId);+ props.moveTag(+ item.tagTitle,+ item.sourceTagGroupId,+ dropResult.tagGroupId+ );} else if (dropResult && dropResult.entryPath && props.addTags) {// console.log(`Dropped item: ${item.tag.title} onto file: ${dropResult.entryPath}!`);if (diff --git a/app/components/dialogs/EditTagDialog.tsx b/app/components/dialogs/EditTagDialog.tsxindex fad90aeac..0c62747ca 100644--- a/app/components/dialogs/EditTagDialog.tsx+++ b/app/components/dialogs/EditTagDialog.tsx@@ -35,7 +35,7 @@ interface Props {open: boolean;fullScreen?: boolean;onClose: () => void;- editTag: (tag: Tag, tagGroupId: string) => void;+ editTag: (tag: Tag, tagGroupId: string, origTitle: string) => void;selectedTag: Tag;selectedTagGroupEntry: TagGroup;}@@ -46,6 +46,7 @@ interface State {displayTextColorPicker: boolean;disableConfirmButton: boolean;title: string;+ origTitle: string;color: string;textcolor: string;modifiedDate: string;@@ -57,6 +58,7 @@ class EditTagDialog extends React.Component<Props, State> {displayTextColorPicker: false,inputError: false,disableConfirmButton: true,+ origTitle: '',title: '',color: '',textcolor: '',@@ -67,6 +69,7 @@ class EditTagDialog extends React.Component<Props, State> {if (open === true) {this.setState({disableConfirmButton: !selectedTag.title,+ origTitle: selectedTag.title,title: selectedTag.title,color: selectedTag.color,textcolor: selectedTag.textcolor,@@ -107,7 +110,8 @@ class EditTagDialog extends React.Component<Props, State> {color: this.state.color,textcolor: this.state.textcolor},- this.props.selectedTagGroupEntry.uuid+ this.props.selectedTagGroupEntry.uuid,+ this.state.origTitle);this.setState({ inputError: false, disableConfirmButton: true });this.props.onClose();diff --git a/app/components/menus/TagMenu.tsx b/app/components/menus/TagMenu.tsxindex e8d81a8e6..09897dda2 100644--- a/app/components/menus/TagMenu.tsx+++ b/app/components/menus/TagMenu.tsx@@ -83,7 +83,10 @@ const TagLibraryMenu = (props: Props) => {function confirmDeleteTag() {if (props.selectedTag && props.selectedTagGroupEntry) {- props.deleteTag(props.selectedTag.id, props.selectedTagGroupEntry.uuid);+ props.deleteTag(+ props.selectedTag.title,+ props.selectedTagGroupEntry.uuid+ );}}diff --git a/app/reducers/taglibrary.ts b/app/reducers/taglibrary.tsindex d7c4641ce..196b23fa8 100644--- a/app/reducers/taglibrary.ts+++ b/app/reducers/taglibrary.ts@@ -201,7 +201,7 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {.split(' ').join(',').split(','); // handle spaces around commas- // tags = [...new Set(tags)]; // remove duplicates+ tags = [...new Set(tags)]; // remove duplicatestags = tags.filter(tag => tag && tag.length > 0); // zero length tagsconst taggroupTags = state[indexForEditing].children;@@ -215,7 +215,6 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {...state[indexForEditing],children: taggroupTags.concat(tags.map(tagTitle => ({- id: uuidv1(),type:taggroupTags.length > 0 ? taggroupTags[0].type : 'sidecar',title: tagTitle.trim(),@@ -244,20 +243,18 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {let indexForUpdating = -1;state.forEach((tagGroup, index) => {if (tagGroup.uuid === action.uuid) {+ tagGroup.children.forEach((tag, tagIndex) => {+ if (tag.title === action.origTitle) {+ tagIndexForUpdating = tagIndex;+ }+ });indexForUpdating = index;}- tagGroup.children.forEach((tag, tagIndex) => {- if (tag.id === action.entry.id) {- tagIndexForUpdating = tagIndex;- }- });});if (tagIndexForUpdating >= 0) {- const modifiedEntry = extend(- { created_date: new Date() },- action.entry,- { modified_date: new Date() }- );+ const modifiedEntry = extend({ created_date: new Date() }, action.tag, {+ modified_date: new Date()+ });return [...state.slice(0, indexForUpdating),{@@ -281,7 +278,7 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {indexForEditing = index;}tagGroup.children.forEach((tag, tagIndex) => {- if (tag.id === action.tagID) {+ if (tag.title === action.tagTitle) {tagIndexForRemoving = tagIndex;}});@@ -381,7 +378,7 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {});if (indexFromGroup >= 0 && state[indexFromGroup].children) {state[indexFromGroup].children.forEach((tag, tagIndex) => {- if (tag.id === action.tagID) {+ if (tag.title === action.tagTitle) {tagIndexForRemoving = tagIndex;}return true;@@ -428,20 +425,7 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {};const tagsArr = [];tagGroup.children.forEach(tag => {- if (!tag.id) {- tag = {- id: uuidv1(),- type: tag.type,- title: tag.title,- functionality: tag.title,- color: tag.color,- textcolor: tag.textcolor,- description: tag.description,- icon: tag.icon,- style: tag.style- };- tagsArr.push(tag);- }+ tagsArr.push(tag);tagGroup.children = tagsArr;arr.push(tagGroup);});@@ -492,14 +476,15 @@ export const actions = {console.log(tag, parentTagGroupUuid);return { type: types.ADD_TAG, tag, uuid: parentTagGroupUuid };},- editTag: (entry: Tag, parentTagGroupUuid: Uuid) => ({+ editTag: (tag: Tag, parentTagGroupUuid: Uuid, origTitle: string) => ({type: types.UPDATE_TAG,- entry,- uuid: parentTagGroupUuid+ tag,+ uuid: parentTagGroupUuid,+ origTitle}),- deleteTag: (tagID: string, parentTagGroupUuid: Uuid) => ({+ deleteTag: (tagTitle: string, parentTagGroupUuid: Uuid) => ({type: types.REMOVE_TAG,- tagID,+ tagTitle,uuid: parentTagGroupUuid}),moveTagGroupUp: (parentTagGroupUuid: Uuid) => ({@@ -514,9 +499,13 @@ export const actions = {type: types.SORT_TAG_GROUP_UP,uuid: parentTagGroupUuid}),- moveTag: (tagID: string, fromTagGroupUuid: Uuid, toTagGroupUuid: Uuid) => ({+ moveTag: (+ tagTitle: string,+ fromTagGroupUuid: Uuid,+ toTagGroupUuid: Uuid+ ) => ({type: types.MOVE_TAG,- tagID,+ tagTitle,fromTagGroupId: fromTagGroupUuid,toTagGroupId: toTagGroupUuid}),