Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spree Edge + Rails 3.1 Asset pipeline compatibility #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Then copy the migrations and assets to your spree application:
rake spree_product_translations:install
rake spree_simple_product_translations:install

To apply the Smoothness theme to the jQuery UI tabs add the following to app/assets/stylesheets/admin/all.css:

*= require jquery-ui-smoothness

Finally migrate your database:

rake db:migrate
Expand Down
5 changes: 5 additions & 0 deletions app/overrides/product_translation_js.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deface::Override.new(
:virtual_path => "layouts/admin",
:name => 'product_translation_js',
:insert_bottom => "[data-hook='admin_inside_head']",
:text => %Q[<%= javascript_tag "$(function(){ $('.tabs').livequery(function() { $(this).tabs(); }); });" %>])
5 changes: 5 additions & 0 deletions app/overrides/product_translation_meta_tabs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deface::Override.new(
:virtual_path => "admin/products/_form",
:name => 'product_translation_meta_tabs',
:replace => "[data-hook='admin_product_form_meta']",
:partial => "admin/products/product_form_meta")
5 changes: 5 additions & 0 deletions app/overrides/product_translation_tabs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deface::Override.new(
:virtual_path => "admin/products/_form",
:name => 'product_translation_tabs',
:replace => "[data-hook='admin_product_form_left']",
:partial => "admin/products/product_form_left")
7 changes: 2 additions & 5 deletions app/views/admin/option_types/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
<%= f.error_message_on :name %>
<% end %>

<%= javascript_include_tag 'jquery-ui-1.7.3.custom.min', 'simple_product_translations' %>
<%= stylesheet_link_tag 'smoothness/jquery-ui-1.7.3.custom' %>

<div id="tabs">
<div class="tabs">
<ul>
<% I18n.available_locales.each do |l| %>
<li><%= link_to t(l), "#tabs-#{l}" %></li>
Expand All @@ -24,4 +21,4 @@
<% end %>
</div>
<% end %>
</div>
</div>
5 changes: 2 additions & 3 deletions app/views/admin/option_types/_option_value_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<tr class="option_value fields" id="<%= dom_id(f.object) %>">
<td class='name'><%= f.text_field :name %></td>
<td class='presentation'>
<%# Required js for tabs is loaded in form partial %>
<td class="name"><%= f.text_field :name %></td>
<td class="presentation">
<% I18n.available_locales.each do |l| %>
<p>
<%= f.globalize_fields_for l do |g| %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<tr class="product_property fields" data-hook="product_property">
<td class="property_name">
<%= f.text_field :property_name, :class => "autocomplete" %>
</td>
<td class="value">
<% I18n.available_locales.each do |l| %>
<p>
<%= f.globalize_fields_for l do |g| %>
<%= g.label :value, "#{t(l)}: " %>
<%= g.text_field :value, :autocomplete => 'off' %><% if l.to_sym == I18n.default_locale %><span class="required">*</span><% end %>
<% end %>
</p>
<% end %>
</td>
<td class="actions">
<%= link_to_remove_fields t("remove"), f %>
</td>
</tr>
7 changes: 1 addition & 6 deletions app/views/admin/products/_product_form_left.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<% content_for :head do %>
<%= javascript_include_tag 'jquery-ui-1.7.3.custom.min', 'simple_product_translations' %>
<%= stylesheet_link_tag 'smoothness/jquery-ui-1.7.3.custom' %>
<% end %>

<div id="tabs">
<div class="tabs" style="float: left; width: 65%; margin-left: 0;">
<ul>
<% I18n.available_locales.each do |l| %>
<li><%= link_to t(l), "#tabs-#{l}" %></li>
Expand Down
21 changes: 21 additions & 0 deletions app/views/admin/products/_product_form_meta.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="tabs">
<ul>
<% I18n.available_locales.each do |l| %>
<li><%= link_to t(l), "#meta-tabs-#{l}" %></li>
<% end %>
</ul>
<% I18n.available_locales.each do |l| %>
<div id="meta-tabs-<%= l %>">
<%= f.globalize_fields_for l do |g| %>
<p>
<%= g.label :meta_keywords, t("meta_keywords")%><br />
<%= g.text_field :meta_keywords, :class => 'fullwidth' %>
</p>
<p>
<%= g.label :meta_description, t("meta_description")%><br />
<%= g.text_field :meta_description, :class => 'fullwidth' %>
</p>
<% end %>
</div>
<% end %>
</div>
5 changes: 1 addition & 4 deletions app/views/admin/properties/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
<%= f.error_message_on :name %>
<% end %>

<%= javascript_include_tag 'jquery-ui-1.7.3.custom.min', 'simple_product_translations' %>
<%= stylesheet_link_tag 'smoothness/jquery-ui-1.7.3.custom' %>

<div id="tabs">
<div class="tabs">
<ul>
<% I18n.available_locales.each do |l| %>
<li><%= link_to t(l), "#tabs-#{l}" %></li>
Expand Down
5 changes: 1 addition & 4 deletions app/views/admin/taxons/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<%= hook :admin_inside_taxon_form, {:f => f} do %>
<%= javascript_include_tag 'jquery-ui-1.7.3.custom.min', 'simple_product_translations' %>
<%= stylesheet_link_tag 'smoothness/jquery-ui-1.7.3.custom' %>

<div id="tabs">
<div class="tabs">
<ul>
<% I18n.available_locales.each do |l| %>
<li><%= link_to t(l), "#tabs-#{l}" %></li>
Expand Down
18 changes: 11 additions & 7 deletions lib/spree_simple_product_translations.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
require 'spree_core'
require 'spree_product_translations'

require 'spree_simple_product_translations_hooks'
require 'batch_translation'

module SpreeSimpleProductTranslations
class Engine < Rails::Engine

config.autoload_paths += %W(#{config.root}/lib)

def self.activate
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.env.production? ? require(c) : load(c)
end

::Product.class_eval do
accepts_nested_attributes_for :translations
end


::ProductProperty.class_eval do
accepts_nested_attributes_for :translations, :reject_if => proc { |attributes| attributes['value'].blank? }
validates_presence_of :value
end

::Property.class_eval do
accepts_nested_attributes_for :translations
end

::Taxon.class_eval do
accepts_nested_attributes_for :translations
end

::OptionType.class_eval do
accepts_nested_attributes_for :translations
accepts_nested_attributes_for :translations, :reject_if => proc { |attributes| attributes['presentation'].blank? }
accepts_nested_attributes_for :option_values, :allow_destroy => true
end

::OptionValue.class_eval do
accepts_nested_attributes_for :translations
validates_presence_of :name, :presentation
accepts_nested_attributes_for :translations, :reject_if => proc { |attributes| attributes['presentation'].blank? }
validates_presence_of :name
end
end

Expand Down
3 changes: 0 additions & 3 deletions lib/spree_simple_product_translations_hooks.rb

This file was deleted.

183 changes: 0 additions & 183 deletions public/javascripts/jquery-ui-1.7.3.custom.min.js

This file was deleted.

3 changes: 0 additions & 3 deletions public/javascripts/simple_product_translations.js

This file was deleted.

2 changes: 0 additions & 2 deletions spree_simple_product_translations.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'

s.has_rdoc = false

s.add_dependency('spree_core', '>= 0.40.3')
s.add_dependency('spree_product_translations', '~> 0.0.3')
end
Loading