activeadmin 1.4.3 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +70 -10
  3. data/CONTRIBUTING.md +12 -11
  4. data/README.md +34 -8
  5. data/app/assets/javascripts/active_admin/base.es6 +23 -0
  6. data/app/assets/javascripts/active_admin/ext/jquery-ui.es6 +7 -0
  7. data/app/assets/javascripts/active_admin/ext/jquery.es6 +9 -0
  8. data/app/assets/javascripts/active_admin/initializers/datepicker.es6 +16 -0
  9. data/app/assets/javascripts/active_admin/initializers/filters.es6 +45 -0
  10. data/app/assets/javascripts/active_admin/initializers/tabs.es6 +6 -0
  11. data/app/assets/javascripts/active_admin/lib/active_admin.es6 +41 -0
  12. data/app/assets/javascripts/active_admin/lib/batch_actions.es6 +55 -0
  13. data/app/assets/javascripts/active_admin/lib/checkbox-toggler.es6 +49 -0
  14. data/app/assets/javascripts/active_admin/lib/dropdown-menu.es6 +123 -0
  15. data/app/assets/javascripts/active_admin/lib/has_many.es6 +95 -0
  16. data/app/assets/javascripts/active_admin/lib/modal_dialog.es6 +61 -0
  17. data/app/assets/javascripts/active_admin/lib/per_page.es6 +47 -0
  18. data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.es6 +36 -0
  19. data/app/assets/stylesheets/active_admin/_forms.scss +2 -14
  20. data/app/assets/stylesheets/active_admin/components/_status_tags.scss +0 -5
  21. data/app/assets/stylesheets/active_admin/components/_tabs.scss +1 -1
  22. data/app/assets/stylesheets/active_admin/mixins/_gradients.scss +1 -1
  23. data/app/views/active_admin/devise/confirmations/new.html.erb +1 -1
  24. data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
  25. data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
  26. data/app/views/active_admin/devise/registrations/new.html.erb +1 -2
  27. data/app/views/active_admin/devise/shared/_error_messages.html.erb +15 -0
  28. data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
  29. data/app/views/layouts/active_admin_logged_out.html.erb +1 -1
  30. data/config/locales/bg.yml +0 -1
  31. data/config/locales/he.yml +0 -1
  32. data/config/locales/hu.yml +4 -0
  33. data/config/locales/lt.yml +2 -2
  34. data/config/locales/uk.yml +2 -0
  35. data/docs/0-installation.md +2 -2
  36. data/docs/13-authorization-adapter.md +4 -4
  37. data/docs/CNAME +1 -1
  38. data/docs/index.html +2 -2
  39. data/lib/active_admin.rb +9 -4
  40. data/lib/active_admin/application.rb +8 -14
  41. data/lib/active_admin/application_settings.rb +3 -0
  42. data/lib/active_admin/asset_registration.rb +0 -8
  43. data/lib/active_admin/base_controller.rb +6 -6
  44. data/lib/active_admin/base_controller/authorization.rb +2 -4
  45. data/lib/active_admin/batch_actions/controller.rb +1 -1
  46. data/lib/active_admin/batch_actions/resource_extension.rb +4 -4
  47. data/lib/active_admin/callbacks.rb +1 -1
  48. data/lib/active_admin/csv_builder.rb +1 -1
  49. data/lib/active_admin/dependency.rb +1 -77
  50. data/lib/active_admin/dsl.rb +1 -8
  51. data/lib/active_admin/error.rb +1 -1
  52. data/lib/active_admin/filters/active_filter.rb +3 -1
  53. data/lib/active_admin/filters/active_sidebar.rb +5 -1
  54. data/lib/active_admin/filters/forms.rb +2 -2
  55. data/lib/active_admin/filters/formtastic_addons.rb +1 -1
  56. data/lib/active_admin/filters/resource_extension.rb +3 -3
  57. data/lib/active_admin/form_builder.rb +3 -3
  58. data/lib/active_admin/generators/boilerplate.rb +1 -1
  59. data/lib/active_admin/helpers/scope_chain.rb +1 -0
  60. data/lib/active_admin/inputs/datepicker_input.rb +1 -1
  61. data/lib/active_admin/inputs/filters/base/search_method_select.rb +2 -2
  62. data/lib/active_admin/menu_item.rb +1 -1
  63. data/lib/active_admin/namespace.rb +2 -2
  64. data/lib/active_admin/namespace_settings.rb +7 -4
  65. data/lib/active_admin/orm/active_record/comments.rb +4 -4
  66. data/lib/active_admin/orm/active_record/comments/comment.rb +2 -2
  67. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +10 -5
  68. data/lib/active_admin/page_dsl.rb +1 -1
  69. data/lib/active_admin/pundit_adapter.rb +13 -4
  70. data/lib/active_admin/resource.rb +2 -2
  71. data/lib/active_admin/resource/action_items.rb +1 -1
  72. data/lib/active_admin/resource/attributes.rb +7 -4
  73. data/lib/active_admin/resource/menu.rb +3 -3
  74. data/lib/active_admin/resource/naming.rb +3 -3
  75. data/lib/active_admin/resource/routes.rb +9 -4
  76. data/lib/active_admin/resource/scopes.rb +3 -3
  77. data/lib/active_admin/resource/sidebars.rb +1 -1
  78. data/lib/active_admin/resource_collection.rb +2 -2
  79. data/lib/active_admin/resource_controller/action_builder.rb +10 -0
  80. data/lib/active_admin/resource_controller/resource_class_methods.rb +2 -0
  81. data/lib/active_admin/resource_dsl.rb +5 -3
  82. data/lib/active_admin/router.rb +1 -1
  83. data/lib/active_admin/scope.rb +4 -4
  84. data/lib/active_admin/settings_node.rb +1 -1
  85. data/lib/active_admin/version.rb +1 -1
  86. data/lib/active_admin/view_helpers.rb +1 -1
  87. data/lib/active_admin/view_helpers/display_helper.rb +10 -2
  88. data/lib/active_admin/view_helpers/download_format_links_helper.rb +1 -0
  89. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +2 -0
  90. data/lib/active_admin/views.rb +1 -1
  91. data/lib/active_admin/views/components/active_admin_form.rb +7 -1
  92. data/lib/active_admin/views/components/attributes_table.rb +3 -3
  93. data/lib/active_admin/views/components/paginated_collection.rb +1 -1
  94. data/lib/active_admin/views/components/sidebar_section.rb +0 -3
  95. data/lib/active_admin/views/components/status_tag.rb +1 -18
  96. data/lib/active_admin/views/components/table_for.rb +2 -2
  97. data/lib/active_admin/views/components/tabs.rb +11 -2
  98. data/lib/active_admin/views/footer.rb +1 -1
  99. data/lib/active_admin/views/index_as_table.rb +5 -4
  100. data/lib/active_admin/views/pages/base.rb +3 -0
  101. data/lib/generators/active_admin/assets/assets_generator.rb +2 -2
  102. data/lib/generators/active_admin/assets/templates/active_admin.js +1 -0
  103. data/lib/generators/active_admin/install/install_generator.rb +6 -2
  104. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +20 -1
  105. data/lib/generators/active_admin/install/templates/dashboard.rb +2 -3
  106. data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb +1 -15
  107. data/lib/generators/active_admin/page/page_generator.rb +1 -1
  108. data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
  109. data/lib/ransack_ext.rb +3 -3
  110. data/vendor/assets/javascripts/jquery-ui/form-reset-mixin.js +80 -0
  111. data/vendor/assets/javascripts/jquery-ui/form.js +22 -0
  112. data/vendor/assets/javascripts/jquery-ui/labels.js +65 -0
  113. data/vendor/assets/javascripts/jquery-ui/widgets/checkboxradio.js +274 -283
  114. metadata +107 -96
  115. data/.circleci/config.yml +0 -572
  116. data/.github/ISSUE_TEMPLATE.md +0 -20
  117. data/.gitignore +0 -16
  118. data/.mdlrc +0 -1
  119. data/.rspec +0 -1
  120. data/.rspec_parallel +0 -2
  121. data/.rubocop.yml +0 -99
  122. data/.simplecov +0 -9
  123. data/.yardopts +0 -7
  124. data/Gemfile +0 -30
  125. data/Gemfile.common +0 -26
  126. data/Gemfile.lock +0 -433
  127. data/Rakefile +0 -24
  128. data/activeadmin.gemspec +0 -32
  129. data/app/assets/javascripts/active_admin/base.js.coffee +0 -13
  130. data/app/assets/javascripts/active_admin/ext/jquery-ui.js.coffee +0 -6
  131. data/app/assets/javascripts/active_admin/ext/jquery.js.coffee +0 -7
  132. data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +0 -11
  133. data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +0 -14
  134. data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +0 -26
  135. data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +0 -7
  136. data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +0 -42
  137. data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +0 -46
  138. data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +0 -104
  139. data/app/assets/javascripts/active_admin/lib/flash.js.coffee +0 -19
  140. data/app/assets/javascripts/active_admin/lib/has_many.js.coffee +0 -79
  141. data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +0 -45
  142. data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +0 -46
  143. data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.js.coffee +0 -22
  144. data/bin/install_chromedriver.sh +0 -17
  145. data/config/i18n-tasks.yml +0 -26
  146. data/config/mdl_style.rb +0 -11
  147. data/cucumber.yml +0 -7
  148. data/gemfiles/rails_42.gemfile +0 -10
  149. data/gemfiles/rails_42.gemfile.lock +0 -339
  150. data/gemfiles/rails_50.gemfile +0 -10
  151. data/gemfiles/rails_50.gemfile.lock +0 -353
  152. data/gemfiles/rails_51.gemfile +0 -10
  153. data/gemfiles/rails_51.gemfile.lock +0 -353
  154. data/lib/active_admin/event.rb +0 -24
  155. data/lib/active_admin/helpers/output_safety_helper.rb +0 -35
  156. data/lib/bug_report_templates/active_admin_master.rb +0 -111
  157. data/lib/generators/active_admin/assets/templates/active_admin.js.coffee +0 -1
  158. data/tasks/application_generator.rb +0 -50
  159. data/tasks/docs.rake +0 -64
  160. data/tasks/gemfiles.rake +0 -8
  161. data/tasks/lint.rake +0 -110
  162. data/tasks/local.rake +0 -27
  163. data/tasks/release.rake +0 -6
  164. data/tasks/test.rake +0 -42
