ab_admin 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/ab_admin/components/admin_assets.js.coffee +1 -1
- data/app/assets/javascripts/ab_admin/core/batch_actions.js.coffee +5 -4
- data/app/assets/javascripts/ab_admin/core/columns_hider.js.coffee +2 -2
- data/app/assets/javascripts/ab_admin/core/init.js.coffee +13 -9
- data/app/assets/javascripts/ab_admin/core/ui_utils.js.coffee +1 -1
- data/app/assets/javascripts/ab_admin/main.js +1 -1
- data/app/controllers/admin/base_controller.rb +10 -6
- data/app/views/admin/base/create.js.erb +4 -2
- data/app/views/admin/base/index.html.slim +5 -5
- data/app/views/admin/base/update.js.erb +2 -1
- data/app/views/admin/shared/_batch_actions.html.slim +1 -1
- data/config/routes.rb +1 -1
- data/lib/ab_admin/controllers/can_can_manager_resource.rb +5 -0
- data/lib/ab_admin/core_ext/string.rb +1 -1
- data/lib/ab_admin/version.rb +1 -1
- data/lib/ab_admin/views/admin_helpers.rb +2 -2
- metadata +4 -4
@@ -45,7 +45,7 @@ class window.AdminAssets
|
|
45
45
|
$curr_cont = $asset.closest('.fileupload')
|
46
46
|
$curr_list = $curr_cont.find('.fileupload-list')
|
47
47
|
asset_klass = $curr_cont.data('asset')
|
48
|
-
$main_list = $(".fileupload.one_asset[data-asset='#{asset_klass}'] .fileupload-list")
|
48
|
+
$main_list = $(".fileupload.one_asset[data-asset='#{asset_klass}'] .fileupload-list:first")
|
49
49
|
|
50
50
|
$.post "/admin/assets/#{$asset.data('id')}/main", ->
|
51
51
|
$main_list.find('.asset').appendTo($curr_list)
|
@@ -15,16 +15,17 @@ $ ->
|
|
15
15
|
action = $el.data('action')
|
16
16
|
$('#batch_action').val(action)
|
17
17
|
$form = $('#batch_action_form')
|
18
|
-
$form.append("<input type='checkbox' name='ids[]' checked='1' value='#{id}'/>") for id in ids
|
18
|
+
$form.append("<input type='checkbox' name='ids[]' checked='1' value='#{id}' style='display:none;'/>") for id in ids
|
19
19
|
$form.submit()
|
20
20
|
|
21
|
-
$(document).on 'click', '#list tbody tr', (e) ->
|
21
|
+
$(document).on 'click', '#list > tbody > tr', (e) ->
|
22
22
|
return true unless _.include(['TR', 'TD'], e.target.tagName)
|
23
23
|
e.preventDefault()
|
24
24
|
e.stopPropagation()
|
25
25
|
$el = $(this)
|
26
|
-
$
|
27
|
-
|
26
|
+
if $(e.target).closest('table').attr('id') == 'list'
|
27
|
+
$el.closest('tr').toggleClass('active_row')
|
28
|
+
$el.find('td:first input').attr 'checked', (i, v) -> !v
|
28
29
|
|
29
30
|
$(document).on 'click confirm:success', '.batch_action_link', (e) ->
|
30
31
|
e.preventDefault()
|
@@ -61,7 +61,7 @@ class window.ColumnsHider
|
|
61
61
|
$('#columns_hider').modal('hide')
|
62
62
|
@refreshColumns()
|
63
63
|
@setData()
|
64
|
-
$(document).on 'pjax:end', =>
|
64
|
+
$(document).on 'pjax:end admin:list_init', =>
|
65
65
|
@refreshColumns()
|
66
66
|
|
67
67
|
refreshColumns: ->
|
@@ -71,7 +71,7 @@ class window.ColumnsHider
|
|
71
71
|
@hideByIndex(i + 1)
|
72
72
|
|
73
73
|
hideByIndex: (i) ->
|
74
|
-
$("#list tr th:nth-child(#{i}), #list tr td:nth-child(#{i})").hide()
|
74
|
+
$("#list > thead > tr > th:nth-child(#{i}), #list > tbody > tr > td:nth-child(#{i})").hide()
|
75
75
|
|
76
76
|
showAll: ->
|
77
77
|
$("#list tr th, #list tr td").show()
|
@@ -16,8 +16,8 @@ $ ->
|
|
16
16
|
$(document).on 'admin:init', (e) ->
|
17
17
|
return unless window.viewType == 'list'
|
18
18
|
clonePagination()
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
$(document).trigger('admin:list_init')
|
21
21
|
|
22
22
|
$('.per_page').click ->
|
23
23
|
$.cookie('pp', $(this).data('val'))
|
@@ -26,18 +26,23 @@ $ ->
|
|
26
26
|
e.preventDefault()
|
27
27
|
$(this).closest('tr').remove()
|
28
28
|
|
29
|
-
$(document).on 'admin:form_init', 'form', (e) ->
|
30
|
-
focusInput($(this))
|
31
|
-
initEditor()
|
32
|
-
initFancySelect()
|
33
|
-
inputSetToggle()
|
34
|
-
|
35
29
|
$(document).on 'admin:init', (e) ->
|
36
30
|
return unless window.viewType == 'form'
|
37
31
|
$form = $('form.simple_form')
|
38
32
|
window.resource_id = $form.data('id')
|
39
33
|
$form.trigger('admin:form_init')
|
40
34
|
|
35
|
+
$(document).on 'admin:list_init', ->
|
36
|
+
initPopover()
|
37
|
+
initTooltip()
|
38
|
+
|
39
|
+
$(document).on 'admin:form_init', 'form', (e) ->
|
40
|
+
# focusInput($(this))
|
41
|
+
initEditor()
|
42
|
+
initFancySelect()
|
43
|
+
inputSetToggle()
|
44
|
+
initPickers()
|
45
|
+
|
41
46
|
$(document).on 'pjax:end', ->
|
42
47
|
$(document).trigger({type: 'admin:init', pjax: true})
|
43
48
|
$(document).trigger({type: 'admin:init'})
|
@@ -46,7 +51,6 @@ $ ->
|
|
46
51
|
e.preventDefault()
|
47
52
|
$(this).find('td a.resource_id_link').toHref()
|
48
53
|
|
49
|
-
|
50
54
|
initFancySelect()
|
51
55
|
initNestedFields()
|
52
56
|
# initAcFileds()
|
@@ -44,7 +44,7 @@ window.flash = (message, type='notice') ->
|
|
44
44
|
|
45
45
|
window.focusInput = (scope=null) ->
|
46
46
|
scope ||= $('form.simple_form:first')
|
47
|
-
$('input[type="text"],input[type="string"],select:visible,textarea:visible').not('.fancy_select,.datepicker').get(0)?.focus()
|
47
|
+
$('input[type="text"],input[type="string"],select:visible,textarea:visible', scope).not('.fancy_select,.datepicker').get(0)?.focus()
|
48
48
|
|
49
49
|
window.templateStorage = {}
|
50
50
|
window.fetchTemplate = (tmpl_id) ->
|
@@ -27,6 +27,6 @@
|
|
27
27
|
//= require ab_admin/components/in_place_edit
|
28
28
|
//= require ab_admin/components/init_nested_filelds
|
29
29
|
//= require ab_admin/components/hotkeys
|
30
|
+
//= require ab_admin/inputs/datetime_input
|
30
31
|
|
31
32
|
//= require ab_admin/core/init
|
32
|
-
//= require ab_admin/inputs/datetime_input
|
@@ -9,8 +9,7 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
9
9
|
before_filter :authenticate_user!, :require_moderator
|
10
10
|
before_filter :add_breadcrumbs, :set_title, :set_user_vars, unless: :xhr?
|
11
11
|
|
12
|
-
class_attribute :export_builder, :batch_action_list, instance_reader: false, instance_writer: false
|
13
|
-
self.batch_action_list = [AbAdmin::Config::BatchAction.new(:destroy, confirm: I18n.t('admin.delete_confirmation'))]
|
12
|
+
class_attribute :export_builder, :batch_action_list, :button_scopes, instance_reader: false, instance_writer: false
|
14
13
|
|
15
14
|
has_scope :ids, type: :array
|
16
15
|
|
@@ -95,7 +94,12 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
95
94
|
protected
|
96
95
|
|
97
96
|
def batch_action_list
|
98
|
-
self.class.batch_action_list
|
97
|
+
self.class.batch_action_list ||= begin
|
98
|
+
resource_class.batch_actions.map do |a|
|
99
|
+
opts = a == :destroy ? {confirm: I18n.t('admin.delete_confirmation')} : {}
|
100
|
+
AbAdmin::Config::BatchAction.new(a, opts)
|
101
|
+
end
|
102
|
+
end
|
99
103
|
end
|
100
104
|
|
101
105
|
def self.inherited(base)
|
@@ -161,7 +165,7 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
161
165
|
end
|
162
166
|
|
163
167
|
def button_scopes
|
164
|
-
|
168
|
+
self.class.button_scopes ||= begin
|
165
169
|
res = {}
|
166
170
|
self.class.scopes_configuration.except(:ids).each do |k, v|
|
167
171
|
res[k] = v if v[:type] == :default
|
@@ -282,8 +286,8 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
282
286
|
end
|
283
287
|
|
284
288
|
def get_role
|
285
|
-
return [:
|
286
|
-
return [:moderator] if moderator?
|
289
|
+
return [:default, :moderator, :admin] if admin?
|
290
|
+
return [:default, :moderator] if moderator?
|
287
291
|
nil
|
288
292
|
end
|
289
293
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
<%
|
2
2
|
form_wrap_id = dom_id(resource_class.new, 'list_edit')
|
3
|
-
html = render('table', collection: [resource])[/<tr id[^>]+>.*<\/tr>/].html_safe
|
3
|
+
html = render('table', collection: [resource])[/<tr id[^>]+>.*<\/tr>/m].html_safe
|
4
4
|
%>
|
5
5
|
$('#<%= form_wrap_id %>').remove();
|
6
|
-
$('#list tbody').prepend('<%= j html %>');
|
6
|
+
$('#list tbody').prepend('<%= j html %>');
|
7
|
+
$('#<%= dom_id(resource, 'list') %>').addClass('success').scrollToEl();
|
8
|
+
$(document).trigger('admin:list_init');
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
/- if settings[:index_view] == 'table'
|
2
|
+
= form_tag url_for(action: :batch), id: 'batch_action_form', class: 'pjax-form' do
|
3
|
+
input name='batch_action' id='batch_action' type='hidden'
|
4
|
+
= render 'admin/shared/batch_actions'
|
5
5
|
|
6
6
|
#content= render settings[:index_view]
|
7
7
|
.pagination.pull-left
|
@@ -10,4 +10,4 @@
|
|
10
10
|
.btn-toolbar.pull-right.pjax_links
|
11
11
|
.btn-group
|
12
12
|
- [50, 100, 500, 1000].each do |c|
|
13
|
-
a.btn.per_page data-val=c href=
|
13
|
+
a.btn.per_page data-val=c href=url_for(params.merge(per_page: c)) class=('active' if c == collection.per_page) = c
|
@@ -4,4 +4,5 @@
|
|
4
4
|
%>
|
5
5
|
$('#<%= form_wrap_id %>').remove();
|
6
6
|
$('#<%= dom_id(resource, 'list') %>').replaceWith('<%= j html %>');
|
7
|
-
$('#<%= dom_id(resource, 'list') %>').addClass('success').scrollToEl()
|
7
|
+
$('#<%= dom_id(resource, 'list') %>').addClass('success').scrollToEl();
|
8
|
+
$(document).trigger('admin:list_init');
|
@@ -1,6 +1,6 @@
|
|
1
1
|
.batch_actions.clearfix
|
2
2
|
- cache [I18n.locale, 'admin', resource_class.name, 'batch_actions'] do
|
3
|
-
- if settings[:batch]
|
3
|
+
- if settings[:batch] && settings[:index_view] == 'table'
|
4
4
|
.btn-group
|
5
5
|
a.btn.dropdown-toggle data-toggle="dropdown" href="#"
|
6
6
|
= t 'admin.batch_actions.title'
|
data/config/routes.rb
CHANGED
data/lib/ab_admin/version.rb
CHANGED
@@ -35,9 +35,9 @@ module AbAdmin
|
|
35
35
|
data = {
|
36
36
|
type: options[:type], source: options[:source].try(:to_json),
|
37
37
|
model: resource_class.model_name.singular, url: resource_path(item),
|
38
|
-
name: attr, value: item[attr]
|
38
|
+
name: attr, value: options[:value] || item[attr]
|
39
39
|
}
|
40
|
-
link_to admin_pretty_data(item[attr]).html_safe, '#', class: 'editable', data: data
|
40
|
+
link_to admin_pretty_data(item[attr].to_s).html_safe, '#', class: 'editable', data: data
|
41
41
|
end
|
42
42
|
|
43
43
|
def options_for_ckeditor(options = {})
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: ab_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Alex Leschenko
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -1073,7 +1073,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1073
1073
|
version: '0'
|
1074
1074
|
segments:
|
1075
1075
|
- 0
|
1076
|
-
hash:
|
1076
|
+
hash: -2603358076628246564
|
1077
1077
|
none: false
|
1078
1078
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1079
1079
|
requirements:
|
@@ -1082,7 +1082,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1082
1082
|
version: '0'
|
1083
1083
|
segments:
|
1084
1084
|
- 0
|
1085
|
-
hash:
|
1085
|
+
hash: -2603358076628246564
|
1086
1086
|
none: false
|
1087
1087
|
requirements: []
|
1088
1088
|
rubyforge_project:
|