Skip to content

Build your personal knowledge base with Trilium Notes

feat(attributes): make the multiplicity a toggle

Elian Doran419aac2c3f82
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index ae29871867..8e86f3a352 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -530,8 +530,8 @@
"promoted": "Promoted",
"promoted_alias_title": "Shown on the promoted field in place of the attribute's own name.",
"promoted_alias": "Alias",
- "multiplicity_title": "Whether a note can carry this attribute more than once.",
- "multiplicity": "Multiplicity",
+ "multiplicity_title": "Lets a note carry this attribute more than once.",
+ "multiplicity": "Multiple values",
"single_value": "Single value",
"multi_value": "Multi value",
"label_type_title": "Decides which kind of field the value is entered in.",
diff --git a/apps/client/src/widgets/attribute_widgets/attribute_detail.tsx b/apps/client/src/widgets/attribute_widgets/attribute_detail.tsx
index 69258f3ab7..e0a86faafc 100644
--- a/apps/client/src/widgets/attribute_widgets/attribute_detail.tsx
+++ b/apps/client/src/widgets/attribute_widgets/attribute_detail.tsx
@@ -1,6 +1,6 @@
import "./attribute_detail.css";
-import type { DefinitionObject, LabelType, Multiplicity } from "@triliumnext/commons";
+import type { DefinitionObject, LabelType } from "@triliumnext/commons";
import { ComponentProps } from "preact";
import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
@@ -461,21 +461,14 @@ function AttributeForm({ opts, attrType, currentNoteId, onCancel, onAttributesCh
)}
{isDefinition(attrType) && !opts.hideMultiplicity && (
- <OptionsRow
+ <OptionsRowWithToggle
name="attr-multiplicity"
label={t("attribute_detail.multiplicity")}
description={t("attribute_detail.multiplicity_title")}
- >
- <FormSelect
- className="attr-input-multiplicity"
- values={MULTIPLICITIES}
- keyProperty="value"
- titleProperty="title"
- currentValue={definition.multiplicity ?? "single"}
- disabled={!isOwned}
- onChange={(multiplicity) => commitDefinition({ multiplicity: multiplicity as Multiplicity })}
- />
- </OptionsRow>
+ currentValue={definition.multiplicity === "multi"}
+ disabled={!isOwned}
+ onChange={(multiple) => commitDefinition({ multiplicity: multiple ? "multi" : "single" })}
+ />
)}
{attrType === "label-definition" && (
@@ -596,11 +589,6 @@ function lookupAttributeHelp(attrType: AttrType, name: string): AttrHelpEntry |
/** Constant so it does not re-initialise the autocomplete on every render. */
const TARGET_NOTE_OPTS = { allowCreatingNotes: true };
-const MULTIPLICITIES = [
- { value: "single", title: t("attribute_detail.single_value") },
- { value: "multi", title: t("attribute_detail.multi_value") }
-];
-
/** Exported so that hosts listing definitions can name their label type as the popup does. */
export const LABEL_TYPES = [
{ value: "text", title: t("attribute_detail.text") },