spree_simple_product_translations 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,7 +16,19 @@ Then copy the assets to your spree application:
16
16
  rake spree_product_translations:install
17
17
  rake spree_simple_product_translations:install
18
18
 
19
+ # Open issues
20
+ In the current version of [Globalize3](https://github.com/svenfuchs/globalize3) there is an issue with fallbacks. When you add new translations in the forms, but leave some of them blank, they won't fall back to the default locale. This is because [Globalize3](https://github.com/svenfuchs/globalize3) only loads fallbacks when the values are nil. Because of the way Rails handles these attributes, they will be stored as blank strings into the database.
21
+
22
+ If you are using the fallbacks, you might want to use [my fork](https://github.com/jeroenj/globalize3) of [Globalize3](https://github.com/svenfuchs/globalize3) in your Gemfile until it gets merged into [Globalize3](https://github.com/svenfuchs/globalize3)'s [master branch](https://github.com/svenfuchs/globalize3):
23
+
24
+ gem 'globalize3', :git => 'git://github.com/jeroenj/globalize3.git'
25
+
26
+ For those interested, you can follow [the pull request here](https://github.com/svenfuchs/globalize3/pull/32).
27
+
19
28
  # To add in future releases
29
+ * Add form to:
30
+ + Prototype
31
+ + Taxonomy
20
32
  * Tests
21
33
  * Configuration option for which locales te load
22
34
  * Better design?
@@ -0,0 +1,29 @@
1
+ <%= f.field_container :name do %>
2
+ <%= f.label :name, t("name") %><br />
3
+ <%= f.text_field :name %>
4
+ <%= f.error_message_on :name %>
5
+ <% end %>
6
+
7
+ <%= javascript_include_tag 'jquery-ui-1.7.3.custom.min', 'simple_product_translations' %>
8
+ <%= stylesheet_link_tag 'smoothness/jquery-ui-1.7.3.custom' %>
9
+
10
+ <div id="tabs">
11
+ <ul>
12
+ <% I18n.available_locales.each do |l| %>
13
+ <li><%= link_to t(l), "#tabs-#{l}" %></li>
14
+ <% end %>
15
+ </ul>
16
+ <% I18n.available_locales.each do |l| %>
17
+ <div id="tabs-<%= l %>">
18
+ <%= f.globalize_fields_for l do |g| %>
19
+ <% default_locale = l.to_sym == I18n.default_locale %>
20
+ <% g = f if default_locale %>
21
+ <%= f.field_container :presentation do %>
22
+ <%= g.label :presentation, t("presentation") %> <% if default_locale %><span class="required">*</span><% end %><br />
23
+ <%= g.text_field :presentation %>
24
+ <%= f.error_message_on :presentation %>
25
+ <% end %>
26
+ <% end %>
27
+ </div>
28
+ <% end %>
29
+ </div>
@@ -0,0 +1,17 @@
1
+ <tr class="option_value fields" id="<%= dom_id(f.object) %>">
2
+ <td><%= f.text_field :name %></td>
3
+ <td>
4
+ <%# Required js for tabs is loaded in form partial %>
5
+ <% I18n.available_locales.each do |l| %>
6
+ <p>
7
+ <%= f.globalize_fields_for l do |g| %>
8
+ <% default_locale = l.to_sym == I18n.default_locale %>
9
+ <% g = f if default_locale %>
10
+ <%= g.label :presentation, "#{t(l)}: " %>
11
+ <%= g.text_field :presentation %><% if default_locale %><span class="required">*</span><% end %>
12
+ <% end %>
13
+ </p>
14
+ <% end %>
15
+ </td>
16
+ <td class="actions"><%= link_to_remove_fields t("remove"), f %></td>
17
+ </tr>
@@ -31,7 +31,6 @@
31
31
  <%= g.text_area :description, {:cols => 60, :rows => 4, :class => 'fullwidth'} %>
32
32
  <%= f.error_message_on :description %>
33
33
  <% end %>
34
- </p>
35
34
  <% end %>
36
35
  </div>
37
36
  <% end %>
@@ -0,0 +1,29 @@
1
+ <%= f.field_container :name do %>
2
+ <%= f.label :name, t("name") %> <span class="required">*</span><br />
3
+ <%= f.text_field :name %>
4
+ <%= f.error_message_on :name %>
5
+ <% end %>
6
+
7
+ <%= javascript_include_tag 'jquery-ui-1.7.3.custom.min', 'simple_product_translations' %>
8
+ <%= stylesheet_link_tag 'smoothness/jquery-ui-1.7.3.custom' %>
9
+
10
+ <div id="tabs">
11
+ <ul>
12
+ <% I18n.available_locales.each do |l| %>
13
+ <li><%= link_to t(l), "#tabs-#{l}" %></li>
14
+ <% end %>
15
+ </ul>
16
+ <% I18n.available_locales.each do |l| %>
17
+ <div id="tabs-<%= l %>">
18
+ <%= f.globalize_fields_for l do |g| %>
19
+ <% default_locale = l.to_sym == I18n.default_locale %>
20
+ <% g = f if default_locale %>
21
+ <%= f.field_container :presentation do %>
22
+ <%= g.label :presentation, t("presentation") %> <% if default_locale %><span class="required">*</span><% end %><br />
23
+ <%= g.text_field :presentation %>
24
+ <%= f.error_message_on :presentation %>
25
+ <% end %>
26
+ <% end %>
27
+ </div>
28
+ <% end %>
29
+ </div>
@@ -0,0 +1,40 @@
1
+ <%= hook :admin_inside_taxon_form do %>
2
+ <%= javascript_include_tag 'jquery-ui-1.7.3.custom.min', 'simple_product_translations' %>
3
+ <%= stylesheet_link_tag 'smoothness/jquery-ui-1.7.3.custom' %>
4
+
5
+ <div id="tabs">
6
+ <ul>
7
+ <% I18n.available_locales.each do |l| %>
8
+ <li><%= link_to t(l), "#tabs-#{l}" %></li>
9
+ <% end %>
10
+ </ul>
11
+ <% I18n.available_locales.each do |l| %>
12
+ <div id="tabs-<%= l %>">
13
+ <%= f.globalize_fields_for l do |g| %>
14
+ <% default_locale = l.to_sym == I18n.default_locale %>
15
+ <% g = f if default_locale %>
16
+ <%= f.field_container :name do %>
17
+ <%= g.label :name, t("name") %> <% if default_locale %><span class="required">*</span><% end %><br />
18
+ <%= error_message_on :taxon, :name, :class => 'fullwidth title' %>
19
+ <%= g.text_field :name %>
20
+ <% end %>
21
+
22
+ <%= f.field_container :description do %>
23
+ <%= g.label :description, t(:description) %><br />
24
+ <%= g.text_area :description %>
25
+ <% end %>
26
+ <% end %>
27
+ </div>
28
+ <% end %>
29
+ </div>
30
+
31
+ <%= f.field_container :permalink_part do %>
32
+ <%= f.label :permalink_part, t("permalink") %><span class="required">*</span><br />
33
+ <%= @taxon.permalink.split("/")[0...-1].join("/") + "/" %><%= text_field_tag :permalink_part, @permalink_part %>
34
+ <% end %>
35
+
36
+ <%= f.field_container :icon do %>
37
+ <%= f.label :icon, t('icon') %><br />
38
+ <%= f.file_field :icon %>
39
+ <% end %>
40
+ <% end %>
@@ -7,7 +7,8 @@ module ActionView
7
7
  raise ArgumentError, "Missing block" unless block_given?
8
8
  @index = @index ? @index + 1 : 1
9
9
  object_name = "#{@object_name}[translations_attributes][#{@index}]"
10
- object = @object.translations.select{|t| t.locale.to_s == locale}.first || @object.translations.find_by_locale(locale.to_s)
10
+ form_object = @object || @object_name.to_s.camelize.constantize.new
11
+ object = form_object.translations.select{|t| t.locale.to_s == locale}.first || form_object.translations.find_by_locale(locale.to_s)
11
12
  @template.concat @template.hidden_field_tag("#{object_name}[id]", object ? object.id : "")
12
13
  @template.concat @template.hidden_field_tag("#{object_name}[locale]", locale)
13
14
  @template.fields_for(object_name, object, *args, &proc)
@@ -14,7 +14,25 @@ module SpreeSimpleProductTranslations
14
14
  Rails.env.production? ? require(c) : load(c)
15
15
  end
16
16
 
17
- ::Product.send :include, Models::Product
17
+ ::Product.class_eval do
18
+ accepts_nested_attributes_for :translations
19
+ end
20
+
21
+ ::Property.class_eval do
22
+ accepts_nested_attributes_for :translations
23
+ end
24
+
25
+ ::Taxon.class_eval do
26
+ accepts_nested_attributes_for :translations
27
+ end
28
+
29
+ ::OptionType.class_eval do
30
+ accepts_nested_attributes_for :translations
31
+ end
32
+
33
+ ::OptionValue.class_eval do
34
+ accepts_nested_attributes_for :translations
35
+ end
18
36
  end
19
37
 
20
38
  config.to_prepare &method(:activate).to_proc
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_simple_product_translations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeroen Jacobs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-02 00:00:00 +01:00
18
+ date: 2011-03-03 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,12 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 29
45
+ hash: 27
46
46
  segments:
47
47
  - 0
48
48
  - 0
49
- - 1
50
- version: 0.0.1
49
+ - 2
50
+ version: 0.0.2
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  description:
@@ -61,12 +61,15 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - README.md
63
63
  - lib/batch_translation.rb
64
- - lib/models/product.rb
65
64
  - lib/spree_simple_product_translations.rb
66
65
  - lib/spree_simple_product_translations_hooks.rb
67
66
  - lib/tasks/install.rake
68
67
  - lib/tasks/spree_simple_product_translations.rake
68
+ - app/views/admin/option_types/_form.html.erb
69
+ - app/views/admin/option_types/_option_value_fields.html.erb
69
70
  - app/views/admin/products/_product_form_left.html.erb
71
+ - app/views/admin/properties/_form.html.erb
72
+ - app/views/admin/taxons/_form.html.erb
70
73
  has_rdoc: false
71
74
  homepage: https://github.com/jeroenj/spree-simple_product_translations
72
75
  licenses: []
@@ -1,7 +0,0 @@
1
- module Models::Product
2
- def self.included(target)
3
- target.class_eval do
4
- accepts_nested_attributes_for :translations
5
- end
6
- end
7
- end