Skip to content
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
37 changes: 21 additions & 16 deletions app/controllers/spree/admin/prototypes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,31 @@

module Spree
module Admin
class PrototypesController < ResourceController
def show
if request.xhr?
render layout: false
else
redirect_to admin_prototypes_path
if defined? ::Spree::Backend
class PrototypesController < ResourceController
def show
if request.xhr?
render layout: false
else
redirect_to admin_prototypes_path
end
end
end

def available
@prototypes = Prototype.order('name asc')
respond_with(@prototypes) do |format|
format.html { render layout: !request.xhr? }
format.js
def available
@prototypes = Prototype.order('name asc')
respond_with(@prototypes) do |format|
format.html { render layout: !request.xhr? }
format.js
end
end
end

def select
@prototype ||= Prototype.find(params[:id])
@prototype_properties = @prototype.properties
def select
@prototype ||= Prototype.find(params[:id])
@prototype_properties = @prototype.properties
end
end
else
class PrototypesController
end
end
end
Expand Down
28 changes: 15 additions & 13 deletions config/initializers/spree.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
Rails.application.config.to_prepare do
Spree::PermittedAttributes.product_attributes << :prototype_id
Spree::Backend::Config.configure do |config|
product_tab = config.menu_items.detect { |menu_item|
menu_item.label == :products
}
if product_tab.respond_to?(:children)
product_tab.children << Spree::BackendConfiguration::MenuItem.new(
condition: -> { can?(:admin, Spree::Prototype) },
url: :admin_prototypes_path,
label: :prototypes,
match_path: '/prototypes'
)
else
product_tab.sections << :prototypes
if defined?(Spree::Backend)
Spree::Backend::Config.configure do |config|
product_tab = config.menu_items.detect { |menu_item|
menu_item.label == :products
}
if product_tab.respond_to?(:children)
product_tab.children << Spree::BackendConfiguration::MenuItem.new(
condition: -> { can?(:admin, Spree::Prototype) },
url: :admin_prototypes_path,
label: :prototypes,
match_path: '/prototypes'
)
else
product_tab.sections << :prototypes
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def load_prototype
@prototype = Spree::Prototype.find(params[resource][:prototype_id])
end

::Spree::Admin::ProductsController.prepend self
::Spree::Admin::ProductsController.prepend self if defined? ::Spree::Admin::ProductsController
end
end
end
7 changes: 5 additions & 2 deletions solidus_prototypes.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.description = "Breaking out prototypes from solidus"
s.license = "BSD-3-Clause"

s.required_ruby_version = [">= 3.0", "< 4"]
s.required_ruby_version = Gem::Requirement.new('>= 3.0')

s.author = "Graeme Nathan"
s.email = "graeme@stembolt.com"
Expand All @@ -34,5 +34,8 @@ Gem::Specification.new do |s|
s.add_dependency "solidus_core", [">= 3.2.0", "< 5"]
s.add_dependency "solidus_support", "~> 0.4"

s.add_development_dependency "solidus_dev_support"
s.add_development_dependency 'rubocop', '~> 1.0'
s.add_development_dependency 'rubocop-performance', '~> 1.5'
s.add_development_dependency 'rubocop-rails', '~> 2.3'
s.add_development_dependency 'rubocop-rspec', '~> 2.0'
end