ifd_tools 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
|
|
1
|
+
module IfdTools
|
2
|
+
module ActiveAdmin
|
3
|
+
module CanCan
|
4
|
+
module ActionItems
|
5
|
+
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
alias_method :original_add_default_action_items, :add_default_action_items unless method_defined?(:original_add_default_action_items)
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def add_default_action_items
|
14
|
+
add_action_item :except => [:new, :show] do
|
15
|
+
if controller.current_ability.can?(:create, active_admin_config.resource_class_name.constantize)
|
16
|
+
if controller.action_methods.include?('new')
|
17
|
+
link_to(I18n.t('active_admin.new_model', :model => active_admin_config.resource_name), new_resource_path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Edit link on show
|
23
|
+
add_action_item :only => :show do
|
24
|
+
if controller.current_ability.can?(:update, resource)
|
25
|
+
if controller.action_methods.include?('edit')
|
26
|
+
link_to(I18n.t('active_admin.edit_model', :model => active_admin_config.resource_name), edit_resource_path(resource))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Destroy link on show
|
32
|
+
add_action_item :only => :show do
|
33
|
+
if controller.current_ability.can?(:destroy, resource)
|
34
|
+
if controller.action_methods.include?("destroy")
|
35
|
+
link_to(I18n.t('active_admin.delete_model', :model => active_admin_config.resource_name),
|
36
|
+
resource_path(resource),
|
37
|
+
:method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/ifd_tools/engine.rb
CHANGED
@@ -7,10 +7,11 @@ module IfdTools
|
|
7
7
|
end
|
8
8
|
|
9
9
|
initializer "ifd_tools.active_admin" do |app|
|
10
|
-
ActiveAdmin::Event.subscribe ActiveAdmin::Application::BeforeLoadEvent do |app|
|
10
|
+
::ActiveAdmin::Event.subscribe ::ActiveAdmin::Application::BeforeLoadEvent do |app|
|
11
11
|
require 'ifd_tools/tracking/customer_tracking'
|
12
12
|
app.load_paths << File.expand_path( File.dirname(__FILE__) + "../../../app/admin" )
|
13
|
-
|
13
|
+
::ActiveAdmin::Resource.send(:include, IfdTools::ActiveAdmin::CanCan::ActionItems)
|
14
|
+
end
|
14
15
|
end
|
15
16
|
|
16
17
|
end
|
data/lib/ifd_tools/version.rb
CHANGED
data/lib/ifd_tools.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ifd_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -342,6 +342,7 @@ files:
|
|
342
342
|
- lib/generators/ifd_tools/install/templates/views/customers/_form.html.haml
|
343
343
|
- lib/generators/ifd_tools/install/USAGE
|
344
344
|
- lib/ifd_tools/active_admin/base.rb
|
345
|
+
- lib/ifd_tools/active_admin/can_can/action_items.rb
|
345
346
|
- lib/ifd_tools/api_controller/contact_requests.rb
|
346
347
|
- lib/ifd_tools/api_controller/emergency_messages.rb
|
347
348
|
- lib/ifd_tools/api_controller/notifier_updates.rb
|