Skip to content

Commit

Permalink
SetUp LiveView Formatter (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed May 26, 2022
1 parent 95ddc3b commit 3905d64
Show file tree
Hide file tree
Showing 40 changed files with 792 additions and 554 deletions.
5 changes: 3 additions & 2 deletions .formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"{mix,.formatter}.exs",
"*.{ex,exs}",
"priv/*/seeds.exs",
"{config,lib,test}/**/*.{ex,exs}"
"{config,lib,test}/**/*.{ex,exs,heex}"
],
subdirectories: ["priv/*/migrations"]
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter]
]
7 changes: 5 additions & 2 deletions lib/athena_web/admin/templates/event/edit.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
<%= gettext("edit %{event}", event: @event.name) %>
</h1>

<%= render "form.html", Map.put(assigns, :action, Routes.admin_event_path(@conn, :update, @event)) %>
<%= render(
"form.html",
Map.put(assigns, :action, Routes.admin_event_path(@conn, :update, @event))
) %>

<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "back" |> gettext |> link(to: Routes.admin_event_path(@conn, :index)) %></li>
</ul>
</ul>
6 changes: 3 additions & 3 deletions lib/athena_web/admin/templates/event/form.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</div>
<% end %>

<%= label f, :name, gettext("name") %>
<%= text_input f, :name %>
<%= error_tag f, :name %>
<%= label(f, :name, gettext("name")) %>
<%= text_input(f, :name) %>
<%= error_tag(f, :name) %>

<div>
<%= "save" |> gettext |> submit %>
Expand Down
20 changes: 16 additions & 4 deletions lib/athena_web/admin/templates/event/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@
<tr>
<td><%= event.name %></td>
<td>
<span><%= "show" |> gettext |> link(to: Routes.admin_event_path(@conn, :show, event)) %></span>
<span><%= "edit" |> gettext |> link(to: Routes.admin_event_path(@conn, :edit, event)) %></span>
<span><%= "delete" |> gettext |> link(to: Routes.admin_event_path(@conn, :delete, event), method: :delete, data: [confirm: "Are you sure?"]) %></span>
<span>
<%= "show" |> gettext |> link(to: Routes.admin_event_path(@conn, :show, event)) %>
</span>
<span>
<%= "edit" |> gettext |> link(to: Routes.admin_event_path(@conn, :edit, event)) %>
</span>
<span>
<%= "delete"
|> gettext
|> link(
to: Routes.admin_event_path(@conn, :delete, event),
method: :delete,
data: [confirm: "Are you sure?"]
) %>
</span>
</td>
</tr>
<% end %>
Expand All @@ -27,4 +39,4 @@

<ul>
<li><%= "create event" |> gettext |> link(to: Routes.admin_event_path(@conn, :new)) %></li>
</ul>
</ul>
4 changes: 2 additions & 2 deletions lib/athena_web/admin/templates/event/new.html.heex
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<h1><%= gettext("create event") %></h1>

<%= render "form.html", Map.put(assigns, :action, Routes.admin_event_path(@conn, :create)) %>
<%= render("form.html", Map.put(assigns, :action, Routes.admin_event_path(@conn, :create))) %>

<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "back" |> gettext |> link(to: Routes.admin_event_path(@conn, :index)) %></li>
</ul>
</ul>
18 changes: 11 additions & 7 deletions lib/athena_web/admin/templates/event/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
<%= gettext("QR code") %>
</h3>

<%
qr_code = link
<% qr_code =
link
|> EQRCode.encode()
|> EQRCode.svg()
%>
|> EQRCode.svg() %>

<a href={"data:image/svg+xml;base64,#{Base.encode64(qr_code) }"} download={ gettext("%{event} logistics", event: @event.name) <> ".svg"}>
<a
href={"data:image/svg+xml;base64,#{Base.encode64(qr_code)}"}
download={gettext("%{event} logistics", event: @event.name) <> ".svg"}
>
<%= raw(qr_code) %>
</a>
</div>
Expand All @@ -37,6 +39,8 @@
<%= "locations" |> gettext |> link(to: Routes.admin_location_path(@conn, :index, @event.id)) %>
</li>
<li>
<%= "item groups" |> gettext |> link(to: Routes.admin_item_group_path(@conn, :index, @event.id)) %>
<%= "item groups"
|> gettext
|> link(to: Routes.admin_item_group_path(@conn, :index, @event.id)) %>
</li>
</ul>
</ul>
8 changes: 5 additions & 3 deletions lib/athena_web/admin/templates/item/edit.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
<%= gettext("edit %{item}", item: @item.name) %>
</h1>

<%= render "form.html", Map.put(assigns, :action, Routes.admin_item_path(@conn, :update, @item)) %>
<%= render("form.html", Map.put(assigns, :action, Routes.admin_item_path(@conn, :update, @item))) %>

