rails_admin 2.0.0.beta → 2.0.0.rc
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 +1 -1
- data/README.md +1 -1
- data/app/assets/javascripts/rails_admin/custom/ui.js +1 -0
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +1 -1
- data/app/assets/javascripts/rails_admin/ra.i18n.js +28 -0
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.js +57 -0
- data/app/assets/javascripts/rails_admin/ra.sidescroll.js +31 -0
- data/app/assets/javascripts/rails_admin/ra.widgets.js +371 -0
- data/app/assets/javascripts/rails_admin/ui.js +135 -0
- data/app/assets/stylesheets/rails_admin/ra.widgets.scss +4 -0
- data/app/helpers/rails_admin/application_helper.rb +17 -2
- data/app/views/layouts/rails_admin/_head.html.haml +7 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +1 -1
- data/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +2 -1
- data/app/views/layouts/rails_admin/application.html.haml +3 -8
- data/app/views/rails_admin/main/_form_file_upload.html.haml +3 -3
- data/app/views/rails_admin/main/_form_multiple_file_upload.html.haml +6 -4
- data/config/locales/rails_admin.en.yml +1 -0
- data/lib/generators/rails_admin/templates/initializer.erb +2 -2
- data/lib/rails_admin.rb +0 -1
- data/lib/rails_admin/abstract_model.rb +1 -1
- data/lib/rails_admin/adapters/active_record.rb +12 -3
- data/lib/rails_admin/adapters/mongoid.rb +14 -0
- data/lib/rails_admin/bootstrap-sass.rb +1 -1
- data/lib/rails_admin/config.rb +4 -6
- data/lib/rails_admin/config/actions/base.rb +17 -1
- data/lib/rails_admin/config/actions/edit.rb +1 -3
- data/lib/rails_admin/config/actions/index.rb +1 -1
- data/lib/rails_admin/config/actions/new.rb +1 -3
- data/lib/rails_admin/config/fields.rb +0 -1
- data/lib/rails_admin/config/fields/association.rb +1 -1
- data/lib/rails_admin/config/fields/types/action_text.rb +1 -2
- data/lib/rails_admin/config/fields/types/all.rb +0 -1
- data/lib/rails_admin/config/fields/types/ck_editor.rb +2 -2
- data/lib/rails_admin/config/fields/types/code_mirror.rb +2 -2
- data/lib/rails_admin/config/fields/types/color.rb +2 -2
- data/lib/rails_admin/config/fields/types/file_upload.rb +6 -2
- data/lib/rails_admin/config/fields/types/froala.rb +2 -2
- data/lib/rails_admin/config/fields/types/hidden.rb +2 -2
- data/lib/rails_admin/config/fields/types/multiple_active_storage.rb +1 -1
- data/lib/rails_admin/config/fields/types/multiple_carrierwave.rb +15 -3
- data/lib/rails_admin/config/fields/types/multiple_file_upload.rb +17 -3
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +7 -0
- data/lib/rails_admin/config/fields/types/shrine.rb +5 -1
- data/lib/rails_admin/config/fields/types/simple_mde.rb +2 -2
- data/lib/rails_admin/config/fields/types/string.rb +2 -2
- data/lib/rails_admin/config/fields/types/string_like.rb +19 -0
- data/lib/rails_admin/config/fields/types/text.rb +2 -2
- data/lib/rails_admin/config/fields/types/wysihtml5.rb +2 -2
- data/lib/rails_admin/extensions/cancancan/authorization_adapter.rb +45 -21
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +4 -1
- data/lib/rails_admin/version.rb +1 -1
- data/{app → vendor}/assets/images/rails_admin/bootstrap/glyphicons-halflings-white.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/bootstrap/glyphicons-halflings.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/select.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/select2.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/slider.png +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-affix.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-carousel.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-collapse.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-dropdown.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-modal.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-popover.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-scrollspy.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-tab.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-tooltip.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-transition.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-typeahead.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/jquery.colorpicker.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/jquery.pjax.js +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_alerts.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_badges.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_breadcrumbs.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_button-groups.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_buttons.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_carousel.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_close.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_code.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_component-animations.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_dropdowns.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_forms.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_glyphicons.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_grid.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_input-groups.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_jumbotron.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_labels.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_list-group.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_media.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_mixins.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_modals.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_navbar.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_navs.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_normalize.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_pager.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_pagination.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_panels.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_popovers.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_print.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_progress-bars.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_responsive-embed.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_responsive-utilities.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_scaffolding.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_tables.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_theme.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_thumbnails.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_tooltip.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_type.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_utilities.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_variables.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_wells.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/bootstrap.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_alerts.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_background-variant.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_border-radius.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_buttons.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_center-block.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_clearfix.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_forms.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_gradients.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_grid-framework.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_grid.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_hide-text.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_image.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_labels.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_list-group.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-divider.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-vertical-align.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_opacity.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_pagination.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_panels.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_progress-bar.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_reset-filter.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_resize.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_responsive-visibility.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_size.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_tab-focus.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_table-row.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_text-emphasis.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_text-overflow.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_vendor-prefixes.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/jquery.colorpicker.scss +0 -0
- metadata +130 -153
- data/app/assets/javascripts/rails_admin/custom/ui.coffee +0 -1
- data/app/assets/javascripts/rails_admin/ra.i18n.coffee +0 -10
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +0 -55
- data/app/assets/javascripts/rails_admin/ra.sidescroll.coffee +0 -19
- data/app/assets/javascripts/rails_admin/ra.widgets.coffee +0 -359
- data/app/assets/javascripts/rails_admin/ui.coffee +0 -107
- data/lib/rails_admin/config/fields/factories/refile.rb +0 -25
- data/lib/rails_admin/config/fields/types/refile.rb +0 -27
- data/lib/rails_admin/extensions/cancan.rb +0 -3
- data/lib/rails_admin/extensions/cancan/authorization_adapter.rb +0 -57
@@ -0,0 +1,135 @@
|
|
1
|
+
(function($) {
|
2
|
+
$(document).on("click", "#list input.toggle", function() {
|
3
|
+
$("#list [name='bulk_ids[]']").prop("checked", $(this).is(":checked"));
|
4
|
+
});
|
5
|
+
|
6
|
+
$(document).on('click', '.pjax', function(event) {
|
7
|
+
if (event.which > 1 || event.metaKey || event.ctrlKey) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
|
11
|
+
if ($.support.pjax) {
|
12
|
+
event.preventDefault();
|
13
|
+
$.pjax({
|
14
|
+
container: $(this).data('pjax-container') || '[data-pjax-container]',
|
15
|
+
url: $(this).data('href') || $(this).attr('href'),
|
16
|
+
timeout: 2000
|
17
|
+
});
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
|
21
|
+
if ($(this).data('href')) {
|
22
|
+
window.location = $(this).data('href');
|
23
|
+
}
|
24
|
+
});
|
25
|
+
|
26
|
+
$(document).on('submit', '.pjax-form', function(event) {
|
27
|
+
if ($.support.pjax) {
|
28
|
+
event.preventDefault();
|
29
|
+
$.pjax({
|
30
|
+
container: $(this).data('pjax-container') || '[data-pjax-container]',
|
31
|
+
url: this.action + (this.action.indexOf('?') !== -1 ? '&' : '?') + $(this).serialize(),
|
32
|
+
timeout: 2000
|
33
|
+
});
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
$(document).on('pjax:start', function() {
|
38
|
+
return $('#loading').show();
|
39
|
+
}).on('pjax:end', function() {
|
40
|
+
return $('#loading').hide();
|
41
|
+
});
|
42
|
+
|
43
|
+
$(document).on('click', '[data-target]', function() {
|
44
|
+
if (!$(this).hasClass('disabled')) {
|
45
|
+
if ($(this).has('i.icon-chevron-down').length) {
|
46
|
+
$(this).removeClass('active').children('i').toggleClass('icon-chevron-down icon-chevron-right');
|
47
|
+
$($(this).data('target')).select(':visible').hide('slow');
|
48
|
+
} else {
|
49
|
+
if ($(this).has('i.icon-chevron-right').length) {
|
50
|
+
$(this).addClass('active').children('i').toggleClass('icon-chevron-down icon-chevron-right');
|
51
|
+
$($(this).data('target')).select(':hidden').show('slow');
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
});
|
56
|
+
|
57
|
+
$(document).on('click', '.form-horizontal legend', function() {
|
58
|
+
if ($(this).has('i.icon-chevron-down').length) {
|
59
|
+
$(this).siblings('.control-group:visible').hide('slow');
|
60
|
+
$(this).children('i').toggleClass('icon-chevron-down icon-chevron-right');
|
61
|
+
} else {
|
62
|
+
if ($(this).has('i.icon-chevron-right').length) {
|
63
|
+
$(this).siblings('.control-group:hidden').show('slow');
|
64
|
+
$(this).children('i').toggleClass('icon-chevron-down icon-chevron-right');
|
65
|
+
}
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
$(document).on('click', 'form .tab-content .tab-pane a.remove_nested_one_fields', function() {
|
70
|
+
$(this).children('input[type="hidden"]').val($(this).hasClass('active')).siblings('i').toggleClass('icon-check icon-trash');
|
71
|
+
});
|
72
|
+
|
73
|
+
$(document).ready(function() {
|
74
|
+
RailsAdmin.I18n.init($('html').attr('lang'), $("#admin-js").data('i18nOptions'));
|
75
|
+
$(document).trigger('rails_admin.dom_ready');
|
76
|
+
});
|
77
|
+
|
78
|
+
$(document).on('pjax:end', function() {
|
79
|
+
$(document).trigger('rails_admin.dom_ready');
|
80
|
+
});
|
81
|
+
|
82
|
+
$(document).on('rails_admin.dom_ready', function() {
|
83
|
+
$('.nav.nav-pills li.active').removeClass('active');
|
84
|
+
$(".nav.nav-pills li[data-model=\"" + ($('.page-header').data('model')) + "\"]").addClass('active');
|
85
|
+
$('.animate-width-to').each(function() {
|
86
|
+
var length, width;
|
87
|
+
length = $(this).data("animate-length");
|
88
|
+
width = $(this).data("animate-width-to");
|
89
|
+
$(this).animate({
|
90
|
+
width: width
|
91
|
+
}, length, 'easeOutQuad');
|
92
|
+
});
|
93
|
+
$('.form-horizontal legend').has('i.icon-chevron-right').each(function() {
|
94
|
+
$(this).siblings('.control-group').hide();
|
95
|
+
});
|
96
|
+
$(".table").tooltip({
|
97
|
+
selector: "th[rel=tooltip]"
|
98
|
+
});
|
99
|
+
$('[formnovalidate]').on('click', function() {
|
100
|
+
$(this).closest('form').attr('novalidate', true);
|
101
|
+
});
|
102
|
+
$.each($('#filters_box').data('options'), function() {
|
103
|
+
$.filters.append(this);
|
104
|
+
});
|
105
|
+
});
|
106
|
+
|
107
|
+
$(document).on('click', ".bulk-link", function(event) {
|
108
|
+
event.preventDefault();
|
109
|
+
$('#bulk_action').val($(this).data('action'));
|
110
|
+
$('#bulk_form').submit();
|
111
|
+
});
|
112
|
+
|
113
|
+
$(document).on('click', "#remove_filter", function(event) {
|
114
|
+
event.preventDefault();
|
115
|
+
$("#filters_box").html("");
|
116
|
+
$("hr.filters_box").hide();
|
117
|
+
$(this).parent().siblings("input[type='search']").val("");
|
118
|
+
$(this).parents("form").submit();
|
119
|
+
});
|
120
|
+
|
121
|
+
$(document).on('click', '#fields_to_export label input#check_all', function() {
|
122
|
+
var elems;
|
123
|
+
elems = $('#fields_to_export label input');
|
124
|
+
if ($('#fields_to_export label input#check_all').is(':checked')) {
|
125
|
+
$(elems).prop('checked', true);
|
126
|
+
} else {
|
127
|
+
$(elems).prop('checked', false);
|
128
|
+
}
|
129
|
+
});
|
130
|
+
|
131
|
+
$(document).on('click', '#fields_to_export .reverse-selection', function() {
|
132
|
+
$(this).closest(".control-group").find(".controls").find("input").click();
|
133
|
+
});
|
134
|
+
|
135
|
+
}(jQuery));
|
@@ -84,9 +84,24 @@ module RailsAdmin
|
|
84
84
|
end.join.html_safe
|
85
85
|
end
|
86
86
|
|
87
|
+
def root_navigation
|
88
|
+
actions(:root).select(&:show_in_sidebar).group_by(&:sidebar_label).collect do |label, nodes|
|
89
|
+
li_stack = nodes.map do |node|
|
90
|
+
url = rails_admin.url_for(action: node.action_name, controller: "rails_admin/main")
|
91
|
+
nav_icon = node.link_icon ? %(<i class="#{node.link_icon}"></i>).html_safe : ''
|
92
|
+
content_tag :li do
|
93
|
+
link_to nav_icon + " " + wording_for(:menu, node), url, class: "pjax"
|
94
|
+
end
|
95
|
+
end.join.html_safe
|
96
|
+
label ||= t('admin.misc.root_navigation')
|
97
|
+
|
98
|
+
%(<li class='dropdown-header'>#{capitalize_first_letter label}</li>#{li_stack}) if li_stack.present?
|
99
|
+
end.join.html_safe
|
100
|
+
end
|
101
|
+
|
87
102
|
def static_navigation
|
88
103
|
li_stack = RailsAdmin::Config.navigation_static_links.collect do |title, url|
|
89
|
-
content_tag(:li, link_to(title.to_s, url, target: '_blank'))
|
104
|
+
content_tag(:li, link_to(title.to_s, url, target: '_blank', rel: 'noopener noreferrer'))
|
90
105
|
end.join
|
91
106
|
|
92
107
|
label = RailsAdmin::Config.navigation_static_label || t('admin.misc.navigation_static_label')
|
@@ -138,7 +153,7 @@ module RailsAdmin
|
|
138
153
|
|
139
154
|
# parent => :root, :collection, :member
|
140
155
|
def menu_for(parent, abstract_model = nil, object = nil, only_icon = false) # perf matters here (no action view trickery)
|
141
|
-
actions = actions(parent, abstract_model, object).select { |a| a.http_methods.include?(:get) }
|
156
|
+
actions = actions(parent, abstract_model, object).select { |a| a.http_methods.include?(:get) && a.show_in_menu }
|
142
157
|
actions.collect do |action|
|
143
158
|
wording = wording_for(:menu, action)
|
144
159
|
%(
|
@@ -0,0 +1,7 @@
|
|
1
|
+
%meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}
|
2
|
+
%meta{content: "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
|
3
|
+
%meta{content: "width=device-width, initial-scale=1", name: "viewport; charset=utf-8"}
|
4
|
+
%meta{content: "NONE,NOARCHIVE", name: "robots"}
|
5
|
+
= csrf_meta_tag
|
6
|
+
= stylesheet_link_tag "rails_admin/rails_admin.css", media: :all
|
7
|
+
= javascript_include_tag "rails_admin/rails_admin.js"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
%ul.nav.navbar-nav.navbar-right.root_links
|
2
|
-
- actions(:root).each do |action|
|
2
|
+
- actions(:root).select(&:show_in_navigation).each do |action|
|
3
3
|
%li{class: "#{action.action_name}_root_link"}= link_to wording_for(:menu, action), { action: action.action_name, controller: 'rails_admin/main' }, class: action.pjax? ? "pjax" : ""
|
4
4
|
- if main_app_root_path = (main_app.root_path rescue false)
|
5
5
|
%li= link_to t('admin.home.name'), main_app_root_path
|
@@ -1,13 +1,7 @@
|
|
1
1
|
!!! 5
|
2
2
|
%html{lang: I18n.locale}
|
3
3
|
%head
|
4
|
-
|
5
|
-
%meta{content: "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
|
6
|
-
%meta{content: "width=device-width, initial-scale=1", name: "viewport; charset=utf-8"}
|
7
|
-
%meta{content: "NONE,NOARCHIVE", name: "robots"}
|
8
|
-
= csrf_meta_tag
|
9
|
-
= stylesheet_link_tag "rails_admin/rails_admin.css", media: :all
|
10
|
-
= javascript_include_tag "rails_admin/rails_admin.js"
|
4
|
+
= render "layouts/rails_admin/head"
|
11
5
|
%body.rails_admin
|
12
6
|
#admin-js{:'data-i18n-options' => I18n.t("admin.js").to_json}
|
13
7
|
#loading.label.label-warning{style: 'display:none; position:fixed; right:20px; bottom:20px; z-index:100000'}= t('admin.loading')
|
@@ -18,4 +12,5 @@
|
|
18
12
|
.col-sm-3.col-md-2.sidebar-nav
|
19
13
|
= render "layouts/rails_admin/sidebar_navigation"
|
20
14
|
.col-sm-9.col-sm-offset-3.col-md-10.col-md-offset-2
|
21
|
-
.content{:'data-pjax-container' => true}
|
15
|
+
.content{:'data-pjax-container' => true}
|
16
|
+
= render template: 'layouts/rails_admin/pjax'
|
@@ -1,5 +1,8 @@
|
|
1
1
|
- file = field.value
|
2
2
|
|
3
|
+
- if field.cache_method
|
4
|
+
= form.hidden_field(field.cache_method, value: field.cache_value)
|
5
|
+
|
3
6
|
.toggle{style: ('display:none;' if file && field.delete_method && form.object.send(field.delete_method) == '1')}
|
4
7
|
- if value = field.pretty_value
|
5
8
|
= value
|
@@ -12,6 +15,3 @@
|
|
12
15
|
= I18n.t('admin.actions.delete.menu').capitalize + " #{field.label.downcase}"
|
13
16
|
|
14
17
|
= form.check_box(field.delete_method, style: 'display:none;')
|
15
|
-
|
16
|
-
- if field.cache_method
|
17
|
-
= form.hidden_field(field.cache_method)
|
@@ -1,12 +1,14 @@
|
|
1
1
|
- field.attachments.each_with_index do |attachment, i|
|
2
|
-
.toggle
|
2
|
+
.toggle{class: field.reorderable? ? 'sortables' : ''}
|
3
3
|
= attachment.pretty_value
|
4
|
-
- if field.delete_method
|
4
|
+
- if field.delete_method || field.keep_method
|
5
5
|
%a.btn.btn-info.btn-remove-image{href: '#', :'data-toggle' => 'button', role: 'button'}
|
6
6
|
%i.icon-white.icon-trash
|
7
7
|
= I18n.t('admin.actions.delete.menu').capitalize + " #{field.label.downcase} ##{i + 1}"
|
8
|
-
|
9
|
-
|
8
|
+
- if field.keep_method
|
9
|
+
= form.check_box(field.keep_method, {multiple:true, checked: true, style: 'display:none;'}, attachment.keep_value, nil)
|
10
|
+
- elsif field.delete_method
|
11
|
+
= form.check_box(field.delete_method, {multiple:true, style: 'display:none;'}, attachment.delete_value, nil)
|
10
12
|
|
11
13
|
= form.file_field(field.name, field.html_attributes.reverse_merge({ data: { :"multiple-fileupload" => true }, multiple: true }))
|
12
14
|
|
data/lib/rails_admin.rb
CHANGED
@@ -2,7 +2,6 @@ require 'rails_admin/engine'
|
|
2
2
|
require 'rails_admin/abstract_model'
|
3
3
|
require 'rails_admin/config'
|
4
4
|
require 'rails_admin/extension'
|
5
|
-
require 'rails_admin/extensions/cancan'
|
6
5
|
require 'rails_admin/extensions/cancancan'
|
7
6
|
require 'rails_admin/extensions/pundit'
|
8
7
|
require 'rails_admin/extensions/paper_trail'
|
@@ -46,7 +46,7 @@ module RailsAdmin
|
|
46
46
|
def initialize(model_or_model_name)
|
47
47
|
@model_name = model_or_model_name.to_s
|
48
48
|
ancestors = model.ancestors.collect(&:to_s)
|
49
|
-
if ancestors.include?('ActiveRecord::Base') && !model.abstract_class?
|
49
|
+
if ancestors.include?('ActiveRecord::Base') && !model.abstract_class? && model.table_exists?
|
50
50
|
initialize_active_record
|
51
51
|
elsif ancestors.include?('Mongoid::Document')
|
52
52
|
initialize_mongoid
|
@@ -64,6 +64,10 @@ module RailsAdmin
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def base_class
|
68
|
+
model.base_class
|
69
|
+
end
|
70
|
+
|
67
71
|
delegate :primary_key, :table_name, to: :model, prefix: false
|
68
72
|
|
69
73
|
def encoding
|
@@ -101,7 +105,7 @@ module RailsAdmin
|
|
101
105
|
|
102
106
|
def add(field, value, operator)
|
103
107
|
field.searchable_columns.flatten.each do |column_infos|
|
104
|
-
statement, value1, value2 = StatementBuilder.new(column_infos[:column], column_infos[:type], value, operator).to_statement
|
108
|
+
statement, value1, value2 = StatementBuilder.new(column_infos[:column], column_infos[:type], value, operator, @scope.connection.adapter_name).to_statement
|
105
109
|
@statements << statement if statement.present?
|
106
110
|
@values << value1 unless value1.nil?
|
107
111
|
@values << value2 unless value2.nil?
|
@@ -149,10 +153,15 @@ module RailsAdmin
|
|
149
153
|
end
|
150
154
|
|
151
155
|
def build_statement(column, type, value, operator)
|
152
|
-
StatementBuilder.new(column, type, value, operator).to_statement
|
156
|
+
StatementBuilder.new(column, type, value, operator, model.connection.adapter_name).to_statement
|
153
157
|
end
|
154
158
|
|
155
159
|
class StatementBuilder < RailsAdmin::AbstractModel::StatementBuilder
|
160
|
+
def initialize(column, type, value, operator, adapter_name)
|
161
|
+
super column, type, value, operator
|
162
|
+
@adapter_name = adapter_name
|
163
|
+
end
|
164
|
+
|
156
165
|
protected
|
157
166
|
|
158
167
|
def unary_operators
|
@@ -265,7 +274,7 @@ module RailsAdmin
|
|
265
274
|
end
|
266
275
|
|
267
276
|
def ar_adapter
|
268
|
-
|
277
|
+
@adapter_name.downcase
|
269
278
|
end
|
270
279
|
end
|
271
280
|
end
|
@@ -49,6 +49,14 @@ module RailsAdmin
|
|
49
49
|
end
|
50
50
|
scope = sort_by(options, scope) if options[:sort]
|
51
51
|
scope
|
52
|
+
rescue NoMethodError => e
|
53
|
+
if e.message =~ /page/
|
54
|
+
e = e.exception <<-EOM.gsub(/^\s{12}/, '')
|
55
|
+
#{e.message}
|
56
|
+
If you don't have kaminari-mongoid installed, add `gem 'kaminari-mongoid'` to your Gemfile.
|
57
|
+
EOM
|
58
|
+
end
|
59
|
+
raise e
|
52
60
|
end
|
53
61
|
|
54
62
|
def count(options = {}, scope = nil)
|
@@ -74,6 +82,12 @@ module RailsAdmin
|
|
74
82
|
fields.collect { |_name, field| Property.new(field, model) }
|
75
83
|
end
|
76
84
|
|
85
|
+
def base_class
|
86
|
+
klass = model
|
87
|
+
klass = klass.superclass while klass.hereditary?
|
88
|
+
klass
|
89
|
+
end
|
90
|
+
|
77
91
|
def table_name
|
78
92
|
model.collection_name.to_s
|
79
93
|
end
|
@@ -11,7 +11,7 @@ module RailsAdmin
|
|
11
11
|
require 'rails_admin/bootstrap-sass/sass_functions'
|
12
12
|
end
|
13
13
|
|
14
|
-
require '
|
14
|
+
require 'sassc-rails' if rails?
|
15
15
|
|
16
16
|
unless rails? || compass?
|
17
17
|
raise(Bootstrap::FrameworkNotFound.new('bootstrap-sass requires either Rails > 3.1 or Compass, neither of which are loaded'))
|
data/lib/rails_admin/config.rb
CHANGED
@@ -141,11 +141,11 @@ module RailsAdmin
|
|
141
141
|
# end
|
142
142
|
#
|
143
143
|
# To use an authorization adapter, pass the name of the adapter. For example,
|
144
|
-
# to use with
|
144
|
+
# to use with CanCanCan[https://github.com/CanCanCommunity/cancancan/], pass it like this.
|
145
145
|
#
|
146
|
-
# @example
|
146
|
+
# @example CanCanCan
|
147
147
|
# RailsAdmin.config do |config|
|
148
|
-
# config.authorize_with :
|
148
|
+
# config.authorize_with :cancancan
|
149
149
|
# end
|
150
150
|
#
|
151
151
|
# See the wiki[https://github.com/sferik/rails_admin/wiki] for more on authorization.
|
@@ -210,9 +210,7 @@ module RailsAdmin
|
|
210
210
|
|
211
211
|
# pool of all found model names from the whole application
|
212
212
|
def models_pool
|
213
|
-
|
214
|
-
|
215
|
-
(viable_models - excluded).uniq.sort
|
213
|
+
(viable_models - excluded_models.collect(&:to_s)).uniq.sort
|
216
214
|
end
|
217
215
|
|
218
216
|
# Loads a model configuration instance from the registry or registers
|
@@ -18,6 +18,22 @@ module RailsAdmin
|
|
18
18
|
[]
|
19
19
|
end
|
20
20
|
|
21
|
+
register_instance_option :show_in_navigation do
|
22
|
+
root?
|
23
|
+
end
|
24
|
+
|
25
|
+
register_instance_option :show_in_sidebar do
|
26
|
+
!show_in_navigation
|
27
|
+
end
|
28
|
+
|
29
|
+
register_instance_option :show_in_menu do
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
register_instance_option :sidebar_label do
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
21
37
|
# http://getbootstrap.com/2.3.2/base-css.html#icons
|
22
38
|
register_instance_option :link_icon do
|
23
39
|
'icon-question-sign'
|
@@ -83,7 +99,7 @@ module RailsAdmin
|
|
83
99
|
key.to_sym
|
84
100
|
end
|
85
101
|
|
86
|
-
# For
|
102
|
+
# For CanCanCan and the like
|
87
103
|
register_instance_option :authorization_key do
|
88
104
|
key.to_sym
|
89
105
|
end
|
@@ -25,9 +25,7 @@ module RailsAdmin
|
|
25
25
|
sanitize_params_for!(request.xhr? ? :modal : :update)
|
26
26
|
|
27
27
|
@object.set_attributes(params[@abstract_model.param_key])
|
28
|
-
@authorization_adapter && @authorization_adapter.
|
29
|
-
@object.send("#{name}=", value)
|
30
|
-
end
|
28
|
+
@authorization_adapter && @authorization_adapter.authorize(:update, @abstract_model, @object)
|
31
29
|
changes = @object.changes
|
32
30
|
if @object.save
|
33
31
|
@auditing_adapter && @auditing_adapter.update_object(@object, @abstract_model, _current_user, changes)
|