ab_admin 0.3.4 → 0.3.5

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.
Files changed (46) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +4 -2
  3. data/app/assets/javascripts/ab_admin/components/google_translate.js.coffee +1 -1
  4. data/app/assets/javascripts/ab_admin/components/init_nested_filelds.js.coffee +2 -2
  5. data/app/assets/javascripts/ab_admin/core/batch_actions.js.coffee +3 -3
  6. data/app/assets/javascripts/ab_admin/core/init.js.coffee +5 -3
  7. data/app/assets/javascripts/ab_admin/core/search_form.js.coffee +2 -2
  8. data/app/assets/javascripts/ab_admin/core/ui_utils.js.coffee +14 -2
  9. data/app/assets/javascripts/ab_admin/core/utils.js.coffee +4 -3
  10. data/app/assets/javascripts/ab_admin/main.js +3 -1
  11. data/app/assets/stylesheets/ab_admin/bootstrap_and_overrides.css.scss +5 -4
  12. data/app/assets/stylesheets/ab_admin/components/_text_styles.css.scss +47 -0
  13. data/app/assets/stylesheets/ab_admin/main.css.scss +1 -1
  14. data/app/controllers/admin/base_controller.rb +1 -1
  15. data/app/views/admin/base/edit.js.erb +1 -1
  16. data/app/views/admin/base/new.js.erb +1 -1
  17. data/app/views/admin/base/update.js.erb +1 -1
  18. data/app/views/admin/fileupload/_container.html.slim +4 -2
  19. data/app/views/admin/fileupload/_file.html.slim +1 -1
  20. data/app/views/admin/fileupload/_ftmpl.html.slim +1 -1
  21. data/app/views/admin/manager/_search_form.html.slim +1 -1
  22. data/app/views/admin/shared/_batch_actions.html.slim +9 -10
  23. data/app/views/layouts/admin/application.html.slim +3 -5
  24. data/config/locales/ru.yml +3 -2
  25. data/features/menu.feature +7 -2
  26. data/features/step_definitions/menu_steps.rb +7 -0
  27. data/lib/ab_admin.rb +3 -3
  28. data/lib/ab_admin/controllers/head_options.rb +2 -2
  29. data/lib/ab_admin/menu_builder.rb +2 -1
  30. data/lib/ab_admin/models/attachment_file.rb +1 -2
  31. data/lib/ab_admin/models/user.rb +1 -1
  32. data/lib/ab_admin/version.rb +1 -1
  33. data/lib/ab_admin/views/admin_helpers.rb +7 -4
  34. data/lib/ab_admin/views/admin_navigation_helpers.rb +4 -4
  35. data/lib/ab_admin/views/form_builder.rb +2 -2
  36. data/lib/generators/template.rb +0 -1
  37. data/spec/ab_admin_spec.rb +2 -2
  38. data/vendor/assets/images/ab_admin/clear.png +0 -0
  39. data/vendor/assets/images/ab_admin/loading.gif +0 -0
  40. data/vendor/assets/javascripts/ab_admin/bootstrap-editable-inline.js +2895 -0
  41. data/vendor/assets/javascripts/ab_admin/bootstrap-editable.js +4523 -0
  42. data/vendor/assets/javascripts/ab_admin/jquery_nested_form.js.coffee +19 -1
  43. data/vendor/assets/javascripts/jquery/jquery-ui.min.js +15 -0
  44. data/vendor/assets/javascripts/jquery/jquery.min.js +4 -0
  45. data/vendor/assets/stylesheets/ab_admin/bootstrap-editable.scss +461 -0
  46. metadata +12 -4
data/.gitignore CHANGED
@@ -18,6 +18,8 @@ tmp
18
18
 
19
19
  .idea
20
20
  .rvmrc
21
+ .ruby-gemset
22
+ .ruby-version
21
23
  .rspec
22
24
  .DS_Store
23
25
 
data/Gemfile CHANGED
@@ -9,6 +9,8 @@ gem 'slim'
9
9
  gem 'devise', '~> 2.1.0'
10
10
  gem 'devise-encryptable'
11
11
  gem 'cancan'
12
+ # for ruby 2.0
13
+ #gem 'inherited_resources', git: 'git://github.com/josevalim/inherited_resources.git'
12
14
  gem 'inherited_resources', '~> 1.3.0'
13
15
  gem 'rack-pjax'
14
16
  gem 'configatron'
@@ -19,7 +21,7 @@ gem 'friendly_id'
19
21
  gem 'galetahub-enum_field', require: 'enum_field'
20
22
  gem 'awesome_nested_set'
21
23
  gem 'sunrise-file-upload', git: 'git://github.com/leschenko/sunrise-file-upload.git', ref: '53da968'
22
- gem 'globalize3', git: 'git://github.com/leschenko/globalize3.git', ref: '586ccbd'
24
+ gem 'globalize3', :git => 'git://github.com/leschenko/globalize3.git', :ref => 'f16ab7f', branch: 'master'
23
25
 
24
26
  gem 'carrierwave'
25
27
  gem 'mini_magick'
@@ -28,7 +30,6 @@ gem 'will_paginate', '>= 3.0.3'
28
30
  gem 'will_paginate-bootstrap', '0.2.1'
29
31
  gem 'bootstrap-sass', '2.0.4'
30
32
  gem 'bootstrap-wysihtml5-rails'
31
- gem 'bootstrap-x-editable-rails'
32
33
  gem 'fancybox2-rails'
33
34
  gem 'select2-rails'
34
35
  gem 'nested_form', '0.2.2'
@@ -57,6 +58,7 @@ group :development, :test do
57
58
  end
58
59
 
59
60
  group :test do
61
+ gem 'childprocess', '0.3.6'
60
62
  gem 'cucumber-rails', require: false
61
63
  gem 'capybara'
62
64
  gem 'shoulda-matchers'
@@ -48,7 +48,7 @@ class window.GoogleLocaleTabs
48
48
  @locales = ['ru', 'en', 'it']
49
49
  constructor: ->
50
50
  @locales = GoogleLocaleTabs.locales
51
- @limit = 1000
51
+ @limit = 10000
52
52
  html = '<div class="t_locales">'
53
53
  for l in @locales
54
54
  html += "<div class='t_locale t_locale_#{l}'></div>"
@@ -1,6 +1,6 @@
1
1
  window.initNestedFields = (opts={}) ->
2
- $form = $('form.simple_form:first')
3
- $form.bind 'nested:fieldAdded', (e) =>
2
+ $(document).on 'nested:fieldAdded', 'form.simple_form', (e) =>
4
3
  window.locale_tabs?.initHandlers() unless opts.skip_tabs
5
4
  window.initFancySelect() unless opts.skip_fancy
5
+ window.initPickers() unless opts.skip_pickers
6
6
  opts.callback.call(e) if opts.callback
@@ -1,11 +1,11 @@
1
1
  $ ->
2
2
  if $('#list')[0]
3
- $("#list input.toggle").live "click", ->
3
+ $(document).on 'click', '#list input.toggle', ->
4
4
  checked = $(this).is(":checked")
5
5
  $("#list [name='ids[]']").attr "checked", checked
6
6
  $('#list tbody tr').toggleClass('active_row', checked)
7
7
 
8
- $("#list tbody input").live "click", ->
8
+ $(document).on 'click', '#list input.batch_check', ->
9
9
  $(this).closest('tr').toggleClass('active_row')
10
10
 
11
11
  submitBatch = (el) ->
@@ -23,7 +23,7 @@ $ ->
23
23
  e.preventDefault()
24
24
  e.stopPropagation()
25
25
  $el = $(this)
26
- if $(e.target).closest('table').attr('id') == 'list'
26
+ unless $(e.target).closest('#list > tbody > tr > td').hasClass('list_adds')
27
27
  $el.closest('tr').toggleClass('active_row')
28
28
  $el.find('td:first input').attr 'checked', (i, v) -> !v
29
29
 
@@ -22,7 +22,7 @@ $ ->
22
22
  $('.per_page').click ->
23
23
  $.cookie('pp', $(this).data('val'))
24
24
 
25
- $('#list').on 'click', '.form_cancel', (e) ->
25
+ $('#list').on 'click', 'tr.list_edit .form_cancel', (e) ->
26
26
  e.preventDefault()
27
27
  $(this).closest('tr').remove()
28
28
 
@@ -47,12 +47,14 @@ $ ->
47
47
  $(document).trigger({type: 'admin:init', pjax: true})
48
48
  $(document).trigger({type: 'admin:init'})
49
49
 
50
- $(document).on 'dblclick', '#list tbody tr', (e) ->
50
+ $(document).on 'dblclick', '#list > tbody > tr', (e) ->
51
51
  e.preventDefault()
52
- $(this).find('td a.resource_id_link').toHref()
52
+ unless $(e.target).closest('#list > tbody > tr > td').hasClass('list_adds')
53
+ $(this).find('td a.resource_id_link').toHref()
53
54
 
54
55
  initFancySelect()
55
56
  initNestedFields()
57
+ initNestedFields()
56
58
  # initAcFileds()
57
59
 
58
60
  if window.gon?.bg_color
@@ -5,9 +5,9 @@ $ ->
5
5
  $el.next('input').attr('name', "q[#{$el.val()}]")
6
6
 
7
7
  $("#search_form").submit ->
8
- $("#search_form [id$='_gteq']").val (i, v) ->
8
+ $("#search_form [name$='_at_gteq]']").val (i, v) ->
9
9
  v + " 00:00" if v
10
- $("#search_form [id$='_lteq']").val (i, v) ->
10
+ $("#search_form [name$='_at_lteq]']").val (i, v) ->
11
11
  v + " 23:59" if v
12
12
 
13
13
  $('#search_cancel').click (e) ->
@@ -102,14 +102,26 @@ window.initFancySelect = ->
102
102
  if $el.data('c')[kind]
103
103
  cond[kind] ||= {}
104
104
  for attr, id of $el.data('c')[kind]
105
- cond[kind][attr] = $('#' + id).val()
105
+ value = $('#' + id).val()
106
+ cond[kind][attr] = value if value
106
107
 
107
108
  for kind in ['with_term', 'without_term']
108
109
  if $el.data('c')[kind]
109
110
  kind_key = kind.replace(/_term$/, '')
110
111
  cond[kind_key] ||= {}
111
112
  for attr, value of $el.data('c')[kind]
112
- cond[kind_key][attr] = value
113
+ cond[kind_key][attr] = value if value
114
+
115
+ for kind in ['with_selector', 'without_selector']
116
+ if $el.data('c')[kind]
117
+ kind_key = kind.replace(/_selector$/, '')
118
+ cond[kind_key] ||= {}
119
+ for attr, value of $el.data('c')[kind]
120
+ selectors = value.split(/\s+/)
121
+ value = $el.closest(selectors[1] || 'html').find(selectors[0]).val()
122
+ cond[kind_key][attr] = value if value
123
+
124
+ log cond
113
125
 
114
126
  data = {q: term, class: $el.data('class'), token: true}
115
127
  _.extend(data, cond)
@@ -68,13 +68,14 @@ $.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')
71
+ $.fn.scrollToEl = (speed='slow') ->
72
+ return unless $(this)[0]
73
+ $('html, body').animate({scrollTop: $(this).offset().top}, speed)
73
74
 
74
75
  $.fn.toHref = ->
75
76
  $el = $(this)
76
77
  if _.isEmpty($el.data())
77
- window.location.href = $el.attr('href')
78
+ window.location.href = $el.attr('href') if $el.attr('href')
78
79
  else
79
80
  $el.click()
80
81
 
@@ -1,5 +1,7 @@
1
1
  //= require i18n
2
2
  //= require i18n/translations
3
+ //= require jquery/jquery.min
4
+ //= require jquery/jquery-ui.min
3
5
  //= require jquery_ujs
4
6
  //= require handlebars.min
5
7
  //= require underscore.min
@@ -15,7 +17,7 @@
15
17
  //= require ab_admin/bootstrap-timepicker
16
18
  //= require bootstrap-wysihtml5
17
19
  //= require bootstrap-wysihtml5/locales/ru
18
- //= require bootstrap-editable-inline
20
+ //= require ab_admin/bootstrap-editable-inline
19
21
  //= require select2
20
22
  //= require fancybox
21
23
  //= require jquery.ui.nestedSortable
@@ -16,6 +16,7 @@ $iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png', image);
16
16
  @import "ab_admin/components/admin_comments";
17
17
  @import "ab_admin/components/geo_input";
18
18
  @import "ab_admin/components/sortable_tree";
19
+ @import "ab_admin/components/text_styles";
19
20
 
20
21
  .dropdown .caret {
21
22
  margin-left: 5px;
@@ -120,19 +121,19 @@ label.control-label.label-reset {
120
121
  }
121
122
 
122
123
  .table tbody {
123
- tr.success > td {
124
+ tr.success > td, &.success > tr > td {
124
125
  background-color: #dff0d8;
125
126
  }
126
127
 
127
- tr.error > td {
128
+ tr.error > td, &.error > tr > td {
128
129
  background-color: #f2dede;
129
130
  }
130
131
 
131
- tr.warning > td {
132
+ tr.warning > td, &.warning > tr > td {
132
133
  background-color: #fcf8e3;
133
134
  }
134
135
 
135
- tr.info > td {
136
+ tr.info > td, &.info > tr > td {
136
137
  background-color: #d9edf7;
137
138
  }
138
139
  }
@@ -0,0 +1,47 @@
1
+ .text-warning {
2
+ color: #c09853;
3
+ }
4
+
5
+ a.text-warning:hover,
6
+ a.text-warning:focus {
7
+ color: #a47e3c;
8
+ }
9
+
10
+ .text-error {
11
+ color: #b94a48;
12
+ }
13
+
14
+ a.text-error:hover,
15
+ a.text-error:focus {
16
+ color: #953b39;
17
+ }
18
+
19
+ .text-info {
20
+ color: #3a87ad;
21
+ }
22
+
23
+ a.text-info:hover,
24
+ a.text-info:focus {
25
+ color: #2d6987;
26
+ }
27
+
28
+ .text-success {
29
+ color: #468847;
30
+ }
31
+
32
+ a.text-success:hover,
33
+ a.text-success:focus {
34
+ color: #356635;
35
+ }
36
+
37
+ .text-left {
38
+ text-align: left;
39
+ }
40
+
41
+ .text-right {
42
+ text-align: right;
43
+ }
44
+
45
+ .text-center {
46
+ text-align: center;
47
+ }
@@ -1,7 +1,7 @@
1
1
  //= require ab_admin/bootstrap-datepicker
2
2
  //= require ab_admin/bootstrap-timepicker
3
3
  //= require bootstrap-wysihtml5
4
- //= require bootstrap-editable
4
+ //= require ab_admin/bootstrap-editable
5
5
  //= require select2
6
6
  //= require fancybox
7
7
  //= require ab_admin/bootstrap_and_overrides
@@ -24,7 +24,7 @@ class Admin::BaseController < ::InheritedResources::Base
24
24
 
25
25
  def index
26
26
  super do |format|
27
- format.js { render collection }
27
+ format.js { render layout: false }
28
28
  format.csv do
29
29
  doc = AbAdmin::Utils::CsvDocument.new(collection, export_options)
30
30
  send_data(doc.render, filename: doc.filename, type: Mime::CSV, disposition: 'attachment')
@@ -1,7 +1,7 @@
1
1
  <%
2
2
  el_id = dom_id(resource, 'list')
3
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
4
+ html = %[<tr id="#{form_wrap_id}" class="list_edit warning"><td>#{render('form')}</td></tr>].html_safe
5
5
  %>
6
6
  $('#<%= form_wrap_id %>').remove();
7
7
  $('#<%= el_id %>').after('<%= j html %>');
@@ -1,6 +1,6 @@
1
1
  <%
2
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
3
+ html = %[<tr id="#{form_wrap_id}" class="warning list_edit"><td>#{render('form')}</td></tr>].html_safe
4
4
  %>
5
5
  $('#<%= form_wrap_id %>').remove();
6
6
  $('#list tbody').prepend('<%= j html %>');
@@ -5,4 +5,4 @@
5
5
  $('#<%= form_wrap_id %>').remove();
6
6
  $('#<%= dom_id(resource, 'list') %>').replaceWith('<%= j html %>');
7
7
  $('#<%= dom_id(resource, 'list') %>').addClass('success').scrollToEl();
8
- $(document).trigger('admin:list_init');
8
+ $(document).trigger('admin:list_init');
@@ -5,7 +5,9 @@
5
5
  .fileupload-list.clearfix= render partial: "admin/fileupload/#{asset_template}", collection: assets
6
6
  .file-types
7
7
  span.fileupload-button
8
- button.btn.btn-primary type="button" = t("admin.fileupload.button#{'s' if multiple}")
9
- .type-info== "#{file_title}. #{t('admin.fileupload.max_size')}: <b>#{file_max_size}</b> MB"
8
+ button.btn type="button" = button_title
9
+ .type-info
10
+ span.file_title== "#{file_title}. "
11
+ span.file_max_size== "#{t('admin.fileupload.max_size')}: <b>#{file_max_size}</b> MB"
10
12
 
11
13
  = init_js(js)
@@ -1,5 +1,5 @@
1
1
  .asset id="asset_#{file.id}" data-id=file.id
2
2
  a href=file.url target='_blank' = file.original_name
3
3
  span== " (#{file.human_filesize}) - #{l(file.created_at, format: :long)}"
4
- = link_to t('admin.delete'), admin_asset_path(file), remote: true, method: :delete, \
4
+ = link_to icon('remove', true), admin_asset_path(file), remote: true, method: :delete, \
5
5
  class: 'del_asset btn btn-danger btn-mini', data: {confirm: t('admin.delete_confirmation')}
@@ -2,5 +2,5 @@ script#fileupload_ftmpl type="text/x-jquery-tmpl"
2
2
  .asset id="asset_${id}" data-id='${id}'
3
3
  a href='${url}' target='_blank' ${original_name}
4
4
  span &nbsp;(${human_filesize})
5
- = link_to t('admin.delete'), '/admin/assets/${id}', remote: true, method: :delete, title: t('admin.delete'), \
5
+ = link_to icon('remove', true), '/admin/assets/${id}', remote: true, method: :delete, title: t('admin.delete'), \
6
6
  class: 'del_asset btn btn-danger btn-mini', data: {confirm: t('admin.delete_confirmation')}
@@ -1,5 +1,5 @@
1
1
  - if tmpl = admin_partial_name(search_builder)
2
- = render tmpl
2
+ = render tmpl, f: f
3
3
  - else
4
4
  - search_builder.fields.each do |field|
5
5
  = f.input field.data, field.options
@@ -1,14 +1,13 @@
1
1
  .batch_actions.clearfix
2
- - cache [I18n.locale, 'admin', resource_class.name, 'batch_actions'] do
3
- - if settings[:batch] && settings[:index_view] == 'table'
4
- .btn-group
5
- a.btn.dropdown-toggle data-toggle="dropdown" href="#"
6
- = t 'admin.batch_actions.title'
7
- span.caret
8
- ul.dropdown-menu
9
- - batch_action_list.each do |batch_action|
10
- li
11
- a.batch_action_link[href='#' data-action=batch_action.name data-confirm=batch_action.confirm]= batch_action.title
2
+ - if settings[:batch] && settings[:index_view] =~ /table/
3
+ .btn-group
4
+ a.btn.dropdown-toggle data-toggle="dropdown" href="#"
5
+ = t 'admin.batch_actions.title'
6
+ span.caret
7
+ ul.dropdown-menu
8
+ - batch_action_list.each do |batch_action|
9
+ li
10
+ a.batch_action_link[href='#' data-action=batch_action.name data-confirm=batch_action.confirm]= batch_action.title
12
11
  .btn-group.pjax_links
13
12
  - button_scopes.each do |name, opts|
14
13
  - active = params[opts[:as]]
@@ -6,8 +6,8 @@ html id="controller_#{controller_name}"
6
6
  meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"
7
7
  title= @page_title || 'Ab Admin'
8
8
  = stylesheet_link_tag 'ab_admin/application', media: 'all'
9
- script(src='//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js')
10
- script(src='//ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js')
9
+ /script(src='//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js')
10
+ /script(src='//ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js')
11
11
  = include_gon
12
12
  = javascript_include_tag 'ab_admin/application'
13
13
  = csrf_meta_tags
@@ -23,9 +23,7 @@ html id="controller_#{controller_name}"
23
23
  .clearfix[data-pjax-container=true class=layout_css]= yield
24
24
  - if collection_action? && settings[:search]
25
25
  .sidebar.well= render 'search_layout'
26
- - elsif content_for? :sidebar
27
- = yield :sidebar
28
- = yield :bottom
26
+ = yield :sidebar
29
27
  #loading.label.label-warning= t 'admin.loading'
30
28
  #push
31
29
  = render 'layouts/admin/footer'
@@ -109,12 +109,13 @@ ru:
109
109
  form:
110
110
  cancel: "Отмена"
111
111
  save: "Сохранить"
112
- save_and_add_another: "Сохранить и добавить новый"
113
- save_and_edit: "Сохранить и продолжить редактирование"
112
+ save_and_add_another: "Сохранить & новый"
113
+ save_and_edit: "Применить"
114
114
  save_and_edit_next: "Сохранить и след."
115
115
  save_and_edit_prev: "Сохранить и пред."
116
116
  details: "Подробнее"
117
117
  base: "Основное"
118
+ keywords: 'Мета теги'
118
119
  gender:
119
120
  female: "Женский"
120
121
  male: "Мужской"
@@ -2,8 +2,6 @@ Feature: Admin menu
2
2
 
3
3
  Background:
4
4
  Given I am logged in
5
-
6
- Scenario: Show menu tree
7
5
  Given i18n key "admin.navigation.system" with value "System"
8
6
  And i18n key "admin.navigation.for_admin" with value "for admin"
9
7
  And a menu configuration of:
@@ -22,9 +20,16 @@ Feature: Admin menu
22
20
  end
23
21
  end
24
22
  """
23
+
24
+ Scenario: Show menu tree
25
25
  When I am on the dashboard page
26
26
  Then I should see menu item for "User" with path "/admin/users"
27
27
  Then I should see menu item for "Settings" with path "/admin/settings/edit"
28
28
  And I should see group "System" with menu item for "Structure"
29
29
  And I should see group "Moderator" with menu item for "for moderator"
30
30
  And I should see group "Admin" with menu item for "for admin"
31
+
32
+ Scenario: Active menu link for current resource
33
+ When I am on the admin structures page
34
+ Then menu item for "Structure" should be active
35
+ And menu item for "User" should not be active
@@ -11,3 +11,10 @@ Then /^I should see group "(.*?)" with menu item for "(.*?)"$/ do |group, name|
11
11
  page.should have_css('header.navbar ul.dropdown-menu a', text: name)
12
12
  end
13
13
 
14
+ Then /^menu item for "(.*?)" should be active$/ do |link|
15
+ page.should have_css('header.navbar li.active a', text: link)
16
+ end
17
+
18
+ Then /^menu item for "(.*?)" should not be active$/ do |link|
19
+ page.should_not have_css('header.navbar li.active a', text: link)
20
+ end