@@ -102,7 +102,7 @@ module ActiveAdmin
102
102
  # you pass in the :total_pages option. We issue a query to determine
103
103
  # if there is another page or not, but the limit/offset make this
104
104
  # query fast.
105
- offset = collection.offset(collection.current_page * @per_page.to_i).limit(1).count
105
+ offset = collection.offset(collection.current_page * collection.limit_value).limit(1).count
106
106
  options[:total_pages] = collection.current_page + offset
107
107
  options[:right] = 0
108
108
  end
@@ -1,11 +1,8 @@
1
- require 'active_admin/helpers/output_safety_helper'
2
-
3
1
  module ActiveAdmin
4
2
  module Views
5
3
 
6
4
  class SidebarSection < Panel
7
5
  builder_method :sidebar_section
8
- include OutputSafetyHelper
9
6
 
10
7
  # Takes a ActiveAdmin::SidebarSection instance
11
8
  def build(section)
@@ -28,11 +28,7 @@ module ActiveAdmin
28
28
  # status_tag('active', class: 'important', id: 'status_123', label: 'on')
29
29
  # # => <span class='status_tag active important' id='status_123'>on</span>
30
30
  #
31
- def build(*args)
32
- options = args.extract_options!
33
- status = args[0]
34
- type = args[1]
35
-
31
+ def build(status, options = {})
36
32
  label = options.delete(:label)
37
33
  classes = options.delete(:class)
38
34
  status = convert_to_boolean_status(status)
@@ -46,19 +42,6 @@ module ActiveAdmin
46
42
  super(content, options)
47
43
 
48
44
  add_class(status_to_class(status)) if status
49
-
50
- if type
51
- Deprecation.warn <<-MSG.strip_heredoc
52
- The `type` parameter has been deprecated. Provide the "#{type}" type as
53
- a class instead. For example, `status_tag(status, :#{type}, class: "abc")`
54
- would change to `status_tag(status, class: "#{type} abc")`. Also note that
55
- the "#{type}" CSS rule will be removed too, so you'll have to provide
56
- the styles yourself. See https://github.com/activeadmin/activeadmin/blob/master/CHANGELOG.md#110-
57
- for more information.
58
- MSG
59
- add_class(type.to_s)
60
- end
61
-
62
45
  add_class(classes) if classes
63
46
  end
64
47
 
@@ -22,7 +22,7 @@ module ActiveAdmin
22
22
  end
23
23
 
24
24
  def columns(*attrs)
25
- attrs.each {|attr| column(attr) }
25
+ attrs.each { |attr| column(attr) }
26
26
  end
27
27
 
28
28
  def column(*args, &block)
@@ -147,7 +147,7 @@ module ActiveAdmin
147
147
  if @options.has_key?(:class)
