Add order direction to table overview.

This commit is contained in:
Martin Edenhofer 2015-09-29 22:07:50 +02:00
parent e570e110c5
commit 24ef928c96
4 changed files with 23 additions and 9 deletions

View file

@ -72,7 +72,7 @@ class App.ControllerTable extends App.Controller
'mouseover': rowMouseover
'mouseout': rowMouseout
'dblclick': rowDblClick
callbackHeader: callbackHeader
callbackHeader: [callbackHeader]
callbackAttributes:
attributeName: [
callbackAttributes
@ -161,7 +161,8 @@ class App.ControllerTable extends App.Controller
# execute header callback
if data.callbackHeader
header = data.callbackHeader(header)
for callback in data.callbackHeader
header = callback(header)
# get content
@log 'debug', 'table', 'header', header, 'overview', 'objects', data.objects

View file

@ -264,15 +264,28 @@ class Table extends App.Controller
@el.find('.bulkAction').addClass('hide')
else
@el.find('.bulkAction').removeClass('hide')
callbackIconHeader = (header) ->
callbackIconHeader = (headers) ->
attribute =
name: 'icon'
display: ''
translation: false
style: 'width: 28px'
header.unshift(0)
header[0] = attribute
header
headers.unshift(0)
headers[0] = attribute
headers
callbackSortOrderHeader = (headers) =>
return headers if !@overview
return headers if !@overview.order
return headers if !@overview.order.by
for header in headers
if header.name is @overview.order.by
if @overview.order.direction is 'DESC'
header.sortOrderIcon = ['arrow-down', 'table-sort-arrow']
else
header.sortOrderIcon = ['arrow-up', 'table-sort-arrow']
else
header.sortOrderIcon = undefined
headers
callbackIcon = (value, object, attribute, header, refObject) ->
value = ' '
attribute.class = object.iconClass()
@ -294,7 +307,7 @@ class Table extends App.Controller
# customer_id:
# events:
# 'mouseover': popOver
callbackHeader: callbackIconHeader
callbackHeader: [ callbackIconHeader, callbackSortOrderHeader ]
callbackAttributes:
icon:
[ callbackIcon ]

View file

@ -107,7 +107,7 @@ class Index extends App.Controller
model: App.User
objects: users
class: 'user-list'
callbackHeader: callbackHeader
callbackHeader: [callbackHeader]
callbackAttributes:
switch_to: [
callbackAttributes

View file

@ -46,7 +46,7 @@ class App.TicketList extends App.Controller
overview: [ 'number', 'title', 'customer', 'group', 'created_at' ]
model: App.Ticket
objects: list
callbackHeader: callbackIconHeader
callbackHeader: [ callbackIconHeader ]
callbackAttributes:
icon:
[ callbackIcon ]