administrate 0.15.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +0 -2
- data/app/assets/javascripts/administrate/application.js +0 -2
- data/app/assets/stylesheets/administrate/application.scss +0 -1
- data/app/assets/stylesheets/administrate/base/_forms.scss +1 -1
- data/app/assets/stylesheets/administrate/components/_buttons.scss +12 -0
- data/app/assets/stylesheets/administrate/components/_flashes.scss +2 -2
- data/app/assets/stylesheets/administrate/library/_variables.scss +1 -1
- data/app/controllers/administrate/application_controller.rb +95 -17
- data/app/controllers/concerns/administrate/punditize.rb +4 -2
- data/app/helpers/administrate/application_helper.rb +24 -6
- data/app/views/administrate/application/_collection.html.erb +20 -24
- 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 +1 -1
- 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 +2 -2
- data/app/views/administrate/application/_pagination.html.erb +1 -0
- data/app/views/administrate/application/edit.html.erb +1 -1
- data/app/views/administrate/application/index.html.erb +9 -29
- data/app/views/administrate/application/show.html.erb +9 -1
- 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 +1 -3
- 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_one/_form.html.erb +1 -1
- data/app/views/fields/has_one/_index.html.erb +2 -1
- data/app/views/fields/has_one/_show.html.erb +3 -2
- 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 +4 -2
- data/app/views/fields/time/_form.html.erb +2 -3
- data/app/views/fields/time/_index.html.erb +1 -1
- data/app/views/fields/time/_show.html.erb +1 -1
- data/app/views/fields/url/_index.html.erb +2 -2
- data/app/views/fields/url/_show.html.erb +2 -2
- data/config/locales/administrate.de.yml +2 -2
- data/config/locales/administrate.sl.yml +30 -0
- data/config/locales/administrate.zh-TW.yml +1 -1
- data/docs/adding_controllers_without_related_model.md +2 -4
- data/docs/authorization.md +25 -12
- data/docs/customizing_controller_actions.md +30 -7
- data/docs/customizing_dashboards.md +62 -6
- data/docs/extending_administrate.md +5 -5
- data/docs/getting_started.md +1 -1
- data/docs/guides/customising_search.md +149 -0
- data/docs/guides/hiding_dashboards_from_sidebar.md +4 -2
- data/docs/guides/scoping_has_many_relations.md +27 -0
- data/docs/guides.md +3 -1
- data/lib/administrate/base_dashboard.rb +30 -2
- data/lib/administrate/engine.rb +2 -2
- data/lib/administrate/field/associative.rb +7 -7
- data/lib/administrate/field/base.rb +4 -0
- data/lib/administrate/field/belongs_to.rb +4 -0
- data/lib/administrate/field/deferred.rb +4 -0
- data/lib/administrate/field/has_one.rb +4 -0
- data/lib/administrate/field/select.rb +4 -0
- data/lib/administrate/field/time.rb +11 -0
- data/lib/administrate/field/url.rb +4 -0
- data/lib/administrate/namespace.rb +1 -1
- data/lib/administrate/not_authorized_error.rb +18 -0
- data/lib/administrate/order.rb +35 -5
- data/lib/administrate/page/base.rb +4 -0
- data/lib/administrate/page/form.rb +9 -2
- data/lib/administrate/resource_resolver.rb +1 -1
- data/lib/administrate/search.rb +21 -17
- data/lib/administrate/version.rb +1 -1
- data/lib/administrate/view_generator.rb +1 -1
- data/lib/administrate.rb +18 -0
- data/lib/generators/administrate/dashboard/dashboard_generator.rb +15 -2
- data/lib/generators/administrate/dashboard/templates/controller.rb.erb +2 -2
- data/lib/generators/administrate/install/templates/application_controller.rb.erb +1 -1
- metadata +11 -49
- data/app/assets/javascripts/administrate/components/date_time_picker.js +0 -14
- data/config/i18n-tasks.yml +0 -18
- data/config/routes.rb +0 -2
- data/config/unicorn.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6711a800e61649dffc4e96f9ddfaf3af21d364a1cfc659959dc5496357af262
|
4
|
+
data.tar.gz: 3dc0046165d843a60359343d756b584cb7d5a8a505c5ba4c2858749b4aceba28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88099b1defc211784c017a82dc2a4f90d91599f664a768acb652dd5a9ac3358b00180bc1f7da7b072e26cb1412b967fb7c244096005ee782fb1719340a832f3b
|
7
|
+
data.tar.gz: 2d01b4c1131ed1a7c2d9f70756c5d9b0b442abf846425c486ae0d9b5ee6d65c9d3e0e3f45b1d9864749c6901cc29cc90f3261c229ba8ba96e26ee552f92e9d88
|
data/Rakefile
CHANGED
@@ -47,5 +47,17 @@ input[type="submit"],
|
|
47
47
|
border: $base-border;
|
48
48
|
border-color: $blue;
|
49
49
|
color: $blue;
|
50
|
+
}
|
51
|
+
|
52
|
+
.button--danger {
|
53
|
+
background-color: $red;
|
54
|
+
|
55
|
+
&:hover {
|
56
|
+
background-color: mix($black, $red, 20%);
|
57
|
+
color: $white;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
.button--nav {
|
50
62
|
margin-bottom: $base-spacing;
|
51
63
|
}
|
@@ -14,7 +14,7 @@ $heading-line-height: 1.2 !default;
|
|
14
14
|
// Other Sizes
|
15
15
|
$base-border-radius: 4px !default;
|
16
16
|
$base-spacing: $base-line-height * 1em !default;
|
17
|
-
$small-spacing: $base-spacing
|
17
|
+
$small-spacing: $base-spacing * 0.5 !default;
|
18
18
|
|
19
19
|
// Colors
|
20
20
|
$white: #fff !default;
|
@@ -5,12 +5,10 @@ module Administrate
|
|
5
5
|
def index
|
6
6
|
authorize_resource(resource_class)
|
7
7
|
search_term = params[:search].to_s.strip
|
8
|
-
resources =
|
9
|
-
dashboard_class,
|
10
|
-
search_term).run
|
8
|
+
resources = filter_resources(scoped_resource, search_term: search_term)
|
11
9
|
resources = apply_collection_includes(resources)
|
12
10
|
resources = order.apply(resources)
|
13
|
-
resources = resources
|
11
|
+
resources = paginate_resources(resources)
|
14
12
|
page = Administrate::Page::Collection.new(dashboard, order: order)
|
15
13
|
|
16
14
|
render locals: {
|
@@ -47,7 +45,7 @@ module Administrate
|
|
47
45
|
|
48
46
|
if resource.save
|
49
47
|
redirect_to(
|
50
|
-
|
48
|
+
after_resource_created_path(resource),
|
51
49
|
notice: translate_with_resource("create.success"),
|
52
50
|
)
|
53
51
|
else
|
@@ -60,7 +58,7 @@ module Administrate
|
|
60
58
|
def update
|
61
59
|
if requested_resource.update(resource_params)
|
62
60
|
redirect_to(
|
63
|
-
|
61
|
+
after_resource_updated_path(requested_resource),
|
64
62
|
notice: translate_with_resource("update.success"),
|
65
63
|
)
|
66
64
|
else
|
@@ -76,25 +74,61 @@ module Administrate
|
|
76
74
|
else
|
77
75
|
flash[:error] = requested_resource.errors.full_messages.join("<br/>")
|
78
76
|
end
|
79
|
-
redirect_to
|
77
|
+
redirect_to after_resource_destroyed_path(requested_resource)
|
80
78
|
end
|
81
79
|
|
82
80
|
private
|
83
81
|
|
82
|
+
def filter_resources(resources, search_term:)
|
83
|
+
Administrate::Search.new(
|
84
|
+
resources,
|
85
|
+
dashboard,
|
86
|
+
search_term,
|
87
|
+
).run
|
88
|
+
end
|
89
|
+
|
90
|
+
def after_resource_destroyed_path(_requested_resource)
|
91
|
+
{ action: :index }
|
92
|
+
end
|
93
|
+
|
94
|
+
def after_resource_created_path(requested_resource)
|
95
|
+
[namespace, requested_resource]
|
96
|
+
end
|
97
|
+
|
98
|
+
def after_resource_updated_path(requested_resource)
|
99
|
+
[namespace, requested_resource]
|
100
|
+
end
|
101
|
+
|
84
102
|
helper_method :nav_link_state
|
85
103
|
def nav_link_state(resource)
|
86
|
-
|
104
|
+
underscore_resource = resource.to_s.split("/").join("__")
|
105
|
+
resource_name.to_s.pluralize == underscore_resource ? :active : :inactive
|
87
106
|
end
|
88
107
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
108
|
+
# Whether the named action route exists for the resource class.
|
109
|
+
#
|
110
|
+
# @param resource [Class, String, Symbol] A class of resources, or the name
|
111
|
+
# of a class of resources.
|
112
|
+
# @param action_name [String, Symbol] The name of an action that might be
|
113
|
+
# possible to perform on a resource or resource class.
|
114
|
+
# @return [Boolean] `true` if a route exists for the resource class and the
|
115
|
+
# action. `false` otherwise.
|
116
|
+
def existing_action?(resource, action_name)
|
117
|
+
routes.include?([resource.to_s.underscore.pluralize, action_name.to_s])
|
94
118
|
end
|
119
|
+
helper_method :existing_action?
|
120
|
+
|
121
|
+
# @deprecated Use {#existing_action} instead. Note that, in
|
122
|
+
# {#existing_action}, the order of parameters is reversed and
|
123
|
+
# there is no default value for the `resource` parameter.
|
124
|
+
def valid_action?(action_name, resource = resource_class)
|
125
|
+
Administrate.warn_of_deprecated_authorization_method(__method__)
|
126
|
+
existing_action?(resource, action_name)
|
127
|
+
end
|
128
|
+
helper_method :valid_action?
|
95
129
|
|
96
130
|
def routes
|
97
|
-
@routes ||= Namespace.new(namespace).routes
|
131
|
+
@routes ||= Namespace.new(namespace).routes.to_set
|
98
132
|
end
|
99
133
|
|
100
134
|
def records_per_page
|
@@ -102,7 +136,23 @@ module Administrate
|
|
102
136
|
end
|
103
137
|
|
104
138
|
def order
|
105
|
-
@order ||= Administrate::Order.new(
|
139
|
+
@order ||= Administrate::Order.new(
|
140
|
+
sorting_attribute,
|
141
|
+
sorting_direction,
|
142
|
+
association_attribute: order_by_field(
|
143
|
+
dashboard_attribute(sorting_attribute),
|
144
|
+
),
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
def order_by_field(dashboard)
|
149
|
+
return unless dashboard.try(:options)
|
150
|
+
|
151
|
+
dashboard.options.fetch(:order, nil)
|
152
|
+
end
|
153
|
+
|
154
|
+
def dashboard_attribute(attribute)
|
155
|
+
dashboard.attribute_types[attribute.to_sym] if attribute
|
106
156
|
end
|
107
157
|
|
108
158
|
def sorting_attribute
|
@@ -193,9 +243,26 @@ module Administrate
|
|
193
243
|
).any? { |_name, attribute| attribute.searchable? }
|
194
244
|
end
|
195
245
|
|
196
|
-
|
246
|
+
# Whether the current user is authorized to perform the named action on the
|
247
|
+
# resource.
|
248
|
+
#
|
249
|
+
# @param _resource [ActiveRecord::Base, Class, String, Symbol] The
|
250
|
+
# temptative target of the action, or the name of its class.
|
251
|
+
# @param _action_name [String, Symbol] The name of an action that might be
|
252
|
+
# possible to perform on a resource or resource class.
|
253
|
+
# @return [Boolean] `true` if the current user is authorized to perform the
|
254
|
+
# action on the resource. `false` otherwise.
|
255
|
+
def authorized_action?(_resource, _action_name)
|
197
256
|
true
|
198
257
|
end
|
258
|
+
helper_method :authorized_action?
|
259
|
+
|
260
|
+
# @deprecated Use {#authorized_action} instead. Note that the order of
|
261
|
+
# parameters is reversed in {#authorized_action}.
|
262
|
+
def show_action?(action, resource)
|
263
|
+
Administrate.warn_of_deprecated_authorization_method(__method__)
|
264
|
+
authorized_action?(resource, action)
|
265
|
+
end
|
199
266
|
helper_method :show_action?
|
200
267
|
|
201
268
|
def new_resource
|
@@ -204,7 +271,18 @@ module Administrate
|
|
204
271
|
helper_method :new_resource
|
205
272
|
|
206
273
|
def authorize_resource(resource)
|
207
|
-
resource
|
274
|
+
if authorized_action?(resource, action_name)
|
275
|
+
resource
|
276
|
+
else
|
277
|
+
raise Administrate::NotAuthorizedError.new(
|
278
|
+
action: action_name,
|
279
|
+
resource: resource,
|
280
|
+
)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def paginate_resources(resources)
|
285
|
+
resources.page(params[:_page]).per(records_per_page)
|
208
286
|
end
|
209
287
|
end
|
210
288
|
end
|
@@ -2,9 +2,11 @@ module Administrate
|
|
2
2
|
module Punditize
|
3
3
|
if Object.const_defined?("Pundit")
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
include Pundit
|
5
|
+
include Pundit::Authorization
|
6
6
|
|
7
7
|
included do
|
8
|
+
private
|
9
|
+
|
8
10
|
def scoped_resource
|
9
11
|
policy_scope_admin super
|
10
12
|
end
|
@@ -13,7 +15,7 @@ module Administrate
|
|
13
15
|
authorize resource
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
18
|
+
def authorized_action?(resource, action)
|
17
19
|
Pundit.policy!(pundit_user, resource).send("#{action}?".to_sym)
|
18
20
|
end
|
19
21
|
end
|
@@ -4,11 +4,7 @@ module Administrate
|
|
4
4
|
SINGULAR_COUNT = 1
|
5
5
|
|
6
6
|
def application_title
|
7
|
-
|
8
|
-
Rails.application.class.parent_name.titlecase
|
9
|
-
else
|
10
|
-
Rails.application.class.module_parent_name.titlecase
|
11
|
-
end
|
7
|
+
Rails.application.class.module_parent_name.titlecase
|
12
8
|
end
|
13
9
|
|
14
10
|
def render_field(field, locals = {})
|
@@ -29,6 +25,28 @@ module Administrate
|
|
29
25
|
dashboard.try(:model) || resource_name.to_sym
|
30
26
|
end
|
31
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
|
+
|
32
50
|
def display_resource_name(resource_name, opts = {})
|
33
51
|
dashboard_from_resource(resource_name).resource_name(
|
34
52
|
count: opts[:singular] ? SINGULAR_COUNT : PLURAL_MANY_COUNT,
|
@@ -52,7 +70,7 @@ module Administrate
|
|
52
70
|
end
|
53
71
|
|
54
72
|
def sanitized_order_params(page, current_field_name)
|
55
|
-
collection_names = page.
|
73
|
+
collection_names = page.item_associations + [current_field_name]
|
56
74
|
association_params = collection_names.map do |assoc_name|
|
57
75
|
{ assoc_name => %i[order direction page per_page] }
|
58
76
|
end
|
@@ -24,7 +24,8 @@ 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
30
|
role="columnheader"
|
30
31
|
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
|
@@ -45,23 +46,26 @@ to display a collection of resources in an HTML table.
|
|
45
46
|
<% end %>
|
46
47
|
</th>
|
47
48
|
<% end %>
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
<%= render(
|
50
|
+
"collection_header_actions",
|
51
|
+
collection_presenter: collection_presenter,
|
52
|
+
page: page,
|
53
|
+
resources: resources,
|
54
|
+
table_title: "page-title"
|
55
|
+
) %>
|
52
56
|
</tr>
|
53
57
|
</thead>
|
54
58
|
|
55
59
|
<tbody>
|
56
60
|
<% resources.each do |resource| %>
|
57
61
|
<tr class="js-table-row"
|
58
|
-
<% if
|
62
|
+
<% if accessible_action?(resource, :show) %>
|
59
63
|
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
60
64
|
<% end %>
|
61
65
|
>
|
62
66
|
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
63
67
|
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
64
|
-
<% if
|
68
|
+
<% if accessible_action?(resource, :show) -%>
|
65
69
|
<a href="<%= polymorphic_path([namespace, resource]) -%>"
|
66
70
|
tabindex="-1"
|
67
71
|
class="action-show"
|
@@ -74,23 +78,15 @@ to display a collection of resources in an HTML table.
|
|
74
78
|
</td>
|
75
79
|
<% end %>
|
76
80
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
<td><%= link_to(
|
87
|
-
t("administrate.actions.destroy"),
|
88
|
-
[namespace, resource],
|
89
|
-
class: "text-color-red",
|
90
|
-
method: :delete,
|
91
|
-
data: { confirm: t("administrate.actions.confirm") }
|
92
|
-
) if show_action? :destroy, resource %></td>
|
93
|
-
<% end %>
|
81
|
+
<%= render(
|
82
|
+
"collection_item_actions",
|
83
|
+
collection_presenter: collection_presenter,
|
84
|
+
collection_field_name: collection_field_name,
|
85
|
+
page: page,
|
86
|
+
namespace: namespace,
|
87
|
+
resource: resource,
|
88
|
+
table_title: "page-title"
|
89
|
+
) %>
|
94
90
|
</tr>
|
95
91
|
<% end %>
|
96
92
|
</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>
|
@@ -33,7 +33,7 @@ and renders all form fields for a resource's editable attributes.
|
|
33
33
|
</div>
|
34
34
|
<% end %>
|
35
35
|
|
36
|
-
<% page.attributes.each do |attribute| -%>
|
36
|
+
<% page.attributes(controller.action_name).each do |attribute| -%>
|
37
37
|
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
|
38
38
|
<%= render_field attribute, f: f %>
|
39
39
|
</div>
|
@@ -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" role="banner">
|
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>
|
@@ -8,13 +8,13 @@ as defined by the routes in the `admin/` namespace
|
|
8
8
|
%>
|
9
9
|
|
10
10
|
<nav class="navigation" role="navigation">
|
11
|
-
<%= link_to(t("administrate.navigation.back_to_app"), root_url, class: "button button--alt") if defined?(root_url) %>
|
11
|
+
<%= link_to(t("administrate.navigation.back_to_app"), root_url, class: "button button--alt button--nav") if defined?(root_url) %>
|
12
12
|
|
13
13
|
<% Administrate::Namespace.new(namespace).resources_with_index_route.each do |resource| %>
|
14
14
|
<%= link_to(
|
15
15
|
display_resource_name(resource),
|
16
16
|
resource_index_route(resource),
|
17
17
|
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
|
18
|
-
) if
|
18
|
+
) if accessible_action?(model_from_resource(resource), :index) %>
|
19
19
|
<% end %>
|
20
20
|
</nav>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= paginate resources, param_name: '_page' %>
|
@@ -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: display_resource_name(page.resource_name, singular: true).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>
|
@@ -28,7 +28,15 @@ 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
|
|
@@ -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],
|
@@ -2,7 +2,6 @@
|
|
2
2
|
# Date Form Partial
|
3
3
|
|
4
4
|
This partial renders an input element for a date 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 Date value pulled from the database.
|
14
13
|
|
15
14
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Date
|
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.date_field field.attribute %>
|
24
22
|
</div>
|
@@ -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>
|