forked from e621ng/e621ng
[Forms] Add displaying dropdowns as button selects
The first user of this is creating user feedback, where you have 3 buttons Also default to negative feedback when linking to create on user pages
This commit is contained in:
parent
f7e6985c82
commit
619754283b
@ -4,5 +4,14 @@ class CustomFormBuilder < SimpleForm::FormBuilder
|
||||
super
|
||||
end
|
||||
|
||||
def button_select(attribute_name, values, **args)
|
||||
html = collection_radio_buttons(attribute_name, values, :first, :last)
|
||||
label = args[:label] || attribute_name.to_s.titleize
|
||||
%(<div class="collection-radio-buttons input">
|
||||
<label>#{label}</label>
|
||||
#{html}
|
||||
</div>).html_safe
|
||||
end
|
||||
|
||||
include FormBuilderCommon
|
||||
end
|
||||
|
@ -43,6 +43,26 @@ form.simple_form {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.collection-radio-buttons {
|
||||
input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
input + label {
|
||||
@extend .button;
|
||||
// Overwrite the themed color from the imported class, which has higher specificity
|
||||
color: black !important;
|
||||
background-color: white;
|
||||
margin: 0 0.25rem 0.25rem 0;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input:checked + label {
|
||||
@include themable { background-color: themed("color-button-active"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
form.inline-form {
|
||||
|
@ -2,7 +2,7 @@
|
||||
<% if user_feedback.new_record? %>
|
||||
<%= f.input :user_name, label: "User", autocomplete: "user", input_html: { value: user_feedback.user.try(:name) } %>
|
||||
<% end %>
|
||||
<%= f.input :category, collection: ["positive", "neutral", "negative"], include_blank: false %>
|
||||
<%= f.button_select :category, ["positive", "neutral", "negative"].map { |e| [e, e.titleize] } %>
|
||||
<%= dtext_field "user_feedback", "body" %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<% end %>
|
||||
|
@ -96,7 +96,7 @@
|
||||
<%= presenter.feedbacks %>
|
||||
<%= link_to("List", user_feedbacks_path(search: { user_id: @user.id })) %>
|
||||
<% if CurrentUser.is_moderator? && @user.feedback.count.zero? %>
|
||||
| <%= link_to("Create", new_user_feedback_path(user_feedback: { user_id: @user.id })) %>
|
||||
| <%= link_to("Create", new_user_feedback_path(user_feedback: { user_id: @user.id, category: "neutral" })) %>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user