activeadmin_custom_layout 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +54 -59
- data/activeadmin_custom_layout.gemspec +5 -5
- data/bin/.keep +0 -0
- data/lib/activeadmin_custom_layout/engine.rb +7 -2
- data/lib/activeadmin_custom_layout/helpers.rb +26 -0
- data/lib/activeadmin_custom_layout/layout/components/batch_action_selector.rb +44 -0
- data/lib/activeadmin_custom_layout/layout/components/index_list.rb +33 -0
- data/lib/activeadmin_custom_layout/layout/components/scopes.rb +40 -0
- data/lib/activeadmin_custom_layout/layout/components/site_title.rb +17 -0
- data/lib/activeadmin_custom_layout/layout/components/table_for.rb +101 -0
- data/lib/activeadmin_custom_layout/layout/header.rb +29 -0
- data/lib/activeadmin_custom_layout/layout/{base.rb → pages/base.rb} +12 -1
- data/lib/activeadmin_custom_layout/layout/pages/index.rb +72 -0
- data/lib/activeadmin_custom_layout/layout/title_bar.rb +37 -0
- data/lib/activeadmin_custom_layout/version.rb +1 -1
- data/test/dummy/app/admin/admin_user.rb +6 -0
- data/test/dummy/app/views/layouts/application.html.erb +1 -0
- data/test/dummy/config/routes.rb +1 -0
- metadata +39 -4
- data/lib/activeadmin_custom_layout/layout/index.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66db8d86d70872f98b93b795491d9aea88861f33
|
4
|
+
data.tar.gz: f5c20ef1a5de93b4d08a782af64f04ccbdadb601
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af86a26f59228e927662edd314a99b780fb1f2fdbbc6149752a7abf7d703f75a5a450c1f2c71483cf68fb071a5795c1522e83ee141dc056ffa56f10e744b90a4
|
7
|
+
data.tar.gz: 48334248000b55e731d82e60cf4856ab2989fd8bae34c59f8bc528d1782062d02355cc1f6b8309ba4fe7ea88e19467f62d61f20d2671de1e0061faad601a25ef
|
data/Gemfile.lock
CHANGED
@@ -28,75 +28,52 @@ GIT
|
|
28
28
|
railties (>= 3.2, < 5.1)
|
29
29
|
responders
|
30
30
|
|
31
|
-
|
32
|
-
remote:
|
33
|
-
|
34
|
-
|
31
|
+
PATH
|
32
|
+
remote: .
|
33
|
+
specs:
|
34
|
+
activeadmin_custom_layout (0.1.3)
|
35
|
+
activeadmin (>= 1.0.0.pre4)
|
36
|
+
|
37
|
+
GEM
|
38
|
+
remote: https://rubygems.org/
|
35
39
|
specs:
|
36
|
-
actioncable (5.0.
|
37
|
-
actionpack (= 5.0.
|
40
|
+
actioncable (5.0.1)
|
41
|
+
actionpack (= 5.0.1)
|
38
42
|
nio4r (~> 1.2)
|
39
43
|
websocket-driver (~> 0.6.1)
|
40
|
-
actionmailer (5.0.
|
41
|
-
actionpack (= 5.0.
|
42
|
-
actionview (= 5.0.
|
43
|
-
activejob (= 5.0.
|
44
|
+
actionmailer (5.0.1)
|
45
|
+
actionpack (= 5.0.1)
|
46
|
+
actionview (= 5.0.1)
|
47
|
+
activejob (= 5.0.1)
|
44
48
|
mail (~> 2.5, >= 2.5.4)
|
45
49
|
rails-dom-testing (~> 2.0)
|
46
|
-
actionpack (5.0.
|
47
|
-
actionview (= 5.0.
|
48
|
-
activesupport (= 5.0.
|
50
|
+
actionpack (5.0.1)
|
51
|
+
actionview (= 5.0.1)
|
52
|
+
activesupport (= 5.0.1)
|
49
53
|
rack (~> 2.0)
|
50
54
|
rack-test (~> 0.6.3)
|
51
55
|
rails-dom-testing (~> 2.0)
|
52
56
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
53
|
-
actionview (5.0.
|
54
|
-
activesupport (= 5.0.
|
57
|
+
actionview (5.0.1)
|
58
|
+
activesupport (= 5.0.1)
|
55
59
|
builder (~> 3.1)
|
56
60
|
erubis (~> 2.7.0)
|
57
61
|
rails-dom-testing (~> 2.0)
|
58
62
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
59
|
-
activejob (5.0.
|
60
|
-
activesupport (= 5.0.
|
63
|
+
activejob (5.0.1)
|
64
|
+
activesupport (= 5.0.1)
|
61
65
|
globalid (>= 0.3.6)
|
62
|
-
activemodel (5.0.
|
63
|
-
activesupport (= 5.0.
|
64
|
-
activerecord (5.0.
|
65
|
-
activemodel (= 5.0.
|
66
|
-
activesupport (= 5.0.
|
66
|
+
activemodel (5.0.1)
|
67
|
+
activesupport (= 5.0.1)
|
68
|
+
activerecord (5.0.1)
|
69
|
+
activemodel (= 5.0.1)
|
70
|
+
activesupport (= 5.0.1)
|
67
71
|
arel (~> 7.0)
|
68
|
-
activesupport (5.0.
|
72
|
+
activesupport (5.0.1)
|
69
73
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
70
74
|
i18n (~> 0.7)
|
71
75
|
minitest (~> 5.1)
|
72
76
|
tzinfo (~> 1.1)
|
73
|
-
rails (5.0.0.1)
|
74
|
-
actioncable (= 5.0.0.1)
|
75
|
-
actionmailer (= 5.0.0.1)
|
76
|
-
actionpack (= 5.0.0.1)
|
77
|
-
actionview (= 5.0.0.1)
|
78
|
-
activejob (= 5.0.0.1)
|
79
|
-
activemodel (= 5.0.0.1)
|
80
|
-
activerecord (= 5.0.0.1)
|
81
|
-
activesupport (= 5.0.0.1)
|
82
|
-
bundler (>= 1.3.0, < 2.0)
|
83
|
-
railties (= 5.0.0.1)
|
84
|
-
sprockets-rails (>= 2.0.0)
|
85
|
-
railties (5.0.0.1)
|
86
|
-
actionpack (= 5.0.0.1)
|
87
|
-
activesupport (= 5.0.0.1)
|
88
|
-
method_source
|
89
|
-
rake (>= 0.8.7)
|
90
|
-
thor (>= 0.18.1, < 2.0)
|
91
|
-
|
92
|
-
PATH
|
93
|
-
remote: .
|
94
|
-
specs:
|
95
|
-
activeadmin_custom_layout (0.1.1)
|
96
|
-
|
97
|
-
GEM
|
98
|
-
remote: https://rubygems.org/
|
99
|
-
specs:
|
100
77
|
annotate (2.7.1)
|
101
78
|
activerecord (>= 3.2, < 6.0)
|
102
79
|
rake (>= 10.4, < 12.0)
|
@@ -109,7 +86,7 @@ GEM
|
|
109
86
|
bourbon (4.2.7)
|
110
87
|
sass (~> 3.4)
|
111
88
|
thor (~> 0.19)
|
112
|
-
builder (3.2.
|
89
|
+
builder (3.2.3)
|
113
90
|
byebug (9.0.5)
|
114
91
|
coderay (1.1.1)
|
115
92
|
coffee-rails (4.2.1)
|
@@ -160,7 +137,7 @@ GEM
|
|
160
137
|
mime-types-data (~> 3.2015)
|
161
138
|
mime-types-data (3.2016.0521)
|
162
139
|
mini_portile2 (2.1.0)
|
163
|
-
minitest (5.10.
|
140
|
+
minitest (5.10.1)
|
164
141
|
nio4r (1.2.1)
|
165
142
|
nokogiri (1.6.8)
|
166
143
|
mini_portile2 (~> 2.1.0)
|
@@ -182,11 +159,29 @@ GEM
|
|
182
159
|
rack (2.0.1)
|
183
160
|
rack-test (0.6.3)
|
184
161
|
rack (>= 1.0)
|
162
|
+
rails (5.0.1)
|
163
|
+
actioncable (= 5.0.1)
|
164
|
+
actionmailer (= 5.0.1)
|
165
|
+
actionpack (= 5.0.1)
|
166
|
+
actionview (= 5.0.1)
|
167
|
+
activejob (= 5.0.1)
|
168
|
+
activemodel (= 5.0.1)
|
169
|
+
activerecord (= 5.0.1)
|
170
|
+
activesupport (= 5.0.1)
|
171
|
+
bundler (>= 1.3.0, < 2.0)
|
172
|
+
railties (= 5.0.1)
|
173
|
+
sprockets-rails (>= 2.0.0)
|
185
174
|
rails-dom-testing (2.0.1)
|
186
175
|
activesupport (>= 4.2.0, < 6.0)
|
187
176
|
nokogiri (~> 1.6.0)
|
188
177
|
rails-html-sanitizer (1.0.3)
|
189
178
|
loofah (~> 2.0)
|
179
|
+
railties (5.0.1)
|
180
|
+
actionpack (= 5.0.1)
|
181
|
+
activesupport (= 5.0.1)
|
182
|
+
method_source
|
183
|
+
rake (>= 0.8.7)
|
184
|
+
thor (>= 0.18.1, < 2.0)
|
190
185
|
rainbow (2.1.0)
|
191
186
|
rake (11.2.2)
|
192
187
|
ransack (1.8.2)
|
@@ -240,7 +235,7 @@ GEM
|
|
240
235
|
activemodel (>= 5.0)
|
241
236
|
debug_inspector
|
242
237
|
railties (>= 5.0)
|
243
|
-
websocket-driver (0.6.
|
238
|
+
websocket-driver (0.6.5)
|
244
239
|
websocket-extensions (>= 0.1.0)
|
245
240
|
websocket-extensions (0.1.2)
|
246
241
|
|
@@ -252,15 +247,15 @@ DEPENDENCIES
|
|
252
247
|
activeadmin_custom_layout!
|
253
248
|
annotate
|
254
249
|
awesome_print
|
255
|
-
devise (~> 4.2.0)
|
250
|
+
devise (~> 4.2, >= 4.2.0)
|
256
251
|
inherited_resources!
|
257
|
-
listen (~> 3.0.5)
|
258
|
-
pry (~> 0.10.4)
|
259
|
-
pry-byebug (~> 3.4.0)
|
260
|
-
rails
|
252
|
+
listen (~> 3.0, >= 3.0.5)
|
253
|
+
pry (~> 0.10, >= 0.10.4)
|
254
|
+
pry-byebug (~> 3.4, >= 3.4.0)
|
255
|
+
rails (= 5.0.1)
|
261
256
|
rubocop
|
262
257
|
spring
|
263
|
-
spring-watcher-listen (~> 2.0.0)
|
258
|
+
spring-watcher-listen (~> 2.0, >= 2.0.0)
|
264
259
|
sqlite3
|
265
260
|
web-console
|
266
261
|
|
@@ -20,14 +20,14 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency "activeadmin", ">= 1.0.0.pre4"
|
21
21
|
|
22
22
|
s.add_development_dependency "sqlite3"
|
23
|
-
s.add_development_dependency "devise", "~> 4.2.0"
|
24
|
-
s.add_development_dependency "pry", "~> 0.10.4"
|
25
|
-
s.add_development_dependency "pry-byebug", "~> 3.4.0"
|
23
|
+
s.add_development_dependency "devise", "~> 4.2", ">= 4.2.0"
|
24
|
+
s.add_development_dependency "pry", "~> 0.10", ">= 0.10.4"
|
25
|
+
s.add_development_dependency "pry-byebug", "~> 3.4", ">= 3.4.0"
|
26
26
|
|
27
27
|
s.add_development_dependency 'web-console'
|
28
|
-
s.add_development_dependency 'listen', '~> 3.0.5'
|
28
|
+
s.add_development_dependency 'listen', '~> 3.0', '>= 3.0.5'
|
29
29
|
s.add_development_dependency 'spring'
|
30
|
-
s.add_development_dependency 'spring-watcher-listen', '~> 2.0.0'
|
30
|
+
s.add_development_dependency 'spring-watcher-listen', '~> 2.0', '>= 2.0.0'
|
31
31
|
s.add_development_dependency 'rubocop'
|
32
32
|
s.add_development_dependency 'annotate'
|
33
33
|
s.add_development_dependency 'awesome_print'
|
data/bin/.keep
CHANGED
File without changes
|
@@ -1,10 +1,15 @@
|
|
1
1
|
require "activeadmin_custom_layout/helpers"
|
2
2
|
|
3
3
|
# Export layout items as content_for elements
|
4
|
-
require "activeadmin_custom_layout/layout/base"
|
4
|
+
require "activeadmin_custom_layout/layout/pages/base"
|
5
|
+
require "activeadmin_custom_layout/layout/pages/index"
|
5
6
|
require "activeadmin_custom_layout/layout/header"
|
6
|
-
require "activeadmin_custom_layout/layout/index"
|
7
7
|
require "activeadmin_custom_layout/layout/title_bar"
|
8
|
+
require "activeadmin_custom_layout/layout/components/scopes"
|
9
|
+
require "activeadmin_custom_layout/layout/components/site_title"
|
10
|
+
require "activeadmin_custom_layout/layout/components/index_list"
|
11
|
+
require "activeadmin_custom_layout/layout/components/table_for"
|
12
|
+
require "activeadmin_custom_layout/layout/components/batch_action_selector"
|
8
13
|
|
9
14
|
module ActiveadminCustomLayout
|
10
15
|
class Engine < ::Rails::Engine
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
module ViewHelpers
|
3
3
|
module ActiveAdminApplicationHelper
|
4
|
+
attr_accessor :aa_data
|
4
5
|
|
5
6
|
def arbre_content_for( name, &block )
|
6
7
|
if block_given?
|
@@ -12,6 +13,31 @@ module ActiveAdmin
|
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
16
|
+
#
|
17
|
+
# Injects ActiveAdmin data into the WEB page as a javaScript object
|
18
|
+
#
|
19
|
+
#
|
20
|
+
# @return [string]
|
21
|
+
#
|
22
|
+
def active_admin_data_tag
|
23
|
+
"<script type=\"text/javascript\">window.active_admin_data = #{aa_data.to_json}</script>".html_safe
|
24
|
+
end
|
25
|
+
|
26
|
+
def controlller_stylesheet_link_tag
|
27
|
+
stylesheet_link_tag params[:controller] if asset_exist?("#{params[:controller]}.css")
|
28
|
+
end
|
29
|
+
|
30
|
+
def controller_env_stylesheet_link_tag
|
31
|
+
stylesheet_link_tag "#{params[:controller]}-#{Rails.env}" if asset_exist?("#{params[:controller]}-#{Rails.env}.css")
|
32
|
+
end
|
33
|
+
|
34
|
+
def controller_javascript_include_tag
|
35
|
+
javascript_include_tag params[:controller] if asset_exist?("#{params[:controller]}.js")
|
36
|
+
end
|
37
|
+
|
38
|
+
def controller_env_javascript_include_tag
|
39
|
+
javascript_include_tag "#{params[:controller]}-#{Rails.env}" if asset_exist?("#{params[:controller]}-#{Rails.env}.js")
|
40
|
+
end
|
15
41
|
end
|
16
42
|
end
|
17
43
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module BatchActionSelectorPatch
|
2
|
+
|
3
|
+
private
|
4
|
+
|
5
|
+
def build_drop_down
|
6
|
+
return if batch_actions_to_display.empty?
|
7
|
+
aa_data[:batch_actions] ||= []
|
8
|
+
dropdown_menu I18n.t("active_admin.batch_actions.button_label"),
|
9
|
+
class: "batch_actions_selector dropdown_menu",
|
10
|
+
button: { class: "disabled" } do
|
11
|
+
batch_actions_to_display.each do |batch_action|
|
12
|
+
confirmation_text = render_or_call_method_or_proc_on(self, batch_action.confirm)
|
13
|
+
|
14
|
+
options = {
|
15
|
+
:class => "batch_action",
|
16
|
+
"data-action" => batch_action.sym,
|
17
|
+
"data-confirm" => confirmation_text,
|
18
|
+
"data-inputs" => render_in_context(self, batch_action.inputs).to_json
|
19
|
+
}
|
20
|
+
|
21
|
+
default_title = render_or_call_method_or_proc_on(self, batch_action.title)
|
22
|
+
title = I18n.t("active_admin.batch_actions.labels.#{batch_action.sym}", default: default_title)
|
23
|
+
label = I18n.t("active_admin.batch_actions.action_label", title: title)
|
24
|
+
|
25
|
+
item label, "#", options
|
26
|
+
|
27
|
+
aa_data[:batch_actions].push({
|
28
|
+
title: title,
|
29
|
+
label: label,
|
30
|
+
options: options
|
31
|
+
})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
module ActiveAdmin
|
39
|
+
module BatchActions
|
40
|
+
class BatchActionSelector < ActiveAdmin::Component
|
41
|
+
prepend BatchActionSelectorPatch
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module IndexListPatch
|
2
|
+
|
3
|
+
protected
|
4
|
+
|
5
|
+
def build_index_list(index_class)
|
6
|
+
aa_data[:index_list] ||= []
|
7
|
+
url = url_for(as: index_class.index_name.to_sym)
|
8
|
+
name = index_class.index_name
|
9
|
+
i18n_name = I18n.t("active_admin.index_list.#{name}", default: name.to_s.titleize)
|
10
|
+
|
11
|
+
li class: classes_for_index(index_class) do
|
12
|
+
a href: url, class: "table_tools_button" do
|
13
|
+
i18n_name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
aa_data[:index_list] << {
|
18
|
+
name: name,
|
19
|
+
i18n_name: i18n_name,
|
20
|
+
url: url,
|
21
|
+
current: current_index?(index_class)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
module ActiveAdmin
|
28
|
+
module Views
|
29
|
+
class IndexList
|
30
|
+
prepend IndexListPatch
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ScopesPatch
|
2
|
+
|
3
|
+
protected
|
4
|
+
|
5
|
+
def build_scope(scope, options)
|
6
|
+
aa_data[:scopes] ||= []
|
7
|
+
li class: classes_for_scope(scope) do
|
8
|
+
scope_name = I18n.t "active_admin.scopes.#{scope.id}", default: scope.name
|
9
|
+
params = request.query_parameters.except :page, :scope, :commit, :format
|
10
|
+
count = nil
|
11
|
+
url = url_for(scope: scope.id, params: params)
|
12
|
+
if options[:scope_count] && scope.show_count
|
13
|
+
count = get_scope_count(scope)
|
14
|
+
end
|
15
|
+
|
16
|
+
a href: url, class: 'table_tools_button' do
|
17
|
+
text_node scope_name
|
18
|
+
span class: 'count' do
|
19
|
+
"(#{count})"
|
20
|
+
end if options[:scope_count] && scope.show_count
|
21
|
+
end
|
22
|
+
|
23
|
+
aa_data[:scopes].push({
|
24
|
+
name: scope_name,
|
25
|
+
url: url,
|
26
|
+
count: count,
|
27
|
+
current: current_scope?(scope)
|
28
|
+
})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
module ActiveAdmin
|
35
|
+
module Views
|
36
|
+
class Scopes
|
37
|
+
prepend ScopesPatch
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SiteTitlePatch
|
2
|
+
def build(*args)
|
3
|
+
super
|
4
|
+
self.aa_data[:title] = {
|
5
|
+
text: "#{title_text}",
|
6
|
+
image: "#{title_image}"
|
7
|
+
}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ActiveAdmin
|
12
|
+
module Views
|
13
|
+
class SiteTitle
|
14
|
+
prepend SiteTitlePatch
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module TableForPatch
|
2
|
+
|
3
|
+
def column(*args, &block)
|
4
|
+
super
|
5
|
+
|
6
|
+
col = @columns.last
|
7
|
+
|
8
|
+
@collection.each_with_index do |resource, index|
|
9
|
+
data = aa_data[:table][:rows][index][:data] ||= []
|
10
|
+
|
11
|
+
attr = col.data
|
12
|
+
attr = args[1][:sortable] if args[1] and args[1][:sortable].present?
|
13
|
+
|
14
|
+
data << {
|
15
|
+
classes: col.html_class,
|
16
|
+
html: "#{find_last_child(@tbody.children[index].children.last)}",
|
17
|
+
value: "#{find_value_patch(resource, attr)}"
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def find_last_child(elem)
|
23
|
+
if elem.children.length>0
|
24
|
+
find_last_child(elem.children.first)
|
25
|
+
else
|
26
|
+
elem
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_value_patch(resource, attr)
|
31
|
+
if attr.is_a? Proc
|
32
|
+
nil
|
33
|
+
elsif attr =~ /\A(.+)_id\z/ && reflection_for(resource, $1.to_sym)
|
34
|
+
resource.public_send $1
|
35
|
+
elsif resource.respond_to? attr
|
36
|
+
resource.public_send attr
|
37
|
+
elsif resource.respond_to? :[]
|
38
|
+
resource[attr]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def build_table_header(col)
|
45
|
+
aa_data[:table][:header] ||= []
|
46
|
+
|
47
|
+
classes = Arbre::HTML::ClassList.new
|
48
|
+
sort_key = sortable? && col.sortable? && col.sort_key
|
49
|
+
params = request.query_parameters.except :page, :order, :commit, :format
|
50
|
+
url = nil
|
51
|
+
|
52
|
+
classes << 'sortable' if sort_key
|
53
|
+
classes << "sorted-#{current_sort[1]}" if sort_key && current_sort[0] == sort_key
|
54
|
+
classes << col.html_class
|
55
|
+
|
56
|
+
if sort_key
|
57
|
+
th class: classes do
|
58
|
+
url = link_to col.pretty_title, params: params, order: "#{sort_key}_#{order_for_sort_key(sort_key)}"
|
59
|
+
end
|
60
|
+
else
|
61
|
+
th col.pretty_title, class: classes
|
62
|
+
end
|
63
|
+
|
64
|
+
aa_data[:table][:header].push({
|
65
|
+
name: "#{col.pretty_title}",
|
66
|
+
classes: "#{classes}".split(' '),
|
67
|
+
url: url,
|
68
|
+
current_sort: current_sort
|
69
|
+
})
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_table_body
|
73
|
+
aa_data[:table][:rows] ||= []
|
74
|
+
@tbody = tbody do
|
75
|
+
# Build enough rows for our collection
|
76
|
+
@collection.each do |elem|
|
77
|
+
classes = [cycle('odd', 'even')]
|
78
|
+
|
79
|
+
if @row_class
|
80
|
+
classes << @row_class.call(elem)
|
81
|
+
end
|
82
|
+
|
83
|
+
tr(class: classes.flatten.join(' '), id: dom_id_for(elem))
|
84
|
+
aa_data[:table][:rows].push({
|
85
|
+
id: dom_id_for(elem),
|
86
|
+
classes: classes
|
87
|
+
})
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
module ActiveAdmin
|
96
|
+
module Views
|
97
|
+
class TableFor < Arbre::HTML::Table
|
98
|
+
prepend TableForPatch
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -1,4 +1,10 @@
|
|
1
1
|
module HeaderPatch
|
2
|
+
def build(*args)
|
3
|
+
super
|
4
|
+
self.aa_data[:global_navigation] = export_aa_data_menu @menu.items(self)
|
5
|
+
self.aa_data[:utility_navigation] = export_aa_data_menu @utility_menu.items(self)
|
6
|
+
end
|
7
|
+
|
2
8
|
def build_site_title
|
3
9
|
arbre_content_for :site_title do
|
4
10
|
super
|
@@ -16,6 +22,29 @@ module HeaderPatch
|
|
16
22
|
super
|
17
23
|
end
|
18
24
|
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Exports menu data as a hash
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# @return [Hash] Hash containing current menu information
|
31
|
+
#
|
32
|
+
def export_aa_data_menu menu_items
|
33
|
+
menu_data = []
|
34
|
+
if menu_items.presence
|
35
|
+
menu_items.each do |item|
|
36
|
+
menu_data.push({
|
37
|
+
id: item.id,
|
38
|
+
current: item.current?(assigns[:current_tab]),
|
39
|
+
url: item.url(self),
|
40
|
+
label: item.label(self),
|
41
|
+
html_options: item.html_options,
|
42
|
+
children: export_aa_data_menu(item.items(self))
|
43
|
+
})
|
44
|
+
end
|
45
|
+
end
|
46
|
+
menu_data
|
47
|
+
end
|
19
48
|
end
|
20
49
|
|
21
50
|
module ActiveAdmin
|
@@ -1,5 +1,14 @@
|
|
1
1
|
module BasePatch
|
2
2
|
|
3
|
+
def build
|
4
|
+
self.aa_data = {
|
5
|
+
action: params[:action],
|
6
|
+
controller: params[:controller].tr('/', '_'),
|
7
|
+
url: request.path
|
8
|
+
}
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
3
12
|
def add_classes_to_body
|
4
13
|
super
|
5
14
|
content_for :body_classes do
|
@@ -27,7 +36,8 @@ module BasePatch
|
|
27
36
|
|
28
37
|
if active_admin_namespace.favicon
|
29
38
|
arbre_content_for :favicon do
|
30
|
-
|
39
|
+
t
|
40
|
+
ext_node(favicon_link_tag(active_admin_namespace.favicon))
|
31
41
|
end
|
32
42
|
end
|
33
43
|
|
@@ -76,6 +86,7 @@ module BasePatch
|
|
76
86
|
super
|
77
87
|
end
|
78
88
|
end
|
89
|
+
|
79
90
|
end
|
80
91
|
|
81
92
|
module ActiveAdmin
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module IndexPatch
|
2
|
+
def build_table_tools
|
3
|
+
arbre_content_for :index_table_tools do
|
4
|
+
super
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def build_batch_actions_selector
|
9
|
+
arbre_content_for :index_batch_actions do
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_scopes
|
15
|
+
arbre_content_for :index_scopes do
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_index_list
|
21
|
+
arbre_content_for :index_index_list do
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_collection
|
27
|
+
arbre_content_for :index_collection do
|
28
|
+
super
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def render_index
|
33
|
+
renderer_class = find_index_renderer_class(config[:as])
|
34
|
+
entry_name = active_admin_config.resource_label
|
35
|
+
entries_name = active_admin_config.plural_resource_label(count: collection_size)
|
36
|
+
paginator = config.fetch(:paginator, true)
|
37
|
+
download_links = config.fetch(:download_links, active_admin_config.namespace.download_links)
|
38
|
+
pagination_total = config.fetch(:pagination_total, true)
|
39
|
+
per_page = config.fetch(:per_page, active_admin_config.per_page)
|
40
|
+
|
41
|
+
aa_data[:table] = {
|
42
|
+
entry_name: entry_name,
|
43
|
+
entries_name: entries_name,
|
44
|
+
download_links: download_links,
|
45
|
+
paginator: paginator,
|
46
|
+
per_page: per_page,
|
47
|
+
pagination_total: pagination_total
|
48
|
+
}
|
49
|
+
|
50
|
+
paginated_collection(collection, entry_name: entry_name,
|
51
|
+
entries_name: entries_name,
|
52
|
+
download_links: download_links,
|
53
|
+
paginator: paginator,
|
54
|
+
per_page: per_page,
|
55
|
+
pagination_total: pagination_total) do
|
56
|
+
div class: 'index_content' do
|
57
|
+
insert_tag(renderer_class, config, collection)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
module ActiveAdmin
|
65
|
+
module Views
|
66
|
+
module Pages
|
67
|
+
class Index
|
68
|
+
prepend IndexPatch
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -1,4 +1,9 @@
|
|
1
1
|
module TitleBarPatch
|
2
|
+
def build(*args)
|
3
|
+
super
|
4
|
+
self.aa_data[:action_items] = export_aa_data_actions
|
5
|
+
self.aa_data[:breadcrumbs] = export_aa_data_breadcrumbs
|
6
|
+
end
|
2
7
|
|
3
8
|
def build_titlebar_right
|
4
9
|
arbre_content_for :titlebar_right do
|
@@ -24,6 +29,38 @@ module TitleBarPatch
|
|
24
29
|
end
|
25
30
|
end
|
26
31
|
|
32
|
+
def export_aa_data_actions
|
33
|
+
action_data = []
|
34
|
+
|
35
|
+
@action_items.each do |action_item|
|
36
|
+
action_data.push({
|
37
|
+
name: action_item.name,
|
38
|
+
action: instance_exec(&action_item.block)
|
39
|
+
})
|
40
|
+
end
|
41
|
+
|
42
|
+
action_data
|
43
|
+
end
|
44
|
+
|
45
|
+
def export_aa_data_breadcrumbs
|
46
|
+
breadcrumb_data = []
|
47
|
+
breadcrumb_config = active_admin_config && active_admin_config.breadcrumb
|
48
|
+
|
49
|
+
links = if breadcrumb_config.is_a?(Proc)
|
50
|
+
instance_exec(controller, &active_admin_config.breadcrumb)
|
51
|
+
elsif breadcrumb_config.present?
|
52
|
+
breadcrumb_links
|
53
|
+
end
|
54
|
+
if links.present? && links.is_a?(::Array)
|
55
|
+
links.each do |url|
|
56
|
+
breadcrumb_data.push({
|
57
|
+
url: "#{url}"
|
58
|
+
})
|
59
|
+
end
|
60
|
+
end
|
61
|
+
breadcrumb_data
|
62
|
+
end
|
63
|
+
|
27
64
|
end
|
28
65
|
|
29
66
|
module ActiveAdmin
|
@@ -1,10 +1,16 @@
|
|
1
1
|
ActiveAdmin.register AdminUser do
|
2
2
|
permit_params :email, :password, :password_confirmation
|
3
3
|
|
4
|
+
scope :all
|
5
|
+
|
4
6
|
controller do
|
5
7
|
layout 'application'
|
6
8
|
end
|
7
9
|
|
10
|
+
index as: :grid do |context|
|
11
|
+
h1 "Grid"
|
12
|
+
end
|
13
|
+
|
8
14
|
index do
|
9
15
|
selectable_column
|
10
16
|
id_column
|
data/test/dummy/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_custom_layout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ByS Sistemas de Control
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -43,6 +43,9 @@ dependencies:
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.2'
|
48
|
+
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
50
|
version: 4.2.0
|
48
51
|
type: :development
|
@@ -50,6 +53,9 @@ dependencies:
|
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '4.2'
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: 4.2.0
|
55
61
|
- !ruby/object:Gem::Dependency
|
@@ -57,6 +63,9 @@ dependencies:
|
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.10'
|
68
|
+
- - ">="
|
60
69
|
- !ruby/object:Gem::Version
|
61
70
|
version: 0.10.4
|
62
71
|
type: :development
|
@@ -64,6 +73,9 @@ dependencies:
|
|
64
73
|
version_requirements: !ruby/object:Gem::Requirement
|
65
74
|
requirements:
|
66
75
|
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.10'
|
78
|
+
- - ">="
|
67
79
|
- !ruby/object:Gem::Version
|
68
80
|
version: 0.10.4
|
69
81
|
- !ruby/object:Gem::Dependency
|
@@ -71,6 +83,9 @@ dependencies:
|
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
72
84
|
requirements:
|
73
85
|
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '3.4'
|
88
|
+
- - ">="
|
74
89
|
- !ruby/object:Gem::Version
|
75
90
|
version: 3.4.0
|
76
91
|
type: :development
|
@@ -78,6 +93,9 @@ dependencies:
|
|
78
93
|
version_requirements: !ruby/object:Gem::Requirement
|
79
94
|
requirements:
|
80
95
|
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.4'
|
98
|
+
- - ">="
|
81
99
|
- !ruby/object:Gem::Version
|
82
100
|
version: 3.4.0
|
83
101
|
- !ruby/object:Gem::Dependency
|
@@ -99,6 +117,9 @@ dependencies:
|
|
99
117
|
requirement: !ruby/object:Gem::Requirement
|
100
118
|
requirements:
|
101
119
|
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '3.0'
|
122
|
+
- - ">="
|
102
123
|
- !ruby/object:Gem::Version
|
103
124
|
version: 3.0.5
|
104
125
|
type: :development
|
@@ -106,6 +127,9 @@ dependencies:
|
|
106
127
|
version_requirements: !ruby/object:Gem::Requirement
|
107
128
|
requirements:
|
108
129
|
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.0'
|
132
|
+
- - ">="
|
109
133
|
- !ruby/object:Gem::Version
|
110
134
|
version: 3.0.5
|
111
135
|
- !ruby/object:Gem::Dependency
|
@@ -127,6 +151,9 @@ dependencies:
|
|
127
151
|
requirement: !ruby/object:Gem::Requirement
|
128
152
|
requirements:
|
129
153
|
- - "~>"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '2.0'
|
156
|
+
- - ">="
|
130
157
|
- !ruby/object:Gem::Version
|
131
158
|
version: 2.0.0
|
132
159
|
type: :development
|
@@ -134,6 +161,9 @@ dependencies:
|
|
134
161
|
version_requirements: !ruby/object:Gem::Requirement
|
135
162
|
requirements:
|
136
163
|
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '2.0'
|
166
|
+
- - ">="
|
137
167
|
- !ruby/object:Gem::Version
|
138
168
|
version: 2.0.0
|
139
169
|
- !ruby/object:Gem::Dependency
|
@@ -210,9 +240,14 @@ files:
|
|
210
240
|
- lib/activeadmin_custom_layout.rb
|
211
241
|
- lib/activeadmin_custom_layout/engine.rb
|
212
242
|
- lib/activeadmin_custom_layout/helpers.rb
|
213
|
-
- lib/activeadmin_custom_layout/layout/
|
243
|
+
- lib/activeadmin_custom_layout/layout/components/batch_action_selector.rb
|
244
|
+
- lib/activeadmin_custom_layout/layout/components/index_list.rb
|
245
|
+
- lib/activeadmin_custom_layout/layout/components/scopes.rb
|
246
|
+
- lib/activeadmin_custom_layout/layout/components/site_title.rb
|
247
|
+
- lib/activeadmin_custom_layout/layout/components/table_for.rb
|
214
248
|
- lib/activeadmin_custom_layout/layout/header.rb
|
215
|
-
- lib/activeadmin_custom_layout/layout/
|
249
|
+
- lib/activeadmin_custom_layout/layout/pages/base.rb
|
250
|
+
- lib/activeadmin_custom_layout/layout/pages/index.rb
|
216
251
|
- lib/activeadmin_custom_layout/layout/title_bar.rb
|
217
252
|
- lib/activeadmin_custom_layout/version.rb
|
218
253
|
- lib/tasks/activeadmin_custom_layout_tasks.rake
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module IndexPatch
|
2
|
-
|
3
|
-
def build_table_tools
|
4
|
-
arbre_content_for :index_table_tools do
|
5
|
-
super
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def build_batch_actions_selector
|
10
|
-
arbre_content_for :index_batch_actions do
|
11
|
-
super
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def build_scopes
|
16
|
-
arbre_content_for :index_scopes do
|
17
|
-
super
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def build_index_list
|
22
|
-
arbre_content_for :index_index_list do
|
23
|
-
super
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def build_collection
|
28
|
-
arbre_content_for :index_collection do
|
29
|
-
super
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
module ActiveAdmin
|
36
|
-
module Views
|
37
|
-
module Pages
|
38
|
-
class Index
|
39
|
-
prepend IndexPatch
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|