Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow filtering of table select column label #36755

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,17 @@ describe(
expect(afterSearch).to.eq("Software Engineer");
});
table.RemoveSearchTextNVerify("1", "v2");
});

// Search for a value in the table
table.SearchTable("20");
table.ReadTableRowColumnData(0, 2, "v2").then((afterSearch) => {
expect(afterSearch).to.eq("Product Manager");
it("12. Verify table filter for select column type", function () {
featureFlagIntercept({ release_table_cell_label_value_enabled: true });
table.OpenNFilterTable("role", "is exactly", "Product Manager");
table.ReadTableRowColumnData(0, 2, "v2").then(($cellData) => {
expect($cellData).to.eq("Product Manager");
});
table.ReadTableRowColumnData(1, 2, "v2").then(($cellData) => {
expect($cellData).to.eq("Product Manager");
});
table.RemoveSearchTextNVerify("1", "v2");
});
},
);
14 changes: 8 additions & 6 deletions app/client/src/widgets/TableWidgetV2/widget/derived.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ export default {
* For select columns with label and values, we need to include the label value
* in the search
*/
let labelValueForSelectCell = "";
let labelValuesForSelectCell = {};
jacquesikot marked this conversation as resolved.
Show resolved Hide resolved
/*
* Initialize an array to store keys for columns that have the 'select' column type
* and contain selectOptions.
Expand Down Expand Up @@ -716,13 +716,15 @@ export default {
primaryColumns[key].selectOptions,
);

let selectOptions;
let selectOptions = {};

/*
* If selectOptions is an array, check if it contains nested arrays.
* This is to handle situations where selectOptons is a javascript object and computes as a nested array.
*/
if (isSelectOptionsAnArray) {
const selectOptionKey = primaryColumns[key].alias;

if (_.some(primaryColumns[key].selectOptions, _.isArray)) {
/* Handle the case where selectOptions contains nested arrays - selectOptions is javascript */
selectOptions =
Expand All @@ -732,7 +734,7 @@ export default {
});

if (option) {
labelValueForSelectCell = option.label;
labelValuesForSelectCell[selectOptionKey] = option.label;
}
} else {
/* Handle the case where selectOptions is a flat array - selectOptions is plain JSON */
Expand All @@ -742,7 +744,7 @@ export default {
);

if (option) {
labelValueForSelectCell = option.label;
labelValuesForSelectCell[selectOptionKey] = option.label;
}
}
} else {
Expand All @@ -753,15 +755,15 @@ export default {
);

if (option) {
labelValueForSelectCell = option.label;
labelValuesForSelectCell[selectOptionKey] = option.label;
}
}
});
}

const displayedRow = {
...row,
labelValueForSelectCell,
...labelValuesForSelectCell,
...columnWithDisplayText.reduce((acc, column) => {
let displayText;

Expand Down
Loading