feat: add parent chain tags when adding a tag
This commit is contained in:
@@ -59,28 +59,28 @@ export const NotesOptionsPanel = observer(({ appState }: Props) => {
|
|||||||
<VisuallyHidden>Actions</VisuallyHidden>
|
<VisuallyHidden>Actions</VisuallyHidden>
|
||||||
<Icon type="more" className="block" />
|
<Icon type="more" className="block" />
|
||||||
</DisclosureButton>
|
</DisclosureButton>
|
||||||
<DisclosurePanel
|
<DisclosurePanel
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key === 'Escape' && !submenuOpen) {
|
if (event.key === 'Escape' && !submenuOpen) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
buttonRef.current.focus();
|
buttonRef.current.focus();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
ref={panelRef}
|
ref={panelRef}
|
||||||
style={{
|
style={{
|
||||||
...position,
|
...position,
|
||||||
maxHeight
|
maxHeight,
|
||||||
}}
|
}}
|
||||||
className="sn-dropdown sn-dropdown--animated max-h-120 max-w-xs flex flex-col py-2 overflow-y-scroll fixed"
|
className="sn-dropdown sn-dropdown--animated max-h-120 max-w-xs flex flex-col py-2 overflow-y-scroll fixed"
|
||||||
>
|
>
|
||||||
{open && (
|
{open && (
|
||||||
<NotesOptions
|
<NotesOptions
|
||||||
appState={appState}
|
appState={appState}
|
||||||
closeOnBlur={closeOnBlur}
|
closeOnBlur={closeOnBlur}
|
||||||
onSubmenuChange={onSubmenuChange}
|
onSubmenuChange={onSubmenuChange}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</DisclosurePanel>
|
</DisclosurePanel>
|
||||||
</Disclosure>
|
</Disclosure>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -181,9 +181,15 @@ export class NoteTagsState {
|
|||||||
async addTagToActiveNote(tag: SNTag): Promise<void> {
|
async addTagToActiveNote(tag: SNTag): Promise<void> {
|
||||||
const { activeNote } = this;
|
const { activeNote } = this;
|
||||||
if (activeNote) {
|
if (activeNote) {
|
||||||
await this.application.changeItem(tag.uuid, (mutator) => {
|
const parentChainTags = this.application.getTagParentChain(tag);
|
||||||
mutator.addItemAsRelationship(activeNote);
|
const tagsToAdd = [...parentChainTags, tag];
|
||||||
});
|
await Promise.all(
|
||||||
|
tagsToAdd.map(async (tag) => {
|
||||||
|
await this.application.changeItem(tag.uuid, (mutator) => {
|
||||||
|
mutator.addItemAsRelationship(activeNote);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
this.application.sync();
|
this.application.sync();
|
||||||
this.reloadTags();
|
this.reloadTags();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,11 +330,17 @@ export class NotesState {
|
|||||||
|
|
||||||
async addTagToSelectedNotes(tag: SNTag): Promise<void> {
|
async addTagToSelectedNotes(tag: SNTag): Promise<void> {
|
||||||
const selectedNotes = Object.values(this.selectedNotes);
|
const selectedNotes = Object.values(this.selectedNotes);
|
||||||
await this.application.changeItem(tag.uuid, (mutator) => {
|
const parentChainTags = this.application.getTagParentChain(tag);
|
||||||
for (const note of selectedNotes) {
|
const tagsToAdd = [...parentChainTags, tag];
|
||||||
mutator.addItemAsRelationship(note);
|
await Promise.all(
|
||||||
}
|
tagsToAdd.map(async (tag) => {
|
||||||
});
|
await this.application.changeItem(tag.uuid, (mutator) => {
|
||||||
|
for (const note of selectedNotes) {
|
||||||
|
mutator.addItemAsRelationship(note);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
this.application.sync();
|
this.application.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user