diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx index a57c879121..959a0571c6 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx @@ -32,6 +32,8 @@ export function Select({ componentMeta, darkMode, ...restProps }) { const isDynamicOptionsEnabled = getResolvedValue(component?.component?.definition?.properties?.advanced?.value); + const isSortingEnabled = componentMeta?.properties['sort'] ?? false; + const constructOptions = () => { let optionsValue = component?.component?.definition?.properties?.options?.value; if (!Array.isArray(optionsValue)) { @@ -512,6 +514,17 @@ export function Select({ componentMeta, darkMode, ...restProps }) { currentState, allComponents )} + {isSortingEnabled && + renderElement( + component, + componentMeta, + paramUpdated, + dataQueries, + 'sort', + 'properties', + currentState, + allComponents + )} ), }); diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js b/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js index 247af3ccef..befb739c2a 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js @@ -63,6 +63,18 @@ export const dropdownV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -301,6 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js b/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js index 6aefd71067..a6bf6f80e2 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js @@ -130,6 +130,18 @@ export const multiselectV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -313,6 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/Editor/WidgetManager/configs/dropdownV2.js b/frontend/src/Editor/WidgetManager/configs/dropdownV2.js index 247af3ccef..befb739c2a 100644 --- a/frontend/src/Editor/WidgetManager/configs/dropdownV2.js +++ b/frontend/src/Editor/WidgetManager/configs/dropdownV2.js @@ -63,6 +63,18 @@ export const dropdownV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -301,6 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/Editor/WidgetManager/configs/multiselectV2.js b/frontend/src/Editor/WidgetManager/configs/multiselectV2.js index 6aefd71067..a6bf6f80e2 100644 --- a/frontend/src/Editor/WidgetManager/configs/multiselectV2.js +++ b/frontend/src/Editor/WidgetManager/configs/multiselectV2.js @@ -130,6 +130,18 @@ export const multiselectV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -313,6 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/server/src/modules/apps/services/widget-config/dropdownV2.js b/server/src/modules/apps/services/widget-config/dropdownV2.js index 247af3ccef..befb739c2a 100644 --- a/server/src/modules/apps/services/widget-config/dropdownV2.js +++ b/server/src/modules/apps/services/widget-config/dropdownV2.js @@ -63,6 +63,18 @@ export const dropdownV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -301,6 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/server/src/modules/apps/services/widget-config/multiselectV2.js b/server/src/modules/apps/services/widget-config/multiselectV2.js index 6aefd71067..a6bf6f80e2 100644 --- a/server/src/modules/apps/services/widget-config/multiselectV2.js +++ b/server/src/modules/apps/services/widget-config/multiselectV2.js @@ -130,6 +130,18 @@ export const multiselectV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -313,6 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' },