Fixed group selection in customer ticket create.
This commit is contained in:
parent
ec2f74192f
commit
7127791e50
3 changed files with 37 additions and 46 deletions
|
@ -1489,7 +1489,7 @@ class App.ControllerForm extends App.Controller
|
|||
|
||||
# check all filter values as array
|
||||
# if it's matching, use it for selection
|
||||
if record['id'] is key
|
||||
if record['id'] is key || ( record['id'] && key && record['id'].toString() is key.toString() )
|
||||
list.push record
|
||||
|
||||
# no data filter matched
|
||||
|
@ -1537,9 +1537,9 @@ class App.ControllerForm extends App.Controller
|
|||
|
||||
# set selected attributes
|
||||
_selectedOptions: (attribute) ->
|
||||
|
||||
return if !attribute.options
|
||||
|
||||
# check if selected / checked need to be set
|
||||
check = (value, record) ->
|
||||
if typeof value is 'string' || typeof value is 'number' || typeof value is 'boolean'
|
||||
|
||||
|
@ -1547,14 +1547,12 @@ class App.ControllerForm extends App.Controller
|
|||
if record.value.toString() is value.toString() || record.name.toString() is value.toString()
|
||||
record.selected = 'selected'
|
||||
record.checked = 'checked'
|
||||
# if record.name.toString() is attribute.value.toString()
|
||||
# record.selected = 'selected'
|
||||
# record.checked = 'checked'
|
||||
|
||||
else if ( value && record.value && _.include( value, record.value ) ) || ( value && record.name && _.include( value, record.name ) )
|
||||
record.selected = 'selected'
|
||||
record.checked = 'checked'
|
||||
|
||||
# lookup of any record
|
||||
for record in attribute.options
|
||||
|
||||
if _.isArray( attribute.value )
|
||||
|
@ -1564,6 +1562,16 @@ class App.ControllerForm extends App.Controller
|
|||
if typeof attribute.value is 'string' || typeof attribute.value is 'number' || typeof attribute.value is 'boolean'
|
||||
check( attribute.value, record )
|
||||
|
||||
# if noting is selected / checked, use default as selected / checked
|
||||
selected = false
|
||||
for record in attribute.options
|
||||
if record.selected || record.checked
|
||||
selected = true
|
||||
if !selected
|
||||
for record in attribute.options
|
||||
if typeof attribute.default is 'string' || typeof attribute.default is 'number' || typeof attribute.default is 'boolean'
|
||||
check( attribute.default, record )
|
||||
|
||||
# set disabled attributes
|
||||
_disabledOptions: (attribute) ->
|
||||
|
||||
|
|
|
@ -57,35 +57,12 @@ class Index extends App.ControllerContent
|
|||
|
||||
# set defaults
|
||||
defaults = template['options'] || {}
|
||||
if !( 'state_id' of defaults )
|
||||
defaults['state_id'] = App.TicketState.findByAttribute( 'name', 'new' )
|
||||
if !( 'priority_id' of defaults )
|
||||
defaults['priority_id'] = App.TicketPriority.findByAttribute( 'name', '2 normal' )
|
||||
|
||||
groupFilter = (collection, type) =>
|
||||
|
||||
# only filter on collections
|
||||
return collection if type isnt 'collection'
|
||||
|
||||
# get configured ids
|
||||
group_ids = App.Config.get('customer_ticket_create_group_ids')
|
||||
|
||||
# return all groups if no one is selected
|
||||
return collection if !group_ids
|
||||
return collection if !_.isArray( group_ids ) && group_ids is ''
|
||||
return collection if _.isEmpty( group_ids )
|
||||
|
||||
if !_.isArray( group_ids )
|
||||
group_ids = [group_ids]
|
||||
|
||||
# filter selected groups
|
||||
if _.isEmpty( group_ids )
|
||||
return collection
|
||||
_.filter(
|
||||
collection
|
||||
(item) ->
|
||||
return item if item && _.contains( group_ids, item.id.toString() )
|
||||
)
|
||||
groupFilter = App.Config.get('customer_ticket_create_group_ids')
|
||||
if groupFilter
|
||||
if !_.isArray(groupFilter)
|
||||
groupFilter = [groupFilter]
|
||||
@form_meta.filter.group_id = groupFilter
|
||||
|
||||
formChanges = (params, attribute, attributes, classname, form, ui) =>
|
||||
if @form_meta.dependencies && @form_meta.dependencies[attribute.name]
|
||||
|
@ -113,12 +90,11 @@ class Index extends App.ControllerContent
|
|||
|
||||
@html App.view('customer_ticket_create')( head: 'New Ticket' )
|
||||
|
||||
|
||||
new App.ControllerForm(
|
||||
el: @el.find('.ticket-form-top')
|
||||
form_id: @form_id
|
||||
model: App.Ticket
|
||||
screen: 'create_top'#@article_attributes['screen']
|
||||
screen: 'create_top'
|
||||
handlers: [
|
||||
formChanges
|
||||
]
|
||||
|
@ -131,14 +107,14 @@ class Index extends App.ControllerContent
|
|||
el: @el.find('.article-form-top')
|
||||
form_id: @form_id
|
||||
model: App.TicketArticle
|
||||
screen: 'create_top'#@article_attributes['screen']
|
||||
screen: 'create_top'
|
||||
params: defaults
|
||||
)
|
||||
new App.ControllerForm(
|
||||
el: @el.find('.ticket-form-middle')
|
||||
form_id: @form_id
|
||||
model: App.Ticket
|
||||
screen: 'create_middle'#@article_attributes['screen']
|
||||
screen: 'create_middle'
|
||||
handlers: [
|
||||
formChanges
|
||||
]
|
||||
|
|
|
@ -179,10 +179,17 @@ class CreateObjectManager < ActiveRecord::Migration
|
|||
:active => true,
|
||||
:screens => {
|
||||
:create_middle => {
|
||||
'-all-' => {
|
||||
:Agent => {
|
||||
:null => false,
|
||||
:item_class => 'column',
|
||||
},
|
||||
:Customer => {
|
||||
:item_class => 'column',
|
||||
:nulloption => false,
|
||||
:null => true,
|
||||
:filter => [1,4],
|
||||
:default => 1,
|
||||
},
|
||||
},
|
||||
:edit => {
|
||||
:Agent => {
|
||||
|
|
Loading…
Reference in a new issue