<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "back" |> gettext |> link(to: Routes.admin_item_path(@conn, :index, @item.item_group_id)) %></li>
</ul>
<li>
<%= "back" |> gettext |> link(to: Routes.admin_item_path(@conn, :index, @item.item_group_id)) %>
</li>
</ul>
18 changes: 9 additions & 9 deletions lib/athena_web/admin/templates/item/form.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
</div>
<% end %>

<%= label f, :name, gettext("name") %>
<%= text_input f, :name %>
<%= error_tag f, :name %>
<%= label(f, :name, gettext("name")) %>
<%= text_input(f, :name) %>
<%= error_tag(f, :name) %>

<%= label f, :unit, gettext("unit") %>
<%= text_input f, :unit %>
<%= error_tag f, :unit %>
<%= label(f, :unit, gettext("unit")) %>
<%= text_input(f, :unit) %>
<%= error_tag(f, :unit) %>

<%= label f, :inverse, gettext("inverse") %>
<%= checkbox f, :inverse %>
<%= error_tag f, :inverse %>
<%= label(f, :inverse, gettext("inverse")) %>
<%= checkbox(f, :inverse) %>
<%= error_tag(f, :inverse) %>

<div>
<%= "save" |> gettext |> submit %>
Expand Down
38 changes: 26 additions & 12 deletions lib/athena_web/admin/templates/item/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,37 @@
</thead>
<tbody>
<%= for item <- @items do %>
<tr>
<td><%= item.name %></td>
<td><%= item.unit %></td>
<td><%= if item.inverse, do: gettext("yes"), else: gettext("no") %></td>
<tr>
<td><%= item.name %></td>
<td><%= item.unit %></td>
<td><%= if item.inverse, do: gettext("yes"), else: gettext("no") %></td>

<td>
<span><%= "show" |> gettext |> link(to: Routes.admin_item_path(@conn, :show, item)) %></span>
<span><%= "edit" |> gettext |> link(to: Routes.admin_item_path(@conn, :edit, item)) %></span>
<span><%= "delete" |> gettext |> link(to: Routes.admin_item_path(@conn, :delete, item), method: :delete, data: [confirm: "Are you sure?"]) %></span>
</td>
</tr>
<td>
<span>
<%= "show" |> gettext |> link(to: Routes.admin_item_path(@conn, :show, item)) %>
</span>
<span>
<%= "edit" |> gettext |> link(to: Routes.admin_item_path(@conn, :edit, item)) %>
</span>
<span>
<%= "delete"
|> gettext
|> link(
to: Routes.admin_item_path(@conn, :delete, item),
method: :delete,
data: [confirm: "Are you sure?"]
) %>
</span>
</td>
</tr>
<% end %>
</tbody>
</table>

<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "create item" |> gettext |> link(to: Routes.admin_item_path(@conn, :new, @item_group.id)) %></li>
</ul>
<li>
<%= "create item" |> gettext |> link(to: Routes.admin_item_path(@conn, :new, @item_group.id)) %>
</li>
</ul>
9 changes: 7 additions & 2 deletions lib/athena_web/admin/templates/item/new.html.heex
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<h1><%= gettext("create item") %></h1>

<%= render "form.html", Map.put(assigns, :action, Routes.admin_item_path(@conn, :create, @item_group.id)) %>
<%= render(
"form.html",
Map.put(assigns, :action, Routes.admin_item_path(@conn, :create, @item_group.id))
) %>

<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "back" |> gettext |> link(to: Routes.admin_item_path(@conn, :index, @item_group.id)) %></li>
<li>
<%= "back" |> gettext |> link(to: Routes.admin_item_path(@conn, :index, @item_group.id)) %>
</li>
</ul>
10 changes: 7 additions & 3 deletions lib/athena_web/admin/templates/item/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

<ul>
<li><%= "edit" |> gettext |> link(to: Routes.admin_item_path(@conn, :edit, @item)) %></li>
<li><%= "back" |> gettext |> link(to: Routes.admin_item_path(@conn, :index, @item.item_group_id)) %></li>
<li><%= "movements" |> gettext |> link(to: Routes.admin_movement_path(@conn, :index, @item.id)) %></li>
</ul>
<li>
<%= "back" |> gettext |> link(to: Routes.admin_item_path(@conn, :index, @item.item_group_id)) %>
</li>
<li>
<%= "movements" |> gettext |> link(to: Routes.admin_movement_path(@conn, :index, @item.id)) %>
</li>
</ul>
11 changes: 9 additions & 2 deletions lib/athena_web/admin/templates/item_group/edit.html.heex
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<h1><%= gettext("edit %{item_group}", item_group: @item_group.name) %></h1>

