spree_maker_search 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +14 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +6 -0
  4. data/LICENSE +26 -0
  5. data/README.ja.md +56 -0
  6. data/README.md +56 -0
  7. data/Rakefile +15 -0
  8. data/app/assets/javascripts/admin/spree_maker_search.js +45 -0
  9. data/app/assets/javascripts/store/spree_maker_search.js +1 -0
  10. data/app/assets/stylesheets/admin/spree_maker_search.css +3 -0
  11. data/app/assets/stylesheets/store/spree_maker_search.css +34 -0
  12. data/app/controllers/spree/admin/add_on_makers_controller.rb +34 -0
  13. data/app/controllers/spree/admin/products_controller_decorator.rb +8 -0
  14. data/app/controllers/spree/products_controller_decorator.rb +7 -0
  15. data/app/controllers/spree/taxons_controller_decorator.rb +47 -0
  16. data/app/helpers/spree/admin/products_helper_decorator.rb +12 -0
  17. data/app/helpers/spree/taxons_helper_decorator.rb +7 -0
  18. data/app/models/spree/ability_decorator.rb +12 -0
  19. data/app/models/spree/add_on_maker.rb +11 -0
  20. data/app/models/spree/add_on_maker_product.rb +6 -0
  21. data/app/models/spree/add_on_maker_translation.rb +6 -0
  22. data/app/models/spree/product_decorator.rb +6 -0
  23. data/app/models/spree/products/scopes_decorator.rb +0 -0
  24. data/app/models/spree/taxons_decorator.rb +5 -0
  25. data/app/overrides/add_add_on_maker_configration_menu_to_add_on_menu.rb +6 -0
  26. data/app/overrides/add_maker_to_admin_product.rb +11 -0
  27. data/app/overrides/add_maker_to_front_product.rb +8 -0
  28. data/app/overrides/add_makers_to_front_navigation.rb +16 -0
  29. data/app/overrides/add_makers_to_front_taxon_products.rb +20 -0
  30. data/app/views/spree/admin/add_on_makers/_form.html.erb +14 -0
  31. data/app/views/spree/admin/add_on_makers/api.json.rabl +9 -0
  32. data/app/views/spree/admin/add_on_makers/edit.html.erb +11 -0
  33. data/app/views/spree/admin/add_on_makers/index.html.erb +29 -0
  34. data/app/views/spree/admin/add_on_makers/new.html.erb +11 -0
  35. data/bin/rails +7 -0
  36. data/config/locales/en.yml +16 -0
  37. data/config/locales/ja.yml +13 -0
  38. data/config/routes.rb +12 -0
  39. data/db/migrate/20140410084602_create_spree_maker_search.rb +21 -0
  40. data/lib/generators/spree_maker_search/install/install_generator.rb +31 -0
  41. data/lib/spree_maker_search.rb +2 -0
  42. data/lib/spree_maker_search/engine.rb +22 -0
  43. data/lib/spree_maker_search/factories.rb +6 -0
  44. data/spec/spec_helper.rb +82 -0
  45. data/spree_maker_search.gemspec +32 -0
  46. metadata +52 -6
@@ -0,0 +1,14 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ .sass-cache
8
+ coverage
9
+ Gemfile.lock
10
+ tmp
11
+ nbproject
12
+ pkg
13
+ *.swp
14
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Provides basic authentication functionality for testing parts of your engine
4
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise'
5
+
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2014 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,56 @@
1
+ SpreeMakerSearch
2
+ ================
3
+
4
+ 目的
5
+ -------
6
+ * 商品のメーカー名を商品詳細ページに表示します。
7
+ * ショッピングサイト上で、メーカー名でフィルタリングできます(分類のページで)。
8
+ * 管理者はメーカーのリストを管理でき、製品に1メーカーを設定することができます(ADD ON MENUタブを開いてください)。
9
+
10
+ 商品名の下にメーカー名を表示
11
+ ![MakerSearch](https://raw.githubusercontent.com/wiki/digitalm/spree_maker_search/images/makersearch2.jpg)
12
+
13
+ フィルタ検索
14
+ ![MakerSearch](https://raw.githubusercontent.com/wiki/digitalm/spree_maker_search/images/makersearch1.jpg)
15
+
16
+ 管理サイト - ADD ON MENUタブ
17
+ ![Maker](https://raw.githubusercontent.com/wiki/digitalm/spree_maker_search/images/maker1.jpg)
18
+
19
+ 管理サイト - 商品タブ - 商品編集ページ
20
+ ![Maker](https://raw.githubusercontent.com/wiki/digitalm/spree_maker_search/images/maker2.jpg)
21
+
22
+ 設置方法
23
+ ------------
24
+
25
+ Gemfileに追加します:
26
+
27
+ ```ruby
28
+ gem 'spree_maker_search'
29
+ ```
30
+
31
+ Bundleしてインストールします:
32
+
33
+ ```shell
34
+ bundle
35
+ bundle exec rails g spree_maker_search:install
36
+ ```
37
+
38
+ Testing
39
+ -------
40
+
41
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
42
+
43
+ ```shell
44
+ bundle
45
+ bundle exec rake test_app
46
+ bundle exec rspec spec
47
+ ```
48
+
49
+ When testing your applications integration with this extension you may use it's factories.
50
+ Simply add this require statement to your spec_helper:
51
+
52
+ ```ruby
53
+ require 'spree_maker_search/factories'
54
+ ```
55
+
56
+ Copyright (c) 2014 [Exsight.inc](http://www.exsight.co.jp/) , released under the New BSD License
@@ -0,0 +1,56 @@
1
+ SpreeMakerSearch
2
+ ================
3
+
4
+ Purpose
5
+ -------
6
+ * Product's maker name is shown on product detail page.
7
+ * Customer can filter by maker name on taxon page.
8
+ * Admin can manage maker list and set one maker to product.
9
+
10
+ Show maker name under product name
11
+ ![MakerSearch](https://raw.githubusercontent.com/wiki/digitalm/spree_maker_search/images/makersearch2.jpg)
12
+
13
+ Filter search
14
+ ![MakerSearch](https://raw.githubusercontent.com/wiki/digitalm/spree_maker_search/images/makersearch1.jpg)
15
+
16
+ Admin manage
17
+ ![Maker](https://raw.githubusercontent.com/wiki/digitalm/spree_maker_search/images/maker1.jpg)
18
+
19
+ Admin manage - Product
20
+ ![Maker](https://raw.githubusercontent.com/wiki/digitalm/spree_maker_search/images/maker2.jpg)
21
+
22
+ Installation
23
+ ------------
24
+
25
+ Add spree_maker_search to your Gemfile:
26
+
27
+ ```ruby
28
+ gem 'spree_maker_search'
29
+ ```
30
+
31
+ Bundle your dependencies and run the installation generator:
32
+
33
+ ```shell
34
+ bundle
35
+ bundle exec rails g spree_maker_search:install
36
+ ```
37
+
38
+ Testing
39
+ -------
40
+
41
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
42
+
43
+ ```shell
44
+ bundle
45
+ bundle exec rake test_app
46
+ bundle exec rspec spec
47
+ ```
48
+
49
+ When testing your applications integration with this extension you may use it's factories.
50
+ Simply add this require statement to your spec_helper:
51
+
52
+ ```ruby
53
+ require 'spree_maker_search/factories'
54
+ ```
55
+
56
+ Copyright (c) 2014 [Exsight.inc](http://www.exsight.co.jp/) , released under the New BSD License
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default => [:spec]
10
+
11
+ desc 'Generates a dummy app for testing'
12
+ task :test_app do
13
+ ENV['LIB_NAME'] = 'spree_maker_search'
14
+ Rake::Task['extension:test_app'].invoke
15
+ end
@@ -0,0 +1,45 @@
1
+ //= require admin/spree_backend
2
+ $(document).ready(function () {
3
+ 'use strict';
4
+
5
+ if ($('#product_add_on_maker_ids').length > 0) {
6
+ $('#product_add_on_maker_ids').select2({
7
+ placeholder: Spree.translations.add_on_maker_placeholder,
8
+ multiple: true,
9
+ initSelection: function (element, callback) {
10
+ var url = Spree.url(Spree.routes.add_on_makers_search, {
11
+ ids: element.val()
12
+ });
13
+ return $.getJSON(url, null, function (data) {
14
+ return callback(data['add_on_makers']);
15
+ });
16
+ },
17
+ ajax: {
18
+ url: Spree.routes.add_on_makers_search,
19
+ datatype: 'json',
20
+ data: function (term, page) {
21
+ return {
22
+ per_page: 50,
23
+ page: page,
24
+ q: {
25
+ name_cont: term
26
+ }
27
+ };
28
+ },
29
+ results: function (data, page) {
30
+ var more = page < data.pages;
31
+ return {
32
+ results: data['add_on_makers'],
33
+ more: more
34
+ };
35
+ }
36
+ },
37
+ formatResult: function (add_on_maker) {
38
+ return add_on_maker.name;
39
+ },
40
+ formatSelection: function (add_on_maker) {
41
+ return add_on_maker.name;
42
+ }
43
+ });
44
+ }
45
+ });
@@ -0,0 +1 @@
1
+ //= require store/spree_frontend
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_backend
3
+ */
@@ -0,0 +1,34 @@
1
+ /*
2
+ *= require store/spree_frontend
3
+ */
4
+ .add_on_maker {
5
+ display: block;
6
+ }
7
+ .add_on_maker ul{
8
+ list-style :none;
9
+ }
10
+ .add_on_maker ul li {
11
+ display: inline;
12
+ float: left;
13
+ padding: 0 1em;
14
+ border-left: solid 1px black;
15
+ }
16
+ .add_on_maker li:first-child{
17
+ border-left: none;
18
+ }
19
+
20
+ .add_on_maker_sidebar {
21
+ display: block;
22
+ }
23
+ .add_on_maker_sidebar ul{
24
+ list-style :none;
25
+ }
26
+ nav#add_on_maker_sidebar .add_on_maker {
27
+ border-bottom: 1px solid #D9D9DB;
28
+ font-size: 14px;
29
+ margin-bottom: 5px;
30
+ text-transform: uppercase;
31
+ }
32
+ #product-description .product-maker-name {
33
+ margin-bottom: 15px;
34
+ }
@@ -0,0 +1,34 @@
1
+ module Spree
2
+ module Admin
3
+ class AddOnMakersController < ResourceController
4
+
5
+ def update_values_positions
6
+ params[:positions].each do |id, index|
7
+ AddOnMaker.where(:id => id).update_all(:position => index)
8
+ end
9
+
10
+ respond_to do |format|
11
+ format.html { redirect_to admin_add_on_makers_url(params[:id]) }
12
+ format.js { render :text => 'Ok' }
13
+ end
14
+ end
15
+
16
+ def index
17
+ @add_on_maker = Spree::AddOnMaker.page(params[:page])
18
+ end
19
+
20
+ def api
21
+ if params[:ids]
22
+ @add_on_makers = Spree::AddOnMaker.where(:id => params[:ids].split(','))
23
+ else
24
+ @add_on_makers = Spree::AddOnMaker.accessible_by(current_ability, :read).load.ransack(params[:q]).result
25
+ end
26
+ Rails.logger.debug "####### executing admin/add_on_makers/api #######"
27
+ Rails.logger.debug current_ability.inspect
28
+ @add_on_makers = @add_on_makers.page(params[:page]).per(params[:per_page])
29
+ Rails.logger.debug @add_on_makers.inspect
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,8 @@
1
+ Spree::Admin::ProductsController.class_eval do
2
+ before_filter :load_add_on_maker, :only => :load_data
3
+
4
+ def load_add_on_maker
5
+ @add_on_maker = Spree::AddOnMaker.order(:name)
6
+ logger.info @add_on_maker
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ Spree::ProductsController.class_eval do
2
+ before_filter :load_product_maker, :only => :show
3
+ def load_product_maker
4
+ @add_on_maker_product = Spree::AddOnMakerProduct.includes(:add_on_maker).where(:product_id => @product.id).first
5
+ logger.info @add_on_maker_product.inspect
6
+ end
7
+ end
@@ -0,0 +1,47 @@
1
+ module Spree
2
+ Spree::TaxonsController.class_eval do
3
+ alias_method :original_show, :show unless method_defined?(:original_show)
4
+
5
+ def advanced_search
6
+ logger.info "############processing taxon/advanced_search######"
7
+ @taxon = Taxon.find_by_permalink!(params[:id])
8
+ return unless @taxon
9
+
10
+ @products = Spree::Product.includes(:add_on_makers).where("available_on not ?",nil).uniq
11
+ @q = Spree::Product.includes(:add_on_makers).search(params[:q])
12
+ @products = @q.result(distinct: true).page(params[:page]).joins(:variants_including_master).joins(:add_on_makers)
13
+
14
+ @searcher = build_searcher(params.merge(:taxon => @taxon.id))
15
+ @searcher_products = @searcher.retrieve_products
16
+
17
+ if @searcher_products.any?
18
+ @products_ids = @searcher_products.pluck(:id)
19
+ logger.info @products_ids
20
+ @add_on_maker_products_ids = Spree::AddOnMakerProduct.where(:product_id => @products_ids).pluck(:add_on_maker_id)
21
+ logger.info @add_on_maker_products.inspect
22
+ @add_on_makers = Spree::AddOnMaker.where(:id => @add_on_maker_products_ids).order(:name)
23
+ end
24
+
25
+ render "show"
26
+ end
27
+
28
+ def show
29
+ logger.info "############processing taxon/show######"
30
+ @taxon = Taxon.find_by_permalink!(params[:id])
31
+ return unless @taxon
32
+
33
+ @searcher = build_searcher(params.merge(:taxon => @taxon.id))
34
+ @products = @searcher.retrieve_products
35
+
36
+ if @products.any?
37
+ @products_ids = @products.pluck(:id)
38
+ logger.info @products_ids
39
+ @add_on_maker_products_ids = Spree::AddOnMakerProduct.where(:product_id => @products_ids).pluck(:add_on_maker_id)
40
+ logger.info @add_on_maker_products.inspect
41
+ @add_on_makers = Spree::AddOnMaker.where(:id => @add_on_maker_products_ids).order(:name)
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ Spree::Admin::ProductsHelper.class_eval do
2
+ def add_on_suppliers_options_for(product)
3
+ options = @add_on_suppliers.map do |add_on_supplier|
4
+ selected = product.add_on_suppliers.include?(add_on_supplier)
5
+ content_tag(:option,
6
+ :value => add_on_supplier.id,
7
+ :selected => ('selected' if selected)) do
8
+ add_on_supplier.name
9
+ end
10
+ end.join("").html_safe
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ Spree::TaxonsHelper.class_eval do
2
+ def generate_link_add_on_makers_in_taxon(add_on_makers)
3
+ add_on_makers.map do |add_on_maker|
4
+ link_to(add_on_maker.name, latest_path) + "|"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ class AbilityDecorator
2
+ include CanCan::Ability
3
+ def initialize(user)
4
+ #can [:read, :index], Spree::NewsEntry
5
+
6
+ if user.respond_to?(:has_spree_role?) && user.has_spree_role?('admin')
7
+ can [:admin, :index, :read, :update, :edit], Spree::AddOnMaker
8
+ end
9
+ end
10
+ end
11
+
12
+ Spree::Ability.register_ability(AbilityDecorator)
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ class AddOnMaker < ActiveRecord::Base
3
+ acts_as_paranoid
4
+ has_many :add_on_maker_products
5
+ has_many :products, :through => :add_on_maker_products
6
+ # acts_as_list scope: :product
7
+
8
+ validates :name, presence: true
9
+ validates_uniqueness_of :name
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module Spree
2
+ class AddOnMakerProduct < ActiveRecord::Base
3
+ belongs_to :product, class_name: 'Spree::Product'
4
+ belongs_to :add_on_maker, class_name: 'Spree::AddOnMaker', :foreign_key => :add_on_maker_id
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Spree
2
+ AddOnMaker.class_eval do
3
+ translates :name, :presentation, :fallbacks_for_empty_translations => true
4
+ include SpreeI18n::Translatable
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Spree
2
+ Product.class_eval do
3
+ has_many :add_on_maker_products
4
+ has_many :add_on_makers, :through => :add_on_maker_products
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Spree
2
+ Taxon.class_eval do
3
+ has_many :add_on_makers, :through => :add_on_maker_products
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => 'spree/admin/add_on_menu/index',
2
+ :name => 'add_add_on_maker_configration_menu_to_add_on_menu',
3
+ :insert_bottom => "[data-hook='admin_add_on_menu_sidebar_menu']",
4
+ :text => "
5
+ <%= configurations_sidebar_menu_item t('add_on.add_on_maker'), admin_add_on_makers_path %>
6
+ ")
@@ -0,0 +1,11 @@
1
+ Deface::Override.new(:virtual_path => 'spree/admin/products/_form',
2
+ :name => 'add_maker_to_admin_product',
3
+ :insert_top => "[data-hook='admin_product_form_additional_fields']",
4
+ :text => "
5
+ <%= f.field_container :add_on_makers do %>
6
+ <%= f.label :add_on_maker_ids, t('add_on.add_on_maker') %>
7
+ <%= f.collection_select(:add_on_maker_ids, Spree::AddOnMaker.all, :id, :name, { :include_blank => Spree.t('match_choices.none') }, { :class => 'select2' }) %>
8
+ <%= f.error_message_on :add_on_makers %>
9
+ <% end %>
10
+ ")
11
+
@@ -0,0 +1,8 @@
1
+ Deface::Override.new(:virtual_path => 'spree/products/show',
2
+ :name => 'add_maker_to_front_product',
3
+ :insert_before => "[data-hook='description']",
4
+ :text => "
5
+ <% if @add_on_maker_product %>
6
+ <h3 class='product-maker-name'><%= @add_on_maker_product.add_on_maker.name %></h3>
7
+ <% end %>
8
+ ")
@@ -0,0 +1,16 @@
1
+ Deface::Override.new(:virtual_path => 'spree/taxons/show',
2
+ :name => 'add_makers_to_front_navigation',
3
+ :insert_bottom => "[data-hook='taxon_sidebar_navigation']",
4
+ :text => "
5
+ <% if @add_on_makers && @add_on_makers.any? %>
6
+ <nav id='add_on_maker_sidebar'>
7
+ <h6 class='add_on_maker'><%=t('add_on.add_on_maker')%></h6>
8
+ <ul>
9
+ <% @add_on_makers.each do |add_on_maker| %>
10
+ <% next unless add_on_maker %>
11
+ <li><%= link_to(add_on_maker.name, taxons_advanced_search_path(:q => {:add_on_makers_id_eq => add_on_maker.id})) %></li>
12
+ <% end %>
13
+ </ul>
14
+ </nav>
15
+ <%end %>
16
+ ")
@@ -0,0 +1,20 @@
1
+ Deface::Override.new(:virtual_path => 'spree/taxons/show',
2
+ :name => 'add_makers_to_front_taxon_products',
3
+ :insert_before => "[data-hook='taxon_products']",
4
+ :text => "
5
+ <% if @add_on_makers && @add_on_makers.any? %>
6
+ <div class='add_on_maker'>
7
+ <ul>
8
+ <li><%=t('add_on.add_on_maker')%></li>
9
+ </ul>
10
+ <ul>
11
+ <% @add_on_makers.each do |add_on_maker| %>
12
+ <% next unless add_on_maker %>
13
+ <li><%= link_to(add_on_maker.name, taxons_advanced_search_path(:q => {:add_on_makers_id_eq => add_on_maker.id}) ) %></li>
14
+ <% end %>
15
+ </ul>
16
+ </div>
17
+ <div class='clear'></div>
18
+ <% end %>
19
+ ")
20
+
@@ -0,0 +1,14 @@
1
+ <%= form_for [:admin, @add_on_maker] do |f| %>
2
+ <div data-hook="admin_inside_bank_form" class="row">
3
+ <div class="alpha five columns">
4
+ <%= f.field_container :name do %>
5
+ <%= f.label :name, Spree.t(:name) %> <span class="required">*</span><br />
6
+ <%= f.error_message_on :name, :class => 'fullwidth title' %>
7
+ <%= f.text_field :name, :class => 'fullwidth' %>
8
+ <% end %>
9
+
10
+ <%= f.submit %>
11
+
12
+ </div>
13
+ </div>
14
+ <% end %>
@@ -0,0 +1,9 @@
1
+ object false
2
+ node(:count) { @add_on_makers.count }
3
+ node(:total_count) { @add_on_makers.total_count }
4
+ node(:current_page) { params[:page] ? params[:page].to_i : 1 }
5
+ node(:per_page) { params[:per_page] || Kaminari.config.default_per_page }
6
+ node(:pages) { @add_on_makers.num_pages }
7
+ child @add_on_makers => :add_on_makers do
8
+ attributes :id, :name
9
+ end
@@ -0,0 +1,11 @@
1
+ <% content_for :page_title do %>
2
+ <%= Spree.t(:edit_maker) %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= button_link_to Spree.t(:back_to_makers_list), admin_add_on_makers_path, :icon => 'icon-arrow-left' %>
8
+ </li>
9
+ <% end %>
10
+
11
+ <%= render :partial => 'form' %>
@@ -0,0 +1,29 @@
1
+ <% content_for :page_title do %>
2
+ <%= t("add_on.listing_add_on_maker") %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= button_link_to t("add_on.new_add_on_maker"), new_admin_add_on_maker_path , :icon => 'icon-plus', :id => 'admin_new_add_on_maker'%>
8
+ </li>
9
+ <% end %>
10
+
11
+ <%= paginate @add_on_maker %>
12
+
13
+ <table class='index'>
14
+ <thead>
15
+ <tr>
16
+ <th><%= t("activerecord.attributes.add_on_maker.name") %></th>
17
+ </tr>
18
+ </thead>
19
+
20
+ <tbody>
21
+ <% @add_on_maker.each do |maker| %>
22
+ <tr class="<%= cycle('odd', 'even') %>">
23
+ <td class="align-center"><%= maker.name %></td>
24
+ <td class="actions"><%= link_to_edit maker, :no_text => true, :class => 'edit' %></td>
25
+ <td class="actions"><%= link_to_delete maker, :no_text => true if can?(:delete, maker) && !maker.deleted? %></td>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ </table>
@@ -0,0 +1,11 @@
1
+ <% content_for :page_title do %>
2
+ <%= Spree.t(:new_add_on_maker) %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= button_link_to Spree.t(:back_to_add_on_makers_list), admin_add_on_makers_path, :icon => 'icon-arrow-left' %>
8
+ </li>
9
+ <% end %>
10
+
11
+ <%= render :partial => 'form' %>
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree_maker_search/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,16 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ add_on:
6
+ add_on_maker: Maker
7
+ listing_add_on_maker: Listing Makers
8
+ new_add_on_maker: New Makers
9
+ edit_add_on_maker: Edit Makers
10
+ destroy: Destroy
11
+ add_one: Add One
12
+ back_to_add_on_makers_list: Back To Makers List
13
+ activerecord:
14
+ attributes:
15
+ add_on_maker:
16
+ name: name
@@ -0,0 +1,13 @@
1
+ ja:
2
+ add_on:
3
+ add_on_maker: メーカー
4
+ listing_add_on_maker: メーカー一覧
5
+ new_add_on_maker: 新規
6
+ edit_add_on_maker: 編集
7
+ destroy: 削除
8
+ add_one: 新規追加
9
+ back_to_add_on_makers_list: 登録済メーカー一覧
10
+ activerecord:
11
+ attributes:
12
+ add_on_maker:
13
+ name: 名前
@@ -0,0 +1,12 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+
4
+ get 'admin/add_on_makers/api', :to => 'admin/add_on_makers#api', :defaults => { :format => 'json' }
5
+ get 't/*id/advanced_search' => 'taxons#advanced_search', :as => :taxons_advanced_search
6
+
7
+ namespace :admin do
8
+ resources :add_on_makers , :only => [:index, :new, :create, :edit, :update, :destroy] do
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,21 @@
1
+ class CreateSpreeMakerSearch < ActiveRecord::Migration
2
+ def change
3
+ create_table :spree_add_on_makers do |t|
4
+ t.string :name
5
+ t.datetime :deleted_at
6
+ t.timestamps
7
+ end
8
+ create_table :spree_add_on_maker_products do |t|
9
+ t.integer :product_id
10
+ t.integer :add_on_maker_id
11
+ t.integer :position
12
+ t.timestamps
13
+ end
14
+ create_table :spree_add_on_maker_translations do |t|
15
+ t.integer :add_on_maker_id
16
+ t.string :locale
17
+ t.string :name
18
+ t.timestamps
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,31 @@
1
+ module SpreeMakerSearch
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ class_option :auto_run_migrations, :type => :boolean, :default => false
6
+
7
+ def add_javascripts
8
+ append_file 'app/assets/javascripts/store/all.js', "//= require store/spree_maker_search\n"
9
+ append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_maker_search\n"
10
+ end
11
+
12
+ def add_stylesheets
13
+ inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/spree_maker_search\n", :before => /\*\//, :verbose => true
14
+ inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/spree_maker_search\n", :before => /\*\//, :verbose => true
15
+ end
16
+
17
+ def add_migrations
18
+ run 'bundle exec rake railties:install:migrations FROM=spree_maker_search'
19
+ end
20
+
21
+ def run_migrations
22
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
23
+ if run_migrations
24
+ run 'bundle exec rake db:migrate'
25
+ else
26
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_maker_search/engine'
@@ -0,0 +1,22 @@
1
+ module SpreeMakerSearch
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_maker_search'
6
+
7
+ config.autoload_paths += %W(#{config.root}/lib)
8
+
9
+ # use rspec for tests
10
+ config.generators do |g|
11
+ g.test_framework :rspec
12
+ end
13
+
14
+ def self.activate
15
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
16
+ Rails.configuration.cache_classes ? require(c) : load(c)
17
+ end
18
+ end
19
+
20
+ config.to_prepare &method(:activate).to_proc
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'spree_maker_search/factories'
6
+ end
@@ -0,0 +1,82 @@
1
+ # Run Coverage report
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'spec/dummy'
5
+ add_group 'Controllers', 'app/controllers'
6
+ add_group 'Helpers', 'app/helpers'
7
+ add_group 'Mailers', 'app/mailers'
8
+ add_group 'Models', 'app/models'
9
+ add_group 'Views', 'app/views'
10
+ add_group 'Libraries', 'lib'
11
+ end
12
+
13
+ # Configure Rails Environment
14
+ ENV['RAILS_ENV'] = 'test'
15
+
16
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
17
+
18
+ require 'rspec/rails'
19
+ require 'database_cleaner'
20
+ require 'ffaker'
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc,
23
+ # in spec/support/ and its subdirectories.
24
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
25
+
26
+ # Requires factories defined in spree_core
27
+ require 'spree/testing_support/factories'
28
+ require 'spree/testing_support/controller_requests'
29
+ require 'spree/testing_support/authorization_helpers'
30
+ require 'spree/testing_support/url_helpers'
31
+
32
+ # Requires factories defined in lib/spree_maker_search/factories.rb
33
+ require 'spree_maker_search/factories'
34
+
35
+ RSpec.configure do |config|
36
+ config.include FactoryGirl::Syntax::Methods
37
+
38
+ # == URL Helpers
39
+ #
40
+ # Allows access to Spree's routes in specs:
41
+ #
42
+ # visit spree.admin_path
43
+ # current_path.should eql(spree.products_path)
44
+ config.include Spree::TestingSupport::UrlHelpers
45
+
46
+ # == Mock Framework
47
+ #
48
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
49
+ #
50
+ # config.mock_with :mocha
51
+ # config.mock_with :flexmock
52
+ # config.mock_with :rr
53
+ config.mock_with :rspec
54
+ config.color = true
55
+
56
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
57
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
58
+
59
+ # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
60
+ # to cleanup after each test instead. Without transactional fixtures set to false the records created
61
+ # to setup a test will be unavailable to the browser, which runs under a seperate server instance.
62
+ config.use_transactional_fixtures = false
63
+
64
+ # Ensure Suite is set to use transactions for speed.
65
+ config.before :suite do
66
+ DatabaseCleaner.strategy = :transaction
67
+ DatabaseCleaner.clean_with :truncation
68
+ end
69
+
70
+ # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
71
+ config.before :each do
72
+ DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
73
+ DatabaseCleaner.start
74
+ end
75
+
76
+ # After each spec clean the database.
77
+ config.after :each do
78
+ DatabaseCleaner.clean
79
+ end
80
+
81
+ config.fail_fast = ENV['FAIL_FAST'] || false
82
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+ Gem::Specification.new do |s|
3
+ s.platform = Gem::Platform::RUBY
4
+ s.name = 'spree_maker_search'
5
+ s.version = '0.1.1'
6
+ s.summary = 'Spree Extension : Show maker name on detail page , enable filter by maker name list on taxon page , and enable manage makers.'
7
+ s.description = "Product's maker name is shown on product detail page. Customer can filter by maker name on taxon page. Admin can manage maker list and set one maker to product."
8
+ s.required_ruby_version = '>= 1.9.3'
9
+
10
+ s.author = 'Mika Mizuno'
11
+ s.email = 'mika.mizuno@exsight.co.jp'
12
+ s.homepage = 'http://www.exsight.co.jp'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.require_path = 'lib'
17
+ s.requirements << 'none'
18
+
19
+ s.add_dependency 'spree_core', '~> 2.1.4'
20
+ s.add_dependency 'spree_add_on_menu', '~> 0.1.0'
21
+
22
+ s.add_development_dependency 'capybara', '~> 2.1'
23
+ s.add_development_dependency 'coffee-rails'
24
+ s.add_development_dependency 'database_cleaner'
25
+ s.add_development_dependency 'factory_girl', '~> 4.2'
26
+ s.add_development_dependency 'ffaker'
27
+ s.add_development_dependency 'rspec-rails', '~> 2.13'
28
+ s.add_development_dependency 'sass-rails'
29
+ s.add_development_dependency 'selenium-webdriver'
30
+ s.add_development_dependency 'simplecov'
31
+ s.add_development_dependency 'sqlite3'
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_maker_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-22 00:00:00.000000000 Z
12
+ date: 2014-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0.1'
37
+ version: 0.1.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0.1'
45
+ version: 0.1.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: capybara
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -209,7 +209,52 @@ email: mika.mizuno@exsight.co.jp
209
209
  executables: []
210
210
  extensions: []
211
211
  extra_rdoc_files: []
212
- files: []
212
+ files:
213
+ - .gitignore
214
+ - .rspec
215
+ - Gemfile
216
+ - LICENSE
217
+ - README.ja.md
218
+ - README.md
219
+ - Rakefile
220
+ - app/assets/javascripts/admin/spree_maker_search.js
221
+ - app/assets/javascripts/store/spree_maker_search.js
222
+ - app/assets/stylesheets/admin/spree_maker_search.css
223
+ - app/assets/stylesheets/store/spree_maker_search.css
224
+ - app/controllers/spree/admin/add_on_makers_controller.rb
225
+ - app/controllers/spree/admin/products_controller_decorator.rb
226
+ - app/controllers/spree/products_controller_decorator.rb
227
+ - app/controllers/spree/taxons_controller_decorator.rb
228
+ - app/helpers/spree/admin/products_helper_decorator.rb
229
+ - app/helpers/spree/taxons_helper_decorator.rb
230
+ - app/models/spree/ability_decorator.rb
231
+ - app/models/spree/add_on_maker.rb
232
+ - app/models/spree/add_on_maker_product.rb
233
+ - app/models/spree/add_on_maker_translation.rb
234
+ - app/models/spree/product_decorator.rb
235
+ - app/models/spree/products/scopes_decorator.rb
236
+ - app/models/spree/taxons_decorator.rb
237
+ - app/overrides/add_add_on_maker_configration_menu_to_add_on_menu.rb
238
+ - app/overrides/add_maker_to_admin_product.rb
239
+ - app/overrides/add_maker_to_front_product.rb
240
+ - app/overrides/add_makers_to_front_navigation.rb
241
+ - app/overrides/add_makers_to_front_taxon_products.rb
242
+ - app/views/spree/admin/add_on_makers/_form.html.erb
243
+ - app/views/spree/admin/add_on_makers/api.json.rabl
244
+ - app/views/spree/admin/add_on_makers/edit.html.erb
245
+ - app/views/spree/admin/add_on_makers/index.html.erb
246
+ - app/views/spree/admin/add_on_makers/new.html.erb
247
+ - bin/rails
248
+ - config/locales/en.yml
249
+ - config/locales/ja.yml
250
+ - config/routes.rb
251
+ - db/migrate/20140410084602_create_spree_maker_search.rb
252
+ - lib/generators/spree_maker_search/install/install_generator.rb
253
+ - lib/spree_maker_search.rb
254
+ - lib/spree_maker_search/engine.rb
255
+ - lib/spree_maker_search/factories.rb
256
+ - spec/spec_helper.rb
257
+ - spree_maker_search.gemspec
213
258
  homepage: http://www.exsight.co.jp
214
259
  licenses: []
215
260
  post_install_message:
@@ -236,4 +281,5 @@ signing_key:
236
281
  specification_version: 3
237
282
  summary: ! 'Spree Extension : Show maker name on detail page , enable filter by maker
238
283
  name list on taxon page , and enable manage makers.'
239
- test_files: []
284
+ test_files:
285
+ - spec/spec_helper.rb