[15-min-fix] Remove badge slug field b/c auto-gen by title (#13649)
* Make explicit that badge slug is auto generated * Remove slug from new form * Remove unused disabled form field * Remove link and Crayonsify form * Add badge's path
This commit is contained in:
parent
27eda9ca3d
commit
ebbbcee41a
4 changed files with 20 additions and 25 deletions
|
|
@ -41,7 +41,7 @@ module Admin
|
|||
private
|
||||
|
||||
def badge_params
|
||||
params.require(:badge).permit(:title, :slug, :description, :badge_image, :credits_awarded)
|
||||
params.require(:badge).permit(:title, :description, :badge_image, :credits_awarded)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,34 +6,33 @@
|
|||
</div>
|
||||
</header>
|
||||
|
||||
<div class="crayons-card p-6">
|
||||
<div class="crayons-card crayons-card--content-rows">
|
||||
<%= form_for [:admin, @badge], method: :patch do |form| %>
|
||||
<div class="form-group">
|
||||
<%= form.label :title %>
|
||||
<%= form.text_field :title, class: "form-control" %>
|
||||
<div class="crayons-field mb-3">
|
||||
<%= form.label :title, "Title:", class: "crayons-field__label" %>
|
||||
<p class="crayons-field__description">
|
||||
Badge's link is auto-generated based on the title:
|
||||
<%= link_to @badge.path, @badge.path %>
|
||||
</p>
|
||||
<%= form.text_field :title, class: "crayons-textfield" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= form.label :slug, "Slug:" %>
|
||||
<%= form.text_field :slug, class: "form-control" %>
|
||||
<div class="crayons-field mb-3">
|
||||
<%= form.label :description, "Description:", class: "crayons-field__label" %>
|
||||
<%= form.text_field :description, class: "crayons-textfield" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= form.label :description, "Description:" %>
|
||||
<%= form.text_field :description, class: "form-control" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= form.label :badge_image, "Badge Image:" %>
|
||||
<div class="crayons-field mb-3">
|
||||
<%= form.label :badge_image, "Badge Image:", class: "crayons-field__label" %>
|
||||
<% if @badge.badge_image %>
|
||||
<img class="mx-auto mt-3" width="60" height="60" src="<%= @badge.badge_image %>" alt="badge image">
|
||||
<% end %>
|
||||
<%= form.file_field :badge_image, class: "form-control" %>
|
||||
<%= form.file_field :badge_image %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= form.label :credits_awarded, "Credits awarded:" %>
|
||||
<%= form.text_field :credits_awarded, class: "form-control" %>
|
||||
<div class="crayons-field mb-3">
|
||||
<%= form.label :credits_awarded, "Credits awarded:", class: "crayons-field__label" %>
|
||||
<%= form.text_field :credits_awarded, class: "crayons-textfield" %>
|
||||
</div>
|
||||
<%= submit_tag "Update Badge", class: "btn btn-primary" %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -3,15 +3,10 @@
|
|||
<div class="crayons-card p-6">
|
||||
<%= form_for [:admin, @badge], method: :post do |form| %>
|
||||
<div class="form-group">
|
||||
<%= form.label :title %>
|
||||
<%= form.label :title, "Title:" %>
|
||||
<%= form.text_field :title, class: "form-control" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= form.label :slug, "Slug:" %>
|
||||
<%= form.text_field :slug, class: "form-control" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= form.label :description, "Description:" %>
|
||||
<%= form.text_field :description, class: "form-control" %>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ RSpec.describe "/admin/content_manager/badge_achievements", type: :request do
|
|||
expect do
|
||||
patch admin_badge_path(badge.id), params: params
|
||||
end.to change { badge.reload.title }.to("Hello, world!")
|
||||
expect(badge.slug).to eq(CGI.escape(badge.title).parameterize)
|
||||
end
|
||||
|
||||
it "successfully updates badge's credits_awarded" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue