mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +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 ->
|
= form_for @changeset, @action, fn f ->
|
||||||
|
- badge_options = badge_options(@badges)
|
||||||
|
|
||||||
= if @changeset.action do
|
= if @changeset.action do
|
||||||
.alert.alert-danger
|
.alert.alert-danger
|
||||||
p Oops, something went wrong! Please check the errors below.
|
p Oops, something went wrong! Please check the errors below.
|
||||||
|
|
||||||
.field
|
.field
|
||||||
=> label f, :badge_id, "Badge type"
|
=> 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
|
= error_tag f, :badge_id
|
||||||
|
|
||||||
.field
|
.field
|
||||||
=> label f, :label, "Label (Public)"
|
=> 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
|
= error_tag f, :label
|
||||||
|
|
||||||
.field
|
.field
|
||||||
|
|
|
@ -10,4 +10,12 @@ defmodule PhilomenaWeb.Profile.AwardView do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def first_badge_label([]) do
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def first_badge_label([badge | _rest]) do
|
||||||
|
badge[:data][:set_value]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue