2019-11-29 22:47:41 +01:00
|
|
|
defmodule PhilomenaWeb.DnpEntryView do
|
|
|
|
use PhilomenaWeb, :view
|
2019-12-12 22:44:50 +01:00
|
|
|
|
|
|
|
def reasons do
|
|
|
|
Philomena.DnpEntries.DnpEntry.reasons()
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_class(changeset) do
|
|
|
|
case show_steps?(changeset) do
|
|
|
|
true -> "hidden"
|
|
|
|
false -> nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def selectable_options(tags) do
|
|
|
|
Enum.map(tags, &{&1.name, &1.id})
|
|
|
|
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"
|
|
|
|
def pretty_state(%{aasm_state: "acknowledged"}), do: "Claimed (Rescinded)"
|
|
|
|
def pretty_state(_dnp_entry), do: "Requested"
|
|
|
|
|
|
|
|
def show_steps?(changeset) do
|
2019-12-31 01:04:19 +01:00
|
|
|
changeset.action == nil and changeset.data.__meta__.state != :loaded
|
2019-12-12 22:44:50 +01:00
|
|
|
end
|
2019-11-29 22:47:41 +01:00
|
|
|
end
|