From f8e5feb24cd6a0eceda24daffc66b3b616190087 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sat, 1 Feb 2020 10:45:44 -0500 Subject: [PATCH] fix dnp editing --- lib/philomena_web/templates/dnp_entry/_form.html.slime | 8 ++++++-- lib/philomena_web/templates/dnp_entry/edit.html.slime | 2 +- lib/philomena_web/templates/dnp_entry/new.html.slime | 2 +- lib/philomena_web/views/dnp_entry_view.ex | 4 ++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/philomena_web/templates/dnp_entry/_form.html.slime b/lib/philomena_web/templates/dnp_entry/_form.html.slime index e8164b7f..81a6bfd0 100644 --- a/lib/philomena_web/templates/dnp_entry/_form.html.slime +++ b/lib/philomena_web/templates/dnp_entry/_form.html.slime @@ -40,6 +40,12 @@ span.block__header__title DNP Request Form .block__content + / Option (set by script depending on the option chosen above) + strong Type + .field + = select f, :dnp_type, selectable_types(), class: "js-dnp-type input input--wide" + = error_tag f, :dnp_type + / Artist Tag strong Artist Tag p Select the artist tag you would like to request a DNP entry for @@ -79,7 +85,5 @@ = textarea f, :feedback, class: "input input--wide", placeholder: "Feedback" = error_tag f, :feedback - / Option (hidden, set by script depending on the option chosen above) - = hidden_input f, :dnp_type, class: "js-dnp-type" hr = submit "Submit Request", class: "button" diff --git a/lib/philomena_web/templates/dnp_entry/edit.html.slime b/lib/philomena_web/templates/dnp_entry/edit.html.slime index 1201dfa1..2761b395 100644 --- a/lib/philomena_web/templates/dnp_entry/edit.html.slime +++ b/lib/philomena_web/templates/dnp_entry/edit.html.slime @@ -1,2 +1,2 @@ h2 Edit DNP Request -= render PhilomenaWeb.DnpEntryView, "_form.html", changeset: @changeset, action: Routes.dnp_entry_path(@conn, :update, @dnp_entry), conn: @conn, selectable_tags: @selectable_tags += render PhilomenaWeb.DnpEntryView, "_form.html", changeset: @changeset, action: Routes.dnp_entry_path(@conn, :update, @dnp_entry, tag_id: @dnp_entry.tag_id), conn: @conn, selectable_tags: @selectable_tags diff --git a/lib/philomena_web/templates/dnp_entry/new.html.slime b/lib/philomena_web/templates/dnp_entry/new.html.slime index e6cbb325..95c822d2 100644 --- a/lib/philomena_web/templates/dnp_entry/new.html.slime +++ b/lib/philomena_web/templates/dnp_entry/new.html.slime @@ -1,2 +1,2 @@ h2 New DNP Request -= render PhilomenaWeb.DnpEntryView, "_form.html", changeset: @changeset, action: Routes.dnp_entry_path(@conn, :create), conn: @conn, selectable_tags: @selectable_tags += render PhilomenaWeb.DnpEntryView, "_form.html", changeset: @changeset, action: Routes.dnp_entry_path(@conn, :create, tag_id: @conn.params["tag_id"]), conn: @conn, selectable_tags: @selectable_tags diff --git a/lib/philomena_web/views/dnp_entry_view.ex b/lib/philomena_web/views/dnp_entry_view.ex index 3a117749..a04562e3 100644 --- a/lib/philomena_web/views/dnp_entry_view.ex +++ b/lib/philomena_web/views/dnp_entry_view.ex @@ -16,6 +16,10 @@ defmodule PhilomenaWeb.DnpEntryView do Enum.map(tags, &{&1.name, &1.id}) end + def selectable_types do + Enum.map(reasons(), fn {k, v} -> [key: v, value: k] end) + end + def pretty_state(%{aasm_state: "claimed"}), do: "Claimed" def pretty_state(%{aasm_state: "listed"}), do: "Listed" def pretty_state(%{aasm_state: "closed"}), do: "Closed"