Skip to content

Commit

Permalink
#1611 Filter getPropertyValues() based on the selected tab
Browse files Browse the repository at this point in the history
Signed-off-by: Neha Gokhale <[email protected]>
  • Loading branch information
nmgokhale committed Oct 30, 2023
1 parent 1bfbaf9 commit 71555f5
Show file tree
Hide file tree
Showing 11 changed files with 340 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,21 @@ describe("Correct form should be created", () => {
"boolean_param": true
}
};
const groupMetadata = {
"groups": [
{
"name": "settings",
"parameters": [
"boolean_param"
]
}
]
};
let help;
let pixelWidth; // Pass in an undefined pixelWidth to simulate it missing from ParamDefs.
let conditions;
let resources;
const expectedForm = new Form("TestOp", "TestOp", true, help, "small", pixelWidth, [primaryTabs], buttons, data, conditions, resources, "./test.svg");
const expectedForm = new Form("TestOp", "TestOp", true, help, "small", pixelWidth, [primaryTabs], buttons, data, conditions, groupMetadata, resources, "./test.svg");

const paramSpec = {
"current_parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import structureTableParamDef from "../test_resources/paramDefs/structuretable_p
import checkboxsetParamDef from "../test_resources/paramDefs/checkboxset_paramDef.json";
import actionParamDef from "../test_resources/paramDefs/action_paramDef.json";
import numberfieldParamDef from "../test_resources/paramDefs/numberfield_paramDef.json";
import textfieldParamDef from "../test_resources/paramDefs/textfield_paramDef.json";
import tabParamDef from "../test_resources/paramDefs/tab_paramDef.json";
import structuretablePropertyValues from "../test_resources/json/structuretable_propertyValues.json";
import ExpressionInfo from "../test_resources/json/expression-function-list.json";
import readonlyTableParamDef from "../test_resources/paramDefs/readonlyTable_paramDef.json";
Expand Down Expand Up @@ -590,6 +592,102 @@ describe("Properties Controller property values", () => {
const actualFilteredValues = controller.getPropertyValues({ filterHiddenControls: true, filterHiddenDisabled: true });
expect(expectedFilteredValues).to.eql(actualFilteredValues);
});

it("should get properties in active tab correctly", () => {
let renderedObject = testUtils.flyoutEditorForm(textfieldParamDef);
controller = renderedObject.controller;
let wrapper = renderedObject.wrapper;

// Open "Conditions" category
const conditionsCategory = wrapper.find("div.properties-category-container").at(1);
const conditionsButton = conditionsCategory.find("button.properties-category-title");
expect(conditionsButton.text()).to.equal("Conditions");
conditionsButton.simulate("click");

// Get all properties in active tab ("Conditions" tab)
let expectedAllPropertiesInActiveTab = {
string_error: "testing",
string_warning: "testing",
hide: true,
string_hidden: "testing",
disable: true,
string_disabled: "testing",
string_condition_handling: "testing"
};
let actualAllPropertiesInActiveTab = controller.getPropertyValues({ getActiveTabControls: true });
expect(expectedAllPropertiesInActiveTab).to.eql(actualAllPropertiesInActiveTab);

// getActiveTabControls: return all properties under selected tab/category
// filterHiddenDisabled: filter controls having state "hidden" or "disabled"
const expectedFilteredHiddenDisabledPropertiesInActiveTab = {
string_error: "testing",
string_warning: "testing",
hide: true,
disable: true,
string_condition_handling: "testing"
};
const actualFilteredHiddenDisabledPropertiesInActiveTab = controller.getPropertyValues({ getActiveTabControls: true, filterHiddenDisabled: true });
expect(expectedFilteredHiddenDisabledPropertiesInActiveTab).to.eql(actualFilteredHiddenDisabledPropertiesInActiveTab);

// getActiveTabControls: return all properties under selected tab/category
// filterHidden: filter controls having state "hidden"
const expectedFilteredHiddenPropertiesInActiveTab = {
string_error: "testing",
string_warning: "testing",
hide: true,
disable: true,
string_disabled: "testing",
string_condition_handling: "testing"
};
const actualFilteredHiddenPropertiesInActiveTab = controller.getPropertyValues({ getActiveTabControls: true, filterHidden: true });
expect(expectedFilteredHiddenPropertiesInActiveTab).to.eql(actualFilteredHiddenPropertiesInActiveTab);

// getActiveTabControls: return all properties under selected tab/category
// filterDisabled: filter controls having state "disabled"
const expectedFilteredDisabledPropertiesInActiveTab = {
string_error: "testing",
string_warning: "testing",
hide: true,
string_hidden: "testing",
disable: true,
string_condition_handling: "testing"
};
const actualFilteredDisabledPropertiesInActiveTab = controller.getPropertyValues({ getActiveTabControls: true, filterDisabled: true });
expect(expectedFilteredDisabledPropertiesInActiveTab).to.eql(actualFilteredDisabledPropertiesInActiveTab);


// Verify getActiveTabControls: true returns all properties in nested subtabs as well
renderedObject = testUtils.flyoutEditorForm(tabParamDef);
controller = renderedObject.controller;
wrapper = renderedObject.wrapper;

// Get all properties in active tab ("Tab Test" tab)
expectedAllPropertiesInActiveTab = {
hide: false,
disable: false,
fromValue: 2,
toValue: 1,
fields: [
"Age",
"Drug"
],
fruit: "apple",
other: "lemon",
readonly_double_subtabs: "If multiple subtabs are defined in a tearsheet, additional padding is required to avoid overlay.",
fromValue_summary: 2,
toValue_summary: 1,
fields_summary: [
"Age",
"Drug"
],
fruit_summary: "apple",
other_summary: "lemon",
openTearsheet: undefined
};
actualAllPropertiesInActiveTab = controller.getPropertyValues({ getActiveTabControls: true });
expect(expectedAllPropertiesInActiveTab).to.eql(actualAllPropertiesInActiveTab);

});
});

