Skip to content

Provide preferred pattern for modals launched via either application or action button #31

@aduane

Description

@aduane

We observed the CPA's tendency to lump everything into a single class: html, js, css, data retrieval, launcher, modal definition.
We should offer the preferred pattern:

  • Launcher (whether action button or application) is only responsible for the configuration of the modal (button placement, modal size and location, and content url)
  • Content from that URL is retrieved via a SimpleAPI handler, which is responsible for data access enforcement, most often decided by session user
    • The SimpleAPI handler retrieves whatever data is needed to form the context provided to the template
    • The SimpleAPI handler uses render_to_string to insert that context into an HTML template
    • The HTML template may include JS or CSS in-line if there is not much to be included
    • JS and CSS may be provided as separate endpoints in the SimpleAPI handler
  • Templates and static content are provided in the plugin as separate files and not as python strings inline with the handler.

An example plugin showcasing this pattern can be found here: https://github.com/canvas-medical/canvas-plugins/tree/main/example-plugins/example_provider_page/example_provider_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