godmin 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +2 -2
  4. data/.travis.yml +12 -5
  5. data/Appraisals +7 -0
  6. data/CHANGELOG.md +18 -2
  7. data/README.md +3 -3
  8. data/Rakefile +2 -1
  9. data/app/assets/javascripts/godmin/batch-actions.js +10 -1
  10. data/app/views/godmin/resource/_batch_actions.html.erb +1 -1
  11. data/app/views/godmin/resource/_export_actions.html.erb +2 -2
  12. data/app/views/godmin/resource/_pagination.html.erb +5 -5
  13. data/app/views/godmin/resource/_scopes.html.erb +1 -1
  14. data/app/views/godmin/resource/_table.html.erb +3 -3
  15. data/app/views/godmin/resource/columns/_actions.html.erb +20 -4
  16. data/app/views/layouts/godmin/login.html.erb +1 -1
  17. data/config/locales/en.yml +3 -0
  18. data/config/locales/pt-BR.yml +3 -0
  19. data/config/locales/sv.yml +3 -0
  20. data/gemfiles/rails_4.gemfile +9 -0
  21. data/gemfiles/rails_5.gemfile +9 -0
  22. data/godmin.gemspec +19 -18
  23. data/lib/godmin/application_controller.rb +11 -0
  24. data/lib/godmin/authorization.rb +1 -1
  25. data/lib/godmin/helpers/application.rb +9 -2
  26. data/lib/godmin/helpers/batch_actions.rb +1 -9
  27. data/lib/godmin/helpers/filters.rb +17 -10
  28. data/lib/godmin/helpers/forms.rb +3 -1
  29. data/lib/godmin/helpers/tables.rb +1 -1
  30. data/lib/godmin/resources/resource_controller/batch_actions.rb +1 -1
  31. data/lib/godmin/resources/resource_service/batch_actions.rb +14 -0
  32. data/lib/godmin/version.rb +1 -1
  33. data/template.rb +4 -24
  34. data/test/dummy/admin/admin.gemspec +1 -1
  35. data/test/dummy/app/services/article_service.rb +18 -3
  36. data/test/dummy/config/environments/test.rb +8 -2
  37. data/test/dummy/db/schema.rb +0 -1
  38. data/test/fakes/article_service.rb +1 -1
  39. data/test/integration/batch_actions_test.rb +30 -1
  40. data/test/integration/filters_test.rb +15 -0
  41. data/test/integration/scopes_test.rb +1 -1
  42. data/test/lib/godmin/helpers/filters_test.rb +32 -6
  43. data/test/lib/godmin/resources/resource_service/batch_actions_test.rb +1 -1
  44. metadata +88 -63
  45. data/test/dummy/admin/Rakefile +0 -24
  46. data/test/dummy/admin/app/helpers/admin/application_helper.rb +0 -4
  47. data/test/dummy/app/controllers/concerns/.keep +0 -0
  48. data/test/dummy/app/helpers/application_helper.rb +0 -2
  49. data/test/dummy/app/models/concerns/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5485225c54b1b8d9dec2a7d5d01aafe12f6109fa
4
- data.tar.gz: f9ccde13580100c1134bc45701bd4e06cd4222f7
3
+ metadata.gz: 43049a2e50fce4f665099b88786fd13cda3d1e58
4
+ data.tar.gz: 4ddd3cf185bcca97a1d50d37893cf760a5d3ebf7
5
5
  SHA512:
6
- metadata.gz: f2312da3947f533300714a819f812d1d2bfbffafe20d93fbf6a74c8aff1262e3587218e3116d7edf64d16248ff78022f7fe2addf103adfe6e26c863aada8e297
7
- data.tar.gz: 34df58f5528358d065426c1ffae18619b1f431ec341ab9bfc5de4344b2bfdfbd2c3590702674ddb8d3b76d9ccc20742ba71c1b0a4317644a99e955d0adc7205c
6
+ metadata.gz: b8ed426f1242d6054da877458cd5dd81e25ca8a30133edd0a0e3a44e34db3a616138c01d2c332444dd3f0df716992efc15265f9285ac746581e63f0b1fd0aba4
7
+ data.tar.gz: 74131a43082434db552085b31fc767610545c36cb7f64f6fc39838f814349b0070bf38fde927d07fc0514f9e998acbcc04e863643f2ff3caf6d24cddd98f658d
data/.gitignore CHANGED
@@ -25,3 +25,5 @@ config/initializers/secret_token.rb
25
25
  /test/dummy/db/*.sqlite3
26
26
  Gemfile.lock
27
27
  .tags
28
+ gemfiles/.bundle
29
+ gemfiles/*.lock
@@ -1,5 +1,5 @@
1
- AllCops:
2
- RunRailsCops: true
1
+ Rails:
2
+ Enabled: true
3
3
 
4
4
  Documentation:
5
5
  Enabled: false
@@ -1,13 +1,20 @@
1
1
  bundler_args: --without debug
2
-
2
+ cache: bundler
3
3
  script: "bundle exec rake test"
4
4
  sudo: false
5
- cache: bundler
6
5
 
7
6
  rvm:
8
- - 2.0.0
9
- - 2.1
10
- - 2.2
7
+ - 2.1.0
8
+ - 2.3.1
9
+
10
+ gemfile:
11
+ - gemfiles/rails_4.gemfile
12
+ - gemfiles/rails_5.gemfile
13
+
14
+ matrix:
15
+ exclude:
16
+ - rvm: 2.1.0
17
+ gemfile: gemfiles/rails_5.gemfile
11
18
 
12
19
  addons:
13
20
  code_climate:
@@ -0,0 +1,7 @@
1
+ appraise "rails-4" do
2
+ gem "rails", "~> 4.0"
3
+ end
4
+
5
+ appraise "rails-5" do
6
+ gem "rails", "~> 5.0"
7
+ end
@@ -1,11 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.3.0 - 2016-07-11
4
+ Features
5
+ - Increased batch action checkbox click area (https://github.com/varvet/godmin/pull/183)
6
+ - Adds titles to action links (https://github.com/varvet/godmin/pull/185)
7
+ - Rails 5 support (https://github.com/varvet/godmin/pull/199)
8
+
9
+ Bug fixes
10
+ - Use translated title on login page (https://github.com/varvet/godmin/pull/195)
11
+ - Hide batch action toggle when no batch action available (https://github.com/varvet/godmin/pull/197)
12
+ - Remove hidden field for multiselect filters (https://github.com/varvet/godmin/pull/169)
13
+
14
+ Other
15
+ - Fixes a deprecation warning on Rails 4.2.5.1 (https://github.com/varvet/godmin/pull/188)
16
+ - Adds caching partial overrides to increase table rendering speed (https://github.com/varvet/godmin/pull/184)
17
+
3
18
  ### 1.2.0 - 2016-02-02
4
19
  Features
5
20
  - Adds support for custom ordering of columns (https://github.com/varvet/godmin/pull/168)
6
- - Adds passing of html options to association helper (https://github.com/varvet/godmin/pull/176)
21
+ - Adds passing of options to association form helper (https://github.com/varvet/godmin/pull/172)
22
+ - Adds passing of html options to association form helper (https://github.com/varvet/godmin/pull/176)
7
23
 
8
- Bug fixes:
24
+ Bug fixes
9
25
  - Fixes an issue with the template resolver and Rails 4.2.5.1 (https://github.com/varvet/godmin/pull/175)
10
26
 
11
27
  ### 1.1.0 - 2015-12-08
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Code Climate](https://img.shields.io/codeclimate/github/varvet/godmin.svg)](https://codeclimate.com/github/varvet/godmin)
6
6
  [![Test Coverage](https://codeclimate.com/github/varvet/godmin/badges/coverage.svg)](https://codeclimate.com/github/varvet/godmin/coverage)
7
7
 
8
- Godmin is an admin framework for Rails 4+. Use it to build dedicated admin sections for your apps, or stand alone admin apps such as internal tools. It has support for common features such as scoping, filtering and performing batch actions on your models. [Try the demo](http://godmin-sandbox.herokuapp.com).
8
+ Godmin is an admin framework for Rails 4+. Use it to build dedicated admin sections for your apps, or stand alone admin apps such as internal tools. It has support for common features such as scoping, filtering and performing batch actions on your models. Check out the [demo app](http://godmin-sandbox.herokuapp.com) and its [source code](https://github.com/varvet/godmin-sandbox) to get a feel for how it works.
9
9
 
10
10
  Godmin differs from tools like [ActiveAdmin](http://activeadmin.info/) and [RailsAdmin](https://github.com/sferik/rails_admin) in how admin sections are created. Rather than being DSL-based, Godmin is a set of opt-in modules and helpers that can be applied to regular Rails apps and engines. An admin section built with Godmin is just that, a regular Rails app or Rails engine, with regular routes, controllers and views. That means there is less to learn, because you already know most of it, and fewer constraints on what you can do. After all, administrators are users too, and what better way to provide them with a tailor made experience than building them a Rails app?
11
11
 
@@ -536,8 +536,8 @@ end
536
536
  It's easy to override view templates and partials in Godmin, both globally and per resource. All you have to do is place a file with an identical name in your `app/views` directory. For instance, to override the `godmin/resource/index.html.erb` template for all resources, place a file under `app/views/resource/index.html.erb`. If you only wish to override it for articles, place it instead under `app/views/articles/index.html.erb`.
537
537
 
538
538
  You can also inherit from the default template as such:
539
- ```ruby
540
- <%= render template: 'godmin/resource/show' %>
539
+ ```erb
540
+ <%= render template: "godmin/resource/show" %>
541
541
 
542
542
  <p>Append stuff here</p>
543
543
  ```
data/Rakefile CHANGED
@@ -25,13 +25,14 @@ Rake::TestTask.new(:test) do |t|
25
25
  t.libs << "lib"
26
26
  t.libs << "test"
27
27
  t.pattern = "test/**/*_test.rb"
