administrate 0.0.7 → 0.0.8

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.

Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/administrate/application_helper.rb +2 -1
  3. data/app/views/administrate/application/_sidebar.html.erb +1 -1
  4. data/app/views/fields/belongs_to/_form.html.erb +7 -0
  5. data/app/views/fields/belongs_to/_index.html.erb +3 -0
  6. data/app/views/fields/belongs_to/_show.html.erb +3 -0
  7. data/app/views/fields/email/_form.html.erb +2 -0
  8. data/app/views/fields/email/_index.html.erb +1 -0
  9. data/app/views/fields/email/_show.html.erb +1 -0
  10. data/app/views/fields/has_many/_form.html.erb +11 -0
  11. data/app/views/fields/has_many/_index.html.erb +1 -0
  12. data/app/views/fields/has_many/_show.html.erb +9 -0
  13. data/app/views/fields/has_one/_form.html.erb +7 -0
  14. data/app/views/fields/has_one/_index.html.erb +3 -0
  15. data/app/views/fields/has_one/_show.html.erb +3 -0
  16. data/app/views/fields/image/_form.html.erb +2 -0
  17. data/app/views/fields/image/_index.html.erb +1 -0
  18. data/app/views/fields/image/_show.html.erb +1 -0
  19. data/app/views/fields/string/_form.html.erb +2 -0
  20. data/app/views/fields/string/_index.html.erb +1 -0
  21. data/app/views/fields/string/_show.html.erb +1 -0
  22. data/lib/administrate/base_dashboard.rb +16 -0
  23. data/lib/administrate/fields/base.rb +1 -1
  24. data/lib/administrate/version.rb +1 -1
  25. data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +24 -40
  26. data/lib/generators/administrate/install/templates/dashboard_manifest.rb.erb +8 -12
  27. data/lib/generators/administrate/install/templates/routes.rb +2 -2
  28. metadata +20 -20
  29. data/app/views/fields/form/_belongs_to.html.erb +0 -7
  30. data/app/views/fields/form/_email.html.erb +0 -2
  31. data/app/views/fields/form/_has_many.html.erb +0 -11
  32. data/app/views/fields/form/_has_one.html.erb +0 -7
  33. data/app/views/fields/form/_image.html.erb +0 -2
  34. data/app/views/fields/form/_string.html.erb +0 -2
  35. data/app/views/fields/index/_belongs_to.html.erb +0 -3
  36. data/app/views/fields/index/_email.html.erb +0 -1
  37. data/app/views/fields/index/_has_many.html.erb +0 -1
  38. data/app/views/fields/index/_has_one.html.erb +0 -3
  39. data/app/views/fields/index/_image.html.erb +0 -1
  40. data/app/views/fields/index/_string.html.erb +0 -1
  41. data/app/views/fields/show/_belongs_to.html.erb +0 -3
  42. data/app/views/fields/show/_email.html.erb +0 -1
  43. data/app/views/fields/show/_has_many.html.erb +0 -9
  44. data/app/views/fields/show/_has_one.html.erb +0 -3
  45. data/app/views/fields/show/_image.html.erb +0 -1
  46. data/app/views/fields/show/_string.html.erb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 683ee0c8cf867c553a2c367063d9112cd8ff968f
4
- data.tar.gz: be6336fc10bc73444eb2d42a5c95f7519252dc42
3
+ metadata.gz: 3f7b0d12f02edff96609479df3375a76f8416daa
4
+ data.tar.gz: c40ce457633bb9ae64f34313d058917986d8944e
5
5
  SHA512:
