Skip to content

Redesign model inputs into "store" pattern #583

@pinkwah

Description

@pinkwah

The models page has problems that make it difficult to handle the input flow. In particular, I would like to have the following features be available:

  • Setting the selected model and model input to something specific (eg. when the user sends a link with simulationId)
  • Flagging when the input has changed (eg. the user clicks on a simulationId link and types a different number for H2O, it should be evident that this happened)
  • Reverting changed values back to their defaults / past simulation inputs
  • Deleting concentrations that were previously added

We can maybe have a zustand store or something with the following API (TODO: Still thinking about this):

type StoreFields {
    selectedModel: ModelConfig
}

type StoreActions {
  /** Set the input to specific values, such as when sending someone a link with a past result */
  setInput(modelId: string, inputs: ModelInputs);

  setConcentration(modelId: string, name: string, amount: number);

  setParameter(modelId: string, name: string, value: string | number | boolean);
}

We may also want to think about how we can make this work with a sequence of simulations. Maybe when the user clicks on a model, it creates some new ModelInput instance?

As only the Models.tsx page needs this, I think we can bring all the details into that file (or related files), and assume that no other page will ever use this store code. Ie, the flow of the store is allowed to be specific to the Models page.

Metadata

Metadata

Assignees

No one assigned

    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