Added admin interface for overviews.
This commit is contained in:
parent
36d0220183
commit
8e91657fcd
|
@ -49,46 +49,74 @@ class App.ControllerForm extends App.Controller
|
||||||
|
|
||||||
# input text field with max. 100 size
|
# input text field with max. 100 size
|
||||||
attribute_config = {
|
attribute_config = {
|
||||||
name: 'subject',
|
name: 'subject'
|
||||||
display: 'Subject',
|
display: 'Subject'
|
||||||
tag: 'input',
|
tag: 'input'
|
||||||
type: 'text',
|
type: 'text'
|
||||||
limit: 100,
|
limit: 100
|
||||||
null: false,
|
null: false
|
||||||
default: defaults['subject'],
|
default: defaults['subject']
|
||||||
class: 'span7'
|
class: 'span7'
|
||||||
}
|
}
|
||||||
|
|
||||||
# colection as relation with auto completion
|
# colection as relation with auto completion
|
||||||
attribute_config = {
|
attribute_config = {
|
||||||
name: 'customer_id',
|
name: 'customer_id'
|
||||||
display: 'Customer',
|
display: 'Customer'
|
||||||
tag: 'autocompletion',
|
tag: 'autocompletion'
|
||||||
# auto completion params, endpoints, ui,...
|
# auto completion params, endpoints, ui,...
|
||||||
type: 'text',
|
type: 'text'
|
||||||
limit: 100,
|
limit: 100
|
||||||
null: false,
|
null: false
|
||||||
relation: 'User',
|
relation: 'User'
|
||||||
autocapitalize: false,
|
autocapitalize: false
|
||||||
help: 'Select the customer of the Ticket or create one.',
|
help: 'Select the customer of the Ticket or create one.'
|
||||||
link: '<a href="" class="customer_new">»</a>',
|
link: '<a href="" class="customer_new">»</a>'
|
||||||
callback: @userInfo
|
callback: @userInfo
|
||||||
class: 'span7',
|
class: 'span7'
|
||||||
}
|
}
|
||||||
|
|
||||||
# colection as relation
|
# colection as relation
|
||||||
attribute_config = {
|
attribute_config = {
|
||||||
name: 'ticket_priority_id',
|
name: 'ticket_priority_id'
|
||||||
display: 'Priority',
|
display: 'Priority'
|
||||||
tag: 'select',
|
tag: 'select'
|
||||||
multiple: false,
|
multiple: false
|
||||||
null: false,
|
null: false
|
||||||
relation: 'TicketPriority',
|
relation: 'TicketPriority'
|
||||||
default: defaults['ticket_priority_id'],
|
default: defaults['ticket_priority_id']
|
||||||
translate: true,
|
translate: true
|
||||||
class: 'medium'
|
class: 'medium'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# colection as options
|
||||||
|
attribute_config = {
|
||||||
|
name: 'ticket_priority_id'
|
||||||
|
display: 'Priority'
|
||||||
|
tag: 'select'
|
||||||
|
multiple: false
|
||||||
|
null: false
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
value: 5
|
||||||
|
name: 'very hight'
|
||||||
|
selected: false
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 3
|
||||||
|
name: 'normal'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
]
|
||||||
|
default: 3
|
||||||
|
translate: true
|
||||||
|
class: 'medium'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
formGenItem: (attribute_config, classname, form ) ->
|
formGenItem: (attribute_config, classname, form ) ->
|
||||||
|
@ -127,8 +155,14 @@ class App.ControllerForm extends App.Controller
|
||||||
|
|
||||||
# set value
|
# set value
|
||||||
if @params
|
if @params
|
||||||
if attribute.name of @params
|
|
||||||
attribute.value = @params[attribute.name]
|
# check if we have a references
|
||||||
|
parts = attribute.name.split '::'
|
||||||
|
if parts[0] && parts[1]
|
||||||
|
if @params[ parts[0] ] && @params[ parts[0] ][ parts[1] ]
|
||||||
|
attribute.value = @params[ parts[0] ][ parts[1] ]
|
||||||
|
else
|
||||||
|
attribute.value = @params[ attribute.name ]
|
||||||
|
|
||||||
# set default value
|
# set default value
|
||||||
else
|
else
|
||||||
|
@ -139,7 +173,6 @@ class App.ControllerForm extends App.Controller
|
||||||
|
|
||||||
App.Log.log 'ControllerForm', 'debug', 'formGenItem-before', attribute
|
App.Log.log 'ControllerForm', 'debug', 'formGenItem-before', attribute
|
||||||
|
|
||||||
|
|
||||||
# build options list based on config
|
# build options list based on config
|
||||||
@_getConfigOptionList( attribute )
|
@_getConfigOptionList( attribute )
|
||||||
|
|
||||||
|
@ -155,6 +188,9 @@ class App.ControllerForm extends App.Controller
|
||||||
# finde selected/checked item of list
|
# finde selected/checked item of list
|
||||||
@_selectedOptions( attribute )
|
@_selectedOptions( attribute )
|
||||||
|
|
||||||
|
# disable item of list
|
||||||
|
@_disabledOptions( attribute )
|
||||||
|
|
||||||
# filter attributes
|
# filter attributes
|
||||||
@_filterOption( attribute )
|
@_filterOption( attribute )
|
||||||
|
|
||||||
|
@ -382,6 +418,343 @@ class App.ControllerForm extends App.Controller
|
||||||
)
|
)
|
||||||
@delay( a, 180 )
|
@delay( a, 180 )
|
||||||
|
|
||||||
|
# ticket attribute selection
|
||||||
|
else if attribute.tag is 'ticket_attribute_selection'
|
||||||
|
|
||||||
|
# list of possible attributes
|
||||||
|
item = $(
|
||||||
|
App.view('generic/ticket_attribute_selection')(
|
||||||
|
attribute: attribute
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
addShownAttribute = ( key, value ) =>
|
||||||
|
console.log( 'addShownAttribute', key, value )
|
||||||
|
if key is 'number'
|
||||||
|
attribute_config = {
|
||||||
|
name: attribute.name + '::number'
|
||||||
|
display: 'Number'
|
||||||
|
tag: 'input'
|
||||||
|
type: 'text'
|
||||||
|
null: false
|
||||||
|
value: value
|
||||||
|
class: 'medium'
|
||||||
|
remove: true
|
||||||
|
}
|
||||||
|
else if key is 'title'
|
||||||
|
attribute_config = {
|
||||||
|
name: attribute.name + '::title'
|
||||||
|
display: 'Title'
|
||||||
|
tag: 'input'
|
||||||
|
type: 'text'
|
||||||
|
null: false
|
||||||
|
value: value
|
||||||
|
class: 'medium'
|
||||||
|
remove: true
|
||||||
|
}
|
||||||
|
else if key is 'group_id'
|
||||||
|
attribute_config = {
|
||||||
|
name: attribute.name + '::group_id'
|
||||||
|
display: 'Group'
|
||||||
|
tag: 'select'
|
||||||
|
multiple: true
|
||||||
|
null: false
|
||||||
|
nulloption: false
|
||||||
|
relation: 'Group'
|
||||||
|
value: value
|
||||||
|
class: 'medium'
|
||||||
|
remove: true
|
||||||
|
}
|
||||||
|
else if key is 'owner_id' || key is 'customer_id'
|
||||||
|
display = 'Owner'
|
||||||
|
name = 'owner_id'
|
||||||
|
if key is 'customer_id'
|
||||||
|
display = 'Customer'
|
||||||
|
name = 'customer_id'
|
||||||
|
attribute_config = {
|
||||||
|
name: attribute.name + '::' + name
|
||||||
|
display: display
|
||||||
|
tag: 'select'
|
||||||
|
multiple: true
|
||||||
|
null: false
|
||||||
|
nulloption: false
|
||||||
|
relation: 'User'
|
||||||
|
value: value || null
|
||||||
|
class: 'medium'
|
||||||
|
remove: true
|
||||||
|
filter: ( all, type ) ->
|
||||||
|
return all if type isnt 'collection'
|
||||||
|
all = _.filter( all, (item) ->
|
||||||
|
return if item.id is 1
|
||||||
|
return item
|
||||||
|
)
|
||||||
|
all.unshift( {
|
||||||
|
id: ''
|
||||||
|
name: '--'
|
||||||
|
} )
|
||||||
|
all.unshift( {
|
||||||
|
id: 1
|
||||||
|
name: '*** nobody ***'
|
||||||
|
} )
|
||||||
|
all.unshift( {
|
||||||
|
id: 'current_user.id'
|
||||||
|
name: '*** current user ***'
|
||||||
|
} )
|
||||||
|
all
|
||||||
|
}
|
||||||
|
else if key is 'organization_id'
|
||||||
|
attribute_config = {
|
||||||
|
name: attribute.name + '::organization_id'
|
||||||
|
display: 'Organization'
|
||||||
|
tag: 'select'
|
||||||
|
multiple: true
|
||||||
|
null: false
|
||||||
|
nulloption: false
|
||||||
|
relation: 'Organization'
|
||||||
|
value: value || null
|
||||||
|
class: 'medium'
|
||||||
|
remove: true
|
||||||
|
filter: ( all, type ) ->
|
||||||
|
return all if type isnt 'collection'
|
||||||
|
all.unshift( {
|
||||||
|
id: ''
|
||||||
|
name: '--'
|
||||||
|
} )
|
||||||
|
all.unshift( {
|
||||||
|
id: 'current_user.organization_id'
|
||||||
|
name: '*** organization of current user ***'
|
||||||
|
} )
|
||||||
|
all
|
||||||
|
}
|
||||||
|
else if key is 'ticket_state_id'
|
||||||
|
attribute_config = {
|
||||||
|
name: attribute.name + '::ticket_state_id'
|
||||||
|
display: 'State'
|
||||||
|
tag: 'select'
|
||||||
|
multiple: true
|
||||||
|
null: false
|
||||||
|
nulloption: false
|
||||||
|
relation: 'TicketState'
|
||||||
|
value: value
|
||||||
|
translate: true
|
||||||
|
class: 'medium'
|
||||||
|
remove: true
|
||||||
|
}
|
||||||
|
else if key is 'ticket_priority_id'
|
||||||
|
attribute_config = {
|
||||||
|
name: attribute.name + '::ticket_priority_id'
|
||||||
|
display: 'Priority'
|
||||||
|
tag: 'select'
|
||||||
|
multiple: true
|
||||||
|
null: false
|
||||||
|
nulloption: false
|
||||||
|
relation: 'TicketPriority'
|
||||||
|
value: value
|
||||||
|
translate: true
|
||||||
|
class: 'medium'
|
||||||
|
remove: true
|
||||||
|
}
|
||||||
|
else
|
||||||
|
attribute_config = {
|
||||||
|
name: attribute.name + '::' + key
|
||||||
|
display: 'FIXME!'
|
||||||
|
tag: 'input'
|
||||||
|
type: 'text'
|
||||||
|
value: value
|
||||||
|
class: 'medium'
|
||||||
|
remove: true
|
||||||
|
}
|
||||||
|
itemSub = @formGenItem( attribute_config )
|
||||||
|
itemSub.find('.icon-minus').bind('click', (e) ->
|
||||||
|
e.preventDefault()
|
||||||
|
$(@).parent().parent().parent().remove()
|
||||||
|
)
|
||||||
|
# itemSub.append('<a href=\"#\" class=\"icon-minus\"></a>')
|
||||||
|
item.find('.ticket_attribute_item').append( itemSub )
|
||||||
|
|
||||||
|
|
||||||
|
# list of shown attributes
|
||||||
|
show = []
|
||||||
|
if attribute.value
|
||||||
|
for key, value of attribute.value
|
||||||
|
addShownAttribute( key, value )
|
||||||
|
|
||||||
|
# list of existing attributes
|
||||||
|
attribute_config = {
|
||||||
|
name: 'ticket_attribute_list'
|
||||||
|
display: 'Add Attribute'
|
||||||
|
tag: 'select'
|
||||||
|
multiple: false
|
||||||
|
null: false
|
||||||
|
# nulloption: true
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
value: ''
|
||||||
|
name: '-- Ticket --'
|
||||||
|
selected: false
|
||||||
|
disable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'number'
|
||||||
|
name: 'Number'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'title'
|
||||||
|
name: 'Title'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'group_id'
|
||||||
|
name: 'Group'
|
||||||
|
selected: false
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'ticket_state_id'
|
||||||
|
name: 'State'
|
||||||
|
selected: false
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'ticket_priority_id'
|
||||||
|
name: 'Priority'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'owner_id'
|
||||||
|
name: 'Owner'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'customer_id'
|
||||||
|
name: 'Customer'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'organization_id'
|
||||||
|
name: 'Organization'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
|
||||||
|
# {
|
||||||
|
# value: 'tag'
|
||||||
|
# name: 'Tag'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# value: 'created_before'
|
||||||
|
# name: 'Erstell vor'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# value: 'created_after'
|
||||||
|
# name: 'Erstell nach'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# value: 'created_between'
|
||||||
|
# name: 'Erstell zwischen'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# value: 'closed_before'
|
||||||
|
# name: 'Geschlossen vor'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# value: 'closed_after'
|
||||||
|
# name: 'Geschlossen nach'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# value: 'closed_between'
|
||||||
|
# name: 'Geschlossen zwischen'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
{
|
||||||
|
value: '-a'
|
||||||
|
name: '-- ' + App.i18n.translateInline('Article') + ' --'
|
||||||
|
selected: false
|
||||||
|
disable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'from'
|
||||||
|
name: 'From'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'to'
|
||||||
|
name: 'To'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'cc'
|
||||||
|
name: 'Cc'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'subject'
|
||||||
|
name: 'Subject'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'body'
|
||||||
|
name: 'Text'
|
||||||
|
selected: true
|
||||||
|
disable: false
|
||||||
|
},
|
||||||
|
# {
|
||||||
|
# value: '-c'
|
||||||
|
# name: '-- ' + App.i18n.translateInline('Customer') + ' --'
|
||||||
|
# selected: false
|
||||||
|
# disable: true
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# value: 'customer_user'
|
||||||
|
# name: 'Kunde'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# value: 'organization'
|
||||||
|
# name: 'Organization'
|
||||||
|
# selected: true
|
||||||
|
# disable: false
|
||||||
|
# },
|
||||||
|
]
|
||||||
|
default: ''
|
||||||
|
translate: true
|
||||||
|
class: 'medium'
|
||||||
|
add: true
|
||||||
|
}
|
||||||
|
list = @formGenItem( attribute_config )
|
||||||
|
|
||||||
|
list.find('.icon-plus').bind('click', (e) ->
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
value = $(e.target).parents().find('[name=ticket_attribute_list]').val()
|
||||||
|
addShownAttribute( value, '' )
|
||||||
|
)
|
||||||
|
item.find('.ticket_attribute_list').prepend( list )
|
||||||
|
|
||||||
# input
|
# input
|
||||||
else
|
else
|
||||||
item = $( App.view('generic/input')( attribute: attribute ) )
|
item = $( App.view('generic/input')( attribute: attribute ) )
|
||||||
|
@ -407,14 +780,14 @@ class App.ControllerForm extends App.Controller
|
||||||
classname = @classname
|
classname = @classname
|
||||||
attributes_clean = @attributes_clean
|
attributes_clean = @attributes_clean
|
||||||
ui = @
|
ui = @
|
||||||
$('#' + @attribute.id).bind('change', ->
|
$( '#' + @attribute.id ).bind('change', ->
|
||||||
ui.log 'change', @, attribute, change
|
ui.log 'change', @, attribute, change
|
||||||
ui.log change[0] + ' has changed - changing ' + change[1]
|
ui.log change[0] + ' has changed - changing ' + change[1]
|
||||||
|
|
||||||
item = $( ui.formGenItem(attribute, classname, attributes_clean) )
|
item = $( ui.formGenItem(attribute, classname, attributes_clean) )
|
||||||
ui.log item, classname
|
ui.log item, classname
|
||||||
)
|
)
|
||||||
@delay(b, 100)
|
@delay( b, 100 )
|
||||||
# if attribute.onchange[]
|
# if attribute.onchange[]
|
||||||
|
|
||||||
ui = @
|
ui = @
|
||||||
|
@ -452,10 +825,12 @@ class App.ControllerForm extends App.Controller
|
||||||
if !attribute.display
|
if !attribute.display
|
||||||
return item
|
return item
|
||||||
else
|
else
|
||||||
a = $( App.view('generic/attribute')(
|
a = $(
|
||||||
attribute: attribute,
|
App.view('generic/attribute')(
|
||||||
item: '',
|
attribute: attribute,
|
||||||
) )
|
item: '',
|
||||||
|
)
|
||||||
|
)
|
||||||
a.find('.controls').prepend( item )
|
a.find('.controls').prepend( item )
|
||||||
return a
|
return a
|
||||||
|
|
||||||
|
@ -463,6 +838,7 @@ class App.ControllerForm extends App.Controller
|
||||||
_sortOptions: (attribute) ->
|
_sortOptions: (attribute) ->
|
||||||
|
|
||||||
return if !attribute.options
|
return if !attribute.options
|
||||||
|
return if _.isArray( attribute.options )
|
||||||
|
|
||||||
options_by_name = []
|
options_by_name = []
|
||||||
for i in attribute.options
|
for i in attribute.options
|
||||||
|
@ -478,30 +854,32 @@ class App.ControllerForm extends App.Controller
|
||||||
options_new.push ii
|
options_new.push ii
|
||||||
attribute.options = options_new
|
attribute.options = options_new
|
||||||
|
|
||||||
|
|
||||||
_addNullOption: (attribute) ->
|
_addNullOption: (attribute) ->
|
||||||
return if !attribute.options
|
return if !attribute.options
|
||||||
return if !attribute.nulloption
|
return if !attribute.nulloption
|
||||||
attribute.options[''] = '-'
|
if _.isArray( attribute.options )
|
||||||
attribute.options.push {
|
attribute.options.unshift( { name: '-', value: '' } )
|
||||||
name: '-',
|
else
|
||||||
value: '',
|
attribute.options[''] = '-'
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_getConfigOptionList: (attribute) ->
|
_getConfigOptionList: (attribute) ->
|
||||||
return if !attribute.options
|
return if !attribute.options
|
||||||
selection = attribute.options
|
selection = attribute.options
|
||||||
attribute.options = []
|
attribute.options = []
|
||||||
for key, value of selection
|
if _.isArray( selection )
|
||||||
name_new = value
|
for row in selection
|
||||||
if attribute.translate
|
if attribute.translate
|
||||||
name_new = App.i18n.translateInline( name_new )
|
row.name = App.i18n.translateInline( row.name )
|
||||||
attribute.options.push {
|
attribute.options.push row
|
||||||
name: name_new,
|
else
|
||||||
value: key,
|
for key, value of selection
|
||||||
}
|
name_new = value
|
||||||
|
if attribute.translate
|
||||||
|
name_new = App.i18n.translateInline( name_new )
|
||||||
|
attribute.options.push {
|
||||||
|
name: name_new
|
||||||
|
value: key
|
||||||
|
}
|
||||||
|
|
||||||
_getRelationOptionList: (attribute) ->
|
_getRelationOptionList: (attribute) ->
|
||||||
|
|
||||||
|
@ -519,7 +897,8 @@ class App.ControllerForm extends App.Controller
|
||||||
if typeof attribute.filter is 'function'
|
if typeof attribute.filter is 'function'
|
||||||
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-function'
|
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-function'
|
||||||
|
|
||||||
all = App[attribute.relation].all()
|
all = App.Collection.all( type: attribute.relation, sortBy: attribute.sortBy || 'name' )
|
||||||
|
|
||||||
list = attribute.filter( all, 'collection' )
|
list = attribute.filter( all, 'collection' )
|
||||||
|
|
||||||
# data based filter
|
# data based filter
|
||||||
|
@ -529,7 +908,7 @@ class App.ControllerForm extends App.Controller
|
||||||
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-data', filter
|
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-data', filter
|
||||||
|
|
||||||
# check all records
|
# check all records
|
||||||
for record in App[attribute.relation].all()
|
for record in App.Collection.all( type: attribute.relation, sortBy: attribute.sortBy || 'name' )
|
||||||
|
|
||||||
# check all filter attributes
|
# check all filter attributes
|
||||||
for key in filter
|
for key in filter
|
||||||
|
@ -542,17 +921,16 @@ class App.ControllerForm extends App.Controller
|
||||||
# no data filter matched
|
# no data filter matched
|
||||||
else
|
else
|
||||||
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-data no filter matched'
|
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-data no filter matched'
|
||||||
list = App[attribute.relation].all()
|
list = App.Collection.all( type: attribute.relation, sortBy: attribute.sortBy || 'name' )
|
||||||
else
|
else
|
||||||
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-no filter defined'
|
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-no filter defined'
|
||||||
list = App[attribute.relation].all()
|
list = App.Collection.all( type: attribute.relation, sortBy: attribute.sortBy || 'name' )
|
||||||
|
|
||||||
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList', attribute, list
|
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList', attribute, list
|
||||||
|
|
||||||
# build options list
|
# build options list
|
||||||
@_buildOptionList( list, attribute )
|
@_buildOptionList( list, attribute )
|
||||||
|
|
||||||
|
|
||||||
# build options list
|
# build options list
|
||||||
_buildOptionList: (list, attribute) ->
|
_buildOptionList: (list, attribute) ->
|
||||||
|
|
||||||
|
@ -563,6 +941,8 @@ class App.ControllerForm extends App.Controller
|
||||||
name_new = '?'
|
name_new = '?'
|
||||||
if item.displayName
|
if item.displayName
|
||||||
name_new = item.displayName()
|
name_new = item.displayName()
|
||||||
|
else if item.name
|
||||||
|
name_new = item.name
|
||||||
if attribute.translate
|
if attribute.translate
|
||||||
name_new = App.i18n.translateInline(name_new)
|
name_new = App.i18n.translateInline(name_new)
|
||||||
attribute.options.push {
|
attribute.options.push {
|
||||||
|
@ -586,21 +966,42 @@ class App.ControllerForm extends App.Controller
|
||||||
|
|
||||||
return if !attribute.options
|
return if !attribute.options
|
||||||
|
|
||||||
for record in attribute.options
|
check = (value, record) ->
|
||||||
if typeof attribute.value is 'string' || typeof attribute.value is 'number' || typeof attribute.value is 'boolean'
|
if typeof value is 'string' || typeof value is 'number' || typeof value is 'boolean'
|
||||||
|
|
||||||
# if name or value is matching
|
# if name or value is matching
|
||||||
if record.value.toString() is attribute.value.toString() || record.name.toString() is attribute.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()
|
# if record.name.toString() is attribute.value.toString()
|
||||||
# record.selected = 'selected'
|
# record.selected = 'selected'
|
||||||
# record.checked = 'checked'
|
# record.checked = 'checked'
|
||||||
|
|
||||||
else if ( attribute.value && record.value && _.include(attribute.value, record.value) ) || ( attribute.value && record.name && _.include(attribute.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'
|
||||||
|
|
||||||
|
for record in attribute.options
|
||||||
|
|
||||||
|
if _.isArray( attribute.value )
|
||||||
|
for value in attribute.value
|
||||||
|
check( value, record )
|
||||||
|
|
||||||
|
if typeof attribute.value is 'string' || typeof attribute.value is 'number' || typeof attribute.value is 'boolean'
|
||||||
|
check( attribute.value, record )
|
||||||
|
|
||||||
|
# set disabled attributes
|
||||||
|
_disabledOptions: (attribute) ->
|
||||||
|
|
||||||
|
return if !attribute.options
|
||||||
|
return if !_.isArray( attribute.options )
|
||||||
|
|
||||||
|
for record in attribute.options
|
||||||
|
if record.disable is true
|
||||||
|
record.disabled = 'disabled'
|
||||||
|
else
|
||||||
|
record.disabled = ''
|
||||||
|
|
||||||
validate: (params) ->
|
validate: (params) ->
|
||||||
App.Model.validate(
|
App.Model.validate(
|
||||||
model: @model,
|
model: @model,
|
||||||
|
@ -645,8 +1046,17 @@ class App.ControllerForm extends App.Controller
|
||||||
|
|
||||||
param[key.name] = key.value
|
param[key.name] = key.value
|
||||||
|
|
||||||
# check {input_select}
|
# check :: fields
|
||||||
inputSelectObject = {}
|
inputSelectObject = {}
|
||||||
|
for key of param
|
||||||
|
parts = key.split '::'
|
||||||
|
if parts[0] && parts[1]
|
||||||
|
if !inputSelectObject[ parts[0] ]
|
||||||
|
inputSelectObject[ parts[0] ] = {}
|
||||||
|
inputSelectObject[ parts[0] ][ parts[1] ] = param[ key ]
|
||||||
|
delete param[ key ]
|
||||||
|
|
||||||
|
# check {input_select}
|
||||||
for key of param
|
for key of param
|
||||||
attributeType = key.split '::'
|
attributeType = key.split '::'
|
||||||
name = attributeType[1]
|
name = attributeType[1]
|
||||||
|
|
|
@ -79,8 +79,8 @@ class App.DashboardTicket extends App.Controller
|
||||||
@overview = data.overview
|
@overview = data.overview
|
||||||
@tickets_count = data.tickets_count
|
@tickets_count = data.tickets_count
|
||||||
@ticket_list = data.ticket_list
|
@ticket_list = data.ticket_list
|
||||||
|
# FIXME 10
|
||||||
pages_total = parseInt( ( @tickets_count / @overview.view.d.per_page ) + 0.99999 ) || 1
|
pages_total = parseInt( ( @tickets_count / 10 ) + 0.99999 ) || 1
|
||||||
html = App.view('dashboard/ticket')(
|
html = App.view('dashboard/ticket')(
|
||||||
overview: @overview,
|
overview: @overview,
|
||||||
pages_total: pages_total,
|
pages_total: pages_total,
|
||||||
|
@ -99,7 +99,7 @@ class App.DashboardTicket extends App.Controller
|
||||||
if @ticket_list[ i - 1 ]
|
if @ticket_list[ i - 1 ]
|
||||||
@tickets_in_table.push App.Collection.find( 'Ticket', @ticket_list[ i - 1 ] )
|
@tickets_in_table.push App.Collection.find( 'Ticket', @ticket_list[ i - 1 ] )
|
||||||
|
|
||||||
shown_all_attributes = @ticketTableAttributes( App.Overview.find(@overview.id).view.d.overview )
|
shown_all_attributes = @ticketTableAttributes( App.Overview.find(@overview.id).view.d )
|
||||||
new App.ControllerTable(
|
new App.ControllerTable(
|
||||||
el: html.find('.table-overview'),
|
el: html.find('.table-overview'),
|
||||||
overview_extended: shown_all_attributes,
|
overview_extended: shown_all_attributes,
|
||||||
|
@ -161,7 +161,7 @@ class Settings extends App.ControllerModal
|
||||||
tag: 'select',
|
tag: 'select',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
null: false,
|
null: false,
|
||||||
default: @overview.view.d.per_page,
|
# default: @overview.view.d.per_page,
|
||||||
options: {
|
options: {
|
||||||
5: 5,
|
5: 5,
|
||||||
10: 10,
|
10: 10,
|
||||||
|
@ -175,7 +175,7 @@ class Settings extends App.ControllerModal
|
||||||
name: 'attributes',
|
name: 'attributes',
|
||||||
display: 'Attributes',
|
display: 'Attributes',
|
||||||
tag: 'checkbox',
|
tag: 'checkbox',
|
||||||
default: @overview.view.d.overview,
|
default: @overview.view.d,
|
||||||
null: false,
|
null: false,
|
||||||
translate: true
|
translate: true
|
||||||
options: {
|
options: {
|
||||||
|
@ -263,7 +263,7 @@ class Settings extends App.ControllerModal
|
||||||
@overview.order['direction'] = params['order_by_direction']
|
@overview.order['direction'] = params['order_by_direction']
|
||||||
@reload_needed = 1
|
@reload_needed = 1
|
||||||
|
|
||||||
@overview.view['d']['overview'] = params['attributes']
|
@overview.view['d'] = params['attributes']
|
||||||
|
|
||||||
@overview.save(
|
@overview.save(
|
||||||
success: =>
|
success: =>
|
||||||
|
|
|
@ -124,10 +124,7 @@ class Index extends App.Controller
|
||||||
@selected = @bulkGetSelected()
|
@selected = @bulkGetSelected()
|
||||||
|
|
||||||
# set page title
|
# set page title
|
||||||
@title @overview.meta.name
|
@title @overview.name
|
||||||
|
|
||||||
# get total pages
|
|
||||||
pages_total = parseInt( ( @tickets_count / @overview.view[@view_mode].per_page ) + 0.99999 ) || 1
|
|
||||||
|
|
||||||
# render init page
|
# render init page
|
||||||
checkbox = true
|
checkbox = true
|
||||||
|
@ -152,8 +149,6 @@ class Index extends App.Controller
|
||||||
html = App.view('agent_ticket_view')(
|
html = App.view('agent_ticket_view')(
|
||||||
overview: @overview
|
overview: @overview
|
||||||
view_modes: view_modes
|
view_modes: view_modes
|
||||||
pages_total: pages_total
|
|
||||||
start_page: @start_page
|
|
||||||
checkbox: checkbox
|
checkbox: checkbox
|
||||||
edit: edit
|
edit: edit
|
||||||
)
|
)
|
||||||
|
@ -179,7 +174,7 @@ class Index extends App.Controller
|
||||||
)
|
)
|
||||||
@el.find('.table-overview').append(table)
|
@el.find('.table-overview').append(table)
|
||||||
else
|
else
|
||||||
shown_all_attributes = @ticketTableAttributes( App.Overview.find( @overview.id ).view.s.overview )
|
shown_all_attributes = @ticketTableAttributes( App.Overview.find( @overview.id ).view.s )
|
||||||
groupBy = undefined
|
groupBy = undefined
|
||||||
if @overview.group_by
|
if @overview.group_by
|
||||||
group_by =
|
group_by =
|
||||||
|
@ -366,7 +361,7 @@ class Settings extends App.ControllerModal
|
||||||
tag: 'select'
|
tag: 'select'
|
||||||
multiple: false
|
multiple: false
|
||||||
null: false
|
null: false
|
||||||
default: @overview.view[@view_mode].per_page
|
# default: @overview.view[@view_mode].per_page
|
||||||
options:
|
options:
|
||||||
15: 15
|
15: 15
|
||||||
20: 20
|
20: 20
|
||||||
|
@ -380,7 +375,7 @@ class Settings extends App.ControllerModal
|
||||||
name: 'attributes'
|
name: 'attributes'
|
||||||
display: 'Attributes'
|
display: 'Attributes'
|
||||||
tag: 'checkbox'
|
tag: 'checkbox'
|
||||||
default: @overview.view[@view_mode].overview
|
default: @overview.view[@view_mode]
|
||||||
null: false
|
null: false
|
||||||
translate: true
|
translate: true
|
||||||
options:
|
options:
|
||||||
|
@ -481,10 +476,6 @@ class Settings extends App.ControllerModal
|
||||||
|
|
||||||
# check if refetch is needed
|
# check if refetch is needed
|
||||||
@reload_needed = 0
|
@reload_needed = 0
|
||||||
if @overview.view[@view_mode]['per_page'] isnt params['per_page']
|
|
||||||
@overview.view[@view_mode]['per_page'] = params['per_page']
|
|
||||||
@reload_needed = 1
|
|
||||||
|
|
||||||
if @overview.order['by'] isnt params['order_by']
|
if @overview.order['by'] isnt params['order_by']
|
||||||
@overview.order['by'] = params['order_by']
|
@overview.order['by'] = params['order_by']
|
||||||
@reload_needed = 1
|
@reload_needed = 1
|
||||||
|
@ -497,7 +488,7 @@ class Settings extends App.ControllerModal
|
||||||
@overview['group_by'] = params['group_by']
|
@overview['group_by'] = params['group_by']
|
||||||
@reload_needed = 1
|
@reload_needed = 1
|
||||||
|
|
||||||
@overview.view[@view_mode]['overview'] = params['attributes']
|
@overview.view[@view_mode] = params['attributes']
|
||||||
|
|
||||||
@overview.save(
|
@overview.save(
|
||||||
success: =>
|
success: =>
|
||||||
|
|
|
@ -236,12 +236,12 @@ class App.Navigation extends App.Controller
|
||||||
|
|
||||||
# add new views
|
# add new views
|
||||||
for item in data
|
for item in data
|
||||||
NavBar['TicketOverview' + item.url] = {
|
NavBar['TicketOverview' + item.link] = {
|
||||||
prio: item.prio,
|
prio: item.prio,
|
||||||
parent: '#ticket_view',
|
parent: '#ticket_view',
|
||||||
name: item.name,
|
name: item.name,
|
||||||
count: item.count,
|
count: item.count,
|
||||||
target: '#ticket_view/' + item.url,
|
target: '#ticket_view/' + item.link,
|
||||||
# role: ['Agent', 'Customer'],
|
# role: ['Agent', 'Customer'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ class App.Group extends App.Model
|
||||||
@configure_attributes = [
|
@configure_attributes = [
|
||||||
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false, 'class': 'span4' },
|
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false, 'class': 'span4' },
|
||||||
{ name: 'assignment_timeout', display: 'Assignment Timout', tag: 'input', note: 'Assignment timout in minutes if assigned agent is not working on it. Ticket will be shown as unassigend.', type: 'text', limit: 100, 'null': true, 'class': 'span4' },
|
{ name: 'assignment_timeout', display: 'Assignment Timout', tag: 'input', note: 'Assignment timout in minutes if assigned agent is not working on it. Ticket will be shown as unassigend.', type: 'text', limit: 100, 'null': true, 'class': 'span4' },
|
||||||
{ name: 'follow_up_possible', display: 'Follow possible', tag: 'select', default: 'yes', options: { yes: 'yes', reject: 'reject follow up/do not reopen Ticket', 'new_ticket': 'do not reopen Ticket but create new Ticket' }, 'null': false, note: 'Follow up for closed ticket possible or not.', 'class': 'span4' },
|
{ name: 'follow_up_possible', display: 'Follow up possible',tag: 'select', default: 'yes', options: { yes: 'yes', reject: 'reject follow up/do not reopen Ticket', 'new_ticket': 'do not reopen Ticket but create new Ticket' }, 'null': false, note: 'Follow up for closed ticket possible or not.', 'class': 'span4' },
|
||||||
{ name: 'follow_up_assignment', display: 'Assign Follow Ups', tag: 'select', default: 'yes', options: { yes: 'yes', no: 'no' }, 'null': false, note: 'Assign follow up to latest agent again.', 'class': 'span4' },
|
{ name: 'follow_up_assignment', display: 'Assign Follow Ups', tag: 'select', default: 'yes', options: { true: 'yes', false: 'no' }, 'null': false, note: 'Assign follow up to latest agent again.', 'class': 'span4' },
|
||||||
{ name: 'email_address_id', display: 'Email', tag: 'select', multiple: false, null: true, relation: 'EmailAddress', nulloption: true, class: 'span4' },
|
{ name: 'email_address_id', display: 'Email', tag: 'select', multiple: false, null: true, relation: 'EmailAddress', nulloption: true, class: 'span4' },
|
||||||
{ name: 'signature_id', display: 'Signature', tag: 'select', multiple: false, null: true, relation: 'Signature', nulloption: true, class: 'span4' },
|
{ name: 'signature_id', display: 'Signature', tag: 'select', multiple: false, null: true, relation: 'Signature', nulloption: true, class: 'span4' },
|
||||||
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, 'null': true, 'class': 'span4' },
|
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, 'null': true, 'class': 'span4' },
|
||||||
|
|
|
@ -1,17 +1,100 @@
|
||||||
class App.Overview extends Spine.Model
|
class App.Overview extends Spine.Model
|
||||||
@configure 'Overview', 'name', 'meta', 'condition', 'order', 'group_by', 'view', 'user_id', 'group_ids'
|
@configure 'Overview', 'name', 'link', 'prio', 'condition', 'order', 'group_by', 'view', 'user_id', 'organization_shared', 'role_id', 'order', 'group_by'
|
||||||
@extend Spine.Model.Ajax
|
@extend Spine.Model.Ajax
|
||||||
@url: 'api/overviews'
|
@url: 'api/overviews'
|
||||||
@configure_attributes = [
|
@configure_attributes = [
|
||||||
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false, 'class': 'span4' },
|
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false, 'class': 'span4' },
|
||||||
{ name: 'role_id', display: 'Role', tag: 'select', multiple: false, nulloption: true, null: false, relation: 'Role', class: 'span4' },
|
{ name: 'link', display: 'URL', tag: 'input', type: 'text', limit: 100, 'null': false, 'class': 'span4' },
|
||||||
{ name: 'user_id', display: 'User', tag: 'select', multiple: false, nulloption: true, null: true, relation: 'User', class: 'span4' },
|
{ name: 'role_id', display: 'Available for Role', tag: 'select', multiple: false, nulloption: true, null: false, relation: 'Role', translate: true, class: 'span4' },
|
||||||
|
{ name: 'user_id', display: 'Available for User', tag: 'select', multiple: true, nulloption: true, null: true, relation: 'User', sortBy: 'firstname', class: 'span4' },
|
||||||
|
{ name: 'organization_shared', display: 'Only available for Users with shared Organization', tag: 'select', options: { true: 'yes', false: 'no' }, default: false, null: true, 'class': 'span4' },
|
||||||
# { name: 'content', display: 'Content', tag: 'textarea', limit: 250, 'null': false, 'class': 'span4' },
|
# { name: 'content', display: 'Content', tag: 'textarea', limit: 250, 'null': false, 'class': 'span4' },
|
||||||
|
{ name: 'condition', display: 'Conditions for shown Tickets', tag: 'ticket_attribute_selection', null: true, class: 'span4' },
|
||||||
|
{ name: 'prio', display: 'Prio', tag: 'input', type: 'text', limit: 10, 'null': false, 'class': 'span4' },
|
||||||
|
{
|
||||||
|
name: 'view::s'
|
||||||
|
display: 'Attributes'
|
||||||
|
tag: 'checkbox'
|
||||||
|
default: ['number', 'title', 'ticket_state', 'created_at']
|
||||||
|
null: false
|
||||||
|
translate: true
|
||||||
|
options:
|
||||||
|
number: 'Number'
|
||||||
|
title: 'Title'
|
||||||
|
customer: 'Customer'
|
||||||
|
ticket_state: 'State'
|
||||||
|
ticket_priority: 'Priority'
|
||||||
|
group: 'Group'
|
||||||
|
owner: 'Owner'
|
||||||
|
created_at: 'Age'
|
||||||
|
last_contact: 'Last Contact'
|
||||||
|
last_contact_agent: 'Last Contact Agent'
|
||||||
|
last_contact_customer: 'Last Contact Customer'
|
||||||
|
first_response: 'First Response'
|
||||||
|
close_time: 'Close Time'
|
||||||
|
article_count: 'Article Count'
|
||||||
|
class: 'medium'
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'order::by',
|
||||||
|
display: 'Order',
|
||||||
|
tag: 'select'
|
||||||
|
default: 'created_at'
|
||||||
|
null: false
|
||||||
|
translate: true
|
||||||
|
options:
|
||||||
|
number: 'Number'
|
||||||
|
title: 'Title'
|
||||||
|
customer: 'Customer'
|
||||||
|
ticket_state: 'State'
|
||||||
|
ticket_priority: 'Priority'
|
||||||
|
group: 'Group'
|
||||||
|
owner: 'Owner'
|
||||||
|
created_at: 'Age'
|
||||||
|
last_contact: 'Last Contact'
|
||||||
|
last_contact_agent: 'Last Contact Agent'
|
||||||
|
last_contact_customer: 'Last Contact Customer'
|
||||||
|
first_response: 'First Response'
|
||||||
|
close_time: 'Close Time'
|
||||||
|
article_count: 'Article Count'
|
||||||
|
class: 'span4'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'order::direction'
|
||||||
|
display: 'Direction'
|
||||||
|
tag: 'select'
|
||||||
|
default: 'down'
|
||||||
|
null: false
|
||||||
|
translate: true
|
||||||
|
options:
|
||||||
|
ASC: 'up'
|
||||||
|
DESC: 'down'
|
||||||
|
class: 'span4'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'group_by'
|
||||||
|
display: 'Group by'
|
||||||
|
tag: 'select'
|
||||||
|
default: ''
|
||||||
|
null: true
|
||||||
|
nulloption: true
|
||||||
|
translate: true
|
||||||
|
options:
|
||||||
|
customer: 'Customer'
|
||||||
|
ticket_state: 'State'
|
||||||
|
ticket_priority: 'Priority'
|
||||||
|
group: 'Group'
|
||||||
|
owner: 'Owner'
|
||||||
|
class: 'span4'
|
||||||
|
},
|
||||||
{ name: 'updated_at', display: 'Updated', type: 'time', readonly: 1 },
|
{ name: 'updated_at', display: 'Updated', type: 'time', readonly: 1 },
|
||||||
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', 'default': true, 'null': false, 'class': 'span4' },
|
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', 'default': true, 'null': false, 'class': 'span4' },
|
||||||
]
|
]
|
||||||
@configure_overview = [
|
@configure_overview = [
|
||||||
'name',
|
'name',
|
||||||
|
'link',
|
||||||
'role',
|
'role',
|
||||||
|
'prio',
|
||||||
'active',
|
'active',
|
||||||
]
|
]
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span9">
|
<div class="span9">
|
||||||
<h1><%- @T( @overview.meta.name ) %> <% if @edit: %><small><a href="#" data-type="settings" class="icon-edit"></a></small><% end %></h1>
|
<h1><%- @T( @overview.name ) %> <% if @edit: %><small><a href="#" data-type="settings" class="icon-edit"></a></small><% end %></h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="span3">
|
<div class="span3">
|
||||||
<div class="pagination pagination-small pagination-right">
|
<div class="pagination pagination-small pagination-right">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="span9">
|
<div class="span9">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span6">
|
<div class="span6">
|
||||||
<h2 class="can-move"><%- @T( @overview.meta.name ) %> <small><a href="#" data-type="settings" class="icon-edit"></a></small></h2>
|
<h2 class="can-move"><%- @T( @overview.name ) %> <small><a href="#" data-type="settings" class="icon-edit"></a></small></h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="span3">
|
<div class="span3">
|
||||||
<div class="pagination pagination-small pagination-right">
|
<div class="pagination pagination-small pagination-right">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<a href="#" class="close">×</a>
|
<a href="#" class="close">×</a>
|
||||||
<h2><%- @T( 'Edit' ) %>: <%- @T( @overview.meta.name ) %></h2>
|
<h2><%- @T( 'Edit' ) %>: <%- @T( @overview.name ) %></h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div id="form-setting"></div>
|
<div id="form-setting"></div>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
class Overview < ApplicationModel
|
class Overview < ApplicationModel
|
||||||
store :condition
|
store :condition
|
||||||
store :order
|
store :order
|
||||||
store :meta
|
|
||||||
store :view
|
store :view
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
validates :prio, :presence => true
|
||||||
|
validates :link, :presence => true
|
||||||
end
|
end
|
|
@ -265,7 +265,7 @@ class Ticket < ApplicationModel
|
||||||
overviews.each { |overview|
|
overviews.each { |overview|
|
||||||
|
|
||||||
# remember selected view
|
# remember selected view
|
||||||
if data[:view] && data[:view] == overview.meta[:url]
|
if data[:view] && data[:view] == overview.link
|
||||||
overview_selected = overview
|
overview_selected = overview
|
||||||
overview_selected_raw = Marshal.load( Marshal.dump(overview.attributes) )
|
overview_selected_raw = Marshal.load( Marshal.dump(overview.attributes) )
|
||||||
end
|
end
|
||||||
|
@ -328,7 +328,11 @@ class Ticket < ApplicationModel
|
||||||
count = Ticket.where( :group_id => group_ids ).where( overview.condition ).count()
|
count = Ticket.where( :group_id => group_ids ).where( overview.condition ).count()
|
||||||
|
|
||||||
# get meta info
|
# get meta info
|
||||||
all = overview.meta
|
all = {
|
||||||
|
:name => overview.name,
|
||||||
|
:prio => overview.prio,
|
||||||
|
:link => overview.link,
|
||||||
|
}
|
||||||
|
|
||||||
# push to result data
|
# push to result data
|
||||||
result.push all.merge( { :count => count } )
|
result.push all.merge( { :count => count } )
|
||||||
|
|
|
@ -167,7 +167,8 @@ class CreateTicket < ActiveRecord::Migration
|
||||||
t.references :user, :null => true
|
t.references :user, :null => true
|
||||||
t.references :role, :null => false
|
t.references :role, :null => false
|
||||||
t.column :name, :string, :limit => 250, :null => false
|
t.column :name, :string, :limit => 250, :null => false
|
||||||
t.column :meta, :string, :limit => 1000, :null => false
|
t.column :url, :string, :limit => 250, :null => false
|
||||||
|
t.column :prio, :integer, :null => false
|
||||||
t.column :condition, :string, :limit => 2500, :null => false
|
t.column :condition, :string, :limit => 2500, :null => false
|
||||||
t.column :order, :string, :limit => 2500, :null => false
|
t.column :order, :string, :limit => 2500, :null => false
|
||||||
t.column :group_by, :string, :limit => 250, :null => true
|
t.column :group_by, :string, :limit => 250, :null => true
|
||||||
|
|
16
db/migrate/20130130005817_overview_update.rb
Normal file
16
db/migrate/20130130005817_overview_update.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
class OverviewUpdate < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
add_column :overviews, :link, :string, :limit => 250, :null => false
|
||||||
|
add_column :overviews, :prio, :integer, :null => false
|
||||||
|
Overview.all.each {|overview|
|
||||||
|
overview.link = overview.meta[:url]
|
||||||
|
overview.name = overview.meta[:name]
|
||||||
|
overview.prio = overview.meta[:prio]
|
||||||
|
overview.save
|
||||||
|
}
|
||||||
|
remove_column :overviews, :meta
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue