Compare commits

...

3 Commits

Author SHA1 Message Date
Ryan Rix 18dde03b52 edit action can't whine about missing container
fix the header while we're at it.
2020-09-16 19:19:45 -07:00
Ryan Rix 80aa3a8ee2 add has_many :photos to PokaIjo.Thing 2020-09-16 19:19:10 -07:00
Ryan Rix 30be373278 easy enough to add "next to" button for objects for sibling insertion 2020-09-16 19:03:00 -07:00
2 changed files with 35 additions and 16 deletions

View File

@ -134,21 +134,29 @@ end
</div>
<div class="small-12 medium-4 cell">
<div class="grid-x small-up-4">
<div class="cell">
<%= link "edit", to: Routes.thing_path(@conn, :edit, @thing),
class: "button primary expanded" %>
</div>
<div class="cell">
<%= link "insert", to: Routes.thing_path(@conn, :insert, @thing),
class: "button secondary expanded" %>
</div>
<%= if @thing.container do %>
<div class="cell">
<%= link "next_to", to: Routes.thing_path(@conn, :insert, @thing.container),
class: "button expanded" %>
</div>
<% end %>
<div class="cell">
<%= link "move", to: Routes.thing_path(@conn, :move, @thing),
class: "button success expanded" %>
</div>
</div>
<iframe src="https://www.youtube.com/embed/VFZNvj-HfBU" frameborder="0" allow="picture-in-picture" allowfullscreen></iframe>
<div class="grid-x">
<div class="small-4 cell">
<%= link "edit", to: Routes.thing_path(@conn, :edit, @thing),
class: "button primary expanded" %>
</div>
<div class="small-4 cell">
<%= link "insert", to: Routes.thing_path(@conn, :insert, @thing),
class: "button secondary expanded" %>
</div>
<div class="small-4 cell">
<%= link "move", to: Routes.thing_path(@conn, :move, @thing),
class: "button success expanded" %>
</div>
</div>
</div>
#+end_src
@ -207,7 +215,13 @@ end
#+begin_src web :tangle lib/poka_ijo_web/templates/thing/edit.html.eex :mkdirp yes
<div class="grid-x grid-padding-x">
<div class="small-12 medium-8 cell">
<h2>New Thing</h2>
<h2>
<%= if @changeset.data.name do %>
Editing <%= @changeset.data.name %>
<% else %>
New Thing
<% end %>
</h2>
<%= if assigns[:container] do %>
will be stored in&nbsp;
@ -222,7 +236,7 @@ end
<% end %>
<%# if it's shown in the UI and the changeset has the ID: %>
<%= if assigns[:container] && @changeset.changes.container_id do %>
<%= if assigns[:container] && Map.get(@changeset.data, :container_id) do %>
<%= hidden_input f, :container_id %>
<% end %>
@ -426,6 +440,7 @@ def edit(conn, %{"id" => id}) do
|> put_view(PokaIjoWeb.ThingView)
|> render(:edit,
thing: thing,
container: thing.container,
changeset: changeset,
page_title: "Poka Ijo: #{thing.name}"
)

View File

@ -38,7 +38,11 @@ schema "things" do
field :value_cents, :integer, default: 0
belongs_to :container, PokaIjo.Thing
has_many :contents, PokaIjo.Thing, foreign_key: :container_id
has_many :contents, PokaIjo.Thing, foreign_key: :container_id
has_many :photos, PokaIjo.Photo,
foreign_key: :thing_id,
on_delete: :delete_all
timestamps()
end