diff --git a/app/client/src/components/propertyControls/ActionSelectorControl.tsx b/app/client/src/components/propertyControls/ActionSelectorControl.tsx index f2eda411a9..a2f1d18780 100644 --- a/app/client/src/components/propertyControls/ActionSelectorControl.tsx +++ b/app/client/src/components/propertyControls/ActionSelectorControl.tsx @@ -2,7 +2,6 @@ import React from "react"; import BaseControl, { ControlProps } from "./BaseControl"; // import DynamicActionCreator from "components/editorComponents/DynamicActionCreator"; import { ActionCreator } from "components/editorComponents/actioncreator/ActionCreator"; -import { ColumnProperties } from "components/designSystems/appsmith/TableComponent/Constants"; class ActionSelectorControl extends BaseControl { handleValueUpdate = (newValue: string) => { @@ -12,28 +11,14 @@ class ActionSelectorControl extends BaseControl { render() { const { propertyValue } = this.props; - /* The following code is very specific to the table columns */ - const { widgetProperties } = this.props; - let additionalAutoComplete = {}; - if ( - this.props.customJSControl && - this.props.customJSControl === "COMPUTE_VALUE" - ) { - const columns: ColumnProperties[] = widgetProperties.primaryColumns || []; - const currentRow: { [key: string]: any } = {}; - for (let i = 0; i < columns.length; i++) { - currentRow[columns[i].id] = undefined; - } - additionalAutoComplete = { currentRow }; - } - /* EO specific code */ + return ( ); } diff --git a/app/client/src/components/propertyControls/BaseControl.tsx b/app/client/src/components/propertyControls/BaseControl.tsx index 387604ab56..3d0ceba178 100644 --- a/app/client/src/components/propertyControls/BaseControl.tsx +++ b/app/client/src/components/propertyControls/BaseControl.tsx @@ -36,8 +36,10 @@ export interface ControlBuilder { export interface ControlProps extends ControlData, ControlFunctions { key?: string; + additionalAutoComplete?: Record>; } -export interface ControlData extends PropertyPaneControlConfig { +export interface ControlData + extends Omit { propertyValue?: any; isValid: boolean; errorMessage?: string; diff --git a/app/client/src/constants/PropertyControlConstants.tsx b/app/client/src/constants/PropertyControlConstants.tsx index 10e1e51aa1..0978a1809c 100644 --- a/app/client/src/constants/PropertyControlConstants.tsx +++ b/app/client/src/constants/PropertyControlConstants.tsx @@ -42,6 +42,9 @@ export type PropertyPaneControlConfig = { hidden?: (props: any, propertyPath: string) => boolean; isBindProperty: boolean; isTriggerProperty: boolean; + additionalAutoComplete?: ( + props: any, + ) => Record>; }; export type PropertyPaneConfig = diff --git a/app/client/src/pages/Editor/PropertyPane/PropertyControl.tsx b/app/client/src/pages/Editor/PropertyPane/PropertyControl.tsx index 0b03bcd6da..b306728a7f 100644 --- a/app/client/src/pages/Editor/PropertyPane/PropertyControl.tsx +++ b/app/client/src/pages/Editor/PropertyPane/PropertyControl.tsx @@ -172,8 +172,9 @@ const PropertyControl = memo((props: Props) => { ); const { isValid, validationMessage } = getPropertyValidation(propertyName); + const { additionalAutoComplete, ...rest } = props; const config = { - ...props, + ...rest, isValid, propertyValue, validationMessage, @@ -246,6 +247,9 @@ const PropertyControl = memo((props: Props) => { }, isDynamic, props.customJSControl, + additionalAutoComplete + ? additionalAutoComplete(widgetProperties) + : undefined, )} diff --git a/app/client/src/utils/PropertyControlFactory.tsx b/app/client/src/utils/PropertyControlFactory.tsx index 5569796aa0..f997c8e5eb 100644 --- a/app/client/src/utils/PropertyControlFactory.tsx +++ b/app/client/src/utils/PropertyControlFactory.tsx @@ -21,6 +21,7 @@ class PropertyControlFactory { controlFunctions: ControlFunctions, preferEditor: boolean, customEditor?: string, + additionalAutoComplete?: Record>, ): JSX.Element { let controlBuilder = this.controlMap.get(controlData.controlType); if (preferEditor) { @@ -34,6 +35,7 @@ class PropertyControlFactory { ...controlFunctions, key: controlData.id, customJSControl: customEditor, + additionalAutoComplete, }; const control = controlBuilder.buildPropertyControl(controlProps); return control; diff --git a/app/client/src/utils/migrations/TableWidget.ts b/app/client/src/utils/migrations/TableWidget.ts index 6cc37279d0..e025d72745 100644 --- a/app/client/src/utils/migrations/TableWidget.ts +++ b/app/client/src/utils/migrations/TableWidget.ts @@ -135,6 +135,9 @@ export const tableWidgetPropertyPaneMigrations = ( onClick: action.dynamicTrigger, computedValue: "", }; + dynamicTriggerPathList.push({ + key: `primaryColumns.${columnPrefix}${index + 1}.onClick`, + }); updatedDerivedColumns[column.id] = column; }); diff --git a/app/client/src/widgets/TableWidget/TablePropertyPaneConfig.ts b/app/client/src/widgets/TableWidget/TablePropertyPaneConfig.ts index 4bd40acb12..861791506b 100644 --- a/app/client/src/widgets/TableWidget/TablePropertyPaneConfig.ts +++ b/app/client/src/widgets/TableWidget/TablePropertyPaneConfig.ts @@ -500,7 +500,14 @@ export default [ propertyName: "onClick", label: "onClick", controlType: "ACTION_SELECTOR", - customJSControl: "COMPUTE_VALUE", + additionalAutoComplete: (props: TableWidgetProps) => ({ + currentRow: Object.assign( + {}, + ...Object.keys(props.primaryColumns).map((key) => ({ + [key]: "", + })), + ), + }), isJSConvertible: true, updateHook: updateDerivedColumnsHook, isBindProperty: true, diff --git a/app/client/src/widgets/TableWidget/index.tsx b/app/client/src/widgets/TableWidget/index.tsx index 4ec130bf5c..84bd674b97 100644 --- a/app/client/src/widgets/TableWidget/index.tsx +++ b/app/client/src/widgets/TableWidget/index.tsx @@ -903,6 +903,7 @@ class TableWidget extends BaseWidget { const modifiedAction = jsSnippets.reduce((prev: string, next: string) => { return prev + `{{(currentRow) => { ${next} }}} `; }, ""); + super.executeAction({ dynamicString: modifiedAction, event: {