rails_admin 0.0.5 → 0.1.0
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.
- data/Gemfile +5 -30
- data/README.md +20 -2
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +2 -2
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +1 -1
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +1 -1
- data/app/assets/javascripts/rails_admin/ra.widgets.coffee +43 -3
- data/app/assets/javascripts/rails_admin/ui.js.coffee +2 -0
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +3 -0
- data/app/assets/stylesheets/rails_admin/ra.widgets.css.scss +8 -0
- data/app/controllers/rails_admin/main_controller.rb +3 -3
- data/app/helpers/rails_admin/application_helper.rb +15 -4
- data/app/helpers/rails_admin/form_builder.rb +35 -35
- data/app/views/layouts/rails_admin/application.html.haml +2 -1
- data/app/views/rails_admin/main/_delete_notice.html.haml +9 -8
- data/app/views/rails_admin/main/_form_datetime.html.haml +1 -1
- data/app/views/rails_admin/main/_form_enumeration.html.haml +18 -1
- data/app/views/rails_admin/main/_form_file_upload.html.haml +2 -2
- data/app/views/rails_admin/main/_form_text.html.haml +7 -1
- data/app/views/rails_admin/main/dashboard.html.haml +26 -25
- data/app/views/rails_admin/main/index.html.haml +1 -1
- data/config/initializers/active_record_extensions.rb +2 -2
- data/config/locales/rails_admin.en.yml +1 -0
- data/lib/generators/rails_admin/install_generator.rb +1 -1
- data/lib/generators/rails_admin/templates/initializer.erb +66 -67
- data/lib/rails_admin/abstract_model.rb +7 -7
- data/lib/rails_admin/adapters/active_record.rb +17 -8
- data/lib/rails_admin/adapters/mongoid.rb +38 -42
- data/lib/rails_admin/adapters/mongoid/extension.rb +1 -1
- data/lib/rails_admin/config.rb +15 -1
- data/lib/rails_admin/config/actions/base.rb +16 -2
- data/lib/rails_admin/config/actions/dashboard.rb +17 -11
- data/lib/rails_admin/config/fields.rb +0 -1
- data/lib/rails_admin/config/fields/association.rb +2 -3
- data/lib/rails_admin/config/fields/base.rb +18 -6
- data/lib/rails_admin/config/fields/types/enum.rb +4 -0
- data/lib/rails_admin/config/fields/types/string.rb +6 -4
- data/lib/rails_admin/config/fields/types/text.rb +19 -2
- data/lib/rails_admin/config/model.rb +17 -0
- data/lib/rails_admin/config/sections/base.rb +17 -0
- data/lib/rails_admin/engine.rb +4 -0
- data/lib/rails_admin/extensions/history/auditing_adapter.rb +1 -1
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +4 -4
- data/lib/rails_admin/support/csv_converter.rb +3 -3
- data/lib/rails_admin/version.rb +2 -2
- data/lib/tasks/rails_admin.rake +36 -6
- data/spec/controllers/main_controller_spec.rb +52 -9
- data/spec/dummy_app/Gemfile +7 -16
- data/spec/dummy_app/app/active_record/another_field_test.rb +4 -0
- data/spec/dummy_app/app/active_record/ball.rb +1 -1
- data/spec/dummy_app/app/active_record/nested_field_test.rb +2 -1
- data/spec/dummy_app/app/active_record/team.rb +3 -2
- data/spec/dummy_app/app/active_record/user.rb +6 -2
- data/spec/dummy_app/app/mongoid/another_field_test.rb +6 -0
- data/spec/dummy_app/app/mongoid/ball.rb +1 -1
- data/spec/dummy_app/app/mongoid/nested_field_test.rb +2 -1
- data/spec/dummy_app/app/mongoid/team.rb +1 -1
- data/spec/dummy_app/config/environments/development.rb +2 -2
- data/spec/dummy_app/db/migrate/20120720075608_create_another_field_tests.rb +8 -0
- data/spec/dummy_app/db/seeds.rb +3 -3
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/dummy_app/log/test.log +53792 -0
- data/spec/helpers/application_helper_spec.rb +37 -0
- data/spec/helpers/form_builder_spec.rb +17 -0
- data/spec/integration/authorization/cancan_spec.rb +21 -13
- data/spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb +1 -8
- data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +15 -4
- data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +9 -12
- data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +2 -10
- data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +6 -0
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +241 -300
- data/spec/integration/config/list/rails_admin_config_list_spec.rb +3 -81
- data/spec/integration/config/show/rails_admin_config_show_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/active_record_extension_spec.rb +16 -0
- data/spec/unit/adapters/active_record_spec.rb +11 -9
- data/spec/unit/adapters/mongoid_spec.rb +4 -4
- data/spec/unit/config/actions/base_spec.rb +32 -0
- data/spec/unit/config/fields/base_spec.rb +56 -0
- data/spec/unit/config/fields/date_spec.rb +53 -0
- data/spec/unit/config/fields/datetime_spec.rb +55 -0
- data/spec/unit/config/fields/time_spec.rb +39 -0
- data/spec/unit/config/fields/timestamp_spec.rb +20 -0
- data/spec/unit/config_spec.rb +1 -1
- data/spec/unit/support/csv_converter_spec.rb +16 -0
- metadata +44 -35
- data/lib/rails_admin/config/fields/factories/serialized.rb +0 -17
- data/lib/tasks/prepare_ci_env.rake +0 -27
data/Gemfile
CHANGED
@@ -32,47 +32,22 @@ group :active_record do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
group :mongoid do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
gem 'mongoid-paperclip', :require => 'mongoid_paperclip', :git => 'git://github.com/mshibuya/mongoid-paperclip.git', :branch => 'fix-stop-patching-logger'
|
39
|
-
# For now, carrierwave-mongoid's mongoid dependency is restricted to '~> 2.1'
|
40
|
-
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid', :git => 'git://github.com/tanordheim/carrierwave-mongoid.git', :branch => 'mongoid_3_0'
|
41
|
-
else
|
42
|
-
platforms :ruby, :mswin, :mingw do
|
43
|
-
gem 'bson'
|
44
|
-
gem 'bson_ext'
|
45
|
-
end
|
46
|
-
gem 'mongoid'
|
47
|
-
gem 'mongoid-paperclip', :require => 'mongoid_paperclip'
|
48
|
-
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
|
49
|
-
end
|
35
|
+
gem 'mongoid', '~> 3.0'
|
36
|
+
gem 'mongoid-paperclip', '~> 0.0.8', :require => 'mongoid_paperclip'
|
37
|
+
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid', :git => 'git://github.com/jnicklas/carrierwave-mongoid.git', :branch => 'mongoid-3.0'
|
50
38
|
end
|
51
39
|
|
52
40
|
group :debug do
|
53
|
-
platform :mri_18 do
|
54
|
-
gem 'ruby-debug'
|
55
|
-
gem 'linecache'
|
56
|
-
end
|
57
|
-
|
58
41
|
platform :mri_19 do
|
59
|
-
gem '
|
42
|
+
gem 'debugger'
|
60
43
|
gem 'simplecov', :require => false
|
61
44
|
end
|
62
|
-
|
63
|
-
platform :jruby do
|
64
|
-
gem 'ruby-debug'
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
platforms :jruby, :mingw_18, :ruby_18 do
|
69
|
-
gem 'fastercsv', '~> 1.5'
|
70
45
|
end
|
71
46
|
|
72
47
|
group :development, :test do
|
73
48
|
gem 'cancan'
|
74
49
|
gem 'devise'
|
75
|
-
gem 'paperclip'
|
50
|
+
gem 'paperclip'
|
76
51
|
end
|
77
52
|
|
78
53
|
gemspec
|
data/README.md
CHANGED
@@ -18,6 +18,20 @@ Hoeven][plukevdh], and [Rein Henrichs][reinh].
|
|
18
18
|
[plukevdh]: https://github.com/plukevdh
|
19
19
|
[reinh]: https://github.com/reinh
|
20
20
|
|
21
|
+
## Announcements
|
22
|
+
|
23
|
+
* for those with `rake db:migrate` errors, update to master and check that you see the line: "[RailsAdmin] RailsAdmin initialization disabled by default." when you launch the task. If not (or if migrations still don't work), open a ticket with an application on Github that can reproduce the issue.
|
24
|
+
|
25
|
+
* `config.models do ... end` is deprecated (note the 's' to models, `config.model(MyModel) do .. end` is fine), for performance reasons (forces early loading of all application's models). Duplicate to each model instead, before next release. If you really need the old behavior:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
config.models.each do |m|
|
29
|
+
config.model m do
|
30
|
+
# <<<< here goes your code
|
31
|
+
end
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
21
35
|
## Features
|
22
36
|
|
23
37
|
* Display database tables
|
@@ -43,6 +57,7 @@ Take RailsAdmin for a [test drive][demo] with sample data. ([Source code.][dummy
|
|
43
57
|
[dummy_app]: https://github.com/bbenezech/dummy_app
|
44
58
|
|
45
59
|
## Installation
|
60
|
+
|
46
61
|
In your `Gemfile`, add the following dependencies:
|
47
62
|
|
48
63
|
gem 'fastercsv' # Only required on Ruby 1.8 and below
|
@@ -98,6 +113,7 @@ Optionally, you may wish to set up [Cancan](https://github.com/ryanb/cancan),
|
|
98
113
|
More on that in the [Wiki](https://github.com/sferik/rails_admin/wiki)
|
99
114
|
|
100
115
|
## Usage
|
116
|
+
|
101
117
|
Start the server:
|
102
118
|
|
103
119
|
$ rails server
|
@@ -110,13 +126,15 @@ You should now be able to administer your site at
|
|
110
126
|
All configuration documentation has moved to the wiki: https://github.com/sferik/rails_admin/wiki
|
111
127
|
|
112
128
|
## Screenshots
|
129
|
+
|
113
130
|
![Dashboard view](https://github.com/sferik/rails_admin/raw/master/screenshots/dashboard.png "dashboard view")
|
114
131
|
![Delete view](https://github.com/sferik/rails_admin/raw/master/screenshots/delete.png "delete view")
|
115
132
|
![List view](https://github.com/sferik/rails_admin/raw/master/screenshots/list.png "list view")
|
116
133
|
![Nested view](https://github.com/sferik/rails_admin/raw/master/screenshots/nested.png "nested view")
|
117
|
-
![
|
134
|
+
![Polymorphic edit view](https://github.com/sferik/rails_admin/raw/master/screenshots/polymorphic.png "polymorphic view")
|
118
135
|
|
119
136
|
## Support
|
137
|
+
|
120
138
|
If you have a question, please check this README, the wiki, and the [list of
|
121
139
|
known issues][troubleshoot].
|
122
140
|
|
@@ -130,6 +148,7 @@ list][list].
|
|
130
148
|
If you think you found a bug in RailsAdmin, you can [submit an issue][issues].
|
131
149
|
|
132
150
|
## Contributing
|
151
|
+
|
133
152
|
In the spirit of [free software][free-sw], **everyone** is encouraged to help
|
134
153
|
improve this project.
|
135
154
|
|
@@ -180,7 +199,6 @@ Ideally, a bug report should include a pull request with failing specs.
|
|
180
199
|
## Supported Ruby Versions
|
181
200
|
This library aims to support and is [tested against][travis] the following Ruby implementations:
|
182
201
|
|
183
|
-
* Ruby 1.8.7
|
184
202
|
* Ruby 1.9.2
|
185
203
|
* Ruby 1.9.3
|
186
204
|
* [Rubinius][]
|
@@ -40,7 +40,7 @@
|
|
40
40
|
}).toArray();
|
41
41
|
}
|
42
42
|
var filtering_select = $('<div class="input-append filtering-select" style="float:left"></div>')
|
43
|
-
var input = this.input = $('<input type="
|
43
|
+
var input = this.input = $('<input type="text">')
|
44
44
|
.val(value)
|
45
45
|
.addClass("ra-filtering-select-input")
|
46
46
|
.attr('style', select.attr('style'))
|
@@ -83,7 +83,7 @@
|
|
83
83
|
.keyup(function() {
|
84
84
|
/* Clear select options and trigger change if selected item is deleted */
|
85
85
|
if ($(this).val().length == 0) {
|
86
|
-
select.
|
86
|
+
select.html($('<option value="" selected="selected"></option>'));
|
87
87
|
select.trigger("change");
|
88
88
|
}
|
89
89
|
})
|
@@ -7,7 +7,7 @@ $(document).ready ->
|
|
7
7
|
tab_content.children().last()
|
8
8
|
|
9
9
|
$('form').live 'nested:fieldAdded', (content) ->
|
10
|
-
field = content.field.addClass('tab-pane')
|
10
|
+
field = content.field.addClass('tab-pane').attr('id', 'unique-id-' + (new Date().getTime()))
|
11
11
|
new_tab = $('<li><a data-toggle="tab" href="#' + field.attr('id') + '">' + field.children('.object-infos').data('object-label') + '</a></li>')
|
12
12
|
parent_group = field.closest('.control-group')
|
13
13
|
controls = parent_group.children('.controls')
|
@@ -26,7 +26,10 @@ $(document).live 'rails_admin.dom_ready', ->
|
|
26
26
|
# enumeration
|
27
27
|
|
28
28
|
$('form [data-enumeration]').each ->
|
29
|
-
|
29
|
+
if $(this).is('[multiple]')
|
30
|
+
$(this).filteringMultiselect $(this).data('options')
|
31
|
+
else
|
32
|
+
$(this).filteringSelect $(this).data('options')
|
30
33
|
|
31
34
|
# fileupload
|
32
35
|
|
@@ -35,6 +38,24 @@ $(document).live 'rails_admin.dom_ready', ->
|
|
35
38
|
$(this).find(".delete input[type='checkbox']").live 'click', ->
|
36
39
|
$(input).children('.toggle').toggle('slow')
|
37
40
|
|
41
|
+
# fileupload-preview
|
42
|
+
|
43
|
+
$('form [data-fileupload]').change ->
|
44
|
+
input = this
|
45
|
+
image_container = $("#" + input.id).parent().children(".preview")
|
46
|
+
unless image_container.length
|
47
|
+
image_container = $("#" + input.id).parent().prepend($('<img />').addClass('preview')).find('img.preview')
|
48
|
+
image_container.parent().find('img:not(.preview)').hide()
|
49
|
+
ext = $("#" + input.id).val().split('.').pop().toLowerCase()
|
50
|
+
if input.files and input.files[0] and $.inArray(ext, ['gif','png','jpg','jpeg','bmp']) != -1
|
51
|
+
reader = new FileReader()
|
52
|
+
reader.onload = (e) ->
|
53
|
+
image_container.attr "src", e.target.result
|
54
|
+
reader.readAsDataURL input.files[0]
|
55
|
+
image_container.show()
|
56
|
+
else
|
57
|
+
image_container.hide()
|
58
|
+
|
38
59
|
# filtering-multiselect
|
39
60
|
|
40
61
|
$('form [data-filteringmultiselect]').each ->
|
@@ -62,6 +83,7 @@ $(document).live 'rails_admin.dom_ready', ->
|
|
62
83
|
toggler = field.find('> .controls > .btn-group > .toggler')
|
63
84
|
# add each nested field to a tab-pane and reference it in the nav
|
64
85
|
content.children('.fields:not(.tab-pane)').addClass('tab-pane').each ->
|
86
|
+
$(this).attr('id', 'unique-id-' + (new Date().getTime()) + Math.floor(Math.random()*100000)) # some elements are created on the same ms
|
65
87
|
nav.append('<li><a data-toggle="tab" href="#' + this.id + '">' + $(this).children('.object-infos').data('object-label') + '</a></li>')
|
66
88
|
# only if no tab is set to active
|
67
89
|
if nav.find("> li.active").length == 0
|
@@ -88,7 +110,7 @@ $(document).live 'rails_admin.dom_ready', ->
|
|
88
110
|
nav = field.find("> .controls > .nav")
|
89
111
|
content = field.find("> .tab-content")
|
90
112
|
toggler = field.find('> .controls > .toggler')
|
91
|
-
content.children(".fields:not(.tab-pane)").addClass('tab-pane').each ->
|
113
|
+
content.children(".fields:not(.tab-pane)").addClass('tab-pane active').each ->
|
92
114
|
nav.append('<li><a data-toggle="tab" href="#' + this.id + '">' + $(this).children('.object-infos').data('object-label') + '</a></li>')
|
93
115
|
first_tab = nav.find("> li > a[data-toggle='tab']:first")
|
94
116
|
first_tab.tab('show')
|
@@ -156,7 +178,7 @@ $(document).live 'rails_admin.dom_ready', ->
|
|
156
178
|
CodeMirror.fromTextArea(textarea,{mode:options['options']['mode'],theme:options['options']['theme']})
|
157
179
|
$(textarea).addClass('codemirrored')
|
158
180
|
|
159
|
-
array = $('form [data-richtext=codemirror]').not('.codemirrored')
|
181
|
+
array = $('form [data-richtext=codemirror]').not('.codemirrored')
|
160
182
|
if array.length
|
161
183
|
@array = array
|
162
184
|
if not window.CodeMirror
|
@@ -167,3 +189,21 @@ $(document).live 'rails_admin.dom_ready', ->
|
|
167
189
|
else
|
168
190
|
goCodeMirrors(@array)
|
169
191
|
|
192
|
+
# bootstrap_wysihtml5
|
193
|
+
|
194
|
+
goBootstrapWysihtml5s = (array) =>
|
195
|
+
array.each ->
|
196
|
+
$(@).addClass('bootstrap-wysihtml5ed')
|
197
|
+
$(@).closest('.controls').addClass('well')
|
198
|
+
$(@).wysihtml5()
|
199
|
+
|
200
|
+
array = $('form [data-richtext=bootstrap-wysihtml5]').not('.bootstrap-wysihtml5ed')
|
201
|
+
if array.length
|
202
|
+
@array = array
|
203
|
+
if not window.wysihtml5
|
204
|
+
options = $(array[0]).data('options')
|
205
|
+
$('head').append('<link href="' + options['csspath'] + '" rel="stylesheet" media="all" type="text\/css">')
|
206
|
+
$.getScript options['jspath'], (script, textStatus, jqXHR) =>
|
207
|
+
goBootstrapWysihtml5s(@array)
|
208
|
+
else
|
209
|
+
goBootstrapWysihtml5s(@array)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@charset "UTF-8";
|
2
|
+
|
1
3
|
<%
|
2
4
|
theme = ENV['RAILS_ADMIN_THEME'] || :default
|
3
5
|
%>
|
@@ -25,6 +27,7 @@
|
|
25
27
|
@import "rails_admin/jquery.ui.timepicker";
|
26
28
|
@import "rails_admin/ra.calendar-additions";
|
27
29
|
@import "rails_admin/ra.filtering-multiselect";
|
30
|
+
@import "rails_admin/ra.widgets";
|
28
31
|
@import "rails_admin/jquery.colorpicker";
|
29
32
|
|
30
33
|
|
@@ -29,7 +29,7 @@ module RailsAdmin
|
|
29
29
|
self.send(params[:bulk_action]) if params[:bulk_action].in?(RailsAdmin::Config::Actions.all(:controller => self, :abstract_model => @abstract_model).select(&:bulkable?).map(&:route_fragment))
|
30
30
|
end
|
31
31
|
|
32
|
-
def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = get_association_scope_from_params, pagination = !(params[:associated_collection] || params[:all]))
|
32
|
+
def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = get_association_scope_from_params, pagination = !(params[:associated_collection] || params[:all] || params[:bulk_ids]))
|
33
33
|
scope = model_config.abstract_model.scoped
|
34
34
|
if auth_scope = @authorization_adapter && @authorization_adapter.query(auth_scope_key, model_config.abstract_model)
|
35
35
|
scope = scope.merge(auth_scope)
|
@@ -40,7 +40,7 @@ module RailsAdmin
|
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|
43
|
-
|
43
|
+
|
44
44
|
def get_layout
|
45
45
|
"rails_admin/#{request.headers['X-PJAX'] ? 'pjax' : 'application'}"
|
46
46
|
end
|
@@ -113,7 +113,7 @@ module RailsAdmin
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def check_for_cancel
|
116
|
-
if params[:_continue]
|
116
|
+
if params[:_continue] || (params[:bulk_action] && !params[:bulk_ids])
|
117
117
|
redirect_to(back_or_index, :flash => { :info => t("admin.flash.noaction") })
|
118
118
|
end
|
119
119
|
end
|
@@ -10,8 +10,8 @@ module RailsAdmin
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def current_action?(action, abstract_model = @abstract_model, object = @object)
|
13
|
-
@action.custom_key == action.custom_key &&
|
14
|
-
abstract_model.try(:to_param) == @abstract_model.try(:to_param) &&
|
13
|
+
@action.custom_key == action.custom_key &&
|
14
|
+
abstract_model.try(:to_param) == @abstract_model.try(:to_param) &&
|
15
15
|
(@object.try(:persisted?) ? @object.id == object.try(:id) : !object.try(:persisted?))
|
16
16
|
end
|
17
17
|
|
@@ -43,7 +43,7 @@ module RailsAdmin
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def main_navigation
|
46
|
-
nodes_stack = RailsAdmin::Config.visible_models(:controller => self.controller)
|
46
|
+
nodes_stack = RailsAdmin::Config.visible_models(:controller => self.controller)
|
47
47
|
nodes_stack.group_by(&:navigation_label).map do |navigation_label, nodes|
|
48
48
|
|
49
49
|
li_stack = nodes.select{|n| n.parent.nil? || !n.parent.to_s.in?(nodes_stack.map{|c| c.abstract_model.model_name }) }.map do |node|
|
@@ -63,6 +63,18 @@ module RailsAdmin
|
|
63
63
|
end.join.html_safe
|
64
64
|
end
|
65
65
|
|
66
|
+
def static_navigation
|
67
|
+
li_stack = RailsAdmin::Config.navigation_static_links.map do |title, url|
|
68
|
+
content_tag(:li, link_to(title.to_s, url, :target => '_blank')).html_safe
|
69
|
+
end.join.html_safe
|
70
|
+
|
71
|
+
if li_stack.present?
|
72
|
+
li_stack = %{<li class='nav-header'>#{RailsAdmin::Config.navigation_static_label || t('admin.misc.navigation_static_label')}</li>}.html_safe + li_stack
|
73
|
+
end
|
74
|
+
|
75
|
+
li_stack
|
76
|
+
end
|
77
|
+
|
66
78
|
def navigation nodes_stack, nodes, level
|
67
79
|
nodes.map do |node|
|
68
80
|
%{
|
@@ -78,7 +90,6 @@ module RailsAdmin
|
|
78
90
|
begin
|
79
91
|
(parent_actions ||= []) << action
|
80
92
|
end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent))
|
81
|
-
parent_actions << action(:dashboard) if parent_actions.last.key != :dashboard # in case chain is interrupted
|
82
93
|
|
83
94
|
content_tag(:ul, :class => "breadcrumb") do
|
84
95
|
parent_actions.map do |a|
|
@@ -1,31 +1,31 @@
|
|
1
|
-
ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| html_tag }
|
2
|
-
|
3
1
|
module RailsAdmin
|
4
2
|
class FormBuilder < ::ActionView::Helpers::FormBuilder
|
5
3
|
include ::NestedForm::BuilderMixin
|
6
4
|
|
7
5
|
def generate(options = {})
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
without_field_error_proc_added_div do
|
7
|
+
options.reverse_merge!({
|
8
|
+
:action => @template.controller.params[:action],
|
9
|
+
:model_config => @template.instance_variable_get(:@model_config),
|
10
|
+
:nested_in => false
|
11
|
+
})
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
if options[:nested_in]
|
14
|
+
action = :nested
|
15
|
+
elsif @template.request.format == 'text/javascript'
|
16
|
+
action = :modal
|
17
|
+
else
|
18
|
+
action = options[:action]
|
19
|
+
end
|
20
|
+
|
21
|
+
groups = options[:model_config].send(action).with(:form => self, :object => @object, :view => @template).visible_groups
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
object_infos +
|
24
|
+
groups.map do |fieldset|
|
25
|
+
fieldset_for fieldset, options[:nested_in]
|
26
|
+
end.join.html_safe +
|
27
|
+
(options[:nested_in] ? '' : @template.render(:partial => 'rails_admin/main/submit_buttons'))
|
28
|
+
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def fieldset_for fieldset, nested_in
|
@@ -43,14 +43,15 @@ module RailsAdmin
|
|
43
43
|
def field_wrapper_for field, nested_in
|
44
44
|
if field.label
|
45
45
|
# do not show nested field if the target is the origin
|
46
|
-
unless field.inverse_of.presence && field.inverse_of == nested_in
|
46
|
+
unless field.inverse_of.presence && field.inverse_of == nested_in &&
|
47
|
+
@template.instance_variable_get(:@model_config).abstract_model == field.associated_model_config.abstract_model
|
47
48
|
@template.content_tag(:div, :class => "control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", :id => "#{dom_id(field)}_field") do
|
48
49
|
label(field.method_name, field.label, :class => 'control-label') +
|
49
50
|
(field.nested_form ? field_for(field) : input_for(field))
|
50
51
|
end
|
51
52
|
end
|
52
53
|
else
|
53
|
-
(field.nested_form ? field_for(field) : input_for(field))
|
54
|
+
(field.nested_form ? field_for(field) : input_for(field))
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
@@ -85,18 +86,6 @@ module RailsAdmin
|
|
85
86
|
%{<span style="display:none" class="object-infos" data-model-label="#{model_label}" data-object-label="#{object_label}"></span>}.html_safe
|
86
87
|
end
|
87
88
|
|
88
|
-
def javascript_for(field, options = {}, &block)
|
89
|
-
%{<script type="text/javascript">
|
90
|
-
jQuery(function($) {
|
91
|
-
if(!$("#{jquery_namespace(field)}").parents(".fields_blueprint").length) {
|
92
|
-
if(#{options[:modal] == false ? '!$("#modal").length' : 'true'}) {
|
93
|
-
#{@template.capture(&block)}
|
94
|
-
}
|
95
|
-
}
|
96
|
-
});
|
97
|
-
</script>}.html_safe
|
98
|
-
end
|
99
|
-
|
100
89
|
def jquery_namespace field
|
101
90
|
%{#{(@template.controller.params[:modal] ? '#modal ' : '')}##{dom_id(field)}_field}
|
102
91
|
end
|
@@ -113,5 +102,16 @@ module RailsAdmin
|
|
113
102
|
def dom_name field
|
114
103
|
(@dom_name ||= {})[field.name] ||= %{#{@object_name}#{options[:index] && "[#{options[:index]}]"}[#{field.method_name}]#{field.is_a?(Config::Fields::Association) && field.multiple? ? '[]' : ''}}
|
115
104
|
end
|
105
|
+
|
106
|
+
protected
|
107
|
+
def without_field_error_proc_added_div
|
108
|
+
default_field_error_proc = ::ActionView::Base.field_error_proc
|
109
|
+
begin
|
110
|
+
::ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| html_tag }
|
111
|
+
yield
|
112
|
+
ensure
|
113
|
+
::ActionView::Base.field_error_proc = default_field_error_proc
|
114
|
+
end
|
115
|
+
end
|
116
116
|
end
|
117
117
|
end
|