From d6bc129af4cf669df662c6179a087ac93ac5e62e Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Wed, 23 Aug 2017 16:41:01 +0200 Subject: [PATCH] Fixed bug #1175: DynamicFields imported from OTRS are mandatory and stop input forms from submitting. --- lib/import/otrs/dynamic_field/checkbox.rb | 2 +- lib/import/otrs/dynamic_field/date.rb | 2 +- lib/import/otrs/dynamic_field/date_time.rb | 2 +- lib/import/otrs/dynamic_field/dropdown.rb | 11 ++++++----- lib/import/otrs/dynamic_field/multiselect.rb | 11 ++++++----- lib/import/otrs/dynamic_field/text.rb | 2 +- lib/import/otrs/dynamic_field/text_area.rb | 2 +- spec/lib/import/otrs/dynamic_field/checkbox_spec.rb | 2 +- spec/lib/import/otrs/dynamic_field/date_spec.rb | 2 +- spec/lib/import/otrs/dynamic_field/date_time_spec.rb | 2 +- spec/lib/import/otrs/dynamic_field/dropdown_spec.rb | 5 +++-- .../lib/import/otrs/dynamic_field/multiselect_spec.rb | 5 +++-- spec/lib/import/otrs/dynamic_field/text_area_spec.rb | 2 +- spec/lib/import/otrs/dynamic_field/text_spec.rb | 2 +- 14 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lib/import/otrs/dynamic_field/checkbox.rb b/lib/import/otrs/dynamic_field/checkbox.rb index 8666986ac..33044c8c6 100644 --- a/lib/import/otrs/dynamic_field/checkbox.rb +++ b/lib/import/otrs/dynamic_field/checkbox.rb @@ -11,7 +11,7 @@ module Import true => 'Yes', false => 'No', }, - null: false, + null: true, translate: true, } ) diff --git a/lib/import/otrs/dynamic_field/date.rb b/lib/import/otrs/dynamic_field/date.rb index 6be4508bd..7d8d71133 100644 --- a/lib/import/otrs/dynamic_field/date.rb +++ b/lib/import/otrs/dynamic_field/date.rb @@ -14,7 +14,7 @@ module Import future: dynamic_field['Config']['YearsInFuture'] != '0', past: dynamic_field['Config']['YearsInPast'] != '0', diff: dynamic_field['Config']['DefaultValue'].to_i / 60 / 60 / 24, - null: false, + null: true, } ) end diff --git a/lib/import/otrs/dynamic_field/date_time.rb b/lib/import/otrs/dynamic_field/date_time.rb index 997a4ac49..d9a7761b1 100644 --- a/lib/import/otrs/dynamic_field/date_time.rb +++ b/lib/import/otrs/dynamic_field/date_time.rb @@ -14,7 +14,7 @@ module Import future: dynamic_field['Config']['YearsInFuture'] != '0', past: dynamic_field['Config']['YearsInPast'] != '0', diff: dynamic_field['Config']['DefaultValue'].to_i / 60 / 60, - null: false, + null: true, } ) end diff --git a/lib/import/otrs/dynamic_field/dropdown.rb b/lib/import/otrs/dynamic_field/dropdown.rb index a6d0d8c5a..6af21498b 100644 --- a/lib/import/otrs/dynamic_field/dropdown.rb +++ b/lib/import/otrs/dynamic_field/dropdown.rb @@ -6,11 +6,12 @@ module Import @attribute_config.merge!( data_type: 'select', data_option: { - default: '', - multiple: false, - options: dynamic_field['Config']['PossibleValues'], - null: dynamic_field['Config']['PossibleNone'] == '1', - translate: dynamic_field['Config']['TranslatableValues'] == '1', + default: '', + multiple: false, + options: dynamic_field['Config']['PossibleValues'], + nulloption: dynamic_field['Config']['PossibleNone'] == '1', + null: true, + translate: dynamic_field['Config']['TranslatableValues'] == '1', } ) end diff --git a/lib/import/otrs/dynamic_field/multiselect.rb b/lib/import/otrs/dynamic_field/multiselect.rb index 3710fc7d0..f1c13ef06 100644 --- a/lib/import/otrs/dynamic_field/multiselect.rb +++ b/lib/import/otrs/dynamic_field/multiselect.rb @@ -6,11 +6,12 @@ module Import @attribute_config.merge!( data_type: 'select', data_option: { - default: '', - multiple: true, - options: dynamic_field['Config']['PossibleValues'], - null: dynamic_field['Config']['PossibleNone'] == '1', - translate: dynamic_field['Config']['TranslatableValues'] == '1', + default: '', + multiple: true, + options: dynamic_field['Config']['PossibleValues'], + nulloption: dynamic_field['Config']['PossibleNone'] == '1', + null: true, + translate: dynamic_field['Config']['TranslatableValues'] == '1', } ) end diff --git a/lib/import/otrs/dynamic_field/text.rb b/lib/import/otrs/dynamic_field/text.rb index cafcb7f41..a5067ba02 100644 --- a/lib/import/otrs/dynamic_field/text.rb +++ b/lib/import/otrs/dynamic_field/text.rb @@ -9,7 +9,7 @@ module Import default: dynamic_field['Config']['DefaultValue'], type: 'text', maxlength: 255, - null: false, + null: true, } ) end diff --git a/lib/import/otrs/dynamic_field/text_area.rb b/lib/import/otrs/dynamic_field/text_area.rb index e4b71ce72..b25d54ce2 100644 --- a/lib/import/otrs/dynamic_field/text_area.rb +++ b/lib/import/otrs/dynamic_field/text_area.rb @@ -8,7 +8,7 @@ module Import data_option: { default: dynamic_field['Config']['DefaultValue'], rows: dynamic_field['Config']['Rows'], - null: false, + null: true, } ) end diff --git a/spec/lib/import/otrs/dynamic_field/checkbox_spec.rb b/spec/lib/import/otrs/dynamic_field/checkbox_spec.rb index 658467d92..000ecc5a1 100644 --- a/spec/lib/import/otrs/dynamic_field/checkbox_spec.rb +++ b/spec/lib/import/otrs/dynamic_field/checkbox_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Import::OTRS::DynamicField::Checkbox do true => 'Yes', false => 'No' }, - null: false, + null: true, translate: true } } diff --git a/spec/lib/import/otrs/dynamic_field/date_spec.rb b/spec/lib/import/otrs/dynamic_field/date_spec.rb index 2fa688a37..0de5e4cb4 100644 --- a/spec/lib/import/otrs/dynamic_field/date_spec.rb +++ b/spec/lib/import/otrs/dynamic_field/date_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Import::OTRS::DynamicField::Date do future: false, past: false, diff: 0, - null: false + null: true } } diff --git a/spec/lib/import/otrs/dynamic_field/date_time_spec.rb b/spec/lib/import/otrs/dynamic_field/date_time_spec.rb index 1fc1c7601..b2ac81093 100644 --- a/spec/lib/import/otrs/dynamic_field/date_time_spec.rb +++ b/spec/lib/import/otrs/dynamic_field/date_time_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Import::OTRS::DynamicField::DateTime do future: true, past: true, diff: 72, - null: false + null: true } } diff --git a/spec/lib/import/otrs/dynamic_field/dropdown_spec.rb b/spec/lib/import/otrs/dynamic_field/dropdown_spec.rb index 75b7bce81..5cc0f1365 100644 --- a/spec/lib/import/otrs/dynamic_field/dropdown_spec.rb +++ b/spec/lib/import/otrs/dynamic_field/dropdown_spec.rb @@ -32,8 +32,9 @@ RSpec.describe Import::OTRS::DynamicField::Dropdown do 'Köln' => 'Köln', 'Berlin' => 'Berlin' }, - null: true, - translate: false + nulloption: true, + null: true, + translate: false } } diff --git a/spec/lib/import/otrs/dynamic_field/multiselect_spec.rb b/spec/lib/import/otrs/dynamic_field/multiselect_spec.rb index 4b7e0e1c8..be8ca129b 100644 --- a/spec/lib/import/otrs/dynamic_field/multiselect_spec.rb +++ b/spec/lib/import/otrs/dynamic_field/multiselect_spec.rb @@ -32,8 +32,9 @@ RSpec.describe Import::OTRS::DynamicField::Multiselect do 'Köln' => 'Köln', 'Berlin' => 'Berlin' }, - null: false, - translate: false + nulloption: false, + null: true, + translate: false } } diff --git a/spec/lib/import/otrs/dynamic_field/text_area_spec.rb b/spec/lib/import/otrs/dynamic_field/text_area_spec.rb index fa8e430af..18199a7ca 100644 --- a/spec/lib/import/otrs/dynamic_field/text_area_spec.rb +++ b/spec/lib/import/otrs/dynamic_field/text_area_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Import::OTRS::DynamicField::TextArea do data_option: { default: '', rows: '20', - null: false + null: true } } diff --git a/spec/lib/import/otrs/dynamic_field/text_spec.rb b/spec/lib/import/otrs/dynamic_field/text_spec.rb index 34201654b..1b0919958 100644 --- a/spec/lib/import/otrs/dynamic_field/text_spec.rb +++ b/spec/lib/import/otrs/dynamic_field/text_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Import::OTRS::DynamicField::Text do default: '', type: 'text', maxlength: 255, - null: false + null: true } }