Add mapping to citext columns
This commit is contained in:
parent
5943e07fc4
commit
213f766953
|
@ -1,3 +1,6 @@
|
||||||
|
### enhancements
|
||||||
|
* Add mapping to `citext` columns.
|
||||||
|
|
||||||
### bug fix
|
### bug fix
|
||||||
* Fix `uuid` input to generate proper input[type=text].
|
* Fix `uuid` input to generate proper input[type=text].
|
||||||
|
|
||||||
|
|
|
@ -17,19 +17,20 @@ module SimpleForm
|
||||||
extend MapType
|
extend MapType
|
||||||
include SimpleForm::Inputs
|
include SimpleForm::Inputs
|
||||||
|
|
||||||
map_type :text, to: SimpleForm::Inputs::TextInput
|
map_type :text, to: SimpleForm::Inputs::TextInput
|
||||||
map_type :file, to: SimpleForm::Inputs::FileInput
|
map_type :file, to: SimpleForm::Inputs::FileInput
|
||||||
map_type :string, :email, :search, :tel, :url, :uuid, to: SimpleForm::Inputs::StringInput
|
map_type :string, :email, :search, :tel, :url, to: SimpleForm::Inputs::StringInput
|
||||||
map_type :password, to: SimpleForm::Inputs::PasswordInput
|
map_type :citext, :uuid, to: SimpleForm::Inputs::StringInput
|
||||||
map_type :integer, :decimal, :float, to: SimpleForm::Inputs::NumericInput
|
map_type :password, to: SimpleForm::Inputs::PasswordInput
|
||||||
map_type :range, to: SimpleForm::Inputs::RangeInput
|
map_type :integer, :decimal, :float, to: SimpleForm::Inputs::NumericInput
|
||||||
map_type :check_boxes, to: SimpleForm::Inputs::CollectionCheckBoxesInput
|
map_type :range, to: SimpleForm::Inputs::RangeInput
|
||||||
map_type :radio_buttons, to: SimpleForm::Inputs::CollectionRadioButtonsInput
|
map_type :check_boxes, to: SimpleForm::Inputs::CollectionCheckBoxesInput
|
||||||
map_type :select, to: SimpleForm::Inputs::CollectionSelectInput
|
map_type :radio_buttons, to: SimpleForm::Inputs::CollectionRadioButtonsInput
|
||||||
map_type :grouped_select, to: SimpleForm::Inputs::GroupedCollectionSelectInput
|
map_type :select, to: SimpleForm::Inputs::CollectionSelectInput
|
||||||
map_type :date, :time, :datetime, to: SimpleForm::Inputs::DateTimeInput
|
map_type :grouped_select, to: SimpleForm::Inputs::GroupedCollectionSelectInput
|
||||||
map_type :country, :time_zone, to: SimpleForm::Inputs::PriorityInput
|
map_type :date, :time, :datetime, to: SimpleForm::Inputs::DateTimeInput
|
||||||
map_type :boolean, to: SimpleForm::Inputs::BooleanInput
|
map_type :country, :time_zone, to: SimpleForm::Inputs::PriorityInput
|
||||||
|
map_type :boolean, to: SimpleForm::Inputs::BooleanInput
|
||||||
|
|
||||||
def self.discovery_cache
|
def self.discovery_cache
|
||||||
@discovery_cache ||= {}
|
@discovery_cache ||= {}
|
||||||
|
|
|
@ -17,7 +17,7 @@ module SimpleForm
|
||||||
private
|
private
|
||||||
|
|
||||||
def postgresql_type?
|
def postgresql_type?
|
||||||
input_type == :uuid
|
input_type == :uuid || input_type == :citext
|
||||||
end
|
end
|
||||||
|
|
||||||
def string?
|
def string?
|
||||||
|
|
|
@ -126,6 +126,11 @@ class FormBuilderTest < ActionView::TestCase
|
||||||
assert_select 'form input#user_credit_limit.numeric.decimal'
|
assert_select 'form input#user_credit_limit.numeric.decimal'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'builder generates text fields for citext columns' do
|
||||||
|
with_form_for @user, :citext
|
||||||
|
assert_select 'form input[type=text]#user_citext.string.citext'
|
||||||
|
end
|
||||||
|
|
||||||
test 'builder generates text fields for uuid columns' do
|
test 'builder generates text fields for uuid columns' do
|
||||||
with_form_for @user, :uuid
|
with_form_for @user, :uuid
|
||||||
assert_select 'form input[type=text]#user_uuid.string.uuid'
|
assert_select 'form input[type=text]#user_uuid.string.uuid'
|
||||||
|
|
|
@ -74,7 +74,7 @@ class User
|
||||||
:avatar, :home_picture, :email, :status, :residence_country, :phone_number,
|
:avatar, :home_picture, :email, :status, :residence_country, :phone_number,
|
||||||
:post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender,
|
:post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender,
|
||||||
:extra_special_company_id, :pictures, :picture_ids, :special_pictures,
|
:extra_special_company_id, :pictures, :picture_ids, :special_pictures,
|
||||||
:special_picture_ids, :uuid
|
:special_picture_ids, :uuid, :citext
|
||||||
|
|
||||||
def self.build(extra_attributes = {})
|
def self.build(extra_attributes = {})
|
||||||
attributes = {
|
attributes = {
|
||||||
|
@ -126,6 +126,7 @@ class User
|
||||||
when :action then :string
|
when :action then :string
|
||||||
when :credit_card then :string
|
when :credit_card then :string
|
||||||
when :uuid then :uuid
|
when :uuid then :uuid
|
||||||
|
when :citext then :citext
|
||||||
end
|
end
|
||||||
Column.new(attribute, column_type, limit)
|
Column.new(attribute, column_type, limit)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue