administrate 0.0.12 → 0.1.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.

Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/administrate/dropdown.svg +3 -0
  3. data/app/assets/javascripts/administrate/components/_search.js +2 -1
  4. data/app/assets/javascripts/administrate/components/has_many_form.js +1 -1
  5. data/app/assets/stylesheets/administrate/application.scss +0 -1
  6. data/app/assets/stylesheets/administrate/base/_forms.scss +3 -3
  7. data/app/assets/stylesheets/administrate/base/_lists.scss +7 -7
  8. data/app/assets/stylesheets/administrate/base/_variables.scss +3 -0
  9. data/app/assets/stylesheets/administrate/components/_attributes.scss +13 -0
  10. data/app/assets/stylesheets/administrate/components/_cells.scss +2 -8
  11. data/app/assets/stylesheets/administrate/components/_form.scss +32 -25
  12. data/app/assets/stylesheets/administrate/components/_header.scss +1 -1
  13. data/app/assets/stylesheets/administrate/components/_search.scss +1 -1
  14. data/app/assets/stylesheets/administrate/components/_table.scss +4 -0
  15. data/app/assets/stylesheets/administrate/mixins/_data_label.scss +8 -0
  16. data/app/assets/stylesheets/administrate/mixins/_mixins.scss +1 -0
  17. data/app/controllers/administrate/application_controller.rb +35 -38
  18. data/app/views/administrate/application/{_table.html.erb → _collection.html.erb} +26 -6
  19. data/app/views/administrate/application/_flashes.html.erb +13 -0
  20. data/app/views/administrate/application/_form.html.erb +23 -7
  21. data/app/views/administrate/application/_javascript.html.erb +9 -0
  22. data/app/views/administrate/application/_sidebar.html.erb +9 -0
  23. data/app/views/administrate/application/edit.html.erb +22 -3
  24. data/app/views/administrate/application/index.html.erb +31 -6
  25. data/app/views/administrate/application/new.html.erb +22 -3
  26. data/app/views/administrate/application/show.html.erb +24 -4
  27. data/app/views/fields/belongs_to/_form.html.erb +18 -0
  28. data/app/views/fields/belongs_to/_index.html.erb +17 -0
  29. data/app/views/fields/belongs_to/_show.html.erb +17 -0
  30. data/app/views/fields/boolean/_form.html.erb +17 -0
  31. data/app/views/fields/boolean/_index.html.erb +19 -1
  32. data/app/views/fields/boolean/_show.html.erb +19 -1
  33. data/app/views/fields/date_time/_form.html.erb +18 -0
  34. data/app/views/fields/date_time/_index.html.erb +18 -0
  35. data/app/views/fields/date_time/_show.html.erb +18 -0
  36. data/app/views/fields/email/_form.html.erb +17 -0
  37. data/app/views/fields/email/_index.html.erb +17 -0
  38. data/app/views/fields/email/_show.html.erb +17 -0
  39. data/app/views/fields/has_many/_form.html.erb +21 -0
  40. data/app/views/fields/has_many/_index.html.erb +18 -0
  41. data/app/views/fields/has_many/_show.html.erb +33 -3
  42. data/app/views/fields/has_one/_form.html.erb +21 -1
  43. data/app/views/fields/has_one/_index.html.erb +17 -0
  44. data/app/views/fields/has_one/_show.html.erb +17 -0
  45. data/app/views/fields/image/_form.html.erb +17 -0
  46. data/app/views/fields/image/_index.html.erb +17 -0
  47. data/app/views/fields/image/_show.html.erb +17 -0
  48. data/app/views/fields/number/_form.html.erb +17 -0
  49. data/app/views/fields/number/_index.html.erb +19 -1
  50. data/app/views/fields/number/_show.html.erb +19 -1
  51. data/app/views/fields/polymorphic/_form.html.erb +20 -0
  52. data/app/views/fields/polymorphic/_index.html.erb +18 -0
  53. data/app/views/fields/polymorphic/_show.html.erb +18 -0
  54. data/app/views/fields/string/_form.html.erb +17 -0
  55. data/app/views/fields/string/_index.html.erb +17 -0
  56. data/app/views/fields/string/_show.html.erb +17 -0
  57. data/app/views/fields/text/_form.html.erb +2 -0
  58. data/app/views/fields/text/_index.html.erb +1 -0
  59. data/app/views/fields/text/_show.html.erb +1 -0
  60. data/app/views/layouts/administrate/application.html.erb +15 -1
  61. data/config/locales/administrate.en.yml +14 -10
  62. data/lib/administrate/base_dashboard.rb +3 -2
  63. data/lib/administrate/engine.rb +1 -1
  64. data/lib/administrate/fields/has_many.rb +7 -3
  65. data/lib/administrate/fields/text.rb +21 -0
  66. data/lib/administrate/page/{table.rb → collection.rb} +2 -6
  67. data/lib/administrate/version.rb +1 -1
  68. data/lib/administrate/view_generator.rb +27 -0
  69. data/lib/generators/administrate/dashboard/dashboard_generator.rb +7 -1
  70. data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +16 -10
  71. data/lib/generators/administrate/field/field_generator.rb +31 -0
  72. data/lib/generators/administrate/field/templates/_form.html.erb +2 -0
  73. data/lib/generators/administrate/field/templates/_index.html.erb +1 -0
  74. data/lib/generators/administrate/field/templates/_show.html.erb +1 -0
  75. data/lib/generators/administrate/field/templates/field_object.rb.erb +7 -0
  76. data/lib/generators/administrate/views/edit_generator.rb +16 -0
  77. data/lib/generators/administrate/views/field_generator.rb +36 -0
  78. data/lib/generators/administrate/views/form_generator.rb +15 -0
  79. data/lib/generators/administrate/views/index_generator.rb +16 -0
  80. data/lib/generators/administrate/views/new_generator.rb +16 -0
  81. data/lib/generators/administrate/views/show_generator.rb +15 -0
  82. data/lib/generators/administrate/views/views_generator.rb +14 -0
  83. metadata +33 -15
  84. data/app/assets/stylesheets/administrate/_show.sass +0 -16
