administrate 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of administrate might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/administrate/application.scss +1 -1
- data/app/assets/stylesheets/administrate/base/_forms.scss +5 -1
- data/app/assets/stylesheets/administrate/components/_attributes.scss +5 -0
- data/app/assets/stylesheets/administrate/components/_cells.scss +2 -2
- data/app/assets/stylesheets/administrate/components/_field-unit.scss +15 -0
- data/app/assets/stylesheets/administrate/components/_main-content.scss +1 -2
- data/app/assets/stylesheets/administrate/components/_search.scss +30 -65
- data/app/assets/stylesheets/administrate/library/_variables.scss +28 -27
- data/app/controllers/administrate/application_controller.rb +15 -7
- data/app/helpers/administrate/application_helper.rb +5 -15
- data/app/views/administrate/application/_collection.html.erb +16 -14
- data/app/views/administrate/application/_icons.erb +13 -0
- data/app/views/administrate/application/_search.html.erb +23 -19
- data/app/views/administrate/application/index.html.erb +15 -7
- data/app/views/administrate/application/show.html.erb +1 -1
- data/app/views/fields/has_many/_show.html.erb +2 -1
- data/app/views/fields/has_one/_form.html.erb +11 -9
- data/app/views/fields/has_one/_show.html.erb +22 -5
- data/app/views/layouts/administrate/application.html.erb +2 -1
- data/config/locales/administrate.ar.yml +3 -0
- data/config/locales/administrate.da.yml +3 -0
- data/config/locales/administrate.de.yml +3 -0
- data/config/locales/administrate.en.yml +3 -0
- data/config/locales/administrate.es.yml +3 -0
- data/config/locales/administrate.fr.yml +3 -0
- data/config/locales/administrate.it.yml +3 -0
- data/config/locales/administrate.ja.yml +3 -0
- data/config/locales/administrate.ko.yml +3 -0
- data/config/locales/administrate.nl.yml +3 -0
- data/config/locales/administrate.pl.yml +3 -0
- data/config/locales/administrate.pt-BR.yml +3 -0
- data/config/locales/administrate.pt.yml +3 -0
- data/config/locales/administrate.ru.yml +3 -0
- data/config/locales/administrate.sv.yml +3 -0
- data/config/locales/administrate.uk.yml +3 -0
- data/config/locales/administrate.vi.yml +3 -0
- data/config/locales/administrate.zh-CN.yml +3 -0
- data/config/locales/administrate.zh-TW.yml +3 -0
- data/docs/customizing_controller_actions.md +10 -0
- data/docs/customizing_page_views.md +2 -2
- data/lib/administrate/engine.rb +0 -8
- data/lib/administrate/field/base.rb +2 -1
- data/lib/administrate/field/deferred.rb +2 -1
- data/lib/administrate/field/has_many.rb +7 -1
- data/lib/administrate/field/has_one.rb +17 -1
- data/lib/administrate/order.rb +1 -1
- data/lib/administrate/page/base.rb +1 -1
- data/lib/administrate/search.rb +8 -9
- data/lib/administrate/version.rb +1 -1
- data/lib/generators/administrate/assets/assets_generator.rb +0 -1
- data/lib/generators/administrate/routes/routes_generator.rb +1 -1
- data/lib/generators/administrate/views/layout_generator.rb +1 -0
- metadata +11 -30
- data/app/assets/images/administrate/cancel.svg +0 -6
- data/app/assets/images/administrate/dropdown.svg +0 -3
- data/app/assets/images/administrate/search.svg +0 -6
- data/app/assets/images/administrate/sort_arrow.svg +0 -4
- data/app/assets/javascripts/administrate/components/_search.js +0 -43
- data/lib/generators/administrate/assets/images_generator.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecd4d11ba0fe55d836d185b1b88372b69fd661df
|
4
|
+
data.tar.gz: e0a491ee47a85a797d6a01df24091ab1ecb1473f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dba9aaf579c9814dabe44f50ee80cf4774a08a6aa502fdbddb34e0b518099fc0b5f598907626ff677ba34ac14c5edf77f519ecf0117a956d23dc69295d8401a
|
7
|
+
data.tar.gz: efecd0357a76bc8099c82e65b377b6cbff4fc30128e9f62728f54ed5359de8b38e3f342f57754e41196a1a2a643aad4603fb401de3f2669d2bb7e9a08019f213
|
@@ -51,7 +51,7 @@ textarea {
|
|
51
51
|
background-color: $white;
|
52
52
|
border: $base-border;
|
53
53
|
border-radius: $base-border-radius;
|
54
|
-
padding:
|
54
|
+
padding: 0.5em;
|
55
55
|
transition: border-color $base-duration $base-timing;
|
56
56
|
width: 100%;
|
57
57
|
|
@@ -72,6 +72,10 @@ textarea {
|
|
72
72
|
border: $base-border;
|
73
73
|
}
|
74
74
|
}
|
75
|
+
|
76
|
+
&::placeholder {
|
77
|
+
font-style: italic;
|
78
|
+
}
|
75
79
|
}
|
76
80
|
|
77
81
|
textarea {
|
@@ -27,15 +27,15 @@
|
|
27
27
|
|
28
28
|
.cell-label__sort-indicator {
|
29
29
|
display: inline-block;
|
30
|
-
height: 1em;
|
31
30
|
overflow: hidden;
|
32
31
|
position: absolute;
|
33
32
|
right: 0;
|
34
33
|
|
35
34
|
svg {
|
36
35
|
fill: $hint-grey;
|
37
|
-
height:
|
36
|
+
height: 13px;
|
38
37
|
transition: transform $base-duration $base-timing;
|
38
|
+
width: 13px;
|
39
39
|
}
|
40
40
|
}
|
41
41
|
|
@@ -19,3 +19,18 @@
|
|
19
19
|
margin-left: 2rem;
|
20
20
|
width: 45%;
|
21
21
|
}
|
22
|
+
|
23
|
+
.field-unit--nested {
|
24
|
+
border: $base-border;
|
25
|
+
margin-left: 7.5%;
|
26
|
+
padding: $small-spacing;
|
27
|
+
width: 50%;
|
28
|
+
|
29
|
+
.field-unit__field {
|
30
|
+
width: calc(75% - 1rem);
|
31
|
+
}
|
32
|
+
|
33
|
+
.field-unit__label {
|
34
|
+
width: calc(25% - 1rem);
|
35
|
+
}
|
36
|
+
}
|
@@ -1,81 +1,46 @@
|
|
1
|
+
$_search-icon-size: 1rem;
|
2
|
+
|
1
3
|
.search {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
flex-direction: row;
|
6
|
-
justify-content: flex-start;
|
7
|
-
padding-left: $base-spacing;
|
8
|
-
padding-right: $base-spacing;
|
4
|
+
margin-left: auto;
|
5
|
+
margin-right: 2rem;
|
6
|
+
max-width: 20rem;
|
9
7
|
position: relative;
|
10
8
|
width: 100%;
|
11
9
|
}
|
12
10
|
|
13
|
-
.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
width: 1em;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
.search__icon {
|
22
|
-
path {
|
23
|
-
fill: $hint-grey;
|
24
|
-
transition: fill $base-duration $base-timing;
|
25
|
-
}
|
26
|
-
|
27
|
-
&--active {
|
28
|
-
svg {
|
29
|
-
fill: $action-color;
|
30
|
-
}
|
31
|
-
}
|
11
|
+
.search__input {
|
12
|
+
border-radius: 100rem;
|
13
|
+
padding-left: $_search-icon-size * 2.5;
|
14
|
+
padding-right: $_search-icon-size * 2.5;
|
32
15
|
}
|
33
16
|
|
34
|
-
.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
fill: $action-color;
|
43
|
-
}
|
17
|
+
.search__eyeglass-icon {
|
18
|
+
fill: $grey-7;
|
19
|
+
height: $_search-icon-size;
|
20
|
+
left: $_search-icon-size;
|
21
|
+
position: absolute;
|
22
|
+
top: 50%;
|
23
|
+
transform: translateY(-50%);
|
24
|
+
width: $_search-icon-size;
|
44
25
|
}
|
45
26
|
|
46
|
-
.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
&:focus {
|
55
|
-
box-shadow: none;
|
56
|
-
}
|
27
|
+
.search__clear-link {
|
28
|
+
height: $_search-icon-size;
|
29
|
+
position: absolute;
|
30
|
+
right: $_search-icon-size * 0.75;
|
31
|
+
top: 50%;
|
32
|
+
transform: translateY(-50%);
|
33
|
+
width: $_search-icon-size;
|
57
34
|
}
|
58
35
|
|
59
|
-
.
|
60
|
-
|
61
|
-
|
62
|
-
opacity: 0;
|
36
|
+
.search__clear-icon {
|
37
|
+
fill: $grey-5;
|
38
|
+
height: $_search-icon-size;
|
63
39
|
position: absolute;
|
64
|
-
|
65
|
-
|
66
|
-
z-index: 1;
|
67
|
-
|
68
|
-
svg {
|
69
|
-
height: 100%;
|
70
|
-
width: 100%;
|
71
|
-
}
|
40
|
+
transition: fill $base-duration $base-timing;
|
41
|
+
width: $_search-icon-size;
|
72
42
|
|
73
|
-
|
74
|
-
rect {
|
43
|
+
&:hover {
|
75
44
|
fill: $action-color;
|
76
45
|
}
|
77
|
-
|
78
|
-
&--active {
|
79
|
-
opacity: 1;
|
80
|
-
}
|
81
46
|
}
|
@@ -1,43 +1,44 @@
|
|
1
1
|
// Typography
|
2
2
|
$base-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
|
3
3
|
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
4
|
-
sans-serif;
|
5
|
-
$heading-font-family: $base-font-family;
|
4
|
+
sans-serif !default;
|
5
|
+
$heading-font-family: $base-font-family !default;
|
6
6
|
|
7
|
-
$base-font-size: 1em;
|
7
|
+
$base-font-size: 1em !default;
|
8
8
|
|
9
|
-
$bold-font-weight: 700;
|
9
|
+
$bold-font-weight: 700 !default;
|
10
10
|
|
11
|
-
$base-line-height: 1.5;
|
12
|
-
$heading-line-height: 1.2;
|
11
|
+
$base-line-height: 1.5 !default;
|
12
|
+
$heading-line-height: 1.2 !default;
|
13
13
|
|
14
14
|
// Other Sizes
|
15
|
-
$base-border-radius: 4px;
|
16
|
-
$base-spacing: $base-line-height * 1em;
|
17
|
-
$small-spacing: $base-spacing / 2;
|
15
|
+
$base-border-radius: 4px !default;
|
16
|
+
$base-spacing: $base-line-height * 1em !default;
|
17
|
+
$small-spacing: $base-spacing / 2 !default;
|
18
18
|
|
19
19
|
// Colors
|
20
|
-
$white: #fff;
|
21
|
-
$black: #000;
|
20
|
+
$white: #fff !default;
|
21
|
+
$black: #000 !default;
|
22
22
|
|
23
|
-
$blue: #1976d2;
|
24
|
-
$red: #d32f2f;
|
25
|
-
$light-yellow: #f0cd66;
|
26
|
-
$light-green: #4ab471;
|
23
|
+
$blue: #1976d2 !default;
|
24
|
+
$red: #d32f2f !default;
|
25
|
+
$light-yellow: #f0cd66 !default;
|
26
|
+
$light-green: #4ab471 !default;
|
27
27
|
|
28
|
-
$grey-0: #f6f7f7;
|
29
|
-
$grey-1: #dfe0e1;
|
30
|
-
$grey-2: #cfd8dc;
|
31
|
-
$grey-
|
28
|
+
$grey-0: #f6f7f7 !default;
|
29
|
+
$grey-1: #dfe0e1 !default;
|
30
|
+
$grey-2: #cfd8dc !default;
|
31
|
+
$grey-5: #adb5bd !default;
|
32
|
+
$grey-7: #293f54 !default;
|
32
33
|
|
33
|
-
$hint-grey: #7b808c;
|
34
|
+
$hint-grey: #7b808c !default;
|
34
35
|
|
35
36
|
// Font Colors
|
36
|
-
$base-font-color: $grey-7;
|
37
|
-
$action-color: $blue;
|
37
|
+
$base-font-color: $grey-7 !default;
|
38
|
+
$action-color: $blue !default;
|
38
39
|
|
39
40
|
// Background Colors
|
40
|
-
$base-background-color: $grey-0;
|
41
|
+
$base-background-color: $grey-0 !default;
|
41
42
|
|
42
43
|
// Focus
|
43
44
|
$focus-outline-color: transparentize($action-color, 0.4);
|
@@ -54,9 +55,9 @@ $flash-colors: (
|
|
54
55
|
);
|
55
56
|
|
56
57
|
// Border
|
57
|
-
$base-border-color: $grey-1;
|
58
|
-
$base-border: 1px solid $base-border-color;
|
58
|
+
$base-border-color: $grey-1 !default;
|
59
|
+
$base-border: 1px solid $base-border-color !default;
|
59
60
|
|
60
61
|
// Transitions
|
61
|
-
$base-duration: 250ms;
|
62
|
-
$base-timing: ease-in-out;
|
62
|
+
$base-duration: 250ms !default;
|
63
|
+
$base-timing: ease-in-out !default;
|
@@ -4,7 +4,9 @@ module Administrate
|
|
4
4
|
|
5
5
|
def index
|
6
6
|
search_term = params[:search].to_s.strip
|
7
|
-
resources = Administrate::Search.new(
|
7
|
+
resources = Administrate::Search.new(scoped_resource,
|
8
|
+
dashboard_class,
|
9
|
+
search_term).run
|
8
10
|
resources = resources.includes(*resource_includes) if resource_includes.any?
|
9
11
|
resources = order.apply(resources)
|
10
12
|
resources = resources.page(params[:page]).per(records_per_page)
|
@@ -78,9 +80,9 @@ module Administrate
|
|
78
80
|
end
|
79
81
|
|
80
82
|
helper_method :valid_action?
|
81
|
-
def valid_action?(name, resource =
|
83
|
+
def valid_action?(name, resource = resource_class)
|
82
84
|
!!routes.detect do |controller, action|
|
83
|
-
controller == resource.to_s.pluralize && action == name.to_s
|
85
|
+
controller == resource.to_s.underscore.pluralize && action == name.to_s
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
@@ -97,7 +99,7 @@ module Administrate
|
|
97
99
|
end
|
98
100
|
|
99
101
|
def dashboard
|
100
|
-
@_dashboard ||=
|
102
|
+
@_dashboard ||= dashboard_class.new
|
101
103
|
end
|
102
104
|
|
103
105
|
def requested_resource
|
@@ -105,7 +107,11 @@ module Administrate
|
|
105
107
|
end
|
106
108
|
|
107
109
|
def find_resource(param)
|
108
|
-
|
110
|
+
scoped_resource.find(param)
|
111
|
+
end
|
112
|
+
|
113
|
+
def scoped_resource
|
114
|
+
resource_class.default_scoped
|
109
115
|
end
|
110
116
|
|
111
117
|
def resource_includes
|
@@ -113,10 +119,12 @@ module Administrate
|
|
113
119
|
end
|
114
120
|
|
115
121
|
def resource_params
|
116
|
-
params.require(
|
122
|
+
params.require(resource_class.model_name.param_key).
|
123
|
+
permit(dashboard.permitted_attributes)
|
117
124
|
end
|
118
125
|
|
119
|
-
delegate :resource_class, :resource_name, :namespace,
|
126
|
+
delegate :dashboard_class, :resource_class, :resource_name, :namespace,
|
127
|
+
to: :resource_resolver
|
120
128
|
helper_method :namespace
|
121
129
|
helper_method :resource_name
|
122
130
|
|
@@ -19,21 +19,11 @@ module Administrate
|
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
28
|
-
xml_attributes = {
|
29
|
-
"xmlns".freeze => "http://www.w3.org/2000/svg".freeze,
|
30
|
-
"xmlns:xlink".freeze => "http://www.w3.org/1999/xlink".freeze,
|
31
|
-
height: options[:height],
|
32
|
-
width: options[:width],
|
33
|
-
}.delete_if { |_key, value| value.nil? }
|
34
|
-
|
35
|
-
content_tag :svg, xml_attributes do
|
36
|
-
content_tag :use, nil, svg_attributes
|
22
|
+
def sort_order(order)
|
23
|
+
case order
|
24
|
+
when "asc" then "ascending"
|
25
|
+
when "desc" then "descending"
|
26
|
+
else "none"
|
37
27
|
end
|
38
28
|
end
|
39
29
|
|
@@ -18,36 +18,36 @@ to display a collection of resources in an HTML table.
|
|
18
18
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
|
19
19
|
%>
|
20
20
|
|
21
|
-
<table aria-labelledby="
|
21
|
+
<table aria-labelledby="<%= table_title %>">
|
22
22
|
<thead>
|
23
23
|
<tr>
|
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) %>
|
28
|
-
|
27
|
+
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>"
|
28
|
+
scope="col"
|
29
|
+
role="columnheader"
|
30
|
+
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
|
29
31
|
<%= link_to(sanitized_order_params.merge(
|
30
32
|
collection_presenter.order_params_for(attr_name)
|
31
33
|
)) do %>
|
32
34
|
<%= t(
|
33
|
-
"helpers.label.#{resource_name}.#{attr_name}",
|
35
|
+
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
|
34
36
|
default: attr_name.to_s,
|
35
37
|
).titleize %>
|
36
38
|
|
37
39
|
<% if collection_presenter.ordered_by?(attr_name) %>
|
38
40
|
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
|
39
|
-
|
40
|
-
"
|
41
|
-
|
42
|
-
width: "13",
|
43
|
-
height: "13"
|
44
|
-
) %>
|
41
|
+
<svg aria-hidden="true">
|
42
|
+
<use xlink:href="#icon-up-caret" />
|
43
|
+
</svg>
|
45
44
|
</span>
|
46
45
|
<% end %>
|
47
46
|
<% end %>
|
48
47
|
</th>
|
49
48
|
<% end %>
|
50
|
-
<% [valid_action?(:edit
|
49
|
+
<% [valid_action?(:edit, collection_presenter.resource_name),
|
50
|
+
valid_action?(:destroy, collection_presenter.resource_name)].count(true).times do %>
|
51
51
|
<th scope="col"></th>
|
52
52
|
<% end %>
|
53
53
|
</tr>
|
@@ -57,7 +57,9 @@ to display a collection of resources in an HTML table.
|
|
57
57
|
<% resources.each do |resource| %>
|
58
58
|
<tr class="js-table-row"
|
59
59
|
tabindex="0"
|
60
|
-
|
60
|
+
<% if valid_action? :show, collection_presenter.resource_name %>
|
61
|
+
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
62
|
+
<% end %>
|
61
63
|
>
|
62
64
|
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
63
65
|
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
@@ -69,7 +71,7 @@ to display a collection of resources in an HTML table.
|
|
69
71
|
</td>
|
70
72
|
<% end %>
|
71
73
|
|
72
|
-
<% if valid_action? :edit %>
|
74
|
+
<% if valid_action? :edit, collection_presenter.resource_name %>
|
73
75
|
<td><%= link_to(
|
74
76
|
t("administrate.actions.edit"),
|
75
77
|
[:edit, namespace, resource],
|
@@ -77,7 +79,7 @@ to display a collection of resources in an HTML table.
|
|
77
79
|
) %></td>
|
78
80
|
<% end %>
|
79
81
|
|
80
|
-
<% if valid_action? :destroy %>
|
82
|
+
<% if valid_action? :destroy, collection_presenter.resource_name %>
|
81
83
|
<td><%= link_to(
|
82
84
|
t("administrate.actions.destroy"),
|
83
85
|
[namespace, resource],
|