Streamline of attribute selection for overviews.

This commit is contained in:
Martin Edenhofer 2016-09-28 14:12:28 +02:00
parent a83d0bc819
commit da2ce8e1b4
4 changed files with 72 additions and 118 deletions

View file

@ -0,0 +1,32 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.checkboxTicketAttributes extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
configureAttributes = App.Ticket.configure_attributes
for row, localAttribute of App.Ticket.attributesGet()
configureAttributes.push localAttribute
attributeOptionsArray = []
attributeOptions = {}
for row in configureAttributes
# ignore passwords
if row.type isnt 'password' && row.type isnt 'tag' && row.name isnt 'tags'
nameTmp = row.name
# get correct data name
if row.name.substr(row.name.length-4,4) is '_ids'
nameTmp = row.name.substr(0, row.name.length-4)
else if row.name.substr(row.name.length-3,3) is '_id'
nameTmp = row.name.substr(0, row.name.length-3)
if !attributeOptions[ nameTmp ]
attributeOptions[ nameTmp ] = row.display
attributeOptionsArray.push(
{
value: nameTmp
name: row.display
}
)
attribute.item_class = 'checkbox'
attribute.options = attributeOptions
App.UiElement.checkbox.render(attribute, params)

View file

@ -0,0 +1,31 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.selectTicketAttributes extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
configureAttributes = App.Ticket.configure_attributes
for row, localAttribute of App.Ticket.attributesGet()
configureAttributes.push localAttribute
attributeOptionsArray = []
attributeOptions = {}
for row in configureAttributes
# ignore passwords
if row.type isnt 'password' && row.type isnt 'tag' && row.name isnt 'tags'
nameTmp = row.name
# get correct data name
if row.name.substr(row.name.length-4,4) is '_ids'
nameTmp = row.name.substr(0, row.name.length-4)
else if row.name.substr(row.name.length-3,3) is '_id'
nameTmp = row.name.substr(0, row.name.length-3)
if !attributeOptions[ nameTmp ]
attributeOptions[ nameTmp ] = row.display
attributeOptionsArray.push(
{
value: nameTmp
name: row.display
}
)
attribute.options = attributeOptions
App.UiElement.select.render(attribute, params)

View file

@ -764,50 +764,24 @@ class App.OverviewSettings extends App.ControllerModal
25: '25' 25: '25'
}, },
}) })
attributeOptions = {}
attributeOptionsArray = []
configure_attributes = App.Ticket.configure_attributes
for row, attribute of App.Ticket.attributesGet()
configure_attributes.push attribute
for row in configure_attributes
# ignore passwords
if row.type isnt 'password'
name = row.name
# get correct data name
if row.name.substr(row.name.length-4,4) is '_ids'
name = row.name.substr(0, row.name.length-4)
else if row.name.substr(row.name.length-3,3) is '_id'
name = row.name.substr(0, row.name.length-3)
if !attributeOptions[ name ]
attributeOptions[ name ] = row.display
attributeOptionsArray.push(
{
value: name
name: row.display
}
)
@configure_attributes_article.push({ @configure_attributes_article.push({
name: "view::#{@view_mode}" name: "view::#{@view_mode}"
display: 'Attributes' display: 'Attributes'
tag: 'checkbox' tag: 'checkboxTicketAttributes'
default: @overview.view[@view_mode] default: @overview.view[@view_mode]
null: false null: false
translate: true translate: true
sortBy: null sortBy: null
options: attributeOptionsArray
}, },
{ {
name: 'order::by' name: 'order::by'
display: 'Order' display: 'Order'
tag: 'select' tag: 'selectTicketAttributes'
default: @overview.order.by default: @overview.order.by
null: false null: false
translate: true translate: true
sortBy: null sortBy: null
options: attributeOptionsArray
}, },
{ {
name: 'order::direction' name: 'order::direction'

View file

@ -13,99 +13,18 @@ class App.Overview extends App.Model
{ {
name: 'view::s' name: 'view::s'
display: 'Attributes' display: 'Attributes'
tag: 'checkbox' tag: 'checkboxTicketAttributes'
default: ['number', 'title', 'state', 'created_at'] default: ['number', 'title', 'state', 'created_at']
null: false null: false
translate: true translate: true
options: [
{
value: 'number'
name: 'Number'
}, },
{
value: 'title'
name: 'Title'
},
{
value: 'customer'
name: 'Customer'
},
{
value: 'state'
name: 'State'
},
{
value: 'priority'
name: 'Priority'
},
{
value: 'group'
name: 'Group'
},
{
value: 'owner'
name: 'Owner'
},
{
value: 'last_contact_at'
name: 'Last contact'
},
{
value: 'last_contact_agent_at'
name: 'Last contact (Agent)'
},
{
value: 'last_contact_customer_at'
name: 'Last contact (Customer)'
},
{
value: 'first_response_at'
name: 'First Response'
},
{
value: 'close_at'
name: 'Close time'
},
{
value: 'article_count'
name: 'Article Count'
},
{
value: 'updated_at'
name: 'Updated at'
},
{
value: 'created_at'
name: 'Created at'
},
]
class: 'medium'
},
{ {
name: 'order::by', name: 'order::by',
display: 'Order', display: 'Order',
tag: 'select' tag: 'selectTicketAttributes'
default: 'created_at' default: 'created_at'
null: false null: false
translate: true translate: true
options:
number: 'Number'
title: 'Title'
customer: 'Customer'
state: 'State'
priority: 'Priority'
group: 'Group'
owner: 'Owner'
last_contact_at: 'Last contact'
last_contact_agent_at: 'Last contact (Agent)'
last_contact_customer_at: 'Last contact (Customer)'
first_response_at: 'First Response'
close_at: 'Close time'
article_count: 'Article Count'
updated_at: 'Updated at'
created_at: 'Created at'
class: 'span4'
}, },
{ {
name: 'order::direction' name: 'order::direction'
@ -117,7 +36,6 @@ class App.Overview extends App.Model
options: options:
ASC: 'up' ASC: 'up'
DESC: 'down' DESC: 'down'
class: 'span4'
}, },
{ {
name: 'group_by' name: 'group_by'
@ -133,7 +51,6 @@ class App.Overview extends App.Model
priority: 'Priority' priority: 'Priority'
group: 'Group' group: 'Group'
owner: 'Owner' owner: 'Owner'
class: 'span4'
}, },
{ name: 'active', display: 'Active', tag: 'active', default: true }, { name: 'active', display: 'Active', tag: 'active', default: true },
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 }, { name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },