Browse Source

Fixes #4055 - Migrations (Zendesk, Kayako) currently do not support custom dropdown multi-select fields.

Dominik Klein 2 years ago
parent
commit
a6b6f391ea

+ 0 - 30
.rubocop/todo.rspec.yml

@@ -412,16 +412,6 @@ RSpec/MessageSpies:
     - 'spec/lib/import/otrs/ticket_spec.rb'
     - 'spec/lib/import/otrs/user_factory_spec.rb'
     - 'spec/lib/import/otrs/user_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/base_examples.rb'
-    - 'spec/lib/import/zendesk/object_attribute/checkbox_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/date_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/decimal_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/dropdown_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/integer_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/regexp_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/tagger_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/text_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/textarea_spec.rb'
     - 'spec/lib/ldap/group_spec.rb'
     - 'spec/lib/ldap/guid_spec.rb'
     - 'spec/lib/ldap/user_spec.rb'
@@ -483,16 +473,6 @@ RSpec/MultipleExpectations:
     - 'spec/lib/import/otrs/priority_factory_spec.rb'
     - 'spec/lib/import/otrs/requester_spec.rb'
     - 'spec/lib/import/otrs/state_factory_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/base_examples.rb'
-    - 'spec/lib/import/zendesk/object_attribute/checkbox_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/date_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/decimal_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/dropdown_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/integer_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/regexp_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/tagger_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/text_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/textarea_spec.rb'
     - 'spec/lib/ldap/group_spec.rb'
     - 'spec/lib/ldap/guid_spec.rb'
     - 'spec/lib/ldap/user_spec.rb'
@@ -660,16 +640,6 @@ RSpec/VerifiedDoubles:
     - 'spec/db/migrate/issue_2460_fix_corrupted_twitter_ids_spec.rb'
     - 'spec/jobs/communicate_twitter_job_spec.rb'
     - 'spec/lib/external_sync_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/base_examples.rb'
-    - 'spec/lib/import/zendesk/object_attribute/checkbox_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/date_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/decimal_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/dropdown_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/integer_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/regexp_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/tagger_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/text_spec.rb'
-    - 'spec/lib/import/zendesk/object_attribute/textarea_spec.rb'
     - 'spec/lib/ldap_spec.rb'
     - 'spec/lib/sequencer/sequence/import/ldap/users_spec.rb'
     - 'spec/lib/sequencer/unit/import/zendesk/sub_sequence/base_examples.rb'

+ 0 - 79
lib/import/zendesk/object_attribute/base.rb

@@ -1,79 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Base
-
-        def initialize(object, name, attribute)
-
-          initialize_data_option(attribute)
-          init_callback(attribute)
-
-          add(object, name, attribute)
-        end
-
-        private
-
-        def init_callback(_attribute); end
-
-        def add(object, name, attribute)
-          ObjectManager::Attribute.add(attribute_config(object, name, attribute))
-          ObjectManager::Attribute.migration_execute(false)
-        rescue
-          # rubocop:disable Style/SpecialGlobalVars
-          raise $!, "Problem with ObjectManager Attribute '#{name}': #{$!}", $!.backtrace
-          # rubocop:enable Style/SpecialGlobalVars
-        end
-
-        def attribute_config(object, name, attribute)
-          {
-            object:        object.to_s,
-            name:          name,
-            display:       attribute.title,
-            data_type:     data_type(attribute),
-            data_option:   @data_option,
-            editable:      !attribute.removable,
-            active:        attribute.active,
-            screens:       screens(attribute),
-            position:      attribute.position,
-            created_by_id: 1,
-            updated_by_id: 1,
-          }
-        end
-
-        def screens(attribute)
-          config = {
-            view: {
-              '-all-' => {
-                shown: true,
-              },
-            }
-          }
-
-          return config if !attribute.visible_in_portal && attribute.required_in_portal
-
-          {
-            edit: {
-              Customer: {
-                shown: attribute.visible_in_portal,
-                null:  !attribute.required_in_portal,
-              },
-            }.merge(config)
-          }
-        end
-
-        def initialize_data_option(attribute)
-          @data_option = {
-            null: !attribute.required,
-            note: attribute.description,
-          }
-        end
-
-        def data_type(attribute)
-          attribute.type
-        end
-      end
-    end
-  end
-end

+ 0 - 26
lib/import/zendesk/object_attribute/checkbox.rb

@@ -1,26 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Checkbox < Import::Zendesk::ObjectAttribute::Base
-
-        def init_callback(_object_attribte)
-          @data_option.merge!(
-            default: false,
-            options: {
-              true  => 'yes',
-              false => 'no',
-            },
-          )
-        end
-
-        private
-
-        def data_type(_attribute)
-          'boolean'
-        end
-      end
-    end
-  end
-end

+ 0 - 17
lib/import/zendesk/object_attribute/date.rb

@@ -1,17 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Date < Import::Zendesk::ObjectAttribute::Base
-        def init_callback(_object_attribte)
-          @data_option.merge!(
-            future: true,
-            past:   true,
-            diff:   0,
-          )
-        end
-      end
-    end
-  end
-end

+ 0 - 10
lib/import/zendesk/object_attribute/decimal.rb

@@ -1,10 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Decimal < Import::Zendesk::ObjectAttribute::Text
-      end
-    end
-  end
-end

+ 0 - 10
lib/import/zendesk/object_attribute/dropdown.rb

@@ -1,10 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Dropdown < Import::Zendesk::ObjectAttribute::Select
-      end
-    end
-  end
-end

+ 0 - 23
lib/import/zendesk/object_attribute/integer.rb

@@ -1,23 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Integer < Import::Zendesk::ObjectAttribute::Base
-
-        def init_callback(_object_attribte)
-          @data_option.merge!(
-            min: 0,
-            max: 999_999_999,
-          )
-        end
-
-        private
-
-        def data_type(_attribute)
-          'integer'
-        end
-      end
-    end
-  end
-end

+ 0 - 24
lib/import/zendesk/object_attribute/regexp.rb

@@ -1,24 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Regexp < Import::Zendesk::ObjectAttribute::Base
-
-        def init_callback(object_attribte)
-          @data_option.merge!(
-            type:      'text',
-            maxlength: 255,
-            regex:     object_attribte.regexp_for_validation,
-          )
-        end
-
-        private
-
-        def data_type(_attribute)
-          'input'
-        end
-      end
-    end
-  end
-end

+ 0 - 31
lib/import/zendesk/object_attribute/select.rb

@@ -1,31 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Select < Import::Zendesk::ObjectAttribute::Base
-
-        def init_callback(object_attribte)
-          @data_option.merge!(
-            default: '',
-            options: options(object_attribte),
-          )
-        end
-
-        private
-
-        def data_type(_attribute)
-          'select'
-        end
-
-        def options(object_attribte)
-          result = {}
-          object_attribte.custom_field_options.each do |entry|
-            result[ entry['value'] ] = entry['name']
-          end
-          result
-        end
-      end
-    end
-  end
-end

+ 0 - 10
lib/import/zendesk/object_attribute/tagger.rb

@@ -1,10 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module Import
-  class Zendesk
-    module ObjectAttribute
-      class Tagger < Import::Zendesk::ObjectAttribute::Select
-      end
-    end
-  end
-end

Some files were not shown because too many files changed in this diff