6
- metadata.gz: 84a3b33e1464a4aff24661891d7333c71bd1809131994cb7af9993735230e81765fffcf0f90dc861e79fa006a06a26ca8dda37b5a045221b1e6ac13c55d0d669
7
- data.tar.gz: ca89ca985db441fb3aa69bf6dfe4e5ddee6d268a1c1b034a64eac8b0a5b0b6bb27986a7f9ed359d4c48fac6c9ce0238edee87ced64bf667f89fefa783ab98c01
6
+ metadata.gz: dd8f1d80fa12320624e3c4c630ece69e5379a934f3ca22952648f9b42fd3f3aac5d3b99e146827a5f0732f825c6f9152e1f7a1fb7d348ffc55e690aae317232f
7
+ data.tar.gz: 682b91038a806ca8bfe0b0c1584eb6c9b95399bee08ee9ab35e39b864b3fa294d892bd7b38b007aeab85da2d71a32c6a01164b23f11ebef5f19ee90bacf21cb5
@@ -1,7 +1,8 @@
1
1
  module Administrate
2
2
  module ApplicationHelper
3
3
  def render_field(field, locals = {})
4
- render locals: locals, object: field, partial: field.to_partial_path
4
+ locals.merge!(field: field)
5
+ render locals: locals, partial: field.to_partial_path
5
6
  end
6
7
  end
7
8
  end
@@ -4,7 +4,7 @@
4
4
  <h1 class="sidebar-logo-heading">Administrate</h1>
5
5
  </div>
6
6
 
7
- <% DashboardManifest.new.dashboards.each do |resource| %>
7
+ <% DashboardManifest::DASHBOARDS.each do |resource| %>
8
8
  <li>
