diff --git a/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx b/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx index 0e00bad07..3490e296d 100644 --- a/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx +++ b/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx @@ -20,6 +20,7 @@ import tree from "../../services/tree"; import NoteAutocomplete from "../react/NoteAutocomplete"; import FormSelect from "../react/FormSelect"; import Icon from "../react/Icon"; +import FormTextBox from "../react/FormTextBox"; interface SearchOption { attributeName: string; @@ -39,6 +40,7 @@ interface SearchOptionProps { attributeName: string; attributeType: "label" | "relation"; additionalAttributesToDelete?: { type: "label" | "relation", name: string }[]; + defaultValue?: string; error?: { message: string }; } @@ -95,9 +97,11 @@ const SEARCH_OPTIONS: SearchOption[] = [ { attributeName: "limit", attributeType: "label", + defaultValue: "10", icon: "bx bx-stop", label: t("search_definition.limit"), - tooltip: t("search_definition.limit_description") + tooltip: t("search_definition.limit_description"), + component: LimitOption }, { attributeName: "debug", @@ -179,14 +183,15 @@ export default function SearchDefinitionTab({ note, ntxId }: TabContext) { - {searchOptions?.activeOptions.map(({ attributeType, attributeName, component, additionalAttributesToDelete }) => { + {searchOptions?.activeOptions.map(({ attributeType, attributeName, component, additionalAttributesToDelete, defaultValue }) => { return component?.({ attributeName, attributeType, note, refreshResults, error, - additionalAttributesToDelete + additionalAttributesToDelete, + defaultValue }); })} @@ -482,4 +487,20 @@ function OrderByOption({ note, ...restProps }: SearchOptionProps) { ]} /> +} + +function LimitOption({ note, defaultValue, ...restProps }: SearchOptionProps) { + const [ limit, setLimit ] = useNoteLabel(note, "limit"); + + return + + } \ No newline at end of file diff --git a/apps/client/src/widgets/search_options/limit.ts b/apps/client/src/widgets/search_options/limit.ts deleted file mode 100644 index 1925f29f1..000000000 --- a/apps/client/src/widgets/search_options/limit.ts +++ /dev/null @@ -1,49 +0,0 @@ -import AbstractSearchOption from "./abstract_search_option.js"; -import { t } from "../../services/i18n.js"; - -const TPL = /*html*/` - - - - ${t("limit.limit")} - - - - - - - - - -`; - -export default class Limit extends AbstractSearchOption { - - private $limit!: JQuery; - - static async create(noteId: string) { - await AbstractSearchOption.setAttribute(noteId, "label", "limit", "10"); - } - - doRender() { - const $option = $(TPL); - - this.$limit = $option.find("input[name=limit]"); - this.$limit.on("change", () => this.update()); - this.$limit.on("input", () => this.update()); - this.$limit.val(this.note.getLabelValue("limit") ?? ""); - - return $option; - } - - async update() { - const limit = String(this.$limit.val()); - - await this.setAttribute("label", "limit", limit); - } -}