ab_admin 0.6.0 → 0.6.1
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/ab_admin/components/croppable_image.js.coffee +6 -5
- data/app/assets/javascripts/ab_admin/components/select2_bridge.js.coffee +8 -1
- data/app/assets/stylesheets/ab_admin/components/_table_view.scss +45 -1
- data/app/controllers/admin/base_controller.rb +12 -5
- data/app/views/admin/base/edit.js.erb +1 -1
- data/app/views/admin/manager/_form.html.slim +2 -2
- data/app/views/admin/manager/_show_table.html.slim +1 -1
- data/app/views/admin/manager/_table.html.slim +3 -3
- data/app/views/admin/shared/_content_actions.html.slim +1 -1
- data/app/views/admin/shared/_locale_tabs.html.slim +1 -1
- data/app/views/admin/users/_table.html.slim +7 -8
- data/app/views/layouts/admin/application.html.slim +1 -1
- data/lib/ab_admin.rb +2 -0
- data/lib/ab_admin/concerns/utilities.rb +7 -2
- data/lib/ab_admin/engine.rb +1 -0
- data/lib/ab_admin/models/user.rb +1 -1
- data/lib/ab_admin/version.rb +1 -1
- data/lib/ab_admin/views/admin_navigation_helpers.rb +11 -0
- data/lib/ab_admin/views/search_form_builder.rb +5 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07cf0aa2ce7c13f970015d489ec04b5d6bbb3e99
|
4
|
+
data.tar.gz: 568de144f99ceb62940e015ee41379ce70d76002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cb44209d391674ea609b3a3b154d1103f3bbcf56aed44f3f13a6f5a06a176f2189c17ad4fd65f7a9bf5325e542c9d6c2794b7411b11cf769dda97fd0fc0f5d1
|
7
|
+
data.tar.gz: 426d9d87810a841b6b04b2429d26ba548aae20e8f5e59f38224707d54c57affadf38d1533d5d307b96ac58b72f85e4fc90140cf756a718a202acafc235fda562
|
@@ -10,8 +10,9 @@ class window.CroppableImage
|
|
10
10
|
_.defaults(@options, CroppableImage.crop_defaults)
|
11
11
|
@options.onSelect = @setCropData
|
12
12
|
@options.onChange = @setCropData
|
13
|
-
|
14
|
-
$
|
13
|
+
$img = $('.fancybox-image:first')
|
14
|
+
@options.trueSize = [$img[0].naturalWidth, $img[0].naturalHeight]
|
15
|
+
$img.Jcrop @options
|
15
16
|
$('.fancybox-nav').hide()
|
16
17
|
|
17
18
|
$cont = $('.fancybox-outer:first')
|
@@ -24,9 +25,9 @@ class window.CroppableImage
|
|
24
25
|
|
25
26
|
cropHandler: (e) =>
|
26
27
|
e.preventDefault()
|
27
|
-
asset_id = to_i($('.fancybox-image:first').attr('src').match(/\/[\d\/]{
|
28
|
-
$asset = $("#asset_#{asset_id}")
|
28
|
+
asset_id = to_i($('.fancybox-image:first').attr('src').match(/\/[\d\/]{1,}\//)[0].replace(/\//g, ''))
|
29
|
+
$asset = $(@options.asset_selector || "#asset_#{asset_id}")
|
29
30
|
geometry = [@cropData['w'], @cropData['h'], @cropData['x'], @cropData['y']].join(',')
|
30
|
-
$.post "/admin/assets/#{
|
31
|
+
$.post "/admin/assets/#{asset_id}/crop", {geometry: geometry}, (data) =>
|
31
32
|
$asset.replaceWith @el.data('assets').template(data.asset)
|
32
33
|
$.fancybox.close()
|
@@ -168,5 +168,12 @@ class window.Select2Bridge
|
|
168
168
|
value = @el.closest(selectors[1] || 'html').find(selectors[0]).val()
|
169
169
|
cond[kind_key][attr] = value if value
|
170
170
|
|
171
|
-
data =
|
171
|
+
data =
|
172
|
+
q: term
|
173
|
+
class: @el.data('class')
|
174
|
+
token: true
|
175
|
+
page: page,
|
176
|
+
order: @el.data('order')
|
177
|
+
sort_mode: @el.data('sortMode')
|
178
|
+
|
172
179
|
_.extend(data, cond)
|
@@ -84,8 +84,52 @@ table.index_table {
|
|
84
84
|
form.simple_form {
|
85
85
|
margin: 0;
|
86
86
|
}
|
87
|
+
|
88
|
+
.actions_panel {
|
89
|
+
width: 0px !important;
|
90
|
+
vertical-align: bottom !important;
|
91
|
+
padding: 0;
|
92
|
+
margin: 0;
|
93
|
+
border: none;
|
94
|
+
.actions_panel-wrap_outer {
|
95
|
+
position: relative;
|
96
|
+
top: 0px;
|
97
|
+
bottom: 0px;
|
98
|
+
height: 100%;
|
99
|
+
padding: 0 0 20px 0
|
100
|
+
}
|
101
|
+
|
102
|
+
.actions_panel-wrap_inner {
|
103
|
+
display: none;
|
104
|
+
position: absolute;
|
105
|
+
left: 100px;
|
106
|
+
width: auto;
|
107
|
+
height: 20px;
|
108
|
+
margin-top: 20px;
|
109
|
+
padding: 5px 12px;
|
110
|
+
background: #f6f6f6;
|
111
|
+
border-radius: 0 0 10px 10px;
|
112
|
+
box-shadow: 0 3px 5px #bbb;
|
113
|
+
border: #ccc 1px solid;
|
114
|
+
border-top: none;
|
115
|
+
z-index: 10;
|
116
|
+
text-align: center;
|
117
|
+
white-space: nowrap;
|
118
|
+
> * {
|
119
|
+
margin-top: -10px;
|
120
|
+
}
|
121
|
+
.hide_pane {
|
122
|
+
display: none;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
tr:hover > td > .actions_panel-wrap_outer > .actions_panel-wrap_inner {
|
128
|
+
display: block;
|
129
|
+
}
|
87
130
|
}
|
88
131
|
|
89
132
|
#batch_action_form {
|
90
133
|
margin-bottom: 10px;
|
91
|
-
}
|
134
|
+
}
|
135
|
+
|
@@ -93,7 +93,13 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
93
93
|
raise 'No ids specified for batch action' unless params[:by_ids].present?
|
94
94
|
batch_action = params[:batch_action].to_sym
|
95
95
|
if allow_batch_action?(batch_action) && collection.all?{|item| can?(batch_action, item) }
|
96
|
-
|
96
|
+
if batch_action.to_s.end_with?('_collection')
|
97
|
+
count = collection.size
|
98
|
+
resource_class.public_send(batch_action, collection)
|
99
|
+
collection.each { |item| track_action!("batch_#{batch_action}", item) } if settings[:history]
|
100
|
+
else
|
101
|
+
count = collection.inject(0) { |c, item| apply_batch_action(item, batch_action) ? c + 1 : c }
|
102
|
+
end
|
97
103
|
batch_action_name = I18n.t("admin.actions.batch_#{batch_action}.title", default: batch_action.to_s.humanize)
|
98
104
|
flash[:success] = I18n.t('admin.batch_actions.status', count: count, action: batch_action_name)
|
99
105
|
else
|
@@ -247,7 +253,8 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
247
253
|
|
248
254
|
def search_collection
|
249
255
|
params[:q] ||= {}
|
250
|
-
|
256
|
+
nested = resource_class.respond_to?(:acts_as_nested_set_options) && current_index_view == 'tree'
|
257
|
+
params[:q][:s] ||= settings[:default_order] || ('id desc' unless nested)
|
251
258
|
@search = end_of_association_chain.accessible_by(current_ability).admin.ransack(params[:q].no_blank)
|
252
259
|
@search.result(distinct: @search.object.joins_values.present?)
|
253
260
|
end
|
@@ -363,11 +370,11 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
363
370
|
end
|
364
371
|
|
365
372
|
def bind_current_user(*args)
|
366
|
-
resource.user_id = current_user.id if resource.respond_to?(:user_id)
|
373
|
+
resource.user_id = current_user.id if !settings[:skip_bind_current_user] && resource.respond_to?(:user_id)
|
367
374
|
end
|
368
375
|
|
369
376
|
def bind_current_updater(*args)
|
370
|
-
resource.updater_id = current_user.id if resource.respond_to?(:updater_id)
|
377
|
+
resource.updater_id = current_user.id if !settings[:skip_bind_current_updater] && resource.respond_to?(:updater_id)
|
371
378
|
end
|
372
379
|
|
373
380
|
# roles logic
|
@@ -413,4 +420,4 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
413
420
|
{root: false}
|
414
421
|
end
|
415
422
|
end
|
416
|
-
end
|
423
|
+
end
|
@@ -10,7 +10,7 @@
|
|
10
10
|
%>
|
11
11
|
$('#<%= form_wrap_id %>').remove();
|
12
12
|
$('#<%= el_id %>').after('<%= j html %>');
|
13
|
-
$('#<%= form_wrap_id %> td:first').attr('colspan', $('
|
13
|
+
$('#<%= form_wrap_id %> td:first').attr('colspan', $('#<%= form_wrap_id %>').prev('tr').find('> td').length);
|
14
14
|
$('#<%= form_wrap_id %> form').trigger('admin:form_init');
|
15
15
|
$('#<%= el_id %>').scrollToEl();
|
16
16
|
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
- if tmpl = admin_partial_name(form_builder)
|
2
|
-
= render tmpl
|
2
|
+
= render partial: tmpl, locals: local_assigns
|
3
3
|
- else
|
4
4
|
= admin_form_for resource do |f|
|
5
5
|
- form_builder.fields.each do |node|
|
@@ -39,4 +39,4 @@
|
|
39
39
|
- resource.tracks.recently.each do |a|
|
40
40
|
tr
|
41
41
|
td= l(a.created_at, format: :short)
|
42
|
-
td= auto_show_link a.user
|
42
|
+
td= auto_show_link a.user
|
@@ -1,11 +1,12 @@
|
|
1
1
|
- if tmpl = admin_partial_name(table_builder)
|
2
|
-
= render tmpl
|
2
|
+
= render partial: tmpl, locals: local_assigns
|
3
3
|
- else
|
4
4
|
table.table.table-striped.index_table#list
|
5
5
|
thead
|
6
6
|
tr.pjax_links
|
7
7
|
= batch_action_toggle
|
8
8
|
th= list_sort_link(:id)
|
9
|
+
th.actions_panel
|
9
10
|
- table_builder.fields.each do |field|
|
10
11
|
th class=('hide_cell' if field.options[:hidden])
|
11
12
|
- if field.options[:sortable] && !field.options[:image]
|
@@ -16,13 +17,13 @@
|
|
16
17
|
= list_sort_link field.name, opts
|
17
18
|
- else
|
18
19
|
= field.name.is_a?(Symbol) ? ha(field.name) : field.name
|
19
|
-
th= t 'admin.table.actions'
|
20
20
|
tbody
|
21
21
|
- is_edit_link = manager.actions.include?(:edit)
|
22
22
|
- collection.each do |item|
|
23
23
|
tr id=dom_id(item, 'list') class=(table_builder.options[:row_class].call(item) if table_builder.options[:row_class])
|
24
24
|
= batch_action_item(item)
|
25
25
|
td= id_link(item, edit: is_edit_link)
|
26
|
+
= item_index_actions_panel(item)
|
26
27
|
- table_builder.fields.each do |field|
|
27
28
|
td
|
28
29
|
- if field.options[:editable] && field.data.is_a?(Symbol)
|
@@ -31,4 +32,3 @@
|
|
31
32
|
= item_image_link(item, assoc: field.name)
|
32
33
|
- else
|
33
34
|
= admin_pretty_data call_method_or_proc_on(item, field.data)
|
34
|
-
td.actions= item_index_actions(item)
|
@@ -12,7 +12,7 @@
|
|
12
12
|
.btn-group.pjax_links
|
13
13
|
- button_scopes.each do |name, opts|
|
14
14
|
- active = params[opts[:as]]
|
15
|
-
a.btn href=url_for(opts[:as] => (active ? nil : 1)) class=('active' if active) = t "admin.scopes.#{name}"
|
15
|
+
a.btn href=url_for(opts[:as] => (active ? nil : 1)) class=('active' if active) = t "admin.scopes.#{name}", default: name
|
16
16
|
|
17
17
|
a.btn.pull-left#columns_hider_show href="#columns_hider" data-toggle='modal' = t 'admin.columns_hider.button'
|
18
18
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
ul.nav.nav-tabs
|
3
3
|
- Globalize.available_locales.each_with_index do |l, i|
|
4
4
|
li class=('active' if i.zero?)
|
5
|
-
a data-toggle="tab" href="##{l}" class="ico_#{l}" = t("admin.langs.#{l}")
|
5
|
+
a data-toggle="tab" href="##{l}" class="ico_#{l}" = t("admin.langs.#{l}", default: l.to_s)
|
6
6
|
.tab-content
|
7
7
|
- Globalize.available_locales.each_with_index do |l, i|
|
8
8
|
.tab-pane id=l class="tab_#{l} #{'active' if i.zero?}" = loc_html[l]
|
@@ -3,6 +3,7 @@ table.table.table-striped.index_table#list
|
|
3
3
|
tr.pjax_links
|
4
4
|
= batch_action_toggle
|
5
5
|
th= list_sort_link(:id)
|
6
|
+
th.actions_panel
|
6
7
|
th= list_sort_link(:email)
|
7
8
|
th= ha :avatar
|
8
9
|
th= list_sort_link(:user_role_id)
|
@@ -11,12 +12,16 @@ table.table.table-striped.index_table#list
|
|
11
12
|
th= list_sort_link(:phone)
|
12
13
|
th= list_sort_link(:skype)
|
13
14
|
th= list_sort_link(:created_at)
|
14
|
-
th=t 'admin.table.actions'
|
15
15
|
tbody
|
16
16
|
- collection.each do |item|
|
17
17
|
tr
|
18
18
|
= batch_action_item(item)
|
19
19
|
td= id_link(item)
|
20
|
+
= item_index_actions_panel(item) do
|
21
|
+
- if item.active?
|
22
|
+
= link_to t('admin.actions.suspend.link'), suspend_admin_user_path(item), method: :post, class: 'btn btn-warning'
|
23
|
+
- else
|
24
|
+
= link_to icon('ok', true), activate_admin_user_path(item), method: :post, class: 'btn btn-success', title: t('admin.actions.activate.link')
|
20
25
|
td= mail_to item.email
|
21
26
|
td= item_image_link(item, assoc: :avatar)
|
22
27
|
td= item.user_role_type.try(:title)
|
@@ -24,10 +29,4 @@ table.table.table-striped.index_table#list
|
|
24
29
|
td= item.last_name
|
25
30
|
td= item.phone
|
26
31
|
td= skype_link item.skype
|
27
|
-
td= pretty_data item.created_at
|
28
|
-
td.actions
|
29
|
-
= item_index_actions(item)
|
30
|
-
- if item.active?
|
31
|
-
= link_to t('admin.actions.suspend.link'), suspend_admin_user_path(item), method: :post, class: 'btn btn-warning'
|
32
|
-
- else
|
33
|
-
= link_to icon('ok', true), activate_admin_user_path(item), method: :post, class: 'btn btn-success', title: t('admin.actions.activate.link')
|
32
|
+
td= pretty_data item.created_at
|
@@ -9,7 +9,7 @@ html id="controller_#{controller_name}"
|
|
9
9
|
= javascript_include_tag 'ab_admin/application'
|
10
10
|
= csrf_meta_tags
|
11
11
|
= yield(:head)
|
12
|
-
body id="action_#{action_name}" class="resource_#{resource_collection_name}"
|
12
|
+
body id="action_#{action_name}" class="resource_#{resource_collection_name} #{AbAdmin.body_css_class}"
|
13
13
|
#wrap
|
14
14
|
= render 'layouts/admin/navigation'
|
15
15
|
#main role="main"
|
data/lib/ab_admin.rb
CHANGED
@@ -68,12 +68,17 @@ module AbAdmin
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
add_cond << "#{assoc.klass.quoted_table_name}.#{assoc.type} = '#{name}'" if assoc.type
|
71
|
-
add_cond
|
71
|
+
add_cond << assoc.klass.instance_exec(&assoc.scope).to_sql[/WHERE(.*?)(?:(?:ORDER|LIMIT).*)?$/, 1] if assoc.scope
|
72
|
+
if assoc.klass.default_scopes.present?
|
73
|
+
assoc.klass.default_scopes.each do |scope|
|
74
|
+
add_cond << scope.call.to_sql[/WHERE(.*?)(?:(?:ORDER|LIMIT).*)?$/, 1]
|
75
|
+
end
|
76
|
+
end
|
72
77
|
count_klass = assoc_count.klass
|
73
78
|
query = <<-SQL
|
74
79
|
UPDATE #{quoted_table_name} SET #{col} = (SELECT COUNT(#{count_klass.quoted_table_name}.id)
|
75
80
|
FROM #{count_klass.quoted_table_name} #{add_from}
|
76
|
-
WHERE #{quoted_table_name}.id = #{count_klass.quoted_table_name}.#{assoc_count.foreign_key} AND #{add_cond.join(' AND ')})
|
81
|
+
WHERE #{quoted_table_name}.id = #{count_klass.quoted_table_name}.#{assoc_count.foreign_key} AND #{add_cond.reject(&:blank?).join(' AND ')})
|
77
82
|
SQL
|
78
83
|
connection.execute(query)
|
79
84
|
end
|
data/lib/ab_admin/engine.rb
CHANGED
@@ -18,6 +18,7 @@ module AbAdmin
|
|
18
18
|
ActiveRecord::Base.send :extend, AbAdmin::Concerns::Silencer
|
19
19
|
ActiveRecord::Base.send :include, AbAdmin::Concerns::Validations
|
20
20
|
ActiveRecord::Base.send :include, AbAdmin::Concerns::Fileuploads
|
21
|
+
ActiveRecord::Base.send :extend, EnumField::EnumeratedAttribute
|
21
22
|
end
|
22
23
|
|
23
24
|
ActiveSupport.on_load :action_mailer do
|
data/lib/ab_admin/models/user.rb
CHANGED
data/lib/ab_admin/version.rb
CHANGED
@@ -158,6 +158,17 @@ module AbAdmin
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
+
def item_index_actions_panel(item)
|
162
|
+
content = "#{item_index_actions(item)}#{capture{yield item} if block_given?}"
|
163
|
+
<<-HTML.html_safe
|
164
|
+
<td class="actions_panel">
|
165
|
+
<div class="actions_panel-wrap_outer">
|
166
|
+
<div class="actions_panel-wrap_inner">#{content}</div>
|
167
|
+
</div>
|
168
|
+
</td>
|
169
|
+
HTML
|
170
|
+
end
|
171
|
+
|
161
172
|
def item_index_actions(item)
|
162
173
|
actions = resource_action_items.map do |act|
|
163
174
|
short_action_link(act, item)
|
@@ -72,7 +72,7 @@ module AbAdmin
|
|
72
72
|
opts = [['=', 'eq'], ['>', 'gt'], ['<', 'lt']].map { |m| [m[0], "#{attr}_#{m[1]}"] }
|
73
73
|
current_filter = (opts.detect { |m| params[:q][m[1]].present? } || opts.first)[1]
|
74
74
|
select_tag('', options_for_select(opts, current_filter), class: 'input-small predicate-select') +
|
75
|
-
text_field_tag("q[#{current_filter}]", params[:q][current_filter], class: 'input-small')
|
75
|
+
text_field_tag("q[#{current_filter}]", params[:q][current_filter], class: 'input-small', type: :number)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -89,11 +89,11 @@ module AbAdmin
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def presence_field(attr, options={})
|
92
|
-
yes_no_field(attr, {yes: %w(present 1), no: %w(present 0)}
|
92
|
+
yes_no_field(attr, options.merge(predicates: {yes: %w(present 1), no: %w(present 0)}))
|
93
93
|
end
|
94
94
|
|
95
95
|
def null_field(attr, options={})
|
96
|
-
yes_no_field(attr, {yes: %w(null 0), no: %w(null 1)}
|
96
|
+
yes_no_field(attr, options.merge(predicates: {yes: %w(null 0), no: %w(null 1)}))
|
97
97
|
end
|
98
98
|
|
99
99
|
|
@@ -134,9 +134,8 @@ module AbAdmin
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
def yes_no_field(attr, predicates, options={})
|
137
|
+
def yes_no_field(attr, options={})
|
138
|
+
predicates = options[:predicates]
|
140
139
|
content_tag(:div, class: 'pull-left') do
|
141
140
|
content_tag(:label, class: 'checkbox inline') do
|
142
141
|
param = "#{attr}_#{predicates[:yes][0]}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ab_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Leschenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -364,16 +364,16 @@ dependencies:
|
|
364
364
|
name: mysql2
|
365
365
|
requirement: !ruby/object:Gem::Requirement
|
366
366
|
requirements:
|
367
|
-
- - "
|
367
|
+
- - "~>"
|
368
368
|
- !ruby/object:Gem::Version
|
369
|
-
version:
|
369
|
+
version: 0.3.19
|
370
370
|
type: :development
|
371
371
|
prerelease: false
|
372
372
|
version_requirements: !ruby/object:Gem::Requirement
|
373
373
|
requirements:
|
374
|
-
- - "
|
374
|
+
- - "~>"
|
375
375
|
- !ruby/object:Gem::Version
|
376
|
-
version:
|
376
|
+
version: 0.3.19
|
377
377
|
description: Simple and real-life tested Rails::Engine admin interface
|
378
378
|
email:
|
379
379
|
- leschenko.al@gmail.com
|