@@ -1,13 +1,29 @@
1
- <%= form_for([Administrate::NAMESPACE, @page.resource], class: "form") do |f| %>
2
- <% if @page.resource.errors.any? %>
1
+ <%#
2
+ # Form Partial
3
+
4
+ This partial is rendered on a resource's `new` and `edit` pages,
5
+ and renders all form fields for a resource's editable attributes.
6
+
7
+ ## Local variables:
8
+
9
+ - `page`:
10
+ An instance of [Administrate::Page::Form][1].
11
+ Contains helper methods to display a form,
12
+ and knows which attributes should be displayed in the resource's form.
13
+
14
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
15
+ %>
16
+
17
+ <%= form_for([Administrate::NAMESPACE, page.resource], class: "form") do |f| %>
18
+ <% if page.resource.errors.any? %>
3
19
  <div id="error_explanation">
4
20
  <h2>
5
- <%= pluralize(@page.resource.errors.count, "error") %>
6
- prohibited this <%= @page.resource_name %> from being saved:
21
+ <%= pluralize(page.resource.errors.count, "error") %>
22
+ prohibited this <%= page.resource_name %> from being saved:
7
23
  </h2>
8
24
 
9
25
  <ul>
10
- <% @page.resource.errors.full_messages.each do |message| %>
26
+ <% page.resource.errors.full_messages.each do |message| %>
11
27
  <li><%= message %></li>
12
28
  <% end %>
13
29
  </ul>
@@ -15,8 +31,8 @@
15
31
  <% end %>
16
32
 
17
33
  <div class="form-inputs">
18
- <% @page.attributes.each do |attribute| -%>
19
- <div class="form-field form-field-<%= attribute.html_class %>">
34
+ <% page.attributes.each do |attribute| -%>
35
+ <div class="form-field form-field--<%= attribute.html_class %>">
20
36
  <%= render_field attribute, f: f %>
21
37
  </div>
22
38
  <% end -%>
@@ -1,3 +1,12 @@
1
+ <%#
2
+ # Javascript Partial
3
+
4
+ This partial imports the necessary javascript on each page.
5
+ By default, it includes the application JS,
6
+ but each page can define additional JS sources
7
+ by providing a `content_for(:javascript)` block.
8
+ %>
9
+
1
10
  <%= javascript_include_tag "administrate/application" %>
2
11
 
3
12
  <%= yield :javascript %>
@@ -1,3 +1,12 @@
1
+ <%#
2
+ # Sidebar
3
+
4
+ This partial is used to display the sidebar in Administrate.
5
+ By default, the sidebar contains navigation links
6
+ for all resources in the admin dashboard,
7
+ as defined by the DashboardManifest.
8
+ %>
9
+
1
10
  <ul class="sidebar__list">
2
11
  <% DashboardManifest::DASHBOARDS.each do |resource| %>
3
12
  <li>
@@ -1,6 +1,25 @@
1
+ <%#
2
+ # Edit
3
+
4
+ This view is the template for the edit page.
5
+
6
+ It displays a header, and renders the `_form` partial to do the heavy lifting.
7
+
8
+ ## Local variables:
9
+
10
+ - `page`:
11
+ An instance of [Administrate::Page::Form][1].
12
+ Contains helper methods to help display a form,
13
+ and knows which attributes should be displayed in the resource's form.
14
+
15
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
16
+ %>
17
+
18
+ <% content_for(:title) { "Edit #{page.page_title}" } %>
19
+
1
20
  <header class="header">
2
- <h1 class="header-heading">Edit <%= @page.page_title %></h1>
3
- <%= link_to "Show #{@page.resource}", [Administrate::NAMESPACE, @page.resource], class: "button" %>
21
+ <h1 class="header-heading"><%= content_for(:title) %></h1>
22
+ <%= link_to "Show #{page.resource}", [Administrate::NAMESPACE, page.resource], class: "button" %>
4
23
  </header>
5
24
 
6
- <%= render "form" %>
25
+ <%= render "form", page: page %>
@@ -1,3 +1,28 @@
1
+ <%#
2
+ # Index
3
+
4
+ This view is the template for the index page.
5
+ It is responsible for rendering the search bar, header and pagination.
6
+ It renders the `_table` partial to display details about the resources.
7
+
8
+ ## Local variables:
9
+
10
+ - `page`:
11
+ An instance of [Administrate::Page::Table][1].
12
+ Contains helper methods to help display a table,
13
+ and knows which attributes should be displayed in the resource's table.
14
+ - `resources`:
15
+ An instance of `ActiveRecord::Relation` containing the resources
16
+ that match the user's search criteria.
17
+ By default, these resources are passed to the table partial to be displayed.
18
+ - `search_term`:
19
+ A string containing the term the user has searched for, if any.
20
+
21
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Table
22
+ %>
23
+
24
+ <% content_for(:title) { page.resource_name.pluralize.titleize } %>
25
+
1
26
  <% content_for(:search) do %>
2
27
  <form class="search">
3
28
  <span class="search__icon">
@@ -8,7 +33,7 @@
8
33
  name="search"
9
34
  class="search__input"
10
35
  placeholder="Search"
11
- value="<%= @search_term %>"
36
+ value="<%= search_term %>"
12
37
  />
13
38
  <span class="search__hint">
14
39
  Press enter to search
@@ -17,14 +42,14 @@
17
42
  <% end %>
18
43
 
19
44
  <header class="header">
20
- <h1 class="header-heading"><%= @page.resource_name.pluralize.titleize %></h1>
45
+ <h1 class="header-heading"><%= content_for(:title) %></h1>
21
46
  <%= link_to(
22
- "New #{@page.resource_name.titleize.downcase}",
23
- [:new, Administrate::NAMESPACE, @page.resource_name],
47
+ "New #{page.resource_name.titleize.downcase}",
48
+ [:new, Administrate::NAMESPACE, page.resource_name],
24
49
  class: "button",
25
50
  ) %>
26
51
  </header>
27
52
 
28
- <%= render "table", table_presenter: @page, resources: @resources %>
53
+ <%= render "collection", collection_presenter: page, resources: resources %>
29
54
 
30
- <%= paginate @resources %>
55
+ <%= paginate resources %>
@@ -1,6 +1,25 @@
1
+ <%#
2
+ # New
3
+
4
+ This view is the template for the "new resource" page.
5
+ It displays a header, and then renders the `_form` partial
6
+ to do the heavy lifting.
7
+
8
+ ## Local variables:
9
+
10
+ - `page`:
11
+ An instance of [Administrate::Page::Form][1].
12
+ Contains helper methods to help display a form,
13
+ and knows which attributes should be displayed in the resource's form.
14
+
15
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
16
+ %>
17
+
18
+ <% content_for(:title) { "New #{page.resource_name.titleize}" } %>
19
+
1
20
  <header class="header">
