therealkevinard opened a new pull request #7382: [SIP #7380] Add optional, user-friendly label to Filter Box URL: https://github.com/apache/incubator-superset/pull/7382 ### CATEGORY - [ ] Bug Fix - [x] Enhancement (new features, refinement) - [ ] Refactor - [ ] Add tests - [ ] Build / Development Environment - [ ] Documentation ### SUMMARY This PR corresponds to SIP https://github.com/apache/incubator-superset/issues/7380 It allows the Filter Box to optionally source its option labels from a different field than the filter value. *Notes:* - this is backwards-compatible/non-breaking. The fallback/default behavior is to use the original label=value strategy. This also doesn't interfere with the metric property implementation. ### ~~BEFORE/~~ AFTER SCREENSHOTS **New Filter Box configuration** *Note the second select box, labeled "Single Option Label". It's a poor name for the option, but "Label" is more relevant where it is, and clarification was needed.*  **Filter Box using the friendly labels.**  ### TEST PLAN _all code/config here is from my personal reference implementation. of course, adjust field names/sql as needed_ 1. Setup a query that returns at least 2 fields: one for the filter value, and a separate one for the filter label - The source query from my reference use-case is: ```sql select array_agg(gorm_pipeline_resources.tokenized_resource_id) as pipeline_datasets, pipelines.name as pipeline_name from pipelines left join users on pipelines.owner_id = users.id left join gorm_pipeline_resources on pipelines.id = gorm_pipeline_resources.pipeline_id where owner_id = 1 group by pipelines.id order by pipeline_name ASC ``` - its sql lab output is  2. Configure a filter box using this datasource, according to the screenshots above. - For the filter in question, select Column: `pipeline_datasets` Single Option Label: `pipeline_name` 3. Create a datasource that references the filter: ```jinja2 {% set vals = filter_values('pipeline_datasets', '0')[0] %} SELECT datasource_id as "ds_id", other_fields, from some_table WHERE datasource_id in ({{ vals|replace("[",'')|replace("]",'') }}) ``` 4. As usual, add the filter box, and chart(s) whose datasets reference the filter param. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [x] Changes UI: optionally, allows filter box labels to come from a different field than the values. - [ ] Requires DB Migration. - [ ] Confirm DB Migration upgrade and downgrade tested. - [x] Introduces new feature or API: resolves SIP #7380 (pending) - [ ] Removes existing feature or API ### REVIEWERS
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
