From 00df3c3d1fde68c9dcde4a95b89605da0eee2011 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 11 Dec 2025 19:51:40 +0200 Subject: [PATCH] feat(note_bars/collection): support number fields --- .../note_bars/CollectionProperties.tsx | 30 +++++++++++++++++-- apps/client/src/widgets/note_title.css | 9 ++++++ .../ribbon/CollectionPropertiesTab.tsx | 2 +- .../ribbon/collection-properties-config.tsx | 2 ++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/apps/client/src/widgets/note_bars/CollectionProperties.tsx b/apps/client/src/widgets/note_bars/CollectionProperties.tsx index 7042e80d3..e8b1c82bc 100644 --- a/apps/client/src/widgets/note_bars/CollectionProperties.tsx +++ b/apps/client/src/widgets/note_bars/CollectionProperties.tsx @@ -5,10 +5,11 @@ import Dropdown from "../react/Dropdown"; import { FormDropdownDivider, FormDropdownSubmenu, FormListItem, FormListToggleableItem } from "../react/FormList"; import Icon from "../react/Icon"; import { useViewType, VIEW_TYPE_MAPPINGS } from "../ribbon/CollectionPropertiesTab"; -import { bookPropertiesConfig, BookProperty, ButtonProperty, CheckBoxProperty, SplitButtonProperty } from "../ribbon/collection-properties-config"; -import { useNoteLabelBoolean } from "../react/hooks"; +import { bookPropertiesConfig, BookProperty, ButtonProperty, CheckBoxProperty, NumberProperty, SplitButtonProperty } from "../ribbon/collection-properties-config"; +import { useNoteLabel, useNoteLabelBoolean } from "../react/hooks"; import { useContext } from "preact/hooks"; import { ParentComponent } from "../react/react_utils"; +import FormTextBox from "../react/FormTextBox"; const ICON_MAPPINGS: Record = { grid: "bx bxs-grid", @@ -83,6 +84,8 @@ function ViewProperty({ note, property }: { note: FNote, property: BookProperty return ; case "checkbox": return ; + case "number": + return ; } } @@ -123,6 +126,29 @@ function SplitButtonPropertyView({ note, property }: { note: FNote, property: Sp ); } +function NumberPropertyView({ note, property }: { note: FNote, property: NumberProperty }) { + //@ts-expect-error Interop with text box which takes in string values even for numbers. + const [ value, setValue ] = useNoteLabel(note, property.bindToLabel); + const disabled = property.disabled?.(note); + + return ( + e.stopPropagation()} + > + {property.label} + + + ); +} + function CheckBoxPropertyView({ note, property }: { note: FNote, property: CheckBoxProperty }) { const [ value, setValue ] = useNoteLabelBoolean(note, property.bindToLabel); return ( diff --git a/apps/client/src/widgets/note_title.css b/apps/client/src/widgets/note_title.css index 668695cd9..0d9912b33 100644 --- a/apps/client/src/widgets/note_title.css +++ b/apps/client/src/widgets/note_title.css @@ -37,6 +37,15 @@ body.experimental-feature-new-layout { padding-inline-start: 24px; } + .title-details { + .dropdown-menu { + input.form-control { + padding: 2px 8px; + margin-left: 1em; + } + } + } + .title-row { margin-left: 12px; diff --git a/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx b/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx index 7df070879..4af8247a3 100644 --- a/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx +++ b/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx @@ -155,7 +155,7 @@ function NumberPropertyView({ note, property }: { note: FNote, property: NumberP diff --git a/apps/client/src/widgets/ribbon/collection-properties-config.tsx b/apps/client/src/widgets/ribbon/collection-properties-config.tsx index e8db421d3..9dddae75a 100644 --- a/apps/client/src/widgets/ribbon/collection-properties-config.tsx +++ b/apps/client/src/widgets/ribbon/collection-properties-config.tsx @@ -41,6 +41,7 @@ export interface NumberProperty { bindToLabel: FilterLabelsByType; width?: number; min?: number; + icon?: string; disabled?: (note: FNote) => boolean; } @@ -160,6 +161,7 @@ export const bookPropertiesConfig: Record = { properties: [ { label: t("book_properties_config.max-nesting-depth"), + icon: "bx bx-subdirectory-right", type: "number", bindToLabel: "maxNestingDepth", width: 65,