Fixes tagging
This commit is contained in:
@@ -84,7 +84,10 @@ class EditorCtrl extends PureCtrl {
|
|||||||
componentStack: [],
|
componentStack: [],
|
||||||
editorDebounce: EDITOR_DEBOUNCE,
|
editorDebounce: EDITOR_DEBOUNCE,
|
||||||
isDesktop: isDesktopApplication(),
|
isDesktop: isDesktopApplication(),
|
||||||
spellcheck: true
|
spellcheck: true,
|
||||||
|
mutable: {
|
||||||
|
tagsString: ''
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.leftResizeControl = {};
|
this.leftResizeControl = {};
|
||||||
@@ -694,7 +697,10 @@ class EditorCtrl extends PureCtrl {
|
|||||||
|
|
||||||
reloadTagsString() {
|
reloadTagsString() {
|
||||||
this.setState({
|
this.setState({
|
||||||
tagsString: this.state.note.tagsString()
|
mutable: {
|
||||||
|
...this.state.mutable,
|
||||||
|
tagsString: this.state.note.tagsString()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,8 +709,7 @@ class EditorCtrl extends PureCtrl {
|
|||||||
return currentTag.title;
|
return currentTag.title;
|
||||||
});
|
});
|
||||||
strings.push(tag.title);
|
strings.push(tag.title);
|
||||||
this.updateTags(strings);
|
this.saveTags({ strings: strings});
|
||||||
this.reloadTagsString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTag(tag) {
|
removeTag(tag) {
|
||||||
@@ -713,14 +718,25 @@ class EditorCtrl extends PureCtrl {
|
|||||||
}).filter((title) => {
|
}).filter((title) => {
|
||||||
return title !== tag.title;
|
return title !== tag.title;
|
||||||
});
|
});
|
||||||
this.updateTags(strings);
|
this.saveTags({ strings: strings });
|
||||||
this.reloadTagsString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTag(stringTags) {
|
saveTags({strings} = {}) {
|
||||||
|
if (!strings && this.state.mutable.tagsString === this.state.note.tagsString()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!strings) {
|
||||||
|
strings = this.state.mutable.tagsString.split('#').filter((string) => {
|
||||||
|
return string.length > 0;
|
||||||
|
}).map((string) => {
|
||||||
|
return string.trim();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.state.note.dummy = false;
|
||||||
|
|
||||||
const toRemove = [];
|
const toRemove = [];
|
||||||
for (const tag of this.state.note.tags) {
|
for (const tag of this.state.note.tags) {
|
||||||
if (stringTags.indexOf(tag.title) === -1) {
|
if (strings.indexOf(tag.title) === -1) {
|
||||||
toRemove.push(tag);
|
toRemove.push(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -729,7 +745,7 @@ class EditorCtrl extends PureCtrl {
|
|||||||
}
|
}
|
||||||
this.modelManager.setItemsDirty(toRemove);
|
this.modelManager.setItemsDirty(toRemove);
|
||||||
const tags = [];
|
const tags = [];
|
||||||
for (const tagString of stringTags) {
|
for (const tagString of strings) {
|
||||||
const existingRelationship = _.find(
|
const existingRelationship = _.find(
|
||||||
this.state.note.tags,
|
this.state.note.tags,
|
||||||
{ title: tagString }
|
{ title: tagString }
|
||||||
@@ -745,19 +761,7 @@ class EditorCtrl extends PureCtrl {
|
|||||||
}
|
}
|
||||||
this.modelManager.setItemsDirty(tags);
|
this.modelManager.setItemsDirty(tags);
|
||||||
this.syncManager.sync();
|
this.syncManager.sync();
|
||||||
}
|
this.reloadTagsString();
|
||||||
|
|
||||||
updateTagsFromTagsString() {
|
|
||||||
if (this.state.tagsString === this.state.note.tagsString()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const strings = this.state.tagsString.split('#').filter((string) => {
|
|
||||||
return string.length > 0;
|
|
||||||
}).map((string) => {
|
|
||||||
return string.trim();
|
|
||||||
});
|
|
||||||
this.state.note.dummy = false;
|
|
||||||
this.updateTags(strings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onPanelResizeFinish = (width, left, isMaxWidth) => {
|
onPanelResizeFinish = (width, left, isMaxWidth) => {
|
||||||
|
|||||||
@@ -38,11 +38,11 @@
|
|||||||
ng-style="self.state.note.locked && {'pointer-events' : 'none'}"
|
ng-style="self.state.note.locked && {'pointer-events' : 'none'}"
|
||||||
)
|
)
|
||||||
input.tags-input(
|
input.tags-input(
|
||||||
ng-blur='self.updateTagsFromTagsString($event, self.state.tagsString)',
|
ng-blur='self.saveTags()',
|
||||||
ng-disabled='self.state.note.locked',
|
ng-disabled='self.state.note.locked',
|
||||||
ng-if='!(self.state.tagsComponent && self.state.tagsComponent.active)',
|
ng-if='!(self.state.tagsComponent && self.state.tagsComponent.active)',
|
||||||
ng-keyup='$event.keyCode == 13 && $event.target.blur();',
|
ng-keyup='$event.keyCode == 13 && $event.target.blur();',
|
||||||
ng-model='self.state.tagsString',
|
ng-model='self.state.mutable.tagsString',
|
||||||
placeholder='#tags',
|
placeholder='#tags',
|
||||||
spellcheck='false',
|
spellcheck='false',
|
||||||
type='text'
|
type='text'
|
||||||
|
|||||||
79109
dist/javascripts/app.js
vendored
79109
dist/javascripts/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/javascripts/app.js.map
vendored
2
dist/javascripts/app.js.map
vendored
File diff suppressed because one or more lines are too long
2652
dist/stylesheets/app.css
vendored
2652
dist/stylesheets/app.css
vendored
File diff suppressed because one or more lines are too long
2
dist/stylesheets/app.css.map
vendored
2
dist/stylesheets/app.css.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user