Add label to cards
Also removes unused fields related to buttons and alignment
This commit is contained in:
@@ -39,7 +39,7 @@ class Admin::Widget::CardsController < Admin::BaseController
|
||||
private
|
||||
|
||||
def card_params
|
||||
params.require(:widget_card).permit(:title, :description, :link_text, :link_url,
|
||||
params.require(:widget_card).permit(:label, :title, :description, :link_text, :link_url,
|
||||
:button_text, :button_url, :alignment, :header,
|
||||
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
|
||||
end
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<tr id="<%= dom_id(card) %>" class="card">
|
||||
<td><%= card.title %></td>
|
||||
<td>
|
||||
<%= card.label %><br>
|
||||
<%= card.title %>
|
||||
</td>
|
||||
<td><%= card.description %></td>
|
||||
<td>
|
||||
<%= card.link_text %><br>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<%= form_for [:admin, @card] do |f| %>
|
||||
<div class="small-12 medium-6">
|
||||
<%= f.text_field :label %>
|
||||
</div>
|
||||
|
||||
<%= f.text_field :title %>
|
||||
|
||||
<%= f.text_area :description, rows: 5 %>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<%= image_tag(card.image_url(:large), alt: card.image.title) %>
|
||||
<% end %>
|
||||
<figcaption>
|
||||
<span>LABEL</span><br>
|
||||
<span><%= card.label %></span><br>
|
||||
<h3><%= card.title %></h3>
|
||||
</figcaption>
|
||||
</figure>
|
||||
|
||||
@@ -246,6 +246,7 @@ en:
|
||||
from: From
|
||||
body: Email content
|
||||
widget/card:
|
||||
label: Label
|
||||
title: Title
|
||||
description: Description
|
||||
link_text: Link text
|
||||
|
||||
@@ -242,6 +242,7 @@ es:
|
||||
from: Enviado por
|
||||
body: Contenido del email
|
||||
widget/card:
|
||||
label: Etiqueta
|
||||
title: Título
|
||||
description: Descripción
|
||||
link_text: Texto del enlace
|
||||
|
||||
@@ -5,10 +5,8 @@ class CreateWidgetCards < ActiveRecord::Migration
|
||||
t.text :description
|
||||
t.string :link_text
|
||||
t.string :link_url
|
||||
t.string :button_text
|
||||
t.string :button_url
|
||||
t.string :label
|
||||
t.boolean :header, default: false
|
||||
t.string :alignment
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1231,10 +1231,8 @@ ActiveRecord::Schema.define(version: 20180519132715) do
|
||||
t.text "description"
|
||||
t.string "link_text"
|
||||
t.string "link_url"
|
||||
t.string "button_text"
|
||||
t.string "button_url"
|
||||
t.string "label"
|
||||
t.boolean "header", default: false
|
||||
t.string "alignment"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
@@ -76,33 +76,37 @@ feature 'Homepage' do
|
||||
end
|
||||
|
||||
scenario "Cards" do
|
||||
card1 = create(:widget_card, title: "Card text",
|
||||
description: "Card description",
|
||||
link_text: "Link text",
|
||||
link_url: "consul.dev")
|
||||
card1 = create(:widget_card, label: "Card1 label",
|
||||
title: "Card1 text",
|
||||
description: "Card1 description",
|
||||
link_text: "Link1 text",
|
||||
link_url: "consul1.dev")
|
||||
|
||||
card2 = create(:widget_card, title: "Card text2",
|
||||
description: "Card description2",
|
||||
link_text: "Link text2",
|
||||
link_url: "consul.dev2")
|
||||
card2 = create(:widget_card, label: "Card2 label",
|
||||
title: "Card2 text",
|
||||
description: "Card2 description",
|
||||
link_text: "Link2 text",
|
||||
link_url: "consul2.dev")
|
||||
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_css(".card", count: 2)
|
||||
|
||||
within("#widget_card_#{card1.id}") do
|
||||
expect(page).to have_content("Card text")
|
||||
expect(page).to have_content("Card description")
|
||||
expect(page).to have_content("Link text")
|
||||
expect(page).to have_link(href: "consul.dev")
|
||||
expect(page).to have_content("Card1 label")
|
||||
expect(page).to have_content("Card1 text")
|
||||
expect(page).to have_content("Card1 description")
|
||||
expect(page).to have_content("Link1 text")
|
||||
expect(page).to have_link(href: "consul1.dev")
|
||||
expect(page).to have_css("img[alt='#{card1.image.title}']")
|
||||
end
|
||||
|
||||
within("#widget_card_#{card2.id}") do
|
||||
expect(page).to have_content("Card text2")
|
||||
expect(page).to have_content("Card description2")
|
||||
expect(page).to have_content("Link text2")
|
||||
expect(page).to have_link(href: "consul.dev2")
|
||||
expect(page).to have_content("Card2 label")
|
||||
expect(page).to have_content("Card2 text")
|
||||
expect(page).to have_content("Card2 description")
|
||||
expect(page).to have_content("Link2 text")
|
||||
expect(page).to have_link(href: "consul2.dev")
|
||||
expect(page).to have_css("img[alt='#{card2.image.title}']")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ feature 'Cards' do
|
||||
visit admin_homepage_path
|
||||
click_link "Create card"
|
||||
|
||||
fill_in "widget_card_label", with: "Card label"
|
||||
fill_in "widget_card_title", with: "Card text"
|
||||
fill_in "widget_card_description", with: "Card description"
|
||||
fill_in "widget_card_link_text", with: "Link text"
|
||||
@@ -23,6 +24,7 @@ feature 'Cards' do
|
||||
|
||||
card = Widget::Card.last
|
||||
within("#widget_card_#{card.id}") do
|
||||
expect(page).to have_content "Card label"
|
||||
expect(page).to have_content "Card text"
|
||||
expect(page).to have_content "Card description"
|
||||
expect(page).to have_content "Link text"
|
||||
@@ -57,6 +59,7 @@ feature 'Cards' do
|
||||
click_link "Edit"
|
||||
end
|
||||
|
||||
fill_in "widget_card_label", with: "Card label updated"
|
||||
fill_in "widget_card_title", with: "Card text updated"
|
||||
fill_in "widget_card_description", with: "Card description updated"
|
||||
fill_in "widget_card_link_text", with: "Link text updated"
|
||||
@@ -67,6 +70,7 @@ feature 'Cards' do
|
||||
|
||||
expect(page).to have_css(".card", count: 1)
|
||||
within("#widget_card_#{Widget::Card.last.id}") do
|
||||
expect(page).to have_content "Card label updated"
|
||||
expect(page).to have_content "Card text updated"
|
||||
expect(page).to have_content "Card description updated"
|
||||
expect(page).to have_content "Link text updated"
|
||||
@@ -95,8 +99,9 @@ feature 'Cards' do
|
||||
visit admin_homepage_path
|
||||
click_link "Create header"
|
||||
|
||||
fill_in "widget_card_title", with: "Card text"
|
||||
fill_in "widget_card_description", with: "Card description"
|
||||
fill_in "widget_card_label", with: "Header label"
|
||||
fill_in "widget_card_title", with: "Header text"
|
||||
fill_in "widget_card_description", with: "Header description"
|
||||
fill_in "widget_card_link_text", with: "Link text"
|
||||
fill_in "widget_card_link_url", with: "consul.dev"
|
||||
click_button "Create header"
|
||||
@@ -105,8 +110,9 @@ feature 'Cards' do
|
||||
|
||||
within("#header") do
|
||||
expect(page).to have_css(".card", count: 1)
|
||||
expect(page).to have_content "Card text"
|
||||
expect(page).to have_content "Card description"
|
||||
expect(page).to have_content "Header label"
|
||||
expect(page).to have_content "Header text"
|
||||
expect(page).to have_content "Header description"
|
||||
expect(page).to have_content "Link text"
|
||||
expect(page).to have_content "consul.dev"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user