-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OptionTypesController with position update and destroy actions
- Loading branch information
1 parent
a0b8a40
commit a3243ad
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
admin/app/controllers/solidus_admin/option_types_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidusAdmin | ||
class OptionTypesController < SolidusAdmin::BaseController | ||
before_action :load_option_type, only: [:move] | ||
|
||
def move | ||
@option_type.insert_at(params[:position].to_i) | ||
|
||
respond_to do |format| | ||
format.js { head :no_content } | ||
end | ||
end | ||
|
||
def destroy | ||
@option_types = Spree::OptionType.where(id: params[:id]) | ||
|
||
Spree::OptionType.transaction { @option_types.destroy_all } | ||
|
||
flash[:notice] = t('.success') | ||
redirect_back_or_to option_types_path, status: :see_other | ||
end | ||
|
||
private | ||
|
||
def load_option_type | ||
@option_type = Spree::OptionType.find(params[:id]) | ||
authorize! action_name, @option_type | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
en: | ||
solidus_admin: | ||
option_types: | ||
title: "Option Types" | ||
destroy: | ||
success: "Option Types were successfully removed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters