summaryrefslogtreecommitdiff
path: root/lib/aggiedit_web/live/post_live/index.html.heex
blob: 329f84cce48e04159164d6d6ce4ea54f5e8b693b (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
<h1>Listing Posts</h1>

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

<table>
  <thead>
    <tr>
      <th>Title</th>
      <th>Body</th>

      <th></th>
    </tr>
  </thead>
  <tbody id="posts">
    <%= for post <- @posts do %>
      <tr id={"post-#{post.id}"}>
        <td><%= post.title %></td>
        <td><%= post.body %></td>

        <td>
          <span><%= live_redirect "Show", to: Routes.post_show_path(@socket, :show, @room, post) %></span>
          <span><%= live_patch "Edit", to: Routes.post_index_path(@socket, :edit, @room, post) %></span>
          <span><%= link "Delete", to: "#", phx_click: "delete", phx_value_id: post.id, data: [confirm: "Are you sure?"] %></span>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<span><%= live_patch "New Post", to: Routes.post_index_path(@socket, :new, @room) %></span>