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

Documentation: Modals #305

Closed
mpscholten opened this issue Aug 6, 2020 · 1 comment · Fixed by #539
Closed

Documentation: Modals #305

mpscholten opened this issue Aug 6, 2020 · 1 comment · Fixed by #539

Comments

@mpscholten
Copy link
Member

No description provided.

@ruhatch
Copy link
Collaborator

ruhatch commented Aug 9, 2020

Following copied from Gitter

Here’s some example code:

action CommentsAction { postId } = do
    comments <- query @Comment
        |> filterWhere (#postId, postId)
        |> orderBy #createdAt
        |> fetch
    post <- fetch postId
    user <- fetch (get #userId post)
    users <- query @User
        |> filterWhere (#companyId, get #companyId currentUser)
        |> fetch
    let newComment = newRecord @Comment
            |> set #postId postId

    renderHtml IndexView { .. }
        >>= setModal
    let ?theAction = PostsAction in action PostsAction

in this example it renders a comments modal on top of a posts feed

The layout for this app looks like this:

<body>
<div class="container mt-2">
{navbar}
{renderFlashMessages}
{inner}
</div>
{renderCurrentModal}
<script>{inlineJs}</script>
<script src="/emoji.min.js"></script>
</body>

additonally the modal has to be loaded into the controller context inside Web.Controller:

instance InitControllerContext WebApplication where
initContext =
initAuthentication @User

    >=> Modal.initModal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants