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 }) => (