Skip to content

Commit

Permalink
Don't show readonly controls in multi select edit subpanel
Browse files Browse the repository at this point in the history
Signed-off-by: Neha Gokhale <[email protected]>
  • Loading branch information
nmgokhale committed May 22, 2024
1 parent 172796b commit 026a6d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ describe("structuretable multiselect edit works incrementally", () => {
const renderedObject = propertyUtils.flyoutEditorForm(structuretableParamDef);
const wrapper = renderedObject.wrapper;
const renderedController = renderedObject.controller;
it("Opens mse table II multiselect and selects two rows", () => {
it("structuretable multiselect edit works incrementally", () => {
// Open mse Summary Panel in structuretableParamDef
propertyUtils.openSummaryPanel(wrapper, "ST_mse_table_II-summary-panel");

Expand Down Expand Up @@ -923,7 +923,7 @@ describe("structuretable multiselect edit works incrementally", () => {
expect(rowCheckbox.props().checked).to.be.true;
}

// Select Baseball for Sport again
// Select Football for Sport
tableToolbar = wrapper.find("div.properties-table-toolbar");
editButton = tableToolbar.find("button.properties-action-multi-select-edit");
editButton.simulate("click");
Expand All @@ -934,8 +934,8 @@ describe("structuretable multiselect edit works incrementally", () => {
dropdownButton.simulate("click");
dropdownList = wrapper.find("li.cds--list-box__menu-item");
expect(dropdownList).to.have.length(4);
expect(dropdownList.at(3).text()).to.equal("Baseball");
dropdownList.at(3).simulate("click");
expect(dropdownList.at(0).text()).to.equal("Football");
dropdownList.at(0).simulate("click");

// Save wide flyout
wrapper.find(".properties-modal-buttons").find("button.properties-apply-button")
Expand All @@ -944,7 +944,7 @@ describe("structuretable multiselect edit works incrementally", () => {

rowValues = renderedController.getPropertyValue(propertyIdMSEII);
for (const row of [0, 1, 2, 3]) {
expect(rowValues[row][2]).to.equal("Baseball");
expect(rowValues[row][2]).to.equal("Football");
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ export default class AbstractTable extends React.Component {
const newSelectedSummaryRow = this.props.controller.getPropertyValue(summaryPropertyId);
if (newSelectedSummaryRow && Array.isArray(newSelectedSummaryRow)) {
newSelectedSummaryRow[0].forEach((cellValue, colIndex) => {
if (cellValue !== null && !isEqual(cellValue, this.selectedSummaryRowValue[0][colIndex])) {
if (!isEqual(cellValue, this.selectedSummaryRowValue[0][colIndex])) {
// if a column does not have a value, the default value is null and the value returned
// from getPropertyValue is undefined causing unneccessary updates and an infinite loop during intialization
const testCell = (typeof cellValue === "undefined") ? null : cellValue;
this.props.selectedRows.forEach((rowIndex) => {
this.props.controller.updatePropertyValue({ name: this.props.control.name, row: rowIndex, col: colIndex }, testCell, true);
});
if (tableControl.subControls[colIndex].controlType === ControlType.ONEOFSELECT) {
this.props.controller.updatePropertyValue({ name: this.selectSummaryPropertyName, row: 0, col: colIndex }, null);
this.props.controller.updatePropertyValue({ name: this.selectSummaryPropertyName, row: 0, col: colIndex }, testCell);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { Separator } from "../constants/form-constants";
import { Type, ParamRole, EditStyle } from "../constants/form-constants";
import { Type, ParamRole, EditStyle, ControlType } from "../constants/form-constants";
import { ResourceDef } from "../util/L10nProvider";
import { propertyOf } from "lodash";
import { toType } from "../util/property-utils";
Expand Down Expand Up @@ -196,7 +196,7 @@ export class ParameterDef {

// For multi select edit subpanel, fields having editStyle "inline" and undefined can be edited in the subpanel
isInlineEdit() {
if (this.editStyle === EditStyle.INLINE || typeof this.editStyle === "undefined") {
if ((this.editStyle === EditStyle.INLINE || typeof this.editStyle === "undefined") && this.control !== ControlType.READONLY) {
return true;
}
return false;
Expand Down

0 comments on commit 026a6d1

Please sign in to comment.