administrate 0.10.0 → 0.11.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/controllers/administrate/application_controller.rb +5 -2
- data/app/helpers/administrate/application_helper.rb +9 -3
- data/app/views/administrate/application/_collection.html.erb +2 -3
- data/app/views/administrate/application/index.html.erb +2 -0
- data/app/views/administrate/application/show.html.erb +1 -1
- data/app/views/fields/has_many/_form.html.erb +2 -2
- data/app/views/fields/has_many/_show.html.erb +8 -5
- data/app/views/fields/has_one/_form.html.erb +1 -1
- data/app/views/fields/polymorphic/_form.html.erb +0 -3
- data/config/locales/administrate.id.yml +28 -0
- data/config/locales/administrate.zh-TW.yml +4 -4
- data/docs/customizing_dashboards.md +7 -7
- data/lib/administrate/base_dashboard.rb +5 -1
- data/lib/administrate/field/has_many.rb +15 -8
- data/lib/administrate/page/base.rb +4 -0
- data/lib/administrate/page/collection.rb +5 -1
- data/lib/administrate/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11c705312ca68f68a80830fbe9088602b2d495fb4a4ee75ad86997a3ddb86c42
|
4
|
+
data.tar.gz: 8f56b485d373c66777ef5d535916953a57b0d5416019504ddc45d4a0d5fc37fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3eefe2c7ff3dd30bcf5f58ee2bdfe8ad86645f6e34f1b8d0a6fd74094bedaff76c96c0526b839dca435a4e1acda2f71c8687aaae27b62be301a1d087420bdcb2
|
7
|
+
data.tar.gz: 5fb275186d046fd0daa165b994f84df4d4f944c56128e7c9309c9070e4d1e4a9ebecaf2d1c22b8d5677c8493bfcffda9414ecb819673ed8216bc9d74c745bd09
|
@@ -101,7 +101,10 @@ module Administrate
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def order
|
104
|
-
@order ||= Administrate::Order.new(
|
104
|
+
@order ||= Administrate::Order.new(
|
105
|
+
params.fetch(resource_name, {}).fetch(:order, nil),
|
106
|
+
params.fetch(resource_name, {}).fetch(:direction, nil),
|
107
|
+
)
|
105
108
|
end
|
106
109
|
|
107
110
|
def dashboard
|
@@ -165,7 +168,7 @@ module Administrate
|
|
165
168
|
|
166
169
|
def show_search_bar?
|
167
170
|
dashboard.attribute_types_for(
|
168
|
-
dashboard.
|
171
|
+
dashboard.all_attributes,
|
169
172
|
).any? { |_name, attribute| attribute.searchable? }
|
170
173
|
end
|
171
174
|
|
@@ -32,12 +32,18 @@ module Administrate
|
|
32
32
|
ActiveModel::Naming.route_key(class_from_resource(resource_name))
|
33
33
|
end
|
34
34
|
|
35
|
-
def sanitized_order_params
|
36
|
-
|
35
|
+
def sanitized_order_params(page, current_field_name)
|
36
|
+
collection_names = page.association_includes + [current_field_name]
|
37
|
+
association_params = collection_names.map do |assoc_name|
|
38
|
+
{ assoc_name => %i[order direction page per_page] }
|
39
|
+
end
|
40
|
+
params.permit(:search, :id, :page, :per_page, association_params)
|
37
41
|
end
|
38
42
|
|
39
43
|
def clear_search_params
|
40
|
-
params.except(:search, :page).permit(
|
44
|
+
params.except(:search, :page).permit(
|
45
|
+
:per_page, resource_name => %i[order direction]
|
46
|
+
)
|
41
47
|
end
|
42
48
|
end
|
43
49
|
end
|
@@ -28,14 +28,13 @@ to display a collection of resources in an HTML table.
|
|
28
28
|
scope="col"
|
29
29
|
role="columnheader"
|
30
30
|
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
|
31
|
-
<%= link_to(sanitized_order_params.merge(
|
32
|
-
collection_presenter.order_params_for(attr_name)
|
31
|
+
<%= link_to(sanitized_order_params(page, collection_field_name).merge(
|
32
|
+
collection_presenter.order_params_for(attr_name, key: collection_field_name)
|
33
33
|
)) do %>
|
34
34
|
<%= t(
|
35
35
|
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
|
36
36
|
default: attr_name.to_s,
|
37
37
|
).titleize %>
|
38
|
-
|
39
38
|
<% if collection_presenter.ordered_by?(attr_name) %>
|
40
39
|
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
|
41
40
|
<svg aria-hidden="true">
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%#
|
2
2
|
# HasMany Form Partial
|
3
3
|
|
4
|
-
This partial renders an input element for
|
4
|
+
This partial renders an input element for has_many relationships.
|
5
5
|
By default, the input is a collection select box
|
6
6
|
that displays all possible records to associate with.
|
7
7
|
The collection select box supports multiple inputs,
|
@@ -20,7 +20,7 @@ and is augmented with [Selectize].
|
|
20
20
|
%>
|
21
21
|
|
22
22
|
<div class="field-unit__label">
|
23
|
-
<%= f.label field.
|
23
|
+
<%= f.label field.attribute, for: "#{f.object_name}_#{field.attribute_key}" %>
|
24
24
|
</div>
|
25
25
|
<div class="field-unit__field">
|
26
26
|
<%= f.select(field.attribute_key, nil, {}, multiple: true) do %>
|
@@ -19,15 +19,18 @@ from the associated resource class's dashboard.
|
|
19
19
|
%>
|
20
20
|
|
21
21
|
<% if field.resources.any? %>
|
22
|
+
<% order = field.order_from_params(params.fetch(field.name, {})) %>
|
23
|
+
<% page_number = params.fetch(field.name, {}).fetch(:page, nil) %>
|
22
24
|
<%= render(
|
23
25
|
"collection",
|
24
|
-
collection_presenter: field.associated_collection,
|
25
|
-
|
26
|
-
|
26
|
+
collection_presenter: field.associated_collection(order),
|
27
|
+
collection_field_name: field.name,
|
28
|
+
page: page,
|
29
|
+
resources: field.resources(page_number, order),
|
30
|
+
table_title: field.name,
|
27
31
|
) %>
|
28
|
-
|
29
32
|
<% if field.more_than_limit? %>
|
30
|
-
<%= paginate field.resources(
|
33
|
+
<%= paginate field.resources(page_number), param_name: "#{field.name}[page]" %>
|
31
34
|
<% end %>
|
32
35
|
|
33
36
|
<% else %>
|
@@ -18,7 +18,7 @@ The form will be rendered as nested_from to parent relationship.
|
|
18
18
|
|
19
19
|
<%= f.fields_for field.attribute, field.data || field.nested_form.resource.class.new do |has_one_f| %>
|
20
20
|
<fieldset class="field-unit--nested">
|
21
|
-
<legend><%= field.nested_form.resource_name.titleize %></legend>
|
21
|
+
<legend><%= t "helpers.label.#{f.object_name}.#{field.nested_form.resource_name}", default: field.nested_form.resource_name.titleize %></legend>
|
22
22
|
<% field.nested_form.attributes.each do |attribute| -%>
|
23
23
|
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
24
24
|
<%= render_field attribute, f: has_one_f %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
id:
|
3
|
+
administrate:
|
4
|
+
actions:
|
5
|
+
confirm: Anda yakin?
|
6
|
+
destroy: Hapus
|
7
|
+
edit: Perbarui
|
8
|
+
edit_resource: Perbarui %{name}
|
9
|
+
show_resource: Tampilkan %{name}
|
10
|
+
new_resource: "%{name} baru"
|
11
|
+
back: Kembali
|
12
|
+
controller:
|
13
|
+
create:
|
14
|
+
success: "%{resource} telah berhasil dibuat."
|
15
|
+
destroy:
|
16
|
+
success: "%{resource} telah berhasil dihapus."
|
17
|
+
update:
|
18
|
+
success: "%{resource} telah berhasil diperbarui."
|
19
|
+
fields:
|
20
|
+
has_many:
|
21
|
+
more: Menampilkan %{count} dari %{total_count}
|
22
|
+
none: Kosong
|
23
|
+
form:
|
24
|
+
error: error
|
25
|
+
errors: "%{pluralized_errors} membuat %{resource_name} tidak bisa tersimpan:"
|
26
|
+
search:
|
27
|
+
clear: Kosongkan pencarian
|
28
|
+
label: Cari %{resource}
|
@@ -21,8 +21,8 @@ zh-TW:
|
|
21
21
|
more: 顯示 %{total_count} 筆中的 %{count} 筆資料
|
22
22
|
none: 無
|
23
23
|
form:
|
24
|
-
error:
|
25
|
-
errors: "%{pluralized_errors}
|
24
|
+
error: 錯誤
|
25
|
+
errors: "%{pluralized_errors} 導致此 %{resource_name} 不能被儲存:"
|
26
26
|
search:
|
27
|
-
clear:
|
28
|
-
label:
|
27
|
+
clear: 清除搜尋
|
28
|
+
label: 搜尋 %{resource}
|
@@ -96,7 +96,7 @@ if `searchable` is `true`
|
|
96
96
|
For example:
|
97
97
|
|
98
98
|
```ruby
|
99
|
-
country: Field::BelongsTo(
|
99
|
+
country: Field::BelongsTo.with_options(
|
100
100
|
searchable: true,
|
101
101
|
seachable_field: 'name',
|
102
102
|
)
|
@@ -135,9 +135,9 @@ Default is `false`.
|
|
135
135
|
For example:
|
136
136
|
|
137
137
|
```ruby
|
138
|
-
cities: Field::HasMany(
|
138
|
+
cities: Field::HasMany.with_options(
|
139
139
|
searchable: true,
|
140
|
-
|
140
|
+
searchable_field: 'name',
|
141
141
|
)
|
142
142
|
```
|
143
143
|
|
@@ -192,7 +192,7 @@ in.
|
|
192
192
|
|
193
193
|
**Field::Select**
|
194
194
|
|
195
|
-
`:collection` - Specify the array or range to select from.
|
195
|
+
`:collection` - Specify the array or range to select from. Defaults to `[]`.
|
196
196
|
|
197
197
|
`:searchable` - Specify if the attribute should be considered when searching.
|
198
198
|
Default is `true`.
|
@@ -246,11 +246,11 @@ Add this method to the dashboard for Users.
|
|
246
246
|
Use whatever attribute or method you like.
|
247
247
|
Example for *user*:
|
248
248
|
|
249
|
-
|
249
|
+
```ruby
|
250
250
|
def display_resource(user)
|
251
251
|
user.name
|
252
252
|
end
|
253
|
-
|
253
|
+
```
|
254
254
|
|
255
255
|
[define your own]: /adding_custom_field_types
|
256
256
|
|
@@ -262,7 +262,7 @@ en:
|
|
262
262
|
models:
|
263
263
|
customer:
|
264
264
|
one: Happy Customer
|
265
|
-
|
265
|
+
other: Happy Customers
|
266
266
|
```
|
267
267
|
|
268
268
|
## Customizing Actions
|
@@ -32,6 +32,10 @@ module Administrate
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def all_attributes
|
36
|
+
attribute_types.keys
|
37
|
+
end
|
38
|
+
|
35
39
|
def form_attributes
|
36
40
|
self.class::FORM_ATTRIBUTES
|
37
41
|
end
|
@@ -61,7 +65,7 @@ module Administrate
|
|
61
65
|
field = self.class::ATTRIBUTE_TYPES[key]
|
62
66
|
|
63
67
|
next key if association_classes.include?(field)
|
64
|
-
key if association_classes.include?(field.try
|
68
|
+
key if association_classes.include?(field.try(:deferred_class))
|
65
69
|
end.compact
|
66
70
|
end
|
67
71
|
|
@@ -11,8 +11,8 @@ module Administrate
|
|
11
11
|
{ "#{attr.to_s.singularize}_ids".to_sym => [] }
|
12
12
|
end
|
13
13
|
|
14
|
-
def associated_collection
|
15
|
-
Administrate::Page::Collection.new(associated_dashboard)
|
14
|
+
def associated_collection(order = self.order)
|
15
|
+
Administrate::Page::Collection.new(associated_dashboard, order: order)
|
16
16
|
end
|
17
17
|
|
18
18
|
def attribute_key
|
@@ -39,7 +39,7 @@ module Administrate
|
|
39
39
|
self.class.permitted_attribute(attribute)
|
40
40
|
end
|
41
41
|
|
42
|
-
def resources(page = 1)
|
42
|
+
def resources(page = 1, order = self.order)
|
43
43
|
resources = order.apply(data).page(page).per(limit)
|
44
44
|
includes.any? ? resources.includes(*includes) : resources
|
45
45
|
end
|
@@ -49,7 +49,18 @@ module Administrate
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def data
|
52
|
-
@data ||= associated_class.none
|
52
|
+
@data ||= associated_class.none
|
53
|
+
end
|
54
|
+
|
55
|
+
def order_from_params(params)
|
56
|
+
Administrate::Order.new(
|
57
|
+
params.fetch(:order, sort_by),
|
58
|
+
params.fetch(:direction, direction),
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def order
|
63
|
+
@order ||= Administrate::Order.new(sort_by, direction)
|
53
64
|
end
|
54
65
|
|
55
66
|
private
|
@@ -71,10 +82,6 @@ module Administrate
|
|
71
82
|
associated_dashboard.display_resource(resource)
|
72
83
|
end
|
73
84
|
|
74
|
-
def order
|
75
|
-
@_order ||= Administrate::Order.new(sort_by, direction)
|
76
|
-
end
|
77
|
-
|
78
85
|
def sort_by
|
79
86
|
options[:sort_by]
|
80
87
|
end
|
@@ -21,7 +21,11 @@ module Administrate
|
|
21
21
|
ordered_by?(attr) && order.direction
|
22
22
|
end
|
23
23
|
|
24
|
-
delegate :ordered_by?,
|
24
|
+
delegate :ordered_by?, to: :order
|
25
|
+
|
26
|
+
def order_params_for(attr, key: resource_name)
|
27
|
+
{ key => order.order_params_for(attr) }
|
28
|
+
end
|
25
29
|
|
26
30
|
private
|
27
31
|
|
data/lib/administrate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Charlton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -282,6 +282,7 @@ files:
|
|
282
282
|
- config/locales/administrate.en.yml
|
283
283
|
- config/locales/administrate.es.yml
|
284
284
|
- config/locales/administrate.fr.yml
|
285
|
+
- config/locales/administrate.id.yml
|
285
286
|
- config/locales/administrate.it.yml
|
286
287
|
- config/locales/administrate.ja.yml
|
287
288
|
- config/locales/administrate.ko.yml
|
@@ -384,7 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
384
385
|
version: '0'
|
385
386
|
requirements: []
|
386
387
|
rubyforge_project:
|
387
|
-
rubygems_version: 2.7.
|
388
|
+
rubygems_version: 2.7.6
|
388
389
|
signing_key:
|
389
390
|
specification_version: 4
|
390
391
|
summary: A Rails engine for creating super-flexible admin dashboards
|