<%= render "form.html", Map.put(assigns, :action, Routes.admin_item_group_path(@conn, :update, @item_group)) %>
<%= render(
"form.html",
Map.put(assigns, :action, Routes.admin_item_group_path(@conn, :update, @item_group))
) %>

<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "back" |> gettext |> link(to: Routes.admin_item_group_path(@conn, :index, @item_group.event_id)) %></li>
<li>
<%= "back"
|> gettext
|> link(to: Routes.admin_item_group_path(@conn, :index, @item_group.event_id)) %>
</li>
</ul>
6 changes: 3 additions & 3 deletions lib/athena_web/admin/templates/item_group/form.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</div>
<% end %>

<%= label f, :name, gettext("name") %>
<%= text_input f, :name %>
<%= error_tag f, :name %>
<%= label(f, :name, gettext("name")) %>
<%= text_input(f, :name) %>
<%= error_tag(f, :name) %>

<div>
<%= "save" |> gettext |> submit %>
Expand Down
22 changes: 18 additions & 4 deletions lib/athena_web/admin/templates/item_group/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@
<tr>
<td><%= item_group.name %></td>
<td>
<span><%= link "Show", to: Routes.admin_item_group_path(@conn, :show, item_group) %></span>
<span><%= link "Edit", to: Routes.admin_item_group_path(@conn, :edit, item_group) %></span>
<span><%= link "Delete", to: Routes.admin_item_group_path(@conn, :delete, item_group), method: :delete, data: [confirm: "Are you sure?"] %></span>
<span>
<%= link("Show", to: Routes.admin_item_group_path(@conn, :show, item_group)) %>
</span>
<span>
<%= link("Edit", to: Routes.admin_item_group_path(@conn, :edit, item_group)) %>
</span>
<span>
<%= link("Delete",
to: Routes.admin_item_group_path(@conn, :delete, item_group),
method: :delete,
data: [confirm: "Are you sure?"]
) %>
</span>
</td>
</tr>
<% end %>
Expand All @@ -24,5 +34,9 @@
<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "create item group" |> gettext |> link(to: Routes.admin_item_group_path(@conn, :new, @event.id)) %></li>
<li>
<%= "create item group"
|> gettext
|> link(to: Routes.admin_item_group_path(@conn, :new, @event.id)) %>
</li>
</ul>
9 changes: 7 additions & 2 deletions lib/athena_web/admin/templates/item_group/new.html.heex
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<h1><%= gettext("create item group") %></h1>

<%= render "form.html", Map.put(assigns, :action, Routes.admin_item_group_path(@conn, :create, @event.id)) %>
<%= render(
"form.html",
Map.put(assigns, :action, Routes.admin_item_group_path(@conn, :create, @event.id))
) %>

<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "back" |> gettext |> link(to: Routes.admin_item_group_path(@conn, :index, @event.id)) %></li>
<li>
<%= "back" |> gettext |> link(to: Routes.admin_item_group_path(@conn, :index, @event.id)) %>
</li>
</ul>
16 changes: 12 additions & 4 deletions lib/athena_web/admin/templates/item_group/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
<h2><%= gettext("actions") %></h2>

<ul>
<li><%= "edit" |> gettext |> link(to: Routes.admin_item_group_path(@conn, :edit, @item_group)) %></li>
<li><%= "back" |> gettext |> link(to: Routes.admin_item_group_path(@conn, :index, @item_group.event_id)) %></li>
<li><%= "items" |> gettext |> link(to: Routes.admin_item_path(@conn, :index, @item_group.id)) %></li>
</ul>
<li>
<%= "edit" |> gettext |> link(to: Routes.admin_item_group_path(@conn, :edit, @item_group)) %>
</li>
<li>
<%= "back"
|> gettext
|> link(to: Routes.admin_item_group_path(@conn, :index, @item_group.event_id)) %>
</li>
<li>
<%= "items" |> gettext |> link(to: Routes.admin_item_path(@conn, :index, @item_group.id)) %>
</li>
</ul>
12 changes: 6 additions & 6 deletions lib/athena_web/admin/templates/layout/live.html.heex
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<main class="container">
<p class="alert alert-info" role="alert"
phx-click="lv:clear-flash"
phx-value-key="info"><%= live_flash(@flash, :info) %></p>
<p class="alert alert-info" role="alert" phx-click="lv:clear-flash" phx-value-key="info">
<%= live_flash(@flash, :info) %>
</p>

<p class="alert alert-danger" role="alert"
phx-click="lv:clear-flash"
phx-value-key="error"><%= live_flash(@flash, :error) %></p>
<p class="alert alert-danger" role="alert" phx-click="lv:clear-flash" phx-value-key="error">
<%= live_flash(@flash, :error) %>
</p>

<%= @inner_content %>
</main>
Loading

0 comments on commit 3905d64

Please sign in to comment.