148
148
  html_classes << @options.delete(:class)
149
149
  elsif @title.present?
150
- html_classes << "col-#{ActiveAdmin::Dependency.rails.parameterize(@title.to_s)}"
150
+ html_classes << "col-#{@title.to_s.parameterize(separator: "_")}"
151
151
  end
152
152
  @html_class = html_classes.join(' ')
153
153
  @data = args[1] || args[0]
@@ -15,7 +15,8 @@ module ActiveAdmin
15
15
  end
16
16
 
17
17
  def build_menu_item(title, options, &block)
18
- fragment = options.fetch(:id, title.parameterize)
18
+ fragment = options.fetch(:id, fragmentize(title))
19
+
19
20
  html_options = options.fetch(:html_options, {})
20
21
  li html_options do
21
22
  link_to title, "##{fragment}"
@@ -23,9 +24,17 @@ module ActiveAdmin
23
24
  end
24
25
 
25
26
  def build_content_item(title, options, &block)
26
- options = options.reverse_merge(id: title.parameterize)
27
+ options = options.reverse_merge(id: fragmentize(title))
27
28
  div(options, &block)
28
29
  end
30
+
31
+ private
32
+
33
+ def fragmentize(string)
34
+ result = string.parameterize
35
+ result = URI.encode(string) if result.blank?
36
+ result
37
+ end
29
38
  end
30
39
  end
31
40
  end
@@ -21,7 +21,7 @@ module ActiveAdmin
21
21
 
22
22
  def powered_by_message
23
23
  I18n.t('active_admin.powered_by',
24
- active_admin: link_to("Active Admin", "http://www.activeadmin.info"),
24
+ active_admin: link_to("Active Admin", "https://activeadmin.info"),
25
25
  version: ActiveAdmin::VERSION).html_safe
26
26
  end
27
27
 
@@ -365,15 +365,16 @@ module ActiveAdmin
365
365
  private
366
366
 
367
367
  def defaults(resource, options = {})
368
+ localizer = ActiveAdmin::Localizers.resource(active_admin_config)
368
369
  if controller.action_methods.include?('show') && authorized?(ActiveAdmin::Auth::READ, resource)
369
- item I18n.t('active_admin.view'), resource_path(resource), class: "view_link #{options[:css_class]}", title: I18n.t('active_admin.view')
370
+ item localizer.t(:view), resource_path(resource), class: "view_link #{options[:css_class]}", title: localizer.t(:view)
370
371
  end
371
372
  if controller.action_methods.include?('edit') && authorized?(ActiveAdmin::Auth::UPDATE, resource)
372
- item I18n.t('active_admin.edit'), edit_resource_path(resource), class: "edit_link #{options[:css_class]}", title: I18n.t('active_admin.edit')
373
+ item localizer.t(:edit), edit_resource_path(resource), class: "edit_link #{options[:css_class]}", title: localizer.t(:edit)
373
374
  end
374
375
  if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
375
- item I18n.t('active_admin.delete'), resource_path(resource), class: "delete_link #{options[:css_class]}", title: I18n.t('active_admin.delete'),
376
- method: :delete, data: {confirm: I18n.t('active_admin.delete_confirmation')}
376
+ item localizer.t(:delete), resource_path(resource), class: "delete_link #{options[:css_class]}", title: localizer.t(:delete),
377
+ method: :delete, data: { confirm: localizer.t(:delete_confirmation) }
377
378
  end
378
379
  end
379
380
 
@@ -4,6 +4,7 @@ module ActiveAdmin
4
4
  class Base < Arbre::HTML::Document
5
5
 
6
6
  def build(*args)
7
+ set_attribute :lang, I18n.locale
7
8
  build_active_admin_head
8
9
  build_page
9
10
  end
@@ -25,6 +26,8 @@ module ActiveAdmin
25
26
  within head do
26
27
  html_title [title, helpers.active_admin_namespace.site_title(self)].compact.join(" | ")
27
28
 
29
+ text_node(active_admin_namespace.head)
30
+
28
31
  active_admin_application.stylesheets.each do |style, options|
29
32
  text_node stylesheet_link_tag(style, options).html_safe
30
33
  end
@@ -2,10 +2,10 @@ module ActiveAdmin
2
2
  module Generators
3
3
  class AssetsGenerator < Rails::Generators::Base
