administrate 0.11.0 → 0.17.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/base/_typography.scss +1 -1
- data/app/assets/stylesheets/administrate/components/_attributes.scss +4 -3
- data/app/assets/stylesheets/administrate/components/_buttons.scss +11 -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 +50 -16
- data/app/controllers/concerns/administrate/punditize.rb +3 -3
- data/app/helpers/administrate/application_helper.rb +41 -15
- data/app/views/administrate/application/_collection.html.erb +24 -26
- 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 +3 -3
- data/app/views/administrate/application/{_icons.erb → _icons.html.erb} +1 -1
- data/app/views/administrate/application/_index_header.html.erb +28 -0
- data/app/views/administrate/application/_navigation.html.erb +5 -3
- data/app/views/administrate/application/index.html.erb +9 -29
- 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/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 +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 +24 -10
- 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/fields/url/_form.html.erb +23 -0
- data/app/views/fields/url/_index.html.erb +20 -0
- data/app/views/fields/url/_show.html.erb +20 -0
- 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 +2 -0
- data/config/locales/administrate.en.yml +2 -0
- data/config/locales/administrate.es.yml +3 -1
- 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 +12 -10
- 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 +4 -2
- data/config/locales/administrate.zh-TW.yml +2 -0
- data/config/unicorn.rb +8 -13
- 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 +5 -3
- data/docs/customizing_attribute_partials.md +5 -2
- data/docs/customizing_controller_actions.md +50 -2
- data/docs/customizing_dashboards.md +112 -31
- data/docs/customizing_page_views.md +18 -4
- data/docs/extending_administrate.md +27 -0
- data/docs/getting_started.md +49 -56
- data/docs/guides/hiding_dashboards_from_sidebar.md +19 -0
- data/docs/guides.md +5 -0
- data/docs/rails_api.md +45 -0
- data/lib/administrate/base_dashboard.rb +47 -11
- data/lib/administrate/custom_dashboard.rb +15 -0
- data/lib/administrate/engine.rb +8 -1
- 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 +16 -3
- 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 +10 -1
- data/lib/administrate/field/time.rb +11 -0
- data/lib/administrate/field/url.rb +21 -0
- data/lib/administrate/namespace.rb +5 -1
- data/lib/administrate/order.rb +17 -7
- data/lib/administrate/page/base.rb +7 -5
- data/lib/administrate/page/form.rb +10 -3
- data/lib/administrate/resource_resolver.rb +2 -2
- data/lib/administrate/search.rb +116 -28
- 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 +22 -16
- data/lib/generators/administrate/dashboard/templates/controller.rb.erb +35 -10
- data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +18 -6
- data/lib/generators/administrate/install/install_generator.rb +37 -1
- data/lib/generators/administrate/install/templates/application_controller.rb.erb +4 -4
- data/lib/generators/administrate/routes/routes_generator.rb +21 -26
- data/lib/generators/administrate/views/layout_generator.rb +1 -0
- data/lib/generators/administrate/views/views_generator.rb +5 -4
- metadata +38 -53
- data/app/assets/javascripts/administrate/components/has_many_form.js +0 -3
- data/config/secrets.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a099c28c8a74491759229e6fe82de763f25b9ff59473d5c70b00d38675e3498
|
4
|
+
data.tar.gz: c24140b9e1bc63eb9ecd5f38cd0cfd3d3c0f125a81370df1dd6663af66121baa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ada94532afa210a359eece24f042fdb7de549cdb6bb94507c044f85df7b26cfbd5855202de2016255d635d2448dcba303d91eac4dc41c896f30e52f95073345
|
7
|
+
data.tar.gz: 98e115c8c3acfe7dc5cab3a3055b5f06dfa5661f9d2eb135c528b474cbe36e6fb51b36a8c88489860a9fda200758ce37f4d60375705f0e0234af4dc2805e75ff
|
@@ -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,
|
9
10
|
search_term).run
|
10
|
-
resources =
|
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),
|
@@ -46,26 +47,26 @@ module Administrate
|
|
46
47
|
|
47
48
|
if resource.save
|
48
49
|
redirect_to(
|
49
|
-
|
50
|
+
after_resource_created_path(resource),
|
50
51
|
notice: translate_with_resource("create.success"),
|
51
52
|
)
|
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
|
|
59
60
|
def update
|
60
61
|
if requested_resource.update(resource_params)
|
61
62
|
redirect_to(
|
62
|
-
|
63
|
+
after_resource_updated_path(requested_resource),
|
63
64
|
notice: translate_with_resource("update.success"),
|
64
65
|
)
|
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
|
|
@@ -75,14 +76,27 @@ module Administrate
|
|
75
76
|
else
|
76
77
|
flash[:error] = requested_resource.errors.full_messages.join("<br/>")
|
77
78
|
end
|
78
|
-
redirect_to
|
79
|
+
redirect_to after_resource_destroyed_path(requested_resource)
|
79
80
|
end
|
80
81
|
|
81
82
|
private
|
82
83
|
|
84
|
+
def after_resource_destroyed_path(_requested_resource)
|
85
|
+
{ action: :index }
|
86
|
+
end
|
87
|
+
|
88
|
+
def after_resource_created_path(requested_resource)
|
89
|
+
[namespace, requested_resource]
|
90
|
+
end
|
91
|
+
|
92
|
+
def after_resource_updated_path(requested_resource)
|
93
|
+
[namespace, requested_resource]
|
94
|
+
end
|
95
|
+
|
83
96
|
helper_method :nav_link_state
|
84
97
|
def nav_link_state(resource)
|
85
|
-
|
98
|
+
underscore_resource = resource.to_s.split("/").join("__")
|
99
|
+
resource_name.to_s.pluralize == underscore_resource ? :active : :inactive
|
86
100
|
end
|
87
101
|
|
88
102
|
helper_method :valid_action?
|
@@ -101,10 +115,27 @@ module Administrate
|
|
101
115
|
end
|
102
116
|
|
103
117
|
def order
|
104
|
-
@order ||= Administrate::Order.new(
|
105
|
-
|
106
|
-
|
107
|
-
|
118
|
+
@order ||= Administrate::Order.new(sorting_attribute, sorting_direction)
|
119
|
+
end
|
120
|
+
|
121
|
+
def sorting_attribute
|
122
|
+
sorting_params.fetch(:order) { default_sorting_attribute }
|
123
|
+
end
|
124
|
+
|
125
|
+
def default_sorting_attribute
|
126
|
+
nil
|
127
|
+
end
|
128
|
+
|
129
|
+
def sorting_direction
|
130
|
+
sorting_params.fetch(:direction) { default_sorting_direction }
|
131
|
+
end
|
132
|
+
|
133
|
+
def default_sorting_direction
|
134
|
+
nil
|
135
|
+
end
|
136
|
+
|
137
|
+
def sorting_params
|
138
|
+
Hash.try_convert(request.query_parameters[resource_name]) || {}
|
108
139
|
end
|
109
140
|
|
110
141
|
def dashboard
|
@@ -125,8 +156,8 @@ module Administrate
|
|
125
156
|
resource_class.default_scoped
|
126
157
|
end
|
127
158
|
|
128
|
-
def
|
129
|
-
resource_includes = dashboard.
|
159
|
+
def apply_collection_includes(relation)
|
160
|
+
resource_includes = dashboard.collection_includes
|
130
161
|
return relation if resource_includes.empty?
|
131
162
|
relation.includes(*resource_includes)
|
132
163
|
end
|
@@ -144,6 +175,8 @@ module Administrate
|
|
144
175
|
else
|
145
176
|
raise "Unrecognised param data: #{data.inspect}"
|
146
177
|
end
|
178
|
+
elsif data.is_a?(ActionController::Parameters)
|
179
|
+
data.transform_values { |v| read_param_value(v) }
|
147
180
|
else
|
148
181
|
data
|
149
182
|
end
|
@@ -153,6 +186,7 @@ module Administrate
|
|
153
186
|
to: :resource_resolver
|
154
187
|
helper_method :namespace
|
155
188
|
helper_method :resource_name
|
189
|
+
helper_method :resource_class
|
156
190
|
|
157
191
|
def resource_resolver
|
158
192
|
@resource_resolver ||=
|
@@ -1,23 +1,39 @@
|
|
1
1
|
module Administrate
|
2
2
|
module ApplicationHelper
|
3
3
|
PLURAL_MANY_COUNT = 2.1
|
4
|
+
SINGULAR_COUNT = 1
|
5
|
+
|
6
|
+
def application_title
|
7
|
+
if Rails::VERSION::MAJOR <= 5
|
8
|
+
Rails.application.class.parent_name.titlecase
|
9
|
+
else
|
10
|
+
Rails.application.class.module_parent_name.titlecase
|
11
|
+
end
|
12
|
+
end
|
4
13
|
|
5
14
|
def render_field(field, locals = {})
|
6
|
-
locals
|
15
|
+
locals[:field] = field
|
7
16
|
render locals: locals, partial: field.to_partial_path
|
8
17
|
end
|
9
18
|
|
10
|
-
def
|
11
|
-
|
19
|
+
def requireness(field)
|
20
|
+
field.required? ? "required" : "optional"
|
21
|
+
end
|
22
|
+
|
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
|
12
30
|
end
|
13
31
|
|
14
|
-
def display_resource_name(resource_name)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
default: resource_name.to_s.pluralize.titleize,
|
20
|
-
)
|
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
|
+
)
|
21
37
|
end
|
22
38
|
|
23
39
|
def sort_order(order)
|
@@ -28,22 +44,32 @@ module Administrate
|
|
28
44
|
end
|
29
45
|
end
|
30
46
|
|
31
|
-
def
|
32
|
-
|
47
|
+
def resource_index_route(resource_name)
|
48
|
+
url_for(
|
49
|
+
action: "index",
|
50
|
+
controller: "/#{namespace}/#{resource_name}",
|
51
|
+
)
|
33
52
|
end
|
34
53
|
|
35
54
|
def sanitized_order_params(page, current_field_name)
|
36
|
-
collection_names = page.
|
55
|
+
collection_names = page.item_includes + [current_field_name]
|
37
56
|
association_params = collection_names.map do |assoc_name|
|
38
57
|
{ assoc_name => %i[order direction page per_page] }
|
39
58
|
end
|
40
|
-
params.permit(:search, :id, :
|
59
|
+
params.permit(:search, :id, :_page, :per_page, association_params)
|
41
60
|
end
|
42
61
|
|
43
62
|
def clear_search_params
|
44
|
-
params.except(:search, :
|
63
|
+
params.except(:search, :_page).permit(
|
45
64
|
:per_page, resource_name => %i[order direction]
|
46
65
|
)
|
47
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
|
48
74
|
end
|
49
75
|
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--<%= "#{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)) %>">
|
@@ -33,7 +34,7 @@ to display a collection of resources in an HTML table.
|
|
33
34
|
)) do %>
|
34
35
|
<%= t(
|
35
36
|
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
|
36
|
-
default: attr_name
|
37
|
+
default: resource_class.human_attribute_name(attr_name),
|
37
38
|
).titleize %>
|
38
39
|
<% if collection_presenter.ordered_by?(attr_name) %>
|
39
40
|
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
|
@@ -45,50 +46,47 @@ 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
|
-
|
59
|
-
|
60
|
-
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
62
|
+
<% if show_action? :show, resource %>
|
63
|
+
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
61
64
|
<% end %>
|
62
65
|
>
|
63
66
|
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
64
67
|
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
65
68
|
<% if show_action? :show, resource -%>
|
66
69
|
<a href="<%= polymorphic_path([namespace, resource]) -%>"
|
70
|
+
tabindex="-1"
|
67
71
|
class="action-show"
|
68
72
|
>
|
69
73
|
<%= render_field attribute %>
|
70
74
|
</a>
|
75
|
+
<% else %>
|
76
|
+
<%= render_field attribute %>
|
71
77
|
<% end -%>
|
72
78
|
</td>
|
73
79
|
<% end %>
|
74
80
|
|
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 %>
|
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
|
+
) %>
|
92
90
|
</tr>
|
93
91
|
<% end %>
|
94
92
|
</tbody>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% if valid_action?(:edit, collection_presenter.resource_name) %>
|
2
|
+
<td><%= link_to(
|
3
|
+
t("administrate.actions.edit"),
|
4
|
+
[:edit, namespace, resource],
|
5
|
+
class: "action-edit",
|
6
|
+
) if show_action?(:edit, resource) %></td>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% if valid_action?(:destroy, collection_presenter.resource_name) %>
|
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 show_action?(:destroy, resource) %></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,8 +33,8 @@ 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| -%>
|
37
|
-
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
36
|
+
<% page.attributes(controller.action_name).each do |attribute| -%>
|
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 -%>
|
@@ -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 valid_action?(:new) && show_action?(:new, new_resource) %>
|
27
|
+
</div>
|
28
|
+
</header>
|
@@ -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 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 valid_action?(:index, resource) && show_action?(:index, model_from_resource(resource)) %>
|
17
19
|
<% end %>
|
18
20
|
</nav>
|