mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
prefill award label (#5)
This commit is contained in:
parent
6deab827ac
commit
504b1d5b82
2 changed files with 12 additions and 2 deletions
|
@ -1,16 +1,18 @@
|
|||
= form_for @changeset, @action, fn f ->
|
||||
- badge_options = badge_options(@badges)
|
||||
|
||||
= if @changeset.action do
|
||||
.alert.alert-danger
|
||||
p Oops, something went wrong! Please check the errors below.
|
||||
|
||||
.field
|
||||
=> label f, :badge_id, "Badge type"
|
||||
= select f, :badge_id, badge_options(@badges), class: "input", data: [change_selectvalue: "#award_label"]
|
||||
= select f, :badge_id, badge_options, class: "input", data: [change_selectvalue: "#award_label"]
|
||||
= error_tag f, :badge_id
|
||||
|
||||
.field
|
||||
=> label f, :label, "Label (Public)"
|
||||
= text_input f, :label, class: "input input--wide"
|
||||
= text_input f, :label, class: "input input--wide", value: first_badge_label(badge_options)
|
||||
= error_tag f, :label
|
||||
|
||||
.field
|
||||
|
|
|
@ -10,4 +10,12 @@ defmodule PhilomenaWeb.Profile.AwardView do
|
|||
]
|
||||
end
|
||||
end
|
||||
|
||||
def first_badge_label([]) do
|
||||
nil
|
||||
end
|
||||
|
||||
def first_badge_label([badge | _rest]) do
|
||||
badge[:data][:set_value]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue