Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into cou-fix-expand-edit…
Browse files Browse the repository at this point in the history
…or-button
  • Loading branch information
caritaou committed Aug 15, 2024
2 parents 607de13 + 8483035 commit 328cdc8
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,22 @@ describe("expression-builder select from tables correctly", () => {
expect(controller.getPropertyValue(propertyId)).to.equal(" Age");
});

it("expression builder select a field on double clicking row", () => {
reset();
const wrapper = mountWithIntl(
<Provider store={controller.getStore()}>
<ExpressionBuilder
control={control}
controller={controller}
propertyId={propertyId}
/>
</Provider>
);
const fieldTable = wrapper.find("div.properties-field-table-container");
tableUtils.dblClickTableRows(fieldTable, [0]);
expect(controller.getPropertyValue(propertyId)).to.equal(" Age");
});

it("expression builder select a field value", () => {
reset();
const wrapper = mountWithIntl(
Expand All @@ -529,6 +545,22 @@ describe("expression-builder select from tables correctly", () => {
expect(controller.getPropertyValue(propertyId)).to.equal(" 21");
});

it("expression builder select a Value on double clicking row", () => {
reset();
const wrapper = mountWithIntl(
<Provider store={controller.getStore()}>
<ExpressionBuilder
control={control}
controller={controller}
propertyId={propertyId}
/>
</Provider>
);
const valueTable = wrapper.find("div.properties-value-table-container");
tableUtils.dblClickTableRows(valueTable, [0]);
expect(controller.getPropertyValue(propertyId)).to.equal(" 21");
});

it("expression builder select a field value of type string", () => {
reset();
const wrapper = mountWithIntl(
Expand Down
5 changes: 4 additions & 1 deletion canvas_modules/common-canvas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
"@wojtekmaj/enzyme-adapter-react-17": {
"react": "^18",
"react-dom": "^18"
}
},
"enzyme": {
"cheerio": "1.0.0-rc.12"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ $operator-margin: 50%;
width: 100%;
}
}
.expression-builder-table{
.properties-vt-row-selected {
cursor: pointer;
}
.properties-vt-row-class {
&:focus {
color: $button-primary;
border: 1px solid $button-primary;
}
}

}

.properties-value-table-container {
width: $values-table-width;
Expand Down Expand Up @@ -147,3 +159,9 @@ $operator-margin: 50%;
.properties-primaryTabs .cds--tabs-trigger {
margin-bottom: 5px;
}

.expression-add-field-button {
svg.add-btn-svg {
fill: $button-primary;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
});

}

onAddFieldClick(rowKey) {
// field table - called on row doubleclick & also Add btn click.
onAddFieldClick(evt, rowKey, index) {
const field = this.state.currentFieldDataset[rowKey];
let value = field.id;
if (this.state.fieldCategory !== this.recentUseCat) {
Expand All @@ -150,7 +150,8 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
});
}

onAddValueClick(rowKey) {
// value table - called on row doubleclick & also Add btn click.
onAddValueClick(evt, rowKey, index) {
if (this.props.onChange) {
const field = this.state.currentFieldDataset[this.state.fieldSelected];
const quote = "\"";
Expand Down Expand Up @@ -179,7 +180,8 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
});
}

onAddFunctionClick(rowKey) {
// function table - called on row doubleclick & also Add btn click.
onAddFunctionClick(evt, rowKey, index) {
let field;
if (this.state.functionCategory === this.recentUseCat) {
field = this.props.controller.getExpressionRecentlyUsed()[rowKey];
Expand Down Expand Up @@ -278,24 +280,24 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
kind="ghost"
size="sm"
>
<Add aria-label={formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN)} />
{<Add className="add-btn-svg" aria-label={formatMessage(this.reactIntl, MESSAGE_KEYS.EXPRESSION_ADD_COLUMN)} />}
</Button>
);
return addValueButtonContent;
}

handleAddButtonClick(index, tableType) {
handleAddButtonClick(index, tableType, evt) {
switch (tableType) {
case "value": {
this.onAddValueClick(index);
this.onAddValueClick(evt, index);
break;
}
case "field": {
this.onAddFieldClick(index);
this.onAddFieldClick(evt, index);
break;
}
case "function": {
this.onAddFunctionClick(index);
this.onAddFunctionClick(evt, index);
break;
}
default:
Expand Down Expand Up @@ -497,7 +499,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
return (
<div className="properties-field-and-values-table-container" >
{fieldCategory}
<div className="properties-field-table-container" >
<div className="properties-field-table-container expression-builder-table" >
<FlexibleTable
columns={fieldHeaders}
data={tableData}
Expand All @@ -508,13 +510,14 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
tableLabel={fieldsTableLabel}
rowSelection={ROW_SELECTION.SINGLE}
updateRowSelections={this.onFieldTableClick}
onRowDoubleClick={this.onAddFieldClick}
selectedRows={[selectedField]}
onSort={this.setSortColumn.bind(this, "fieldTable")}
light={!this.props.controller.getLight()}
emptyTablePlaceholder={emptyFieldsLabel}
/>
</div>
<div className="properties-value-table-container" >
<div className="properties-value-table-container expression-builder-table" >
<FlexibleTable
columns={valueHeader}
data={valuesTableData}
Expand All @@ -525,6 +528,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
tableLabel={valuesTableLabel}
rowSelection={ROW_SELECTION.SINGLE}
updateRowSelections={this.onValueTableClick}
onRowDoubleClick={this.onAddValueClick}
selectedRows={[selectedValue]}
onSort={this.setSortColumn.bind(this, "valuesTable")}
light={!this.props.controller.getLight()}
Expand Down Expand Up @@ -682,7 +686,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {

return (
<div className="properties-functions-table-helper-container">
<div className="properties-functions-table-container">
<div className="properties-functions-table-container expression-builder-table">
<div className="properties-functions-table" >
<FlexibleTable
columns={headers}
Expand All @@ -694,6 +698,7 @@ export default class ExpressionSelectFieldOrFunction extends React.Component {
tableLabel={functionsTableLabel}
rowSelection={ROW_SELECTION.SINGLE}
updateRowSelections={this.onFunctionTableClick}
onRowDoubleClick={this.onAddFunctionClick}
selectedRows={[selectedFunction]}
onSort={this.setSortColumn.bind(this, "functionTable")}
light={!this.props.controller.getLight()}
Expand Down
17 changes: 17 additions & 0 deletions docs/pages/04.03-ui-hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,23 @@ Example complex_type_info section:
}
]
```
## Title-info
The title_info sections defines what will be displayed in the title section alongside the `titleDefinition`.
Title info attributes.
* `action_refs` (*array[string]*) List of action to be displayed in the title section. Each action_ref must have a corresponding action defined in the action_info section.
Example title info section:
```js
"title_info": {
"action_refs": [
"increment"
]
}
```
## Action Info
The action_info section defines an action. Actions are used to callback to the application to perform an operation.
Expand Down

0 comments on commit 328cdc8

Please sign in to comment.