From e5ac9519e7e42e34ed917b32e39f76f33678a384 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 12 Oct 2015 23:12:44 +0200 Subject: [PATCH] New overview seeds. --- db/migrate/20151012000001_update_overview4.rb | 283 ++++++++++++++++++ db/seeds.rb | 71 ++--- 2 files changed, 320 insertions(+), 34 deletions(-) create mode 100644 db/migrate/20151012000001_update_overview4.rb diff --git a/db/migrate/20151012000001_update_overview4.rb b/db/migrate/20151012000001_update_overview4.rb new file mode 100644 index 000000000..200174d27 --- /dev/null +++ b/db/migrate/20151012000001_update_overview4.rb @@ -0,0 +1,283 @@ +class UpdateOverview4 < ActiveRecord::Migration + def up + + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + UserInfo.current_user_id = 1 + overview_role = Role.where( name: 'Agent' ).first + Overview.create_or_update( + name: 'My assigned Tickets', + link: 'my_assigned', + prio: 1000, + role_id: overview_role.id, + condition: { + 'ticket.state_id' => { + operator: 'is', + value: [ 1, 2, 3, 7 ], + }, + 'ticket.owner_id' => { + operator: 'is', + value: 'current_user.id', + }, + }, + order: { + by: 'created_at', + direction: 'ASC', + }, + view: { + d: %w(title customer group created_at), + s: %w(title customer group created_at), + m: %w(number title customer group created_at), + view_mode_default: 's', + }, + ) + + Overview.create_or_update( + name: 'My pending reached Tickets', + link: 'my_pending_reached', + prio: 1010, + role_id: overview_role.id, + condition: { + 'ticket.state_id' => { + operator: 'is', + value: 3, + }, + 'ticket.owner_id' => { + operator: 'is', + value: 'current_user.id', + }, + 'ticket.pending_time' => { + operator: 'within next (relative)', + value: 0, + range: 'minute', + }, + }, + order: { + by: 'created_at', + direction: 'ASC', + }, + view: { + d: %w(title customer group created_at), + s: %w(title customer group created_at), + m: %w(number title customer group created_at), + view_mode_default: 's', + }, + ) + + Overview.create_or_update( + name: 'Unassigned & Open Tickets', + link: 'all_unassigned', + prio: 1020, + role_id: overview_role.id, + condition: { + 'ticket.state_id' => { + operator: 'is', + value: [1, 2, 3], + }, + 'ticket.owner_id' => { + operator: 'is', + value: 1, + }, + }, + order: { + by: 'created_at', + direction: 'ASC', + }, + view: { + d: %w(title customer group created_at), + s: %w(title customer group created_at), + m: %w(number title customer group created_at), + view_mode_default: 's', + }, + ) + + Overview.create_or_update( + name: 'All Open Tickets', + link: 'all_open', + prio: 1030, + role_id: overview_role.id, + condition: { + 'ticket.state_id' => { + operator: 'is', + value: [1, 2, 3], + }, + }, + order: { + by: 'created_at', + direction: 'ASC', + }, + view: { + d: %w(title customer group state owner created_at), + s: %w(title customer group state owner created_at), + m: %w(number title customer group state owner created_at), + view_mode_default: 's', + }, + ) + + Overview.create_or_update( + name: 'All pending reached Tickets', + link: 'all_pending_reached', + prio: 1035, + role_id: overview_role.id, + condition: { + 'ticket.state_id' => { + operator: 'is', + value: [3], + }, + 'ticket.pending_time' => { + operator: 'within next (relative)', + value: 0, + range: 'minute', + }, + }, + order: { + by: 'created_at', + direction: 'ASC', + }, + view: { + d: %w(title customer group owner created_at), + s: %w(title customer group owner created_at), + m: %w(number title customer group owner created_at), + view_mode_default: 's', + }, + ) + + Overview.create_or_update( + name: 'Escalated Tickets', + link: 'all_escalated', + prio: 1040, + role_id: overview_role.id, + condition: { + 'ticket.escalation_time' => { + operator: 'within next (relative)', + value: '10', + range: 'minute', + }, + }, + order: { + by: 'escalation_time', + direction: 'ASC', + }, + view: { + d: %w(title customer group owner escalation_time), + s: %w(title customer group owner escalation_time), + m: %w(number title customer group owner escalation_time), + view_mode_default: 's', + }, + ) + + overview_role = Role.where( name: 'Customer' ).first + Overview.create_or_update( + name: 'My Tickets', + link: 'my_tickets', + prio: 1000, + role_id: overview_role.id, + condition: { + 'ticket.state_id' => { + operator: 'is', + value: [ 1, 2, 3, 4, 6, 7 ], + }, + 'ticket.customer_id' => { + operator: 'is', + value: 'current_user.id', + }, + }, + order: { + by: 'created_at', + direction: 'DESC', + }, + view: { + d: %w(title customer state created_at), + s: %w(number title state created_at), + m: %w(number title state created_at), + view_mode_default: 's', + }, + ) + Overview.create_or_update( + name: 'My Organization Tickets', + link: 'my_organization_tickets', + prio: 1100, + role_id: overview_role.id, + organization_shared: true, + condition: { + 'ticket.state_id' => { + operator: 'is', + value: [ 1, 2, 3, 4, 6, 7 ], + }, + 'ticket.organization_id' => { + operator: 'is', + value: 'current_user.organization_id', + }, + }, + order: { + by: 'created_at', + direction: 'DESC', + }, + view: { + d: %w(title customer state created_at), + s: %w(number title customer state created_at), + m: %w(number title customer state created_at), + view_mode_default: 's', + }, + ) + + ObjectManager::Attribute.add( + object: 'Ticket', + name: 'title', + display: 'Title', + data_type: 'input', + data_option: { + type: 'text', + maxlength: 200, + null: false, + translate: false, + }, + editable: false, + active: true, + screens: { + create_top: { + '-all-' => { + null: false, + }, + }, + edit: {}, + }, + pending_migration: false, + position: 15, + ) + + ObjectManager::Attribute.add( + object: 'Ticket', + name: 'group_id', + display: 'Group', + data_type: 'select', + data_option: { + relation: 'Group', + relation_condition: { access: 'rw' }, + nulloption: true, + multiple: false, + null: false, + translate: false, + }, + editable: false, + active: true, + screens: { + create_middle: { + '-all-' => { + null: false, + item_class: 'column', + }, + }, + edit: { + Agent: { + null: false, + }, + }, + }, + pending_migration: false, + position: 25, + ) + + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 1ba8be1e9..e0ca60de6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1645,8 +1645,9 @@ Overview.create_if_not_exists( value: 'current_user.id', }, 'ticket.pending_time' => { - operator: 'after (relative)', - value: '1', + operator: 'within next (relative)', + value: 0, + range: 'minute', }, }, order: { @@ -1722,8 +1723,9 @@ Overview.create_if_not_exists( value: [3], }, 'ticket.pending_time' => { - operator: 'after (relative)', - value: 1, + operator: 'within next (relative)', + value: 0, + range: 'minute', }, }, order: { @@ -1745,8 +1747,9 @@ Overview.create_if_not_exists( role_id: overview_role.id, condition: { 'ticket.escalation_time' => { - operator: 'before (relative)', - value: 5, + operator: 'within next (relative)', + value: '10', + range: 'minute', }, }, order: { @@ -1770,7 +1773,7 @@ Overview.create_if_not_exists( condition: { 'ticket.state_id' => { operator: 'is', - value: [ 1, 2, 3, 4, 6 ], + value: [ 1, 2, 3, 4, 6, 7 ], }, 'ticket.customer_id' => { operator: 'is', @@ -1797,7 +1800,7 @@ Overview.create_if_not_exists( condition: { 'ticket.state_id' => { operator: 'is', - value: [ 1, 2, 3, 4, 6 ], + value: [ 1, 2, 3, 4, 6, 7 ], }, 'ticket.organization_id' => { operator: 'is', @@ -1946,6 +1949,31 @@ Network::Item::Comment.create( body: 'Some comment....', ) +ObjectManager::Attribute.add( + object: 'Ticket', + name: 'title', + display: 'Title', + data_type: 'input', + data_option: { + type: 'text', + maxlength: 200, + null: false, + translate: false, + }, + editable: false, + active: true, + screens: { + create_top: { + '-all-' => { + null: false, + }, + }, + edit: {}, + }, + pending_migration: false, + position: 15, +) + ObjectManager::Attribute.add( object: 'Ticket', name: 'customer_id', @@ -2038,7 +2066,7 @@ ObjectManager::Attribute.add( }, }, pending_migration: false, - position: 20, + position: 25, ) ObjectManager::Attribute.add( object: 'Ticket', @@ -2211,31 +2239,6 @@ ObjectManager::Attribute.add( position: 900, ) -ObjectManager::Attribute.add( - object: 'Ticket', - name: 'title', - display: 'Title', - data_type: 'input', - data_option: { - type: 'text', - maxlength: 200, - null: false, - translate: false, - }, - editable: false, - active: true, - screens: { - create_top: { - '-all-' => { - null: false, - }, - }, - edit: {}, - }, - pending_migration: false, - position: 15, -) - ObjectManager::Attribute.add( object: 'TicketArticle', name: 'type_id',