28
+ t.warning = false
28
29
  t.verbose = false
29
30
  end
30
31
 
31
32
  task default: :test
32
33
 
33
34
  namespace :sandbox do
34
- desc "Push the sandbox app to GitHub which deploys it to Heroku"
35
+ desc "Generate the Sandbox app then push it to GitHub which deploys it to Heroku"
35
36
  task :deploy do
36
37
  message = "Generated from: https://github.com/varvet/godmin/commit/#{`git rev-parse HEAD`.strip}"
37
38
  template_path = File.expand_path("../template.rb", __FILE__)
@@ -16,6 +16,7 @@ Godmin.BatchActions = (function() {
16
16
 
17
17
  function initializeEvents() {
18
18
  $container.find('[data-behavior~=batch-actions-select]').on('click', toggleCheckboxes);
19
+ $container.find('[data-behavior~=batch-actions-checkbox-container]').on('click', toggleCheckbox);
19
20
  $container.find('[data-behavior~=batch-actions-checkbox]').on('change', toggleActions);
20
21
  $(document).delegate('[data-behavior~=batch-actions-action-link]', 'mousedown', triggerAction);
21
22
  }
@@ -38,7 +39,15 @@ Godmin.BatchActions = (function() {
38
39
  }).toArray().join(',');
39
40
  }
40
41
 
41
- function toggleCheckboxes() {
42
+ function toggleCheckbox(e) {
43
+ if (this == e.target) {
44
+ $(this).find('[data-behavior~=batch-actions-checkbox]').click();
45
+ }
46
+ }
47
+
48
+ function toggleCheckboxes(e) {
49
+ e.preventDefault();
50
+
42
51
  if (checkedCheckboxes().length > 0) {
43
52
  $container.find('[data-behavior~=batch-actions-checkbox]').prop('checked', false).trigger('change');
44
53
  setSelectToAll();
@@ -1,4 +1,4 @@
1
- <% if @resource_service.batch_action_map.present? %>
1
+ <% if @resource_service.include_batch_actions? %>
2
2
  <%= link_to translate_scoped("batch_actions.buttons.select_all"), "#", class: "btn btn-default",
3
3
  data: { behavior: "batch-actions-select batch-actions-select-all" } %>
4
4
  <%= link_to translate_scoped("batch_actions.buttons.deselect_all"), "#", class: "btn btn-default hidden",
@@ -5,10 +5,10 @@
5
5
  </button>
6
6
  <ul class="dropdown-menu" role="menu">
7
7
  <li>
8
- <%= link_to "#{translate_scoped("actions.export_as")} JSON", url_for(params.merge(only_path: true, format: "json")) %>
8
+ <%= link_to "#{translate_scoped("actions.export_as")} JSON", url_for(params.to_unsafe_h.merge(only_path: true, format: "json")) %>
9
9
  </li>
10
10
  <li>
11
- <%= link_to "#{translate_scoped("actions.export_as")} CSV", url_for(params.merge(only_path: true, format: "csv")) %>
11
+ <%= link_to "#{translate_scoped("actions.export_as")} CSV", url_for(params.to_unsafe_h.merge(only_path: true, format: "csv")) %>
12
12
  </li>
13
13
  </ul>
14
14
  </div>
@@ -3,23 +3,23 @@
3
3
  <nav>
4
4
  <ul class="pagination">
5
5
  <% unless @resource_service.paginator.pages.first == 1 && @resource_service.paginator.current_page == @resource_service.paginator.pages.first %>
6
- <li><%= link_to translate_scoped("pagination.first"), params.merge(page: 1) %></li>
7
- <li><%= link_to "«", params.merge(page: @resource_service.paginator.current_page - 1) %></li>
6
+ <li><%= link_to translate_scoped("pagination.first"), params.to_unsafe_h.merge(page: 1) %></li>
7
+ <li><%= link_to "«", params.to_unsafe_h.merge(page: @resource_service.paginator.current_page - 1) %></li>
8
8
  <% end %>
9
9
  <% unless @resource_service.paginator.pages.first == 1 %>
10
10
  <li class="disabled"><%= link_to "…" %></li>
11
11
  <% end %>
12
12
  <% @resource_service.paginator.pages.each do |page| %>
13
13
  <li class="<%= "active" if page == @resource_service.paginator.current_page %>">
14
- <%= link_to page, params.merge(page: page) %>
14
+ <%= link_to page, params.to_unsafe_h.merge(page: page) %>
15
15
  </li>
16
16
  <% end %>
17
17
  <% unless @resource_service.paginator.pages.last == @resource_service.paginator.total_pages %>
18
18
  <li class="disabled"><%= link_to "…" %></li>
19
19
  <% end %>
20
20
  <% unless @resource_service.paginator.pages.last == @resource_service.paginator.total_pages && @resource_service.paginator.current_page == @resource_service.paginator.pages.last %>
21
- <li><%= link_to "»", params.merge(page: @resource_service.paginator.current_page + 1) %></li>
22
- <li><%= link_to translate_scoped("pagination.last"), params.merge(page: @resource_service.paginator.total_pages) %></li>
21
+ <li><%= link_to "»", params.to_unsafe_h.merge(page: @resource_service.paginator.current_page + 1) %></li>
22
+ <li><%= link_to translate_scoped("pagination.last"), params.to_unsafe_h.merge(page: @resource_service.paginator.total_pages) %></li>
23
23
  <% end %>
24
24
  </ul>
25
25
  </nav>
@@ -3,7 +3,7 @@
3
3
  <ul class="nav nav-tabs">
4
4
  <% @resource_service.scope_map.each do |name, options| %>
5
5
  <li class="<%= "active" if @resource_service.scoped_by?(name) %>">
6
- <%= link_to url_for(params.merge(scope: name, only_path: true).except(:page)) do %>
6
+ <%= link_to url_for(params.to_unsafe_h.merge(scope: name, only_path: true).except(:page)) do %>
7
7
  <%= translate_scoped("scopes.labels.#{name.to_s.underscore}", default: name.to_s.titleize) %>
8
8
  <span class="text-muted"> (<%= @resource_service.scope_count(name) %>)</span>
9
9
  <% end %>
@@ -2,7 +2,7 @@
2
2
  <table class="table table-bordered table-hover">
3
3
  <thead>
4
4
  <tr>
5
- <% if @resource_service.batch_action_map.present? %>
5
+ <% if @resource_service.include_batch_actions? %>
6
6
  <th></th>
7
7
  <% end %>
8
8
  <% @resource_service.attrs_for_index.each do |attr| %>
@@ -16,8 +16,8 @@
16
16
  <tbody>
17
17
  <% @resources.each do |resource| %>
18
18
  <tr data-resource-id="<%= resource.id %>" class="<%= "highlight" if flash[:updated_ids] && flash[:updated_ids].include?(resource.id) %>">
19
- <% if @resource_service.batch_action_map.present? %>
20
- <td align="center">
19
+ <% if @resource_service.include_batch_actions? %>
20
+ <td align="center" data-behavior="batch-actions-checkbox-container">
21
21
  <%= check_box_tag "batch_action[items][#{resource.id}]", nil, nil,
22
22
  data: { behavior: "batch-actions-checkbox" } %>
23
23
  </td>
@@ -1,12 +1,28 @@
1
1
  <div class="btn-group btn-group-sm pull-right">
2
2
  <% if policy(resource).show? %>
3
- <%= link_to translate_scoped("actions.show"), resource, class: "btn btn-default" %>
3
+ <%= link_to(
4
+ translate_scoped("actions.show"),
5
+ resource,
6
+ class: "btn btn-default",
7
+ title: translate_scoped("actions.show_title", resource: resource)
8
+ ) %>
4
9
  <% end %>
5
10
  <% if policy(resource).edit? %>
6
- <%= link_to translate_scoped("actions.edit"), [:edit, resource], class: "btn btn-default" %>
11
+ <%= link_to(
12
+ translate_scoped("actions.edit"),
13
+ [:edit, resource],
14
+ class: "btn btn-default",
15
+ title: translate_scoped("actions.edit_title", resource: resource)
16
+ ) %>
7
17
  <% end %>
8
18
  <% if policy(resource).destroy? %>
9
- <%= link_to translate_scoped("actions.destroy"), resource, method: :delete,
10
- class: "btn btn-danger", data: { confirm: translate_scoped("actions.confirm_message") } %>
19
+ <%= link_to(
20
+ translate_scoped("actions.destroy"),
21
+ resource,
22
+ method: :delete,
23
+ class: "btn btn-danger",
24
+ title: translate_scoped("actions.destroy_title", resource: resource),
25
+ data: { confirm: translate_scoped("actions.confirm_message") }
26
+ ) %>
11
27
  <% end %>
12
28
  </div>
@@ -4,7 +4,7 @@
4
4
  <div class="col-md-4 col-md-offset-4">
5
5
  <div class="panel panel-default">
6
6
  <div class="panel-heading">
7
- <h3 class="panel-title">Godmin</h3>
7
+ <h3 class="panel-title"><%= t("godmin.title") %></h3>
8
8
  </div>
9
9
  <div class="panel-body">
10
10
  <%= render "layouts/godmin/content" %>
@@ -17,8 +17,11 @@ en:
17
17
  actions:
18
18
  label: Actions
19
19
  show: Show
20
+ show_title: Show %{resource}
20
21
  edit: Edit
22
+ edit_title: Edit %{resource}
21
23
  destroy: Destroy
24
+ destroy_title: Destroy %{resource}
22
25
  confirm_message: Are you sure?
23
26
  export: Export
24
27
  export_as: As
@@ -17,8 +17,11 @@ pt-BR:
17
17
  actions:
18
18
  label: Ações
19
19
  show: Exibir
20
+ show_ttitle: Exibir %{resource}
20
21
  edit: Editar
22
+ edit_title: Editar %{resource}
21
23
  destroy: Remover
24
+ destroy_title: Remover %{resource}
22
25
  confirm_message: Você tem certeza?
23
26
  export: Exportar
24
27
  export_as: Como
@@ -17,8 +17,11 @@ sv:
17
17
  actions:
18
18
  label: Alternativ
19
19
  show: Visa
20
+ show_title: Visa %{resource}
20
21
  edit: Ändra
22
+ edit_title: Ändra %{resource}
21
23
  destroy: Ta bort
24
+ destroy_title: Ta bort %{resource}
22
25
  confirm_message: Är du säker?
23
26
  export: Exportera
24
27
  export_as: Som
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "admin", :path => "../test/dummy/admin", :group => [:test, :development]
6
+ gem "codeclimate-test-reporter", :group => :test, :require => nil
7
+ gem "rails", "~> 4.0"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "admin", :path => "../test/dummy/admin", :group => [:test, :development]
6
+ gem "codeclimate-test-reporter", :group => :test, :require => nil
7
+ gem "rails", "~> 5.0"
8
+
9
+ gemspec :path => "../"
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.email = ["info@varvet.se"]
12
12
  gem.homepage = "https://github.com/varvet/godmin"
13
13
  gem.summary = "Godmin is an admin framework for Rails 4+"
14
- gem.description = "Godmin is an admin framework for Rails 4+"
14
+ gem.description = "Godmin is an admin framework for Rails 4+. Use it to build dedicated admin sections for your apps, or stand alone admin apps such as internal tools."
15
15
  gem.license = "MIT"
16
16
 
17
17
  gem.files = `git ls-files`.split($/)
@@ -19,22 +19,23 @@ Gem::Specification.new do |gem|
19
19
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
20
  gem.require_paths = ["lib"]
21
21
 
22
- gem.add_dependency "bcrypt", "~> 3.1.7"
23
- gem.add_dependency "bootstrap-sass", "~> 3.3.3"
24
- gem.add_dependency "bootstrap_form", "~> 2.2.0"
25
- gem.add_dependency "coffee-rails", [">= 4.0", "< 4.2"]
26
- gem.add_dependency "csv_builder", "~> 2.1.1"
27
- gem.add_dependency "jquery-rails", ">= 3.0"
28
- gem.add_dependency "momentjs-rails", ">= 2.8.1"
29
- gem.add_dependency "rails", "~> 4.0"
30
- gem.add_dependency "sass-rails", ">= 4.0"
31
- gem.add_dependency "selectize-rails", "~> 0.12.0"
22
+ gem.add_dependency "bcrypt", "~> 3.1"
23
+ gem.add_dependency "bootstrap_form", "~> 2.4"
24
+ gem.add_dependency "bootstrap-sass", "~> 3.3"
25
+ gem.add_dependency "coffee-rails", [">= 4.0", "< 6.0"]
26
+ gem.add_dependency "csv_builder", "~> 2.1"
27
+ gem.add_dependency "jquery-rails", [">= 3.0", "< 5.0"]
28
+ gem.add_dependency "momentjs-rails", "~> 2.8"
29
+ gem.add_dependency "rails", [">= 4.0", "< 6.0"]
30
+ gem.add_dependency "sass-rails", [">= 4.0", "< 6.0"]
31
+ gem.add_dependency "selectize-rails", "~> 0.12"
32
32
 
33
- gem.add_development_dependency "capybara"
34
- gem.add_development_dependency "m"
35
- gem.add_development_dependency "minitest-reporters"
36
- gem.add_development_dependency "minitest"
37
- gem.add_development_dependency "poltergeist"
38
- gem.add_development_dependency "pry"
39
- gem.add_development_dependency "sqlite3"
33
+ gem.add_development_dependency "appraisal", "~> 2.1"
34
+ gem.add_development_dependency "capybara", "~> 2.4"
35
+ gem.add_development_dependency "m", "~> 1.3"
36
+ gem.add_development_dependency "minitest-reporters", "~> 1.0"
37
+ gem.add_development_dependency "minitest", "~> 5.5"
38
+ gem.add_development_dependency "poltergeist", "~> 1.7"
39
+ gem.add_development_dependency "pry", "~> 0.10"
40
+ gem.add_development_dependency "sqlite3", "~> 1.3"
40
41
  end
@@ -26,6 +26,17 @@ module Godmin
26
26
 
27
27
  def welcome; end
28
28
 
29
+ protected
30
+
31
+ def redirect_back
32
+ case Rails::VERSION::MAJOR
33
+ when 4
34
+ redirect_to :back
35
+ when 5
36
+ super(fallback_location: root_path)
37
+ end
38
+ end
39
+
29
40
  private
30
41
 
31
42
  def engine_wrapper
@@ -9,7 +9,7 @@ module Godmin
9
9
  helper_method :policy
10
10
 
11
11
  rescue_from NotAuthorizedError do
12
- render text: "You are not authorized to do this", status: 403, layout: "godmin/login"
12
+ render plain: "You are not authorized to do this", status: 403, layout: "godmin/login"
13
13
  end
14
14
  end
15
15
 
@@ -2,9 +2,16 @@ module Godmin
2
2
  module Helpers
3
3
  module Application
4
4
  # Renders the provided partial with locals if it exists, otherwise
5
- # yields the given block.
5
+ # yields the given block. The lookup context call is cached for
6
+ # each partial.
6
7
  def partial_override(partial, locals = {})
7
- if lookup_context.exists?(partial, nil, true)
8
+ @_partial_override ||= {}
9
+
10
+ if @_partial_override[partial].nil?
11
+ @_partial_override[partial] = lookup_context.exists?(partial, nil, true)
12
+ end
13
+
14
+ if @_partial_override[partial]
8
15
  render partial: partial, locals: locals
9
16
  else
10
17
  yield
@@ -2,7 +2,7 @@ module Godmin
2
2
  module Helpers
3
3
  module BatchActions
4
4
  def batch_action_link(name, options)
5
- return unless include_batch_action_link?(options)
5
+ return unless @resource_service.include_batch_action?(name)
6
6
 
7
7
  link_to(
8
8
  translate_scoped("batch_actions.labels.#{name}", default: name.to_s.titleize),
@@ -16,14 +16,6 @@ module Godmin
16
16
  }
17
17
  )
18
18
  end
19
-
20
- private
21
-
22
- def include_batch_action_link?(options)
23
- (options[:only].nil? && options[:except].nil?) ||
24
- (options[:only] && options[:only].include?(@resource_service.scope.to_sym)) ||
25
- (options[:except] && !options[:except].include?(@resource_service.scope.to_sym))
26
- end
27
19
  end
28
20
  end
29
21
  end