9
9
  <%= link_to(
10
10
  resource.to_s.titleize,
@@ -0,0 +1,7 @@
1
+ <%= f.label field.permitted_attribute %>
2
+ <%= f.collection_select(
3
+ field.permitted_attribute,
4
+ field.candidate_records,
5
+ :id,
6
+ :to_s,
7
+ ) %>
@@ -0,0 +1,3 @@
1
+ <% if field.data %>
2
+ <%= link_to field.data, [Administrate::NAMESPACE, field.data] %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <% if field.data %>
2
+ <%= link_to field.data, [Administrate::NAMESPACE, field.data] %>
3
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <%= f.label field.attribute %>
2
+ <%= f.email_field field.attribute %>
@@ -0,0 +1 @@
1
+ <%= mail_to field.data %>
@@ -0,0 +1 @@
1
+ <%= mail_to field.data %>
@@ -0,0 +1,11 @@
1
+ <%= f.label field.attribute_key %>
2
+
3
+ <%= f.collection_select(
4
+ field.attribute_key,
5
+ field.candidate_records,
6
+ :id,
7
+ :to_s,
8
+ {},
9
+ { multiple: true },
10
+ )
11
+ %>
@@ -0,0 +1 @@
1
+ <%= pluralize(field.data.count, field.attribute.to_s.humanize.downcase) %>
@@ -0,0 +1,9 @@
1
+ <% if field.data.any? %>
2
+ <%= render(
3
+ "table",
4
+ table_presenter: field.associated_table,
5
+ resources: field.data
6
+ ) %>
7
+ <% else %>
8
+ <%= t("administrate.fields.has_many.none") %>
9
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= f.label field.permitted_attribute %>
2
+ <%= f.collection_select(
3
+ field.permitted_attribute,
4
+ field.candidate_records,
5
+ :id,
6
+ :to_s,
7
+ ) %>
@@ -0,0 +1,3 @@
1
+ <% if field.data %>
2
+ <%= link_to field.data, [Administrate::NAMESPACE, field.data] %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <% if field.data %>
2
+ <%= link_to field.data, [Administrate::NAMESPACE, field.data] %>
3
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <%= f.label field.attribute %>
2
+ <%= f.text_field field.attribute %>
@@ -0,0 +1 @@
1
+ <%= image_tag field.data %>
@@ -0,0 +1 @@
1
+ <%= image_tag field.data %>
@@ -0,0 +1,2 @@
1
+ <%= f.label field.attribute %>
2
+ <%= f.text_field field.attribute %>
@@ -0,0 +1 @@
1
+ <%= field.data %>
@@ -0,0 +1 @@
1
+ <%= field.data %>
@@ -9,10 +9,26 @@ module Administrate
9
9
  class BaseDashboard
10
10
  include Administrate
11
11
 
12
+ def attribute_types
13
+ self.class::ATTRIBUTE_TYPES
14
+ end
15
+
16
+ def form_attributes
17
+ self.class::FORM_ATTRIBUTES
18
+ end
19
+
12
20
  def permitted_attributes
13
21
  form_attributes.map do |attr|
14
22
  attribute_types[attr].permitted_attribute(attr)
15
23
  end.uniq
16
24
  end
25
+
26
+ def show_page_attributes
27
+ self.class::SHOW_PAGE_ATTRIBUTES
28
+ end
29
+
30
+ def table_attributes
31
+ self.class::TABLE_ATTRIBUTES
32
+ end
17
33
  end
18
34
  end
@@ -27,7 +27,7 @@ module Administrate
27
27
  end
28
28
 
29
29
  def to_partial_path
30
- "/fields/#{page}/#{field_name}"
30
+ "/fields/#{field_name}/#{page}"
31
31
  end
32
32
 
33
33
  attr_reader :attribute, :data, :page
@@ -1,3 +1,3 @@
1
1
  module Administrate
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,53 +1,37 @@
1
1
  require "administrate/base_dashboard"
2
2
 
3
3
  class <%= class_name %>Dashboard < Administrate::BaseDashboard
4
-
5
- # This method returns a hash
6
- # that describes the type of each of the model's fields.
4
+ READ_ONLY_ATTRIBUTES = [
5
+ :id,
6
+ :created_at,
7
+ :updated_at,
8
+ ]
9
+
10
+ # ATTRIBUTE_TYPES
11
+ # a hash that describes the type of each of the model's fields.
7
12
  #
8
13
  # Each different type represents an Administrate::Field object,
9
14
  # which determines how the attribute is displayed
10
15
  # on pages throughout the dashboard.
11
- def attribute_types
12
- {<% attributes.each do |attr| %>
13
- <%= attr %>: <%= field_type(attr) %>,<% end %>
14
- }
15
- end
16
-
17
- # This method returns an array of attributes
18
- # that will be displayed on the model's index page.
16
+ ATTRIBUTE_TYPES = {
17
+ <% attributes.each do |attr| -%>
18
+ <%= attr %>: <%= field_type(attr) %>,
19
+ <% end -%>
20
+ }
21
+
22
+ # TABLE_ATTRIBUTES
23
+ # an array of attributes that will be displayed on the model's index page.
19
24
  #
20
25
  # By default, it's limited to four items to reduce clutter on index pages.
21
26
  # Feel free to remove the limit or customize the returned array.
22
- def table_attributes
23
- attributes.first(<%= TABLE_ATTRIBUTE_LIMIT %>)
24
- end
25
-
26
- # This method returns an array of attributes
27
- # that will be displayed on the model's show page
28
- def show_page_attributes
29
- attributes
30
- end
31
-
32
- # This method returns an array of attributes
33
- # that will be displayed on the model's form pages (`new` and `edit`)
34
- def form_attributes
35
- attributes - read_only_attributes
36
- end
37
-
38
- private
27
+ TABLE_ATTRIBUTES = ATTRIBUTE_TYPES.keys.first(<%= TABLE_ATTRIBUTE_LIMIT %>)
39
28
 
40
- def attributes
41
- [<% attributes.each do |attribute| %>
42
- :<%= attribute %>,<% end %>
43
- ]
44
- end
29
+ # SHOW_PAGE_ATTRIBUTES
30
+ # an array of attributes that will be displayed on the model's show page.
31
+ SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
45
32
 
46
- def read_only_attributes
47
- [
48
- :id,
49
- :created_at,
50
- :updated_at,
51
- ]
52
- end
33
+ # FORM_ATTRIBUTES
34
+ # an array of attributes that will be displayed
35
+ # on the model's form (`new` and `edit`) pages.
36
+ FORM_ATTRIBUTES = ATTRIBUTE_TYPES.keys - READ_ONLY_ATTRIBUTES
53
37
  end
@@ -1,7 +1,7 @@
1
1
  # DashboardManifest tells Administrate which dashboards to display
2
2
  class DashboardManifest
3
- # `#dashboards`
4
- # Returns a list of dashboards to display in the side navigation menu
3
+ # `DASHBOARDS`
4
+ # a list of dashboards to display in the side navigation menu
5
5
  #
6
6
  # These are all of the rails models that we found in your database
7
7
  # at the time you installed Administrate.
@@ -9,21 +9,17 @@ class DashboardManifest
9
9
  # To show or hide dashboards, add or remove the model name from this list.
10
10
  # Dashboards returned from this method must be Rails models for Administrate
11
11
  # to work correctly.
12
- def dashboards
13
- [
12
+ DASHBOARDS = [
14
13
  <% dashboard_resources.each do |model| -%>
15
- :<%= model %>,
14
+ :<%= model %>,
16
15
  <% end -%>
17
- ]
18
- end
16
+ ]
19
17
 
20
- # `#root_dashboard`
21
- # Returns the name of the dashboard that will be displayed
18
+ # `ROOT_DASHBOARD`
19
+ # the name of the dashboard that will be displayed
22
20
  # at "http://your_site.com/admin"
23
21
  #
24
22
  # This dashboard will likely be the first page that admins see
25
23
  # when they log into the dashboard.
26
- def root_dashboard
27
- dashboards.first
28
- end
24
+ ROOT_DASHBOARD = DASHBOARDS.first
29
25
  end
@@ -1,7 +1,7 @@
1
1
  namespace :admin do
2
- DashboardManifest.new.dashboards.each do |dashboard_resource|
2
+ DashboardManifest::DASHBOARDS.each do |dashboard_resource|
3
3
  resources dashboard_resource
4
4
  end
5
5
 
6
- root controller: DashboardManifest.new.root_dashboard, action: :index
6
+ root controller: DashboardManifest::ROOT_DASHBOARD, action: :index
7
7
  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.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grayson Wright
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-24 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: neat
@@ -138,24 +138,24 @@ files:
138
138
  - app/views/administrate/application/index.html.erb
139
139
  - app/views/administrate/application/new.html.erb
140
140
  - app/views/administrate/application/show.html.erb
141
- - app/views/fields/form/_belongs_to.html.erb
142
- - app/views/fields/form/_email.html.erb
143
- - app/views/fields/form/_has_many.html.erb
144
- - app/views/fields/form/_has_one.html.erb
145
- - app/views/fields/form/_image.html.erb
146
- - app/views/fields/form/_string.html.erb
147
- - app/views/fields/index/_belongs_to.html.erb
148
- - app/views/fields/index/_email.html.erb
149
- - app/views/fields/index/_has_many.html.erb
150
- - app/views/fields/index/_has_one.html.erb
151
- - app/views/fields/index/_image.html.erb
152
- - app/views/fields/index/_string.html.erb
153
- - app/views/fields/show/_belongs_to.html.erb
154
- - app/views/fields/show/_email.html.erb
155
- - app/views/fields/show/_has_many.html.erb
156
- - app/views/fields/show/_has_one.html.erb
157
- - app/views/fields/show/_image.html.erb
158
- - app/views/fields/show/_string.html.erb
141
+ - app/views/fields/belongs_to/_form.html.erb
142
+ - app/views/fields/belongs_to/_index.html.erb
143
+ - app/views/fields/belongs_to/_show.html.erb
144
+ - app/views/fields/email/_form.html.erb
145
+ - app/views/fields/email/_index.html.erb
146
+ - app/views/fields/email/_show.html.erb
147
+ - app/views/fields/has_many/_form.html.erb
148
+ - app/views/fields/has_many/_index.html.erb
149
+ - app/views/fields/has_many/_show.html.erb
150
+ - app/views/fields/has_one/_form.html.erb
151
+ - app/views/fields/has_one/_index.html.erb
152
+ - app/views/fields/has_one/_show.html.erb
153
+ - app/views/fields/image/_form.html.erb
154
+ - app/views/fields/image/_index.html.erb
155
+ - app/views/fields/image/_show.html.erb
156
+ - app/views/fields/string/_form.html.erb
157
+ - app/views/fields/string/_index.html.erb
158
+ - app/views/fields/string/_show.html.erb
159
159
  - app/views/layouts/administrate/application.html.erb
160
160
  - config/locales/administrate.en.yml
161
161
  - config/routes.rb
@@ -1,7 +0,0 @@
1
- <%= f.label belongs_to.permitted_attribute %>
2
- <%= f.collection_select(
3
- belongs_to.permitted_attribute,
4
- belongs_to.candidate_records,
5
- :id,
6
- :to_s
7
- ) %>
@@ -1,2 +0,0 @@
1
- <%= f.label email.attribute %>
2
- <%= f.email_field email.attribute %>
@@ -1,11 +0,0 @@
1
- <%= f.label has_many.attribute_key %>
2
-
3
- <%= f.collection_select(
4
- has_many.attribute_key,
5
- has_many.candidate_records,
6
- :id,
7
- :to_s,
8
- {},
9
- { multiple: true }
10
- )
11
- %>
@@ -1,7 +0,0 @@
1
- <%= f.label has_one.permitted_attribute %>
2
- <%= f.collection_select(
3
- has_one.permitted_attribute,
4
- has_one.candidate_records,
5
- :id,
6
- :to_s,
7
- ) %>
@@ -1,2 +0,0 @@
1
- <%= f.label image.attribute %>
2
- <%= f.text_field image.attribute %>
@@ -1,2 +0,0 @@
1
- <%= f.label string.attribute %>
2
- <%= f.text_field string.attribute %>
@@ -1,3 +0,0 @@
1
- <% if belongs_to.data %>
2
- <%= link_to belongs_to.data, [Administrate::NAMESPACE, belongs_to.data] %>
3
- <% end %>
@@ -1 +0,0 @@
1
- <%= mail_to email.data %>
@@ -1 +0,0 @@
1
- <%= pluralize(has_many.data.count, has_many.attribute.to_s.humanize.downcase) %>
@@ -1,3 +0,0 @@
1
- <% if has_one.data %>
2
- <%= link_to has_one.data, [Administrate::NAMESPACE, has_one.data] %>
3
- <% end %>
@@ -1 +0,0 @@
1
- <%= image_tag image.data %>
@@ -1 +0,0 @@
1
- <%= string.data %>
@@ -1,3 +0,0 @@
1
- <% if belongs_to.data %>
2
- <%= link_to belongs_to.data, [Administrate::NAMESPACE, belongs_to.data] %>
3
- <% end %>
@@ -1 +0,0 @@
1
- <%= mail_to email.data %>
@@ -1,9 +0,0 @@
1
- <% if has_many.data.any? %>
2
- <%= render(
3
- "table",
4
- table_presenter: has_many.associated_table,
5
- resources: has_many.data
6
- ) %>
7
- <% else %>
8
- <%= t("administrate.fields.has_many.none") %>
9
- <% end %>
@@ -1,3 +0,0 @@
1
- <% if has_one.data %>
2
- <%= link_to has_one.data, [Administrate::NAMESPACE, has_one.data] %>
3
- <% end %>
@@ -1 +0,0 @@
1
- <%= image_tag image.data %>
@@ -1 +0,0 @@
1
- <%= string.data %>