Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(note_bars/collection): support split button properties
Elian Dorana1513a35673d
diff --git a/apps/client/src/widgets/note_bars/CollectionProperties.tsx b/apps/client/src/widgets/note_bars/CollectionProperties.tsxindex 0de1e363a6..830ef67c2e 100644--- a/apps/client/src/widgets/note_bars/CollectionProperties.tsx+++ b/apps/client/src/widgets/note_bars/CollectionProperties.tsx@@ -2,10 +2,10 @@ import { t } from "i18next";import FNote from "../../entities/fnote";import { ViewTypeOptions } from "../collections/interface";import Dropdown from "../react/Dropdown";-import { FormDropdownDivider, FormListItem, FormListToggleableItem } from "../react/FormList";+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 } from "../ribbon/collection-properties-config";+import { bookPropertiesConfig, BookProperty, ButtonProperty, CheckBoxProperty, SplitButtonProperty } from "../ribbon/collection-properties-config";import { useNoteLabel, useNoteLabelBoolean } from "../react/hooks";import { useContext } from "preact/hooks";import { ParentComponent } from "../react/react_utils";@@ -78,6 +78,8 @@ function ViewProperty({ note, property }: { note: FNote, property: BookPropertyswitch (property.type) {case "button":return <ButtonPropertyView note={note} property={property} />;+ case "split-button":+ return <SplitButtonPropertyView note={note} property={property} />;case "checkbox":return <CheckBoxPropertyView note={note} property={property} />;}@@ -101,6 +103,17 @@ function ButtonPropertyView({ note, property }: { note: FNote, property: ButtonP);}+function SplitButtonPropertyView({ note, property }: { note: FNote, property: SplitButtonProperty }) {+ const parentComponent = useContext(ParentComponent);+ const ItemsComponent = property.items;++ return (parentComponent &&+ <FormDropdownSubmenu icon={property.icon ?? "bx bx-empty"} title={property.label}>+ <ItemsComponent note={note} parentComponent={parentComponent} />+ </FormDropdownSubmenu>+ );+}+function CheckBoxPropertyView({ note, property }: { note: FNote, property: CheckBoxProperty }) {const [ value, setValue ] = useNoteLabelBoolean(note, property.bindToLabel);return (