summaryrefslogtreecommitdiff
path: root/lib/aggiedit_web/live/post_live/show.html.heex
blob: f0d1f41484f3acfae0c6a93a6cca444d73833107 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<div class="d-flex justify-content-center">
  <div class="container">
    <div>
      <h1><%= @post.title %></h1>
    </div>
    <div>
      <%= if Ecto.assoc_loaded?(@post.upload) && !is_nil(@post.upload) do %>
        <img src={Routes.static_path(@socket, "/uploads/#{@post.upload.file}")} class="img-fluid" style="max-height: 40vh"/>
      <% end %>
    </div>
    <div class="post-body">
      <%= @post.body %>
    </div>
    <%= if Aggiedit.Roles.guard?(@current_user, :edit, @post) do %>
      <span><%= live_patch "Edit", to: Routes.post_show_path(@socket, :edit, @room, @post), class: "button" %></span> |
    <% end %>
    <span><%= live_redirect "Back", to: Routes.post_index_path(@socket, :index, @room) %></span>

    <div class="border rounded p-2 m-2">
      <div class="chat" id="chat">
      </div>
    </div>
    <form class="border rounded p-2 m-2" onsubmit="return RoomChat.submitForm(event)">
      <div class="form-group m-2">
        <label for="message">Message</label>
        <input type="text" class="form-control" id="message" name="message" placeholder="Message">
      </div>
      <button type="submit" class="m-2 btn btn-primary">Submit</button>
    </form>
  </div>
</div>

<%= if @live_action in [:edit] do %>
  <.modal return_to={Routes.post_show_path(@socket, :show, @room, @post)}>
    <.live_component
      module={AggieditWeb.PostLive.FormComponent}
      id={@post.id}
      current_user={@current_user}
      title={@page_title}
      action={@live_action}
      post={@post}
      return_to={Routes.post_show_path(@socket, :show, @room, @post)}
    />
  </.modal>
<% end %>