2
- <h1 class="header-heading">New <%= @page.resource_name.titleize %></h1>
3
- <%= link_to 'Back', @page.resource_name.pluralize, class: "button" %>
21
+ <h1 class="header-heading"><%= content_for(:title) %></h1>
22
+ <%= link_to 'Back', :back, class: "button" %>
4
23
  </header>
5
24
 
6
- <%= render 'form' %>
25
+ <%= render 'form', page: page %>
@@ -1,17 +1,37 @@
1
+ <%#
2
+ # Show
3
+
4
+ This view is the template for the show page.
5
+ It renders the attributes of a resource,
6
+ as well as a link to its edit page.
7
+
8
+ ## Local variables:
9
+
10
+ - `page`:
11
+ An instance of [Administrate::Page::Show][1].
12
+ Contains methods for accessing the resource to be displayed on the page,
13
+ as well as helpers for describing how each attribute of the resource
14
+ should be displayed.
15
+
16
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
17
+ %>
18
+
19
+ <% content_for(:title) { page.page_title } %>
20
+
1
21
  <header class="header">
2
- <h1 class="header-heading"><%= @page.page_title %></h1>
22
+ <h1 class="header-heading"><%= content_for(:title) %></h1>
3
23
  <%= link_to(
4
24
  "Edit",
5
- [:edit, Administrate::NAMESPACE, @page.resource],
25
+ [:edit, Administrate::NAMESPACE, page.resource],
6
26
  class: "button",
7
27
  ) %>
8
28
  </header>
9
29
 
10
30
  <dl>
11
- <% @page.attributes.each do |attribute| %>
31
+ <% page.attributes.each do |attribute| %>
12
32
  <dt class="attribute-label"><%= attribute.name.titleize %></dt>
13
33
 
14
- <dd class="attribute-data--<%=attribute.html_class%>"
34
+ <dd class="attribute-data attribute-data--<%=attribute.html_class%>"
15
35
  ><%= render_field attribute %></dd>
16
36
  <% end %>
17
37
  </dl>
@@ -1,3 +1,21 @@
1
+ <%#
2
+ # BelongsTo Form Partial
3
+
4
+ This partial renders an input element for belongs_to relationships.
5
+ By default, the input is a collection select box
6
+ that displays all possible records to associate with.
7
+
8
+ ## Local variables:
9
+
10
+ - `f`:
11
+ A Rails form generator, used to help create the appropriate input fields.
12
+ - `field`:
13
+ An instance of [Administrate::Field::BelongsTo][1].
14
+ Contains helper methods for displaying a collection select box.
15
+
16
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/BelongsTo
17
+ %>
18
+
1
19
  <%= f.label field.permitted_attribute %>
