small cleaning in filter_value_component
This commit is contained in:
parent
60947f2b97
commit
5532a8a48f
2 changed files with 14 additions and 10 deletions
|
@ -7,25 +7,23 @@ class Instructeurs::ColumnFilterValueComponent < ApplicationComponent
|
||||||
@column = column
|
@column = column
|
||||||
end
|
end
|
||||||
|
|
||||||
def column_type = column.present? ? column.type : :text
|
|
||||||
|
|
||||||
def call
|
def call
|
||||||
if column_type.in?([:enum, :enums, :boolean])
|
if column.nil?
|
||||||
select_tag :filter,
|
tag.input(id: 'value', class: 'fr-input', disabled: true)
|
||||||
|
elsif column.type.in?([:enum, :enums, :boolean])
|
||||||
|
select_tag 'filters[][filter]',
|
||||||
options_for_select(column.options_for_select),
|
options_for_select(column.options_for_select),
|
||||||
id: 'value',
|
id: 'value',
|
||||||
name: "filters[][filter]",
|
|
||||||
class: 'fr-select',
|
class: 'fr-select',
|
||||||
data: { no_autosubmit: true },
|
data: { no_autosubmit: true },
|
||||||
required: true
|
required: true
|
||||||
else
|
else
|
||||||
tag.input(
|
tag.input(
|
||||||
class: 'fr-input',
|
|
||||||
id: 'value',
|
|
||||||
type:,
|
|
||||||
name: "filters[][filter]",
|
name: "filters[][filter]",
|
||||||
|
id: 'value',
|
||||||
|
class: 'fr-input',
|
||||||
|
type:,
|
||||||
maxlength: FilteredColumn::FILTERS_VALUE_MAX_LENGTH,
|
maxlength: FilteredColumn::FILTERS_VALUE_MAX_LENGTH,
|
||||||
disabled: column.nil? ? true : false,
|
|
||||||
data: { no_autosubmit: true },
|
data: { no_autosubmit: true },
|
||||||
required: true
|
required: true
|
||||||
)
|
)
|
||||||
|
@ -35,7 +33,7 @@ class Instructeurs::ColumnFilterValueComponent < ApplicationComponent
|
||||||
private
|
private
|
||||||
|
|
||||||
def type
|
def type
|
||||||
case column_type
|
case column.type
|
||||||
when :datetime, :date
|
when :datetime, :date
|
||||||
'date'
|
'date'
|
||||||
when :integer, :decimal
|
when :integer, :decimal
|
||||||
|
|
|
@ -17,4 +17,10 @@ describe Instructeurs::ColumnFilterValueComponent, type: :component do
|
||||||
|
|
||||||
it { expect(page).to have_selector('input[name="filters[][filter]"][type="date"]') }
|
it { expect(page).to have_selector('input[name="filters[][filter]"][type="date"]') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'the column empty case' do
|
||||||
|
let(:column) { nil }
|
||||||
|
|
||||||
|
it { expect(page).to have_selector('input[disabled]') }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue