mirror of
https://github.com/zadam/trilium.git
synced 2026-01-14 10:34:25 +01:00
fix(client): edge case not handled when parent note overrides to false
This commit is contained in:
parent
6398830c2d
commit
26c25cd4cd
@ -110,4 +110,42 @@ describe("Set boolean with inheritance", () => {
|
||||
await setBooleanWithInheritance(childNote, "foo", true);
|
||||
expect(server.remove).toHaveBeenCalledWith(`notes/${childNote.noteId}/attributes/${childNote.getLabel("foo")!.attributeId}`);
|
||||
});
|
||||
|
||||
it("overrides boolean with inherited false", async () => {
|
||||
const parentNote = buildNote({
|
||||
title: "Parent note",
|
||||
"#foo(inheritable)": "false",
|
||||
"children": [
|
||||
{
|
||||
title: "Child note"
|
||||
}
|
||||
]
|
||||
});
|
||||
const childNote = froca.getNoteFromCache(parentNote.children[0])!;
|
||||
expect(childNote.isLabelTruthy("foo")).toBe(false);
|
||||
await setBooleanWithInheritance(childNote, "foo", true);
|
||||
expect(server.put).toHaveBeenCalledWith(`notes/${childNote.noteId}/set-attribute`, {
|
||||
type: "label",
|
||||
name: "foo",
|
||||
value: "",
|
||||
isInheritable: false
|
||||
});
|
||||
});
|
||||
|
||||
it("deletes override boolean with inherited false with already existing value", async () => {
|
||||
const parentNote = buildNote({
|
||||
title: "Parent note",
|
||||
"#foo(inheritable)": "false",
|
||||
"children": [
|
||||
{
|
||||
title: "Child note",
|
||||
"#foo": "false",
|
||||
}
|
||||
]
|
||||
});
|
||||
const childNote = froca.getNoteFromCache(parentNote.children[0])!;
|
||||
expect(childNote.isLabelTruthy("foo")).toBe(false);
|
||||
await setBooleanWithInheritance(childNote, "foo", true);
|
||||
expect(server.remove).toHaveBeenCalledWith(`notes/${childNote.noteId}/attributes/${childNote.getLabel("foo")!.attributeId}`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -48,7 +48,7 @@ export async function setBooleanWithInheritance(note: FNote, labelName: string,
|
||||
if (actualValue === value) return;
|
||||
|
||||
if (value) {
|
||||
if (note.getLabelValue(labelName) === "false") {
|
||||
if (note.getOwnedLabelValue(labelName) === "false") {
|
||||
// Remove the override so that the inherited true takes effect.
|
||||
removeOwnedLabelByName(note, labelName);
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user