2
20
  <%= f.collection_select(
3
21
  field.permitted_attribute,
@@ -1,3 +1,20 @@
1
+ <%#
2
+ # BelongsTo Index Partial
3
+
4
+ This partial renders a belongs_to relationship,
5
+ to be displayed on a resource's index page.
6
+
7
+ By default, the relationship is rendered as a link to the associated object.
8
+
9
+ ## Local variables:
10
+
11
+ - `field`:
12
+ An instance of [Administrate::Field::BelongsTo][1].
13
+ A wrapper around the belongs_to relationship pulled from the database.
14
+
15
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/BelongsTo
16
+ %>
17
+
1
18
  <% if field.data %>
2
19
  <%= link_to field.data, [Administrate::NAMESPACE, field.data] %>
3
20
  <% end %>
@@ -1,3 +1,20 @@
1
+ <%#
2
+ # BelongsTo Show Partial
3
+
4
+ This partial renders a belongs_to relationship,
5
+ to be displayed on a resource's show page.
6
+
7
+ By default, the relationship is rendered as a link to the associated object.
8
+
9
+ ## Local variables:
10
+
11
+ - `field`:
12
+ An instance of [Administrate::Field::BelongsTo][1].
13
+ A wrapper around the belongs_to relationship pulled from the database.
14
+
15
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/BelongsTo
16
+ %>
17
+
1
18
  <% if field.data %>
2
19
  <%= link_to field.data, [Administrate::NAMESPACE, field.data] %>
3
20
  <% end %>
@@ -1,2 +1,19 @@
1
+ <%#
2
+ # Boolean Form Partial
3
+
4
+ This partial renders an input element for a boolean attribute.
5
+ By default, the input is a checkbox.
6
+
7
+ ## Local variables:
8
+
9
+ - `f`:
10
+ A Rails form generator, used to help create the appropriate input fields.
11
+ - `field`:
12
+ An instance of [Administrate::Field::Boolean][1].
13
+ A wrapper around the boolean value pulled from the database.
14
+
15
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Boolean
16
+ %>
17
+
1
18
  <%= f.label field.attribute %>
2
19
  <%= f.check_box field.attribute %>
@@ -1 +1,19 @@
1
- <%= field %>
1
+ <%#
2
+ # Boolean Index Partial
3
+
4
+ This partial renders a boolean attribute,
5
+ to be displayed on a resource's index page.
6
+
7
+ By default, the attribute is rendered
8
+ as a string representation of the boolean value.
9
+
10
+ ## Local variables:
11
+
12
+ - `field`:
13
+ An instance of [Administrate::Field::Boolean][1].
14
+ A wrapper around the boolean value pulled from the database.
15
+
16
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Boolean
17
+ %>
18
+
19
+ <%= field.to_s %>
@@ -1 +1,19 @@
1
- <%= field %>
1
+ <%#
2
+ # Boolean Show Partial
3
+
4
+ This partial renders a boolean attribute,
5
+ to be displayed on a resource's show page.
6
+
7
+ By default, the attribute is rendered
8
+ as a string representation of the boolean value.
9
+
10
+ ## Local variables:
11
+
12
+ - `field`:
13
+ An instance of [Administrate::Field::Boolean][1].
14
+ A wrapper around the boolean value pulled from the database.
15
+
16
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Boolean
17
+ %>
18
+
19
+ <%= field.to_s %>
@@ -1,2 +1,20 @@
1
+ <%#
2
+ # DateTime Form Partial
3
+
4
+ This partial renders an input element for a datetime attribute.
5
+ By default, the input is a text field that is augmented with [DateTimePicker].
6
+
7
+ ## Local variables:
8
+
9
+ - `f`:
10
+ A Rails form generator, used to help create the appropriate input fields.
11
+ - `field`:
12
+ An instance of [Administrate::Field::DateTime][1].
13
+ A wrapper around the DateTime value pulled from the database.
14
+
15
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/DateTime
16
+ [DateTimePicker]: https://github.com/Eonasdan/bootstrap-datetimepicker
17
+ %>
18
+
1
19
  <%= f.label field.attribute %>
2
20
  <%= f.text_field field.attribute, class: "datetimepicker" %>
@@ -1,3 +1,21 @@
1
+ <%#
2
+ # DateTime Index Partial
3
+
4
+ This partial renders a datetime attribute,
5
+ to be displayed on a resource's index page.
6
+
7
+ By default, the attribute is rendered
8
+ as a localized date & time string.
9
+
10
+ ## Local variables:
11
+
12
+ - `field`:
13
+ An instance of [Administrate::Field::DateTime][1].
14
+ A wrapper around the DateTime value pulled from the database.
15
+
16
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/DateTime
17
+ %>
18
+
1
19
  <% if field.data %>
2
20
  <%= l field.data.to_date %>
3
21
  <% end %>
@@ -1,3 +1,21 @@
1
+ <%#
2
+ # DateTime Show Partial
3
+
4
+ This partial renders a datetime attribute,
5
+ to be displayed on a resource's show page.
6
+
7
+ By default, the attribute is rendered
8
+ as a localized date & time string.
9
+
10
+ ## Local variables:
11
+
12
+ - `field`:
13
+ An instance of [Administrate::Field::DateTime][1].
14
+ A wrapper around the DateTime value pulled from the database.
15
+
16
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/DateTime
17
+ %>
18
+
1
19
  <% if field.data %>
2
20
  <%= l field.data %>
3
21
  <% end %>
@@ -1,2 +1,19 @@
1
+ <%#
2
+ # Email Form Partial
3
+
4
+ This partial renders an input element for email addresses.
5
+ By default, the input is a text box.
6
+
7
+ ## Local variables:
8
+
9
+ - `f`:
10
+ A Rails form generator, used to help create the appropriate input fields.
11
+ - `field`:
12
+ An instance of [Administrate::Field::Email][1].
13
+ A wrapper around the email pulled from the database.
14
+
15
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Email
16
+ %>
17
+
1
18
  <%= f.label field.attribute %>
2
19
  <%= f.email_field field.attribute %>