AdrianKoszalka opened a new pull request, #31998:
URL: https://github.com/apache/superset/pull/31998

   ### SUMMARY
   This PR introduces a new Handlebars helper, parseJson, which enhances the 
functionality of Handlebars templates in Apache Superset. The helper allows the 
processing of more complex data structures, such as arrays containing nested 
arrays, by safely parsing JSON strings into JavaScript arrays
   
   Usage Example:
   
   Here’s an example that demonstrates how parseJson enables iteration over 
nested arrays in Handlebars templates:
   `data` object: 
   ```
   [
     {
       "category": "Fruits",
       "items": ["Apple", "Banana", "Cherry"]
     },
     {
       "category": "Vegetables",
       "items": ["Carrot", "Broccoli", "Spinach"]
     }
   ]
   ```
   
   Handlebars template:
   ```
   <div>
     {{#each data}}
       <h2>{{this.category}}</h2>
       <ul>
         {{#each (parseJson this.items)}}
           <li>{{this}}</li>
         {{/each}}
       </ul>
     {{/each}}
   </div>
   ```
   
   ### TESTING INSTRUCTIONS
   1. Create a Dataset
   1.1. Navigate to the Datasets tab in Superset and create dataset containing 
nested arrays. (You can use data from example)
   2. Create a Handlebars Chart
   2.1. Go to the Charts tab
   2.2. Select + Chart, and choose Handlebars Chart.
   2.3. Select the `Nested Array Dataset` and use the template from usage 
example
   3. Confirm the chart renders nested arrays as lists.
   4. Test Pre-Change Behavior
   4.1. Remove (parseJson) from the template and verify that list is not 
properly handled.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [X] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to