administrate 0.12.0 → 0.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -2
- data/app/assets/javascripts/administrate/application.js +0 -2
- data/app/assets/javascripts/administrate/components/associative.js +5 -0
- data/app/assets/javascripts/administrate/components/select.js +3 -0
- data/app/assets/javascripts/administrate/components/table.js +1 -1
- data/app/assets/stylesheets/administrate/application.scss +0 -1
- data/app/assets/stylesheets/administrate/base/_forms.scss +1 -1
- data/app/assets/stylesheets/administrate/base/_tables.scss +3 -0
- data/app/assets/stylesheets/administrate/components/_attributes.scss +4 -3
- data/app/assets/stylesheets/administrate/components/_buttons.scss +20 -0
- data/app/assets/stylesheets/administrate/components/_cells.scss +2 -0
- data/app/assets/stylesheets/administrate/components/_field-unit.scss +24 -4
- data/app/assets/stylesheets/administrate/components/_flashes.scss +2 -10
- data/app/assets/stylesheets/administrate/components/_main-content.scss +1 -0
- data/app/assets/stylesheets/administrate/components/_navigation.scss +2 -3
- data/app/assets/stylesheets/administrate/library/_variables.scss +11 -9
- data/app/controllers/administrate/application_controller.rb +127 -25
- data/app/controllers/concerns/administrate/punditize.rb +44 -20
- data/app/helpers/administrate/application_helper.rb +56 -20
- data/app/views/administrate/application/_collection.html.erb +26 -29
- data/app/views/administrate/application/_collection_header_actions.html.erb +4 -0
- data/app/views/administrate/application/_collection_item_actions.html.erb +17 -0
- data/app/views/administrate/application/_flashes.html.erb +1 -0
- data/app/views/administrate/application/_form.html.erb +20 -5
- data/app/views/administrate/application/_icons.html.erb +1 -1
- data/app/views/administrate/application/_index_header.html.erb +28 -0
- data/app/views/administrate/application/_navigation.html.erb +6 -4
- data/app/views/administrate/application/_pagination.html.erb +1 -0
- data/app/views/administrate/application/edit.html.erb +2 -2
- data/app/views/administrate/application/index.html.erb +9 -29
- data/app/views/administrate/application/new.html.erb +1 -1
- data/app/views/administrate/application/show.html.erb +28 -12
- data/app/views/fields/belongs_to/_form.html.erb +3 -3
- data/app/views/fields/belongs_to/_index.html.erb +1 -1
- data/app/views/fields/belongs_to/_show.html.erb +1 -1
- data/app/views/fields/date/_form.html.erb +22 -0
- data/app/views/fields/date/_index.html.erb +21 -0
- data/app/views/fields/date/_show.html.erb +21 -0
- data/app/views/fields/date_time/_form.html.erb +1 -3
- data/app/views/fields/has_many/_index.html.erb +1 -1
- data/app/views/fields/has_many/_show.html.erb +2 -1
- data/app/views/fields/has_one/_form.html.erb +15 -5
- data/app/views/fields/has_one/_index.html.erb +3 -2
- data/app/views/fields/has_one/_show.html.erb +22 -15
- data/app/views/fields/number/_form.html.erb +1 -1
- data/app/views/fields/polymorphic/_index.html.erb +2 -1
- data/app/views/fields/polymorphic/_show.html.erb +1 -1
- data/app/views/fields/select/_form.html.erb +9 -8
- data/app/views/fields/string/_show.html.erb +2 -2
- data/app/views/fields/text/_show.html.erb +2 -3
- data/app/views/fields/time/_form.html.erb +2 -2
- data/app/views/fields/time/_index.html.erb +3 -1
- data/app/views/fields/time/_show.html.erb +3 -1
- data/app/views/fields/url/_index.html.erb +2 -2
- data/app/views/fields/url/_show.html.erb +2 -2
- data/app/views/layouts/administrate/application.html.erb +2 -1
- data/config/locales/administrate.ar.yml +2 -0
- data/config/locales/administrate.bs.yml +2 -0
- data/config/locales/administrate.ca.yml +2 -0
- data/config/locales/administrate.da.yml +2 -0
- data/config/locales/administrate.de.yml +4 -2
- data/config/locales/administrate.en.yml +2 -0
- data/config/locales/administrate.es.yml +2 -0
- data/config/locales/administrate.fi.yml +30 -0
- data/config/locales/administrate.fr.yml +4 -2
- data/config/locales/administrate.id.yml +2 -0
- data/config/locales/administrate.it.yml +2 -0
- data/config/locales/administrate.ja.yml +7 -5
- data/config/locales/administrate.ko.yml +2 -0
- data/config/locales/administrate.nl.yml +7 -5
- data/config/locales/administrate.pl.yml +2 -0
- data/config/locales/administrate.pt-BR.yml +4 -2
- data/config/locales/administrate.pt.yml +4 -2
- data/config/locales/administrate.ru.yml +2 -0
- data/config/locales/administrate.sl.yml +30 -0
- data/config/locales/{administrate.al.yml → administrate.sq.yml} +3 -1
- data/config/locales/administrate.sv.yml +2 -0
- data/config/locales/administrate.tr.yml +30 -0
- data/config/locales/administrate.uk.yml +2 -0
- data/config/locales/administrate.vi.yml +2 -0
- data/config/locales/administrate.zh-CN.yml +2 -0
- data/config/locales/administrate.zh-TW.yml +2 -0
- data/docs/adding_controllers_without_related_model.md +52 -0
- data/docs/adding_custom_field_types.md +3 -1
- data/docs/authentication.md +3 -1
- data/docs/authorization.md +47 -22
- data/docs/customizing_attribute_partials.md +4 -1
- data/docs/customizing_controller_actions.md +67 -1
- data/docs/customizing_dashboards.md +171 -40
- data/docs/customizing_page_views.md +18 -4
- data/docs/extending_administrate.md +27 -0
- data/docs/getting_started.md +35 -11
- data/docs/guides/customising_search.md +149 -0
- data/docs/guides/hiding_dashboards_from_sidebar.md +21 -0
- data/docs/guides/scoping_has_many_relations.md +27 -0
- data/docs/guides.md +7 -0
- data/docs/rails_api.md +5 -3
- data/lib/administrate/base_dashboard.rb +73 -14
- data/lib/administrate/custom_dashboard.rb +15 -0
- data/lib/administrate/engine.rb +9 -2
- data/lib/administrate/field/associative.rb +61 -7
- data/lib/administrate/field/base.rb +39 -9
- data/lib/administrate/field/belongs_to.rb +22 -5
- data/lib/administrate/field/date.rb +20 -0
- data/lib/administrate/field/deferred.rb +26 -3
- data/lib/administrate/field/has_many.rb +35 -8
- data/lib/administrate/field/has_one.rb +36 -12
- data/lib/administrate/field/number.rb +13 -2
- data/lib/administrate/field/polymorphic.rb +7 -6
- data/lib/administrate/field/select.rb +23 -4
- data/lib/administrate/field/time.rb +11 -0
- data/lib/administrate/field/url.rb +4 -0
- data/lib/administrate/namespace.rb +5 -1
- data/lib/administrate/not_authorized_error.rb +20 -0
- data/lib/administrate/order.rb +85 -19
- data/lib/administrate/page/base.rb +5 -3
- data/lib/administrate/page/collection.rb +1 -0
- data/lib/administrate/page/form.rb +12 -4
- data/lib/administrate/page/show.rb +10 -2
- data/lib/administrate/resource_resolver.rb +4 -3
- data/lib/administrate/search.rb +47 -36
- data/lib/administrate/version.rb +1 -1
- data/lib/administrate/view_generator.rb +14 -3
- data/lib/administrate.rb +42 -0
- data/lib/generators/administrate/dashboard/dashboard_generator.rb +38 -16
- data/lib/generators/administrate/dashboard/templates/controller.rb.erb +23 -11
- data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +4 -4
- data/lib/generators/administrate/install/install_generator.rb +43 -2
- data/lib/generators/administrate/install/templates/application_controller.rb.erb +4 -4
- data/lib/generators/administrate/routes/routes_generator.rb +26 -27
- data/lib/generators/administrate/test_record.rb +21 -0
- data/lib/generators/administrate/views/views_generator.rb +5 -4
- metadata +57 -78
- data/app/assets/javascripts/administrate/components/date_time_picker.js +0 -10
- data/app/assets/javascripts/administrate/components/has_many_form.js +0 -3
- data/config/i18n-tasks.yml +0 -18
- data/config/routes.rb +0 -2
- data/config/unicorn.rb +0 -30
@@ -1,31 +1,57 @@
|
|
1
1
|
module Administrate
|
2
2
|
module ApplicationHelper
|
3
3
|
PLURAL_MANY_COUNT = 2.1
|
4
|
+
SINGULAR_COUNT = 1
|
4
5
|
|
5
6
|
def application_title
|
6
|
-
|
7
|
-
Rails.application.class.parent_name.titlecase
|
8
|
-
else
|
9
|
-
Rails.application.class.module_parent_name.titlecase
|
10
|
-
end
|
7
|
+
Rails.application.class.module_parent_name.titlecase
|
11
8
|
end
|
12
9
|
|
13
10
|
def render_field(field, locals = {})
|
14
|
-
locals
|
11
|
+
locals[:field] = field
|
15
12
|
render locals: locals, partial: field.to_partial_path
|
16
13
|
end
|
17
14
|
|
18
|
-
def
|
19
|
-
|
15
|
+
def requireness(field)
|
16
|
+
field.required? ? "required" : "optional"
|
17
|
+
end
|
18
|
+
|
19
|
+
def dashboard_from_resource(resource_name)
|
20
|
+
"#{resource_name.to_s.singularize}_dashboard".classify.constantize
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def model_from_resource(resource_name)
|
24
|
+
dashboard = dashboard_from_resource(resource_name)
|
25
|
+
dashboard.try(:model) || resource_name.to_sym
|
26
|
+
end
|
27
|
+
|
28
|
+
# Unification of
|
29
|
+
# {Administrate::ApplicationController#existing_action? existing_action?}
|
30
|
+
# and
|
31
|
+
# {Administrate::ApplicationController#authorized_action?
|
32
|
+
# authorized_action?}
|
33
|
+
#
|
34
|
+
# @param target [ActiveRecord::Base, Class, Symbol, String] A resource,
|
35
|
+
# a class of resources, or the name of a class of resources.
|
36
|
+
# @param action_name [String, Symbol] The name of an action that might be
|
37
|
+
# possible to perform on a resource or resource class.
|
38
|
+
# @return [Boolean] Whether the action both (a) exists for the record class,
|
39
|
+
# and (b) the current user is authorized to perform it on the record
|
40
|
+
# instance or class.
|
41
|
+
def accessible_action?(target, action_name)
|
42
|
+
target = target.to_sym if target.is_a?(String)
|
43
|
+
target_class_or_class_name =
|
44
|
+
target.is_a?(ActiveRecord::Base) ? target.class : target
|
45
|
+
|
46
|
+
existing_action?(target_class_or_class_name, action_name) &&
|
47
|
+
authorized_action?(target, action_name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def display_resource_name(resource_name, opts = {})
|
51
|
+
dashboard_from_resource(resource_name).resource_name(
|
52
|
+
count: opts[:singular] ? SINGULAR_COUNT : PLURAL_MANY_COUNT,
|
53
|
+
default: default_resource_name(resource_name, opts),
|
54
|
+
)
|
29
55
|
end
|
30
56
|
|
31
57
|
def sort_order(order)
|
@@ -36,22 +62,32 @@ module Administrate
|
|
36
62
|
end
|
37
63
|
end
|
38
64
|
|
39
|
-
def
|
40
|
-
|
65
|
+
def resource_index_route(resource_name)
|
66
|
+
url_for(
|
67
|
+
action: "index",
|
68
|
+
controller: "/#{namespace}/#{resource_name}",
|
69
|
+
)
|
41
70
|
end
|
42
71
|
|
43
72
|
def sanitized_order_params(page, current_field_name)
|
44
|
-
collection_names = page.
|
73
|
+
collection_names = page.item_associations + [current_field_name]
|
45
74
|
association_params = collection_names.map do |assoc_name|
|
46
75
|
{ assoc_name => %i[order direction page per_page] }
|
47
76
|
end
|
48
|
-
params.permit(:search, :id, :
|
77
|
+
params.permit(:search, :id, :_page, :per_page, association_params)
|
49
78
|
end
|
50
79
|
|
51
80
|
def clear_search_params
|
52
|
-
params.except(:search, :
|
81
|
+
params.except(:search, :_page).permit(
|
53
82
|
:per_page, resource_name => %i[order direction]
|
54
83
|
)
|
55
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def default_resource_name(name, opts = {})
|
89
|
+
resource_name = (opts[:singular] ? name.to_s : name.to_s.pluralize)
|
90
|
+
resource_name.gsub("/", "_").titleize
|
91
|
+
end
|
56
92
|
end
|
57
93
|
end
|
@@ -24,17 +24,17 @@ to display a collection of resources in an HTML table.
|
|
24
24
|
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
|
25
25
|
<th class="cell-label
|
26
26
|
cell-label--<%= attr_type.html_class %>
|
27
|
-
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
|
27
|
+
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
|
28
|
+
cell-label--<%= "#{collection_presenter.resource_name}_#{attr_name}" %>"
|
28
29
|
scope="col"
|
29
|
-
role="columnheader"
|
30
30
|
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
|
31
31
|
<%= link_to(sanitized_order_params(page, collection_field_name).merge(
|
32
32
|
collection_presenter.order_params_for(attr_name, key: collection_field_name)
|
33
33
|
)) do %>
|
34
34
|
<%= t(
|
35
35
|
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
|
36
|
-
default: attr_name.
|
37
|
-
)
|
36
|
+
default: resource_class.human_attribute_name(attr_name).titleize,
|
37
|
+
) %>
|
38
38
|
<% if collection_presenter.ordered_by?(attr_name) %>
|
39
39
|
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
|
40
40
|
<svg aria-hidden="true">
|
@@ -45,50 +45,47 @@ to display a collection of resources in an HTML table.
|
|
45
45
|
<% end %>
|
46
46
|
</th>
|
47
47
|
<% end %>
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
<%= render(
|
49
|
+
"collection_header_actions",
|
50
|
+
collection_presenter: collection_presenter,
|
51
|
+
page: page,
|
52
|
+
resources: resources,
|
53
|
+
table_title: "page-title"
|
54
|
+
) %>
|
52
55
|
</tr>
|
53
56
|
</thead>
|
54
57
|
|
55
58
|
<tbody>
|
56
59
|
<% resources.each do |resource| %>
|
57
60
|
<tr class="js-table-row"
|
58
|
-
|
59
|
-
|
60
|
-
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
61
|
+
<% if accessible_action?(resource, :show) %>
|
62
|
+
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
61
63
|
<% end %>
|
62
64
|
>
|
63
65
|
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
64
66
|
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
65
|
-
<% if
|
67
|
+
<% if accessible_action?(resource, :show) -%>
|
66
68
|
<a href="<%= polymorphic_path([namespace, resource]) -%>"
|
69
|
+
tabindex="-1"
|
67
70
|
class="action-show"
|
68
71
|
>
|
69
72
|
<%= render_field attribute %>
|
70
73
|
</a>
|
74
|
+
<% else %>
|
75
|
+
<%= render_field attribute %>
|
71
76
|
<% end -%>
|
72
77
|
</td>
|
73
78
|
<% end %>
|
74
79
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
<td><%= link_to(
|
85
|
-
t("administrate.actions.destroy"),
|
86
|
-
[namespace, resource],
|
87
|
-
class: "text-color-red",
|
88
|
-
method: :delete,
|
89
|
-
data: { confirm: t("administrate.actions.confirm") }
|
90
|
-
) if show_action? :destroy, resource %></td>
|
91
|
-
<% end %>
|
80
|
+
<%= render(
|
81
|
+
"collection_item_actions",
|
82
|
+
collection_presenter: collection_presenter,
|
83
|
+
collection_field_name: collection_field_name,
|
84
|
+
page: page,
|
85
|
+
namespace: namespace,
|
86
|
+
resource: resource,
|
87
|
+
table_title: "page-title"
|
88
|
+
) %>
|
92
89
|
</tr>
|
93
90
|
<% end %>
|
94
91
|
</tbody>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% if existing_action?(collection_presenter.resource_name, :edit) %>
|
2
|
+
<td><%= link_to(
|
3
|
+
t("administrate.actions.edit"),
|
4
|
+
[:edit, namespace, resource],
|
5
|
+
class: "action-edit",
|
6
|
+
) if accessible_action?(resource, :edit) %></td>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% if existing_action?(collection_presenter.resource_name, :destroy) %>
|
10
|
+
<td><%= link_to(
|
11
|
+
t("administrate.actions.destroy"),
|
12
|
+
[namespace, resource],
|
13
|
+
class: "text-color-red",
|
14
|
+
method: :delete,
|
15
|
+
data: { confirm: t("administrate.actions.confirm") }
|
16
|
+
) if accessible_action?(resource, :destroy) %></td>
|
17
|
+
<% end %>
|
@@ -14,6 +14,7 @@ This partial renders flash messages on every page.
|
|
14
14
|
<% if flash.any? %>
|
15
15
|
<div class="flashes">
|
16
16
|
<% flash.each do |key, value| -%>
|
17
|
+
<% next unless value.respond_to?(:html_safe) %>
|
17
18
|
<div class="flash flash-<%= key %>"><%= value.html_safe %></div>
|
18
19
|
<% end -%>
|
19
20
|
</div>
|
@@ -21,7 +21,7 @@ and renders all form fields for a resource's editable attributes.
|
|
21
21
|
<%= t(
|
22
22
|
"administrate.form.errors",
|
23
23
|
pluralized_errors: pluralize(page.resource.errors.count, t("administrate.form.error")),
|
24
|
-
resource_name: display_resource_name(page.resource_name)
|
24
|
+
resource_name: display_resource_name(page.resource_name, singular: true)
|
25
25
|
) %>
|
26
26
|
</h2>
|
27
27
|
|
@@ -33,10 +33,25 @@ and renders all form fields for a resource's editable attributes.
|
|
33
33
|
</div>
|
34
34
|
<% end %>
|
35
35
|
|
36
|
-
<% page.attributes.each do |
|
37
|
-
<
|
38
|
-
|
39
|
-
|
36
|
+
<% page.attributes(controller.action_name).each do |title, attributes| -%>
|
37
|
+
<fieldset class="<%= "field-unit--nested" if title.present? %>">
|
38
|
+
<% if title.present? %>
|
39
|
+
<legend><%= t "helpers.label.#{f.object_name}.#{title}", default: title %></legend>
|
40
|
+
<% end %>
|
41
|
+
|
42
|
+
<% attributes.each do |attribute| %>
|
43
|
+
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
|
44
|
+
<%= render_field attribute, f: f %>
|
45
|
+
|
46
|
+
<% hint_key = "administrate.field_hints.#{page.resource_name}.#{attribute.name}" %>
|
47
|
+
<% if I18n.exists?(hint_key) -%>
|
48
|
+
<div class="field-unit__hint">
|
49
|
+
<%= I18n.t(hint_key) %>
|
50
|
+
</div>
|
51
|
+
<% end -%>
|
52
|
+
</div>
|
53
|
+
<% end %>
|
54
|
+
</fieldset>
|
40
55
|
<% end -%>
|
41
56
|
|
42
57
|
<div class="form-actions">
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg"
|
1
|
+
<svg hidden xmlns="http://www.w3.org/2000/svg">
|
2
2
|
<symbol id="icon-cancel" viewBox="0 0 48 48">
|
3
3
|
<path fill-rule="evenodd" d="M24 19.757l-8.485-8.485c-.784-.783-2.047-.782-2.827 0l-1.417 1.416c-.777.777-.78 2.046.002 2.827L19.757 24l-8.485 8.485c-.783.784-.782 2.047 0 2.827l1.416 1.417c.777.777 2.046.78 2.827-.002L24 28.243l8.485 8.485c.784.783 2.047.782 2.827 0l1.417-1.416c.777-.777.78-2.046-.002-2.827L28.243 24l8.485-8.485c.783-.784.782-2.047 0-2.827l-1.416-1.417c-.777-.777-2.046-.78-2.827.002L24 19.757zM24 47c12.703 0 23-10.297 23-23S36.703 1 24 1 1 11.297 1 24s10.297 23 23 23z" />
|
4
4
|
</symbol>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% content_for(:title) do %>
|
2
|
+
<%= display_resource_name(page.resource_name) %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<header class="main-content__header">
|
6
|
+
<h1 class="main-content__page-title" id="page-title">
|
7
|
+
<%= content_for(:title) %>
|
8
|
+
</h1>
|
9
|
+
|
10
|
+
<% if show_search_bar %>
|
11
|
+
<%= render(
|
12
|
+
"search",
|
13
|
+
search_term: search_term,
|
14
|
+
resource_name: display_resource_name(page.resource_name)
|
15
|
+
) %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<div>
|
19
|
+
<%= link_to(
|
20
|
+
t(
|
21
|
+
"administrate.actions.new_resource",
|
22
|
+
name: display_resource_name(page.resource_name, singular: true).downcase
|
23
|
+
),
|
24
|
+
[:new, namespace, page.resource_path.to_sym],
|
25
|
+
class: "button",
|
26
|
+
) if accessible_action?(new_resource, :new) %>
|
27
|
+
</div>
|
28
|
+
</header>
|
@@ -7,12 +7,14 @@ for all resources in the admin dashboard,
|
|
7
7
|
as defined by the routes in the `admin/` namespace
|
8
8
|
%>
|
9
9
|
|
10
|
-
<nav class="navigation"
|
11
|
-
|
10
|
+
<nav class="navigation">
|
11
|
+
<%= link_to(t("administrate.navigation.back_to_app"), root_url, class: "button button--alt button--nav") if defined?(root_url) %>
|
12
|
+
|
13
|
+
<% Administrate::Namespace.new(namespace).resources_with_index_route.each do |resource| %>
|
12
14
|
<%= link_to(
|
13
15
|
display_resource_name(resource),
|
14
|
-
|
16
|
+
resource_index_route(resource),
|
15
17
|
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
|
16
|
-
) %>
|
18
|
+
) if accessible_action?(model_from_resource(resource), :index) %>
|
17
19
|
<% end %>
|
18
20
|
</nav>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= paginate resources, param_name: local_assigns.fetch(:param_name, "_page") %>
|
@@ -17,7 +17,7 @@ It displays a header, and renders the `_form` partial to do the heavy lifting.
|
|
17
17
|
|
18
18
|
<% content_for(:title) { t("administrate.actions.edit_resource", name: page.page_title) } %>
|
19
19
|
|
20
|
-
<header class="main-content__header"
|
20
|
+
<header class="main-content__header">
|
21
21
|
<h1 class="main-content__page-title">
|
22
22
|
<%= content_for(:title) %>
|
23
23
|
</h1>
|
@@ -27,7 +27,7 @@ It displays a header, and renders the `_form` partial to do the heavy lifting.
|
|
27
27
|
t("administrate.actions.show_resource", name: page.page_title),
|
28
28
|
[namespace, page.resource],
|
29
29
|
class: "button",
|
30
|
-
) if
|
30
|
+
) if accessible_action?(page.resource, :show) %>
|
31
31
|
</div>
|
32
32
|
</header>
|
33
33
|
|
@@ -23,34 +23,14 @@ It renders the `_table` partial to display details about the resources.
|
|
23
23
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
|
24
24
|
%>
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
<% if show_search_bar %>
|
36
|
-
<%= render(
|
37
|
-
"search",
|
38
|
-
search_term: search_term,
|
39
|
-
resource_name: display_resource_name(page.resource_name)
|
40
|
-
) %>
|
41
|
-
<% end %>
|
42
|
-
|
43
|
-
<div>
|
44
|
-
<%= link_to(
|
45
|
-
t(
|
46
|
-
"administrate.actions.new_resource",
|
47
|
-
name: page.resource_name.titleize.downcase
|
48
|
-
),
|
49
|
-
[:new, namespace, page.resource_path],
|
50
|
-
class: "button",
|
51
|
-
) if valid_action?(:new) && show_action?(:new, new_resource) %>
|
52
|
-
</div>
|
53
|
-
</header>
|
26
|
+
<%=
|
27
|
+
render("index_header",
|
28
|
+
resources: resources,
|
29
|
+
search_term: search_term,
|
30
|
+
page: page,
|
31
|
+
show_search_bar: show_search_bar,
|
32
|
+
)
|
33
|
+
%>
|
54
34
|
|
55
35
|
<section class="main-content__body main-content__body--flush">
|
56
36
|
<%= render(
|
@@ -62,5 +42,5 @@ It renders the `_table` partial to display details about the resources.
|
|
62
42
|
table_title: "page-title"
|
63
43
|
) %>
|
64
44
|
|
65
|
-
<%=
|
45
|
+
<%= render("pagination", resources: resources) %>
|
66
46
|
</section>
|
@@ -18,7 +18,7 @@ as well as a link to its edit page.
|
|
18
18
|
|
19
19
|
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
|
20
20
|
|
21
|
-
<header class="main-content__header"
|
21
|
+
<header class="main-content__header">
|
22
22
|
<h1 class="main-content__page-title">
|
23
23
|
<%= content_for(:title) %>
|
24
24
|
</h1>
|
@@ -28,22 +28,38 @@ as well as a link to its edit page.
|
|
28
28
|
t("administrate.actions.edit_resource", name: page.page_title),
|
29
29
|
[:edit, namespace, page.resource],
|
30
30
|
class: "button",
|
31
|
-
) if
|
31
|
+
) if accessible_action?(page.resource, :edit) %>
|
32
|
+
|
33
|
+
<%= link_to(
|
34
|
+
t("administrate.actions.destroy"),
|
35
|
+
[namespace, page.resource],
|
36
|
+
class: "button button--danger",
|
37
|
+
method: :delete,
|
38
|
+
data: { confirm: t("administrate.actions.confirm") }
|
39
|
+
) if accessible_action?(page.resource, :destroy) %>
|
32
40
|
</div>
|
33
41
|
</header>
|
34
42
|
|
35
43
|
<section class="main-content__body">
|
36
44
|
<dl>
|
37
|
-
<% page.attributes.each do |
|
38
|
-
<
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
<% page.attributes.each do |title, attributes| %>
|
46
|
+
<fieldset class="<%= "field-unit--nested" if title.present? %>">
|
47
|
+
<% if title.present? %>
|
48
|
+
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
|
49
|
+
<% end %>
|
50
|
+
|
51
|
+
<% attributes.each do |attribute| %>
|
52
|
+
<dt class="attribute-label" id="<%= attribute.name %>">
|
53
|
+
<%= t(
|
54
|
+
"helpers.label.#{resource_name}.#{attribute.name}",
|
55
|
+
default: page.resource.class.human_attribute_name(attribute.name),
|
56
|
+
) %>
|
57
|
+
</dt>
|
58
|
+
|
59
|
+
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
|
60
|
+
><%= render_field attribute, page: page %></dd>
|
61
|
+
<% end %>
|
62
|
+
</fieldset>
|
47
63
|
<% end %>
|
48
64
|
</dl>
|
49
65
|
</section>
|
@@ -20,7 +20,7 @@ that displays all possible records to associate with.
|
|
20
20
|
<%= f.label field.permitted_attribute %>
|
21
21
|
</div>
|
22
22
|
<div class="field-unit__field">
|
23
|
-
<%= f.select(field.permitted_attribute
|
24
|
-
|
25
|
-
|
23
|
+
<%= f.select(field.permitted_attribute,
|
24
|
+
options_for_select(field.associated_resource_options, field.selected_option),
|
25
|
+
include_blank: field.include_blank_option) %>
|
26
26
|
</div>
|
@@ -16,7 +16,7 @@ By default, the relationship is rendered as a link to the associated object.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.data %>
|
19
|
-
<% if
|
19
|
+
<% if accessible_action?(field.data, :show) %>
|
20
20
|
<%= link_to(
|
21
21
|
field.display_associated_resource,
|
22
22
|
[namespace, field.data],
|
@@ -16,7 +16,7 @@ By default, the relationship is rendered as a link to the associated object.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.data %>
|
19
|
-
<% if
|
19
|
+
<% if accessible_action?(field.data, :show) %>
|
20
20
|
<%= link_to(
|
21
21
|
field.display_associated_resource,
|
22
22
|
[namespace, field.data],
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%#
|
2
|
+
# Date Form Partial
|
3
|
+
|
4
|
+
This partial renders an input element for a date attribute.
|
5
|
+
|
6
|
+
## Local variables:
|
7
|
+
|
8
|
+
- `f`:
|
9
|
+
A Rails form generator, used to help create the appropriate input fields.
|
10
|
+
- `field`:
|
11
|
+
An instance of [Administrate::Field::Date][1].
|
12
|
+
A wrapper around the Date value pulled from the database.
|
13
|
+
|
14
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Date
|
15
|
+
%>
|
16
|
+
|
17
|
+
<div class="field-unit__label">
|
18
|
+
<%= f.label field.attribute %>
|
19
|
+
</div>
|
20
|
+
<div class="field-unit__field">
|
21
|
+
<%= f.date_field field.attribute %>
|
22
|
+
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%#
|
2
|
+
# Date Index Partial
|
3
|
+
|
4
|
+
This partial renders a date attribute,
|
5
|
+
to be displayed on a resource's index page.
|
6
|
+
|
7
|
+
By default, the attribute is rendered
|
8
|
+
as a localized date string.
|
9
|
+
|
10
|
+
## Local variables:
|
11
|
+
|
12
|
+
- `field`:
|
13
|
+
An instance of [Administrate::Field::Date][1].
|
14
|
+
A wrapper around the Date value pulled from the database.
|
15
|
+
|
16
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Date
|
17
|
+
%>
|
18
|
+
|
19
|
+
<% if field.data %>
|
20
|
+
<%= field.date %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%#
|
2
|
+
# Date Show Partial
|
3
|
+
|
4
|
+
This partial renders a date attribute,
|
5
|
+
to be displayed on a resource's show page.
|
6
|
+
|
7
|
+
By default, the attribute is rendered
|
8
|
+
as a localized date string.
|
9
|
+
|
10
|
+
## Local variables:
|
11
|
+
|
12
|
+
- `field`:
|
13
|
+
An instance of [Administrate::Field::Date][1].
|
14
|
+
A wrapper around the Date value pulled from the database.
|
15
|
+
|
16
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Date
|
17
|
+
%>
|
18
|
+
|
19
|
+
<% if field.data %>
|
20
|
+
<%= field.date %>
|
21
|
+
<% end %>
|
@@ -2,7 +2,6 @@
|
|
2
2
|
# DateTime Form Partial
|
3
3
|
|
4
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
5
|
|
7
6
|
## Local variables:
|
8
7
|
|
@@ -13,12 +12,11 @@ By default, the input is a text field that is augmented with [DateTimePicker].
|
|
13
12
|
A wrapper around the DateTime value pulled from the database.
|
14
13
|
|
15
14
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/DateTime
|
16
|
-
[DateTimePicker]: https://github.com/Eonasdan/bootstrap-datetimepicker
|
17
15
|
%>
|
18
16
|
|
19
17
|
<div class="field-unit__label">
|
20
18
|
<%= f.label field.attribute %>
|
21
19
|
</div>
|
22
20
|
<div class="field-unit__field">
|
23
|
-
<%= f.
|
21
|
+
<%= f.datetime_local_field field.attribute, step: 1 %>
|
24
22
|
</div>
|
@@ -16,4 +16,4 @@ as a count of how many objects are associated through the relationship.
|
|
16
16
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasMany
|
17
17
|
%>
|
18
18
|
|
19
|
-
<%= pluralize(field.data.size, field.attribute.to_s.humanize.downcase.singularize) %>
|
19
|
+
<%= pluralize(field.data.size, t("activerecord.models.#{field.attribute.to_s.singularize}", default: field.attribute.to_s.humanize.downcase.singularize, count: field.data.size)) %>
|
@@ -28,9 +28,10 @@ from the associated resource class's dashboard.
|
|
28
28
|
page: page,
|
29
29
|
resources: field.resources(page_number, order),
|
30
30
|
table_title: field.name,
|
31
|
+
resource_class: field.associated_class,
|
31
32
|
) %>
|
32
33
|
<% if field.more_than_limit? %>
|
33
|
-
<%=
|
34
|
+
<%= render("pagination", resources: field.resources(page_number), param_name: "#{field.name}[page]") %>
|
34
35
|
<% end %>
|
35
36
|
|
36
37
|
<% else %>
|
@@ -18,11 +18,21 @@ The form will be rendered as nested_from to parent relationship.
|
|
18
18
|
|
19
19
|
<%= f.fields_for field.attribute, field.data || field.nested_form.resource.class.new do |has_one_f| %>
|
20
20
|
<fieldset class="field-unit--nested">
|
21
|
-
<legend><%= t "helpers.label.#{f.object_name}.#{field.
|
22
|
-
<% field.nested_form.attributes.each do |
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
<legend><%= t "helpers.label.#{f.object_name}.#{field.name}", default: field.name.titleize %></legend>
|
22
|
+
<% field.nested_form.attributes.each do |title, attributes| -%>
|
23
|
+
|
24
|
+
<fieldset class="<%= "field-unit--nested" if title.present? %>">
|
25
|
+
<% if title.present? %>
|
26
|
+
<legend><%= t "helpers.label.#{f.object_name}.#{title}", default: title %></legend>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% attributes.each do |attribute| %>
|
30
|
+
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
31
|
+
<%= render_field attribute, f: has_one_f %>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
34
|
+
</fieldset>
|
35
|
+
|
26
36
|
<% end -%>
|
27
37
|
</fieldset>
|
28
38
|
<% end %>
|