ab_admin 0.1.0 → 0.1.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.
- data/Gemfile +5 -2
- data/README.md +2 -4
- data/TODO +3 -0
- data/ab_admin.gemspec +1 -1
- data/app/assets/javascripts/ab_admin/application.js +4 -1
- data/app/assets/javascripts/ab_admin/components/in_place_edit.js.coffee +23 -0
- data/app/assets/javascripts/ab_admin/core/batch_actions.js.coffee +4 -1
- data/app/assets/javascripts/ab_admin/core/columns_hider.js.coffee +13 -5
- data/app/assets/javascripts/ab_admin/core/init.js.coffee +30 -15
- data/app/assets/javascripts/ab_admin/core/ui_utils.js.coffee +15 -7
- data/app/assets/javascripts/ab_admin/core/utils.js.coffee +3 -0
- data/app/assets/javascripts/ab_admin/inputs/datetime_input.js.coffee +1 -1
- data/app/assets/stylesheets/ab_admin/application.css.scss +2 -1
- data/app/assets/stylesheets/ab_admin/components/_table_view.css.scss +12 -0
- data/app/controllers/admin/base_controller.rb +20 -2
- data/app/controllers/admin/manager_controller.rb +0 -2
- data/app/views/admin/base/create.js.erb +6 -0
- data/app/views/admin/base/edit.js.erb +10 -0
- data/app/views/admin/base/index.html.slim +2 -3
- data/app/views/admin/base/new.js.erb +8 -0
- data/app/views/admin/base/update.js.erb +7 -0
- data/app/views/admin/manager/_search_form.html.slim +1 -1
- data/app/views/admin/manager/_show_table.html.slim +7 -0
- data/app/views/admin/manager/_table.html.slim +6 -2
- data/app/views/admin/shared/_save_buttons.html.slim +1 -1
- data/features/dsl/action_items.feature +4 -4
- data/features/dsl/in_place_edit.feature +26 -0
- data/features/dsl/list_edit.feature +46 -0
- data/features/dsl/show.feature +37 -0
- data/features/step_definitions/dsl/in_place_edit_steps.rb +7 -0
- data/features/step_definitions/dsl/show_steps.rb +8 -0
- data/features/step_definitions/dsl/table_steps.rb +2 -2
- data/features/step_definitions/web_steps/browsing_steps.rb +13 -0
- data/features/support/paths.rb +1 -1
- data/lib/ab_admin/abstract_resource.rb +5 -1
- data/lib/ab_admin/config/base.rb +14 -0
- data/lib/ab_admin/version.rb +1 -1
- data/lib/ab_admin/views/admin_helpers.rb +22 -0
- data/lib/ab_admin/views/admin_navigation_helpers.rb +6 -7
- data/lib/ab_admin/views/form_builder.rb +1 -1
- data/lib/ab_admin/views/manager_helpers.rb +4 -0
- data/lib/ab_admin/views/search_form_builder.rb +5 -1
- data/lib/generators/template.rb +4 -3
- data/spec/dummy/app/helpers/application_helper.rb +1 -0
- data/spec/dummy/app/models/ab_admin/ab_admin_product.rb +33 -70
- data/spec/dummy/app/models/product.rb +2 -0
- data/vendor/assets/javascripts/jquery.hotkeys.js +106 -0
- metadata +26 -15
- data/NOTES +0 -16
- data/app/assets/images/admin/chosen-sprite.png +0 -0
- data/app/assets/stylesheets/ab_admin/chosen.css.scss +0 -368
- data/app/assets/stylesheets/ab_admin/components/_table_tools.css.scss +0 -94
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/vendor/assets/javascripts/chosen.js.coffee +0 -780
data/Gemfile
CHANGED
|
@@ -23,10 +23,13 @@ gem 'globalize3', :git => 'git://github.com/leschenko/globalize3.git', :ref => '
|
|
|
23
23
|
|
|
24
24
|
gem 'carrierwave'
|
|
25
25
|
gem 'mini_magick'
|
|
26
|
+
gem 'will_paginate', '>= 3.0.3'
|
|
27
|
+
# disabled links broken styling in 0.2.2
|
|
28
|
+
gem 'will_paginate-bootstrap', '0.2.1'
|
|
26
29
|
gem 'bootstrap-sass', '2.0.4'
|
|
27
30
|
gem 'bootstrap-wysihtml5-rails'
|
|
28
|
-
gem '
|
|
29
|
-
gem '
|
|
31
|
+
gem 'bootstrap-x-editable-rails'
|
|
32
|
+
gem 'select2-rails'
|
|
30
33
|
gem 'nested_form', '0.2.2'
|
|
31
34
|
gem 'simple_form'
|
|
32
35
|
gem 'russian'
|
data/README.md
CHANGED
|
@@ -7,12 +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
|
-
|
|
10
|
+
rails new [MyAppName] -m https://raw.github.com/leschenko/ab_admin/master/lib/generators/template.rb
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Or add [list of gems](https://gist.github.com/leschenko/752aaa0f03323aa8c6b3) to an existing application
|
|
14
|
-
|
|
15
|
-
Run generators
|
|
13
|
+
Or add [list of gems](https://gist.github.com/leschenko/752aaa0f03323aa8c6b3) to an existing application and run generators:
|
|
16
14
|
|
|
17
15
|
```bash
|
|
18
16
|
rails generate devise:install
|
data/TODO
ADDED
data/ab_admin.gemspec
CHANGED
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |gem|
|
|
|
39
39
|
gem.add_dependency 'bootstrap-sass', '~> 2.0.4'
|
|
40
40
|
gem.add_dependency 'bootstrap-wysihtml5-rails'
|
|
41
41
|
gem.add_dependency 'will_paginate'
|
|
42
|
-
gem.add_dependency 'will_paginate-bootstrap'
|
|
42
|
+
gem.add_dependency 'will_paginate-bootstrap', '0.2.1'
|
|
43
43
|
gem.add_dependency 'nested_form', '~> 0.2.2'
|
|
44
44
|
gem.add_dependency 'simple_form'
|
|
45
45
|
gem.add_dependency 'gon'
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
//= require jquery.pjax
|
|
6
6
|
//= require jquery.ui.nestedSortable
|
|
7
7
|
//= require jquery_nested_form
|
|
8
|
+
//= require jquery.hotkeys
|
|
8
9
|
//= require bootstrap
|
|
9
10
|
//= require ab_admin/bootstrap-tab-multi
|
|
10
11
|
//= require ab_admin/bootstrap-datepicker/core
|
|
@@ -12,13 +13,15 @@
|
|
|
12
13
|
//= require ab_admin/bootstrap-timepicker
|
|
13
14
|
//= require bootstrap-wysihtml5
|
|
14
15
|
//= require bootstrap-wysihtml5/locales/ru
|
|
15
|
-
//= require
|
|
16
|
+
//= require bootstrap-editable-inline
|
|
17
|
+
//= require select2
|
|
16
18
|
//= require jquery.ui.nestedSortable
|
|
17
19
|
//= require ab_admin/components/sortable_tree
|
|
18
20
|
//= require ab_admin/components/google_translate
|
|
19
21
|
//= require ab_admin/components/locator
|
|
20
22
|
//= require ab_admin/components/admin_assets
|
|
21
23
|
//= require ab_admin/components/gmaps
|
|
24
|
+
//= require ab_admin/components/in_place_edit
|
|
22
25
|
|
|
23
26
|
//= require ab_admin/core/init
|
|
24
27
|
//= require ab_admin/inputs/datetime_input
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
EditableForm = $.fn.editableform.Constructor
|
|
2
|
+
EditableForm.prototype.saveWithUrlHook = (value) ->
|
|
3
|
+
url = @options.url
|
|
4
|
+
@options.url = (params) =>
|
|
5
|
+
params[@options.model] ||= {}
|
|
6
|
+
params[@options.model][params.name] = value
|
|
7
|
+
ajax_opts =
|
|
8
|
+
url: url
|
|
9
|
+
data: params
|
|
10
|
+
type: 'PUT'
|
|
11
|
+
dataType: 'json'
|
|
12
|
+
delete params.name
|
|
13
|
+
delete params.value
|
|
14
|
+
delete params.pk
|
|
15
|
+
$.ajax $.extend(ajax_opts, @options.ajaxOptions)
|
|
16
|
+
@saveWithoutUrlHook(value)
|
|
17
|
+
EditableForm.prototype.saveWithoutUrlHook = EditableForm.prototype.save
|
|
18
|
+
EditableForm.prototype.save = EditableForm.prototype.saveWithUrlHook
|
|
19
|
+
|
|
20
|
+
$(document).on 'admin:init', (e) ->
|
|
21
|
+
return unless window.viewType == 'list'
|
|
22
|
+
$('.editable').editable
|
|
23
|
+
onblur: 'submit'
|
|
@@ -11,9 +11,12 @@ $ ->
|
|
|
11
11
|
submitBatch = (el) ->
|
|
12
12
|
if $("#list [name='ids[]']:checked")[0]
|
|
13
13
|
$el = $(el)
|
|
14
|
+
ids = $("#list [name='ids[]']:checked").map(-> $(this).val()).get()
|
|
14
15
|
action = $el.data('action')
|
|
15
16
|
$('#batch_action').val(action)
|
|
16
|
-
$('#batch_action_form')
|
|
17
|
+
$form = $('#batch_action_form')
|
|
18
|
+
$form.append("<input type='checkbox' name='ids[]' checked='1' value='#{id}'/>") for id in ids
|
|
19
|
+
$form.submit()
|
|
17
20
|
|
|
18
21
|
$('#list tbody tr').live 'click', (e) ->
|
|
19
22
|
return true unless _.include(['TR', 'TD'], e.target.tagName)
|
|
@@ -2,13 +2,17 @@ class window.ColumnsHider
|
|
|
2
2
|
constructor: ->
|
|
3
3
|
@store_key = 'cols'
|
|
4
4
|
@data_el = $('#columns_hider_data')
|
|
5
|
-
@data = @getData()
|
|
6
|
-
@collection_name = $('html').attr('id').replace(/^controller_/, '')
|
|
7
5
|
@column_names = @columnNames()
|
|
6
|
+
@collection_name = $('html').attr('id').replace(/^controller_/, '')
|
|
7
|
+
@data = @getData()
|
|
8
|
+
@initDefaults()
|
|
8
9
|
@initButtons()
|
|
9
10
|
@initHandlers()
|
|
10
11
|
@refreshColumns()
|
|
11
12
|
|
|
13
|
+
initDefaults: ->
|
|
14
|
+
@data
|
|
15
|
+
|
|
12
16
|
setData: ->
|
|
13
17
|
res = {}
|
|
14
18
|
_.each @data, (v, k) ->
|
|
@@ -22,6 +26,10 @@ class window.ColumnsHider
|
|
|
22
26
|
data[k] = []
|
|
23
27
|
_.each v.split('_'), (el) ->
|
|
24
28
|
data[k].push to_i(el) if el
|
|
29
|
+
unless data[@collection_name]
|
|
30
|
+
data[@collection_name] = []
|
|
31
|
+
for col, i in @column_names
|
|
32
|
+
data[@collection_name].push(i) if col.disabled
|
|
25
33
|
data
|
|
26
34
|
|
|
27
35
|
fetchData: ->
|
|
@@ -36,15 +44,15 @@ class window.ColumnsHider
|
|
|
36
44
|
|
|
37
45
|
initButtons: ->
|
|
38
46
|
@data_el.empty()
|
|
39
|
-
for
|
|
47
|
+
for col, i in @column_names
|
|
40
48
|
css_class = if _.include(@data[@collection_name], i) then 'active' else ''
|
|
41
|
-
html = "<button class='btn btn-primary #{css_class}' data-val='#{i}'>#{name}</button>"
|
|
49
|
+
html = "<button class='btn btn-primary #{css_class}' data-val='#{i}'>#{col.name}</button>"
|
|
42
50
|
@data_el.append(html)
|
|
43
51
|
|
|
44
52
|
columnNames: ->
|
|
45
53
|
_.map $('#list th'), (el) ->
|
|
46
54
|
$el = $(el)
|
|
47
|
-
$.trim($el.text().replace(/[▼▲]/g, ''))
|
|
55
|
+
{disabled: $el.hasClass('hide_cell'), name: $.trim($el.text().replace(/[▼▲]/g, ''))}
|
|
48
56
|
|
|
49
57
|
initHandlers: ->
|
|
50
58
|
$('#submit_columns_hider').click =>
|
|
@@ -19,36 +19,51 @@ $ ->
|
|
|
19
19
|
initPopover()
|
|
20
20
|
initTooltip()
|
|
21
21
|
|
|
22
|
-
$('#list tbody tr').dblclick (e) ->
|
|
23
|
-
e.preventDefault()
|
|
24
|
-
$el = $(this)
|
|
25
|
-
window.location.href = $el.find('td a.resource_id_link').prop('href')
|
|
26
|
-
|
|
27
22
|
$('.per_page').click ->
|
|
28
23
|
$.cookie('pp', $(this).data('val'))
|
|
29
24
|
|
|
25
|
+
$('#list').on 'click', '.form_cancel', (e) ->
|
|
26
|
+
e.preventDefault()
|
|
27
|
+
$(this).closest('tr').remove()
|
|
28
|
+
|
|
30
29
|
|
|
31
30
|
$(document).on 'admin:init', (e) ->
|
|
32
31
|
return unless window.viewType == 'form'
|
|
33
32
|
window.resource_id = $('form.simple_form').data('id')
|
|
34
|
-
|
|
35
|
-
inputSetToggle()
|
|
33
|
+
$(document).trigger('admin:form_init')
|
|
36
34
|
|
|
37
|
-
# $('form .region_ac').regionAc()
|
|
38
|
-
# new NestedFieldsAdder
|
|
39
|
-
# region_ac: true
|
|
40
|
-
# callback: ->
|
|
41
|
-
# initPickers()
|
|
42
|
-
# initChosen()
|
|
43
|
-
# initEditor()
|
|
44
35
|
|
|
36
|
+
$(document).on 'admin:form_init', 'form', (e) ->
|
|
37
|
+
focusInput($(this))
|
|
38
|
+
initEditor()
|
|
39
|
+
initFancySelect()
|
|
40
|
+
inputSetToggle()
|
|
45
41
|
|
|
46
42
|
$(document).on 'pjax:end', ->
|
|
47
43
|
$(document).trigger({type: 'admin:init', pjax: true})
|
|
48
44
|
$(document).trigger({type: 'admin:init'})
|
|
49
45
|
|
|
46
|
+
$(document).on 'dblclick', '#list tbody tr', (e) ->
|
|
47
|
+
e.preventDefault()
|
|
48
|
+
$el = $(this)
|
|
49
|
+
$el.find('td a.resource_id_link').click()
|
|
50
|
+
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
initFancySelect()
|
|
52
53
|
# initAcFileds()
|
|
53
54
|
if window.gon?.bg_color
|
|
54
55
|
$('body').css('background-color', "##{window.gon.bg_color.replace(/^#/, '')}")
|
|
56
|
+
|
|
57
|
+
if window.gon?.hotkeys
|
|
58
|
+
$(document).bind 'keydown.alt_n', -> $('a.new_resource:first').click()
|
|
59
|
+
$(document).bind 'keydown.alt_left', -> $('a[rel^="prev"]:first').click()
|
|
60
|
+
$(document).bind 'keydown.alt_right', -> $('a[rel="next"]:first').click()
|
|
61
|
+
$(document).bind 'keydown.alt_s', -> $('#search_form').submit()
|
|
62
|
+
|
|
63
|
+
# $('form .region_ac').regionAc()
|
|
64
|
+
# new NestedFieldsAdder
|
|
65
|
+
# region_ac: true
|
|
66
|
+
# callback: ->
|
|
67
|
+
# initPickers()
|
|
68
|
+
# initFancySelect()
|
|
69
|
+
# initEditor()
|
|
@@ -15,14 +15,19 @@ window.initPopover = ->
|
|
|
15
15
|
$('.popover').hide()
|
|
16
16
|
$('a[rel=popover]').popover({trigger: 'hover'})
|
|
17
17
|
|
|
18
|
-
window.
|
|
18
|
+
window.initFancySelect = ->
|
|
19
19
|
return if gon.test
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
options =
|
|
21
|
+
formatNoMatches: -> I18n.t('admin_js.no_results')
|
|
22
|
+
placeholder: ' '
|
|
23
|
+
width: 'resolve'
|
|
24
|
+
$('form .fancy_select, .without_form.fancy_select, form .fancy_select_multi').select2(options)
|
|
25
|
+
# chosen_options =
|
|
26
|
+
# allow_single_deselect: true
|
|
27
|
+
# no_results_text: I18n.t('admin_js.no_results')
|
|
28
|
+
# placeholder_text_single: ' '
|
|
29
|
+
# placeholder_text_multiple: ' '
|
|
30
|
+
# $('form .do_chosen, .without_form.do_chosen, form .do_chosen_multi').chosen(chosen_options)
|
|
26
31
|
|
|
27
32
|
window.initAcFileds = ->
|
|
28
33
|
for el in $('.ac_field')
|
|
@@ -60,3 +65,6 @@ window.inputSetToggle = ->
|
|
|
60
65
|
|
|
61
66
|
window.flash = (type, message) ->
|
|
62
67
|
$('#wrap').prepend $("<div class='alert alert-#{type}'><a class='close' data-dismiss='alert'>×</a>#{message}</div>")
|
|
68
|
+
|
|
69
|
+
window.focusInput = (scope=null) ->
|
|
70
|
+
$('input[type="text"],input[type="string"],select:visible,textarea:visible', scope || $('form.simple_form:first')).get(0)?.focus()
|
|
@@ -68,6 +68,9 @@ $.fn.loadSelect = (optionsDataArray) ->
|
|
|
68
68
|
else
|
|
69
69
|
selectElement.add option, null
|
|
70
70
|
|
|
71
|
+
$.fn.scrollToEl = ->
|
|
72
|
+
$('html, body').animate({scrollTop: $(this).offset().top}, 'slow')
|
|
73
|
+
|
|
71
74
|
$.parseQuery = ->
|
|
72
75
|
window.location.search.replace("?", "").parseQuery()
|
|
73
76
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//= require ab_admin/bootstrap-datepicker
|
|
2
2
|
//= require ab_admin/bootstrap-timepicker
|
|
3
3
|
//= require bootstrap-wysihtml5
|
|
4
|
-
//= require
|
|
4
|
+
//= require bootstrap-editable
|
|
5
|
+
//= require select2
|
|
5
6
|
//= require ab_admin/bootstrap_and_overrides
|
|
6
7
|
//= require ab_admin/fileupload
|
|
7
8
|
|
|
@@ -72,4 +72,16 @@ table.index_table {
|
|
|
72
72
|
tr.selected td {
|
|
73
73
|
background: #d9e4ec;
|
|
74
74
|
}
|
|
75
|
+
.form-actions {
|
|
76
|
+
position: static;
|
|
77
|
+
background-color: transparent;
|
|
78
|
+
border-top: none;
|
|
79
|
+
margin: 0;
|
|
80
|
+
.extra_buttons button {
|
|
81
|
+
display: none;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
form.simple_form {
|
|
85
|
+
margin: 0;
|
|
86
|
+
}
|
|
75
87
|
}
|
|
@@ -19,7 +19,7 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
19
19
|
helper_method :button_scopes, :collection_action?, :action_items, :resource_action_items, :csv_builder,
|
|
20
20
|
:preview_resource_path, :get_subject, :settings, :batch_action_list, :tree_node_renderer
|
|
21
21
|
|
|
22
|
-
respond_to :json, :only => [:index]
|
|
22
|
+
respond_to :json, :only => [:index, :update]
|
|
23
23
|
|
|
24
24
|
rescue_from ::CanCan::AccessDenied, :with => :render_unauthorized
|
|
25
25
|
|
|
@@ -42,6 +42,8 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
42
42
|
def create
|
|
43
43
|
create! do |success, failure|
|
|
44
44
|
success.html { redirect_to redirect_to_on_success }
|
|
45
|
+
success.js { render :layout => false }
|
|
46
|
+
failure.js { render :new, :layout => false }
|
|
45
47
|
end
|
|
46
48
|
end
|
|
47
49
|
|
|
@@ -49,6 +51,8 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
49
51
|
update! do |success, failure|
|
|
50
52
|
success.html { redirect_to redirect_to_on_success }
|
|
51
53
|
failure.html { render :edit }
|
|
54
|
+
success.js { render :layout => false }
|
|
55
|
+
failure.js { render :edit, :layout => false }
|
|
52
56
|
end
|
|
53
57
|
end
|
|
54
58
|
|
|
@@ -56,6 +60,18 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
56
60
|
destroy! { redirect_to_on_success }
|
|
57
61
|
end
|
|
58
62
|
|
|
63
|
+
def edit
|
|
64
|
+
edit! do |format|
|
|
65
|
+
format.js { render :layout => false }
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def new
|
|
70
|
+
new! do |format|
|
|
71
|
+
format.js { render :layout => false }
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
59
75
|
def batch
|
|
60
76
|
raise 'No ids specified for batch action' unless params[:ids].present?
|
|
61
77
|
batch_action = params[:batch_action].to_sym
|
|
@@ -119,7 +135,8 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
119
135
|
end
|
|
120
136
|
|
|
121
137
|
def settings
|
|
122
|
-
{:index_view => 'table', :sidebar => collection_action?, :well => (collection_action? || action_name == 'show'),
|
|
138
|
+
{:index_view => 'table', :sidebar => collection_action?, :well => (collection_action? || action_name == 'show'),
|
|
139
|
+
:search => true, :batch => true, :hotkeys => true}
|
|
123
140
|
end
|
|
124
141
|
|
|
125
142
|
def action_items
|
|
@@ -223,6 +240,7 @@ class Admin::BaseController < ::InheritedResources::Base
|
|
|
223
240
|
gon.bg_color = current_user.bg_color
|
|
224
241
|
gon.admin = admin?
|
|
225
242
|
gon.test = Rails.env.test?
|
|
243
|
+
gon.hotkeys = settings[:hotkeys]
|
|
226
244
|
end
|
|
227
245
|
|
|
228
246
|
def moderator?
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%
|
|
2
|
+
el_id = dom_id(resource, 'list')
|
|
3
|
+
form_wrap_id = dom_id(resource, 'list_edit')
|
|
4
|
+
html = %[<tr id="#{form_wrap_id}" class="warning"><td>#{render('form')}</td></tr>].html_safe
|
|
5
|
+
%>
|
|
6
|
+
$('#<%= form_wrap_id %>').remove();
|
|
7
|
+
$('#<%= el_id %>').after('<%= j html %>');
|
|
8
|
+
$('#<%= form_wrap_id %> td').attr('colspan', $('#list tr:first th').length);
|
|
9
|
+
$('#<%= el_id %>').scrollToEl();
|
|
10
|
+
$('#<%= form_wrap_id %> form').trigger('admin:form_init');
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
= form_tag url_for(:action => :batch), :id => 'batch_action_form', :class => 'pjax-form' do
|
|
3
3
|
input name='batch_action' id='batch_action' type='hidden'
|
|
4
4
|
= render 'admin/shared/batch_actions'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
#content= render settings[:index_view]
|
|
5
|
+
|
|
6
|
+
#content= render settings[:index_view]
|
|
8
7
|
.pagination.pull-left
|
|
9
8
|
= will_paginate collection, :renderer => BootstrapPagination::Rails
|
|
10
9
|
.pagination_info= pagination_info collection
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%
|
|
2
|
+
form_wrap_id = dom_id(resource, 'list_edit')
|
|
3
|
+
html = %[<tr id="#{form_wrap_id}" class="warning"><td>#{render('form')}</td></tr>].html_safe
|
|
4
|
+
%>
|
|
5
|
+
$('#<%= form_wrap_id %>').remove();
|
|
6
|
+
$('#list tbody').prepend('<%= j html %>');
|
|
7
|
+
$('#<%= form_wrap_id %> td').attr('colspan', $('#list tr:first th').length);
|
|
8
|
+
$('#<%= form_wrap_id %> form').trigger('admin:form_init');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%
|
|
2
|
+
form_wrap_id = dom_id(resource, 'list_edit')
|
|
3
|
+
html = render('table', :collection => [resource])[/<tr id[^>]+>.*<\/tr>/].html_safe
|
|
4
|
+
%>
|
|
5
|
+
$('#<%= form_wrap_id %>').remove();
|
|
6
|
+
$('#<%= dom_id(resource, 'list') %>').replaceWith('<%= j html %>');
|
|
7
|
+
$('#<%= dom_id(resource, 'list') %>').addClass('success').scrollToEl()
|
|
@@ -19,9 +19,13 @@
|
|
|
19
19
|
th=t 'admin.table.actions'
|
|
20
20
|
tbody
|
|
21
21
|
- collection.each do |item|
|
|
22
|
-
tr
|
|
22
|
+
tr id=dom_id(item, 'list')
|
|
23
23
|
= batch_action_item(item)
|
|
24
24
|
td= id_link(item)
|
|
25
25
|
- table_builder.fields.each do |field|
|
|
26
|
-
td
|
|
26
|
+
td
|
|
27
|
+
- if field.options[:editable] && field.data.is_a?(Symbol)
|
|
28
|
+
= admin_editable item, field.data, field.options[:editable]
|
|
29
|
+
- else
|
|
30
|
+
= admin_pretty_data call_method_or_proc_on(item, field.data)
|
|
27
31
|
td.actions= item_index_actions(item)
|
|
@@ -19,6 +19,6 @@ input type='hidden' name='return_to' value=return_to
|
|
|
19
19
|
- if can? :edit, resource
|
|
20
20
|
button.btn.btn-info type="submit" name="_add_edit" data-disable-with=t('admin.form.save_and_edit')
|
|
21
21
|
= t('admin.form.save_and_edit')
|
|
22
|
-
a.btn href=(return_to || collection_path)
|
|
22
|
+
a.btn.form_cancel href=(return_to || collection_path)
|
|
23
23
|
= icon('remove')
|
|
24
24
|
= t('admin.form.cancel')
|
|
@@ -24,7 +24,7 @@ Feature: Actions items
|
|
|
24
24
|
Then I should see action items:
|
|
25
25
|
| Create | Review | Remove |
|
|
26
26
|
|
|
27
|
-
When I am on the
|
|
27
|
+
When I am on the the admin product page
|
|
28
28
|
Then I should see action items:
|
|
29
29
|
| Create | Edit | Remove |
|
|
30
30
|
|
|
@@ -47,7 +47,7 @@ Feature: Actions items
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
"""
|
|
50
|
-
When I am on the
|
|
50
|
+
When I am on the the admin product page
|
|
51
51
|
Then I should see an action item to "Main page"
|
|
52
52
|
|
|
53
53
|
Scenario: Conditional action item
|
|
@@ -59,7 +59,7 @@ Feature: Actions items
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
"""
|
|
62
|
-
When I am on the
|
|
62
|
+
When I am on the the admin product page
|
|
63
63
|
Then I should see an action item to "Secret link"
|
|
64
64
|
|
|
65
65
|
When I am on the edit admin product page
|
|
@@ -75,5 +75,5 @@ Feature: Actions items
|
|
|
75
75
|
action_item :destroy, false
|
|
76
76
|
end
|
|
77
77
|
"""
|
|
78
|
-
When I am on the
|
|
78
|
+
When I am on the the admin product page
|
|
79
79
|
Then I should not see an action item to "Remove"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@dsl @javascript
|
|
2
|
+
Feature: In place edit
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
Given I am logged in
|
|
6
|
+
And a product with sku "sofa-12"
|
|
7
|
+
And a configuration of:
|
|
8
|
+
"""
|
|
9
|
+
class AbAdminProduct < AbAdmin::AbstractResource
|
|
10
|
+
table do
|
|
11
|
+
field :sku, :editable => true
|
|
12
|
+
field :name
|
|
13
|
+
field :created_at
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
"""
|
|
17
|
+
And I am on the admin products page
|
|
18
|
+
|
|
19
|
+
Scenario: In place edit field
|
|
20
|
+
When I click "sofa-12"
|
|
21
|
+
And I fill in place with "sofa_new"
|
|
22
|
+
And I submit in place form
|
|
23
|
+
Then I should see "sofa_new"
|
|
24
|
+
|
|
25
|
+
When I reload the page
|
|
26
|
+
Then I should see "sofa_new"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
@dsl @javascript
|
|
2
|
+
Feature: Editing records in the list
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
Given I am logged in
|
|
6
|
+
And a product with sku "sofa-12"
|
|
7
|
+
And a configuration of:
|
|
8
|
+
"""
|
|
9
|
+
class AbAdminProduct < AbAdmin::AbstractResource
|
|
10
|
+
settings :list_edit => true
|
|
11
|
+
end
|
|
12
|
+
"""
|
|
13
|
+
And I am on the admin products page
|
|
14
|
+
|
|
15
|
+
Scenario: Saving record with valid attributes
|
|
16
|
+
Given I click "Edit"
|
|
17
|
+
Then I should be on the admin products page
|
|
18
|
+
And I fill in "Sku" with "new_sofa" within "#list"
|
|
19
|
+
And I submit form
|
|
20
|
+
When I should see "new_sofa"
|
|
21
|
+
And I should not see "Save"
|
|
22
|
+
|
|
23
|
+
Scenario: Saving record with invalid attributes
|
|
24
|
+
Given I click "Edit"
|
|
25
|
+
Then I should be on the admin products page
|
|
26
|
+
And I fill in "Sku" with "" within "#list"
|
|
27
|
+
And I submit form
|
|
28
|
+
When I should see "Sku can't be blank"
|
|
29
|
+
And I should see "Save"
|
|
30
|
+
|
|
31
|
+
Scenario: Creating record with valid attributes
|
|
32
|
+
Given I click "Create" within ".resource_actions"
|
|
33
|
+
Then I should be on the admin products page
|
|
34
|
+
And I fill in "Sku" with "new_sofa" within "#list"
|
|
35
|
+
And I submit form
|
|
36
|
+
When I should see "new_sofa"
|
|
37
|
+
And I should not see "Save"
|
|
38
|
+
|
|
39
|
+
Scenario: Creating record with invalid attributes
|
|
40
|
+
Given I click "Create" within ".resource_actions"
|
|
41
|
+
Then I should be on the admin products page
|
|
42
|
+
And I fill in "Sku" with "" within "#list"
|
|
43
|
+
And I submit form
|
|
44
|
+
When I should see "Sku can't be blank"
|
|
45
|
+
And I should see "Save"
|
|
46
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@dsl
|
|
2
|
+
Feature: Show resource page
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
Given I am logged in
|
|
6
|
+
And products exists with attributes:
|
|
7
|
+
| sku | name | price |
|
|
8
|
+
| sofa-12 | FancySofa | 123 |
|
|
9
|
+
|
|
10
|
+
Scenario: Default show view
|
|
11
|
+
Given a configuration of:
|
|
12
|
+
"""
|
|
13
|
+
class AbAdminProduct < AbAdmin::AbstractResource
|
|
14
|
+
end
|
|
15
|
+
"""
|
|
16
|
+
When I am on the admin product page
|
|
17
|
+
Then I should see attributes table:
|
|
18
|
+
| Sku | sofa-12 |
|
|
19
|
+
| Name | FancySofa |
|
|
20
|
+
| Price | 123 |
|
|
21
|
+
|
|
22
|
+
Scenario: Default show view
|
|
23
|
+
Given a configuration of:
|
|
24
|
+
"""
|
|
25
|
+
class AbAdminProduct < AbAdmin::AbstractResource
|
|
26
|
+
show do
|
|
27
|
+
field :sku
|
|
28
|
+
field(:price) {|item| "$#{item.price}" }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
"""
|
|
32
|
+
When I am on the admin product page
|
|
33
|
+
Then I should see attributes table:
|
|
34
|
+
| Sku | sofa-12 |
|
|
35
|
+
| Price | $123 |
|
|
36
|
+
And I should not see "FancySofa" within "table"
|
|
37
|
+
|
|
@@ -2,9 +2,9 @@ Given /^a product with sku "(.*?)"$/ do |sku|
|
|
|
2
2
|
@product = FactoryGirl.create(:product, :sku => sku)
|
|
3
3
|
end
|
|
4
4
|
|
|
5
|
-
Given /^products exists with attributes:$/ do |products|
|
|
5
|
+
Given /^products? exists with attributes:$/ do |products|
|
|
6
6
|
products.hashes.each do |attrs|
|
|
7
|
-
FactoryGirl.create(:full_product, attrs)
|
|
7
|
+
@product = FactoryGirl.create(:full_product, attrs)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|