diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb
index f5dce76a1..519d5ff94 100644
--- a/app/controllers/admin/widget/cards_controller.rb
+++ b/app/controllers/admin/widget/cards_controller.rb
@@ -43,9 +43,8 @@ class Admin::Widget::CardsController < Admin::BaseController
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
params.require(:widget_card).permit(
- :label, :title, :description, :link_text, :link_url,
- :button_text, :button_url, :alignment, :header,
- *translation_params(Widget::Card),
+ :link_url, :button_text, :button_url, :alignment, :header,
+ translation_params(Widget::Card),
image_attributes: image_attributes
)
end
diff --git a/app/models/widget/card.rb b/app/models/widget/card.rb
index 73bc3eb00..0f8e176a4 100644
--- a/app/models/widget/card.rb
+++ b/app/models/widget/card.rb
@@ -9,6 +9,7 @@ class Widget::Card < ActiveRecord::Base
translates :description, touch: true
translates :link_text, touch: true
globalize_accessors
+ accepts_nested_attributes_for :translations, allow_destroy: true
def self.header
where(header: true)
diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb
index c22225e74..d9e6a955a 100644
--- a/app/views/admin/widget/cards/_form.html.erb
+++ b/app/views/admin/widget/cards/_form.html.erb
@@ -2,17 +2,19 @@
<%= translatable_form_for [:admin, @card] do |f| %>
-
- <%= f.translatable_text_field :label %>
-
+ <%= f.translatable_fields do |translations_form| %>
+
+ <%= translations_form.text_field :label %>
+
- <%= f.translatable_text_field :title %>
+ <%= translations_form.text_field :title %>
- <%= f.translatable_text_area :description, rows: 5 %>
+ <%= translations_form.text_area :description, rows: 5 %>
-
- <%= f.translatable_text_field :link_text %>
-
+
+ <%= translations_form.text_field :link_text %>
+
+ <% end %>
<%= f.text_field :link_url %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index 0e93a99f2..6f834931e 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -291,6 +291,11 @@ en:
description: Description
link_text: Link text
link_url: Link URL
+ widget/card/translation:
+ label: Label (optional)
+ title: Title
+ description: Description
+ link_text: Link text
widget/feed:
limit: Number of items
errors:
diff --git a/spec/features/admin/widgets/cards_spec.rb b/spec/features/admin/widgets/cards_spec.rb
index 22b1e6bff..b8b29887f 100644
--- a/spec/features/admin/widgets/cards_spec.rb
+++ b/spec/features/admin/widgets/cards_spec.rb
@@ -16,10 +16,10 @@ feature 'Cards' do
visit admin_homepage_path
click_link "Create card"
- fill_in "widget_card_label_en", with: "Card label"
- fill_in "widget_card_title_en", with: "Card text"
- fill_in "widget_card_description_en", with: "Card description"
- fill_in "widget_card_link_text_en", with: "Link text"
+ fill_in "Label (optional)", with: "Card label"
+ fill_in "Title", with: "Card text"
+ fill_in "Description", with: "Card description"
+ fill_in "Link text", with: "Link text"
fill_in "widget_card_link_url", with: "consul.dev"
attach_image_to_card
click_button "Create card"
@@ -64,10 +64,10 @@ feature 'Cards' do
click_link "Edit"
end
- fill_in "widget_card_label_en", with: "Card label updated"
- fill_in "widget_card_title_en", with: "Card text updated"
- fill_in "widget_card_description_en", with: "Card description updated"
- fill_in "widget_card_link_text_en", with: "Link text updated"
+ fill_in "Label (optional)", with: "Card label updated"
+ fill_in "Title", with: "Card text updated"
+ fill_in "Description", with: "Card description updated"
+ fill_in "Link text", with: "Link text updated"
fill_in "widget_card_link_url", with: "consul.dev updated"
click_button "Save card"
@@ -104,10 +104,10 @@ feature 'Cards' do
visit admin_homepage_path
click_link "Create header"
- fill_in "widget_card_label_en", with: "Header label"
- fill_in "widget_card_title_en", with: "Header text"
- fill_in "widget_card_description_en", with: "Header description"
- fill_in "widget_card_link_text_en", with: "Link text"
+ fill_in "Label (optional)", with: "Header label"
+ fill_in "Title", with: "Header text"
+ fill_in "Description", with: "Header description"
+ fill_in "Link text", with: "Link text"
fill_in "widget_card_link_url", with: "consul.dev"
click_button "Create header"