administrate 0.12.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/administrate/components/associative.js +5 -0
- data/app/assets/javascripts/administrate/components/date_time_picker.js +6 -2
- data/app/assets/javascripts/administrate/components/table.js +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 +8 -0
- data/app/assets/stylesheets/administrate/components/_cells.scss +2 -0
- data/app/assets/stylesheets/administrate/components/_field-unit.scss +17 -4
- data/app/assets/stylesheets/administrate/components/_flashes.scss +0 -8
- 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 +10 -8
- data/app/controllers/administrate/application_controller.rb +29 -8
- data/app/helpers/administrate/application_helper.rb +32 -14
- data/app/views/administrate/application/_collection.html.erb +6 -4
- data/app/views/administrate/application/_form.html.erb +2 -2
- data/app/views/administrate/application/_navigation.html.erb +5 -3
- data/app/views/administrate/application/index.html.erb +2 -2
- data/app/views/administrate/application/show.html.erb +1 -1
- data/app/views/fields/belongs_to/_form.html.erb +3 -3
- data/app/views/fields/date/_form.html.erb +24 -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/has_one/_index.html.erb +1 -1
- data/app/views/fields/has_one/_show.html.erb +4 -4
- data/app/views/fields/number/_form.html.erb +1 -1
- data/app/views/fields/polymorphic/_show.html.erb +1 -1
- data/app/views/fields/select/_form.html.erb +21 -9
- 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 +3 -2
- data/app/views/fields/time/_index.html.erb +3 -1
- data/app/views/fields/time/_show.html.erb +3 -1
- data/app/views/layouts/administrate/application.html.erb +1 -0
- 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 +2 -0
- 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 +2 -0
- 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.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/config/unicorn.rb +8 -13
- data/docs/adding_controllers_without_related_model.md +54 -0
- data/docs/adding_custom_field_types.md +3 -1
- data/docs/authentication.md +3 -1
- data/docs/authorization.md +5 -3
- data/docs/customizing_attribute_partials.md +4 -1
- data/docs/customizing_controller_actions.md +30 -1
- data/docs/customizing_dashboards.md +47 -35
- 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/hiding_dashboards_from_sidebar.md +19 -0
- data/docs/guides.md +5 -0
- data/docs/rails_api.md +5 -3
- data/lib/administrate/base_dashboard.rb +19 -10
- data/lib/administrate/custom_dashboard.rb +15 -0
- data/lib/administrate/engine.rb +7 -0
- data/lib/administrate/field/associative.rb +49 -5
- data/lib/administrate/field/base.rb +35 -9
- data/lib/administrate/field/belongs_to.rb +13 -3
- data/lib/administrate/field/date.rb +20 -0
- data/lib/administrate/field/deferred.rb +22 -3
- data/lib/administrate/field/has_many.rb +15 -2
- data/lib/administrate/field/has_one.rb +32 -12
- data/lib/administrate/field/number.rb +19 -2
- data/lib/administrate/field/polymorphic.rb +5 -5
- data/lib/administrate/field/select.rb +6 -1
- data/lib/administrate/namespace.rb +4 -0
- data/lib/administrate/order.rb +17 -7
- data/lib/administrate/page/base.rb +1 -3
- data/lib/administrate/page/form.rb +1 -1
- data/lib/administrate/resource_resolver.rb +1 -1
- data/lib/administrate/search.rb +26 -19
- data/lib/administrate/version.rb +1 -1
- data/lib/administrate/view_generator.rb +9 -3
- data/lib/administrate.rb +19 -0
- data/lib/generators/administrate/dashboard/dashboard_generator.rb +18 -14
- data/lib/generators/administrate/dashboard/templates/controller.rb.erb +20 -8
- data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +4 -4
- data/lib/generators/administrate/install/install_generator.rb +37 -1
- data/lib/generators/administrate/install/templates/application_controller.rb.erb +3 -3
- data/lib/generators/administrate/routes/routes_generator.rb +15 -25
- data/lib/generators/administrate/views/views_generator.rb +5 -4
- metadata +26 -29
- data/app/assets/javascripts/administrate/components/has_many_form.js +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb407c439ba3795c3161109f57d64a8e20db553d80f583c6d2a66bfe0f713cd7
|
4
|
+
data.tar.gz: 1691010813773e6ecc19b067adb4a610c6624f2ec2d8a03bb6414a683d5d83b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fc7042ed3389b1cf87a4ba41681e310dc3678e790a5af0d3c3e3d64c213f50b5bf66409069159a18e784c9cdaf5e6d60e2d2614f4647b5ab0d8e0b4e2f6b70e
|
7
|
+
data.tar.gz: 1c8b66a38eca96f2002ccd8b253b4fc7abd082e7376111e2e1be399b870755ce29511982828760fd6a229f5571eb1ace83a9121fae2253db2653218ffbd237ce
|
@@ -1,10 +1,14 @@
|
|
1
1
|
$(function () {
|
2
2
|
$('[data-type="time"]').datetimepicker({
|
3
3
|
debug: false,
|
4
|
-
format:
|
4
|
+
format: 'HH:mm:ss',
|
5
5
|
});
|
6
6
|
$('[data-type="datetime"]').datetimepicker({
|
7
7
|
debug: false,
|
8
|
-
format:
|
8
|
+
format: 'YYYY-MM-DD HH:mm:ss',
|
9
|
+
});
|
10
|
+
$('[data-type="date"]').datetimepicker({
|
11
|
+
debug: false,
|
12
|
+
format: 'YYYY-MM-DD',
|
9
13
|
});
|
10
14
|
});
|
@@ -13,7 +13,7 @@ $(function() {
|
|
13
13
|
var dataUrl = $(event.target).closest("tr").data("url");
|
14
14
|
var selection = window.getSelection().toString();
|
15
15
|
if (selection.length === 0 && dataUrl) {
|
16
|
-
window.location = dataUrl;
|
16
|
+
window.location = window.location.protocol + '//' + window.location.host + dataUrl;
|
17
17
|
}
|
18
18
|
}
|
19
19
|
};
|
@@ -3,9 +3,9 @@
|
|
3
3
|
clear: left;
|
4
4
|
float: left;
|
5
5
|
margin-bottom: $base-spacing;
|
6
|
-
margin-top: 0;
|
6
|
+
margin-top: 0.25em;
|
7
7
|
text-align: right;
|
8
|
-
width: calc(
|
8
|
+
width: calc(20% - 1rem);
|
9
9
|
}
|
10
10
|
|
11
11
|
.preserve-whitespace {
|
@@ -17,7 +17,8 @@
|
|
17
17
|
float: left;
|
18
18
|
margin-bottom: $base-spacing;
|
19
19
|
margin-left: 2rem;
|
20
|
-
width: calc(
|
20
|
+
width: calc(80% - 1rem);
|
21
|
+
word-break: break-word;
|
21
22
|
}
|
22
23
|
|
23
24
|
.attribute--nested {
|
@@ -17,20 +17,33 @@
|
|
17
17
|
.field-unit__field {
|
18
18
|
float: left;
|
19
19
|
margin-left: 2rem;
|
20
|
-
width:
|
20
|
+
max-width: 50rem;
|
21
|
+
width: 100%;
|
22
|
+
|
23
|
+
.optgroup-header {
|
24
|
+
font-weight: $bold-font-weight;
|
25
|
+
}
|
21
26
|
}
|
22
27
|
|
23
28
|
.field-unit--nested {
|
24
29
|
border: $base-border;
|
25
30
|
margin-left: 7.5%;
|
31
|
+
max-width: 60rem;
|
26
32
|
padding: $small-spacing;
|
27
|
-
width:
|
33
|
+
width: 100%;
|
28
34
|
|
29
35
|
.field-unit__field {
|
30
|
-
width:
|
36
|
+
width: 100%;
|
31
37
|
}
|
32
38
|
|
33
39
|
.field-unit__label {
|
34
|
-
width:
|
40
|
+
width: 10rem;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
.field-unit--required {
|
45
|
+
label::after {
|
46
|
+
color: $red;
|
47
|
+
content: " *";
|
35
48
|
}
|
36
49
|
}
|
@@ -2,9 +2,8 @@ $_navigation-link-padding: 0.6em;
|
|
2
2
|
|
3
3
|
.navigation {
|
4
4
|
flex: 1 0 10rem;
|
5
|
-
padding
|
6
|
-
padding-
|
7
|
-
padding-top: $base-spacing;
|
5
|
+
padding: $base-spacing;
|
6
|
+
padding-left: 0;
|
8
7
|
}
|
9
8
|
|
10
9
|
.navigation__link {
|
@@ -22,8 +22,10 @@ $black: #000 !default;
|
|
22
22
|
|
23
23
|
$blue: #1976d2 !default;
|
24
24
|
$red: #d32f2f !default;
|
25
|
-
$light-yellow: #
|
26
|
-
$light-
|
25
|
+
$light-yellow: #fff6bf !default;
|
26
|
+
$light-red: #fbe3e4 !default;
|
27
|
+
$light-green: #e6efc2 !default;
|
28
|
+
$light-blue: #e5edf8 !default;
|
27
29
|
|
28
30
|
$grey-0: #f6f7f7 !default;
|
29
31
|
$grey-1: #dfe0e1 !default;
|
@@ -47,12 +49,12 @@ $focus-outline: $focus-outline-width solid $focus-outline-color;
|
|
47
49
|
$focus-outline-offset: 1px;
|
48
50
|
|
49
51
|
// Flash Colors
|
50
|
-
$
|
51
|
-
alert: $light-yellow,
|
52
|
-
error: $red,
|
53
|
-
notice:
|
54
|
-
success: $light-green
|
55
|
-
);
|
52
|
+
$flashes: (
|
53
|
+
"alert": $light-yellow,
|
54
|
+
"error": $light-red,
|
55
|
+
"notice": $light-blue,
|
56
|
+
"success": $light-green
|
57
|
+
) !default;
|
56
58
|
|
57
59
|
// Border
|
58
60
|
$base-border-color: $grey-1 !default;
|
@@ -3,13 +3,14 @@ module Administrate
|
|
3
3
|
protect_from_forgery with: :exception
|
4
4
|
|
5
5
|
def index
|
6
|
+
authorize_resource(resource_class)
|
6
7
|
search_term = params[:search].to_s.strip
|
7
8
|
resources = Administrate::Search.new(scoped_resource,
|
8
9
|
dashboard_class,
|
9
10
|
search_term).run
|
10
11
|
resources = apply_collection_includes(resources)
|
11
12
|
resources = order.apply(resources)
|
12
|
-
resources = resources.page(params[:
|
13
|
+
resources = resources.page(params[:_page]).per(records_per_page)
|
13
14
|
page = Administrate::Page::Collection.new(dashboard, order: order)
|
14
15
|
|
15
16
|
render locals: {
|
@@ -27,7 +28,7 @@ module Administrate
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def new
|
30
|
-
resource =
|
31
|
+
resource = new_resource
|
31
32
|
authorize_resource(resource)
|
32
33
|
render locals: {
|
33
34
|
page: Administrate::Page::Form.new(dashboard, resource),
|
@@ -52,7 +53,7 @@ module Administrate
|
|
52
53
|
else
|
53
54
|
render :new, locals: {
|
54
55
|
page: Administrate::Page::Form.new(dashboard, resource),
|
55
|
-
}
|
56
|
+
}, status: :unprocessable_entity
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
@@ -65,7 +66,7 @@ module Administrate
|
|
65
66
|
else
|
66
67
|
render :edit, locals: {
|
67
68
|
page: Administrate::Page::Form.new(dashboard, requested_resource),
|
68
|
-
}
|
69
|
+
}, status: :unprocessable_entity
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
@@ -101,10 +102,27 @@ module Administrate
|
|
101
102
|
end
|
102
103
|
|
103
104
|
def order
|
104
|
-
@order ||= Administrate::Order.new(
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
@order ||= Administrate::Order.new(sorting_attribute, sorting_direction)
|
106
|
+
end
|
107
|
+
|
108
|
+
def sorting_attribute
|
109
|
+
sorting_params.fetch(:order) { default_sorting_attribute }
|
110
|
+
end
|
111
|
+
|
112
|
+
def default_sorting_attribute
|
113
|
+
nil
|
114
|
+
end
|
115
|
+
|
116
|
+
def sorting_direction
|
117
|
+
sorting_params.fetch(:direction) { default_sorting_direction }
|
118
|
+
end
|
119
|
+
|
120
|
+
def default_sorting_direction
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def sorting_params
|
125
|
+
Hash.try_convert(request.query_parameters[resource_name]) || {}
|
108
126
|
end
|
109
127
|
|
110
128
|
def dashboard
|
@@ -144,6 +162,8 @@ module Administrate
|
|
144
162
|
else
|
145
163
|
raise "Unrecognised param data: #{data.inspect}"
|
146
164
|
end
|
165
|
+
elsif data.is_a?(ActionController::Parameters)
|
166
|
+
data.transform_values { |v| read_param_value(v) }
|
147
167
|
else
|
148
168
|
data
|
149
169
|
end
|
@@ -153,6 +173,7 @@ module Administrate
|
|
153
173
|
to: :resource_resolver
|
154
174
|
helper_method :namespace
|
155
175
|
helper_method :resource_name
|
176
|
+
helper_method :resource_class
|
156
177
|
|
157
178
|
def resource_resolver
|
158
179
|
@resource_resolver ||=
|
@@ -1,6 +1,7 @@
|
|
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
|
if Rails::VERSION::MAJOR <= 5
|
@@ -11,21 +12,28 @@ module Administrate
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def render_field(field, locals = {})
|
14
|
-
locals
|
15
|
+
locals[:field] = field
|
15
16
|
render locals: locals, partial: field.to_partial_path
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
-
|
19
|
+
def requireness(field)
|
20
|
+
field.required? ? "required" : "optional"
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def dashboard_from_resource(resource_name)
|
24
|
+
"#{resource_name.to_s.singularize}_dashboard".classify.constantize
|
25
|
+
end
|
26
|
+
|
27
|
+
def model_from_resource(resource_name)
|
28
|
+
dashboard = dashboard_from_resource(resource_name)
|
29
|
+
dashboard.try(:model) || resource_name.to_sym
|
30
|
+
end
|
31
|
+
|
32
|
+
def display_resource_name(resource_name, opts = {})
|
33
|
+
dashboard_from_resource(resource_name).resource_name(
|
34
|
+
count: opts[:singular] ? SINGULAR_COUNT : PLURAL_MANY_COUNT,
|
35
|
+
default: default_resource_name(resource_name, opts),
|
36
|
+
)
|
29
37
|
end
|
30
38
|
|
31
39
|
def sort_order(order)
|
@@ -36,8 +44,11 @@ module Administrate
|
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
39
|
-
def
|
40
|
-
|
47
|
+
def resource_index_route(resource_name)
|
48
|
+
url_for(
|
49
|
+
action: "index",
|
50
|
+
controller: "/#{namespace}/#{resource_name}",
|
51
|
+
)
|
41
52
|
end
|
42
53
|
|
43
54
|
def sanitized_order_params(page, current_field_name)
|
@@ -45,13 +56,20 @@ module Administrate
|
|
45
56
|
association_params = collection_names.map do |assoc_name|
|
46
57
|
{ assoc_name => %i[order direction page per_page] }
|
47
58
|
end
|
48
|
-
params.permit(:search, :id, :
|
59
|
+
params.permit(:search, :id, :_page, :per_page, association_params)
|
49
60
|
end
|
50
61
|
|
51
62
|
def clear_search_params
|
52
|
-
params.except(:search, :
|
63
|
+
params.except(:search, :_page).permit(
|
53
64
|
:per_page, resource_name => %i[order direction]
|
54
65
|
)
|
55
66
|
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def default_resource_name(name, opts = {})
|
71
|
+
resource_name = (opts[:singular] ? name.to_s : name.to_s.pluralize)
|
72
|
+
resource_name.gsub("/", "_").titleize
|
73
|
+
end
|
56
74
|
end
|
57
75
|
end
|
@@ -33,7 +33,7 @@ to display a collection of resources in an HTML table.
|
|
33
33
|
)) do %>
|
34
34
|
<%= t(
|
35
35
|
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
|
36
|
-
default: attr_name
|
36
|
+
default: resource_class.human_attribute_name(attr_name),
|
37
37
|
).titleize %>
|
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) %>">
|
@@ -55,19 +55,21 @@ to display a collection of resources in an HTML table.
|
|
55
55
|
<tbody>
|
56
56
|
<% resources.each do |resource| %>
|
57
57
|
<tr class="js-table-row"
|
58
|
-
|
59
|
-
|
60
|
-
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
58
|
+
<% if show_action? :show, resource %>
|
59
|
+
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
61
60
|
<% end %>
|
62
61
|
>
|
63
62
|
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
64
63
|
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
65
64
|
<% if show_action? :show, resource -%>
|
66
65
|
<a href="<%= polymorphic_path([namespace, resource]) -%>"
|
66
|
+
tabindex="-1"
|
67
67
|
class="action-show"
|
68
68
|
>
|
69
69
|
<%= render_field attribute %>
|
70
70
|
</a>
|
71
|
+
<% else %>
|
72
|
+
<%= render_field attribute %>
|
71
73
|
<% end -%>
|
72
74
|
</td>
|
73
75
|
<% end %>
|
@@ -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
|
|
@@ -34,7 +34,7 @@ and renders all form fields for a resource's editable attributes.
|
|
34
34
|
<% end %>
|
35
35
|
|
36
36
|
<% page.attributes.each do |attribute| -%>
|
37
|
-
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
37
|
+
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
|
38
38
|
<%= render_field attribute, f: f %>
|
39
39
|
</div>
|
40
40
|
<% end -%>
|
@@ -8,11 +8,13 @@ as defined by the routes in the `admin/` namespace
|
|
8
8
|
%>
|
9
9
|
|
10
10
|
<nav class="navigation" role="navigation">
|
11
|
-
|
11
|
+
<%= link_to(t("administrate.navigation.back_to_app"), root_url, class: "button button--alt") 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 valid_action?(:index, resource) && show_action?(:index, model_from_resource(resource)) %>
|
17
19
|
<% end %>
|
18
20
|
</nav>
|
@@ -44,7 +44,7 @@ It renders the `_table` partial to display details about the resources.
|
|
44
44
|
<%= link_to(
|
45
45
|
t(
|
46
46
|
"administrate.actions.new_resource",
|
47
|
-
name: page.resource_name.
|
47
|
+
name: display_resource_name(page.resource_name, singular: true).downcase
|
48
48
|
),
|
49
49
|
[:new, namespace, page.resource_path],
|
50
50
|
class: "button",
|
@@ -62,5 +62,5 @@ It renders the `_table` partial to display details about the resources.
|
|
62
62
|
table_title: "page-title"
|
63
63
|
) %>
|
64
64
|
|
65
|
-
<%= paginate resources %>
|
65
|
+
<%= paginate resources, param_name: '_page' %>
|
66
66
|
</section>
|
@@ -38,7 +38,7 @@ as well as a link to its edit page.
|
|
38
38
|
<dt class="attribute-label" id="<%= attribute.name %>">
|
39
39
|
<%= t(
|
40
40
|
"helpers.label.#{resource_name}.#{attribute.name}",
|
41
|
-
default: attribute.name
|
41
|
+
default: page.resource.class.human_attribute_name(attribute.name),
|
42
42
|
) %>
|
43
43
|
</dt>
|
44
44
|
|
@@ -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>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%#
|
2
|
+
# Date Form Partial
|
3
|
+
|
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
|
+
|
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::Date][1].
|
13
|
+
A wrapper around the Date value pulled from the database.
|
14
|
+
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Date
|
16
|
+
[DateTimePicker]: https://github.com/Eonasdan/bootstrap-datetimepicker
|
17
|
+
%>
|
18
|
+
|
19
|
+
<div class="field-unit__label">
|
20
|
+
<%= f.label field.attribute %>
|
21
|
+
</div>
|
22
|
+
<div class="field-unit__field">
|
23
|
+
<%= f.text_field field.attribute, data: { type: 'date' } %>
|
24
|
+
</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 %>
|
@@ -15,7 +15,7 @@ By default, the relationship is rendered as a link to the associated object.
|
|
15
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasOne
|
16
16
|
%>
|
17
17
|
|
18
|
-
<% if field.
|
18
|
+
<% if field.linkable? %>
|
19
19
|
<%= link_to(
|
20
20
|
field.display_associated_resource,
|
21
21
|
[namespace, field.data],
|
@@ -4,7 +4,7 @@
|
|
4
4
|
This partial renders a has_one relationship,
|
5
5
|
to be displayed on a resource's show page.
|
6
6
|
|
7
|
-
All
|
7
|
+
All show page attributes of has_one relationship would be rendered
|
8
8
|
|
9
9
|
## Local variables:
|
10
10
|
|
@@ -15,7 +15,7 @@ All fields of has_one relationship would be rendered
|
|
15
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasOne
|
16
16
|
%>
|
17
17
|
|
18
|
-
<% if field.
|
18
|
+
<% if field.linkable? %>
|
19
19
|
<fieldset class="attribute--nested">
|
20
20
|
<legend>
|
21
21
|
<%= link_to(
|
@@ -23,7 +23,7 @@ All fields of has_one relationship would be rendered
|
|
23
23
|
[namespace, field.data],
|
24
24
|
) %>
|
25
25
|
</legend>
|
26
|
-
<% field.
|
26
|
+
<% field.nested_show.attributes.each do |attribute| -%>
|
27
27
|
<div>
|
28
28
|
<dt class="attribute-label">
|
29
29
|
<%= t(
|
@@ -32,7 +32,7 @@ All fields of has_one relationship would be rendered
|
|
32
32
|
) %>
|
33
33
|
</dt>
|
34
34
|
<dd class="attribute-data attribute-data--<%= attribute.html_class %>">
|
35
|
-
<%= attribute
|
35
|
+
<%= render_field attribute, { page: page } %>
|
36
36
|
</dd>
|
37
37
|
</div>
|
38
38
|
<% end -%>
|
@@ -17,7 +17,7 @@ By default, the relationship is rendered as a link to the associated object.
|
|
17
17
|
%>
|
18
18
|
|
19
19
|
<% if field.data %>
|
20
|
-
<% if valid_action?(:show, field.
|
20
|
+
<% if valid_action?(:show, field.data.class) %>
|
21
21
|
<%= link_to(
|
22
22
|
field.display_associated_resource,
|
23
23
|
[namespace, field.data],
|
@@ -19,13 +19,25 @@ to be displayed on a resource's edit form page.
|
|
19
19
|
<%= f.label field.attribute %>
|
20
20
|
</div>
|
21
21
|
<div class="field-unit__field">
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
<% if field.selectable_options.first&.is_a?(Array) %>
|
23
|
+
<%= f.select(
|
24
|
+
field.attribute,
|
25
|
+
options_from_collection_for_select(
|
26
|
+
field.selectable_options,
|
27
|
+
:last,
|
28
|
+
:first,
|
29
|
+
field.data,
|
30
|
+
)
|
31
|
+
) %>
|
32
|
+
<% else %>
|
33
|
+
<%= f.select(
|
34
|
+
field.attribute,
|
35
|
+
options_from_collection_for_select(
|
36
|
+
field.selectable_options,
|
37
|
+
:to_s,
|
38
|
+
:to_s,
|
39
|
+
field.data,
|
40
|
+
)
|
41
|
+
) %>
|
42
|
+
<% end %>
|
31
43
|
</div>
|