rollthecloudinc / quell

Climate aware CMS breaking web apps free from carbon emissions.
https://demo.carbonfreed.app/pages/create-panel-page
GNU General Public License v3.0
14 stars 1 forks source link

create ordain module #307

Closed ng-druid closed 1 year ago

ng-druid commented 1 year ago

The ordain module will provide the validation plugin manager and models.

https://github.com/rollthecloudinc/druid/issues/159

ng-druid commented 1 year ago

Completed:

Visual Aids

New Validation Editor

Screen Shot 2022-07-30 at 10 18 57 PM

Issues

  1. Validation status of form element not propagating up to panel page. This prevents detection of invalid form elements. The panelpage form is always valid since the status isn't making its way all the up the panel page hierarchy. (complete)
  2. Users should be able to customize error messages and use tokens inside messages. Tokens will include access to available contexts and exposed values of validation.

Considerations

ng-druid commented 1 year ago

Debugging Status Propagation:

I seem to have been able to work my way around issue 1 above. This was achieved by doubling up the validation on both the proxy control and parent control. The proxy control uses the raw value where as the serialized value is being used to the parent settings form control. I made the builder function compatible with both these data type contexts by adding a serialized boolean to let the builder function know whether it is operating on raw data or serialized data.

Verified by hitting submit. console logs "detected invalid form" rather than persist of data. When form valid data is logged and persisted.

Screen Shot 2022-07-31 at 12 07 33 AM Screen Shot 2022-07-31 at 12 07 25 AM
ng-druid commented 1 year ago

Task: Customized Error messages

At the moment a single static value inside a dedicated component. The editor will have text area to override and use tokens inside error messages.

Example: "At least [.min] characters required."

Where [.min] would be replaced by the validation return object (_root).min. The validation return object would act as the _root context when replacing tokens in error messages.

This is complete.

Screen Shot 2022-07-31 at 12 20 57 AM
ng-druid commented 1 year ago

Idea:

Validator that integrates with avm (json schema). Accepts url to json schema file. Validator that can expand into multiple validators when being used on forms. For example, a json schema that expands into multiple validators. Would that even be needed?

This might be better of as a spell.

ng-druid commented 1 year ago

The mvp for forms validation is complete. Form elements on panel pages now have optional validation capabilities. Druid core supplies angular core validators. New validators can be added as plugins. Future features/integrations below.

Some trivial clean-up to follow before merge such as; reducing repeating code for resolving params.