administrate 0.1.0 → 0.1.1
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/Rakefile +11 -16
- data/app/assets/javascripts/administrate/components/date_time_picker.js +1 -1
- data/app/assets/stylesheets/administrate/components/_attributes.scss +1 -1
- data/app/controllers/administrate/application_controller.rb +4 -4
- data/app/views/administrate/application/_form.html.erb +1 -1
- data/app/views/fields/belongs_to/_form.html.erb +3 -6
- data/app/views/fields/belongs_to/_index.html.erb +4 -1
- data/app/views/fields/belongs_to/_show.html.erb +4 -1
- data/app/views/fields/has_many/_form.html.erb +3 -9
- data/app/views/fields/has_one/_form.html.erb +1 -1
- data/app/views/fields/has_one/_index.html.erb +4 -1
- data/app/views/fields/has_one/_show.html.erb +4 -1
- data/app/views/fields/polymorphic/_index.html.erb +1 -1
- data/app/views/fields/polymorphic/_show.html.erb +2 -2
- data/app/views/fields/text/_form.html.erb +16 -0
- data/app/views/fields/text/_index.html.erb +17 -0
- data/app/views/fields/text/_show.html.erb +19 -1
- data/config/i18n-tasks.yml +18 -0
- data/config/locales/administrate.pl.yml +23 -0
- data/config/locales/administrate.ru.yml +23 -0
- data/config/locales/administrate.zh-CN.yml +23 -0
- data/config/locales/administrate.zh-TW.yml +23 -0
- data/config/unicorn.rb +30 -0
- data/lib/administrate/base_dashboard.rb +4 -0
- data/lib/administrate/engine.rb +3 -1
- data/lib/administrate/fields/associative.rb +25 -0
- data/lib/administrate/fields/base.rb +1 -0
- data/lib/administrate/fields/belongs_to.rb +12 -6
- data/lib/administrate/fields/date_time.rb +2 -0
- data/lib/administrate/fields/deferred.rb +6 -1
- data/lib/administrate/fields/has_many.rb +10 -8
- data/lib/administrate/fields/has_one.rb +2 -3
- data/lib/administrate/fields/polymorphic.rb +2 -2
- data/lib/administrate/page/form.rb +1 -1
- data/lib/administrate/page/show.rb +1 -1
- data/lib/administrate/search.rb +2 -2
- data/lib/administrate/version.rb +1 -1
- data/lib/generators/administrate/dashboard/dashboard_generator.rb +2 -1
- data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +7 -0
- data/lib/generators/administrate/install/install_generator.rb +25 -1
- metadata +26 -6
- data/LICENSE +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b6aee79ccfd9cf4056bd3c531db50a181e4d9cc
|
4
|
+
data.tar.gz: 9a44fee6bbe7975e58509295d36a260cab4cc129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba14d87d4b00302aedbf6e24a195178591f16b59830d17036c2d1376f51b55cccd538d0425d1fc35e4fadb0bf6740b0b4faaade4c94f5eaefffe3c46dad00ef4
|
7
|
+
data.tar.gz: 1221ee23052b1331a345b9358aafffd5b14d9a9cb2c4344e58d0364df2568b8f3b92cd574c76708d0b2ccfeb6a4a5133bd25427aa60303cc58945f72f04055aa
|
data/Rakefile
CHANGED
@@ -6,6 +6,8 @@ end
|
|
6
6
|
|
7
7
|
require 'rdoc/task'
|
8
8
|
|
9
|
+
require File.expand_path('../spec/example_app/config/application', __FILE__)
|
10
|
+
|
9
11
|
RDoc::Task.new(:rdoc) do |rdoc|
|
10
12
|
rdoc.rdoc_dir = 'rdoc'
|
11
13
|
rdoc.title = 'Administrate'
|
@@ -14,24 +16,17 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
16
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
17
|
end
|
16
18
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
-
load 'rails/tasks/engine.rake'
|
19
|
-
|
20
|
-
|
21
|
-
load 'rails/tasks/statistics.rake'
|
22
|
-
|
23
|
-
|
24
|
-
|
25
19
|
Bundler::GemHelper.install_tasks
|
26
20
|
|
27
|
-
|
21
|
+
Rails.application.load_tasks
|
22
|
+
task(:default).clear
|
23
|
+
task default: [:spec]
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
if defined? RSpec
|
26
|
+
task(:spec).clear
|
27
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
28
|
+
t.verbose = false
|
29
|
+
end
|
34
30
|
end
|
35
31
|
|
36
|
-
|
37
|
-
task default: :test
|
32
|
+
task default: "bundler:audit"
|
@@ -38,7 +38,7 @@ module Administrate
|
|
38
38
|
if resource.save
|
39
39
|
redirect_to(
|
40
40
|
[Administrate::NAMESPACE, resource],
|
41
|
-
notice:
|
41
|
+
notice: translate_with_resource("create.success"),
|
42
42
|
)
|
43
43
|
else
|
44
44
|
render :new, locals: {
|
@@ -51,7 +51,7 @@ module Administrate
|
|
51
51
|
if requested_resource.update(resource_params)
|
52
52
|
redirect_to(
|
53
53
|
[Administrate::NAMESPACE, requested_resource],
|
54
|
-
notice:
|
54
|
+
notice: translate_with_resource("update.success"),
|
55
55
|
)
|
56
56
|
else
|
57
57
|
render :edit, locals: {
|
@@ -62,7 +62,7 @@ module Administrate
|
|
62
62
|
|
63
63
|
def destroy
|
64
64
|
requested_resource.destroy
|
65
|
-
flash[:notice] =
|
65
|
+
flash[:notice] = translate_with_resource("destroy.success")
|
66
66
|
redirect_to action: :index
|
67
67
|
end
|
68
68
|
|
@@ -112,7 +112,7 @@ module Administrate
|
|
112
112
|
Administrate::ResourceResolver.new(controller_path)
|
113
113
|
end
|
114
114
|
|
115
|
-
def
|
115
|
+
def translate_with_resource(key)
|
116
116
|
t(
|
117
117
|
"administrate.controller.#{key}",
|
118
118
|
resource: resource_resolver.resource_title,
|
@@ -14,7 +14,7 @@ and renders all form fields for a resource's editable attributes.
|
|
14
14
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
15
15
|
%>
|
16
16
|
|
17
|
-
<%= form_for([Administrate::NAMESPACE, page.resource], class: "form") do |f| %>
|
17
|
+
<%= form_for([Administrate::NAMESPACE, page.resource], html: { class: "form" }) do |f| %>
|
18
18
|
<% if page.resource.errors.any? %>
|
19
19
|
<div id="error_explanation">
|
20
20
|
<h2>
|
@@ -17,9 +17,6 @@ that displays all possible records to associate with.
|
|
17
17
|
%>
|
18
18
|
|
19
19
|
<%= f.label field.permitted_attribute %>
|
20
|
-
<%= f.
|
21
|
-
field.
|
22
|
-
|
23
|
-
:id,
|
24
|
-
:to_s,
|
25
|
-
) %>
|
20
|
+
<%= f.select(field.permitted_attribute) do %>
|
21
|
+
<%= options_for_select(field.associated_resource_options) %>
|
22
|
+
<% end %>
|
@@ -16,5 +16,8 @@ By default, the relationship is rendered as a link to the associated object.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.data %>
|
19
|
-
<%= link_to
|
19
|
+
<%= link_to(
|
20
|
+
field.display_associated_resource,
|
21
|
+
[Administrate::NAMESPACE, field.data],
|
22
|
+
) %>
|
20
23
|
<% end %>
|
@@ -16,5 +16,8 @@ By default, the relationship is rendered as a link to the associated object.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.data %>
|
19
|
-
<%= link_to
|
19
|
+
<%= link_to(
|
20
|
+
field.display_associated_resource,
|
21
|
+
[Administrate::NAMESPACE, field.data],
|
22
|
+
) %>
|
20
23
|
<% end %>
|
@@ -21,12 +21,6 @@ and is augmented with [Selectize].
|
|
21
21
|
|
22
22
|
<%= f.label field.attribute_key %>
|
23
23
|
|
24
|
-
<%= f.
|
25
|
-
field.
|
26
|
-
|
27
|
-
:id,
|
28
|
-
:to_s,
|
29
|
-
{},
|
30
|
-
{ multiple: true },
|
31
|
-
)
|
32
|
-
%>
|
24
|
+
<%= f.select(field.attribute_key, nil, {}, multiple: true) do %>
|
25
|
+
<%= options_for_select(field.associated_resource_options) %>
|
26
|
+
<% end %>
|
@@ -17,6 +17,6 @@ so this partial renders a message to that effect.
|
|
17
17
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasOne
|
18
18
|
%>
|
19
19
|
|
20
|
-
<%= f.label field.
|
20
|
+
<%= f.label field.attribute %>
|
21
21
|
|
22
22
|
<%= t("administrate.fields.has_one.not_supported") %>
|
@@ -16,5 +16,8 @@ By default, the relationship is rendered as a link to the associated object.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.data %>
|
19
|
-
<%= link_to
|
19
|
+
<%= link_to(
|
20
|
+
field.display_associated_resource,
|
21
|
+
[Administrate::NAMESPACE, field.data],
|
22
|
+
) %>
|
20
23
|
<% end %>
|
@@ -16,5 +16,8 @@ By default, the relationship is rendered as a link to the associated object.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.data %>
|
19
|
-
<%= link_to
|
19
|
+
<%= link_to(
|
20
|
+
field.display_associated_resource,
|
21
|
+
[Administrate::NAMESPACE, field.data],
|
22
|
+
) %>
|
20
23
|
<% end %>
|
@@ -18,7 +18,7 @@ By default, the relationship is rendered as a link to the associated object.
|
|
18
18
|
|
19
19
|
<% if field.data %>
|
20
20
|
<%= link_to(
|
21
|
-
field.
|
22
|
-
|
21
|
+
field.display_associated_resource,
|
22
|
+
[:admin, field.data],
|
23
23
|
) %>
|
24
24
|
<% end %>
|
@@ -1,2 +1,18 @@
|
|
1
|
+
<%#
|
2
|
+
# Text Form Partial
|
3
|
+
|
4
|
+
This partial renders a textarea element for a text attribute.
|
5
|
+
|
6
|
+
## Local variables:
|
7
|
+
|
8
|
+
- `f`:
|
9
|
+
A Rails form generator, used to help create the appropriate input fields.
|
10
|
+
- `field`:
|
11
|
+
An instance of [Administrate::Field::Text][1].
|
12
|
+
A wrapper around the Text pulled from the database.
|
13
|
+
|
14
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Text
|
15
|
+
%>
|
16
|
+
|
1
17
|
<%= f.label field.attribute %>
|
2
18
|
<%= f.text_area field.attribute %>
|
@@ -1 +1,18 @@
|
|
1
|
+
<%#
|
2
|
+
# Text Index Partial
|
3
|
+
|
4
|
+
This partial renders a text attribute
|
5
|
+
to be displayed on a resource's index page.
|
6
|
+
|
7
|
+
By default, the attribute is rendered as a truncated string.
|
8
|
+
|
9
|
+
## Local variables:
|
10
|
+
|
11
|
+
- `field`:
|
12
|
+
An instance of [Administrate::Field::Text][1].
|
13
|
+
A wrapper around the Text pulled from the database.
|
14
|
+
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Text
|
16
|
+
%>
|
17
|
+
|
1
18
|
<%= field.truncate %>
|
@@ -1 +1,19 @@
|
|
1
|
-
|
1
|
+
<%#
|
2
|
+
# Text Show Partial
|
3
|
+
|
4
|
+
This partial renders a text attribute,
|
5
|
+
to be displayed on a resource's show page.
|
6
|
+
|
7
|
+
By default, the attribute is rendered as text with
|
8
|
+
whitespace preserved.
|
9
|
+
|
10
|
+
## Local variables:
|
11
|
+
|
12
|
+
- `field`:
|
13
|
+
An instance of [Administrate::Field::Text][1].
|
14
|
+
A wrapper around the Text pulled from the database.
|
15
|
+
|
16
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Text
|
17
|
+
%>
|
18
|
+
|
19
|
+
<span class="preserve-whitespace"><%= field.data %></span>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
search:
|
2
|
+
paths:
|
3
|
+
- "app/controllers"
|
4
|
+
- "app/helpers"
|
5
|
+
- "app/pages"
|
6
|
+
- "app/views"
|
7
|
+
|
8
|
+
data:
|
9
|
+
read:
|
10
|
+
- config/locales/administrate.%{locale}.yml
|
11
|
+
|
12
|
+
ignore_unused:
|
13
|
+
- activerecord.*
|
14
|
+
- administrate.*
|
15
|
+
- date.*
|
16
|
+
- simple_form.*
|
17
|
+
- time.*
|
18
|
+
- titles.*
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
pl:
|
3
|
+
administrate:
|
4
|
+
actions:
|
5
|
+
confirm: Czy jesteś pewien?
|
6
|
+
destroy: Usuń
|
7
|
+
edit: Edytuj
|
8
|
+
show: Wyświetl
|
9
|
+
controller:
|
10
|
+
create:
|
11
|
+
success: "Zasób %{resource} został pomyślnie utworzony."
|
12
|
+
destroy:
|
13
|
+
success: "Zasób %{resource} został pomyślnie usunięty."
|
14
|
+
update:
|
15
|
+
success: "Zasób %{resource} został pomyślnie zaktualizowany."
|
16
|
+
fields:
|
17
|
+
has_many:
|
18
|
+
more: Wyświetlanie %{count} z %{total_count}
|
19
|
+
none: Brak
|
20
|
+
polymorphic:
|
21
|
+
not_supported: Relacje polimorficzne nie są jeszcze obsługiwane. Przepraszamy!
|
22
|
+
has_one:
|
23
|
+
not_supported: Relacje jeden-do-jednego nie są jeszcze obsługiwane. Przepraszamy!
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
ru:
|
3
|
+
administrate:
|
4
|
+
actions:
|
5
|
+
confirm: Вы уверены?
|
6
|
+
destroy: Удалить
|
7
|
+
edit: Редактировать
|
8
|
+
show: Показать
|
9
|
+
controller:
|
10
|
+
create:
|
11
|
+
success: "%{resource} был успешно создан."
|
12
|
+
destroy:
|
13
|
+
success: "%{resource} был успешно удален."
|
14
|
+
update:
|
15
|
+
success: "%{resource} был успешно обновлен."
|
16
|
+
fields:
|
17
|
+
has_many:
|
18
|
+
more: "%{count} из %{total_count}"
|
19
|
+
none: Нет
|
20
|
+
polymorphic:
|
21
|
+
not_supported: Полиморфные отношения в формах не поддерживаются. Извините!
|
22
|
+
has_one:
|
23
|
+
not_supported: HasOne отношения в формах не поддерживаются. Извините!
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
zh-CN:
|
3
|
+
administrate:
|
4
|
+
actions:
|
5
|
+
confirm: 确定?
|
6
|
+
destroy: 删除
|
7
|
+
edit: 编辑
|
8
|
+
show: 查看
|
9
|
+
controller:
|
10
|
+
create:
|
11
|
+
success: "%{resource} 创建成功."
|
12
|
+
destroy:
|
13
|
+
success: "%{resource} 删除成功."
|
14
|
+
update:
|
15
|
+
success: "%{resource} 更新成功."
|
16
|
+
fields:
|
17
|
+
has_many:
|
18
|
+
more: 显示所有 %{total_count} 中 %{count} 条
|
19
|
+
none: 无
|
20
|
+
polymorphic:
|
21
|
+
not_supported: 对不起,Polymorphic 关系暂不支持!
|
22
|
+
has_one:
|
23
|
+
not_supported: 对不起,HasOne 关系暂不支持!
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
zh-TW:
|
3
|
+
administrate:
|
4
|
+
actions:
|
5
|
+
confirm: 確定?
|
6
|
+
destroy: 刪除
|
7
|
+
edit: 編輯
|
8
|
+
show: 檢視
|
9
|
+
controller:
|
10
|
+
create:
|
11
|
+
success: "已成功新增 %{resource}。"
|
12
|
+
destroy:
|
13
|
+
success: "已成功刪除 %{resource}。"
|
14
|
+
update:
|
15
|
+
success: "已成功更新 %{resource}。"
|
16
|
+
fields:
|
17
|
+
has_many:
|
18
|
+
more: 顯示 %{total_count} 筆中的 %{count} 筆資料
|
19
|
+
none: 無
|
20
|
+
polymorphic:
|
21
|
+
not_supported: 很抱歉,表單尚未支援 Polymorphic 關聯。
|
22
|
+
has_one:
|
23
|
+
not_supported: 很抱歉,表單尚未支援 HasOne 關聯。
|
data/config/unicorn.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# https://devcenter.heroku.com/articles/rails-unicorn
|
2
|
+
|
3
|
+
worker_processes (ENV["UNICORN_WORKERS"] || 3).to_i
|
4
|
+
timeout (ENV["UNICORN_TIMEOUT"] || 15).to_i
|
5
|
+
preload_app true
|
6
|
+
|
7
|
+
before_fork do |_server, _worker|
|
8
|
+
Signal.trap "TERM" do
|
9
|
+
puts "Unicorn master intercepting TERM, sending myself QUIT instead"
|
10
|
+
Process.kill "QUIT", Process.pid
|
11
|
+
end
|
12
|
+
|
13
|
+
if defined? ActiveRecord::Base
|
14
|
+
ActiveRecord::Base.connection.disconnect!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
after_fork do |_server, _worker|
|
19
|
+
Signal.trap "TERM" do
|
20
|
+
puts "Unicorn worker intercepting TERM, waiting for master to send QUIT"
|
21
|
+
end
|
22
|
+
|
23
|
+
if defined? ActiveRecord::Base
|
24
|
+
config = ActiveRecord::Base.configurations[Rails.env] ||
|
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
|
30
|
+
end
|
data/lib/administrate/engine.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require "datetime_picker_rails"
|
2
2
|
require "inline_svg"
|
3
|
+
require "jquery-rails"
|
3
4
|
require "kaminari"
|
4
5
|
require "momentjs-rails"
|
5
6
|
require "neat"
|
6
|
-
require "inline_svg"
|
7
7
|
require "normalize-rails"
|
8
|
+
require "sass-rails"
|
8
9
|
require "selectize-rails"
|
10
|
+
require "sprockets/railtie"
|
9
11
|
|
10
12
|
require "administrate/namespace"
|
11
13
|
require "administrate/page/form"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module Administrate
|
4
|
+
module Field
|
5
|
+
class Associative < Base
|
6
|
+
def display_associated_resource
|
7
|
+
associated_dashboard.display_resource(data)
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def associated_dashboard
|
13
|
+
"#{associated_class_name}Dashboard".constantize.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def associated_class
|
17
|
+
associated_class_name.constantize
|
18
|
+
end
|
19
|
+
|
20
|
+
def associated_class_name
|
21
|
+
options.fetch(:class_name, attribute.to_s.singularize.camelcase)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative "
|
1
|
+
require_relative "associative"
|
2
2
|
|
3
3
|
module Administrate
|
4
4
|
module Field
|
5
|
-
class BelongsTo <
|
5
|
+
class BelongsTo < Associative
|
6
6
|
def self.permitted_attribute(attr)
|
7
7
|
:"#{attr}_id"
|
8
8
|
end
|
@@ -11,14 +11,20 @@ module Administrate
|
|
11
11
|
self.class.permitted_attribute(attribute)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
14
|
+
def associated_resource_options
|
15
|
+
candidate_resources.map do |resource|
|
16
|
+
[display_candidate_resource(resource), resource.id]
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
19
21
|
|
20
|
-
def
|
21
|
-
|
22
|
+
def candidate_resources
|
23
|
+
associated_class.all
|
24
|
+
end
|
25
|
+
|
26
|
+
def display_candidate_resource(resource)
|
27
|
+
associated_dashboard.display_resource(resource)
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "active_support/core_ext/module/delegation"
|
2
|
+
|
1
3
|
module Administrate
|
2
4
|
module Field
|
3
5
|
class Deferred
|
@@ -16,10 +18,13 @@ module Administrate
|
|
16
18
|
deferred_class == other.deferred_class && options == other.options
|
17
19
|
end
|
18
20
|
|
21
|
+
def searchable?
|
22
|
+
options.fetch(:searchable, deferred_class.searchable?)
|
23
|
+
end
|
24
|
+
|
19
25
|
delegate(
|
20
26
|
:html_class,
|
21
27
|
:permitted_attribute,
|
22
|
-
:searchable?,
|
23
28
|
to: :deferred_class,
|
24
29
|
)
|
25
30
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative "
|
1
|
+
require_relative "associative"
|
2
2
|
require "administrate/page/collection"
|
3
3
|
|
4
4
|
module Administrate
|
5
5
|
module Field
|
6
|
-
class HasMany <
|
6
|
+
class HasMany < Associative
|
7
7
|
DEFAULT_LIMIT = 5
|
8
8
|
|
9
9
|
def self.permitted_attribute(attribute)
|
@@ -18,8 +18,10 @@ module Administrate
|
|
18
18
|
permitted_attribute.keys.first
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
21
|
+
def associated_resource_options
|
22
|
+
candidate_resources.map do |resource|
|
23
|
+
[display_candidate_resource(resource), resource.id]
|
24
|
+
end
|
23
25
|
end
|
24
26
|
|
25
27
|
def limit
|
@@ -40,12 +42,12 @@ module Administrate
|
|
40
42
|
|
41
43
|
private
|
42
44
|
|
43
|
-
def
|
44
|
-
|
45
|
+
def candidate_resources
|
46
|
+
associated_class.all
|
45
47
|
end
|
46
48
|
|
47
|
-
def
|
48
|
-
|
49
|
+
def display_candidate_resource(resource)
|
50
|
+
associated_dashboard.display_resource(resource)
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
data/lib/administrate/search.rb
CHANGED
@@ -18,11 +18,11 @@ module Administrate
|
|
18
18
|
delegate :resource_class, to: :resolver
|
19
19
|
|
20
20
|
def query
|
21
|
-
search_attributes.map { |attr| "#{attr}
|
21
|
+
search_attributes.map { |attr| "lower(#{attr}) LIKE ?" }.join(" OR ")
|
22
22
|
end
|
23
23
|
|
24
24
|
def search_terms
|
25
|
-
["%#{term}%"] * search_attributes.count
|
25
|
+
["%#{term.downcase}%"] * search_attributes.count
|
26
26
|
end
|
27
27
|
|
28
28
|
def search_attributes
|
data/lib/administrate/version.rb
CHANGED
@@ -11,13 +11,14 @@ module Administrate
|
|
11
11
|
integer: "Field::Number",
|
12
12
|
time: "Field::DateTime",
|
13
13
|
text: "Field::Text",
|
14
|
+
string: "Field::String",
|
14
15
|
}
|
15
16
|
|
16
17
|
ATTRIBUTE_OPTIONS_MAPPING = {
|
17
18
|
float: { decimals: 2 },
|
18
19
|
}
|
19
20
|
|
20
|
-
DEFAULT_FIELD_TYPE = "Field::String"
|
21
|
+
DEFAULT_FIELD_TYPE = "Field::String.with_options(searchable: false)"
|
21
22
|
COLLECTION_ATTRIBUTE_LIMIT = 4
|
22
23
|
READ_ONLY_ATTRIBUTES = %w[id created_at updated_at]
|
23
24
|
|
@@ -40,4 +40,11 @@ class <%= class_name %>Dashboard < Administrate::BaseDashboard
|
|
40
40
|
end.join("\n")
|
41
41
|
%>
|
42
42
|
]
|
43
|
+
|
44
|
+
# Overwrite this method to customize how <%= file_name.pluralize.humanize.downcase %> are displayed
|
45
|
+
# across all pages of the admin dashboard.
|
46
|
+
#
|
47
|
+
# def display_resource(<%= file_name %>)
|
48
|
+
# "<%= class_name %> ##{<%= file_name %>.id}"
|
49
|
+
# end
|
43
50
|
end
|
@@ -30,6 +30,18 @@ module Administrate
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def warn_about_invalid_models
|
34
|
+
namespaced_models.each do |invalid_model|
|
35
|
+
puts "WARNING: Unable to generate a dashboard for #{invalid_model}."
|
36
|
+
puts " Administrate does not yet support namespaced models."
|
37
|
+
end
|
38
|
+
|
39
|
+
models_without_tables.each do |invalid_model|
|
40
|
+
puts "WARNING: Unable to generate a dashboard for #{invalid_model}."
|
41
|
+
puts " It is not connected to a database table."
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
33
45
|
private
|
34
46
|
|
35
47
|
def singular_dashboard_resources
|
@@ -43,13 +55,25 @@ module Administrate
|
|
43
55
|
end
|
44
56
|
|
45
57
|
def valid_dashboard_models
|
46
|
-
database_models
|
58
|
+
database_models - invalid_database_models
|
47
59
|
end
|
48
60
|
|
49
61
|
def database_models
|
50
62
|
ActiveRecord::Base.descendants
|
51
63
|
end
|
52
64
|
|
65
|
+
def invalid_database_models
|
66
|
+
models_without_tables + namespaced_models
|
67
|
+
end
|
68
|
+
|
69
|
+
def models_without_tables
|
70
|
+
database_models.reject(&:table_exists?)
|
71
|
+
end
|
72
|
+
|
73
|
+
def namespaced_models
|
74
|
+
database_models.select { |model| model.to_s.include?("::") }
|
75
|
+
end
|
76
|
+
|
53
77
|
def dashboard_routes
|
54
78
|
File.read(routes_file_path)
|
55
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grayson Wright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autoprefixer-rails
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jquery-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: kaminari
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,19 +137,19 @@ dependencies:
|
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '4.2'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: sass
|
140
|
+
name: sass-rails
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
145
|
+
version: '5.0'
|
132
146
|
type: :runtime
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
152
|
+
version: '5.0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: selectize-rails
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,7 +183,6 @@ executables: []
|
|
169
183
|
extensions: []
|
170
184
|
extra_rdoc_files: []
|
171
185
|
files:
|
172
|
-
- LICENSE
|
173
186
|
- Rakefile
|
174
187
|
- app/assets/images/administrate/dropdown.svg
|
175
188
|
- app/assets/images/administrate/search.svg
|
@@ -252,11 +265,18 @@ files:
|
|
252
265
|
- app/views/fields/text/_index.html.erb
|
253
266
|
- app/views/fields/text/_show.html.erb
|
254
267
|
- app/views/layouts/administrate/application.html.erb
|
268
|
+
- config/i18n-tasks.yml
|
255
269
|
- config/locales/administrate.en.yml
|
270
|
+
- config/locales/administrate.pl.yml
|
271
|
+
- config/locales/administrate.ru.yml
|
272
|
+
- config/locales/administrate.zh-CN.yml
|
273
|
+
- config/locales/administrate.zh-TW.yml
|
256
274
|
- config/routes.rb
|
275
|
+
- config/unicorn.rb
|
257
276
|
- lib/administrate.rb
|
258
277
|
- lib/administrate/base_dashboard.rb
|
259
278
|
- lib/administrate/engine.rb
|
279
|
+
- lib/administrate/fields/associative.rb
|
260
280
|
- lib/administrate/fields/base.rb
|
261
281
|
- lib/administrate/fields/belongs_to.rb
|
262
282
|
- lib/administrate/fields/boolean.rb
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2015 Grayson Wright
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|