Skip to content

Commit

Permalink
Remove attribute translations for associations
Browse files Browse the repository at this point in the history
Example.  Instead of having country_id having a translation under the
address model attributes of country just use
Spree::Country.model_name.human.
  • Loading branch information
Murph33 committed Feb 18, 2016
1 parent 902ad00 commit 20d7e96
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/products/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@

<div data-hook="admin_product_form_shipping_categories">
<%= f.field_container :shipping_categories do %>
<%= f.label :shipping_category_id %>
<%= f.label :shipping_category_id, Spree::ShippingCategory.model_name.human %>
<%= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { :include_blank => Spree.t('match_choices.none') }, { :class => 'select2' }) %>
<%= f.error_message_on :shipping_category %>
<% end %>
</div>

<div data-hook="admin_product_form_tax_category">
<%= f.field_container :tax_category do %>
<%= f.label :tax_category_id %>
<%= f.label :tax_category_id, Spree::TaxCategory.model_name.human %>
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { :include_blank => Spree.t('match_choices.none') }, { :class => 'select2' }) %>
<%= f.error_message_on :tax_category %>
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion backend/app/views/spree/admin/products/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
<div class='row'>
<div data-hook="new_product_shipping_category" class="alpha four columns">
<%= f.field_container :shipping_category do %>
<%= f.label :shipping_category_id, class: 'required' %><br />
<%= f.label :shipping_category_id, Spree::ShippingCategory.
model_name.human, class: 'required' %><br />
<%= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { :include_blank => Spree.t('match_choices.none') }, { :class => 'select2 fullwidth', :required => true }) %>
<%= f.error_message_on :shipping_category_id %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/promotions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<% end %>
<%= f.field_container :category do %>
<%= f.label :promotion_category_id %><br />
<%= f.label :promotion_category_id, Spree::PromotionCategory.model_name.human %><br />
<%= f.collection_select(:promotion_category_id, @promotion_categories, :id, :name, { :include_blank => Spree.t('match_choices.none') }, { :class => 'select2 fullwidth' }) %>
<% end %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<% end %>
<%= f.field_container :stock_location do %>
<%= f.label :stock_location, Spree.t(:stock_location) %>
<%= f.label :stock_location_id, Spree::StockLocation.model_name.human %>
<%= f.select :stock_location_id, @stock_locations.to_a.collect{|l|[l.name, l.id]}, {include_blank: true}, {class: 'select2 fullwidth', "data-placeholder" => Spree.t(:select_a_stock_location)} %>
<%= f.error_message_on :stock_location_id %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/shared/_address_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
</div>

<div class="field <%= "#{type}-row" %>">
<%= f.label :country_id %>
<%= f.label :country_id, Spree::Country.model_name.human %>
<span id="<%= s_or_b %>country">
<%= f.collection_select :country_id, available_countries, :id, :name, {}, {:class => 'select2 fullwidth'} %>
</span>
</div>

<div class="field <%= "#{type}-row" %>">
<%= f.label :state_id %>
<%= f.label :state_id, Spree::State.model_name.human %>
<span id="<%= s_or_b %>state">
<%= f.text_field :state_name,
:style => "display: #{f.object.country.states.empty? ? 'block' : 'none' };",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= f.text_field :quantity %>
<% end %>
<%= f.field_container :stock_item_id do %>
<%= f.label :stock_item_id %>
<%= f.label :stock_item_id, Spree::StockItem.model_name.human %>
<%= f.text_field 'stock_item_id', :class => 'fullwidth', :'data-stock-location-id' => params[:stock_location_id] %>
<% end %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions backend/spec/features/admin/products/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def build_option_type_with_values(name, values)
select "Size", from: "Prototype"
check "Large"
click_button "Create"
expect(page).to have_content("Shipping Category can't be blank")
expect(page).to have_content("Shipping category can't be blank")
expect(field_labeled("Size")).to be_checked
expect(field_labeled("Large")).to be_checked
expect(field_labeled("Small")).not_to be_checked
Expand Down Expand Up @@ -210,7 +210,7 @@ def build_option_type_with_values(name, values)
fill_in "product_sku", with: "B100"
fill_in "product_price", with: "100"
click_button "Create"
expect(page).to have_content("Shipping Category can't be blank")
expect(page).to have_content("Shipping category can't be blank")
end

context "using a locale with a different decimal format " do
Expand Down
9 changes: 3 additions & 6 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ en:
address2: Street Address (cont'd)
city: City
company: Company
country_id: Country
firstname: First Name
lastname: Last Name
phone: Phone
state_id: State
zipcode: Zip Code
spree/adjustment:
adjustable: Adjustable
Expand Down Expand Up @@ -133,7 +131,6 @@ en:
price: Master Price
promotionable: Promotable
shipping_category: Shipping Category
shipping_category_id: Shipping Category
slug: Slug
tax_category: Tax Category
weight: Weight
Expand All @@ -150,7 +147,6 @@ en:
name: Name
path: Path
per_code_usage_limit: Per Code Usage Limit
promotion_category_id: Promotion Category
starts_at: Starts
usage_limit: Overall Usage Limit
spree/promotion_category:
Expand Down Expand Up @@ -243,8 +239,6 @@ en:
spree/stock_movement:
action: Action
quantity: Quantity
stock_item_id: Stock Item
quantity: Quantity
spree/stock_transfer:
created_at: Created At
created_by_id: Created By
Expand Down Expand Up @@ -394,6 +388,9 @@ en:
one: State
other: States
spree/stock: stock
spree/stock_item:
one: Stock Item
other: Stock Items
spree/stock_movement:
one: Stock Movement
other: Stock Movements
Expand Down

0 comments on commit 20d7e96

Please sign in to comment.