administrate 0.13.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/stylesheets/administrate/base/_tables.scss +3 -0
- data/app/assets/stylesheets/administrate/components/_attributes.scss +3 -2
- data/app/assets/stylesheets/administrate/components/_buttons.scss +3 -0
- data/app/assets/stylesheets/administrate/components/_field-unit.scss +4 -0
- 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/library/_variables.scss +10 -8
- data/app/controllers/administrate/application_controller.rb +47 -13
- data/app/helpers/administrate/application_helper.rb +27 -28
- 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 +2 -2
- data/app/views/administrate/application/_icons.html.erb +1 -1
- data/app/views/administrate/application/_index_header.html.erb +28 -0
- data/app/views/administrate/application/_navigation.html.erb +4 -4
- 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/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 +23 -9
- 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/_index.html.erb +1 -1
- data/app/views/fields/url/_show.html.erb +1 -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 +52 -0
- data/docs/customizing_controller_actions.md +32 -0
- data/docs/customizing_dashboards.md +81 -23
- data/docs/customizing_page_views.md +15 -3
- data/docs/extending_administrate.md +27 -0
- data/docs/getting_started.md +27 -5
- data/docs/guides/hiding_dashboards_from_sidebar.md +19 -0
- data/docs/guides.md +5 -0
- data/lib/administrate/base_dashboard.rb +34 -12
- 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 +30 -0
- data/lib/administrate/field/belongs_to.rb +13 -3
- data/lib/administrate/field/deferred.rb +22 -3
- data/lib/administrate/field/has_many.rb +15 -2
- data/lib/administrate/field/has_one.rb +28 -8
- data/lib/administrate/field/number.rb +19 -2
- data/lib/administrate/field/polymorphic.rb +2 -2
- data/lib/administrate/field/select.rb +10 -1
- data/lib/administrate/field/time.rb +11 -0
- data/lib/administrate/namespace.rb +5 -1
- data/lib/administrate/order.rb +3 -1
- data/lib/administrate/page/base.rb +1 -1
- data/lib/administrate/page/form.rb +10 -3
- data/lib/administrate/resource_resolver.rb +2 -2
- data/lib/administrate/search.rb +47 -36
- data/lib/administrate/version.rb +1 -1
- data/lib/administrate/view_generator.rb +7 -1
- 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 +2 -2
- data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +3 -3
- data/lib/generators/administrate/install/install_generator.rb +37 -1
- data/lib/generators/administrate/install/templates/application_controller.rb.erb +1 -1
- data/lib/generators/administrate/routes/routes_generator.rb +3 -13
- data/lib/generators/administrate/views/views_generator.rb +5 -4
- metadata +25 -44
- data/app/assets/javascripts/administrate/components/has_many_form.js +0 -3
- data/docs/contributing.md +0 -1
@@ -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,27 @@ 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
|
+
include_blank: field.include_blank_option
|
32
|
+
) %>
|
33
|
+
<% else %>
|
34
|
+
<%= f.select(
|
35
|
+
field.attribute,
|
36
|
+
options_from_collection_for_select(
|
37
|
+
field.selectable_options,
|
38
|
+
:to_s,
|
39
|
+
:to_s,
|
40
|
+
field.data,
|
41
|
+
),
|
42
|
+
include_blank: field.include_blank_option
|
43
|
+
) %>
|
44
|
+
<% end %>
|
31
45
|
</div>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Time Form Partial
|
3
3
|
|
4
4
|
This partial renders an input element for time attributes.
|
5
|
-
By default, the input is a
|
5
|
+
By default, the input is a text field that is augmented with [DateTimePicker].
|
6
6
|
|
7
7
|
## Local variables:
|
8
8
|
|
@@ -12,11 +12,12 @@ By default, the input is a select field for the time attributes.
|
|
12
12
|
An instance of [Administrate::Field::Time][1].
|
13
13
|
A wrapper around the tmie attributes pulled from the model.
|
14
14
|
|
15
|
+
[DateTimePicker]: https://github.com/Eonasdan/bootstrap-datetimepicker
|
15
16
|
%>
|
16
17
|
|
17
18
|
<div class="field-unit__label">
|
18
19
|
<%= f.label field.attribute %>
|
19
20
|
</div>
|
20
21
|
<div class="field-unit__field">
|
21
|
-
<%= f.text_field field.attribute, data: { type: 'time' } %>
|
22
|
+
<%= f.text_field field.attribute, data: { type: 'time' }, value: field.data&.strftime("%H:%M:%S") %>
|
22
23
|
</div>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
fi:
|
3
|
+
administrate:
|
4
|
+
actions:
|
5
|
+
confirm: Oletko varma?
|
6
|
+
destroy: Poista
|
7
|
+
edit: Muokkaa
|
8
|
+
edit_resource: Muokkaa %{name}
|
9
|
+
show_resource: Näytä %{name}
|
10
|
+
new_resource: Uusi %{name}
|
11
|
+
back: Takaisin
|
12
|
+
controller:
|
13
|
+
create:
|
14
|
+
success: "%{resource} luotiin onnistuneesti."
|
15
|
+
destroy:
|
16
|
+
success: "%{resource} poistettiin onnistuneesti."
|
17
|
+
update:
|
18
|
+
success: "%{resource} päivitettiin onnistuneesti."
|
19
|
+
fields:
|
20
|
+
has_many:
|
21
|
+
more: Näytetään %{count}/%{total_count}
|
22
|
+
none: Ei yhtään
|
23
|
+
form:
|
24
|
+
error: virhe
|
25
|
+
errors: "%{pluralized_errors} estivät tätä %{resource_name} tallentumasta:"
|
26
|
+
navigation:
|
27
|
+
back_to_app: Takaisin sovellukseen
|
28
|
+
search:
|
29
|
+
clear: Tyhjennä haku
|
30
|
+
label: Etsi %{resource}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
fr:
|
3
3
|
administrate:
|
4
4
|
actions:
|
5
|
-
confirm: Êtes-vous sûr ?
|
5
|
+
confirm: Êtes-vous sûr(e) ?
|
6
6
|
destroy: Supprimer
|
7
7
|
edit: Modifier
|
8
8
|
edit_resource: Modifier %{name}
|
@@ -22,7 +22,9 @@ fr:
|
|
22
22
|
none: Aucun
|
23
23
|
form:
|
24
24
|
error: erreur
|
25
|
-
errors: "%{pluralized_errors} ont
|
25
|
+
errors: "%{pluralized_errors} ont empêché %{resource_name} d'être sauvegardé(e) :"
|
26
|
+
navigation:
|
27
|
+
back_to_app: Retour à l'application
|
26
28
|
search:
|
27
29
|
clear: Effacer la recherche
|
28
30
|
label: Chercher %{resource}
|
@@ -11,18 +11,20 @@ nl:
|
|
11
11
|
back: Terug
|
12
12
|
controller:
|
13
13
|
create:
|
14
|
-
success: "%{resource}
|
14
|
+
success: "%{resource} is succesvol aangemaakt."
|
15
15
|
destroy:
|
16
|
-
success: "%{resource}
|
16
|
+
success: "%{resource} is succesvol verwijderd."
|
17
17
|
update:
|
18
|
-
success: "%{resource}
|
18
|
+
success: "%{resource} is succesvol geupdated."
|
19
19
|
fields:
|
20
20
|
has_many:
|
21
21
|
more: Resultaat %{count} van %{total_count}
|
22
22
|
none: Geen
|
23
23
|
form:
|
24
24
|
error: error
|
25
|
-
errors: "%{pluralized_errors}
|
25
|
+
errors: "%{pluralized_errors} maakten het onmogelijk %{resource_name} op:"
|
26
|
+
navigation:
|
27
|
+
back_to_app: Terug naar app
|
26
28
|
search:
|
27
|
-
clear:
|
29
|
+
clear: Wissen
|
28
30
|
label: Zoeken %{resource}
|
@@ -22,8 +22,10 @@ pt-BR:
|
|
22
22
|
more: "Exibindo %{count} de %{total_count}"
|
23
23
|
none: Nenhum
|
24
24
|
form:
|
25
|
-
error:
|
26
|
-
errors: "%{pluralized_errors}
|
25
|
+
error: erro
|
26
|
+
errors: "%{pluralized_errors} impediram %{resource_name} de ser gravado:"
|
27
|
+
navigation:
|
28
|
+
back_to_app: Voltar ao aplicativo
|
27
29
|
search:
|
28
30
|
clear: Limpar pesquisa
|
29
31
|
label: Pesquisa %{resource}
|
@@ -22,8 +22,10 @@ pt:
|
|
22
22
|
more: "Mostrando %{count} de %{total_count}"
|
23
23
|
none: Nenhum
|
24
24
|
form:
|
25
|
-
error:
|
26
|
-
errors: "%{pluralized_errors}
|
25
|
+
error: erro
|
26
|
+
errors: "%{pluralized_errors} impediram %{resource_name} de ser gravado:"
|
27
|
+
navigation:
|
28
|
+
back_to_app: Voltar à aplicação
|
27
29
|
search:
|
28
30
|
clear: Limpar pesquisa
|
29
31
|
label: Pesquisa %{resource}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
sq:
|
3
3
|
administrate:
|
4
4
|
actions:
|
5
5
|
confirm: A jeni te sigurtë?
|
@@ -23,6 +23,8 @@ al:
|
|
23
23
|
form:
|
24
24
|
error: gabim
|
25
25
|
errors: "%{pluralized_errors} nuk e lejoj %{resource_name} të ruhet:"
|
26
|
+
navigation:
|
27
|
+
back_to_app: Kthehu tek aplikacioni
|
26
28
|
search:
|
27
29
|
clear: Pastro kërkimin
|
28
30
|
label: Kërko %{resource}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
tr:
|
3
|
+
administrate:
|
4
|
+
actions:
|
5
|
+
confirm: Emin misiniz?
|
6
|
+
destroy: Sil
|
7
|
+
edit: Düzenle
|
8
|
+
edit_resource: "%{name} Kaydını Düzenle"
|
9
|
+
show_resource: "%{name} Kaydını Göster"
|
10
|
+
new_resource: Yeni %{name}
|
11
|
+
back: Geri
|
12
|
+
controller:
|
13
|
+
create:
|
14
|
+
success: "%{resource} kaydı başarıyla yaratıldı."
|
15
|
+
destroy:
|
16
|
+
success: "%{resource} kaydı başarıyla silindi."
|
17
|
+
update:
|
18
|
+
success: "%{resource} kaydı başarıyla düzenlendi."
|
19
|
+
fields:
|
20
|
+
has_many:
|
21
|
+
more: Toplam %{total_count} kayıttan %{count} adedi gösteriliyor
|
22
|
+
none: Yok
|
23
|
+
form:
|
24
|
+
error: Hata
|
25
|
+
errors: "%{resource_name} kaydedilemedi: %{pluralized_errors}"
|
26
|
+
navigation:
|
27
|
+
back_to_app: Uygulamaya geri dön
|
28
|
+
search:
|
29
|
+
clear: Temizle
|
30
|
+
label: "%{resource} içerisinde ara"
|
data/config/unicorn.rb
CHANGED
@@ -1,30 +1,25 @@
|
|
1
1
|
# https://devcenter.heroku.com/articles/rails-unicorn
|
2
2
|
|
3
|
-
worker_processes (ENV["
|
4
|
-
timeout
|
3
|
+
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
|
4
|
+
timeout 15
|
5
5
|
preload_app true
|
6
6
|
|
7
7
|
before_fork do |_server, _worker|
|
8
8
|
Signal.trap "TERM" do
|
9
|
-
puts "Unicorn master intercepting TERM
|
9
|
+
puts "Unicorn master intercepting TERM and sending myself QUIT instead"
|
10
10
|
Process.kill "QUIT", Process.pid
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
defined?(ActiveRecord::Base) &&
|
14
14
|
ActiveRecord::Base.connection.disconnect!
|
15
|
-
end
|
16
15
|
end
|
17
16
|
|
18
17
|
after_fork do |_server, _worker|
|
19
18
|
Signal.trap "TERM" do
|
20
|
-
puts "Unicorn worker intercepting TERM
|
19
|
+
puts "Unicorn worker intercepting TERM and doing nothing. " \
|
20
|
+
"Wait for master to send QUIT"
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
Rails.application.config.database_configuration[Rails.env]
|
26
|
-
config["reaping_frequency"] = (ENV["DB_REAPING_FREQUENCY"] || 10).to_i
|
27
|
-
config["pool"] = (ENV["DB_POOL"] || 2).to_i
|
28
|
-
ActiveRecord::Base.establish_connection(config)
|
29
|
-
end
|
23
|
+
defined?(ActiveRecord::Base) &&
|
24
|
+
ActiveRecord::Base.establish_connection
|
30
25
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
title: Adding Controllers without a related Model
|
3
|
+
---
|
4
|
+
|
5
|
+
Sometimes you may want to add a custom controller that has no resource
|
6
|
+
related to it (for example for a statistics page).
|
7
|
+
|
8
|
+
To do that, you must define an `index` route, as only controllers with index
|
9
|
+
routes are displayed in the sidebar and then add a custom dashboard:
|
10
|
+
|
11
|
+
```erb
|
12
|
+
# app/views/admin/stats/index.html.erb
|
13
|
+
|
14
|
+
<div style="padding: 20px">
|
15
|
+
<h1>Stats</h1>
|
16
|
+
<br>
|
17
|
+
<p><b>Total Customers:</b> <%= @stats[:customer_count] %></h1>
|
18
|
+
<br>
|
19
|
+
<p><b>Total Orders:</b> <%= @stats[:order_count] %></h1>
|
20
|
+
</div>
|
21
|
+
```
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# app/dashboards/stat_dashboard.rb
|
25
|
+
require "administrate/custom_dashboard"
|
26
|
+
|
27
|
+
class StatDashboard < Administrate::CustomDashboard
|
28
|
+
resource "Stats" # used by administrate in the views
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# app/controllers/admin/stats_controller.rb
|
34
|
+
module Admin
|
35
|
+
class StatsController < Admin::ApplicationController
|
36
|
+
def index
|
37
|
+
@stats = {
|
38
|
+
customer_count: Customer.count,
|
39
|
+
order_count: Order.count,
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
# config/routes.rb
|
48
|
+
namespace :admin do
|
49
|
+
# ...
|
50
|
+
resources :stats, only: [:index]
|
51
|
+
end
|
52
|
+
```
|
@@ -56,3 +56,35 @@ end
|
|
56
56
|
```
|
57
57
|
|
58
58
|
Action is one of `new`, `edit`, `show`, `destroy`.
|
59
|
+
|
60
|
+
## Customizing Default Sorting
|
61
|
+
|
62
|
+
To set the default sorting on the index action you could override `default_sorting_attribute` or `default_sorting_direction` in your dashboard controller like this:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
def default_sorting_attribute
|
66
|
+
:age
|
67
|
+
end
|
68
|
+
|
69
|
+
def default_sorting_direction
|
70
|
+
:desc
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
## Customizing Redirects after actions
|
75
|
+
|
76
|
+
To set custom redirects after the actions `create`, `update` and `destroy` you can override `after_resource_created_path`, `after_resource_updated_path` or `after_resource_destroyed_path` like this:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
def after_resource_destroyed_path(_requested_resource)
|
80
|
+
{ action: :index, controller: :some_other_resource }
|
81
|
+
end
|
82
|
+
|
83
|
+
def after_resource_created_path(requested_resource)
|
84
|
+
[namespace, requested_resource.some_other_resource]
|
85
|
+
end
|
86
|
+
|
87
|
+
def after_resource_updated_path(requested_resource)
|
88
|
+
[namespace, requested_resource.some_other_resource]
|
89
|
+
end
|
90
|
+
```
|