Skip to content

Commit

Permalink
#1644 Revert schema changes & Code optimize
Browse files Browse the repository at this point in the history
Signed-off-by: Veena S <[email protected]>
  • Loading branch information
veenas1 committed Dec 25, 2023
1 parent b0bfaed commit 76e43fd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ class VirtualizedTable extends React.Component {
}
}

onRowDoubleClick(evt, rowKey, index) {
if (this.props.onRowDoubleClick) {
this.props.onRowDoubleClick(evt, rowKey, index);
}
}

getCheckboxLabelColumnIndex(columns) {
// If 1st column is Index, use the next column for labeling
for (let i = 0; i < columns.length; i++) {
Expand Down Expand Up @@ -428,7 +434,7 @@ class VirtualizedTable extends React.Component {
const newStyle = Object.assign({}, style, { width: width });

// Empty style required on cell for react-virtualized. This div wrapper is required to apply the onDoubleClick handler.
return (<div style={{}} key={key} className="properties-vt-double-click">
return (<div style={{}} key={key} className="properties-vt-double-click" onDoubleClick={(evt) => this.onRowDoubleClick(evt, rowData.rowKey, index)}>
<div
className={classNames(className,
{ "properties-vt-row-selected": selectedRow },
Expand Down Expand Up @@ -531,6 +537,7 @@ VirtualizedTable.propTypes = {
PropTypes.func.isRequired,
PropTypes.number.isRequired
]),
onRowDoubleClick: PropTypes.func,
rowsSelected: PropTypes.array, // Required if selectable is true
checkedAll: PropTypes.bool, // Required if selectable is true
setRowsSelected: PropTypes.func, // Required if selectable is true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,34 +270,37 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
return contentObject;
}

createAddButtonContent(field, index) {
const addButtonContent = (
<Button
className="expression-add-field-button properties-expr-table-cell"
onClick={() => (this.state.selectedIndex === 0 ? this.onAddFieldClick(index) : this.onAddFunctionClick(index))}
kind="ghost"
size="small"
>
<Add16 aria-label="Add" />
</Button>
);
return addButtonContent;
}

createValueAddButtonContent(index) {
createAddButtonContent(index, tableType) {
const addValueButtonContent = (
<Button
className="expression-add-field-button properties-expr-table-cell"
onClick={this.onAddValueClick.bind(this, index)}
onClick={this.handleAddButtonClick.bind(this, index, tableType)}
kind="ghost"
size="small"
>
<Add16 aria-label="Add" />
<Add16 aria-label={formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN)} />
</Button>
);
return addValueButtonContent;
}

handleAddButtonClick(index, tableType) {
switch (tableType) {
case "value": {
this.onAddValueClick(index);
break;
}
case "field": {
this.onAddFieldClick(index);
break;
}
case "function": {
this.onAddFunctionClick(index);
break;
}
default:
}
}

_makeDatasetFields(dataset, fieldDataset) {
const addNewColumn = formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN);
Expand Down Expand Up @@ -418,7 +421,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
fieldHeaders.push(
{
key: "addColumn",
label: categoryInfo.field_columns.add_column_info.locLabel,
label: formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN),
width: 12,
},
{
Expand All @@ -431,7 +434,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
valueHeader.push(
{
key: "addColumn",
label: categoryInfo.field_columns.add_column_info.locLabel,
label: formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN),
width: 15,
},
{
Expand All @@ -457,7 +460,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
const fieldColumns = [];
if (!this.state.fieldFilterText || this.state.fieldFilterText.length === 0 ||
(field.id.toLowerCase().indexOf(this.state.fieldFilterText.toLowerCase()) > -1)) {
fieldColumns.push({ column: "addColumn", content: this.createAddButtonContent(field, index), value: field.id },
fieldColumns.push({ column: "addColumn", content: this.createAddButtonContent(index, "field"), value: field.id },
{ column: "fieldName", content: this.createContentObject(field.id), value: field.id });
if (field.additional_column_entries) {
this._makeAdditionalColumnsContent(field, fieldColumns);
Expand Down Expand Up @@ -558,7 +561,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
(String(content).toLowerCase()
.indexOf(this.state.valueFilterText.toLowerCase()) > -1)) {
const valueColumns = [
{ column: "addColumn", content: this.createValueAddButtonContent(index), value: content },
{ column: "addColumn", content: this.createAddButtonContent(index, "value"), value: content },
{ column: "values", content: this.createContentObject(content), value: content }];
valuesTableData.push({ columns: valueColumns, rowKey: index });
}
Expand Down Expand Up @@ -704,7 +707,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
if (!this.state.functionFilterText || this.state.functionFilterText.length === 0 ||
(catFunction.locLabel.toLowerCase().indexOf(this.state.functionFilterText.toLowerCase()) > -1)) {
const returnType = catFunction.locReturnType ? catFunction.locReturnType : catFunction.return_type;
columns.push({ column: "addColumn", content: this.createAddButtonContent(catFunction, index), value: catFunction.id });
columns.push({ column: "addColumn", content: this.createAddButtonContent(index, "function"), value: catFunction.id });
columns.push({ column: "function", content: this.createContentObject(catFunction.locLabel), value: catFunction.locLabel });
columns.push({ column: "return", content: this.createContentObject(returnType), value: returnType });
table.rows.push({ columns: columns, rowKey: index });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function setExpressionInfo(inExpressionInfo) {
if (inExpressionInfo.fields.field_categories) {
inExpressionInfo.fields.field_categories.forEach((fieldCat) => {
fieldCat.locLabel = l10nProvider.l10nLabel(fieldCat, fieldCat.id);
fieldCat.field_columns.add_column_info.locLabel = l10nProvider.l10nLabel(fieldCat.field_columns.add_column_info, fieldCat.id + ".add_column_info");
fieldCat.field_columns.field_column_info.locLabel = l10nProvider.l10nLabel(fieldCat.field_columns.field_column_info, fieldCat.id + ".field_column_info");
fieldCat.field_columns.value_column_info.locLabel = l10nProvider.l10nLabel(fieldCat.field_columns.value_column_info, fieldCat.id + ".value_column_info");

Expand Down
13 changes: 0 additions & 13 deletions canvas_modules/harness/src/client/constants/json/functionlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -6338,8 +6338,6 @@
{
"id": "globals",
"field_columns": {
"add_column_info": {
},
"field_column_info": {
},
"value_column_info": {
Expand All @@ -6358,11 +6356,6 @@
"default": "Multi Response Set"
},
"field_columns": {
"add_column_info": {
"label": {
"default": "Add"
}
},
"field_column_info": {
"label": {
"default": "Group"
Expand All @@ -6389,11 +6382,6 @@
"default": "Parameters"
},
"field_columns": {
"add_column_info": {
"label": {
"default": "Add"
}
},
"field_column_info": {
"label": {
"default": "Parameter"
Expand Down Expand Up @@ -6522,7 +6510,6 @@
},
"resources": {
"globals.field_column_info.label": "Field",
"globals.add_column_info.label": "Add",
"globals.label": "Globals",
"expression.no.functions": "There are no functions",
"expression.fields.empty.table.label": "There are no fields",
Expand Down

0 comments on commit 76e43fd

Please sign in to comment.