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
@@ -3,9 +3,25 @@ require_relative "associative"
|
|
3
3
|
module Administrate
|
4
4
|
module Field
|
5
5
|
class HasOne < Associative
|
6
|
+
def initialize(attribute, data, page, options = {})
|
7
|
+
resolver = Administrate::ResourceResolver.new("admin/#{attribute}")
|
8
|
+
@nested_form = Administrate::Page::Form.new(
|
9
|
+
resolver.dashboard_class.new,
|
10
|
+
data || resolver.resource_class.new,
|
11
|
+
)
|
12
|
+
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
6
16
|
def self.permitted_attribute(attr)
|
7
|
-
|
17
|
+
related_dashboard_attributes =
|
18
|
+
Administrate::ResourceResolver.new("admin/#{attr}").
|
19
|
+
dashboard_class.new.permitted_attributes + [:id]
|
20
|
+
|
21
|
+
{ "#{attr}_attributes": related_dashboard_attributes }
|
8
22
|
end
|
23
|
+
|
24
|
+
attr_reader :nested_form
|
9
25
|
end
|
10
26
|
end
|
11
27
|
end
|
data/lib/administrate/order.rb
CHANGED
@@ -20,7 +20,7 @@ module Administrate
|
|
20
20
|
def attribute_field(dashboard, resource, attribute_name, page)
|
21
21
|
value = get_attribute_value(resource, attribute_name)
|
22
22
|
field = dashboard.attribute_type_for(attribute_name)
|
23
|
-
field.new(attribute_name, value, page)
|
23
|
+
field.new(attribute_name, value, page, resource: resource)
|
24
24
|
end
|
25
25
|
|
26
26
|
def get_attribute_value(resource, attribute_name)
|
data/lib/administrate/search.rb
CHANGED
@@ -3,34 +3,33 @@ require "active_support/core_ext/object/blank"
|
|
3
3
|
|
4
4
|
module Administrate
|
5
5
|
class Search
|
6
|
-
def initialize(
|
7
|
-
@
|
6
|
+
def initialize(scoped_resource, dashboard_class, term)
|
7
|
+
@dashboard_class = dashboard_class
|
8
|
+
@scoped_resource = scoped_resource
|
8
9
|
@term = term
|
9
10
|
end
|
10
11
|
|
11
12
|
def run
|
12
13
|
if @term.blank?
|
13
|
-
|
14
|
+
@scoped_resource.all
|
14
15
|
else
|
15
|
-
|
16
|
+
@scoped_resource.where(query, *search_terms)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
20
21
|
|
21
|
-
delegate :resource_class, to: :resolver
|
22
|
-
|
23
22
|
def query
|
24
23
|
search_attributes.map do |attr|
|
25
24
|
table_name = ActiveRecord::Base.connection.
|
26
|
-
quote_table_name(
|
25
|
+
quote_table_name(@scoped_resource.table_name)
|
27
26
|
attr_name = ActiveRecord::Base.connection.quote_column_name(attr)
|
28
27
|
"lower(#{table_name}.#{attr_name}) LIKE ?"
|
29
28
|
end.join(" OR ")
|
30
29
|
end
|
31
30
|
|
32
31
|
def search_terms
|
33
|
-
["%#{term.downcase}%"] * search_attributes.count
|
32
|
+
["%#{term.mb_chars.downcase}%"] * search_attributes.count
|
34
33
|
end
|
35
34
|
|
36
35
|
def search_attributes
|
@@ -40,7 +39,7 @@ module Administrate
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def attribute_types
|
43
|
-
|
42
|
+
@dashboard_class::ATTRIBUTE_TYPES
|
44
43
|
end
|
45
44
|
|
46
45
|
attr_reader :resolver, :term
|
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.8.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: 2017-
|
12
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
version: '4.2'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '5.
|
23
|
+
version: '5.2'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: '4.2'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '5.
|
33
|
+
version: '5.2'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: actionview
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version: '4.2'
|
41
41
|
- - "<"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '5.
|
43
|
+
version: '5.2'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
version: '4.2'
|
51
51
|
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '5.
|
53
|
+
version: '5.2'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: activerecord
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
version: '4.2'
|
61
61
|
- - "<"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '5.
|
63
|
+
version: '5.2'
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -70,19 +70,19 @@ dependencies:
|
|
70
70
|
version: '4.2'
|
71
71
|
- - "<"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '5.
|
73
|
+
version: '5.2'
|
74
74
|
- !ruby/object:Gem::Dependency
|
75
75
|
name: autoprefixer-rails
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - "
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '6.0'
|
81
81
|
type: :runtime
|
82
82
|
prerelease: false
|
83
83
|
version_requirements: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - "
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '6.0'
|
88
88
|
- !ruby/object:Gem::Dependency
|
@@ -141,20 +141,6 @@ dependencies:
|
|
141
141
|
- - "~>"
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '2.8'
|
144
|
-
- !ruby/object:Gem::Dependency
|
145
|
-
name: normalize-rails
|
146
|
-
requirement: !ruby/object:Gem::Requirement
|
147
|
-
requirements:
|
148
|
-
- - ">="
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: '3.0'
|
151
|
-
type: :runtime
|
152
|
-
prerelease: false
|
153
|
-
version_requirements: !ruby/object:Gem::Requirement
|
154
|
-
requirements:
|
155
|
-
- - ">="
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '3.0'
|
158
144
|
- !ruby/object:Gem::Dependency
|
159
145
|
name: sass-rails
|
160
146
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,12 +190,7 @@ extensions: []
|
|
204
190
|
extra_rdoc_files: []
|
205
191
|
files:
|
206
192
|
- Rakefile
|
207
|
-
- app/assets/images/administrate/cancel.svg
|
208
|
-
- app/assets/images/administrate/dropdown.svg
|
209
|
-
- app/assets/images/administrate/search.svg
|
210
|
-
- app/assets/images/administrate/sort_arrow.svg
|
211
193
|
- app/assets/javascripts/administrate/application.js
|
212
|
-
- app/assets/javascripts/administrate/components/_search.js
|
213
194
|
- app/assets/javascripts/administrate/components/date_time_picker.js
|
214
195
|
- app/assets/javascripts/administrate/components/has_many_form.js
|
215
196
|
- app/assets/javascripts/administrate/components/table.js
|
@@ -240,6 +221,7 @@ files:
|
|
240
221
|
- app/views/administrate/application/_collection.html.erb
|
241
222
|
- app/views/administrate/application/_flashes.html.erb
|
242
223
|
- app/views/administrate/application/_form.html.erb
|
224
|
+
- app/views/administrate/application/_icons.erb
|
243
225
|
- app/views/administrate/application/_javascript.html.erb
|
244
226
|
- app/views/administrate/application/_navigation.html.erb
|
245
227
|
- app/views/administrate/application/_search.html.erb
|
@@ -343,7 +325,6 @@ files:
|
|
343
325
|
- lib/administrate/version.rb
|
344
326
|
- lib/administrate/view_generator.rb
|
345
327
|
- lib/generators/administrate/assets/assets_generator.rb
|
346
|
-
- lib/generators/administrate/assets/images_generator.rb
|
347
328
|
- lib/generators/administrate/assets/javascripts_generator.rb
|
348
329
|
- lib/generators/administrate/assets/stylesheets_generator.rb
|
349
330
|
- lib/generators/administrate/dashboard/USAGE
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<svg id="cancel-search" width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
2
|
-
<title>cancel</title>
|
3
|
-
<g fill="#D8D8D8" fill-rule="evenodd">
|
4
|
-
<path 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"/>
|
5
|
-
</g>
|
6
|
-
</svg>
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<svg id="search" width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
2
|
-
<title>
|
3
|
-
search
|
4
|
-
</title>
|
5
|
-
<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" fill-rule="evenodd"/>
|
6
|
-
</svg>
|
@@ -1,4 +0,0 @@
|
|
1
|
-
<svg id="sort_arrow" width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
2
|
-
<title>sort_arrow</title>
|
3
|
-
<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" />
|
4
|
-
</svg>
|
@@ -1,43 +0,0 @@
|
|
1
|
-
$(function() {
|
2
|
-
"use strict";
|
3
|
-
|
4
|
-
var $input = $(".search__input");
|
5
|
-
var activeSuffix = "--active";
|
6
|
-
var timeout;
|
7
|
-
|
8
|
-
$.fn.textWidth = function(text, font) {
|
9
|
-
if (!$.fn.textWidth.fakeEl) {
|
10
|
-
$.fn.textWidth.fakeEl = $('<span style="display: none;">')
|
11
|
-
.appendTo(document.body);
|
12
|
-
}
|
13
|
-
|
14
|
-
var htmlText = text || this.val() || this.text();
|
15
|
-
htmlText = $.fn.textWidth.fakeEl.text(htmlText).html();
|
16
|
-
htmlText = htmlText.replace(/\s/g, " ");
|
17
|
-
$.fn.textWidth.fakeEl.html(htmlText).css("font", font || this.css("font"));
|
18
|
-
return $.fn.textWidth.fakeEl.width();
|
19
|
-
};
|
20
|
-
|
21
|
-
var activate = function(className) {
|
22
|
-
$("." + className).addClass(className + activeSuffix);
|
23
|
-
};
|
24
|
-
|
25
|
-
var deactivate = function(className) {
|
26
|
-
$("." + className).removeClass(className + activeSuffix);
|
27
|
-
};
|
28
|
-
|
29
|
-
$input.on("focus", function() { activate("search__icon"); });
|
30
|
-
$input.on("blur", function() { deactivate("search__icon"); });
|
31
|
-
$input.on("keydown", function() { deactivate("search__hint"); });
|
32
|
-
|
33
|
-
var showHint = function() { activate("search__hint"); };
|
34
|
-
|
35
|
-
$input.on("keyup", function() {
|
36
|
-
clearTimeout(timeout);
|
37
|
-
|
38
|
-
if($input.val().length) {
|
39
|
-
$(".search__hint").css("left", $input.textWidth() + 75);
|
40
|
-
timeout = setTimeout(showHint, 250);
|
41
|
-
}
|
42
|
-
});
|
43
|
-
});
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "rails/generators/base"
|
2
|
-
|
3
|
-
module Administrate
|
4
|
-
module Generators
|
5
|
-
module Assets
|
6
|
-
class ImagesGenerator < Rails::Generators::Base
|
7
|
-
IMAGES_PATH = "app/assets/images/administrate"
|
8
|
-
|
9
|
-
source_root File.expand_path("../../../../../", __FILE__)
|
10
|
-
|
11
|
-
def copy_images
|
12
|
-
directory IMAGES_PATH, IMAGES_PATH
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|