2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-03-23 14:26:09 +00:00
|
|
|
FactoryBot.define do
|
2020-11-24 16:20:57 +00:00
|
|
|
factory :object_manager_attribute, class: 'ObjectManager::Attribute' do
|
2020-02-20 08:44:50 +00:00
|
|
|
transient do
|
|
|
|
object_name { 'Ticket' }
|
|
|
|
additional_data_options { nil }
|
2021-08-17 16:37:16 +00:00
|
|
|
default { nil }
|
2020-02-20 08:44:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
object_lookup_id { ObjectLookup.by_name(object_name) }
|
2019-03-27 09:01:36 +00:00
|
|
|
sequence(:name) { |n| "internal_name#{n}" }
|
|
|
|
sequence(:display) { |n| "Display Name #{n}" }
|
|
|
|
data_option_new { {} }
|
|
|
|
editable { true }
|
|
|
|
active { true }
|
|
|
|
add_attribute(:to_create) { true }
|
|
|
|
to_migrate { true }
|
|
|
|
to_delete { false }
|
|
|
|
to_config { false }
|
|
|
|
position { 15 }
|
|
|
|
updated_by_id { 1 }
|
|
|
|
created_by_id { 1 }
|
|
|
|
screens do
|
2018-03-23 14:26:09 +00:00
|
|
|
{
|
|
|
|
'create_top' => {
|
|
|
|
'-all-' => {
|
|
|
|
'null' => false
|
|
|
|
}
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'edit' => {}
|
2018-03-23 14:26:09 +00:00
|
|
|
}
|
|
|
|
end
|
2020-02-20 08:44:50 +00:00
|
|
|
|
|
|
|
callback(:after_stub, :before_create) do |object, context|
|
|
|
|
next if context.additional_data_options.blank?
|
|
|
|
|
|
|
|
object.data_option ||= {}
|
|
|
|
object.data_option.merge! context.additional_data_options
|
|
|
|
end
|
2018-03-23 14:26:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :object_manager_attribute_text, parent: :object_manager_attribute do
|
2019-03-27 09:01:36 +00:00
|
|
|
data_type { 'input' }
|
2018-03-23 14:26:09 +00:00
|
|
|
data_option do
|
|
|
|
{
|
|
|
|
'type' => 'text',
|
|
|
|
'maxlength' => 200,
|
|
|
|
'null' => true,
|
|
|
|
'translate' => false,
|
2021-08-17 16:37:16 +00:00
|
|
|
'default' => default || '',
|
2018-03-23 14:26:09 +00:00
|
|
|
'options' => {},
|
|
|
|
'relation' => '',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-20 09:43:35 +00:00
|
|
|
factory :object_manager_attribute_textarea, parent: :object_manager_attribute do
|
|
|
|
data_type { 'textarea' }
|
|
|
|
data_option do
|
|
|
|
{
|
|
|
|
'type' => 'textarea',
|
|
|
|
'maxlength' => 255,
|
|
|
|
'null' => true,
|
|
|
|
'translate' => false,
|
|
|
|
'default' => default || '',
|
|
|
|
'options' => {},
|
|
|
|
'relation' => '',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-31 13:14:26 +00:00
|
|
|
factory :object_manager_attribute_integer, parent: :object_manager_attribute do
|
2019-03-27 09:01:36 +00:00
|
|
|
data_type { 'integer' }
|
2018-10-31 13:14:26 +00:00
|
|
|
data_option do
|
|
|
|
{
|
2021-08-17 16:37:16 +00:00
|
|
|
'default' => default || 0,
|
2018-12-19 17:31:51 +00:00
|
|
|
'min' => 0,
|
|
|
|
'max' => 9999,
|
2018-10-31 13:14:26 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-25 12:30:12 +00:00
|
|
|
factory :object_manager_attribute_boolean, parent: :object_manager_attribute do
|
|
|
|
data_type { 'boolean' }
|
|
|
|
data_option do
|
|
|
|
{
|
2021-08-17 16:37:16 +00:00
|
|
|
default: default || false,
|
2021-05-25 12:30:12 +00:00
|
|
|
options: {
|
|
|
|
true => 'yes',
|
|
|
|
false => 'no',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-26 11:08:18 +00:00
|
|
|
factory :object_manager_attribute_date, parent: :object_manager_attribute do
|
2019-03-27 09:01:36 +00:00
|
|
|
name { 'date_attribute' }
|
|
|
|
data_type { 'date' }
|
2018-09-26 11:08:18 +00:00
|
|
|
data_option do
|
|
|
|
{
|
2021-08-17 16:37:16 +00:00
|
|
|
'diff' => default || 24,
|
2019-03-14 10:06:49 +00:00
|
|
|
'null' => true,
|
2018-09-26 11:08:18 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :object_manager_attribute_datetime, parent: :object_manager_attribute do
|
2019-03-27 09:01:36 +00:00
|
|
|
name { 'datetime_attribute' }
|
|
|
|
data_type { 'datetime' }
|
2018-09-26 11:08:18 +00:00
|
|
|
data_option do
|
|
|
|
{
|
|
|
|
'future' => true,
|
2018-12-19 17:31:51 +00:00
|
|
|
'past' => true,
|
2021-08-17 16:37:16 +00:00
|
|
|
'diff' => default || 24,
|
2018-12-19 17:31:51 +00:00
|
|
|
'null' => true,
|
2018-09-26 11:08:18 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-23 14:26:09 +00:00
|
|
|
factory :object_manager_attribute_select, parent: :object_manager_attribute do
|
2019-03-27 09:01:36 +00:00
|
|
|
data_type { 'select' }
|
2018-03-23 14:26:09 +00:00
|
|
|
data_option do
|
|
|
|
{
|
2021-08-17 16:37:16 +00:00
|
|
|
'default' => default || '',
|
2018-12-19 17:31:51 +00:00
|
|
|
'options' => {
|
2018-03-23 14:26:09 +00:00
|
|
|
'key_1' => 'value_1',
|
|
|
|
'key_2' => 'value_2',
|
|
|
|
'key_3' => 'value_3',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'relation' => '',
|
2018-03-23 14:26:09 +00:00
|
|
|
'nulloption' => true,
|
|
|
|
'multiple' => false,
|
|
|
|
'null' => true,
|
|
|
|
'translate' => true,
|
|
|
|
'maxlength' => 255
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2018-03-29 11:46:15 +00:00
|
|
|
|
|
|
|
factory :object_manager_attribute_tree_select, parent: :object_manager_attribute do
|
2019-03-27 09:01:36 +00:00
|
|
|
data_type { 'tree_select' }
|
2018-03-29 11:46:15 +00:00
|
|
|
data_option do
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
'options' => [
|
2018-03-29 11:46:15 +00:00
|
|
|
{
|
|
|
|
'name' => 'Incident',
|
|
|
|
'value' => 'Incident',
|
|
|
|
'children' => [
|
|
|
|
{
|
|
|
|
'name' => 'Hardware',
|
|
|
|
'value' => 'Incident::Hardware',
|
|
|
|
'children' => [
|
|
|
|
{
|
|
|
|
'name' => 'Monitor',
|
|
|
|
'value' => 'Incident::Hardware::Monitor'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Mouse',
|
|
|
|
'value' => 'Incident::Hardware::Mouse'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Keyboard',
|
|
|
|
'value' => 'Incident::Hardware::Keyboard'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Softwareproblem',
|
|
|
|
'value' => 'Incident::Softwareproblem',
|
|
|
|
'children' => [
|
|
|
|
{
|
|
|
|
'name' => 'CRM',
|
|
|
|
'value' => 'Incident::Softwareproblem::CRM'
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
'name' => 'EDI',
|
2018-03-29 11:46:15 +00:00
|
|
|
'value' => 'Incident::Softwareproblem::EDI'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'SAP',
|
|
|
|
'value' => 'Incident::Softwareproblem::SAP',
|
|
|
|
'children' => [
|
|
|
|
{
|
|
|
|
'name' => 'Authentication',
|
|
|
|
'value' => 'Incident::Softwareproblem::SAP::Authentication'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Not reachable',
|
|
|
|
'value' => 'Incident::Softwareproblem::SAP::Not reachable'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'MS Office',
|
|
|
|
'value' => 'Incident::Softwareproblem::MS Office',
|
|
|
|
'children' => [
|
|
|
|
{
|
|
|
|
'name' => 'Excel',
|
|
|
|
'value' => 'Incident::Softwareproblem::MS Office::Excel'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'PowerPoint',
|
|
|
|
'value' => 'Incident::Softwareproblem::MS Office::PowerPoint'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Word',
|
|
|
|
'value' => 'Incident::Softwareproblem::MS Office::Word'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Outlook',
|
|
|
|
'value' => 'Incident::Softwareproblem::MS Office::Outlook'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Service request',
|
|
|
|
'value' => 'Service request',
|
|
|
|
'children' => [
|
|
|
|
{
|
|
|
|
'name' => 'New software requirement',
|
|
|
|
'value' => 'Service request::New software requirement'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'New hardware',
|
|
|
|
'value' => 'Service request::New hardware'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Consulting',
|
|
|
|
'value' => 'Service request::Consulting'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name' => 'Change request',
|
|
|
|
'value' => 'Change request'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'default' => '',
|
|
|
|
'null' => true,
|
|
|
|
'relation' => '',
|
|
|
|
'maxlength' => 255,
|
|
|
|
'nulloption' => true,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2019-01-04 14:26:43 +00:00
|
|
|
|
|
|
|
factory :required_screen, class: Hash do
|
|
|
|
create_middle do
|
|
|
|
{
|
|
|
|
'ticket.customer' => {
|
|
|
|
shown: true,
|
|
|
|
required: true,
|
|
|
|
item_class: 'column'
|
|
|
|
},
|
|
|
|
'ticket.agent' => {
|
|
|
|
shown: true,
|
|
|
|
required: true,
|
|
|
|
item_class: 'column'
|
|
|
|
},
|
|
|
|
'admin.organization' => {
|
|
|
|
shown: true,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
'admin.group' => {
|
|
|
|
shown: true,
|
|
|
|
required: true,
|
|
|
|
item_class: 'column'
|
|
|
|
},
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2019-03-27 09:01:36 +00:00
|
|
|
edit do
|
2019-01-04 14:26:43 +00:00
|
|
|
{
|
|
|
|
'ticket.customer' => {
|
|
|
|
shown: true,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
'ticket.agent' => {
|
|
|
|
shown: true,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
'admin.organization' => {
|
|
|
|
shown: true,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
'admin.group' => {
|
|
|
|
shown: true,
|
|
|
|
required: true,
|
|
|
|
item_class: 'column'
|
|
|
|
},
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2018-03-23 14:26:09 +00:00
|
|
|
end
|