mirror of
https://github.com/zadam/trilium.git
synced 2025-09-29 10:05:49 +08:00
feat(views/table): integrate depth limit into collection properties
This commit is contained in:
parent
876c6e9252
commit
a5db5298a0
2 changed files with 31 additions and 3 deletions
|
@ -168,6 +168,22 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
|
|||
});
|
||||
$container.append($button);
|
||||
break;
|
||||
case "number":
|
||||
const $numberInput = $("<input>", {
|
||||
type: "number",
|
||||
class: "form-control form-control-sm",
|
||||
value: note.getLabelValue(property.bindToLabel) || "",
|
||||
});
|
||||
$numberInput.on("change", () => {
|
||||
const value = $numberInput.val();
|
||||
if (value === "") {
|
||||
attributes.removeOwnedLabelByName(note, property.bindToLabel);
|
||||
} else {
|
||||
attributes.setLabel(note.noteId, property.bindToLabel, String(value));
|
||||
}
|
||||
});
|
||||
$container.append($("<label>").text(property.label).append($numberInput));
|
||||
break;
|
||||
}
|
||||
|
||||
return $container;
|
||||
|
|
|
@ -4,8 +4,6 @@ import attributes from "../../services/attributes";
|
|||
import { ViewTypeOptions } from "../../services/note_list_renderer"
|
||||
import NoteContextAwareWidget from "../note_context_aware_widget";
|
||||
|
||||
export type BookProperty = CheckBoxProperty | ButtonProperty;
|
||||
|
||||
interface BookConfig {
|
||||
properties: BookProperty[];
|
||||
}
|
||||
|
@ -24,6 +22,14 @@ interface ButtonProperty {
|
|||
onClick: (context: BookContext) => void;
|
||||
}
|
||||
|
||||
interface NumberProperty {
|
||||
type: "number",
|
||||
label: string;
|
||||
bindToLabel: string;
|
||||
}
|
||||
|
||||
export type BookProperty = CheckBoxProperty | ButtonProperty | NumberProperty;
|
||||
|
||||
interface BookContext {
|
||||
note: FNote;
|
||||
triggerCommand: NoteContextAwareWidget["triggerCommand"];
|
||||
|
@ -85,6 +91,12 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {
|
|||
properties: []
|
||||
},
|
||||
table: {
|
||||
properties: []
|
||||
properties: [
|
||||
{
|
||||
label: "Max nesting depth",
|
||||
type: "number",
|
||||
bindToLabel: "maxNestingDepth"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue