XGovFormBuilder / digital-form-builder

Exploring how to quickly and easily design/prototype/deploy high quality digital forms for UK Gov. Based on the excellent work by DEFRA. Currently maintained by jen+forms@cautionyourblast.com at Caution Your Blast and a community collaboration between FCDO, HO, GDS, DfE, DIT, Version 1, UKHSA
https://digital-form-builder-designer.herokuapp.com/app
MIT License
55 stars 33 forks source link

Feature: Make repeating sections aka "Add multiple things" #798

Open delaynesr opened 2 years ago

delaynesr commented 2 years ago

Is your feature request related to a problem? Please describe. Need expressed for a feature that allows designers using the form builder to link question pages that can be repeated if the user (completing the form) specifies. This would be used, for example, to add the details of multiple tenants to a property, or adding past addresses. The same questions need to be answered for multiple entries. At the moment, the designer using the form builder has to make the series of pages over again which is labour intensive and creates an unnecessarily long form that is hard to digest in the current designer interface.

Describe the solution you'd like Adding the ability to make linked question pages into a repeating section. The idea is to make the section repeat, since this is a feature already in the designer that groups pages. I am suggesting adding a simple checkbox to the "Add a new section" page and the "Edit section" page which would make the pages in the given section repeat until the user decides to stop adding information. In the future, there will probably need to be settings designed for this, such as setting the maximum number of entries a user can make. I haven't applied this to the design yet though. There will also need to be notifications to tell the designer using the form builder that a particular section is repeating and indication on the main designer interface the signify what sections are repeating. I have made some design suggestions for how we could do this below. You will notice some changes to other parts of creating and managing/editing section tasks but I will outline these in a separate post.

New design with make repeating section feature

Manage sections _Add a new section_ _Edit section_ _Edit page_ _Add a page_ new Designer interface repeating sections

Additional Comments GDS - "Add multiple things": https://design.homeoffice.gov.uk/patterns/add-multiple-things

In the process of designing this feature, I have made adjustments/design suggestions for the whole process of creating and managing sections. TBC for linked post containing this info.

jenbutongit commented 3 months ago

I've done a spike into this.. it's a bit of a monster but manageable. There are a few refactors that are necessary otherwise it would bloat the PR.

To do:

Section definition / class

State changes

Currently, the state appears like so

{
  caz: "Bristol",
  registration: { // section called "registration"
    registrationNumber: "OUTATIME",
    registrationDate: "1985-10-01",
    colour: "silver",
  },
};

When a section is repeated, the state will appear as an array

{
  caz: "Bristol",
  registration: [{ 
    registrationNumber: "OUTATIME",
    registrationDate: "1985-10-01",
    colour: "silver",
  },
  { 
    registrationNumber: "OU7A7IM3",
    registrationDate: "2000-10-01",
    colour: "red",
  }],
};

Mini summary

Summary page

https://github.com/XGovFormBuilder/digital-form-builder/assets/22080510/4e5fae43-c978-4d0b-9189-ccd4a0f3ad9d