effective_resources 1.0.13 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/effective/crud_controller.rb +15 -2
- data/app/controllers/concerns/effective/crud_controller/actions.rb +7 -6
- data/app/controllers/concerns/effective/crud_controller/respond.rb +17 -27
- data/app/helpers/effective_resources_helper.rb +1 -0
- data/app/views/application/index.html.haml +1 -1
- data/lib/effective_resources/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b28e265ce6c4288365663aa0bfc56adce448a02
|
4
|
+
data.tar.gz: 5ba116394c1a6a8d53c4f582a9a0118e99bfcbf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bad6d3fb3a9d7c0c69babbeea1d9a53d25bd448772ad848b3361f2116a37044f3245634daa67e423c9eed4feb14e92e0c7815c0796c97363609c64acd3eb4cc
|
7
|
+
data.tar.gz: bafc5d5b585e8f1a9bfd02e7333313ad97f9cba5de1843e56aa59e76d58b850dca88f875dbb5ddf23435c2bc013394000bcdacec095f94b911ba21c376bf8f7f
|
@@ -101,8 +101,21 @@ module Effective
|
|
101
101
|
resource_scope.where_values_hash.symbolize_keys
|
102
102
|
end
|
103
103
|
|
104
|
-
def
|
105
|
-
|
104
|
+
def resource_datatable(action)
|
105
|
+
datatable_klass = if action == :index
|
106
|
+
effective_resource.datatable_klass
|
107
|
+
else # Admin::ActionDatatable.new
|
108
|
+
"#{[effective_resource.namespace.to_s.classify.presence, action.to_s.classify].compact.join('::')}Datatable".safe_constantize ||
|
109
|
+
"#{[effective_resource.namespace.to_s.classify.presence, action.to_s.pluralize.classify].compact.join('::')}Datatable".safe_constantize ||
|
110
|
+
"#{[effective_resource.namespace.to_s.classify.presence, action.to_s.singularize.classify].compact.join('::')}Datatable".safe_constantize
|
111
|
+
end
|
112
|
+
|
113
|
+
return unless datatable_klass.present?
|
114
|
+
|
115
|
+
datatable = datatable_klass.new(resource_datatable_attributes)
|
116
|
+
datatable.view = view_context
|
117
|
+
|
118
|
+
datatable
|
106
119
|
end
|
107
120
|
|
108
121
|
def resource_params_method_name
|
@@ -9,11 +9,7 @@ module Effective
|
|
9
9
|
@page_title ||= resource_plural_name.titleize
|
10
10
|
|
11
11
|
self.resources ||= resource_scope.all
|
12
|
-
|
13
|
-
if (datatable = resource_datatable_class).present?
|
14
|
-
@datatable ||= datatable.new(resource_datatable_attributes)
|
15
|
-
@datatable.view = view_context
|
16
|
-
end
|
12
|
+
@datatable = resource_datatable(:index)
|
17
13
|
|
18
14
|
run_callbacks(:resource_render)
|
19
15
|
end
|
@@ -195,7 +191,12 @@ module Effective
|
|
195
191
|
@page_title ||= "#{action.to_s.titleize} #{resource_plural_name.titleize}"
|
196
192
|
|
197
193
|
if request.get?
|
198
|
-
|
194
|
+
@datatable = resource_datatable(action)
|
195
|
+
run_callbacks(:resource_render)
|
196
|
+
|
197
|
+
view = lookup_context.template_exists?(action, _prefixes) ? action : :index
|
198
|
+
render(view, locals: { action: action })
|
199
|
+
return
|
199
200
|
end
|
200
201
|
|
201
202
|
raise "expected all #{resource_name} objects to respond to #{action}!" if resources.to_a.present? && !resources.all? { |resource| resource.respond_to?("#{action}!") }
|
@@ -15,13 +15,13 @@ module Effective
|
|
15
15
|
elsif lookup_context.template_exists?(action, _prefixes)
|
16
16
|
format.html do
|
17
17
|
flash.now[:success] ||= resource_flash(:success, resource, action)
|
18
|
-
# action.html.haml
|
18
|
+
render(action) # action.html.haml
|
19
19
|
end
|
20
20
|
|
21
21
|
format.js do
|
22
22
|
flash.now[:success] ||= resource_flash(:success, resource, action)
|
23
|
-
reload_resource
|
24
|
-
# action.js.erb
|
23
|
+
reload_resource unless action == :destroy
|
24
|
+
render(action) # action.js.erb
|
25
25
|
end
|
26
26
|
else # Default
|
27
27
|
format.html do
|
@@ -42,18 +42,16 @@ module Effective
|
|
42
42
|
|
43
43
|
run_callbacks(:resource_render)
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
# HTML responder
|
46
|
+
case action.to_sym
|
47
|
+
when :create
|
47
48
|
format.html { render :new }
|
48
|
-
when
|
49
|
+
when :update
|
49
50
|
format.html { render :edit }
|
50
|
-
when
|
51
|
-
# We always need to redirect here
|
51
|
+
when :destroy
|
52
52
|
flash[:danger] = flash.now.delete(:danger)
|
53
|
-
|
54
53
|
format.html { redirect_to(resource_redirect_path(action)) }
|
55
|
-
|
56
|
-
else # member_action
|
54
|
+
else # member action
|
57
55
|
format.html do
|
58
56
|
if lookup_context.template_exists?(action, _prefixes)
|
59
57
|
@page_title ||= "#{action.to_s.titleize} #{resource}"
|
@@ -75,24 +73,16 @@ module Effective
|
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
flash.delete(:success)
|
87
|
-
flash[:danger] ||= resource_flash(:danger, resource, action)
|
88
|
-
|
89
|
-
format.html do
|
90
|
-
redirect_to(resource_redirect_path(action))
|
76
|
+
# Javascript responder
|
77
|
+
if action.to_sym == :destroy
|
78
|
+
format.js { redirect_to(resource_redirect_path(action)) }
|
79
|
+
else
|
80
|
+
format.js do
|
81
|
+
view = lookup_context.template_exists?(action, _prefixes) ? action : :member_action
|
82
|
+
render(view, locals: { action: action }) #
|
83
|
+
end
|
91
84
|
end
|
92
85
|
|
93
|
-
format.js do
|
94
|
-
redirect_to(resource_redirect_path(action))
|
95
|
-
end
|
96
86
|
end
|
97
87
|
|
98
88
|
end
|
@@ -3,6 +3,7 @@ module EffectiveResourcesHelper
|
|
3
3
|
# effective_bootstrap
|
4
4
|
def effective_submit(form, options = {}, &block)
|
5
5
|
actions = (controller.respond_to?(:effective_resource) ? controller.class : find_effective_resource).submits
|
6
|
+
actions = actions.select { |k, v| v[:default] != true } if options.delete(:defaults) == false
|
6
7
|
actions = permitted_resource_actions(form.object, actions)
|
7
8
|
|
8
9
|
submits = actions.map { |name, opts| form.save(name, opts.except(:action, :title, 'data-method', 'data-confirm')) }.join.html_safe
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|