Improved lookups for field for state_id.

This commit is contained in:
Martin Edenhofer 2017-03-31 13:56:42 +02:00
parent 72c4de570e
commit 53cd59902e
2 changed files with 18 additions and 30 deletions

View file

@ -16,7 +16,7 @@ class Ticket::State < ApplicationModel
looks up states for a given category
states = Ticket::State.by_category(:open) # :open|:closed|:work_on|:work_on_all|:viewable|:pending_reminder|:pending_action|:merged
states = Ticket::State.by_category(:open) # :open|:closed|:work_on|:work_on_all|:viewable|:viewable_agent_new|:viewable_agent_edit|:viewable_customer_new|:viewable_customer_edit|:pending_reminder|:pending_action|:pending|:merged
returns:
@ -33,12 +33,22 @@ returns:
state_types = ['pending reminder']
when :pending_action
state_types = ['pending action']
when :pending
state_types = ['pending reminder', 'pending action']
when :work_on
state_types = %w(new open)
when :work_on_all
state_types = ['new', 'open', 'pending reminder']
when :viewable
state_types = ['new', 'open', 'pending reminder', 'pending action', 'closed', 'removed']
when :viewable_agent_new
state_types = ['new', 'open', 'pending reminder', 'pending action', 'closed']
when :viewable_agent_edit
state_types = ['open', 'pending reminder', 'pending action', 'closed']
when :viewable_customer_new
state_types = %w(new closed)
when :viewable_customer_edit
state_types = %w(open closed)
when :closed
state_types = %w(closed)
when :merged

View file

@ -3847,13 +3847,7 @@ ObjectManager::Attribute.add(
null: false,
default: Ticket::State.find_by(name: 'open').id,
translate: true,
filter: [
Ticket::State.find_by(name: 'new').id,
Ticket::State.find_by(name: 'open').id,
Ticket::State.find_by(name: 'pending reminder').id,
Ticket::State.find_by(name: 'closed').id,
Ticket::State.find_by(name: 'pending close').id,
],
filter: Ticket::State.by_category(:viewable).pluck(:id),
},
editable: false,
active: true,
@ -3862,15 +3856,13 @@ ObjectManager::Attribute.add(
Agent: {
null: false,
item_class: 'column',
filter: Ticket::State.by_category(:viewable_agent_new).pluck(:id),
},
Customer: {
item_class: 'column',
nulloption: false,
null: true,
filter: [
Ticket::State.find_by(name: 'new').id,
Ticket::State.find_by(name: 'closed').id
],
filter: Ticket::State.by_category(:viewable_customer_new).pluck(:id),
default: Ticket::State.find_by(name: 'new').id,
},
},
@ -3878,20 +3870,12 @@ ObjectManager::Attribute.add(
Agent: {
nulloption: false,
null: false,
filter: [
Ticket::State.find_by(name: 'open').id,
Ticket::State.find_by(name: 'pending reminder').id,
Ticket::State.find_by(name: 'closed').id,
Ticket::State.find_by(name: 'pending close').id,
],
filter: Ticket::State.by_category(:viewable_agent_edit).pluck(:id),
},
Customer: {
nulloption: false,
null: true,
filter: [
Ticket::State.find_by(name: 'open').id,
Ticket::State.find_by(name: 'closed').id
],
filter: Ticket::State.by_category(:viewable_customer_edit).pluck(:id),
default: Ticket::State.find_by(name: 'open').id,
},
},
@ -3914,16 +3898,10 @@ ObjectManager::Attribute.add(
null: true,
translate: true,
required_if: {
state_id: [
Ticket::State.find_by(name: 'pending reminder').id,
Ticket::State.find_by(name: 'pending close').id,
]
state_id: Ticket::State.by_category(:pending).pluck(:id),
},
shown_if: {
state_id: [
Ticket::State.find_by(name: 'pending reminder').id,
Ticket::State.find_by(name: 'pending close').id,
]
state_id: Ticket::State.by_category(:pending).pluck(:id),
},
},
editable: false,