Update widget cards translatable fields

This commit is contained in:
Javi Martín
2018-10-11 00:57:26 +02:00
parent 3c170f47d2
commit 139cf769c6
6 changed files with 35 additions and 23 deletions

View File

@@ -43,9 +43,8 @@ class Admin::Widget::CardsController < Admin::BaseController
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
params.require(:widget_card).permit( params.require(:widget_card).permit(
:label, :title, :description, :link_text, :link_url, :link_url, :button_text, :button_url, :alignment, :header,
:button_text, :button_url, :alignment, :header, translation_params(Widget::Card),
*translation_params(Widget::Card),
image_attributes: image_attributes image_attributes: image_attributes
) )
end end

View File

@@ -9,6 +9,7 @@ class Widget::Card < ActiveRecord::Base
translates :description, touch: true translates :description, touch: true
translates :link_text, touch: true translates :link_text, touch: true
globalize_accessors globalize_accessors
accepts_nested_attributes_for :translations, allow_destroy: true
def self.header def self.header
where(header: true) where(header: true)

View File

@@ -2,17 +2,19 @@
<%= translatable_form_for [:admin, @card] do |f| %> <%= translatable_form_for [:admin, @card] do |f| %>
<%= f.translatable_fields do |translations_form| %>
<div class="small-12 medium-6"> <div class="small-12 medium-6">
<%= f.translatable_text_field :label %> <%= translations_form.text_field :label %>
</div> </div>
<%= f.translatable_text_field :title %> <%= translations_form.text_field :title %>
<%= f.translatable_text_area :description, rows: 5 %> <%= translations_form.text_area :description, rows: 5 %>
<div class="small-12 medium-6"> <div class="small-12 medium-6">
<%= f.translatable_text_field :link_text %> <%= translations_form.text_field :link_text %>
</div> </div>
<% end %>
<div class="small-12 medium-6"> <div class="small-12 medium-6">
<%= f.text_field :link_url %> <%= f.text_field :link_url %>

View File

@@ -291,6 +291,11 @@ en:
description: Description description: Description
link_text: Link text link_text: Link text
link_url: Link URL link_url: Link URL
widget/card/translation:
label: Label (optional)
title: Title
description: Description
link_text: Link text
widget/feed: widget/feed:
limit: Number of items limit: Number of items
errors: errors:

View File

@@ -291,6 +291,11 @@ es:
description: Descripción description: Descripción
link_text: Texto del enlace link_text: Texto del enlace
link_url: URL del enlace link_url: URL del enlace
widget/card/translation:
label: Etiqueta (opcional)
title: Título
description: Descripción
link_text: Texto del enlace
widget/feed: widget/feed:
limit: Número de elementos limit: Número de elementos
errors: errors:

View File

@@ -16,10 +16,10 @@ feature 'Cards' do
visit admin_homepage_path visit admin_homepage_path
click_link "Create card" click_link "Create card"
fill_in "widget_card_label_en", with: "Card label" fill_in "Label (optional)", with: "Card label"
fill_in "widget_card_title_en", with: "Card text" fill_in "Title", with: "Card text"
fill_in "widget_card_description_en", with: "Card description" fill_in "Description", with: "Card description"
fill_in "widget_card_link_text_en", with: "Link text" fill_in "Link text", with: "Link text"
fill_in "widget_card_link_url", with: "consul.dev" fill_in "widget_card_link_url", with: "consul.dev"
attach_image_to_card attach_image_to_card
click_button "Create card" click_button "Create card"
@@ -64,10 +64,10 @@ feature 'Cards' do
click_link "Edit" click_link "Edit"
end end
fill_in "widget_card_label_en", with: "Card label updated" fill_in "Label (optional)", with: "Card label updated"
fill_in "widget_card_title_en", with: "Card text updated" fill_in "Title", with: "Card text updated"
fill_in "widget_card_description_en", with: "Card description updated" fill_in "Description", with: "Card description updated"
fill_in "widget_card_link_text_en", with: "Link text updated" fill_in "Link text", with: "Link text updated"
fill_in "widget_card_link_url", with: "consul.dev updated" fill_in "widget_card_link_url", with: "consul.dev updated"
click_button "Save card" click_button "Save card"
@@ -104,10 +104,10 @@ feature 'Cards' do
visit admin_homepage_path visit admin_homepage_path
click_link "Create header" click_link "Create header"
fill_in "widget_card_label_en", with: "Header label" fill_in "Label (optional)", with: "Header label"
fill_in "widget_card_title_en", with: "Header text" fill_in "Title", with: "Header text"
fill_in "widget_card_description_en", with: "Header description" fill_in "Description", with: "Header description"
fill_in "widget_card_link_text_en", with: "Link text" fill_in "Link text", with: "Link text"
fill_in "widget_card_link_url", with: "consul.dev" fill_in "widget_card_link_url", with: "consul.dev"
click_button "Create header" click_button "Create header"