Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add Modal Config Section #1075

Merged
merged 1 commit into from

2 participants

@ehoch

Adds the ability to add a Modal config section similar to nested.

I apologize for lack of tests, but there's currently no JS test. Also I am not a master of the ruby one-liners, so I possibly made code uglier.

I'll close out my other PR. I think this may be the rebase you need... but this time I did not do it in its own branch. Sorry.

@bbenezech
Collaborator

That's perfect!

Thanks!

@bbenezech bbenezech merged commit 6d32552 into sferik:master
@ehoch

Thanks! Added brief documentation to Wiki in the vein of Nested...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 10, 2012
  1. @ehoch

    Allow Modal Config Section

    ehoch authored
This page is out of date. Refresh to see the latest.
View
11 app/helpers/rails_admin/form_builder.rb
@@ -10,7 +10,16 @@ def generate(options = {})
:model_config => @template.instance_variable_get(:@model_config),
:nested_in => false
})
- groups = options[:model_config].send(options[:nested_in] ? :nested : options[:action]).with(:form => self, :object => @object, :view => @template).visible_groups
+
+ if options[:nested_in]
+ action = :nested
+ elsif @template.request.format == 'text/javascript'
+ action = :modal
+ else
+ action = options[:action]
+ end
+
+ groups = options[:model_config].send(action).with(:form => self, :object => @object, :view => @template).visible_groups
object_infos +
groups.map do |fieldset|
View
1  lib/rails_admin/config/sections.rb
@@ -4,6 +4,7 @@
require 'rails_admin/config/sections/update'
require 'rails_admin/config/sections/create'
require 'rails_admin/config/sections/nested'
+require 'rails_admin/config/sections/modal'
require 'rails_admin/config/sections/list'
require 'rails_admin/config/sections/export'
require 'rails_admin/config/sections/show'
View
10 lib/rails_admin/config/sections/modal.rb
@@ -0,0 +1,10 @@
+require 'rails_admin/config/sections/edit'
+
+module RailsAdmin
+ module Config
+ module Sections
+ class Modal < RailsAdmin::Config::Sections::Edit
+ end
+ end
+ end
+end
Something went wrong with that request. Please try again.