administrate 0.3.0 → 0.4.0

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

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edc61eafe7e1c58cccdf49d53f0b5c279e343deb
4
- data.tar.gz: 2410bd7f50fe33e8341d1c662db4c6ddc343d408
3
+ metadata.gz: f6a8554f3a353107a488efb3fec4ef4b30f8c936
4
+ data.tar.gz: 7d0941da63a83224d077819a1d7976ded1d40288
5
5
  SHA512:
6
- metadata.gz: 9402b5353adf25c3a1a06f6e33ad963bca6e6aeb3d1806e47941581f1b95d08e737d61bfd42af7a8c495cb24962ab63cb7ca11f7eec5b9b3ad2581185bfd47e2
7
- data.tar.gz: f51fab8de37a22371755543ad6ac29437d0b81c95edfbda7e8f1e93b0a53ac7e8a6f9722c9874176e800f190e29757dcd3ca6605ca81bfb343c7748551716145
6
+ metadata.gz: f0b5072a78e97d7d320ae833c63e5f3d17294c2344a7597e392c1c8ca2eea89445bfbb23cb7943b09392457842b448589be7244c29df8a7306ba7bc7d89df9a7
7
+ data.tar.gz: e67b6690e0ba8d3fbbe579d780f4780998e49bc27d67585cafae7f1741b7fd63e3028c477e95433f23083733dbd07b1e3b9bc3888d67ec4a9f16de52e89bd894
@@ -21,3 +21,11 @@
21
21
  .table__action--destroy {
22
22
  color: $light-red;
23
23
  }
24
+
25
+ .table__link-plain {
26
+ color: inherit;
27
+
28
+ &:hover {
29
+ color: inherit;
30
+ }
31
+ }
@@ -13,6 +13,7 @@ module Administrate
13
13
  resources: resources,
14
14
  search_term: search_term,
15
15
  page: page,
16
+ show_search_bar: show_search_bar?
16
17
  }
17
18
  end
18
19
 
@@ -122,5 +123,11 @@ module Administrate
122
123
  resource: resource_resolver.resource_title,
123
124
  )
124
125
  end
126
+
127
+ def show_search_bar?
128
+ dashboard.attribute_types_for(
129
+ dashboard.collection_attributes
130
+ ).any? { |_name, attribute| attribute.searchable? }
131
+ end
125
132
  end
126
133
  end
@@ -60,7 +60,11 @@ to display a collection of resources in an HTML table.
60
60
  >
61
61
  <% collection_presenter.attributes_for(resource).each do |attribute| %>
62
62
  <td class="cell-data cell-data--<%= attribute.html_class %>">
63
- <%= render_field attribute %>
63
+ <a href="<%= polymorphic_path([namespace, resource]) -%>"
64
+ class="action-show table__link-plain"
65
+ >
66
+ <%= render_field attribute %>
67
+ </a>
64
68
  </td>
65
69
  <% end %>
66
70
 
@@ -17,6 +17,8 @@ It renders the `_table` partial to display details about the resources.
17
17
  By default, these resources are passed to the table partial to be displayed.
18
18
  - `search_term`:
19
19
  A string containing the term the user has searched for, if any.
20
+ - `show_search_bar`:
21
+ A boolean that determines if the search bar should be shown.
20
22
 