4
4
 
5
- source_root File.expand_path("../templates", __FILE__)
5
+ source_root File.expand_path('templates', __dir__)
6
6
 
7
7
  def install_assets
8
- template 'active_admin.js.coffee', 'app/assets/javascripts/active_admin.js.coffee'
8
+ template 'active_admin.js', 'app/assets/javascripts/active_admin.js'
9
9
  template "active_admin.scss", "app/assets/stylesheets/active_admin.scss"
10
10
  end
11
11
 
@@ -0,0 +1 @@
1
+ //= require active_admin/base
@@ -7,12 +7,14 @@ module ActiveAdmin
7
7
  argument :name, type: :string, default: "AdminUser"
8
8
 
9
9
  hook_for :users, default: "devise", desc: "Admin user generator to run. Skip with --skip-users"
10
+ class_option :skip_comments, type: :boolean, default: false, desc: "Skip installation of comments"
10
11
 
11
- source_root File.expand_path("../templates", __FILE__)
12
+ source_root File.expand_path('templates', __dir__)
12
13
 
13
14
  def copy_initializer
14
15
  @underscored_user_name = name.underscore.gsub('/', '_')
15
16
  @use_authentication_method = options[:users].present?
17
+ @skip_comments = options[:skip_comments]
16
18
  template 'active_admin.rb.erb', 'config/initializers/active_admin.rb'
17
19
  end
18
20
 
@@ -38,7 +40,9 @@ module ActiveAdmin
38
40
  end
39
41
 
40
42
  def create_migrations
41
- migration_template 'migrations/create_active_admin_comments.rb.erb', 'db/migrate/create_active_admin_comments.rb'
43
+ unless options[:skip_comments]
44
+ migration_template 'migrations/create_active_admin_comments.rb.erb', 'db/migrate/create_active_admin_comments.rb'
45
+ end
42
46
  end
43
47
  end
44
48
  end
@@ -69,6 +69,11 @@ ActiveAdmin.setup do |config|
69
69
  # case when Pundit is unable to find suitable policy.
70
70
  # config.pundit_default_policy = "MyDefaultPunditPolicy"
71
71
 
72
+ # If you wish to maintain a separate set of Pundit policies for admin
73
+ # resources, you may set a namespace here that Pundit will search
74
+ # within when looking for a resource's policy.
75
+ # config.pundit_policy_namespace = :admin
76
+
72
77
  # You can customize your CanCan Ability class name here.
73
78
  # config.cancan_ability_class = "Ability"
74
79
 
@@ -119,7 +124,7 @@ ActiveAdmin.setup do |config|
119
124
  # This allows your users to comment on any resource registered with Active Admin.
120
125
  #
121
126
  # You can completely disable comments:
122
- # config.comments = false
127
+ <% unless @skip_comments %># <% end %>config.comments = false
123
128
  #
124
129
  # You can change the name under which comments are registered:
125
130
  # config.comments_registration_name = 'AdminComment'
@@ -147,6 +152,13 @@ ActiveAdmin.setup do |config|
147
152
  #
148
153
  # config.before_action :do_something_awesome
149
154
 
155
+ # == Attribute Filters
156
+ #
157
+ # You can exclude possibly sensitive model attributes from being displayed,
158
+ # added to forms, or exported by default by ActiveAdmin
159
+ #
160
+ config.filter_attributes = [:encrypted_password, :password, :password_confirmation]
161
+
150
162
  # == Localize Date/Time Format
151
163
  #
152
164
  # Set the localize format to display dates and times.
@@ -277,6 +289,13 @@ ActiveAdmin.setup do |config|
277
289
  #
278
290
  # config.include_default_association_filters = true
279
291
 
292
+ # == Head
293
+ #
294
+ # You can add your own content to the site head like analytics. Make sure
295
+ # you only pass content you trust.
296
+ #
297
+ # config.head = ''.html_safe
298
+
280
299
  # == Footer
281
300
  #
282
301
  # By default, the footer shows the current Active Admin version. You can
@@ -1,8 +1,7 @@
1
1
  ActiveAdmin.register_page "Dashboard" do
2
+ menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }
2
3
 
3
- menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
4
-
5
- content title: proc{ I18n.t("active_admin.dashboard") } do
4
+ content title: proc { I18n.t("active_admin.dashboard") } do
6
5
  div class: "blank_slate_container", id: "dashboard_default_message" do
