Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
evaneus opened this issue Mar 4, 2019 · 1 comment
Open
Assignees

Comments

@evaneus
Copy link
Contributor

evaneus commented Mar 4, 2019

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.

@edeustace
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants