Fixed group selection in customer ticket create.
This commit is contained in:
parent
b2ee4366a6
commit
8ba9cc98e9
3 changed files with 31 additions and 41 deletions
|
@ -1475,7 +1475,7 @@ class App.ControllerForm extends App.Controller
|
||||||
|
|
||||||
# check all filter values as array
|
# check all filter values as array
|
||||||
# if it's matching, use it for selection
|
# 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
|
list.push record
|
||||||
|
|
||||||
# no data filter matched
|
# no data filter matched
|
||||||
|
@ -1523,9 +1523,9 @@ class App.ControllerForm extends App.Controller
|
||||||
|
|
||||||
# set selected attributes
|
# set selected attributes
|
||||||
_selectedOptions: (attribute) ->
|
_selectedOptions: (attribute) ->
|
||||||
|
|
||||||
return if !attribute.options
|
return if !attribute.options
|
||||||
|
|
||||||
|
# check if selected / checked need to be set
|
||||||
check = (value, record) ->
|
check = (value, record) ->
|
||||||
if typeof value is 'string' || typeof value is 'number' || typeof value is 'boolean'
|
if typeof value is 'string' || typeof value is 'number' || typeof value is 'boolean'
|
||||||
|
|
||||||
|
@ -1533,14 +1533,12 @@ class App.ControllerForm extends App.Controller
|
||||||
if record.value.toString() is value.toString() || record.name.toString() is value.toString()
|
if record.value.toString() is value.toString() || record.name.toString() is value.toString()
|
||||||
record.selected = 'selected'
|
record.selected = 'selected'
|
||||||
record.checked = 'checked'
|
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 ) )
|
else if ( value && record.value && _.include( value, record.value ) ) || ( value && record.name && _.include( value, record.name ) )
|
||||||
record.selected = 'selected'
|
record.selected = 'selected'
|
||||||
record.checked = 'checked'
|
record.checked = 'checked'
|
||||||
|
|
||||||
|
# lookup of any record
|
||||||
for record in attribute.options
|
for record in attribute.options
|
||||||
|
|
||||||
if _.isArray( attribute.value )
|
if _.isArray( attribute.value )
|
||||||
|
@ -1550,6 +1548,16 @@ class App.ControllerForm extends App.Controller
|
||||||
if typeof attribute.value is 'string' || typeof attribute.value is 'number' || typeof attribute.value is 'boolean'
|
if typeof attribute.value is 'string' || typeof attribute.value is 'number' || typeof attribute.value is 'boolean'
|
||||||
check( attribute.value, record )
|
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
|
# set disabled attributes
|
||||||
_disabledOptions: (attribute) ->
|
_disabledOptions: (attribute) ->
|
||||||
|
|
||||||
|
|
|
@ -49,35 +49,13 @@ class Index extends App.ControllerContent
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
defaults = template['options'] || {}
|
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) =>
|
filter = {}
|
||||||
|
groupFilter = App.Config.get('customer_ticket_create_group_ids')
|
||||||
# only filter on collections
|
if groupFilter
|
||||||
return collection if type isnt 'collection'
|
if !_.isArray(groupFilter)
|
||||||
|
groupFilter = [groupFilter]
|
||||||
# get configured ids
|
filter.group_id = groupFilter
|
||||||
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() )
|
|
||||||
)
|
|
||||||
|
|
||||||
@html App.view('customer_ticket_create')( head: 'New Ticket' )
|
@html App.view('customer_ticket_create')( head: 'New Ticket' )
|
||||||
|
|
||||||
|
@ -87,8 +65,7 @@ class Index extends App.ControllerContent
|
||||||
model: App.Ticket
|
model: App.Ticket
|
||||||
screen: 'create_web'
|
screen: 'create_web'
|
||||||
autofocus: true
|
autofocus: true
|
||||||
filter:
|
filter: filter
|
||||||
group_id: groupFilter
|
|
||||||
params: defaults
|
params: defaults
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,12 @@ class CreateObjectManager < ActiveRecord::Migration
|
||||||
:filter => [2,3,4],
|
:filter => [2,3,4],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
:create_web => {},
|
:create_web => {
|
||||||
|
:Customer => {
|
||||||
|
:filter => [1,4],
|
||||||
|
:default => 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
:edit => {
|
:edit => {
|
||||||
:Agent => {
|
:Agent => {
|
||||||
:nulloption => false,
|
:nulloption => false,
|
||||||
|
|
Loading…
Reference in a new issue