7
6
  span class: "blank_slate" do
8
7
  span I18n.t("active_admin.dashboard_welcome.welcome")
@@ -1,27 +1,13 @@
1
- <%
2
- parent_class = ActiveRecord::Migration
3
- parent_class = parent_class[parent_class.current_version] if Rails::VERSION::MAJOR >= 5
4
- -%>
5
- class CreateActiveAdminComments < <%= parent_class.to_s %>
1
+ class CreateActiveAdminComments < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version.to_s %>]
6
2
  def self.up
7
3
  create_table :active_admin_comments do |t|
8
4
  t.string :namespace
9
5
  t.text :body
10
6
  t.references :resource, polymorphic: true
11
7
  t.references :author, polymorphic: true
12
- <%- if Rails::VERSION::MAJOR >= 5 -%>
13
8
  t.timestamps
14
- <%- else -%>
15
- t.timestamps null: false
16
- <%- end -%>
17
9
  end
18
10
  add_index :active_admin_comments, [:namespace]
19
- <%- unless Rails::VERSION::MAJOR >= 5 -%>
20
-
21
- add_index :active_admin_comments, [:author_type, :author_id]
22
- add_index :active_admin_comments, [:resource_type, :resource_id]
23
- <%- end -%>
24
-
25
11
  end
26
12
 
27
13
  def self.down
@@ -1,7 +1,7 @@
1
1
  module ActiveAdmin
2
2
  module Generators
3
3
  class PageGenerator < Rails::Generators::NamedBase
4
- source_root File.expand_path('../templates', __FILE__)
4
+ source_root File.expand_path('templates', __dir__)
5
5
 
6
6
  def generate_config_file
7
7
  template "page.rb", "app/admin/#{file_path.tr('/', '_')}.rb"
@@ -8,7 +8,7 @@ module ActiveAdmin
8
8
  class_option :include_boilerplate, type: :boolean, default: false,
9
9
  desc: "Generate boilerplate code for your resource."
10
10
 
11
- source_root File.expand_path("../templates", __FILE__)
11
+ source_root File.expand_path('templates', __dir__)
12
12
 
13
13
  def generate_config_file
14
14
  @boilerplate = ActiveAdmin::Generators::Boilerplate.new(class_name)
@@ -2,11 +2,11 @@
2
2
  # identically to the versions given in Ransack.
3
3
  #
4
4
  Ransack.configure do |config|
5
- {'contains'=>'cont', 'starts_with'=>'start', 'ends_with'=>'end'}.each do |old, current|
6
- config.add_predicate old, Ransack::Constants::DERIVED_PREDICATES.detect{ |q, _| q == current }[1]
5
+ { 'contains'=>'cont', 'starts_with'=>'start', 'ends_with'=>'end' }.each do |old, current|
6
+ config.add_predicate old, Ransack::Constants::DERIVED_PREDICATES.detect { |q, _| q == current }[1]
7
7
  end
8
8
 
9
- {'equals'=>'eq', 'greater_than'=>'gt', 'less_than'=>'lt'}.each do |old, current|
9
+ { 'equals'=>'eq', 'greater_than'=>'gt', 'less_than'=>'lt' }.each do |old, current|
10
10
  config.add_predicate old, arel_predicate: current
11
11
  end
12
12
 
