msupply-foundation / conforma-web-app

Conforma application manager (IRIMS) front-end
GNU Affero General Public License v3.0
5 stars 0 forks source link

Ingredients list plugin (Table in original IRIMS) #489

Closed nmadruga closed 3 years ago

nmadruga commented 3 years ago

From "IRIMS description truncated user guide.pdf":

Screen Shot 2021-05-17 at 12 53 36 PM

Screen Shot 2021-05-17 at 12 53 42 PM

CarlosNZ commented 3 years ago

I have a thought about how this might work utilising existing plugins (partly).

Because it seems each "ingredient" requires the filling in of its own "mini-form" that uses the same kind of fields we already have.

How would it be if we created the "mini-form" for inputting ingredients using our existing elements (shortText, radioChoice etc.), then we make a new plugin called "buildList". It's parameters would specify a range of existing responses to take in as input and create one "ingredient"?

The plugin UI would have:

I dunno, there may be technical limitations and other problems with this approach that I haven't forseen, but it'd be good to be able to build this fairly complicated ingredients input interface without duplicating existing plugin functionality.

If you think this is a workable idea, let me know and I'll come up with a more detailed description.

CarlosNZ commented 3 years ago

Here's a quick mockup of how it might look:

Ingredients List

andreievg commented 3 years ago

I see a few challenges in implementing this (a lot of them are dealt with by above, but not all)

Validation

I think we would need a 'custom' validation, it would go through every row and do the validation

Visibility of the form

As mentioned above, visibility of the enterable fields need to be toggled

Space

I think our form is too narrow for this sort of plugin. Maybe a modal for adding/editing ?

Re-using plugins

For sure

Brainstorming

paramaters:

{
  form: [
    {
      code: 'someCode',
      title: 'Country code',
      elementTypePluginCode: 'dropdownChoice',
      parameters: {
        search: true,
        options: {
          operator: 'graphQL',
          children: [
            'query countries { countries { code name } }',
            'https://countries.trevorblades.com',
            [],
            'countries',
          ],
        },
        optionsDisplayProperty: 'code',
        placeholder: 'Type one country code (2 digits)',
      },
      '//': 'below is an examples considering the uniqueness case, by the sounds of it its not that important',
      validation: {
        '//': 'just an example of new operator that tries to find a match',
        operator: 'noMatch',
        children: [
          {
            operator: 'objectProperties',
            '//': 'custom validation can insert rows if needed',
            children: ['rows.thisRow.someCode'],
          },
          {
            operator: 'extractObjectKeyFromArray',
            children: [
              {
                operator: 'objectProperties',
                children: ['rows'],
              },
              'someCode',
            ],
          },
        ],
      },
    },
    {
      '//': 'other bits of form',
    },
  ],
  '//': 'other parameters',
}

validation:

a custom validation method that uses evaluator. iterates over each row and each key, and uses inner plugin validation. can render validation errors under each row (or even in each cell).

andreievg commented 3 years ago

I've made a start on the diagram of ApplicationViewWrapper, it's only half done: https://app.diagrams.net/#G1WSMwIiyfmW02z5aqExDcrBurGDxEJfVZ

CarlosNZ commented 3 years ago

And aside from the above, I was envisaging parameters and response shape as follows:

Parameters

Response structure

CarlosNZ commented 3 years ago

I'm going to do a quick proof-of-concept for Andrei's idea of running other plugins as children of the Ingredients list. Will be very simple, just want to check that it will work how we imagine, then we can go from there.