# Epic OP-8375 - Multi-selection for project custom fields of type list

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-8375

## Detailed specification

### Motivation and background information

### Acceptance criteria

### Out of scope

| Attribute | Value |
| --- | --- |
| Mockups |  |

## Planning

| Attribute | Value |
| --- | --- |
| Roadmap |  |
| Date |  |
| Votes |  |
| List |  |
| Target versions | 11.3.0 |
| Sprint | 11.3.0 |
| Backlog bucket |  |
| Relevance |  |

## Subitems

| ID | Type | Subject | Status | Assignee | Target versions | Project | Priority | Spent time |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| OP-8428 | Feature | Allow multi select custom fields in the backend (Administration, API, project list view and filters, ...) | closed |  | 11.3.0 | OpenProject | Medium |  |
| OP-8429 | Feature | Replace project forms by Angular/formly (Create and update + widgets) | closed |  | 11.3.0 | OpenProject | Medium |  |
| OP-8430 | Feature | Allow multi select in angular/formly based project forms (create and update + details widget) | closed |  | 11.3.0 | OpenProject | Medium |  |

## Bugs and other work packages

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Module |  |
| Enterprise plan |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Feature Lead |  |
| Designer |  |
| Developers |  |
| Requested by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| Work |  |

## Description

For work packages, fields can be configured as multiple selections for all projects or for individual projects. The same function is desired for user-defined fields of the type Project.

**Acceptance requirements**

  - The administration of custom fields for projects gets a checkbox "Allow multi-select", just like the lists for work packages
  - The project form is extended such that list custom fields can be multi-selected
  - The project advanced settings is extended such that list custom fields can be multi-selected
  - The project overview list/table is extended to show multi-select custom fields
  - The project details widget on the project overview / dashboard displays custom lists with multiple selections.
  - When copying projects, multi-selection custom fields are also copied

<figure class="image op-uc-figure"><div class="op-uc-figure--content"><img class="op-uc-image" src="/api/v3/attachments/20761/content"></div></figure>

### Development Notes

  - Test route: <http://localhost:4200/projects/demo-project/settings/generic/>
  - Admin \> Custom fields \> Wps \> multiselect checkbox
      - Project \> Overview \> Project details should allow multi-select custom fields
  - Form Config:
      - <https://docs.openproject.org/api/endpoints/projects/>
      - <https://docs.openproject.org/api/endpoints/projects/#projects-projects-schema>
      - <https://docs.openproject.org/api/endpoints/projects/#projects-project-create-form>
  - 3 steps:
      - Replace view with formly
      - Enable the backend capable of multiselect fields project
      - Enable multiselect fields project in the frontend

### Dev requirements

  - Change Sources:
      - Layout:
          - Schema loading (FormConfig):   
            When the user changes the type.
              - First load
              - Schema change
      - Model:
          - Schema loading (Payload (Model + Default values)) :  
            When the user changes the type.
              - First load
              - Schema change
          - User interaction
  - Form component:
      - 2 ways of getting its config:
          - New \>\>\> POST to *api/v3/projects/\[projectId\]/work\_packages/form* with payload *{\_links: {type: {href: "/api/v3/types/1"}}}*
          - Existing \>\>\> POST *api/v3/work\_packages/\[wp\_id\]/form* with payload  *{lockVersion: 2, \_links: {}}*

### 

### DynamicForm use cases:

  - Standalone Form:
      - settings
          - from backend
          - from @Input
      - submit
          - needs resourcePath
  - FormControl
      - settings
          - from backend
          - from @Input
      - submit
          - NO

### TODO

- [x] Move groupField creation as @Input
- [x] A \<formly-field\> tag is wrapping all the \<formly-field\> tags (could be related with the way the groups are defined (\_links...))
- [x] Handle general server errors (right now it is always showing 'Please...')
- [x] fix/fix-form-styles / form-field wrapping the entire form
- [x] Submit form.getRawValue to avoid missing disabled fields
- [x] op-form-group--label styles?
- [x] Open advanced settings when there is an invalid field
- [x] (Other ticket) The select fields should have autocompleters IMO. After all, this would highlight the benefit of having turned it into an Angular form.
- [x] CSS Animation?
- [x] Extract the create group function to dynamic forms
- [x] Attribute help texts
- [x] Handle `_meta.*` properties similar to `_links`
- [x] CSS:
  - [x] new project form doesn't expand all the width
  - [x] field with error hides red border on hover
- [x] form.payload.name default value is "" (?)
- [x] Merge: The Active field should not be rendered as the functionality is handled via the Archive/Unarchive button
- [x] Allow to update only the payload (currently all the formSettings are updated at the same time wich would lead to reload the entire form in order to just set the model).
- [x] The Status field, now that we are in angular, should have that bulb similar to how it is in the widget
- [x] Sort fields in the front
- [x] Replace project setting's Information tab:
  - [x] exclude required disk storage
- [x] Review TODOs
- [x] Hide non-writable fields
- [x] Hide identifier
- [x] Multiselect custom fields
  - [x] Top left buttons (subproject, copy project...)
- [x] Next steps:
  - [x] Clean useless code and do a draft PR (wp specific case)
  - [x] Op-form-field
  - [x] Differentiate between update/create form (/id or href)
    - [x] Create routes:
      - [x] Take the formId from the params?
- [x] Custom fields (starting with \[\])
- [x] Print form
- [x] Fill model
- [x] Default values
- [x] Group fields
- [x] Layout
- [x] Validation
  - [x] Sync
  - [x] Async
- [x] Custom component
- [x] Send to endpoint
  - [x] Postprocess the model
    - [x] Set default values if the user has deleted the default value
- [ ] New Inputs:
  - [x] TextEditFieldComponent
  - [x] IntegerEditFieldComponent
  - [x] SelectEditFieldComponent
  - [x] MultiSelectEditFieldComponent
  - [x] DateEditFieldComponent
    - [x] two datepickers are displayed
    - [x] not close on blur
    - [x] displayed when invalid (also the rest of the project)
    - [x] not disabled properly when formControl.disable
  - [x] FormattableEditFieldComponent
    - [x] *onTouch not working this*.editor.ckEditorInstance.ui.focusTracker.on( 'change:isFocused'
  - [x] FloatEditFieldComponent
  - [x] BooleanEditFieldComponent
- [ ] Others
  - [x] Translations
  - [x] Manage focus
    - [x] ng-select
    - [x] Between fields with tabs (inline edit)
  - [x] Routes
    - [x] Existing form route
    - [x] New form route
    - [x] Redirect when new form is created
    - [x] Resolve data before entering the route?
  - [x] Check touched, disabled, change, onsubmit... on every new input (datepicker)
  - [x] User feedback on submit success/error
  - [x] Import only necessary fields from OpenprojectFieldsModule into DynamicFormsModule (EditFieldControlsComponent)
  - [x] Where do we place the submit button?
