From 73f20d01e4ede6a1ce878636e51013d70c2c9095 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 24 Aug 2025 18:29:47 +0300 Subject: [PATCH] chore(react/ribbon): port order by --- apps/client/src/widgets/react/FormSelect.tsx | 13 ++-- .../widgets/ribbon/SearchDefinitionTab.tsx | 60 ++++++++++++++-- .../src/widgets/search_options/order_by.ts | 72 ------------------- 3 files changed, 60 insertions(+), 85 deletions(-) delete mode 100644 apps/client/src/widgets/search_options/order_by.ts diff --git a/apps/client/src/widgets/react/FormSelect.tsx b/apps/client/src/widgets/react/FormSelect.tsx index 639cd5bde..5b38a4c92 100644 --- a/apps/client/src/widgets/react/FormSelect.tsx +++ b/apps/client/src/widgets/react/FormSelect.tsx @@ -23,14 +23,15 @@ interface FormSelectProps extends ValueConfig { name?: string; onChange: OnChangeListener; style?: CSSProperties; + className?: string; } /** * Combobox component that takes in any object array as data. Each item of the array is rendered as an item, and the key and values are obtained by looking into the object by a specified key. */ -export default function FormSelect({ name, id, onChange, style, ...restProps }: FormSelectProps) { +export default function FormSelect({ name, id, onChange, style, className, ...restProps }: FormSelectProps) { return ( - + ); @@ -39,9 +40,9 @@ export default function FormSelect({ name, id, onChange, style, ...restProps /** * Similar to {@link FormSelect}, but the top-level elements are actually groups. */ -export function FormSelectWithGroups({ name, id, values, keyProperty, titleProperty, currentValue, onChange }: FormSelectProps | T>) { +export function FormSelectWithGroups({ name, id, values, keyProperty, titleProperty, currentValue, onChange, ...restProps }: FormSelectProps | T>) { return ( - + {values.map((item) => { if (!item) return <>; if (typeof item === "object" && "items" in item) { @@ -60,13 +61,13 @@ export function FormSelectWithGroups({ name, id, values, keyProperty, titlePr ) } -function FormSelectBody({ id, name, children, onChange, style }: { id?: string, name?: string, children: ComponentChildren, onChange: OnChangeListener, style?: CSSProperties }) { +function FormSelectBody({ id, name, children, onChange, style, className }: { id?: string, name?: string, children: ComponentChildren, onChange: OnChangeListener, style?: CSSProperties, className?: string }) { return ( diff --git a/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx b/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx index dffd1b024..0e00bad07 100644 --- a/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx +++ b/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx @@ -29,6 +29,7 @@ interface SearchOption { tooltip?: string; // TODO: Make mandatory once all components are ported. component?: (props: SearchOptionProps) => VNode; + defaultValue?: string; additionalAttributesToDelete?: { type: "label" | "relation", name: string }[]; } @@ -52,6 +53,7 @@ const SEARCH_OPTIONS: SearchOption[] = [ { attributeName: "searchScript", attributeType: "relation", + defaultValue: "root", icon: "bx bx-code", label: t("search_definition.search_script"), component: SearchScriptOption @@ -59,9 +61,10 @@ const SEARCH_OPTIONS: SearchOption[] = [ { attributeName: "ancestor", attributeType: "relation", + defaultValue: "root", icon: "bx bx-filter-alt", label: t("search_definition.ancestor"), - component: AncestorOption, + component: AncestorOption, additionalAttributesToDelete: [ { type: "label", name: "ancestorDepth" } ] }, { @@ -83,8 +86,11 @@ const SEARCH_OPTIONS: SearchOption[] = [ { attributeName: "orderBy", attributeType: "label", + defaultValue: "relevancy", icon: "bx bx-arrow-from-top", - label: t("search_definition.order_by") + label: t("search_definition.order_by"), + component: OrderByOption, + additionalAttributesToDelete: [ { type: "label", name: "orderDirection" } ] }, { attributeName: "limit", @@ -162,15 +168,12 @@ export default function SearchDefinitionTab({ note, ntxId }: TabContext) { {t("search_definition.add_search_option")} - {searchOptions?.availableOptions.map(({ icon, label, tooltip, attributeName, attributeType }) => ( + {searchOptions?.availableOptions.map(({ icon, label, tooltip, attributeName, attributeType, defaultValue }) => (