2020-01-23 07:53:36 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import BaseControl, { ControlProps } from "./BaseControl";
|
2020-04-20 05:42:46 +00:00
|
|
|
// import DynamicActionCreator from "components/editorComponents/DynamicActionCreator";
|
|
|
|
|
import { ActionCreator } from "components/editorComponents/actioncreator/ActionCreator";
|
2021-02-16 10:29:08 +00:00
|
|
|
import { ColumnProperties } from "components/designSystems/appsmith/TableComponent/Constants";
|
2020-01-23 07:53:36 +00:00
|
|
|
|
2020-02-18 10:41:52 +00:00
|
|
|
class ActionSelectorControl extends BaseControl<ControlProps> {
|
|
|
|
|
handleValueUpdate = (newValue: string) => {
|
|
|
|
|
const { propertyName } = this.props;
|
2021-02-16 10:29:08 +00:00
|
|
|
this.updateProperty(propertyName, newValue, true);
|
2020-01-23 07:53:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
2020-02-18 10:41:52 +00:00
|
|
|
const { propertyValue } = this.props;
|
2021-02-16 10:29:08 +00:00
|
|
|
/* 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 */
|
2020-01-23 07:53:36 +00:00
|
|
|
return (
|
2020-04-20 05:42:46 +00:00
|
|
|
<ActionCreator
|
2020-02-26 12:44:56 +00:00
|
|
|
value={propertyValue}
|
2020-03-31 10:40:52 +00:00
|
|
|
isValid={this.props.isValid}
|
2020-06-04 13:49:22 +00:00
|
|
|
validationMessage={this.props.errorMessage}
|
2020-02-26 12:44:56 +00:00
|
|
|
onValueChange={this.handleValueUpdate}
|
2021-02-16 10:29:08 +00:00
|
|
|
additionalAutoComplete={additionalAutoComplete}
|
2020-02-26 12:44:56 +00:00
|
|
|
/>
|
2020-01-23 07:53:36 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-14 05:35:16 +00:00
|
|
|
static getControlType() {
|
2020-01-23 07:53:36 +00:00
|
|
|
return "ACTION_SELECTOR";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 10:41:52 +00:00
|
|
|
export default ActionSelectorControl;
|