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.* 
   
   ![Screenshot from 2019-04-25 
09-17-59](https://user-images.githubusercontent.com/12756908/56738681-11bf6c80-673b-11e9-84fe-4fd483ffa42a.png)
   
   **Filter Box using the friendly labels.** 
   ![Screenshot from 2019-04-25 
09-16-07](https://user-images.githubusercontent.com/12756908/56738589-eb013600-673a-11e9-8d22-6d30ac9ab5fd.png)
   
   
   ### 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
   ![Screenshot from 2019-04-25 
09-27-25](https://user-images.githubusercontent.com/12756908/56739333-6a433980-673c-11e9-94fb-845d325531e0.png)
   
   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]

Reply via email to