rails_admin 0.6.8 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rails_admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +17 -37
- data/README.md +1 -1
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +20 -5
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +13 -10
- data/app/assets/javascripts/rails_admin/ra.i18n.coffee +1 -1
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +2 -2
- data/app/assets/javascripts/rails_admin/ra.widgets.coffee +1 -1
- data/app/assets/javascripts/rails_admin/ui.coffee +8 -0
- data/app/assets/stylesheets/rails_admin/base/theming.scss +37 -7
- data/app/assets/stylesheets/rails_admin/ra.widgets.scss +3 -2
- data/app/assets/stylesheets/rails_admin/themes/cerulean/theming.scss +95 -59
- data/app/assets/stylesheets/rails_admin/themes/cerulean/variables.scss +809 -120
- data/app/helpers/rails_admin/application_helper.rb +7 -2
- data/app/helpers/rails_admin/main_helper.rb +4 -2
- data/app/views/layouts/rails_admin/_navigation.html.haml +6 -1
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +1 -3
- data/app/views/rails_admin/main/_form_file_upload.html.haml +6 -2
- data/app/views/rails_admin/main/index.html.haml +2 -0
- data/config/locales/rails_admin.en.yml +3 -0
- data/lib/rails_admin/config.rb +4 -0
- data/lib/rails_admin/config/fields/association.rb +1 -1
- data/lib/rails_admin/config/fields/base.rb +3 -1
- data/lib/rails_admin/config/fields/factories/enum.rb +4 -0
- data/lib/rails_admin/config/fields/types/active_record_enum.rb +41 -0
- data/lib/rails_admin/config/fields/types/all.rb +1 -0
- data/lib/rails_admin/config/fields/types/file_upload.rb +8 -1
- data/lib/rails_admin/config/fields/types/serialized.rb +1 -1
- data/lib/rails_admin/config/fields/types/string.rb +6 -1
- data/lib/rails_admin/config/fields/types/text.rb +1 -0
- data/lib/rails_admin/engine.rb +1 -4
- data/lib/rails_admin/version.rb +2 -2
- metadata +4 -3
@@ -35,7 +35,12 @@ module RailsAdmin
|
|
35
35
|
return nil unless _current_user.respond_to?(:email)
|
36
36
|
return nil unless abstract_model = RailsAdmin.config(_current_user.class).abstract_model
|
37
37
|
return nil unless (edit_action = RailsAdmin::Config::Actions.find(:edit, controller: controller, abstract_model: abstract_model, object: _current_user)).try(:authorized?)
|
38
|
-
link_to
|
38
|
+
link_to url_for(action: edit_action.action_name, model_name: abstract_model.to_param, id: _current_user.id, controller: 'rails_admin/main') do
|
39
|
+
html = []
|
40
|
+
html << image_tag("#{(request.ssl? ? 'https://secure' : 'http://www')}.gravatar.com/avatar/#{Digest::MD5.hexdigest _current_user.email}?s=30", alt: '') if _current_user.email.present?
|
41
|
+
html << content_tag(:span, _current_user.email)
|
42
|
+
html.join.html_safe
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
def logout_path
|
@@ -85,7 +90,7 @@ module RailsAdmin
|
|
85
90
|
end.join
|
86
91
|
|
87
92
|
label = RailsAdmin::Config.navigation_static_label || t('admin.misc.navigation_static_label')
|
88
|
-
li_stack = %(<li class='
|
93
|
+
li_stack = %(<li class='dropdown-header'>#{label}</li>#{li_stack}).html_safe if li_stack.present?
|
89
94
|
li_stack
|
90
95
|
end
|
91
96
|
|
@@ -4,15 +4,17 @@ module RailsAdmin
|
|
4
4
|
module MainHelper
|
5
5
|
def rails_admin_form_for(*args, &block)
|
6
6
|
options = args.extract_options!.reverse_merge(builder: RailsAdmin::FormBuilder)
|
7
|
+
(options[:html] ||= {})[:novalidate] ||= !RailsAdmin::Config.browser_validations
|
8
|
+
|
7
9
|
form_for(*(args << options), &block) << after_nested_form_callbacks
|
8
10
|
end
|
9
11
|
|
10
12
|
def get_indicator(percent)
|
11
13
|
return '' if percent < 0 # none
|
12
|
-
return 'info' if percent < 34
|
14
|
+
return 'info' if percent < 34 # < 1/100 of max
|
13
15
|
return 'success' if percent < 67 # < 1/10 of max
|
14
16
|
return 'warning' if percent < 84 # < 1/3 of max
|
15
|
-
'danger'
|
17
|
+
'danger' # > 1/3 of max
|
16
18
|
end
|
17
19
|
|
18
20
|
def get_column_sets(properties)
|
@@ -1,7 +1,12 @@
|
|
1
1
|
.container-fluid
|
2
2
|
.navbar-header
|
3
|
+
%button.navbar-toggle.collapsed{ type: 'button', data: { toggle: 'collapse', target: '#secondary-navigation' } }
|
4
|
+
%span.sr-only= t('admin.toggle_navigation')
|
5
|
+
%span.icon-bar
|
6
|
+
%span.icon-bar
|
7
|
+
%span.icon-bar
|
3
8
|
%a.navbar-brand.pjax{href: dashboard_path}
|
4
9
|
= _get_plugin_name[0] || 'Rails'
|
5
10
|
%small= _get_plugin_name[1] || 'Admin'
|
6
|
-
.collapse.navbar-collapse
|
11
|
+
.collapse.navbar-collapse#secondary-navigation
|
7
12
|
= render partial: 'layouts/rails_admin/secondary_navigation'
|
@@ -5,8 +5,6 @@
|
|
5
5
|
%li= link_to t('admin.home.name'), main_app_root_path
|
6
6
|
- if _current_user
|
7
7
|
- if user_link = edit_user_link
|
8
|
-
%li= user_link
|
8
|
+
%li.edit_user_root_link= user_link
|
9
9
|
- if logout_path.present?
|
10
10
|
%li= link_to content_tag('span', t('admin.misc.log_out'), class: 'label label-danger'), logout_path, method: logout_method
|
11
|
-
- if _current_user.respond_to?(:email) && _current_user.email.present?
|
12
|
-
%li= image_tag "#{(request.ssl? ? 'https://secure' : 'http://www')}.gravatar.com/avatar/#{Digest::MD5.hexdigest _current_user.email}?s=30", style: 'padding-top:5px'
|
@@ -3,11 +3,15 @@
|
|
3
3
|
.toggle{style: ('display:none;' if file && field.delete_method && form.object.send(field.delete_method) == '1')}
|
4
4
|
- if value = field.pretty_value
|
5
5
|
= value
|
6
|
+
|
6
7
|
= form.file_field(field.name, field.html_attributes.reverse_merge({ data: { fileupload: true }}))
|
8
|
+
|
7
9
|
- if field.optional? && field.errors.blank? && file && field.delete_method
|
8
|
-
%a.btn.btn-info{href: '#', :'data-toggle' => 'button', onclick: "$(this).siblings('[type=checkbox]').click(); $(this).siblings('.toggle').toggle('slow'); jQuery(this).toggleClass('btn-danger btn-info'); return false"}
|
10
|
+
%a.btn.btn-info.btn-remove-image{href: '#', :'data-toggle' => 'button', role: 'button', onclick: "$(this).siblings('[type=checkbox]').click(); $(this).siblings('.toggle').toggle('slow'); jQuery(this).toggleClass('btn-danger btn-info'); return false;"}
|
9
11
|
%i.icon-white.icon-trash
|
10
12
|
= I18n.t('admin.actions.delete.menu').capitalize + " #{field.label.downcase}"
|
11
|
-
|
13
|
+
|
14
|
+
= form.check_box(field.delete_method, style: 'display:none;')
|
15
|
+
|
12
16
|
- if field.cache_method
|
13
17
|
= form.hidden_field(field.cache_method)
|
@@ -102,6 +102,8 @@
|
|
102
102
|
%button.btn.btn-primary{type: "submit", :'data-disable-with' => "<i class='icon-white icon-refresh'></i> ".html_safe + t("admin.misc.refresh")}
|
103
103
|
%i.icon-white.icon-refresh
|
104
104
|
= t("admin.misc.refresh")
|
105
|
+
%button#remove_filter.btn.btn-info{title: "Reset filters"}
|
106
|
+
%i.icon-white.icon-remove
|
105
107
|
- if export_action
|
106
108
|
%span{style: 'float:right'}= link_to wording_for(:link, export_action), export_path(params.except('set').except('page')), class: 'btn btn-info'
|
107
109
|
|
@@ -16,7 +16,10 @@ en:
|
|
16
16
|
is_exactly: Is exactly
|
17
17
|
starts_with: Starts with
|
18
18
|
ends_with: Ends with
|
19
|
+
too_many_objects: "Too many objects, use search box above"
|
20
|
+
no_objects: "No objects found"
|
19
21
|
loading: "Loading..."
|
22
|
+
toggle_navigation: Toggle navigation
|
20
23
|
home:
|
21
24
|
name: "Home"
|
22
25
|
pagination:
|
data/lib/rails_admin/config.rb
CHANGED
@@ -50,6 +50,9 @@ module RailsAdmin
|
|
50
50
|
# hide blank fields in show view if true
|
51
51
|
attr_accessor :compact_show_view
|
52
52
|
|
53
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
54
|
+
attr_accessor :browser_validations
|
55
|
+
|
53
56
|
# Set the max width of columns in list view before a new set is created
|
54
57
|
attr_accessor :total_columns_width
|
55
58
|
|
@@ -254,6 +257,7 @@ module RailsAdmin
|
|
254
257
|
# @see RailsAdmin::Config.registry
|
255
258
|
def reset
|
256
259
|
@compact_show_view = true
|
260
|
+
@browser_validations = true
|
257
261
|
@yell_for_non_accessible_fields = true
|
258
262
|
@authenticate = nil
|
259
263
|
@authorize = nil
|
@@ -21,7 +21,7 @@ module RailsAdmin
|
|
21
21
|
am = amc.abstract_model
|
22
22
|
wording = associated.send(amc.object_label_method)
|
23
23
|
can_see = !am.embedded? && (show_action = v.action(:show, am, associated))
|
24
|
-
can_see ? v.link_to(wording, v.url_for(action: show_action.action_name, model_name: am.to_param, id: associated.id), class: 'pjax') : wording
|
24
|
+
can_see ? v.link_to(wording, v.url_for(action: show_action.action_name, model_name: am.to_param, id: associated.id), class: 'pjax') : ERB::Util.html_escape(wording)
|
25
25
|
end.to_sentence.html_safe
|
26
26
|
end
|
27
27
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rails_admin/config/fields'
|
2
2
|
require 'rails_admin/config/fields/types/enum'
|
3
|
+
require 'rails_admin/config/fields/types/active_record_enum'
|
3
4
|
|
4
5
|
RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
5
6
|
model = parent.abstract_model.model
|
@@ -11,6 +12,9 @@ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
|
11
12
|
model.method_defined?(method_name))
|
12
13
|
fields << RailsAdmin::Config::Fields::Types::Enum.new(parent, properties.name, properties)
|
13
14
|
true
|
15
|
+
elsif model.respond_to?(:defined_enums) && model.defined_enums[properties.name.to_s]
|
16
|
+
fields << RailsAdmin::Config::Fields::Types::ActiveRecordEnum.new(parent, properties.name, properties)
|
17
|
+
true
|
14
18
|
else
|
15
19
|
false
|
16
20
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rails_admin/config/fields/types/enum'
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module Config
|
5
|
+
module Fields
|
6
|
+
module Types
|
7
|
+
class ActiveRecordEnum < Enum
|
8
|
+
RailsAdmin::Config::Fields::Types.register(self)
|
9
|
+
|
10
|
+
def type
|
11
|
+
:enum
|
12
|
+
end
|
13
|
+
|
14
|
+
register_instance_option :enum do
|
15
|
+
abstract_model.model.defined_enums[name.to_s]
|
16
|
+
end
|
17
|
+
|
18
|
+
register_instance_option :pretty_value do
|
19
|
+
bindings[:object].send(name).presence || ' - '
|
20
|
+
end
|
21
|
+
|
22
|
+
register_instance_option :multiple? do
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
register_instance_option :queryable do
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_input(params)
|
31
|
+
if params[name].present?
|
32
|
+
params[name] = enum.invert[params[name].to_i]
|
33
|
+
elsif params[name]
|
34
|
+
params[name] = nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -33,7 +33,8 @@ module RailsAdmin
|
|
33
33
|
url = resource_url
|
34
34
|
if image
|
35
35
|
thumb_url = resource_url(thumb_method)
|
36
|
-
|
36
|
+
image_html = v.image_tag(thumb_url, class: 'img-thumbnail')
|
37
|
+
url != thumb_url ? v.link_to(image_html, url, target: '_blank') : image_html
|
37
38
|
else
|
38
39
|
v.link_to(nil, url, target: '_blank')
|
39
40
|
end
|
@@ -48,6 +49,12 @@ module RailsAdmin
|
|
48
49
|
[method_name, delete_method, cache_method].compact
|
49
50
|
end
|
50
51
|
|
52
|
+
register_instance_option :html_attributes do
|
53
|
+
{
|
54
|
+
required: required? && !value.present?,
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
51
58
|
# virtual class
|
52
59
|
def resource_url
|
53
60
|
fail('not implemented')
|
@@ -14,7 +14,7 @@ module RailsAdmin
|
|
14
14
|
|
15
15
|
def parse_input(params)
|
16
16
|
return unless params[name].is_a?(::String)
|
17
|
-
params[name] = (params[name].blank? ? nil : (
|
17
|
+
params[name] = (params[name].blank? ? nil : (SafeYAML.load(params[name]) || nil))
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -7,10 +7,15 @@ module RailsAdmin
|
|
7
7
|
class String < RailsAdmin::Config::Fields::Base
|
8
8
|
RailsAdmin::Config::Fields::Types.register(self)
|
9
9
|
|
10
|
+
def input_size
|
11
|
+
[50, length.to_i].reject(&:zero?).min
|
12
|
+
end
|
13
|
+
|
10
14
|
register_instance_option :html_attributes do
|
11
15
|
{
|
16
|
+
required: required?,
|
12
17
|
maxlength: length,
|
13
|
-
size:
|
18
|
+
size: input_size,
|
14
19
|
}
|
15
20
|
end
|
16
21
|
|
data/lib/rails_admin/engine.rb
CHANGED
@@ -7,10 +7,7 @@ require 'rack-pjax'
|
|
7
7
|
require 'rails'
|
8
8
|
require 'rails_admin'
|
9
9
|
require 'remotipart'
|
10
|
-
require 'safe_yaml'
|
11
|
-
|
12
|
-
SafeYAML::OPTIONS[:suppress_warnings] = true
|
13
|
-
SafeYAML::OPTIONS[:default_mode] = :unsafe
|
10
|
+
require 'safe_yaml/load'
|
14
11
|
|
15
12
|
module RailsAdmin
|
16
13
|
class Engine < Rails::Engine
|
data/lib/rails_admin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Michaels-Ober
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-
|
15
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: builder
|
@@ -505,6 +505,7 @@ files:
|
|
505
505
|
- lib/rails_admin/config/fields/factories/password.rb
|
506
506
|
- lib/rails_admin/config/fields/group.rb
|
507
507
|
- lib/rails_admin/config/fields/types.rb
|
508
|
+
- lib/rails_admin/config/fields/types/active_record_enum.rb
|
508
509
|
- lib/rails_admin/config/fields/types/all.rb
|
509
510
|
- lib/rails_admin/config/fields/types/belongs_to_association.rb
|
510
511
|
- lib/rails_admin/config/fields/types/boolean.rb
|
@@ -593,7 +594,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
593
594
|
version: 1.8.11
|
594
595
|
requirements: []
|
595
596
|
rubyforge_project:
|
596
|
-
rubygems_version: 2.4.
|
597
|
+
rubygems_version: 2.4.3
|
597
598
|
signing_key:
|
598
599
|
specification_version: 4
|
599
600
|
summary: Admin for Rails
|