@@ -0,0 +1,80 @@
1
+ //= require jquery-ui/form
2
+ //= require jquery-ui/version
3
+
4
+ /*!
5
+ * jQuery UI Form Reset Mixin 1.12.1
6
+ * http://jqueryui.com
7
+ *
8
+ * Copyright jQuery Foundation and other contributors
9
+ * Released under the MIT license.
10
+ * http://jquery.org/license
11
+ */
12
+
13
+ //>>label: Form Reset Mixin
14
+ //>>group: Core
15
+ //>>description: Refresh input widgets when their form is reset
16
+ //>>docs: http://api.jqueryui.com/form-reset-mixin/
17
+
18
+ ( function( factory ) {
19
+ if ( typeof define === "function" && define.amd ) {
20
+
21
+ // AMD. Register as an anonymous module.
22
+ define( [
23
+ "jquery",
24
+ "./form",
25
+ "./version"
26
+ ], factory );
27
+ } else {
28
+
29
+ // Browser globals
30
+ factory( jQuery );
31
+ }
32
+ }( function( $ ) {
33
+
34
+ return $.ui.formResetMixin = {
35
+ _formResetHandler: function() {
36
+ var form = $( this );
37
+
38
+ // Wait for the form reset to actually happen before refreshing
39
+ setTimeout( function() {
40
+ var instances = form.data( "ui-form-reset-instances" );
41
+ $.each( instances, function() {
42
+ this.refresh();
43
+ } );
44
+ } );
45
+ },
46
+
47
+ _bindFormResetHandler: function() {
48
+ this.form = this.element.form();
49
+ if ( !this.form.length ) {
50
+ return;
51
+ }
52
+
53
+ var instances = this.form.data( "ui-form-reset-instances" ) || [];
54
+ if ( !instances.length ) {
55
+
56
+ // We don't use _on() here because we use a single event handler per form
57
+ this.form.on( "reset.ui-form-reset", this._formResetHandler );
58
+ }
59
+ instances.push( this );
60
+ this.form.data( "ui-form-reset-instances", instances );
61
+ },
62
+
63
+ _unbindFormResetHandler: function() {
64
+ if ( !this.form.length ) {
65
+ return;
66
+ }
67
+
68
+ var instances = this.form.data( "ui-form-reset-instances" );
69
+ instances.splice( $.inArray( this, instances ), 1 );
70
+ if ( instances.length ) {
71
+ this.form.data( "ui-form-reset-instances", instances );
72
+ } else {
73
+ this.form
74
+ .removeData( "ui-form-reset-instances" )
75
+ .off( "reset.ui-form-reset" );
76
+ }
77
+ }
78
+ };
79
+
80
+ } ) );
@@ -0,0 +1,22 @@
1
+ //= require jquery-ui/version
2
+
3
+ ( function( factory ) {
4
+ if ( typeof define === "function" && define.amd ) {
5
+
6
+ // AMD. Register as an anonymous module.
7
+ define( [ "jquery", "./version" ], factory );
8
+ } else {
9
+
10
+ // Browser globals
11
+ factory( jQuery );
12
+ }
13
+ } ( function( $ ) {
14
+
15
+ // Support: IE8 Only
16
+ // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
17
+ // with a string, so we need to find the proper form.
18
+ return $.fn.form = function() {
19
+ return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
20
+ };
21
+
22
+ } ) );
@@ -0,0 +1,65 @@
1
+ //= require jquery-ui/version
2
+ //= require jquery-ui/escape-selector
3
+
4
+ /*!
5
+ * jQuery UI Labels 1.12.1
6
+ * http://jqueryui.com
7
+ *
8
+ * Copyright jQuery Foundation and other contributors
9
+ * Released under the MIT license.
10
+ * http://jquery.org/license
11
+ */
12
+
13
+ //>>label: labels
14
+ //>>group: Core
15
+ //>>description: Find all the labels associated with a given input
16
+ //>>docs: http://api.jqueryui.com/labels/
17
+
18
+ ( function( factory ) {
19
+ if ( typeof define === "function" && define.amd ) {
20
+
21
+ // AMD. Register as an anonymous module.
22
+ define( [ "jquery", "./version", "./escape-selector" ], factory );
23
+ } else {
24
+
25
+ // Browser globals
26
+ factory( jQuery );
27
+ }
28
+ } ( function( $ ) {
29
+
30
+ return $.fn.labels = function() {
31
+ var ancestor, selector, id, labels, ancestors;
32
+
33
+ // Check control.labels first
34
+ if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
35
+ return this.pushStack( this[ 0 ].labels );
36
+ }
37
+
38
+ // Support: IE <= 11, FF <= 37, Android <= 2.3 only
39
+ // Above browsers do not support control.labels. Everything below is to support them
40
+ // as well as document fragments. control.labels does not work on document fragments
41
+ labels = this.eq( 0 ).parents( "label" );
42
+
43
+ // Look for the label based on the id
44
+ id = this.attr( "id" );
45
+ if ( id ) {
46
+
47
+ // We don't search against the document in case the element
48
+ // is disconnected from the DOM
49
+ ancestor = this.eq( 0 ).parents().last();
50
+
51
+ // Get a full set of top level ancestors
52
+ ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
53
+
54
+ // Create a selector for the label based on the id
55
+ selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
56
+
57
+ labels = labels.add( ancestors.find( selector ).addBack( selector ) );
58
+
59
+ }
60
+
61
+ // Return whatever we have found for labels
62
+ return this.pushStack( labels );
63
+ };
64
+
65
+ } ) );