administrate 0.12.0 → 0.15.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/components/_attributes.scss +4 -3
- data/app/assets/stylesheets/administrate/components/_buttons.scss +8 -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 +29 -8
- data/app/helpers/administrate/application_helper.rb +32 -14
- data/app/views/administrate/application/_collection.html.erb +6 -4
- data/app/views/administrate/application/_form.html.erb +2 -2
- data/app/views/administrate/application/_navigation.html.erb +5 -3
- data/app/views/administrate/application/index.html.erb +2 -2
- 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/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 +21 -9
- 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/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 +54 -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 +4 -1
- data/docs/customizing_controller_actions.md +30 -1
- data/docs/customizing_dashboards.md +47 -35
- data/docs/customizing_page_views.md +18 -4
- data/docs/extending_administrate.md +27 -0
- data/docs/getting_started.md +35 -11
- data/docs/guides/hiding_dashboards_from_sidebar.md +19 -0
- data/docs/guides.md +5 -0
- data/docs/rails_api.md +5 -3
- data/lib/administrate/base_dashboard.rb +19 -10
- 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 +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 +15 -2
- 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 +6 -1
- data/lib/administrate/namespace.rb +4 -0
- data/lib/administrate/order.rb +17 -7
- data/lib/administrate/page/base.rb +1 -3
- data/lib/administrate/page/form.rb +1 -1
- data/lib/administrate/resource_resolver.rb +1 -1
- data/lib/administrate/search.rb +26 -19
- 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 +18 -14
- data/lib/generators/administrate/dashboard/templates/controller.rb.erb +20 -8
- data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +4 -4
- data/lib/generators/administrate/install/install_generator.rb +37 -1
- data/lib/generators/administrate/install/templates/application_controller.rb.erb +3 -3
- data/lib/generators/administrate/routes/routes_generator.rb +15 -25
- data/lib/generators/administrate/views/views_generator.rb +5 -4
- metadata +26 -29
- data/app/assets/javascripts/administrate/components/has_many_form.js +0 -3
@@ -4,7 +4,7 @@
|
|
4
4
|
This partial renders a string attribute,
|
5
5
|
to be displayed on a resource's show page.
|
6
6
|
|
7
|
-
By default, the attribute is rendered as
|
7
|
+
By default, the attribute is rendered as text with whitespace preserved.
|
8
8
|
|
9
9
|
## Local variables:
|
10
10
|
|
@@ -15,4 +15,4 @@ By default, the attribute is rendered as an unformatted string.
|
|
15
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/String
|
16
16
|
%>
|
17
17
|
|
18
|
-
|
18
|
+
<div class="preserve-whitespace"><%= field.data %></div>
|
@@ -4,8 +4,7 @@
|
|
4
4
|
This partial renders a text attribute,
|
5
5
|
to be displayed on a resource's show page.
|
6
6
|
|
7
|
-
By default, the attribute is rendered as text with
|
8
|
-
whitespace preserved.
|
7
|
+
By default, the attribute is rendered as text with whitespace preserved.
|
9
8
|
|
10
9
|
## Local variables:
|
11
10
|
|
@@ -16,4 +15,4 @@ whitespace preserved.
|
|
16
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Text
|
17
16
|
%>
|
18
17
|
|
19
|
-
<
|
18
|
+
<div class="preserve-whitespace"><%= field.data %></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,54 @@
|
|
1
|
+
---
|
2
|
+
title: Adding Controllers without a related Model
|
3
|
+
---
|
4
|
+
|
5
|
+
# Adding Controllers without a related Model
|
6
|
+
|
7
|
+
Sometimes you may want to add a custom controller that has no resource
|
8
|
+
related to it (for example for a statistics page).
|
9
|
+
|
10
|
+
To do that, you must define an `index` route, as only controllers with index
|
11
|
+
routes are displayed in the sidebar and then add a custom dashboard:
|
12
|
+
|
13
|
+
```erb
|
14
|
+
# app/views/admin/stats/index.html.erb
|
15
|
+
|
16
|
+
<div style="padding: 20px">
|
17
|
+
<h1>Stats</h1>
|
18
|
+
<br>
|
19
|
+
<p><b>Total Customers:</b> <%= @stats[:customer_count] %></h1>
|
20
|
+
<br>
|
21
|
+
<p><b>Total Orders:</b> <%= @stats[:order_count] %></h1>
|
22
|
+
</div>
|
23
|
+
```
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# app/dashboards/stat_dashboard.rb
|
27
|
+
require "administrate/custom_dashboard"
|
28
|
+
|
29
|
+
class StatDashboard < Administrate::CustomDashboard
|
30
|
+
resource "Stats" # used by administrate in the views
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
# app/controllers/admin/stats_controller.rb
|
36
|
+
module Admin
|
37
|
+
class StatsController < Admin::ApplicationController
|
38
|
+
def index
|
39
|
+
@stats = {
|
40
|
+
customer_count: Customer.count,
|
41
|
+
order_count: Order.count,
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
# config/routes.rb
|
50
|
+
namespace :admin do
|
51
|
+
# ...
|
52
|
+
resources :stats, only: [:index]
|
53
|
+
end
|
54
|
+
```
|
data/docs/authentication.md
CHANGED
data/docs/authorization.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
---
|
2
|
+
title: Authorization
|
3
|
+
---
|
2
4
|
|
3
5
|
The default configuration of Administrate is "authenticate-only" - once a
|
4
6
|
user is authenticated, that user has access to every action of every object.
|
@@ -37,7 +39,7 @@ class PostPolicy < ApplicationPolicy
|
|
37
39
|
def resolve
|
38
40
|
scope.all
|
39
41
|
end
|
40
|
-
|
42
|
+
|
41
43
|
def resolve_admin
|
42
44
|
scope.where(owner: user)
|
43
45
|
end
|
@@ -62,7 +64,7 @@ def authorize_resource(resource)
|
|
62
64
|
raise "Erg!" unless show_action?(params[:action], resource)
|
63
65
|
end
|
64
66
|
|
65
|
-
# Hide links to actions if the user is not allowed to do them
|
67
|
+
# Hide links to actions if the user is not allowed to do them
|
66
68
|
def show_action?(action, resource)
|
67
69
|
current_user.can? action, resource
|
68
70
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
---
|
2
|
+
title: Customizing attribute partials
|
3
|
+
---
|
2
4
|
|
3
5
|
Occasionally you might want to change how specific types of attributes appear
|
4
6
|
across all dashboards. You can customize the following built in field types:
|
@@ -6,6 +8,7 @@ across all dashboards. You can customize the following built in field types:
|
|
6
8
|
- `belongs_to`
|
7
9
|
- `boolean`
|
8
10
|
- `date_time`
|
11
|
+
- `date`
|
9
12
|
- `email`
|
10
13
|
- `has_many`
|
11
14
|
- `has_one`
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
---
|
2
|
+
title: Customizing controller actions
|
3
|
+
---
|
2
4
|
|
3
5
|
When you install Administrate into your app,
|
4
6
|
we generate empty controllers for each of your resources.
|
@@ -41,3 +43,30 @@ class Admin::FoosController < Admin::ApplicationController
|
|
41
43
|
# end
|
42
44
|
end
|
43
45
|
```
|
46
|
+
|
47
|
+
## Customizing Actions
|
48
|
+
|
49
|
+
To enable or disable certain actions you could override `valid_action?` method in your dashboard controller like this:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
# disable 'edit' and 'destroy' links
|
53
|
+
def valid_action?(name, resource = resource_class)
|
54
|
+
%w[edit destroy].exclude?(name.to_s) && super
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
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
|
+
```
|