administrate 0.4.0 → 0.5.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/javascripts/administrate/components/table.js +8 -3
- data/app/assets/stylesheets/administrate/components/_attributes.scss +1 -1
- data/app/assets/stylesheets/administrate/components/_flashes.scss +19 -7
- data/app/controllers/administrate/application_controller.rb +12 -5
- data/app/helpers/administrate/application_helper.rb +10 -6
- data/app/views/administrate/application/_collection.html.erb +20 -15
- data/app/views/administrate/application/_flashes.html.erb +1 -1
- data/app/views/administrate/application/_form.html.erb +1 -1
- data/app/views/administrate/application/edit.html.erb +3 -3
- data/app/views/administrate/application/index.html.erb +2 -2
- data/app/views/administrate/application/new.html.erb +2 -2
- data/app/views/administrate/application/show.html.erb +3 -3
- data/app/views/fields/belongs_to/_index.html.erb +8 -4
- data/app/views/fields/belongs_to/_show.html.erb +8 -4
- data/app/views/fields/has_many/_show.html.erb +2 -8
- data/config/locales/administrate.ar.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.fr.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 +25 -0
- data/config/locales/administrate.nl.yml +2 -0
- data/config/locales/administrate.pl.yml +2 -0
- data/config/locales/administrate.pt-BR.yml +2 -0
- data/config/locales/administrate.pt.yml +26 -0
- data/config/locales/administrate.ru.yml +2 -0
- data/config/locales/administrate.sv.yml +2 -0
- data/config/locales/administrate.uk.yml +2 -0
- data/config/locales/administrate.vi.yml +2 -0
- data/config/locales/administrate.zh-CN.yml +2 -0
- data/config/locales/administrate.zh-TW.yml +2 -0
- data/docs/adding_custom_field_types.md +79 -0
- data/docs/authentication.md +60 -0
- data/docs/customizing_attribute_partials.md +34 -0
- data/docs/customizing_controller_actions.md +32 -0
- data/docs/customizing_dashboards.md +143 -0
- data/docs/customizing_page_views.md +78 -0
- data/docs/getting_started.md +60 -0
- data/lib/administrate/field/has_many.rb +8 -3
- data/lib/administrate/field/number.rb +10 -2
- data/lib/administrate/namespace.rb +10 -10
- data/lib/administrate/resource_resolver.rb +1 -1
- data/lib/administrate/version.rb +1 -1
- data/lib/generators/administrate/routes/templates/routes.rb.erb +2 -2
- metadata +25 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab74a9176bf14060fc26e4346b4fca17b2672371
|
4
|
+
data.tar.gz: 990b4f062e37a68c7be97ee5104323d00e99a4ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f04b6bea3d168597600b14b390ec6ea6bc14836cf3236b34a0982b4067468c161b8014f253e8d4ca7ccac898aaac8ca9093dcf7143cc32aa51b8f6d54834c98
|
7
|
+
data.tar.gz: ec346e46a0ed10bbd38d14f5bffc2859fd8047467a1be90360a9b8fdc3dc8d7ebc67aa7472d9537c99527e7fd10960806a58502b88d7f6e4fddcb86e529adc72
|
@@ -2,12 +2,17 @@ $(function() {
|
|
2
2
|
var keycodes = { space: 32, enter: 13 };
|
3
3
|
|
4
4
|
var visitDataUrl = function(event) {
|
5
|
-
if (event.type=="click" ||
|
5
|
+
if (event.type == "click" ||
|
6
6
|
event.keyCode == keycodes.space ||
|
7
7
|
event.keyCode == keycodes.enter) {
|
8
8
|
|
9
|
-
if(
|
10
|
-
|
9
|
+
if (event.target.href) {
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
|
13
|
+
var dataUrl = $(event.target).closest("tr").data("url");
|
14
|
+
if (dataUrl) {
|
15
|
+
window.location = dataUrl;
|
11
16
|
}
|
12
17
|
}
|
13
18
|
};
|
@@ -1,15 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
$base-spacing: 1.5em !default;
|
2
|
+
$flashes: (
|
3
|
+
"alert": #fff6bf,
|
4
|
+
"error": #fbe3e4,
|
5
|
+
"notice": #e5edf8,
|
6
|
+
"success": #e6efc2,
|
7
|
+
) !default;
|
8
|
+
|
9
|
+
@each $flash-type, $color in $flashes {
|
10
|
+
.flash-#{$flash-type} {
|
11
|
+
background-color: $color;
|
12
|
+
color: shade($color, 60%);
|
13
|
+
display: block;
|
14
|
+
margin-bottom: $base-spacing / 2;
|
15
|
+
padding: $base-spacing / 2;
|
16
|
+
text-align: center;
|
6
17
|
|
7
18
|
a {
|
8
|
-
color:
|
19
|
+
color: shade($color, 70%);
|
20
|
+
text-decoration: underline;
|
9
21
|
|
10
22
|
&:focus,
|
11
23
|
&:hover {
|
12
|
-
color:
|
24
|
+
color: shade($color, 90%);
|
13
25
|
}
|
14
26
|
}
|
15
27
|
}
|
@@ -80,6 +80,17 @@ module Administrate
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
helper_method :valid_action?
|
84
|
+
def valid_action?(name, resource = resource_name)
|
85
|
+
!!routes.detect do |controller, action|
|
86
|
+
controller == resource.to_s.pluralize && action == name.to_s
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def routes
|
91
|
+
@routes ||= Namespace.new(namespace).routes
|
92
|
+
end
|
93
|
+
|
83
94
|
def records_per_page
|
84
95
|
params[:per_page] || 20
|
85
96
|
end
|
@@ -101,11 +112,7 @@ module Administrate
|
|
101
112
|
end
|
102
113
|
|
103
114
|
def resource_params
|
104
|
-
params.require(resource_name).permit(
|
105
|
-
end
|
106
|
-
|
107
|
-
def permitted_attributes
|
108
|
-
dashboard.permitted_attributes
|
115
|
+
params.require(resource_name).permit(dashboard.permitted_attributes)
|
109
116
|
end
|
110
117
|
|
111
118
|
delegate :resource_class, :resource_name, :namespace, to: :resource_resolver
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Administrate
|
2
2
|
module ApplicationHelper
|
3
|
+
PLURAL_MANY_COUNT = 2.1
|
4
|
+
|
3
5
|
def render_field(field, locals = {})
|
4
6
|
locals.merge!(field: field)
|
5
7
|
render locals: locals, partial: field.to_partial_path
|
@@ -12,7 +14,7 @@ module Administrate
|
|
12
14
|
constantize.
|
13
15
|
model_name.
|
14
16
|
human(
|
15
|
-
count:
|
17
|
+
count: PLURAL_MANY_COUNT,
|
16
18
|
default: resource_name.to_s.pluralize.titleize,
|
17
19
|
)
|
18
20
|
end
|
@@ -20,13 +22,15 @@ module Administrate
|
|
20
22
|
def svg_tag(asset, svg_id, options = {})
|
21
23
|
svg_attributes = {
|
22
24
|
"xlink:href".freeze => "#{asset_url(asset)}##{svg_id}",
|
23
|
-
height:
|
24
|
-
width:
|
25
|
-
}
|
25
|
+
height: "100%",
|
26
|
+
width: "100%",
|
27
|
+
}
|
26
28
|
xml_attributes = {
|
27
29
|
"xmlns".freeze => "http://www.w3.org/2000/svg".freeze,
|
28
30
|
"xmlns:xlink".freeze => "http://www.w3.org/1999/xlink".freeze,
|
29
|
-
|
31
|
+
height: options[:height],
|
32
|
+
width: options[:width],
|
33
|
+
}.delete_if { |_key, value| value.nil? }
|
30
34
|
|
31
35
|
content_tag :svg, xml_attributes do
|
32
36
|
content_tag :use, nil, svg_attributes
|
@@ -34,7 +38,7 @@ module Administrate
|
|
34
38
|
end
|
35
39
|
|
36
40
|
def sanitized_order_params
|
37
|
-
params.permit(:search, :id, :order, :page, :per_page, :direction)
|
41
|
+
params.permit(:search, :id, :order, :page, :per_page, :direction, :orders)
|
38
42
|
end
|
39
43
|
|
40
44
|
def clear_search_params
|
@@ -47,16 +47,17 @@ to display a collection of resources in an HTML table.
|
|
47
47
|
<% end %>
|
48
48
|
</th>
|
49
49
|
<% end %>
|
50
|
-
|
50
|
+
<% [valid_action?(:edit), valid_action?(:destroy)].count(true).times do %>
|
51
|
+
<th scope="col"></th>
|
52
|
+
<% end %>
|
51
53
|
</tr>
|
52
54
|
</thead>
|
53
55
|
|
54
56
|
<tbody>
|
55
57
|
<% resources.each do |resource| %>
|
56
58
|
<tr class="table__row"
|
57
|
-
role="link"
|
58
59
|
tabindex="0"
|
59
|
-
data-url
|
60
|
+
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) if valid_action? :show -%>
|
60
61
|
>
|
61
62
|
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
62
63
|
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
@@ -68,19 +69,23 @@ to display a collection of resources in an HTML table.
|
|
68
69
|
</td>
|
69
70
|
<% end %>
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
<% if valid_action? :edit %>
|
73
|
+
<td><%= link_to(
|
74
|
+
t("administrate.actions.edit"),
|
75
|
+
[:edit, namespace, resource],
|
76
|
+
class: "action-edit",
|
77
|
+
) %></td>
|
78
|
+
<% end %>
|
76
79
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
<% if valid_action? :destroy %>
|
81
|
+
<td><%= link_to(
|
82
|
+
t("administrate.actions.destroy"),
|
83
|
+
[namespace, resource],
|
84
|
+
class: "table__action--destroy",
|
85
|
+
method: :delete,
|
86
|
+
data: { confirm: t("administrate.actions.confirm") }
|
87
|
+
) %></td>
|
88
|
+
<% end %>
|
84
89
|
</tr>
|
85
90
|
<% end %>
|
86
91
|
</tbody>
|
@@ -14,7 +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
|
-
<div class="flash flash
|
17
|
+
<div class="flash flash-<%= key %>"><%= value %></div>
|
18
18
|
<% end -%>
|
19
19
|
</div>
|
20
20
|
<% end %>
|
@@ -15,16 +15,16 @@ It displays a header, and renders the `_form` partial to do the heavy lifting.
|
|
15
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
16
16
|
%>
|
17
17
|
|
18
|
-
<% content_for(:title) { "
|
18
|
+
<% content_for(:title) { "#{t("administrate.actions.edit")} #{page.page_title}" } %>
|
19
19
|
|
20
20
|
<header class="header">
|
21
21
|
<h1 class="header__heading"><%= content_for(:title) %></h1>
|
22
22
|
<div class="header__actions">
|
23
23
|
<%= link_to(
|
24
|
-
"
|
24
|
+
"#{t("administrate.actions.show")} #{page.page_title}",
|
25
25
|
[namespace, page.resource],
|
26
26
|
class: "button",
|
27
|
-
) %>
|
27
|
+
) if valid_action? :show %>
|
28
28
|
</div>
|
29
29
|
</header>
|
30
30
|
|
@@ -37,10 +37,10 @@ It renders the `_table` partial to display details about the resources.
|
|
37
37
|
<h1 class="header__heading" id="page-title"><%= content_for(:title) %></h1>
|
38
38
|
<div class="header__actions">
|
39
39
|
<%= link_to(
|
40
|
-
"
|
40
|
+
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
|
41
41
|
[:new, namespace, page.resource_name],
|
42
42
|
class: "button",
|
43
|
-
) %>
|
43
|
+
) if valid_action? :new %>
|
44
44
|
</div>
|
45
45
|
</header>
|
46
46
|
|
@@ -15,12 +15,12 @@ to do the heavy lifting.
|
|
15
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
16
16
|
%>
|
17
17
|
|
18
|
-
<% content_for(:title) { "
|
18
|
+
<% content_for(:title) { "#{t("administrate.actions.new")} #{page.resource_name.titleize}" } %>
|
19
19
|
|
20
20
|
<header class="header">
|
21
21
|
<h1 class="header__heading"><%= content_for(:title) %></h1>
|
22
22
|
<div class="header__actions">
|
23
|
-
<%= link_to
|
23
|
+
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
|
24
24
|
</div>
|
25
25
|
</header>
|
26
26
|
|
@@ -16,16 +16,16 @@ as well as a link to its edit page.
|
|
16
16
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
17
17
|
%>
|
18
18
|
|
19
|
-
<% content_for(:title) { page.page_title } %>
|
19
|
+
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
|
20
20
|
|
21
21
|
<header class="header">
|
22
22
|
<h1 class="header__heading"><%= content_for(:title) %></h1>
|
23
23
|
<div class="header__actions">
|
24
24
|
<%= link_to(
|
25
|
-
"
|
25
|
+
"#{t("administrate.actions.edit")} #{page.page_title}",
|
26
26
|
[:edit, namespace, page.resource],
|
27
27
|
class: "button",
|
28
|
-
) %>
|
28
|
+
) if valid_action? :edit %>
|
29
29
|
</div>
|
30
30
|
</header>
|
31
31
|
|
@@ -16,8 +16,12 @@ By default, the relationship is rendered as a link to the associated object.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.data %>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
<% if valid_action?(:show, field.attribute) %>
|
20
|
+
<%= link_to(
|
21
|
+
field.display_associated_resource,
|
22
|
+
[namespace, field.data],
|
23
|
+
) %>
|
24
|
+
<% else %>
|
25
|
+
<%= field.display_associated_resource %>
|
26
|
+
<% end %>
|
23
27
|
<% end %>
|
@@ -16,8 +16,12 @@ By default, the relationship is rendered as a link to the associated object.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.data %>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
<% if valid_action?(:show, field.attribute) %>
|
20
|
+
<%= link_to(
|
21
|
+
field.display_associated_resource,
|
22
|
+
[namespace, field.data],
|
23
|
+
) %>
|
24
|
+
<% else %>
|
25
|
+
<%= field.display_associated_resource %>
|
26
|
+
<% end %>
|
23
27
|
<% end %>
|
@@ -22,17 +22,11 @@ from the associated resource class's dashboard.
|
|
22
22
|
<%= render(
|
23
23
|
"collection",
|
24
24
|
collection_presenter: field.associated_collection,
|
25
|
-
resources: field.resources
|
25
|
+
resources: field.resources(params[field.name])
|
26
26
|
) %>
|
27
27
|
|
28
28
|
<% if field.more_than_limit? %>
|
29
|
-
|
30
|
-
<%= t(
|
31
|
-
'administrate.fields.has_many.more',
|
32
|
-
count: field.limit,
|
33
|
-
total_count: field.data.count(:all),
|
34
|
-
) %>
|
35
|
-
</span>
|
29
|
+
<%= paginate field.resources(params[field.name]), param_name: "#{field.name}" %>
|
36
30
|
<% end %>
|
37
31
|
|
38
32
|
<% else %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
ko:
|
3
|
+
administrate:
|
4
|
+
actions:
|
5
|
+
confirm: 괜찮습니까?
|
6
|
+
destroy: 삭제
|
7
|
+
edit: 편집
|
8
|
+
show: 보여주기
|
9
|
+
new: 새로운
|
10
|
+
back: 뒤로
|
11
|
+
controller:
|
12
|
+
create:
|
13
|
+
success: "%{resource} 가 성공적으로 생성되었습니다."
|
14
|
+
destroy:
|
15
|
+
success: "%{resource} 가 성공적으로 삭제되었습니다."
|
16
|
+
update:
|
17
|
+
success: "%{resource} 가 성공적으로 갱신되었습니다."
|
18
|
+
fields:
|
19
|
+
has_many:
|
20
|
+
more: "%{total_count} 개 중에서 %{count} 개"
|
21
|
+
none: 없음
|
22
|
+
polymorphic:
|
23
|
+
not_supported: 상속 관계에 대한 양식은 제공되지 않습니다.
|
24
|
+
has_one:
|
25
|
+
not_supported: 일대일 관계에 대한 양식은 제공되지 않습니다.
|