describe("Properties Controller states", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,57 @@
}
},
"conditions": [],
"groupMetadata":{
"groups":[
{
"name":"action-tests",
"type":"panels",
"label":{
"default":"Actions"
},
"subGroups":[
{
"name":"increment-action-panel",
"actions":[
"increment",
"decrement"
],
"type":"actionPanel"
},
{
"name":"number-control",
"parameters":[
"number"
],
"type":"controls"
}
]
},
{
"name":"summary-panel",
"type":"summaryPanel",
"label":{
"default":"Summary Panel Actions"
},
"subGroups":[
{
"name":"dm-action-panel",
"actions":[
"dm-update"
],
"type":"actionPanel"
},
{
"name":"summary-controls",
"parameters":[
"fields"
],
"type":"controls"
}
]
}
]
},
"resources": {
"increment": "Increment",
"decrement": "Decrement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,25 @@
}
}
],
"groupMetadata": {
"groups": [
{
"name": "basic-settings",
"type": "panels",
"label": {
"default": "Settings"
},
"subGroups": [
{
"parameters": [
"renamed_fields"
],
"type": "columnSelection"
}
]
}
]
},
"resources": {
"rename.label": "Rename Columns",
"RenameFieldEntry.field": "Input name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,20 @@
]
}
},
"groupMetadata": {
"groups": [
{
"name": "settings",
"parameters": [
"cols"
],
"type": "columnSelection",
"label": {
"default": "Settings"
}
}
]
},
"resources": {
"select.label": "Select Columns",
"mode.label": "Mode",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@
}
}
],
"groupMetadata": {
"groups": [
{
"name": "basic-settings",
"parameters": [
"renamed_fields"
],
"type": "columnSelection",
"label": {
"default": "Settings"
}
}
]
},
"resources": {
"rename.label": "Rename Columns",
"field.label": "Input name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@
]
}
},
"groupMetadata": {
"groups": [
{
"name": "basic-settings",
"parameters": [
"keys"
],
"type": "columnSelection",
"label": {
"default": "Settings"
}
}
]
},
"resources": {
"sort.label": "Sort",
"sort.desc": "Sorts the data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@
}
}
],
"groupMetadata": {
"groups": [
{
"name": "basic-settings",
"parameters": [
"int_param",
"exp_param"
],
"label": {
"default": "Settings"
}
}
]
},
"resources": {
"exp_param_not_empty": "Expression cannot be empty: Resource"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,65 @@
}
],
"data": {},
"groupMetadata":{
"groups":[
{
"name":"fields-settings",
"type":"panels",
"label":{
"default":"Field Settings label: default",
"resource_key":"column-settings.label"
},
"subGroups":[
{
"name":"field-allocation",
"parameters":[
"target",
"inputs"
],
"type":"columnSelection"
}
]
},
{
"name":"settings",
"parameters":[
"enum_param"
],
"label":{
"default":"Parameter Settings label: default"
},
"subGroups":[
{
"name":"enum-settings",
"type":"panelSelector",
"dependsOn":"enum_param",
"subGroups":[
{
"name":"Include",
"parameters":[
"int_param"
]
},
{
"name":"Discard",
"parameters":[
"double_param"
]
}
]
},
{
"name":"boolean-settings",
"parameters":[
"boolean_param",
"str_param"
]
}
]
}
]
},
"resources": {
"target.label": "Target label: resource",
"target.desc": "Target field description: resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Size } from "../constants/form-constants";
import { CONTAINER_TYPE } from "../constants/constants";

export default class Form {
constructor(componentId, label, labelEditable, help, editorSize, pixelWidth, uiItems, buttons, data, conditions, resources, icon, heading) {
constructor(componentId, label, labelEditable, help, editorSize, pixelWidth, uiItems, buttons, data, conditions, groupMetadata, resources, icon, heading) {
this.componentId = componentId;
this.label = label;
this.labelEditable = labelEditable;
Expand All @@ -35,6 +35,7 @@ export default class Form {
this.buttons = buttons;
this.data = data;
this.conditions = conditions;
this.groupMetadata = groupMetadata;
this.resources = resources;
this.icon = icon;
this.heading = heading;
Expand Down Expand Up @@ -77,6 +78,7 @@ export default class Form {
_defaultButtons(),
data,
translateMessages(conditions, l10nProvider),
propDef.groupMetadata,
resources,
propDef.icon,
l10nProvider.l10nResource(propDef.heading)
Expand Down
Loading

0 comments on commit 71555f5

Please sign in to comment.