Skip to content

All config Elements should be initializeable with an empty model object. #124

Open

Description

@evaneus

For each configure element defined in pie-elements/packages/[pie-name]/configure

Verify that the UI can load with an empty model object. If this object is not provided the UI should render with some sensible defaults.

Have a conversation with @edeustace to get started on this.

Activity

  1. edeustace commented on Mar 5, 2019

    @edeustace
    Contributor

    I think there are 3 parts to this.

    1. the ui will render without blowing up, if the model is incomplete/empty.
    2. the controller should be able to render a ui model without blowing up, if the model is incomplete/empty
    3. if the model is empty, render some form of default model.

    I think part 3 requires a bit more thought as to what the flow should be.

    Basically the question is where should the logic to build a default model live, ahd what would be flow around using it?

    For me it's either put it the UI element or put it in the controller

    If you put it in the UI element, the rendering context will need to handle 'model-updated' and persist the change.

    If you put it in the controller, the rendering context will create the model using a controller method say createConfigModel(), save it, then pass that into the ui.

    I'd vote for exposing this method on the controller. The controller is available in the rendering context, so is simple to call. Also I think the controller should be in charge of managing the model.

    const newElement = ( elementType ) => {
      const model = pie[elementType].controller.createConfigModel( {id: '1', prompt: 'custom prompt'});
      save(model)
        .then( ( ) => {
           el.model = model;
        })
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions