2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2017-09-11 06:32:04 +00:00
|
|
|
class OutOfOffice2 < ActiveRecord::Migration[4.2]
|
2017-09-11 00:50:05 +00:00
|
|
|
def up
|
|
|
|
|
|
|
|
# return if it's a new setup
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2017-09-11 00:50:05 +00:00
|
|
|
|
|
|
|
if !ActiveRecord::Base.connection.column_exists?(:overviews, :out_of_office)
|
|
|
|
add_column :overviews, :out_of_office, :boolean, null: false, default: false
|
|
|
|
Overview.reset_column_information
|
|
|
|
end
|
|
|
|
|
2017-09-11 06:32:04 +00:00
|
|
|
if !ActiveRecord::Base.connection.column_exists?(:users, :out_of_office)
|
|
|
|
add_column :users, :out_of_office, :boolean, null: false, default: false
|
|
|
|
add_column :users, :out_of_office_start_at, :date, null: true
|
|
|
|
add_column :users, :out_of_office_end_at, :date, null: true
|
|
|
|
add_column :users, :out_of_office_replacement_id, :integer, null: true
|
|
|
|
|
2017-11-23 08:09:44 +00:00
|
|
|
add_index :users, %i[out_of_office out_of_office_start_at out_of_office_end_at], name: 'index_out_of_office'
|
2017-09-11 06:32:04 +00:00
|
|
|
add_index :users, [:out_of_office_replacement_id]
|
|
|
|
add_foreign_key :users, :users, column: :out_of_office_replacement_id
|
|
|
|
User.reset_column_information
|
|
|
|
end
|
|
|
|
|
2017-09-11 00:50:05 +00:00
|
|
|
role_ids = Role.with_permissions(['ticket.agent']).map(&:id)
|
|
|
|
Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'My replacement Tickets',
|
|
|
|
link: 'my_replacement_tickets',
|
|
|
|
prio: 1080,
|
|
|
|
role_ids: role_ids,
|
2017-09-11 00:50:05 +00:00
|
|
|
out_of_office: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.state_id' => {
|
2017-09-11 00:50:05 +00:00
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: Ticket::State.by_category(:open).pluck(:id),
|
2017-09-11 00:50:05 +00:00
|
|
|
},
|
|
|
|
'ticket.out_of_office_replacement_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2017-09-11 00:50:05 +00:00
|
|
|
pre_condition: 'current_user.id',
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2017-09-11 00:50:05 +00:00
|
|
|
direction: 'DESC',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer group owner escalation_at],
|
|
|
|
s: %w[title customer group owner escalation_at],
|
|
|
|
m: %w[number title customer group owner escalation_at],
|
2017-09-11 00:50:05 +00:00
|
|
|
view_mode_default: 's',
|
|
|
|
},
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
Cache.clear
|
|
|
|
end
|
|
|
|
end
|