Class: Spree::Admin::CustomerGroupUsersController
- Inherits:
-
ResourceController
- Object
- BaseController
- BaseController
- ResourceController
- Spree::Admin::CustomerGroupUsersController
- Includes:
- BulkOperationsConcern
- Defined in:
- app/controllers/spree/admin/customer_group_users_controller.rb
Constant Summary
Constants included from LocaleConcern
LocaleConcern::ADMIN_LOCALE_COOKIE
Instance Method Summary collapse
Methods included from BulkOperationsConcern
#bulk_add_tags, #bulk_remove_tags
Methods inherited from ResourceController
belongs_to, #edit, #index, #new, #update
Methods included from TableConcern
#apply_table_sort, #custom_sort_active?, #process_table_query_state, #table, #table_key, #table_registered?
Methods included from BreadcrumbConcern
#add_breadcrumb_icon_instance_var
Instance Method Details
#bulk_create ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/controllers/spree/admin/customer_group_users_controller.rb', line 12 def bulk_create @customer_group.add_customers(bulk_collection.pluck(:id)) @collection = collection flash.now[:success] = Spree.t(:customers_added_to_group, count: bulk_collection.size) end |
#bulk_destroy ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/spree/admin/customer_group_users_controller.rb', line 48 def bulk_destroy user_ids = Array(params[:ids]).reject(&:blank?) if user_ids.empty? flash.now[:error] = Spree.t(:no_users_selected) else deleted_count = @customer_group.remove_customers(user_ids) flash.now[:success] = Spree.t(:customers_removed_from_group, count: deleted_count) end end |
#bulk_new ⇒ Object
8 9 10 |
# File 'app/controllers/spree/admin/customer_group_users_controller.rb', line 8 def bulk_new # Render the drawer form for adding users end |
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/spree/admin/customer_group_users_controller.rb', line 20 def create user_ids = params[:user_ids].to_a.reject(&:blank?) if user_ids.empty? flash[:error] = Spree.t(:no_users_selected) redirect_to spree.admin_customer_group_path(@customer_group) return end added_count = @customer_group.add_customers(user_ids) flash[:success] = Spree.t(:customers_added_to_group, count: added_count) redirect_to spree.admin_customer_group_path(@customer_group) end |
#destroy ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/spree/admin/customer_group_users_controller.rb', line 35 def destroy user = Spree.user_class.find_by_prefix_id!(params[:id]) deleted_count = @customer_group.remove_customers([user.id]) if deleted_count > 0 flash[:success] = Spree.t(:customer_removed_from_group) else flash[:error] = Spree.t(:customer_could_not_be_removed_from_group) end redirect_to spree.admin_customer_group_path(@customer_group) end |