Skip to content

Commit

Permalink
Revert "Merge pull request #382 from semaperepelitsa/grouped_collection"
Browse files Browse the repository at this point in the history
This reverts commit 5b2f067, reversing
changes made to 9ff998f.

This is going to be applied to master only, sorry.
  • Loading branch information
carlosantoniodasilva committed Jan 24, 2012
1 parent 5b2f067 commit c7c8461
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 74 deletions.
1 change: 0 additions & 1 deletion lib/simple_form/form_builder.rb
Expand Up @@ -12,7 +12,6 @@ class FormBuilder < ActionView::Helpers::FormBuilder
map_type :integer, :decimal, :float, :to => SimpleForm::Inputs::NumericInput
map_type :range, :to => SimpleForm::Inputs::RangeInput
map_type :select, :radio, :check_boxes, :to => SimpleForm::Inputs::CollectionInput
map_type :grouped_select, :to => SimpleForm::Inputs::GroupedCollectionInput
map_type :date, :time, :datetime, :to => SimpleForm::Inputs::DateTimeInput
map_type :country, :time_zone, :to => SimpleForm::Inputs::PriorityInput
map_type :boolean, :to => SimpleForm::Inputs::BooleanInput
Expand Down
27 changes: 13 additions & 14 deletions lib/simple_form/inputs.rb
@@ -1,18 +1,17 @@
module SimpleForm
module Inputs
autoload :Base, 'simple_form/inputs/base'
autoload :BlockInput, 'simple_form/inputs/block_input'
autoload :BooleanInput, 'simple_form/inputs/boolean_input'
autoload :CollectionInput, 'simple_form/inputs/collection_input'
autoload :GroupedCollectionInput, 'simple_form/inputs/grouped_collection_input'
autoload :DateTimeInput, 'simple_form/inputs/date_time_input'
autoload :FileInput, 'simple_form/inputs/file_input'
autoload :HiddenInput, 'simple_form/inputs/hidden_input'
autoload :NumericInput, 'simple_form/inputs/numeric_input'
autoload :PasswordInput, 'simple_form/inputs/password_input'
autoload :PriorityInput, 'simple_form/inputs/priority_input'
autoload :RangeInput, 'simple_form/inputs/range_input'
autoload :StringInput, 'simple_form/inputs/string_input'
autoload :TextInput, 'simple_form/inputs/text_input'
autoload :Base, 'simple_form/inputs/base'
autoload :BlockInput, 'simple_form/inputs/block_input'
autoload :BooleanInput, 'simple_form/inputs/boolean_input'
autoload :CollectionInput, 'simple_form/inputs/collection_input'
autoload :DateTimeInput, 'simple_form/inputs/date_time_input'
autoload :FileInput, 'simple_form/inputs/file_input'
autoload :HiddenInput, 'simple_form/inputs/hidden_input'
autoload :NumericInput, 'simple_form/inputs/numeric_input'
autoload :PasswordInput, 'simple_form/inputs/password_input'
autoload :PriorityInput, 'simple_form/inputs/priority_input'
autoload :RangeInput, 'simple_form/inputs/range_input'
autoload :StringInput, 'simple_form/inputs/string_input'
autoload :TextInput, 'simple_form/inputs/text_input'
end
end
8 changes: 5 additions & 3 deletions lib/simple_form/inputs/collection_input.rb
Expand Up @@ -58,7 +58,9 @@ def detect_collection_methods
[label, value]
end

def detect_common_display_methods(collection_classes = detect_collection_classes)
def detect_common_display_methods
collection_classes = detect_collection_classes

if collection_classes.include?(Array)
{ :label => :first, :value => :last }
elsif collection_includes_basic_objects?(collection_classes)
Expand All @@ -71,8 +73,8 @@ def detect_common_display_methods(collection_classes = detect_collection_classes
end
end

def detect_collection_classes(some_collection = collection)
some_collection.map { |e| e.class }.uniq
def detect_collection_classes
collection.map { |e| e.class }.uniq
end

def collection_includes_basic_objects?(collection_classes)
Expand Down
38 changes: 0 additions & 38 deletions lib/simple_form/inputs/grouped_collection_input.rb

This file was deleted.

18 changes: 0 additions & 18 deletions test/inputs_test.rb
Expand Up @@ -976,24 +976,6 @@ def with_input_for(object, attribute_name, type, options={})
assert_no_select 'select[required]'
end

# GroupedCollectionInput
test 'input should have grouped options' do
with_input_for @user, :name, :grouped_select,
:collection => [['Authors', ['Jose', 'Carlos']], ['General', ['Bob', 'John']]],
:group_method => :last
assert_select 'select.grouped_select#user_name' do
assert_select 'optgroup[label=Authors]' do
assert_select 'option', 'Jose'
assert_select 'option', 'Carlos'
end

assert_select 'optgroup[label=General]' do
assert_select 'option', 'Bob'
assert_select 'option', 'John'
end
end
end

# With no object
test 'input should be generated properly when object is not present' do
with_input_for :project, :name, :string
Expand Down

4 comments on commit c7c8461

@brutuscat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Isn't it ready for this branch? I mean it works right?

@rafaelfranca
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch will accept only bug fixes. New features need to be added in the master branch. So this feature is only available in SimpleForm >= 2.0.0

@brutuscat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks. Anything to read about how to upgrade to 2.0?

@rafaelfranca
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.