diff options
author | Alessandro Desantis <desa.alessandro@gmail.com> | 2020-06-22 15:52:53 +0200 |
---|---|---|
committer | Alessandro Desantis <desa.alessandro@gmail.com> | 2020-06-22 15:52:53 +0200 |
commit | b16d16150a6060ae51ad8db7f31a8b48310a5468 (patch) | |
tree | 485c96f150b7a4e45676003e4c48de58554e7b6d | |
parent | 242020b39f674e6790375f2825e9074581ec6107 (diff) |
Allow admins to make master variants subcribable
-rw-r--r-- | app/decorators/models/solidus_subscriptions/spree/product/delegate_subscribable.rb | 15 | ||||
-rw-r--r-- | app/overrides/views/admin_subscribable_product_checkbox.rb | 6 | ||||
-rw-r--r-- | app/overrides/views/admin_subscribable_variant_checkbox.rb (renamed from app/overrides/views/admin_subscribable_checkbox.rb) | 2 | ||||
-rw-r--r-- | app/views/spree/admin/products/_subscribable_checkbox.html.erb | 8 |
4 files changed, 30 insertions, 1 deletions
diff --git a/app/decorators/models/solidus_subscriptions/spree/product/delegate_subscribable.rb b/app/decorators/models/solidus_subscriptions/spree/product/delegate_subscribable.rb new file mode 100644 index 0000000..cdabb7f --- /dev/null +++ b/app/decorators/models/solidus_subscriptions/spree/product/delegate_subscribable.rb @@ -0,0 +1,15 @@ +module SolidusSubscriptions + module Spree + module Product + module DelegateSubscribable + def self.prepended(base) + base.class_eval do + delegate :subscribable, :subscribable=, to: :find_or_build_master + end + end + end + end + end +end + +Spree::Product.prepend(SolidusSubscriptions::Spree::Product::DelegateSubscribable) diff --git a/app/overrides/views/admin_subscribable_product_checkbox.rb b/app/overrides/views/admin_subscribable_product_checkbox.rb new file mode 100644 index 0000000..221ed1d --- /dev/null +++ b/app/overrides/views/admin_subscribable_product_checkbox.rb @@ -0,0 +1,6 @@ +Deface::Override.new( + virtual_path: "spree/admin/products/_form", + name: "solidus_subscriptions_product_subscribable_checkbox", + insert_after: "[data-hook='admin_product_form_promotionable']", + partial: "spree/admin/products/subscribable_checkbox" +) diff --git a/app/overrides/views/admin_subscribable_checkbox.rb b/app/overrides/views/admin_subscribable_variant_checkbox.rb index e677023..afd44b7 100644 --- a/app/overrides/views/admin_subscribable_checkbox.rb +++ b/app/overrides/views/admin_subscribable_variant_checkbox.rb @@ -1,6 +1,6 @@ Deface::Override.new( virtual_path: "spree/admin/variants/_form", - name: "solidus_subscriptions_subscribable_checkbox", + name: "solidus_subscriptions_variant_subscribable_checkbox", insert_after: "[data-hook='track_inventory']", partial: "spree/admin/variants/subscribable_checkbox" ) diff --git a/app/views/spree/admin/products/_subscribable_checkbox.html.erb b/app/views/spree/admin/products/_subscribable_checkbox.html.erb new file mode 100644 index 0000000..9e570cf --- /dev/null +++ b/app/views/spree/admin/products/_subscribable_checkbox.html.erb @@ -0,0 +1,8 @@ +<div data-hook="admin_product_form_subscribable"> + <%= f.field_container :subscribable do %> + <label> + <%= f.check_box :subscribable %> + <%= Spree::Product.human_attribute_name(:subscribable) %> + </label> + <% end %> +</div> |