-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from spree/feature/product-taxon-tabs-extensi…
…bility SP-62 Feature/product taxon tabs extensibility
- Loading branch information
Showing
29 changed files
with
1,214 additions
and
423 deletions.
There are no files selected for viewing
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
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,50 @@ | ||
module Spree | ||
module Admin | ||
module ItemManager | ||
def add(item) | ||
raise KeyError, "Item with key #{item.key} already exists" if index_for_key(item.key) | ||
|
||
@items << item | ||
end | ||
|
||
def child_with_key?(key) | ||
index_for_key(key).present? | ||
end | ||
|
||
def remove(item_key) | ||
item_index = index_for_key!(item_key) | ||
|
||
@items.delete_at(item_index) | ||
end | ||
|
||
def item_for_key(key) | ||
@items.find { |e| e.key == key } | ||
end | ||
|
||
def insert_before(item_key, item_to_add) | ||
item_index = index_for_key!(item_key) | ||
|
||
@items.insert(item_index, item_to_add) | ||
end | ||
|
||
def insert_after(item_key, item_to_add) | ||
item_index = index_for_key!(item_key) | ||
|
||
@items.insert(item_index + 1, item_to_add) | ||
end | ||
|
||
private | ||
|
||
def index_for_key(key) | ||
@items.index { |e| e.key == key } | ||
end | ||
|
||
def index_for_key!(key) | ||
item_index = index_for_key(key) | ||
raise KeyError, "Item not found for key #{key}" unless item_index | ||
|
||
item_index | ||
end | ||
end | ||
end | ||
end |
22 changes: 0 additions & 22 deletions
22
app/models/spree/admin/main_menu/availability_builder_methods.rb
This file was deleted.
Oops, something went wrong.
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
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
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
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
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,30 @@ | ||
module Spree | ||
module Admin | ||
module PermissionChecks | ||
def with_availability_check(availability_check) | ||
@availability_check = availability_check | ||
self | ||
end | ||
|
||
def with_manage_ability_check(*classes) | ||
@availability_check = ->(ability, _current) { classes.any? { |c| ability.can?(:manage, c) } } | ||
self | ||
end | ||
|
||
def with_admin_ability_check(*classes) | ||
@availability_check = ->(ability, _current) { classes.any? { |c| ability.can?(:admin, c) } } | ||
self | ||
end | ||
|
||
def with_index_ability_check(*classes) | ||
@availability_check = ->(ability, _current) { classes.any? { |c| ability.can?(:index, c) } } | ||
self | ||
end | ||
|
||
def with_update_ability_check | ||
@availability_check = ->(ability, resource) { ability.can?(:update, resource) } | ||
self | ||
end | ||
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,17 @@ | ||
module Spree | ||
module Admin | ||
module Tabs | ||
module ConditionalChecker | ||
def with_active_check | ||
@active_check = ->(current_tab, text) { current_tab == text } | ||
self | ||
end | ||
|
||
def with_completed_check | ||
@completed_check = ->(resource) { resource.completed? } | ||
self | ||
end | ||
end | ||
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,12 @@ | ||
module Spree | ||
module Admin | ||
module Tabs | ||
module DataHook | ||
def with_data_hook(data_hook) | ||
@data_hook = data_hook | ||
self | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.