mirror of
https://github.com/zadam/trilium.git
synced 2026-02-27 00:53:35 +01:00
chore(hidden_subtree): disable hiding subtree by default for now
This commit is contained in:
parent
c03f50583e
commit
ebb180b0ab
@ -158,5 +158,14 @@ describe("Hidden Subtree", () => {
|
||||
cls.init(() => hiddenSubtreeService.checkHiddenSubtree());
|
||||
expect(hiddenSubtree.hasLabel("excludeFromNoteMap")).toBeFalsy();
|
||||
});
|
||||
|
||||
it("cleans up attribute change in templates", () => {
|
||||
const template = becca.getNoteOrThrow("_template_table");
|
||||
cls.init(() => {
|
||||
template.setLabel("subtreeHidden", "foo");
|
||||
hiddenSubtreeService.checkHiddenSubtree();
|
||||
});
|
||||
expect(template.getLabelValue("subtreeHidden")).toBe("false");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import BAttribute from "../becca/entities/battribute.js";
|
||||
import BBranch from "../becca/entities/bbranch.js";
|
||||
import type { HiddenSubtreeItem } from "@triliumnext/commons";
|
||||
import { t } from "i18next";
|
||||
|
||||
import becca from "../becca/becca.js";
|
||||
import noteService from "./notes.js";
|
||||
import log from "./log.js";
|
||||
import migrationService from "./migration.js";
|
||||
import { t } from "i18next";
|
||||
import { cleanUpHelp, getHelpHiddenSubtreeData } from "./in_app_help.js";
|
||||
import BAttribute from "../becca/entities/battribute.js";
|
||||
import BBranch from "../becca/entities/bbranch.js";
|
||||
import buildLaunchBarConfig from "./hidden_subtree_launcherbar.js";
|
||||
import buildHiddenSubtreeTemplates from "./hidden_subtree_templates.js";
|
||||
import { cleanUpHelp, getHelpHiddenSubtreeData } from "./in_app_help.js";
|
||||
import log from "./log.js";
|
||||
import migrationService from "./migration.js";
|
||||
import noteService from "./notes.js";
|
||||
|
||||
export const LBTPL_ROOT = "_lbTplRoot";
|
||||
export const LBTPL_BASE = "_lbTplBase";
|
||||
@ -350,7 +350,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
|
||||
noteId: item.id,
|
||||
title: item.title,
|
||||
type: item.type,
|
||||
parentNoteId: parentNoteId,
|
||||
parentNoteId,
|
||||
content: item.content ?? "",
|
||||
ignoreForbiddenParents: true
|
||||
}));
|
||||
@ -372,7 +372,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
|
||||
log.info(`Creating missing branch for note ${item.id} under parent ${parentNoteId}.`);
|
||||
branch = new BBranch({
|
||||
noteId: item.id,
|
||||
parentNoteId: parentNoteId,
|
||||
parentNoteId,
|
||||
notePosition: item.notePosition !== undefined ? item.notePosition : undefined,
|
||||
isExpanded: item.isExpanded !== undefined ? item.isExpanded : false
|
||||
}).save();
|
||||
@ -454,6 +454,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
|
||||
// Remove unwanted attributes.
|
||||
const attrDef = attrs.find(a => a.name === attribute.name);
|
||||
if (!attrDef) {
|
||||
console.log(`Removing unwanted attribute ${attribute.name} where expected attrs are ${attrs.map(a => a.name).join(", ")}`);
|
||||
attribute.markAsDeleted();
|
||||
continue;
|
||||
}
|
||||
@ -466,7 +467,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
|
||||
}
|
||||
|
||||
for (const attr of attrs) {
|
||||
const attrId = note.noteId + "_" + attr.type.charAt(0) + attr.name;
|
||||
const attrId = `${note.noteId }_${ attr.type.charAt(0) }${attr.name}`;
|
||||
|
||||
const existingAttribute = note.getAttributes().find((attr) => attr.attributeId === attrId);
|
||||
|
||||
|
||||
@ -4,7 +4,8 @@ import { t } from "i18next";
|
||||
export default function buildHiddenSubtreeTemplates() {
|
||||
const hideSubtreeAttributes: HiddenSubtreeAttribute = {
|
||||
name: "subtreeHidden",
|
||||
type: "label"
|
||||
type: "label",
|
||||
value: "false"
|
||||
};
|
||||
|
||||
const templates: HiddenSubtreeItem = {
|
||||
@ -317,5 +318,11 @@ export default function buildHiddenSubtreeTemplates() {
|
||||
]
|
||||
};
|
||||
|
||||
// Enforce attributes.
|
||||
templates.enforceAttributes = true;
|
||||
for (const template of templates.children ?? []) {
|
||||
template.enforceAttributes = true;
|
||||
}
|
||||
|
||||
return templates;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user