administrate 0.7.0 → 0.8.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/stylesheets/administrate/application.scss +1 -1
- data/app/assets/stylesheets/administrate/base/_forms.scss +5 -1
- data/app/assets/stylesheets/administrate/components/_attributes.scss +5 -0
- data/app/assets/stylesheets/administrate/components/_cells.scss +2 -2
- data/app/assets/stylesheets/administrate/components/_field-unit.scss +15 -0
- data/app/assets/stylesheets/administrate/components/_main-content.scss +1 -2
- data/app/assets/stylesheets/administrate/components/_search.scss +30 -65
- data/app/assets/stylesheets/administrate/library/_variables.scss +28 -27
- data/app/controllers/administrate/application_controller.rb +15 -7
- data/app/helpers/administrate/application_helper.rb +5 -15
- data/app/views/administrate/application/_collection.html.erb +16 -14
- data/app/views/administrate/application/_icons.erb +13 -0
- data/app/views/administrate/application/_search.html.erb +23 -19
- data/app/views/administrate/application/index.html.erb +15 -7
- data/app/views/administrate/application/show.html.erb +1 -1
- data/app/views/fields/has_many/_show.html.erb +2 -1
- data/app/views/fields/has_one/_form.html.erb +11 -9
- data/app/views/fields/has_one/_show.html.erb +22 -5
- data/app/views/layouts/administrate/application.html.erb +2 -1
- data/config/locales/administrate.ar.yml +3 -0
- data/config/locales/administrate.da.yml +3 -0
- data/config/locales/administrate.de.yml +3 -0
- data/config/locales/administrate.en.yml +3 -0
- data/config/locales/administrate.es.yml +3 -0
- data/config/locales/administrate.fr.yml +3 -0
- data/config/locales/administrate.it.yml +3 -0
- data/config/locales/administrate.ja.yml +3 -0
- data/config/locales/administrate.ko.yml +3 -0
- data/config/locales/administrate.nl.yml +3 -0
- data/config/locales/administrate.pl.yml +3 -0
- data/config/locales/administrate.pt-BR.yml +3 -0
- data/config/locales/administrate.pt.yml +3 -0
- data/config/locales/administrate.ru.yml +3 -0
- data/config/locales/administrate.sv.yml +3 -0
- data/config/locales/administrate.uk.yml +3 -0
- data/config/locales/administrate.vi.yml +3 -0
- data/config/locales/administrate.zh-CN.yml +3 -0
- data/config/locales/administrate.zh-TW.yml +3 -0
- data/docs/customizing_controller_actions.md +10 -0
- data/docs/customizing_page_views.md +2 -2
- data/lib/administrate/engine.rb +0 -8
- data/lib/administrate/field/base.rb +2 -1
- data/lib/administrate/field/deferred.rb +2 -1
- data/lib/administrate/field/has_many.rb +7 -1
- data/lib/administrate/field/has_one.rb +17 -1
- data/lib/administrate/order.rb +1 -1
- data/lib/administrate/page/base.rb +1 -1
- data/lib/administrate/search.rb +8 -9
- data/lib/administrate/version.rb +1 -1
- data/lib/generators/administrate/assets/assets_generator.rb +0 -1
- data/lib/generators/administrate/routes/routes_generator.rb +1 -1
- data/lib/generators/administrate/views/layout_generator.rb +1 -0
- metadata +11 -30
- data/app/assets/images/administrate/cancel.svg +0 -6
- data/app/assets/images/administrate/dropdown.svg +0 -3
- data/app/assets/images/administrate/search.svg +0 -6
- data/app/assets/images/administrate/sort_arrow.svg +0 -4
- data/app/assets/javascripts/administrate/components/_search.js +0 -43
- data/lib/generators/administrate/assets/images_generator.rb +0 -17
@@ -0,0 +1,13 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
2
|
+
<symbol id="icon-cancel" viewBox="0 0 48 48">
|
3
|
+
<path fill-rule="evenodd" d="M24 19.757l-8.485-8.485c-.784-.783-2.047-.782-2.827 0l-1.417 1.416c-.777.777-.78 2.046.002 2.827L19.757 24l-8.485 8.485c-.783.784-.782 2.047 0 2.827l1.416 1.417c.777.777 2.046.78 2.827-.002L24 28.243l8.485 8.485c.784.783 2.047.782 2.827 0l1.417-1.416c.777-.777.78-2.046-.002-2.827L28.243 24l8.485-8.485c.783-.784.782-2.047 0-2.827l-1.416-1.417c-.777-.777-2.046-.78-2.827.002L24 19.757zM24 47c12.703 0 23-10.297 23-23S36.703 1 24 1 1 11.297 1 24s10.297 23 23 23z" />
|
4
|
+
</symbol>
|
5
|
+
|
6
|
+
<symbol id="icon-eyeglass" viewBox="0 0 48 48">
|
7
|
+
<path d="M27.885 32.515c-2.864 1.966-6.333 3.116-10.07 3.116C7.976 35.63 0 27.656 0 17.817 0 7.976 7.976 0 17.816 0S35.63 7.976 35.63 17.816c0 3.736-1.15 7.205-3.115 10.07l14.53 14.53c1.278 1.277 1.275 3.352 0 4.628-1.28 1.278-3.353 1.278-4.63 0l-14.53-14.53zm-10.07-3.736c6.056 0 10.964-4.91 10.964-10.964 0-6.055-4.91-10.964-10.964-10.964-6.055 0-10.964 4.91-10.964 10.964 0 6.055 4.91 10.963 10.964 10.963z" />
|
8
|
+
</symbol>
|
9
|
+
|
10
|
+
<symbol id="icon-up-caret" viewBox="0 0 48 48">
|
11
|
+
<path d="M2.988 33.02c-1.66 0-1.943-.81-.618-1.824l20-15.28c.878-.672 2.31-.67 3.188 0l20.075 15.288c1.316 1.003 1.048 1.816-.62 1.816H2.987z" />
|
12
|
+
</symbol>
|
13
|
+
</svg>
|
@@ -1,21 +1,25 @@
|
|
1
1
|
<form class="search" role="search">
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
2
|
+
<label class="search__label" for="search">
|
3
|
+
<svg class="search__eyeglass-icon" role="img">
|
4
|
+
<title>
|
5
|
+
<%= t("administrate.search.label", resource: resource_name) %>
|
6
|
+
</title>
|
7
|
+
<use xlink:href="#icon-eyeglass" />
|
8
|
+
</svg>
|
9
|
+
</label>
|
10
|
+
|
11
|
+
<input class="search__input"
|
12
|
+
id="search"
|
13
|
+
type="search"
|
14
|
+
name="search"
|
15
|
+
placeholder="<%= t("administrate.search.label",
|
16
|
+
resource: resource_name) %>"
|
17
|
+
value="<%= search_term %>">
|
18
|
+
|
19
|
+
<%= link_to clear_search_params, class: "search__clear-link" do %>
|
20
|
+
<svg class="search__clear-icon" role="img">
|
21
|
+
<title><%= t("administrate.search.clear") %></title>
|
22
|
+
<use xlink:href="#icon-cancel" />
|
23
|
+
</svg>
|
24
|
+
<% end %>
|
21
25
|
</form>
|
@@ -27,17 +27,19 @@ It renders the `_table` partial to display details about the resources.
|
|
27
27
|
<%= display_resource_name(page.resource_name) %>
|
28
28
|
<% end %>
|
29
29
|
|
30
|
-
<% content_for(:search) do %>
|
31
|
-
<% if show_search_bar %>
|
32
|
-
<%= render "search", search_term: search_term %>
|
33
|
-
<% end %>
|
34
|
-
<% end %>
|
35
|
-
|
36
30
|
<header class="main-content__header" role="banner">
|
37
31
|
<h1 class="main-content__page-title" id="page-title">
|
38
32
|
<%= content_for(:title) %>
|
39
33
|
</h1>
|
40
34
|
|
35
|
+
<% if show_search_bar %>
|
36
|
+
<%= render(
|
37
|
+
"search",
|
38
|
+
search_term: search_term,
|
39
|
+
resource_name: display_resource_name(page.resource_name)
|
40
|
+
) %>
|
41
|
+
<% end %>
|
42
|
+
|
41
43
|
<div>
|
42
44
|
<%= link_to(
|
43
45
|
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
|
@@ -48,6 +50,12 @@ It renders the `_table` partial to display details about the resources.
|
|
48
50
|
</header>
|
49
51
|
|
50
52
|
<section class="main-content__body main-content__body--flush">
|
51
|
-
<%= render
|
53
|
+
<%= render(
|
54
|
+
"collection",
|
55
|
+
collection_presenter: page,
|
56
|
+
resources: resources,
|
57
|
+
table_title: "page-title"
|
58
|
+
) %>
|
59
|
+
|
52
60
|
<%= paginate resources %>
|
53
61
|
</section>
|
@@ -35,7 +35,7 @@ as well as a link to its edit page.
|
|
35
35
|
<section class="main-content__body">
|
36
36
|
<dl>
|
37
37
|
<% page.attributes.each do |attribute| %>
|
38
|
-
<dt class="attribute-label">
|
38
|
+
<dt class="attribute-label" id="<%= attribute.name %>">
|
39
39
|
<%= t(
|
40
40
|
"helpers.label.#{resource_name}.#{attribute.name}",
|
41
41
|
default: attribute.name.titleize,
|
@@ -22,7 +22,8 @@ from the associated resource class's dashboard.
|
|
22
22
|
<%= render(
|
23
23
|
"collection",
|
24
24
|
collection_presenter: field.associated_collection,
|
25
|
-
resources: field.resources(params[field.name])
|
25
|
+
resources: field.resources(params[field.name]),
|
26
|
+
table_title: field.name
|
26
27
|
) %>
|
27
28
|
|
28
29
|
<% if field.more_than_limit? %>
|
@@ -3,8 +3,7 @@
|
|
3
3
|
|
4
4
|
This partial renders an input element for has_one relationships.
|
5
5
|
|
6
|
-
|
7
|
-
so this partial renders a message to that effect.
|
6
|
+
The form will be rendered as nested_from to parent relationship.
|
8
7
|
|
9
8
|
## Local variables:
|
10
9
|
|
@@ -17,10 +16,13 @@ so this partial renders a message to that effect.
|
|
17
16
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasOne
|
18
17
|
%>
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
<div class="field-
|
25
|
-
|
26
|
-
</div>
|
19
|
+
<%= f.fields_for field.attribute, field.data || field.nested_form.resource.class.new do |has_one_f| %>
|
20
|
+
<fieldset class="field-unit--nested">
|
21
|
+
<legend><%= field.nested_form.resource_name.titleize %></legend>
|
22
|
+
<% field.nested_form.attributes.each do |attribute| -%>
|
23
|
+
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
24
|
+
<%= render_field attribute, f: has_one_f %>
|
25
|
+
</div>
|
26
|
+
<% end -%>
|
27
|
+
</fieldset>
|
28
|
+
<% end %>
|
@@ -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
|
-
|
7
|
+
All fields of has_one relationship would be rendered
|
8
8
|
|
9
9
|
## Local variables:
|
10
10
|
|
@@ -16,8 +16,25 @@ 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
|
+
<fieldset class="attribute--nested">
|
20
|
+
<legend>
|
21
|
+
<%= link_to(
|
22
|
+
field.display_associated_resource,
|
23
|
+
[namespace, field.data],
|
24
|
+
) %>
|
25
|
+
</legend>
|
26
|
+
<% field.nested_form.attributes.each do |attribute| -%>
|
27
|
+
<div>
|
28
|
+
<dt class="attribute-label">
|
29
|
+
<%= t(
|
30
|
+
"helpers.label.#{resource_name}.#{attribute.name}",
|
31
|
+
default: attribute.name.titleize,
|
32
|
+
) %>
|
33
|
+
</dt>
|
34
|
+
<dd class="attribute-data attribute-data--<%= attribute.html_class %>">
|
35
|
+
<%= attribute.data %>
|
36
|
+
</dd>
|
37
|
+
</div>
|
38
|
+
<% end -%>
|
39
|
+
</fieldset>
|
23
40
|
<% end %>
|
@@ -25,11 +25,12 @@ By default, it renders:
|
|
25
25
|
<%= csrf_meta_tags %>
|
26
26
|
</head>
|
27
27
|
<body>
|
28
|
+
<%= render "icons" %>
|
29
|
+
|
28
30
|
<div class="app-container">
|
29
31
|
<%= render "navigation" -%>
|
30
32
|
|
31
33
|
<main class="main-content" role="main">
|
32
|
-
<%= content_for(:search) %>
|
33
34
|
<%= render "flashes" -%>
|
34
35
|
<%= yield %>
|
35
36
|
</main>
|
@@ -28,5 +28,15 @@ class Admin::FoosController < Admin::ApplicationController
|
|
28
28
|
# def find_resource(param)
|
29
29
|
# Foo.find_by!(slug: param)
|
30
30
|
# end
|
31
|
+
#
|
32
|
+
# Override this if you have certain roles that require a subset
|
33
|
+
# this will be used to set the records shown on the `index` action.
|
34
|
+
# def scoped_resource
|
35
|
+
# if current_user.super_admin?
|
36
|
+
# resource_class
|
37
|
+
# else
|
38
|
+
# resource_class.with_less_stuff
|
39
|
+
# end
|
40
|
+
# end
|
31
41
|
end
|
32
42
|
```
|
@@ -12,7 +12,7 @@ call the generators with no arguments.
|
|
12
12
|
```bash
|
13
13
|
rails generate administrate:views:index
|
14
14
|
# -> app/views/admin/application/index.html.erb
|
15
|
-
# -> app/views/admin/application/
|
15
|
+
# -> app/views/admin/application/_collection.html.erb
|
16
16
|
|
17
17
|
rails generate administrate:views:show
|
18
18
|
# -> app/views/admin/application/show.html.erb
|
@@ -43,7 +43,7 @@ pass in the resource name to the view generators.
|
|
43
43
|
```bash
|
44
44
|
rails generate administrate:views:index User
|
45
45
|
# -> app/views/admin/users/index.html.erb
|
46
|
-
# -> app/views/admin/users/
|
46
|
+
# -> app/views/admin/users/_collection.html.erb
|
47
47
|
|
48
48
|
rails generate administrate:views:show User
|
49
49
|
# -> app/views/admin/users/show.html.erb
|
data/lib/administrate/engine.rb
CHANGED
@@ -2,7 +2,6 @@ require "datetime_picker_rails"
|
|
2
2
|
require "jquery-rails"
|
3
3
|
require "kaminari"
|
4
4
|
require "momentjs-rails"
|
5
|
-
require "normalize-rails"
|
6
5
|
require "sass-rails"
|
7
6
|
require "selectize-rails"
|
8
7
|
require "sprockets/railtie"
|
@@ -23,13 +22,6 @@ module Administrate
|
|
23
22
|
@@javascripts = []
|
24
23
|
@@stylesheets = []
|
25
24
|
|
26
|
-
Engine.config.assets.precompile << %w(
|
27
|
-
administrate/cancel.svg
|
28
|
-
administrate/dropdown.svg
|
29
|
-
administrate/search.svg
|
30
|
-
administrate/sort_arrow.svg
|
31
|
-
)
|
32
|
-
|
33
25
|
def self.add_javascript(script)
|
34
26
|
@@javascripts << script
|
35
27
|
end
|
@@ -20,6 +20,7 @@ module Administrate
|
|
20
20
|
@attribute = attribute
|
21
21
|
@data = data
|
22
22
|
@page = page
|
23
|
+
@resource = options.delete(:resource)
|
23
24
|
@options = options
|
24
25
|
end
|
25
26
|
|
@@ -39,7 +40,7 @@ module Administrate
|
|
39
40
|
"/fields/#{self.class.field_type}/#{page}"
|
40
41
|
end
|
41
42
|
|
42
|
-
attr_reader :attribute, :data, :page
|
43
|
+
attr_reader :attribute, :data, :page, :resource
|
43
44
|
|
44
45
|
protected
|
45
46
|
|
@@ -11,7 +11,8 @@ module Administrate
|
|
11
11
|
attr_reader :deferred_class, :options
|
12
12
|
|
13
13
|
def new(*args)
|
14
|
-
|
14
|
+
new_options = args.last.respond_to?(:merge) ? args.pop : {}
|
15
|
+
deferred_class.new(*args, options.merge(new_options))
|
15
16
|
end
|
16
17
|
|
17
18
|
def ==(other)
|
@@ -26,7 +26,9 @@ module Administrate
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def selected_options
|
29
|
-
|
29
|
+
return if data.empty?
|
30
|
+
|
31
|
+
data.map { |object| object.send(primary_key) }
|
30
32
|
end
|
31
33
|
|
32
34
|
def limit
|
@@ -46,6 +48,10 @@ module Administrate
|
|
46
48
|
data.count(:all) > limit
|
47
49
|
end
|
48
50
|
|
51
|
+
def data
|
52
|
+
@data ||= associated_class.none
|
53
|
+
end
|
54
|
+
|
49
55
|
private
|
50
56
|
|
51
57
|
def includes
|