bedatadriven / activityinfo-R

ActivityInfo R Language Client
https://www.activityinfo.org/support/docs/R/
18 stars 12 forks source link

Form schema in `data.frame` format to pass into form schema functions #33

Open Ryo-N7 opened 2 years ago

Ryo-N7 commented 2 years ago

Update form schema in data.frame format and pass into the updateFormSchema() to update it. Not as much a priority as previous points as people can just get better at manipulating list objects but could be a useful functionality for all users not just AV.

Ryo-N7 commented 1 year ago

workflow:

  1. change form schema to df view
  2. which will let me use mutate() to modify field elements (change description, etc.)
  3. change back into list-format
  4. upload new form schema back into db with updateFormSchema()
nickdickinson commented 1 year ago

Even slightly neater but with a little more code (TBD) would be to have a custom class extending data.frame so that it is recognized as a form schema and could contain some additional metadata in attributes. This could be fed it directly to updateFormSchema() without an additional conversion step.

nickdickinson commented 1 month ago

@jamiewhths @akbertram Is this something we still want to do? This will create the table.

tibble(element = fmSchema$elements) %>% unnest_wider(element)

To go back to the form, we'd loop through the table records and call formFieldSchema() with the given parameters. Most checks are built in so it may not be too much work and probably we can call the arguments dynamically from the column names. Then we'd need to add a test or two.