21
23
  [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
22
24
  %>
@@ -26,7 +28,9 @@ It renders the `_table` partial to display details about the resources.
26
28
  <% end %>
27
29
 
28
30
  <% content_for(:search) do %>
29
- <%= render "search", search_term: search_term %>
31
+ <% if show_search_bar %>
32
+ <%= render "search", search_term: search_term %>
33
+ <% end %>
30
34
  <% end %>
31
35
 
32
36
  <header class="header">
@@ -30,7 +30,7 @@ from the associated resource class's dashboard.
30
30
  <%= t(
31
31
  'administrate.fields.has_many.more',
32
32
  count: field.limit,
33
- total_count: field.data.count,
33
+ total_count: field.data.count(:all),
34
34
  ) %>
35
35
  </span>
36
36
  <% end %>
@@ -25,6 +25,7 @@
25
25
  <li><a href="/customizing_attribute_partials">Customizing Attribute Partials</a></li>
26
26
  <li><a href="/adding_custom_field_types">Adding Custom Field Types</a></li>
27
27
  <li><a href="/customizing_controller_actions">Customizing Controller Actions</a></li>
28
+ <li><a href="/authentication">Authentication</a></li>
28
29
  </ul>
29
30
  </div>
30
31
 
@@ -0,0 +1,23 @@
1
+ ---
2
+ ja:
3
+ administrate:
4
+ actions:
5
+ confirm: 本当によろしいですか?
6
+ destroy: 削除
7
+ edit: 編集
8
+ show: 参照
9
+ controller:
10
+ create:
11
+ success: "%{resource}を作成しました。"
12
+ destroy:
13
+ success: "%{resource}を削除しました。"
14
+ update:
15
+ success: "%{resource}を更新しました。"
16
+ fields:
17
+ has_many:
18
+ more: "%{total_count} 件中 %{count} 件表示"
19
+ none: データがありません
20
+ polymorphic:
21
+ not_supported: フォームでは「多:多」の関連をサポートしていません。
22
+ has_one:
23
+ not_supported: フォームでは「1:1」の関連をサポートしていません。
@@ -19,6 +19,6 @@ pt-BR:
19
19
  more: "Exibindo %{count} de %{total_count}"
20
20
  none: Nenhum
21
21
  polymorphic:
22
- not_supported: Relações polimórmficas nos formulários não são suportadas.
22
+ not_supported: Relações polimórficas nos formulários não são suportadas.
23
23
  has_one:
24
24
  not_supported: Relações um para muitos nos formulários não são suportadas.
@@ -0,0 +1,14 @@
1
+ default: &default
2
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
3
+
4
+ development:
5
+ <<: *default
6
+
7
+ test:
8
+ <<: *default
9
+
10
+ staging:
11
+ <<: *default
12
+
13
+ production:
14
+ <<: *default
@@ -1,3 +1,4 @@
1
+ require "bourbon"
1
2
  require "datetime_picker_rails"
2
3
  require "jquery-rails"
3
4
  require "kaminari"
@@ -20,6 +20,10 @@ module Administrate
20
20
  def associated_class_name
21
21
  options.fetch(:class_name, attribute.to_s.singularize.camelcase)
22
22
  end
23
+
24
+ def primary_key
25
+ options.fetch(:primary_key, :id)
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -13,12 +13,12 @@ module Administrate
13
13
 
14
14
  def associated_resource_options
15
15
  [nil] + candidate_resources.map do |resource|
16
- [display_candidate_resource(resource), resource.id]
16
+ [display_candidate_resource(resource), resource.send(primary_key)]
17
17
  end
18
18
  end
19
19
 
20
20
  def selected_option
21
- data && data.id
21
+ data && data.send(primary_key)
22
22
  end
23
23
 
24
24
  private
@@ -20,12 +20,12 @@ module Administrate
20
20
 
21
21
  def associated_resource_options
22
22
  candidate_resources.map do |resource|
23
- [display_candidate_resource(resource), resource.id]
23
+ [display_candidate_resource(resource), resource.send(primary_key)]
24
24
  end
25
25
  end
26
26
 
27
27
  def selected_options
28
- data && data.map(&:id)
28
+ data && data.map { |object| object.send(primary_key) }
29
29
  end
30
30
 
31
31
  def limit
@@ -41,7 +41,7 @@ module Administrate
41
41
  end
42
42
 
43
43
  def more_than_limit?
44
- data.count > limit
44
+ data.count(:all) > limit
45
45
  end
46
46
 
47
47
  private
@@ -1,3 +1,3 @@
1
1
  module Administrate
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
@@ -24,7 +24,13 @@ module Administrate
24
24
  end
25
25
 
26
26
  def resource_path
27
- args.first.try(:underscore).try(:pluralize) || "application"
27
+ args.first.try(:underscore).try(:pluralize) || BaseResourcePath.new
28
+ end
29
+
30
+ class BaseResourcePath
31
+ def to_s
32
+ "application"
33
+ end
28
34
  end
29
35
  end
30
36
  end
@@ -5,7 +5,9 @@ module Admin
5
5
  #
6
6
  # def index
7
7
  # super
8
- # @resources = <%= class_name %>.all.paginate(10, params[:page])
8
+ # @resources = <%= class_name %>.
9
+ # page(params[:page]).
10
+ # per(10)
9
11
  # end
10
12
 
11
13
  # Define a custom finder by overriding the `find_resource` method:
@@ -13,7 +15,7 @@ module Admin
13
15
  # <%= class_name %>.find_by!(slug: param)
14
16
  # end
15
17
 
16
- # See https://administrate-docs.herokuapp.com/customizing_controller_actions
18
+ # See https://administrate-prototype.herokuapp.com/customizing_controller_actions
17
19
  # for more information
18
20
  end
19
21
  end
@@ -8,7 +8,7 @@ module Administrate
8
8
  source_root File.expand_path("../templates", __FILE__)
9
9
 
10
10
  def insert_dashboard_routes
11
- unless File.read(rails_routes_file_path).include?(dashboard_routes)
11
+ if should_route_dashboard?
12
12
  route(dashboard_routes)
13
13
  end
14
14
  end
@@ -66,6 +66,10 @@ module Administrate
66
66
  ERB.new(File.read(routes_file_path)).result(binding)
67
67
  end
68
68
 
69
+ def routes_includes_resources?
70
+ File.read(rails_routes_file_path).include?(dashboard_routes)
71
+ end
72
+
69
73
  def rails_routes_file_path
70
74
  Rails.root.join("config/routes.rb")
71
75
  end
@@ -73,6 +77,10 @@ module Administrate
73
77
  def routes_file_path
74
78
  File.expand_path(find_in_source_paths("routes.rb.erb"))
75
79
  end
80
+
81
+ def should_route_dashboard?
82
+ routes_includes_resources? || valid_dashboard_models.any?
83
+ end
76
84
  end
77
85
  end
78
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grayson Wright
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-28 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autoprefixer-rails
@@ -278,6 +278,7 @@ files:
278
278
  - config/locales/administrate.es.yml
279
279
  - config/locales/administrate.fr.yml
280
280
  - config/locales/administrate.it.yml
281
+ - config/locales/administrate.ja.yml
281
282
  - config/locales/administrate.nl.yml
282
283
  - config/locales/administrate.pl.yml
283
284
  - config/locales/administrate.pt-BR.yml
@@ -288,6 +289,7 @@ files:
288
289
  - config/locales/administrate.zh-CN.yml
289
290
  - config/locales/administrate.zh-TW.yml
290
291
  - config/routes.rb
292
+ - config/secrets.yml
291
293
  - config/unicorn.rb
292
294
  - lib/administrate.rb
293
295
  - lib/administrate/base_dashboard.rb
@@ -345,7 +347,7 @@ files:
345
347
  - lib/generators/administrate/views/sidebar_generator.rb
346
348
  - lib/generators/administrate/views/views_generator.rb
347
349
  - lib/tasks/administrate_tasks.rake
348
- homepage: https://administrate-docs.herokuapp.com/
350
+ homepage: https://administrate-prototype.herokuapp.com/
349
351
  licenses:
350
352
  - MIT
351
353
  metadata: {}
@@ -365,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
365
367
  version: '0'
366
368
  requirements: []
367
369
  rubyforge_project:
368
- rubygems_version: 2.6.7
370
+ rubygems_version: 2.5.2
369
371
  signing_key:
370
372
  specification_version: 4
371
373
  summary: A Rails engine for creating super-flexible admin dashboards