# Feature DREAM-266 - Create new component: TreeViewSelectPanel

Project: Stream Design System
Status: in specification
URL: https://community.openproject.org/work_packages/DREAM-266

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | Product Backlog |
| Sprint |  |
| Backlog bucket |  |
| Votes |  |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module | Frontend components and Primer design system |
| Feature Flag |  |
| Requires doc change | No |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable | Henriette Darge |
| Product manager |  |
| Developers | Cameron Dutro |
| Designer | Parimal Satyal |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

### **Context**

We implemented a Rails/ViewComponent version of Primer's Treeview: <mention class="mention" data-id="62667" data-type="work_package" data-text="###62667">\#\#\#62667</mention> , 

as well as a FilterableTreeView component (<mention class="mention" data-id="63717" data-type="work_package" data-text="###63717">###63717</mention>)

Whilst useful, there are places like the 'Include projects' drop-down, which requires the FilterableTreeView to be shown inside an inplace dialog. The [Select panel](https://primer.style/components/selectpanel) would solve this problem if it supported hierarchies, but it doesn't.

### **Acceptance criteria**

  - Create a new Primer component will be constructed with:
    
      - A container like the Select panel but
    
      - The ActionList replaced by a FilterableTreeView
    
      - triggered by a button

  - The **container** should
    
      - be wide enough to comfortably display at least 5 levels of hierarchy
    
      - rendered next to the triggering button

  - The **list** should look and behave like a FilterableTreeView 🌳 including
    
      - a text field to filter
    
      - a segmented control with defaults "All"|"Selected"
    
      - a checkbox to include all sub-items at once
    
      - allow selecting only one or multiple items
    
      - The nodes in the list can be expanded/collapsed
    
      - The list should support unlimited levels of hierarchy

  - The **button** shows a counter indicating how many items are selected (given the selec\_strategy is multiselect). This counter is updated only on save

  - The component should require the user to explicitly execute an action on that list (eg. "Apply")
    
      - That button is fixed at the bottom, so that it does not have to be scrolled to

  - Accessibility:
    
      - Ideally, we'd benefit from Primer's SelectPanel accessibillity consideration

#### **Additonal considerations**

These additional features or options are worth considering but might not have to be a part of the component itself:

  - An additional action that acts on the whole list (eg. 'Select all' / 'Clear selection')

#### **Use cases**

<figure class="table op-uc-figure_align-center op-uc-figure"><table class="op-uc-table"><tbody><tr class="op-uc-table--row"><td class="op-uc-table--cell" style="vertical-align:top;width:100px;"><p class="op-uc-p"><strong>Use case</strong></p></td><td class="op-uc-table--cell" style="vertical-align:top;width:500px;"><p class="op-uc-p"><strong>Dominic's original notes</strong></p></td><td class="op-uc-table--cell" style="vertical-align:top;"><p class="op-uc-p"><strong>Remarks</strong></p></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell" style="vertical-align:top;width:100px;"><p class="op-uc-p"><strong>Include projects</strong></p></td><td class="op-uc-table--cell" style="vertical-align:top;"><p class="op-uc-p">In work package list a user usually only sees work packages of the current project. But if wanted, the user can include work packages of other projects with the "include projects" selector.</p><p class="op-uc-p"><strong>Functionality</strong></p><ul class="op-uc-list"><li class="op-uc-list--item"><p class="op-uc-p">Shows all projects available to the user in a hierarchical structure</p></li><li class="op-uc-list--item"><p class="op-uc-p">User can enable one or more projects (checkbox)</p></li><li class="op-uc-list--item"><p class="op-uc-p">"Only selected"-filter to allow user an overview of the selected items</p></li><li class="op-uc-list--item"><p class="op-uc-p">"Include all sub-projects"-option to enable all sub-projects when a project is enabled.</p></li><li class="op-uc-list--item"><p class="op-uc-p">Deselect all projects</p></li></ul><p class="op-uc-p"><img class="image_resized op-uc-image op-uc-image_inline" style="width:295px;" src="/api/v3/attachments/415033/content"></p></td><td class="op-uc-table--cell" style="vertical-align:top;"><p class="op-uc-p"><br data-cke-filler="true"></p></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell" style="vertical-align:top;width:100px;"><p class="op-uc-p"><strong>Project selector to activate eg. storages</strong></p></td><td class="op-uc-table--cell" style="vertical-align:top;"><p class="op-uc-p">User can select multiple projects to activate a project attribute, a work package type, a storage or other objects that can be added per project</p><p class="op-uc-p"><strong>Functionality</strong></p><ul class="op-uc-list"><li class="op-uc-list--item"><p class="op-uc-p">Shows all projects available to the user in a hierarchical structure</p></li><li class="op-uc-list--item"><p class="op-uc-p">User can add projects one by one or include all sub-projects</p></li><li class="op-uc-list--item"><p class="op-uc-p">Projects that already have this storage activated are disabled</p></li></ul><p class="op-uc-p"><img class="image_resized op-uc-image op-uc-image_inline" style="width:511px;" src="/api/v3/attachments/415096/content"></p></td><td class="op-uc-table--cell" style="vertical-align:top;"><ul class="op-uc-list"><li class="op-uc-list--item"><p class="op-uc-p">We already have a fully-functioning auto-completor with project selector (Angular).</p></li><li class="op-uc-list--item"><p class="op-uc-p">Same as include project: Select panel with multi-level would be more useful (can input names)</p></li></ul></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell" style="vertical-align:top;width:100px;"><p class="op-uc-p"><strong>Selector for custom field of type hierarchy</strong></p></td><td class="op-uc-table--cell" style="vertical-align:top;"><p class="op-uc-p">A user wants to select one or more items of a hierarchy.</p><ul class="op-uc-list"><li class="op-uc-list--item"><p class="op-uc-p">Work package table<br><img class="image_resized op-uc-image op-uc-image_inline" style="width:316px;" src="/api/v3/attachments/415073/content"></p></li><li class="op-uc-list--item"><p class="op-uc-p">Work package details view<br><img class="image_resized op-uc-image op-uc-image_inline" style="width:394px;" src="/api/v3/attachments/415068/content"></p></li><li class="op-uc-list--item"><p class="op-uc-p">Project attribute of type Hierarchy - not implemented yet<br><img class="image_resized op-uc-image op-uc-image_inline" style="width:418px;" src="/api/v3/attachments/415076/content"></p></li><li class="op-uc-list--item"><p class="op-uc-p">Work package field in copy form - not implemented yet<br><img class="image_resized op-uc-image op-uc-image_inline" style="width:382px;" src="/api/v3/attachments/415075/content"></p><p class="op-uc-p"><br><br><br><br><br><br><br><br>&nbsp;</p></li></ul></td><td class="op-uc-table--cell" style="vertical-align:top;"><p class="op-uc-p">Similar to include projects (Select panel with hierarchy)</p></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell"><p class="op-uc-p"><strong>Project selector for admin settings requireing the selection of projects (Eg. Project attributes)</strong></p></td><td class="op-uc-table--cell"><p class="op-uc-p">Places with the 'Project' tab, eg. File storages.</p><p class="op-uc-p">Today in a dialog but perhaps this is not necessary once we have this component.</p><p class="op-uc-p"><img class="image_resized op-uc-image op-uc-image_inline" style="width:678px;" src="/api/v3/attachments/434783/content"></p></td><td class="op-uc-table--cell"><p class="op-uc-p">Replace modal but with a way to select project by traversing the hierarchy. With an option of course to include all sub-projecs.</p></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell"><p class="op-uc-p"><strong>Wiki page management</strong></p></td><td class="op-uc-table--cell"><p class="op-uc-p"><br data-cke-filler="true"></p></td><td class="op-uc-table--cell"><p class="op-uc-p">For actions like bulk delete or bulk move. Might need draggable.&nbsp;</p><p class="op-uc-p">Wiki is not the biggest priority right now.</p></td></tr></tbody></table></figure>

\--------------------------------

**Initial thoughts from meeting with Cameron:**

  - But we can start with a static list for v1 and then iterate and write scenarios.

  - We *could* potentially, at a component level, apply the same filter criteria to the server results. Let the feature deal with it.

  - An alternate approach is, instead of 'show more', require the search to be more specific and afford ways for the user to be more specific. Worth considering.

  - Select panel has three fetch strategies:
    
      - local/static
    
      - eventually local / lazylocal
    
      - remote

**Old considerations regarding async loading**

  - *\[open\] The component allows two filtering stategies.*
    
      - *Static: only if the underlying TreeView itself is static*
        
          - *filtering is done at browser-level (no server calls required)*
    
      - *Dynamic: if the underlying TreeView is dynamic (additional async calls can be made) (?? Open: Could probably also be used if the underlying TreeView is static)*
        
          - *filtering will send a new request to the server to populate **all** results that match the given string,*
        
          - *If there is a lot content (eg. over 25 objects, regardless of if this is a parent or the result node):*
            
              - *The component display only the first 25 items and there will be a 'Show more' action at the very bottom. This includes both nodes and leaves in the hierarchy.*
            
              - *Clicking on the show more will append the next 25 items to the list.*
            
              - *\[Open\] Does that mean that with the dynamic loading strategy we also only show 25 items when opening the component (so before anything was filtered)*
            
              - *The logic to decide which items to show is as follows:*
                
                  - ***Start at the top level**: Begin with the first top-level node and expand it.*
                
                  - ***Load children**: Display the children of the first node until the 25-item limit is reached.*
                
                  - ***Nested nodes**: If the first node contains child nodes (i.e., nested nodes), the **first child node should be expanded first**, and its children should be displayed with priority (e.g., 1 child node + 23 of its children = 24 + 1 top-level node = 25).*
                
                  - ***Expand additional nodes**:*  
                    *If the first node has fewer than 24 children (including child nodes), the next top-level node is expanded, and its children are displayed until the total of 25 visible elements is reached*
