2022-02-14 21:21:24 -05:00
|
|
|
<div>
|
2022-02-18 18:21:56 -05:00
|
|
|
<h2 class="mb-8 text-center title text-xl text-primary-600">
|
2022-02-14 21:21:24 -05:00
|
|
|
<%= @title %>
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
<.form
|
2022-11-07 22:36:38 -05:00
|
|
|
:let={f}
|
2022-02-14 21:21:24 -05:00
|
|
|
for={@changeset}
|
2023-03-29 22:54:55 -04:00
|
|
|
id="pack-form"
|
2022-02-14 21:21:24 -05:00
|
|
|
phx-target={@myself}
|
|
|
|
phx-change="validate"
|
|
|
|
phx-submit="save"
|
2022-02-19 18:06:50 -05:00
|
|
|
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
|
2022-02-14 21:21:24 -05:00
|
|
|
>
|
2023-02-04 10:28:13 -05:00
|
|
|
<div
|
|
|
|
:if={@changeset.action && not @changeset.valid?()}
|
|
|
|
class="invalid-feedback col-span-3 text-center"
|
|
|
|
>
|
|
|
|
<%= changeset_errors(@changeset) %>
|
|
|
|
</div>
|
2022-02-14 21:21:24 -05:00
|
|
|
|
2023-03-30 21:53:52 -04:00
|
|
|
<%= label(f, :type_id, gettext("Type"), class: "title text-lg text-primary-600") %>
|
|
|
|
<%= select(f, :type_id, type_options(@types),
|
2022-02-14 21:21:24 -05:00
|
|
|
class: "text-center col-span-2 input input-primary"
|
|
|
|
) %>
|
2023-03-30 21:53:52 -04:00
|
|
|
<%= error_tag(f, :type_id, "col-span-3 text-center") %>
|
2022-02-14 21:21:24 -05:00
|
|
|
|
2022-02-20 20:28:42 -05:00
|
|
|
<%= label(f, :count, gettext("Count"), class: "title text-lg text-primary-600") %>
|
2022-02-14 21:21:24 -05:00
|
|
|
<%= number_input(f, :count,
|
|
|
|
class: "text-center col-span-2 input input-primary",
|
2022-04-19 19:38:03 -04:00
|
|
|
min: 0
|
2022-02-14 21:21:24 -05:00
|
|
|
) %>
|
|
|
|
<%= error_tag(f, :count, "col-span-3 text-center") %>
|
|
|
|
|
2022-02-20 20:28:42 -05:00
|
|
|
<%= label(f, :price_paid, gettext("Price paid"), class: "title text-lg text-primary-600") %>
|
2022-02-14 21:21:24 -05:00
|
|
|
<%= number_input(f, :price_paid,
|
2022-02-24 00:16:23 -05:00
|
|
|
step: 0.01,
|
2022-02-14 21:21:24 -05:00
|
|
|
class: "text-center col-span-2 input input-primary"
|
|
|
|
) %>
|
|
|
|
<%= error_tag(f, :price_paid, "col-span-3 text-center") %>
|
|
|
|
|
2023-03-30 23:35:01 -04:00
|
|
|
<%= label(f, :lot_number, gettext("Lot number"), class: "title text-lg text-primary-600") %>
|
|
|
|
<%= text_input(f, :lot_number,
|
|
|
|
class: "text-center col-span-2 input input-primary",
|
|
|
|
maxlength: 255
|
|
|
|
) %>
|
|
|
|
<%= error_tag(f, :price_paid, "col-span-3 text-center") %>
|
|
|
|
|
2022-11-19 14:52:01 -05:00
|
|
|
<%= label(f, :purchased_on, gettext("Purchased on"), class: "title text-lg text-primary-600") %>
|
|
|
|
<%= date_input(f, :purchased_on,
|
|
|
|
class: "input input-primary col-span-2",
|
|
|
|
phx_update: "ignore",
|
|
|
|
value: @changeset |> Changeset.get_field(:purchased_on) || Date.utc_today()
|
|
|
|
) %>
|
|
|
|
<%= error_tag(f, :purchased_on, "col-span-3 text-center") %>
|
|
|
|
|
2022-02-20 20:28:42 -05:00
|
|
|
<%= label(f, :notes, gettext("Notes"), class: "title text-lg text-primary-600") %>
|
2022-02-14 21:21:24 -05:00
|
|
|
<%= textarea(f, :notes,
|
2023-03-30 21:38:56 -04:00
|
|
|
id: "pack-form-notes",
|
2022-02-14 21:21:24 -05:00
|
|
|
class: "text-center col-span-2 input input-primary",
|
2023-03-18 22:13:32 -04:00
|
|
|
phx_hook: "MaintainAttrs",
|
|
|
|
phx_update: "ignore"
|
2022-02-14 21:21:24 -05:00
|
|
|
) %>
|
|
|
|
<%= error_tag(f, :notes, "col-span-3 text-center") %>
|
|
|
|
|
2022-02-20 20:28:42 -05:00
|
|
|
<%= label(f, :container, gettext("Container"), class: "title text-lg text-primary-600") %>
|
2022-02-14 21:21:24 -05:00
|
|
|
<%= select(f, :container_id, container_options(@containers),
|
|
|
|
class: "text-center col-span-2 input input-primary"
|
|
|
|
) %>
|
|
|
|
<%= error_tag(f, :container_id, "col-span-3 text-center") %>
|
|
|
|
|
2023-02-04 10:28:13 -05:00
|
|
|
<%= case @action do %>
|
|
|
|
<% action when action in [:new, :clone] -> %>
|
2022-02-24 00:16:23 -05:00
|
|
|
<hr class="hr col-span-3" />
|
|
|
|
|
|
|
|
<%= label(f, :multiplier, gettext("Copies"), class: "title text-lg text-primary-600") %>
|
|
|
|
<%= number_input(f, :multiplier,
|
2023-03-29 22:54:55 -04:00
|
|
|
max: @pack_create_limit,
|
2022-02-24 00:16:23 -05:00
|
|
|
class: "text-center input input-primary",
|
|
|
|
value: 1,
|
|
|
|
phx_update: "ignore"
|
|
|
|
) %>
|
|
|
|
|
|
|
|
<%= submit(dgettext("actions", "Create"),
|
|
|
|
phx_disable_with: dgettext("prompts", "Creating..."),
|
|
|
|
class: "mx-auto btn btn-primary"
|
|
|
|
) %>
|
|
|
|
|
|
|
|
<%= error_tag(f, :multiplier, "col-span-3 text-center") %>
|
2023-02-04 10:28:13 -05:00
|
|
|
<% :edit -> %>
|
2022-02-24 00:16:23 -05:00
|
|
|
<%= submit(dgettext("actions", "Save"),
|
|
|
|
phx_disable_with: dgettext("prompts", "Saving..."),
|
|
|
|
class: "mx-auto col-span-3 btn btn-primary"
|
|
|
|
) %>
|
|
|
|
<% end %>
|
2022-02-14 21:21:24 -05:00
|
|
|
</.form>
|
|
|
|
</div>
|