feat(views/table): integrate depth limit into collection properties

This commit is contained in:
Elian Doran 2025-07-17 19:44:34 +03:00
parent 876c6e9252
commit a5db5298a0
No known key found for this signature in database
2 changed files with 31 additions and 3 deletions

View file

@ -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;

View file

@ -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"
}
]
}
};