fix: associate note with selected tag when saving with editor
This commit is contained in:
@@ -474,14 +474,15 @@ class EditorViewCtrl extends PureViewCtrl<{}, EditorState> {
|
||||
}
|
||||
if (this.editor.isTemplateNote) {
|
||||
await this.editor.insertTemplatedNote();
|
||||
if (this.appState.selectedTag?.isSmartTag() === false) {
|
||||
await this.application.changeItem(
|
||||
this.appState.selectedTag!.uuid,
|
||||
(mutator) => {
|
||||
mutator.addItemAsRelationship(note);
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
const selectedTag = this.appState.selectedTag;
|
||||
if (!selectedTag?.isSmartTag() && !selectedTag?.hasRelationshipWithItem(note)) {
|
||||
await this.application.changeItem(
|
||||
selectedTag!.uuid,
|
||||
(mutator) => {
|
||||
mutator.addItemAsRelationship(note);
|
||||
}
|
||||
)
|
||||
}
|
||||
if (!this.application.findItem(note.uuid)) {
|
||||
this.application.alertService!.alert(
|
||||
@@ -1016,7 +1017,7 @@ class EditorViewCtrl extends PureViewCtrl<{}, EditorState> {
|
||||
if (action === ComponentAction.SetSize) {
|
||||
const setSize = (
|
||||
element: HTMLElement,
|
||||
size: { width: number, height: number }
|
||||
size: { width: string | number, height: string | number }
|
||||
) => {
|
||||
const widthString = typeof size.width === 'string'
|
||||
? size.width
|
||||
@@ -1034,19 +1035,37 @@ class EditorViewCtrl extends PureViewCtrl<{}, EditorState> {
|
||||
const container = document.getElementById(
|
||||
ElementIds.NoteTagsComponentContainer
|
||||
);
|
||||
setSize(container!, data);
|
||||
setSize(container!, { width: data.width!, height: data.height! });
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (action === ComponentAction.AssociateItem) {
|
||||
if (data.item.content_type === ContentType.Tag) {
|
||||
const tag = this.application.findItem(data.item.uuid) as SNTag;
|
||||
if (data.item!.content_type === ContentType.Tag) {
|
||||
const tag = this.application.findItem(data.item!.uuid) as SNTag;
|
||||
this.addTag(tag);
|
||||
}
|
||||
}
|
||||
else if (action === ComponentAction.DeassociateItem) {
|
||||
const tag = this.application.findItem(data.item.uuid) as SNTag;
|
||||
const tag = this.application.findItem(data.item!.uuid) as SNTag;
|
||||
this.removeTag(tag);
|
||||
} else if (
|
||||
action === ComponentAction.SaveSuccess
|
||||
) {
|
||||
const savedUuid = data.item ? data.item.uuid : data.items![0].uuid;
|
||||
if (savedUuid === this.note.uuid) {
|
||||
const selectedTag = this.appState.selectedTag;
|
||||
if (
|
||||
!selectedTag?.isSmartTag() &&
|
||||
!selectedTag?.hasRelationshipWithItem(this.note)
|
||||
) {
|
||||
this.application.changeAndSaveItem(
|
||||
selectedTag!.uuid,
|
||||
(mutator) => {
|
||||
mutator.addItemAsRelationship(this.note);
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -316,16 +316,6 @@ class FooterViewCtrl extends PureViewCtrl<{}, {
|
||||
this.unregisterComponent = this.application.componentManager!.registerHandler({
|
||||
identifier: 'room-bar',
|
||||
areas: [ComponentArea.Rooms, ComponentArea.Modal],
|
||||
actionHandler: (component, action, data) => {
|
||||
if (action === ComponentAction.SetSize) {
|
||||
/** Do comparison to avoid repetitive calls by arbitrary component */
|
||||
if (!topLevelCompare(component.getLastSize(), data)) {
|
||||
this.application.changeItem<ComponentMutator>(component.uuid, (mutator) => {
|
||||
mutator.setLastSize(data);
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
focusHandler: (component, focused) => {
|
||||
if (component.isEditor() && focused) {
|
||||
this.closeAllRooms();
|
||||
|
||||
@@ -346,11 +346,6 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
|
||||
return this.application!.getAppState().getSelectedTag();
|
||||
}
|
||||
|
||||
currentTagCanHavePlaceholderNotes() {
|
||||
const selectedTag = this.selectedTag!;
|
||||
return selectedTag.isAllTag || !selectedTag.isSmartTag()
|
||||
}
|
||||
|
||||
private async performReloadNotes() {
|
||||
const tag = this.appState.selectedTag!;
|
||||
if (!tag) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { PayloadContent } from 'snjs/dist/@types/protocol/payloads/generator';
|
||||
import { WebDirective, PanelPuppet } from '@/types';
|
||||
import { WebApplication } from '@/ui_models/application';
|
||||
import {
|
||||
@@ -248,15 +249,15 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
|
||||
areas: [ComponentArea.TagsList],
|
||||
actionHandler: (_, action, data) => {
|
||||
if (action === ComponentAction.SelectItem) {
|
||||
if (data.item.content_type === ContentType.Tag) {
|
||||
const tag = this.application.findItem(data.item.uuid);
|
||||
if (data.item!.content_type === ContentType.Tag) {
|
||||
const tag = this.application.findItem(data.item!.uuid);
|
||||
if (tag) {
|
||||
this.selectTag(tag as SNTag);
|
||||
}
|
||||
} else if (data.item.content_type === ContentType.SmartTag) {
|
||||
} else if (data.item!.content_type === ContentType.SmartTag) {
|
||||
this.application.createTemplateItem(
|
||||
ContentType.SmartTag,
|
||||
data.item.content
|
||||
data.item!.content as PayloadContent
|
||||
).then(smartTag => {
|
||||
this.selectTag(smartTag as SNSmartTag);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user