ab_admin 0.5.0 → 0.6.0
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/README.md +2 -2
- data/app/assets/javascripts/ab_admin/components/admin_assets.js.coffee +1 -1
- data/app/assets/javascripts/ab_admin/components/locator.js.coffee +2 -0
- data/app/assets/javascripts/ab_admin/components/select2_bridge.js.coffee +8 -7
- data/app/assets/javascripts/ab_admin/core/confirmation.js.coffee +1 -1
- data/app/assets/javascripts/ab_admin/core/init.js.coffee +6 -5
- data/app/assets/javascripts/ab_admin/core/utils.js.coffee +2 -2
- data/app/assets/stylesheets/ab_admin/{application.css.scss → application.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/{bootstrap_and_overrides.css.scss → bootstrap_and_overrides.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_admin_comments.css.scss → _admin_comments.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_base.css.scss → _base.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_colored_tabs.css.scss → _colored_tabs.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_columns_hider.css.scss → _columns_hider.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_form.css.scss → _form.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_geo_input.css.scss → _geo_input.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_grid_view.css.scss → _grid_view.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_locale_tabs.css.scss → _locale_tabs.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_navigation.css.scss → _navigation.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_perms.css.scss → _perms.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_table_view.css.scss → _table_view.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_translations.css.scss → _translations.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_tree_view.css.scss → _tree_view.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/components/{_view_layout.css.scss → _view_layout.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/{devise.css.scss → devise.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/{fileupload.css.scss → fileupload.scss} +0 -0
- data/app/assets/stylesheets/ab_admin/{main.css.scss → main.scss} +0 -0
- data/app/controllers/admin/base_controller.rb +26 -11
- data/app/views/admin/admin_comments/_comment.html.slim +1 -1
- data/app/views/admin/base/_search_layout.html.slim +5 -6
- data/app/views/admin/base/index.html.slim +9 -10
- data/app/views/admin/fileupload/_container.html.slim +2 -1
- data/app/views/admin/locators/edit.html.slim +2 -2
- data/app/views/admin/locators/show.html.slim +2 -2
- data/app/views/admin/manager/_table.html.slim +2 -2
- data/app/views/admin/settings/_form.html.slim +3 -2
- data/app/views/admin/shared/_content_actions.html.slim +1 -1
- data/app/views/admin/shared/_flash.js.erb +2 -2
- data/config/routes.rb +13 -13
- data/lib/ab_admin.rb +13 -0
- data/lib/ab_admin/abstract_resource.rb +0 -4
- data/lib/ab_admin/concerns/admin_addition.rb +5 -1
- data/lib/ab_admin/concerns/has_tracking.rb +1 -1
- data/lib/ab_admin/concerns/utilities.rb +2 -1
- data/lib/ab_admin/devise.rb +0 -2
- data/lib/ab_admin/engine.rb +0 -1
- data/lib/ab_admin/hooks.rb +1 -1
- data/lib/ab_admin/hooks/globalize_locale_suffix_accessors.rb +29 -2
- data/lib/ab_admin/i18n_tools/model_translator.rb +1 -1
- data/lib/ab_admin/menu/group.rb +10 -1
- data/lib/ab_admin/menu/item.rb +5 -4
- data/lib/ab_admin/models/asset.rb +2 -1
- data/lib/ab_admin/models/settings.rb +24 -22
- data/lib/ab_admin/models/user.rb +8 -4
- data/lib/ab_admin/utils.rb +4 -4
- data/lib/ab_admin/utils/logger.rb +1 -1
- data/lib/ab_admin/version.rb +1 -1
- data/lib/ab_admin/views/admin_helpers.rb +4 -0
- data/lib/ab_admin/views/admin_navigation_helpers.rb +1 -0
- data/lib/ab_admin/views/inputs/ckeditor_input.rb +1 -1
- data/lib/ab_admin/views/inputs/color_input.rb +1 -1
- data/lib/ab_admin/views/inputs/date_time_picker_input.rb +1 -3
- data/lib/ab_admin/views/inputs/editor_input.rb +1 -1
- data/lib/ab_admin/views/inputs/token_input.rb +1 -3
- data/lib/ab_admin/views/inputs/uploader_input.rb +2 -2
- data/lib/ab_admin/views/search_form_builder.rb +23 -12
- data/lib/generators/ab_admin/install/install_generator.rb +0 -2
- data/lib/generators/ab_admin/install/templates/config/ab_admin.rb.erb +3 -5
- data/lib/generators/ab_admin/install/templates/config/nginx.conf +2 -1
- data/lib/generators/template.rb +2 -6
- metadata +29 -31
- data/lib/generators/ab_admin/install/templates/config/unicorn/production.rb +0 -49
- data/lib/generators/ab_admin/install/templates/script/unicorn.sh +0 -75
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4b41478c7820e45d9a9deae90db880543e42050
|
|
4
|
+
data.tar.gz: 7c53e52bcde99999c83faf3105c3f7be082176be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e43c703029a62700cf443d0460991011e5a3520569a03640d3e08afe30c59584c4fd5429bff961ce4575efb6630fa1f9fa8066b2afaf394a6298845aaf4a2a4
|
|
7
|
+
data.tar.gz: 520fbc9ebf7047fa5b9dff9ed8f433d2b15dc7e1feef02d933d5839ffe511b4fcc74b02fc2a8f0d92552cc5079b674a3443e1a86a7c5dccc3a6c06b43a3e0bae
|
data/README.md
CHANGED
|
@@ -7,10 +7,10 @@ Simple and real-life tested Rails::Engine admin interface based on slim, bootstr
|
|
|
7
7
|
To build a new Rails application with AbAdmin, run:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
rails new [
|
|
10
|
+
rails new [my_app_name] -m https://raw.githubusercontent.com/leschenko/ab_admin/master/lib/generators/template.rb
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Or add gems from template [list of gems](https://
|
|
13
|
+
Or add gems from template [list of gems](https://raw.githubusercontent.com/leschenko/ab_admin/master/lib/generators/template.rb) to an existing application and run generators:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
rails generate devise:install
|
|
@@ -16,7 +16,7 @@ class window.AdminAssets extends BaseAssets
|
|
|
16
16
|
showErrors: (e, data) ->
|
|
17
17
|
errors = _.map(data.files,(file) ->
|
|
18
18
|
[file.name, "<b>#{file.error}</b>"].join(' - ')).join('<br/>')
|
|
19
|
-
bootbox.alert(errors)
|
|
19
|
+
bootbox.alert("<h3>#{errors}</h3>")
|
|
20
20
|
|
|
21
21
|
initHandlers: ->
|
|
22
22
|
super
|
|
@@ -143,26 +143,27 @@ class window.Select2Bridge
|
|
|
143
143
|
|
|
144
144
|
fetchAjaxParams: (term, page) =>
|
|
145
145
|
cond = {}
|
|
146
|
-
|
|
146
|
+
condData = JSON.parse(@el.attr('data-c') || null)
|
|
147
|
+
if condData
|
|
147
148
|
for kind in ['with', 'without']
|
|
148
|
-
if
|
|
149
|
+
if condData[kind]
|
|
149
150
|
cond[kind] ||= {}
|
|
150
|
-
for attr, id of
|
|
151
|
+
for attr, id of condData[kind]
|
|
151
152
|
value = $('#' + id).val()
|
|
152
153
|
cond[kind][attr] = value if value
|
|
153
154
|
|
|
154
155
|
for kind in ['with_term', 'without_term']
|
|
155
|
-
if
|
|
156
|
+
if condData[kind]
|
|
156
157
|
kind_key = kind.replace(/_term$/, '')
|
|
157
158
|
cond[kind_key] ||= {}
|
|
158
|
-
for attr, value of
|
|
159
|
+
for attr, value of condData[kind]
|
|
159
160
|
cond[kind_key][attr] = value if value
|
|
160
161
|
|
|
161
162
|
for kind in ['with_selector', 'without_selector']
|
|
162
|
-
if
|
|
163
|
+
if condData[kind]
|
|
163
164
|
kind_key = kind.replace(/_selector$/, '')
|
|
164
165
|
cond[kind_key] ||= {}
|
|
165
|
-
for attr, value of
|
|
166
|
+
for attr, value of condData[kind]
|
|
166
167
|
selectors = value.split(/\s+/)
|
|
167
168
|
value = @el.closest(selectors[1] || 'html').find(selectors[0]).val()
|
|
168
169
|
cond[kind_key][attr] = value if value
|
|
@@ -15,7 +15,7 @@ $ ->
|
|
|
15
15
|
$(document).trigger('admin:list_init')
|
|
16
16
|
|
|
17
17
|
$('.per_page').click ->
|
|
18
|
-
$.cookie('pp', $(this).data('val'))
|
|
18
|
+
$.cookie('pp', $(this).data('val'), {path: window.location.pathname})
|
|
19
19
|
|
|
20
20
|
$('#list').on 'click', 'tr.list_edit .form_cancel', ->
|
|
21
21
|
e.preventDefault()
|
|
@@ -39,10 +39,11 @@ $ ->
|
|
|
39
39
|
$(document).trigger({type: 'admin:init', pjax: true})
|
|
40
40
|
$(document).trigger({type: 'admin:init'})
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
$(
|
|
42
|
+
if window.fv?.list_dblclick
|
|
43
|
+
$(document).on 'dblclick', '#list > tbody > tr', (e) ->
|
|
44
|
+
e.preventDefault()
|
|
45
|
+
unless $(e.target).closest('#list > tbody > tr > td').hasClass('list_adds')
|
|
46
|
+
$(this).find('td a.resource_id_link').toHref()
|
|
46
47
|
|
|
47
48
|
initFancySelect()
|
|
48
49
|
initNestedFields()
|
|
@@ -161,9 +161,9 @@ window.storeData = (key, data) ->
|
|
|
161
161
|
str = JSON.stringify(data)
|
|
162
162
|
else
|
|
163
163
|
str = '' + data
|
|
164
|
-
|
|
164
|
+
try
|
|
165
165
|
window.localStorage[key] = str
|
|
166
|
-
|
|
166
|
+
catch
|
|
167
167
|
$.cookie(key, str, {path: '/'})
|
|
168
168
|
|
|
169
169
|
window.fetchData = (key) ->
|
|
File without changes
|
|
File without changes
|
data/app/assets/stylesheets/ab_admin/components/{_admin_comments.css.scss → _admin_comments.scss}
RENAMED
|
File without changes
|
|
File without changes
|
data/app/assets/stylesheets/ab_admin/components/{_colored_tabs.css.scss → _colored_tabs.scss}
RENAMED
|
File without changes
|
data/app/assets/stylesheets/ab_admin/components/{_columns_hider.css.scss → _columns_hider.scss}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/app/assets/stylesheets/ab_admin/components/{_translations.css.scss → _translations.scss}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -21,7 +21,7 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
21
21
|
|
|
22
22
|
helper_method :button_scopes, :collection_action?, :action_items, :resource_action_items,
|
|
23
23
|
:preview_resource_path, :get_subject, :settings, :batch_action_list, :tree_node_renderer,
|
|
24
|
-
:normalized_index_views, :current_index_view, :pjax?, :xhr
|
|
24
|
+
:normalized_index_views, :current_index_view, :pjax?, :xhr?, :max_per_page
|
|
25
25
|
|
|
26
26
|
rescue_from ::CanCan::AccessDenied, with: :render_unauthorized
|
|
27
27
|
|
|
@@ -181,8 +181,15 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
def settings
|
|
184
|
-
{
|
|
185
|
-
|
|
184
|
+
{
|
|
185
|
+
index_view: 'table',
|
|
186
|
+
sidebar: collection_action?,
|
|
187
|
+
well: (collection_action? || %w(show history).include?(action_name)),
|
|
188
|
+
search: true,
|
|
189
|
+
batch: true,
|
|
190
|
+
hotkeys: true,
|
|
191
|
+
list_dblclick: true
|
|
192
|
+
}
|
|
186
193
|
end
|
|
187
194
|
|
|
188
195
|
def action_items
|
|
@@ -246,16 +253,20 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
246
253
|
end
|
|
247
254
|
|
|
248
255
|
def collection
|
|
249
|
-
@collection ||=
|
|
256
|
+
@collection ||= begin
|
|
257
|
+
result = search_collection
|
|
258
|
+
result = result.paginate(page: params[:page], per_page: per_page, large: true) if action_name != 'batch' && !settings[:skip_pagination]
|
|
259
|
+
result
|
|
260
|
+
end
|
|
250
261
|
end
|
|
251
262
|
|
|
252
263
|
def per_page
|
|
253
|
-
request_per_page = (params[:per_page].presence || cookies[:pp].presence).to_i
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
264
|
+
request_per_page = (params[:per_page].presence || cookies[:pp].presence).to_i.nonzero?
|
|
265
|
+
params[:per_page] = [request_per_page || AbAdmin.view_default_per_page[current_index_view.to_sym], max_per_page].min
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def max_per_page
|
|
269
|
+
settings[:max_per_page] || AbAdmin.max_per_page
|
|
259
270
|
end
|
|
260
271
|
|
|
261
272
|
def set_layout
|
|
@@ -309,7 +320,12 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
309
320
|
fv.bg_color = current_user.bg_color
|
|
310
321
|
fv.admin = admin?
|
|
311
322
|
fv.hotkeys = settings[:hotkeys]
|
|
323
|
+
fv.list_dblclick = settings[:list_dblclick]
|
|
312
324
|
fv.env = Rails.env
|
|
325
|
+
if resource_class.respond_to?(:model_name)
|
|
326
|
+
fv.resource_plural = resource_class.model_name.plural
|
|
327
|
+
fv.resource_singular = resource_class.model_name.singular
|
|
328
|
+
end
|
|
313
329
|
if AbAdmin.test_env?
|
|
314
330
|
fv.test = true
|
|
315
331
|
AbAdmin.test_settings.each { |k, v| fv[k] = v }
|
|
@@ -397,5 +413,4 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
397
413
|
{root: false}
|
|
398
414
|
end
|
|
399
415
|
end
|
|
400
|
-
|
|
401
416
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
.span5
|
|
3
3
|
strong
|
|
4
4
|
- if comment.user_id
|
|
5
|
-
|
|
5
|
+
=> link_to comment.user_name, admin_user_path(id: comment.user_id), target: '_blank'
|
|
6
6
|
div.muted= l(comment.created_at, format: :long)
|
|
7
7
|
div= comment.body
|
|
8
8
|
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
#toggle_sidebar_on.btn.btn-large = icon('chevron-right')
|
|
3
3
|
h3= t('admin.search.title')
|
|
4
4
|
= search_admin_form_for @search, url: collection_path do |f|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
= f.submit t('admin.search.cancel'), class: 'btn', id: 'search_cancel'
|
|
5
|
+
= render 'search_form', f: f
|
|
6
|
+
br
|
|
7
|
+
div
|
|
8
|
+
= f.submit t('admin.search.submit'), class: 'btn btn-success btn-large'
|
|
9
|
+
= f.submit t('admin.search.cancel'), class: 'btn', id: 'search_cancel'
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
/- if settings[:index_view] == 'table'
|
|
2
1
|
= form_tag url_for(action: :batch), id: 'batch_action_form', class: 'pjax-form' do
|
|
3
2
|
input name='batch_action' id='batch_action' type='hidden'
|
|
4
3
|
= render 'admin/shared/content_actions'
|
|
5
4
|
|
|
6
5
|
#content= render current_index_view
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
.btn-
|
|
12
|
-
-
|
|
13
|
-
|
|
6
|
+
- unless settings[:skip_pagination]
|
|
7
|
+
.pagination-wrap.pull-left
|
|
8
|
+
= will_paginate collection, renderer: BootstrapPagination::Rails
|
|
9
|
+
.pagination_info= pagination_info collection
|
|
10
|
+
.btn-toolbar.pull-right.pjax_links
|
|
11
|
+
.btn-group
|
|
12
|
+
- per_page_variants.each do |c|
|
|
13
|
+
a.btn.per_page data-val=c href=url_for(params.merge(per_page: c)) class=('active' if c == collection.per_page) = c
|
|
14
14
|
|
|
15
15
|
- if pjax? && flash.present?
|
|
16
|
-
|
|
17
|
-
= javascript_tag %[flash("#{j message}", "#{type}")]
|
|
16
|
+
script type='text/javascript' = render partial: 'admin/shared/flash', formats: :js, local_assigns: {flash: flash}
|
|
18
17
|
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
.fileupload-edit-button.btn.pull-left= t('admin.actions.edit.link')
|
|
9
9
|
|
|
10
10
|
.fileupload-info
|
|
11
|
-
|
|
11
|
+
- if options[:extensions]
|
|
12
|
+
.fileupload-info-extensions= options[:extensions].join(', ')
|
|
12
13
|
.fileupload-info-max_size== "#{t('admin.fileupload.max_size')}: <b>#{options[:max_size]}</b> MB"
|
|
13
14
|
|
|
14
15
|
= init_js("new AdminAssets(#{js_options.to_json})")
|
|
@@ -20,9 +20,9 @@ table.table.table-bordered.table-striped
|
|
|
20
20
|
th = locale_file.locale
|
|
21
21
|
th = I18n.default_locale
|
|
22
22
|
tr
|
|
23
|
-
-
|
|
23
|
+
- [:key_contains, :edit_locale_contains, :main_locale_contains].each do |param|
|
|
24
24
|
th
|
|
25
|
-
input.filter_field type='text' placeholder=t('admin.locators.filter')
|
|
25
|
+
input.filter_field type='text' value=params[param] placeholder=t('admin.locators.filter')
|
|
26
26
|
= form_tag(admin_locators_path, method: :put) do
|
|
27
27
|
tbody#locale_data
|
|
28
28
|
= hidden_field_tag 'edit_locale_name', locale_file.locale
|
|
@@ -9,5 +9,5 @@ table.table.table-striped.table-bordered style='width: 1050px;'
|
|
|
9
9
|
td= filename.to_s[/\w+/]
|
|
10
10
|
td= link_to filename, edit_admin_locators_path(filename: filename)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
=> link_to t('admin.locators.prepare'), prepare_admin_locators_path, class: 'btn btn-warning', method: :post
|
|
13
|
+
=> link_to t('admin.locators.restart'), reload_admin_locators_path, class: 'btn btn-primary', method: :post
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
= list_sort_link field.name, opts
|
|
17
17
|
- else
|
|
18
18
|
= field.name.is_a?(Symbol) ? ha(field.name) : field.name
|
|
19
|
-
th=t 'admin.table.actions'
|
|
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
|
-
tr id=dom_id(item, 'list')
|
|
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
26
|
- table_builder.fields.each do |field|
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
br
|
|
23
23
|
br
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
- if collection.present?
|
|
25
|
+
=> submit_tag(t('admin.form.save'), class: 'btn btn-primary')
|
|
26
|
+
=> link_to t('admin.cache_clear'), cache_clear_admin_settings_path, class: 'btn btn-danger', method: :post, remote: true
|
|
26
27
|
|
|
27
28
|
= init_js('$("form ul.nav-tabs li:first, form .tab-pane:first").addClass("active")')
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
- normalized_index_views.each do |index_view|
|
|
26
26
|
= index_view_link(index_view)
|
|
27
27
|
|
|
28
|
-
- if can?
|
|
28
|
+
- if can?(:export, resource_class) && !settings[:skip_export]
|
|
29
29
|
.btn-group.downloads
|
|
30
30
|
= icon('download-alt')
|
|
31
31
|
/- %w(csv xls json).each do |format|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<% flash.each do |
|
|
2
|
-
flash("<%= j
|
|
1
|
+
<% flash.each do |type, message| %>
|
|
2
|
+
flash("<%= j message.html_safe %>", "<%= type %>");
|
|
3
3
|
<% end unless flash.empty? %>
|
data/config/routes.rb
CHANGED
|
@@ -33,24 +33,24 @@ Rails.application.routes.draw do
|
|
|
33
33
|
|
|
34
34
|
post 'translate' => AbAdmin::I18nTools::TranslateApp
|
|
35
35
|
|
|
36
|
-
controller 'manager' do
|
|
36
|
+
controller 'manager', constraints: {format: /(html|js|json|xml|csv|xls|xlsx)/} do
|
|
37
37
|
scope '(/:parent_resource/:parent_resource_id)/:model_name' do
|
|
38
|
-
get '/new',
|
|
39
|
-
post '/batch',
|
|
40
|
-
post '/rebuild',
|
|
41
|
-
match '/custom_action',
|
|
38
|
+
get '/new', action: :new, as: 'new'
|
|
39
|
+
post '/batch', action: :batch, as: 'batch'
|
|
40
|
+
post '/rebuild', action: :rebuild, as: 'rebuild'
|
|
41
|
+
match '/custom_action', action: :custom_action, as: 'collection_action', via: :all
|
|
42
42
|
|
|
43
43
|
scope ':id' do
|
|
44
|
-
get '/edit',
|
|
45
|
-
get '/history',
|
|
46
|
-
match '/custom_action',
|
|
47
|
-
get '/',
|
|
48
|
-
patch '/',
|
|
49
|
-
delete '/',
|
|
44
|
+
get '/edit', action: :edit, as: 'edit'
|
|
45
|
+
get '/history', action: :history, as: 'history'
|
|
46
|
+
match '/custom_action', action: :custom_action, as: 'member_action', via: :all
|
|
47
|
+
get '/', action: :show, as: 'show'
|
|
48
|
+
patch '/', action: :update, as: 'update'
|
|
49
|
+
delete '/', action: :destroy, as: 'destroy'
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
get '/',
|
|
53
|
-
post '/',
|
|
52
|
+
get '/', action: :index, as: 'index'
|
|
53
|
+
post '/', action: :create, as: 'create'
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
data/lib/ab_admin.rb
CHANGED
|
@@ -164,6 +164,19 @@ module AbAdmin
|
|
|
164
164
|
|
|
165
165
|
mattr_accessor :base_url
|
|
166
166
|
|
|
167
|
+
mattr_accessor :default_per_page
|
|
168
|
+
@@default_per_page = 50
|
|
169
|
+
|
|
170
|
+
mattr_accessor :view_default_per_page
|
|
171
|
+
@@view_default_per_page = Hash.new { AbAdmin.default_per_page }
|
|
172
|
+
@@view_default_per_page[:tree] = 1000
|
|
173
|
+
|
|
174
|
+
mattr_accessor :max_per_page
|
|
175
|
+
@@max_per_page = Float::INFINITY
|
|
176
|
+
|
|
177
|
+
mattr_accessor :per_page_variants
|
|
178
|
+
@@per_page_variants = [50, 100, 500, 1000]
|
|
179
|
+
|
|
167
180
|
extend Utils
|
|
168
181
|
|
|
169
182
|
def self.setup
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
module AbAdmin
|
|
2
2
|
class AbstractResource
|
|
3
|
-
#unloadable
|
|
4
|
-
|
|
5
3
|
include Singleton
|
|
6
4
|
|
|
7
5
|
unless self.const_defined?(:ACTIONS)
|
|
@@ -165,7 +163,5 @@ module AbAdmin
|
|
|
165
163
|
def has_module?(module_constant)
|
|
166
164
|
model.included_modules.include?(module_constant)
|
|
167
165
|
end
|
|
168
|
-
|
|
169
166
|
end
|
|
170
|
-
|
|
171
167
|
end
|
|
@@ -6,7 +6,7 @@ module AbAdmin
|
|
|
6
6
|
included do
|
|
7
7
|
scope(:admin, -> { all }) unless respond_to?(:admin)
|
|
8
8
|
scope(:base, -> { all }) unless respond_to?(:base)
|
|
9
|
-
scope :by_ids, lambda { |ids| where("#{quoted_table_name}.id IN (?)", AbAdmin.val_to_array(ids).push(0)) }
|
|
9
|
+
scope :by_ids, lambda { |ids| where("#{quoted_table_name}.id IN (?)", AbAdmin.val_to_array(ids).push(0)) } unless respond_to?(:by_ids)
|
|
10
10
|
|
|
11
11
|
class_attribute :batch_actions, instance_writer: false
|
|
12
12
|
self.batch_actions = [:destroy]
|
|
@@ -27,6 +27,10 @@ module AbAdmin
|
|
|
27
27
|
"#{self.class.model_name.human(count: 1)} ##{self.id} #{AbAdmin.safe_display_name(self)}"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def translated_any(attr)
|
|
31
|
+
send(attr).presence || translations.detect { |r| r.send(attr).present? }.try!(attr)
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
def new_changes
|
|
31
35
|
exclude_attrs = respond_to?(:translated_attribute_names) ? translated_attribute_names.dup : []
|
|
32
36
|
exclude_attrs << :updated_at
|