rails_admin 0.7.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails_admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +13 -2
- data/README.md +2 -2
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +53 -39
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +50 -32
- data/app/assets/javascripts/rails_admin/ra.i18n.coffee +5 -3
- data/app/assets/javascripts/rails_admin/ra.widgets.coffee +21 -6
- data/app/assets/javascripts/rails_admin/rails_admin.js +2 -3
- data/app/assets/stylesheets/rails_admin/base/theming.scss +6 -7
- data/app/assets/stylesheets/rails_admin/custom/mixins.scss +3 -4
- data/app/assets/stylesheets/rails_admin/custom/theming.scss +4 -4
- data/app/assets/stylesheets/rails_admin/custom/variables.scss +4 -4
- data/app/assets/stylesheets/rails_admin/rails_admin.scss.erb +3 -3
- data/app/assets/stylesheets/rails_admin/themes/default/mixins.scss +2 -2
- data/app/assets/stylesheets/rails_admin/themes/default/theming.scss +3 -3
- data/app/assets/stylesheets/rails_admin/themes/default/variables.scss +3 -3
- data/app/controllers/rails_admin/application_controller.rb +0 -2
- data/app/controllers/rails_admin/main_controller.rb +6 -5
- data/app/helpers/rails_admin/application_helper.rb +3 -3
- data/app/helpers/rails_admin/main_helper.rb +45 -0
- data/app/views/layouts/rails_admin/application.html.haml +2 -2
- data/app/views/layouts/rails_admin/pjax.html.haml +2 -2
- data/app/views/rails_admin/main/_form_datetime.html.haml +4 -1
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +1 -0
- data/app/views/rails_admin/main/_submit_buttons.html.haml +1 -1
- data/app/views/rails_admin/main/export.html.haml +13 -13
- data/app/views/rails_admin/main/index.html.haml +20 -64
- data/config/locales/rails_admin.en.yml +0 -1
- data/lib/generators/rails_admin/templates/initializer.erb +3 -0
- data/lib/rails_admin.rb +2 -1
- data/lib/rails_admin/abstract_model.rb +14 -16
- data/lib/rails_admin/adapters/active_record.rb +17 -8
- data/lib/rails_admin/adapters/active_record/association.rb +5 -0
- data/lib/rails_admin/adapters/mongoid.rb +7 -12
- data/lib/rails_admin/adapters/mongoid/association.rb +5 -0
- data/lib/rails_admin/config/actions/export.rb +1 -1
- data/lib/rails_admin/config/fields.rb +1 -0
- data/lib/rails_admin/config/fields/association.rb +5 -0
- data/lib/rails_admin/config/fields/base.rb +4 -0
- data/lib/rails_admin/config/fields/factories/paperclip.rb +1 -1
- data/lib/rails_admin/config/fields/factories/refile.rb +25 -0
- data/lib/rails_admin/config/fields/types/active_record_enum.rb +5 -5
- data/lib/rails_admin/config/fields/types/all.rb +1 -0
- data/lib/rails_admin/config/fields/types/bson_object_id.rb +16 -2
- data/lib/rails_admin/config/fields/types/date.rb +19 -8
- data/lib/rails_admin/config/fields/types/datetime.rb +33 -117
- data/lib/rails_admin/config/fields/types/json.rb +5 -2
- data/lib/rails_admin/config/fields/types/refile.rb +27 -0
- data/lib/rails_admin/config/fields/types/serialized.rb +5 -2
- data/lib/rails_admin/config/fields/types/time.rb +6 -18
- data/lib/rails_admin/config/has_fields.rb +2 -2
- data/lib/rails_admin/config/lazy_model.rb +2 -2
- data/lib/rails_admin/config/proxyable/proxy.rb +2 -4
- data/lib/rails_admin/extensions/pundit.rb +3 -0
- data/lib/rails_admin/extensions/pundit/authorization_adapter.rb +63 -0
- data/lib/rails_admin/support/datetime.rb +99 -0
- data/lib/rails_admin/support/hash_helper.rb +28 -0
- data/lib/rails_admin/support/i18n.rb +41 -0
- data/lib/rails_admin/version.rb +2 -2
- data/vendor/assets/javascripts/rails_admin/bootstrap-datetimepicker.js +2444 -0
- data/vendor/assets/javascripts/rails_admin/moment-with-locales.js +9977 -0
- data/vendor/assets/stylesheets/rails_admin/_bootstrap-datetimepicker.scss +343 -0
- data/vendor/assets/stylesheets/rails_admin/bootstrap-datetimepicker-build.scss +16 -0
- metadata +14 -9
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +0 -1437
- data/app/assets/javascripts/rails_admin/ra.datetimepicker.js +0 -83
- data/app/assets/stylesheets/rails_admin/jquery.ui.timepicker.scss +0 -68
- data/app/assets/stylesheets/rails_admin/ra.calendar-additions.scss +0 -45
- data/lib/rails_admin/i18n_support.rb +0 -39
- data/lib/rails_admin/support/core_extensions.rb +0 -30
@@ -4,9 +4,8 @@
|
|
4
4
|
//= require 'jquery-ui/effect'
|
5
5
|
//= require 'jquery-ui/sortable'
|
6
6
|
//= require 'jquery-ui/autocomplete'
|
7
|
-
//= require '
|
8
|
-
//= require 'rails_admin/
|
9
|
-
//= require 'rails_admin/ra.datetimepicker'
|
7
|
+
//= require 'rails_admin/moment-with-locales'
|
8
|
+
//= require 'rails_admin/bootstrap-datetimepicker'
|
10
9
|
//= require 'rails_admin/jquery.colorpicker'
|
11
10
|
//= require 'rails_admin/ra.filter-box'
|
12
11
|
//= require 'rails_admin/ra.filtering-multiselect'
|
@@ -8,7 +8,7 @@ $avatar-size: 30px;
|
|
8
8
|
body.rails_admin {
|
9
9
|
|
10
10
|
.thumbnail {
|
11
|
-
display:inline-block;
|
11
|
+
display: inline-block;
|
12
12
|
}
|
13
13
|
|
14
14
|
/* room for upper navbar */
|
@@ -58,6 +58,10 @@ body.rails_admin {
|
|
58
58
|
}
|
59
59
|
}
|
60
60
|
|
61
|
+
label.input-group-addon {
|
62
|
+
cursor: pointer;
|
63
|
+
}
|
64
|
+
|
61
65
|
/* fat labels in forms */
|
62
66
|
.label.form-label {
|
63
67
|
padding: 7px 7px 8px 7px;
|
@@ -127,11 +131,6 @@ body.rails_admin {
|
|
127
131
|
display:block;
|
128
132
|
}
|
129
133
|
|
130
|
-
/* Put form controls above siblings to make them accessible */
|
131
|
-
.controls {
|
132
|
-
z-index: 1;
|
133
|
-
}
|
134
|
-
|
135
134
|
/* nested forms */
|
136
135
|
.tab-content {
|
137
136
|
clear: both;
|
@@ -336,7 +335,7 @@ body.rails_admin {
|
|
336
335
|
position: fixed;
|
337
336
|
top: $navbar-height;
|
338
337
|
bottom: 0;
|
339
|
-
overflow-y:
|
338
|
+
overflow-y: auto;
|
340
339
|
}
|
341
340
|
}
|
342
341
|
}
|
@@ -1,12 +1,11 @@
|
|
1
1
|
/*
|
2
2
|
Customize Sass mixins from Twitter-Bootstrap/RailsAdmin theme or add new ones for your own use.
|
3
|
-
Copy this file to your app/assets/rails_admin/custom/mixins.
|
3
|
+
Copy this file to your app/assets/rails_admin/custom/mixins.scss, leave this one untouched
|
4
4
|
Don't require it in your application.rb
|
5
5
|
|
6
6
|
Available mixins to use/override:
|
7
7
|
|
8
|
-
https://github.com/
|
9
|
-
https://github.com/sferik/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/mixins.
|
8
|
+
https://github.com/twbs/bootstrap-sass/tree/master/assets/stylesheets/bootstrap/mixins
|
9
|
+
https://github.com/sferik/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/mixins.scss
|
10
10
|
Plus the ones from your theme.
|
11
11
|
*/
|
12
|
-
|
@@ -1,13 +1,13 @@
|
|
1
1
|
/*
|
2
2
|
Customize RailsAdmin theme here.
|
3
|
-
Copy this file to your app/assets/stylesheets/rails_admin/custom/theming.
|
3
|
+
Copy this file to your app/assets/stylesheets/rails_admin/custom/theming.scss, leave this one untouched
|
4
4
|
Don't require it in your application.rb
|
5
5
|
|
6
6
|
Look at the markup in RailsAdmin and go there to get inspiration from:
|
7
7
|
|
8
|
-
http://getbootstrap.com
|
8
|
+
http://getbootstrap.com
|
9
9
|
|
10
|
-
Test me: (actual color should be the one defined in variables.
|
10
|
+
Test me: (actual color should be the one defined in variables.scss if you did)
|
11
11
|
|
12
|
-
body{ background-color: $
|
12
|
+
body { background-color: $link-color; }
|
13
13
|
*/
|
@@ -1,15 +1,15 @@
|
|
1
1
|
/*
|
2
2
|
Customize Sass variables from Twitter-Bootstrap/RailsAdmin theme or add new ones for your own use.
|
3
|
-
Copy this file to your app/assets/rails_admin/custom/variables.
|
3
|
+
Copy this file to your app/assets/rails_admin/custom/variables.scss, leave this one untouched
|
4
4
|
Don't require it in your application.rb
|
5
5
|
|
6
6
|
Available variables to use/override:
|
7
7
|
|
8
|
-
https://github.com/
|
9
|
-
https://github.com/sferik/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/variables.
|
8
|
+
https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss
|
9
|
+
https://github.com/sferik/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/variables.scss
|
10
10
|
Plus the ones from your themes.
|
11
11
|
|
12
12
|
Test me: pink links
|
13
13
|
|
14
|
-
$
|
14
|
+
$link-color: #F0F;
|
15
15
|
*/
|
@@ -35,10 +35,10 @@
|
|
35
35
|
|
36
36
|
/*** Variables ***/
|
37
37
|
|
38
|
+
@import "rails_admin/custom/variables";
|
38
39
|
@import "rails_admin/bootstrap/variables";
|
39
40
|
@import "rails_admin/base/variables";
|
40
41
|
@import "rails_admin/themes/<%= theme %>/variables";
|
41
|
-
@import "rails_admin/custom/variables";
|
42
42
|
|
43
43
|
/*** Mixins ***/
|
44
44
|
|
@@ -52,12 +52,12 @@
|
|
52
52
|
/*** Libraries ***/
|
53
53
|
|
54
54
|
@import "rails_admin/aristo/jquery-ui-1.8.7.custom";
|
55
|
-
@import "rails_admin/
|
56
|
-
@import "rails_admin/ra.calendar-additions";
|
55
|
+
@import "rails_admin/bootstrap-datetimepicker-build";
|
57
56
|
@import "rails_admin/ra.filtering-multiselect";
|
58
57
|
@import "rails_admin/ra.widgets";
|
59
58
|
@import "rails_admin/jquery.colorpicker";
|
60
59
|
|
60
|
+
|
61
61
|
/*** Font-awesome ***/
|
62
62
|
|
63
63
|
@import 'font-awesome';
|
@@ -3,6 +3,6 @@
|
|
3
3
|
|
4
4
|
Available mixins to use/override:
|
5
5
|
|
6
|
-
https://github.com/
|
7
|
-
https://github.com/sferik/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/mixins.
|
6
|
+
https://github.com/twbs/bootstrap-sass/tree/master/assets/stylesheets/bootstrap/mixins
|
7
|
+
https://github.com/sferik/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/mixins.scss
|
8
8
|
*/
|
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
Look at the markup in RailsAdmin and go there to get inspiration from:
|
5
5
|
|
6
|
-
http://getbootstrap.com
|
6
|
+
http://getbootstrap.com
|
7
7
|
|
8
|
-
Test me: (actual color should be the one defined in variables.
|
8
|
+
Test me: (actual color should be the one defined in variables.scss if you did)
|
9
9
|
|
10
|
-
body{ background-color: $
|
10
|
+
body { background-color: $link-color; }
|
11
11
|
*/
|
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
Available variables to use/override:
|
5
5
|
|
6
|
-
https://github.com/
|
7
|
-
https://github.com/sferik/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/variables.
|
6
|
+
https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss
|
7
|
+
https://github.com/sferik/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/variables.scss
|
8
8
|
|
9
9
|
Test me: pink links
|
10
10
|
|
11
|
-
$
|
11
|
+
$link-color: #F0F;
|
12
12
|
*/
|
@@ -34,7 +34,6 @@ module RailsAdmin
|
|
34
34
|
scope = scope.merge(auth_scope)
|
35
35
|
end
|
36
36
|
scope = scope.instance_eval(&additional_scope) if additional_scope
|
37
|
-
|
38
37
|
get_collection(model_config, scope, pagination)
|
39
38
|
end
|
40
39
|
|
@@ -51,12 +50,10 @@ module RailsAdmin
|
|
51
50
|
def get_sort_hash(model_config)
|
52
51
|
abstract_model = model_config.abstract_model
|
53
52
|
params[:sort] = params[:sort_reverse] = nil unless model_config.list.fields.collect { |f| f.name.to_s }.include? params[:sort]
|
54
|
-
|
55
53
|
params[:sort] ||= model_config.list.sort_by.to_s
|
56
54
|
params[:sort_reverse] ||= 'false'
|
57
55
|
|
58
56
|
field = model_config.list.fields.detect { |f| f.name.to_s == params[:sort] }
|
59
|
-
|
60
57
|
column = begin
|
61
58
|
if field.nil? || field.sortable == true # use params[:sort] on the base table
|
62
59
|
"#{abstract_model.table_name}.#{params[:sort]}"
|
@@ -88,11 +85,15 @@ module RailsAdmin
|
|
88
85
|
end
|
89
86
|
end
|
90
87
|
|
88
|
+
def visible_fields(action, model_config = @model_config)
|
89
|
+
model_config.send(action).with(controller: self, view: view_context, object: @object).visible_fields
|
90
|
+
end
|
91
|
+
|
91
92
|
def sanitize_params_for!(action, model_config = @model_config, target_params = params[@abstract_model.param_key])
|
92
93
|
return unless target_params.present?
|
93
|
-
fields =
|
94
|
+
fields = visible_fields(action, model_config)
|
94
95
|
allowed_methods = fields.collect(&:allowed_methods).flatten.uniq.collect(&:to_s) << 'id' << '_destroy'
|
95
|
-
fields.each { |
|
96
|
+
fields.each { |field| field.parse_input(target_params) }
|
96
97
|
target_params.slice!(*allowed_methods)
|
97
98
|
target_params.permit! if target_params.respond_to?(:permit!)
|
98
99
|
fields.select(&:nested_form).each do |association|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'rails_admin/
|
1
|
+
require 'rails_admin/support/i18n'
|
2
2
|
|
3
3
|
module RailsAdmin
|
4
4
|
module ApplicationHelper
|
5
|
-
include RailsAdmin::
|
5
|
+
include RailsAdmin::Support::I18n
|
6
6
|
|
7
7
|
def capitalize_first_letter(wording)
|
8
8
|
return nil unless wording.present? && wording.is_a?(String)
|
@@ -156,7 +156,7 @@ module RailsAdmin
|
|
156
156
|
actions = actions(:bulkable, abstract_model)
|
157
157
|
return '' if actions.empty?
|
158
158
|
content_tag :li, class: 'dropdown', style: 'float:right' do
|
159
|
-
content_tag(:a, class: 'dropdown-toggle', data: {toggle: 'dropdown'}, href: '#') { t('admin.misc.bulk_menu_title').html_safe + '<b class="caret"></b>'.html_safe } +
|
159
|
+
content_tag(:a, class: 'dropdown-toggle', data: {toggle: 'dropdown'}, href: '#') { t('admin.misc.bulk_menu_title').html_safe + ' ' + '<b class="caret"></b>'.html_safe } +
|
160
160
|
content_tag(:ul, class: 'dropdown-menu', style: 'left:auto; right:0;') do
|
161
161
|
actions.collect do |action|
|
162
162
|
content_tag :li do
|
@@ -35,5 +35,50 @@ module RailsAdmin
|
|
35
35
|
end
|
36
36
|
sets
|
37
37
|
end
|
38
|
+
|
39
|
+
def filterable_fields
|
40
|
+
@filterable_fields ||= @model_config.list.fields.select(&:filterable?)
|
41
|
+
end
|
42
|
+
|
43
|
+
def ordered_filters
|
44
|
+
return @ordered_filters if @ordered_filters.present?
|
45
|
+
@index = 0
|
46
|
+
@ordered_filters = (params[:f] || @model_config.list.filters).inject({}) do |memo, filter|
|
47
|
+
field_name = filter.is_a?(Array) ? filter.first : filter
|
48
|
+
(filter.is_a?(Array) ? filter.last : {(@index += 1) => {'v' => ''}}).each do |index, filter_hash|
|
49
|
+
if filter_hash['disabled'].blank?
|
50
|
+
memo[index] = {field_name => filter_hash}
|
51
|
+
else
|
52
|
+
params[:f].delete(field_name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
memo
|
56
|
+
end.to_a.sort_by(&:first)
|
57
|
+
end
|
58
|
+
|
59
|
+
def ordered_filter_string
|
60
|
+
@ordered_filter_string ||= ordered_filters.map do |duplet|
|
61
|
+
options = {index: duplet[0]}
|
62
|
+
filter_for_field = duplet[1]
|
63
|
+
filter_name = filter_for_field.keys.first
|
64
|
+
filter_hash = filter_for_field.values.first
|
65
|
+
unless (field = filterable_fields.find { |f| f.name == filter_name.to_sym })
|
66
|
+
fail "#{filter_name} is not currently filterable; filterable fields are #{filterable_fields.map(&:name).join(', ')}"
|
67
|
+
end
|
68
|
+
case field.type
|
69
|
+
when :enum
|
70
|
+
options[:select_options] = options_for_select(field.with(object: @abstract_model.model.new).enum, filter_hash['v'])
|
71
|
+
when :date, :datetime, :time
|
72
|
+
options[:datetimepicker_format] = field.parser.to_momentjs
|
73
|
+
end
|
74
|
+
options[:label] = field.label
|
75
|
+
options[:name] = field.name
|
76
|
+
options[:type] = field.type
|
77
|
+
options[:value] = filter_hash['v']
|
78
|
+
options[:label] = field.label
|
79
|
+
options[:operator] = filter_hash['o']
|
80
|
+
%{$.filters.append(#{options.to_json});}
|
81
|
+
end.join("\n").html_safe if ordered_filters
|
82
|
+
end
|
38
83
|
end
|
39
84
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
!!! 5
|
2
|
-
%html
|
2
|
+
%html{lang: I18n.locale}
|
3
3
|
%head
|
4
4
|
%meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}
|
5
5
|
%meta{content: "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
|
@@ -9,7 +9,7 @@
|
|
9
9
|
= javascript_include_tag "rails_admin/rails_admin.js"
|
10
10
|
-# Initialize JS simple i18n
|
11
11
|
:javascript
|
12
|
-
RailsAdmin.I18n.init(JSON.parse("#{j I18n.t("admin.js").to_json}"))
|
12
|
+
RailsAdmin.I18n.init('#{I18n.locale}', JSON.parse("#{j I18n.t("admin.js").to_json}"))
|
13
13
|
%body.rails_admin
|
14
14
|
#loading.label.label-warning{style: 'display:none; position:fixed; right:20px; bottom:20px; z-index:100000'}= t('admin.loading')
|
15
15
|
%nav.navbar.navbar-default.navbar-fixed-top
|
@@ -6,8 +6,8 @@
|
|
6
6
|
.page-header
|
7
7
|
%h1= @page_name
|
8
8
|
- flash && flash.each do |key, value|
|
9
|
-
.alert{class: flash_alert_class(key)}
|
10
|
-
%
|
9
|
+
.alert.alert-dismissible{class: flash_alert_class(key)}
|
10
|
+
%button.close{type: 'button', :'data-dismiss' => "alert"} ×
|
11
11
|
= value
|
12
12
|
= breadcrumb
|
13
13
|
%ul.nav.nav-tabs
|
@@ -1,2 +1,5 @@
|
|
1
1
|
.form-inline
|
2
|
-
|
2
|
+
.input-group
|
3
|
+
= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({value: field.form_value, class: 'form-control', data: {datetimepicker: true, options: field.datepicker_options.to_json}})
|
4
|
+
= form.label(field.method_name, class: 'input-group-addon') do
|
5
|
+
%i.fa.fa-fw.fa-calendar
|
@@ -26,6 +26,7 @@
|
|
26
26
|
:'edit-url' => (authorized?(:edit, config.abstract_model) ? edit_path(model_name: config.abstract_model.to_param, id: '__ID__') : ''),
|
27
27
|
remote_source: index_path(config.abstract_model, source_object_id: form.object.id, source_abstract_model: source_abstract_model.to_param, associated_collection: field.name, current_action: current_action, compact: true),
|
28
28
|
sortable: !!field.orderable,
|
29
|
+
removable: !!field.removable,
|
29
30
|
cacheAll: !!field.associated_collection_cache_all,
|
30
31
|
regional: {
|
31
32
|
chooseAll: t("admin.misc.chose_all"),
|
@@ -11,6 +11,6 @@
|
|
11
11
|
- if authorized? :edit, @abstract_model
|
12
12
|
%button.btn.btn-info{type: "submit", name: "_add_edit", :'data-disable-with' => t("admin.form.save_and_edit")}
|
13
13
|
= t("admin.form.save_and_edit")
|
14
|
-
%button.btn{type: "submit", name: "_continue", :'data-disable-with' => t("admin.form.cancel"), :formnovalidate => true}
|
14
|
+
%button.btn.btn-default{type: "submit", name: "_continue", :'data-disable-with' => t("admin.form.cancel"), :formnovalidate => true}
|
15
15
|
%i.icon-remove
|
16
16
|
= t("admin.form.cancel")
|
@@ -8,38 +8,38 @@
|
|
8
8
|
%legend
|
9
9
|
%i.icon-chevron-down
|
10
10
|
= t('admin.export.select')
|
11
|
-
.form-group.control-group
|
11
|
+
.form-group.control-group.col-sm-12
|
12
12
|
.controls
|
13
|
-
.col-sm-
|
14
|
-
%label.col-sm-
|
13
|
+
.col-sm-12
|
14
|
+
%label.col-sm-12.checkbox{for: 'check_all'}
|
15
15
|
= check_box_tag 'all', 'all', true, { id: 'check_all' }
|
16
16
|
= t('admin.export.select_all_fields')
|
17
|
-
.form-group.control-group
|
18
|
-
%label.col-sm-
|
19
|
-
.col-sm-
|
17
|
+
.form-group.control-group.col-sm-12
|
18
|
+
%label.col-sm-12.well.control-label{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).siblings(".controls").find("input").click()'}= t('admin.export.fields_from', name: @model_config.label_plural.downcase)
|
19
|
+
.col-sm-11.col-sm-offset-1.controls
|
20
20
|
- visible_fields.select{ |f| !f.association? || f.association.polymorphic? }.each do |field|
|
21
21
|
- list = field.virtual? ? 'methods' : 'only'
|
22
22
|
- if field.association? && field.association.polymorphic?
|
23
|
-
%label.checkbox{for: "schema_#{list}_#{field.method_name}"}
|
23
|
+
%label.checkbox.col-sm-3{for: "schema_#{list}_#{field.method_name}"}
|
24
24
|
= check_box_tag "schema[#{list}][]", field.method_name, true, { id: "schema_#{list}_#{field.method_name}" }
|
25
25
|
= field.label + " [id]"
|
26
26
|
- polymorphic_type_column_name = @abstract_model.properties.detect {|p| field.association.foreign_type == p.name }.name
|
27
|
-
%label.checkbox{for: "schema_#{list}_#{polymorphic_type_column_name}"}
|
27
|
+
%label.checkbox.col-sm-3{for: "schema_#{list}_#{polymorphic_type_column_name}"}
|
28
28
|
= check_box_tag "schema[#{list}][]", polymorphic_type_column_name, true, { id: "schema_#{list}_#{polymorphic_type_column_name}" }
|
29
29
|
= capitalize_first_letter(field.label) + " [type]"
|
30
30
|
- else
|
31
|
-
%label.checkbox{for: "schema_#{list}_#{field.name}"}
|
31
|
+
%label.checkbox.col-sm-3{for: "schema_#{list}_#{field.name}"}
|
32
32
|
= check_box_tag "schema[#{list}][]", field.name, true, { id: "schema_#{list}_#{field.name}" }
|
33
33
|
= capitalize_first_letter(field.label)
|
34
34
|
|
35
35
|
- visible_fields.select{ |f| f.association? && !f.association.polymorphic? }.each do |field|
|
36
36
|
- fields = field.associated_model_config.export.with(controller: self.controller, view: self, object: (associated_model = field.associated_model_config.abstract_model.model).new).visible_fields.select{ |f| !f.association? }
|
37
|
-
.form-group.control-group
|
38
|
-
%label.col-sm-
|
39
|
-
.col-sm-
|
37
|
+
.form-group.control-group.col-sm-12
|
38
|
+
%label.col-sm-12.well.control-label{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).siblings(".controls").find("input").click()'}= t('admin.export.fields_from_associated', name: field.label.downcase)
|
39
|
+
.col-sm-11.col-sm-offset-1.controls
|
40
40
|
- fields.each do |associated_model_field|
|
41
41
|
- list = associated_model_field.virtual? ? 'methods' : 'only'
|
42
|
-
%label.checkbox{for: "schema_include_#{field.name}_#{list}_#{associated_model_field.name}"}
|
42
|
+
%label.checkbox.col-sm-3{for: "schema_include_#{field.name}_#{list}_#{associated_model_field.name}"}
|
43
43
|
= check_box_tag "schema[include][#{field.name}][#{list}][]", associated_model_field.name, true, { id: "schema_include_#{field.name}_#{list}_#{associated_model_field.name}" }
|
44
44
|
= capitalize_first_letter(associated_model_field.label)
|
45
45
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
:ruby
|
2
|
-
require 'rails_admin/config/fields/types/datetime.rb'
|
3
2
|
query = params[:query]
|
4
3
|
params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export, :_pjax)
|
5
4
|
params.delete(:query) if params[:query].blank?
|
@@ -7,95 +6,48 @@
|
|
7
6
|
sort_reverse = params[:sort_reverse]
|
8
7
|
sort = params[:sort]
|
9
8
|
params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s
|
10
|
-
|
11
9
|
export_action = RailsAdmin::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model })
|
12
10
|
export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model)
|
13
|
-
|
14
11
|
description = RailsAdmin.config(@abstract_model.model_name).description
|
15
12
|
properties = @model_config.list.with(controller: self.controller, view: self, object: @abstract_model.model.new).visible_fields
|
16
13
|
# columns paginate
|
17
|
-
@filterable_fields = @model_config.list.fields.select(&:filterable?)
|
18
14
|
sets = get_column_sets(properties)
|
19
15
|
properties = sets[params[:set].to_i] || []
|
20
16
|
other_left = ((params[:set].to_i - 1) >= 0) && sets[params[:set].to_i - 1].present?
|
21
17
|
other_right = sets[params[:set].to_i + 1].present?
|
22
|
-
@index = 0
|
23
|
-
@ordered_filters = (params[:f] || @model_config.list.filters).inject({}) { |memo, filter|
|
24
|
-
field_name = filter.is_a?(Array) ? filter.first : filter
|
25
|
-
(filter.is_a?(Array) ? filter.last : { (@index += 1) => { "v" => '' } }) .each do |index, filter_hash|
|
26
|
-
unless filter_hash['disabled']
|
27
|
-
memo[index] = { field_name => filter_hash }
|
28
|
-
else
|
29
|
-
params[:f].delete(field_name)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
memo
|
33
|
-
}.to_a.sort_by(&:first)
|
34
|
-
|
35
|
-
@ordered_filter_string = @ordered_filters.map do |duplet|
|
36
|
-
filter_index = duplet[0]
|
37
|
-
filter_for_field = duplet[1]
|
38
|
-
filter_name = filter_for_field.keys.first
|
39
|
-
filter_hash = filter_for_field.values.first
|
40
|
-
field = @filterable_fields.find{ |field| field.name == filter_name.to_sym }
|
41
|
-
unless field
|
42
|
-
fail "#{filter_name} is not currently filterable; filterable fields are #{@filterable_fields.map(&:name).join(', ')}"
|
43
|
-
end
|
44
|
-
field_options = case field.type
|
45
|
-
when :enum
|
46
|
-
options_for_select(field.with(object: @abstract_model.model.new).enum, filter_hash['v'])
|
47
|
-
else
|
48
|
-
''
|
49
|
-
end
|
50
|
-
%{
|
51
|
-
$.filters.append(#{field.label.to_json}, #{field.name.to_json}, #{field.type.to_json}, #{filter_hash['v'].to_json}, #{filter_hash['o'].to_json}, #{field_options.to_json}, #{filter_index.to_json});
|
52
|
-
}
|
53
|
-
end.join.html_safe if @ordered_filters
|
54
18
|
|
55
|
-
|
56
|
-
= content_for :contextual_tabs do
|
19
|
+
- content_for :contextual_tabs do
|
57
20
|
= bulk_menu
|
58
|
-
- if
|
21
|
+
- if filterable_fields.present?
|
59
22
|
%li.dropdown{style: 'float:right'}
|
60
23
|
%a.dropdown-toggle{href: '#', :'data-toggle' => "dropdown"}
|
61
24
|
= t('admin.misc.add_filter')
|
62
25
|
%b.caret
|
63
26
|
%ul.dropdown-menu#filters{style: 'left:auto; right:0;'}
|
64
|
-
-
|
27
|
+
- filterable_fields.each do |field|
|
65
28
|
- field_options = case field.type
|
66
29
|
- when :enum
|
67
30
|
- options_for_select(field.with(object: @abstract_model.model.new).enum)
|
68
31
|
- else
|
69
32
|
- ''
|
70
33
|
%li
|
71
|
-
%a{href: '#', :"data-field-label" => field.label, :"data-field-name" => field.name, :"data-field-options" => field_options.html_safe, :"data-field-type" => field.type, :"data-field-value" => ""}= capitalize_first_letter(field.label)
|
34
|
+
%a{href: '#', :"data-field-label" => field.label, :"data-field-name" => field.name, :"data-field-options" => field_options.html_safe, :"data-field-type" => field.type, :"data-field-value" => "", :"data-field-datetimepicker-format" => (field.try(:parser) && field.parser.to_momentjs)}= capitalize_first_letter(field.label)
|
72
35
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
datePicker: {
|
78
|
-
dateFormat: #{raw I18n.t("admin.misc.filter_date_format", default: I18n.t("admin.misc.filter_date_format", locale: :en)).to_json},
|
79
|
-
dayNames: #{raw RailsAdmin::Config::Fields::Types::Datetime.day_names.to_json},
|
80
|
-
dayNamesShort: #{raw RailsAdmin::Config::Fields::Types::Datetime.abbr_day_names.to_json},
|
81
|
-
dayNamesMin: #{raw RailsAdmin::Config::Fields::Types::Datetime.abbr_day_names.to_json},
|
82
|
-
firstDay: "1",
|
83
|
-
monthNames: #{raw RailsAdmin::Config::Fields::Types::Datetime.month_names.to_json},
|
84
|
-
monthNamesShort: #{raw RailsAdmin::Config::Fields::Types::Datetime.abbr_month_names.to_json}
|
85
|
-
}
|
86
|
-
}
|
36
|
+
:javascript
|
37
|
+
jQuery(function($) {
|
38
|
+
#{ordered_filter_string}
|
39
|
+
});
|
87
40
|
|
88
|
-
|
41
|
+
%style
|
42
|
+
- properties.select{ |p| p.column_width.present? }.each do |property|
|
43
|
+
= "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }"
|
44
|
+
= "#list td.#{property.css_class} { max-width: #{property.column_width}px; }"
|
89
45
|
|
90
|
-
|
91
|
-
%style
|
92
|
-
- properties.select{ |p| p.column_width.present? }.each do |property|
|
93
|
-
= "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }"
|
94
|
-
= "#list td.#{property.css_class} { max-width: #{property.column_width}px; }"
|
46
|
+
#list
|
95
47
|
= form_tag(index_path(params.except(*%w[page f query])), method: :get, class: "pjax-form form-inline") do
|
96
48
|
.well
|
97
49
|
%span#filters_box
|
98
|
-
%hr.filters_box{style: "display:#{
|
50
|
+
%hr.filters_box{style: "display:#{ordered_filters.empty? ? 'none' : 'block'}"}
|
99
51
|
.input-group
|
100
52
|
%input.form-control.input-small{name: "query", type: "search", value: query, placeholder: t("admin.misc.filter")}
|
101
53
|
%span.input-group-btn
|
@@ -103,7 +55,7 @@
|
|
103
55
|
%i.icon-white.icon-refresh
|
104
56
|
= t("admin.misc.refresh")
|
105
57
|
%button#remove_filter.btn.btn-info{title: "Reset filters"}
|
106
|
-
%i.icon-white.icon-remove
|
58
|
+
%i.icon-white.icon-remove
|
107
59
|
- if export_action
|
108
60
|
%span{style: 'float:right'}= link_to wording_for(:link, export_action), export_path(params.except('set').except('page')), class: 'btn btn-info'
|
109
61
|
|
@@ -117,7 +69,9 @@
|
|
117
69
|
= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: "form" do
|
118
70
|
= hidden_field_tag :bulk_action
|
119
71
|
- if description.present?
|
120
|
-
|
72
|
+
%p
|
73
|
+
%strong= description
|
74
|
+
|
121
75
|
%table.table.table-condensed.table-striped
|
122
76
|
%thead
|
123
77
|
%tr
|
@@ -148,6 +102,7 @@
|
|
148
102
|
%td.other.right= link_to "...", @other_right_link, class: 'pjax'
|
149
103
|
%td.last.links
|
150
104
|
%ul.inline.list-inline= menu_for :member, @abstract_model, object, true
|
105
|
+
|
151
106
|
- if @objects.respond_to?(:total_count)
|
152
107
|
- total_count = @objects.total_count.to_i
|
153
108
|
.row
|
@@ -155,5 +110,6 @@
|
|
155
110
|
.row
|
156
111
|
.col-md-6= link_to(t("admin.misc.show_all"), index_path(params.merge(all: true)), class: "show-all btn btn-default clearfix pjax") unless total_count > 100 || total_count <= @objects.to_a.size
|
157
112
|
.clearfix.total-count= "#{total_count} #{@model_config.pluralize(total_count).downcase}"
|
113
|
+
|
158
114
|
- else
|
159
115
|
.clearfix.total-count= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}"
|