Add order direction to table overview.
This commit is contained in:
parent
e570e110c5
commit
24ef928c96
4 changed files with 23 additions and 9 deletions
|
@ -72,7 +72,7 @@ class App.ControllerTable extends App.Controller
|
||||||
'mouseover': rowMouseover
|
'mouseover': rowMouseover
|
||||||
'mouseout': rowMouseout
|
'mouseout': rowMouseout
|
||||||
'dblclick': rowDblClick
|
'dblclick': rowDblClick
|
||||||
callbackHeader: callbackHeader
|
callbackHeader: [callbackHeader]
|
||||||
callbackAttributes:
|
callbackAttributes:
|
||||||
attributeName: [
|
attributeName: [
|
||||||
callbackAttributes
|
callbackAttributes
|
||||||
|
@ -161,7 +161,8 @@ class App.ControllerTable extends App.Controller
|
||||||
|
|
||||||
# execute header callback
|
# execute header callback
|
||||||
if data.callbackHeader
|
if data.callbackHeader
|
||||||
header = data.callbackHeader(header)
|
for callback in data.callbackHeader
|
||||||
|
header = callback(header)
|
||||||
|
|
||||||
# get content
|
# get content
|
||||||
@log 'debug', 'table', 'header', header, 'overview', 'objects', data.objects
|
@log 'debug', 'table', 'header', header, 'overview', 'objects', data.objects
|
||||||
|
|
|
@ -264,15 +264,28 @@ class Table extends App.Controller
|
||||||
@el.find('.bulkAction').addClass('hide')
|
@el.find('.bulkAction').addClass('hide')
|
||||||
else
|
else
|
||||||
@el.find('.bulkAction').removeClass('hide')
|
@el.find('.bulkAction').removeClass('hide')
|
||||||
callbackIconHeader = (header) ->
|
callbackIconHeader = (headers) ->
|
||||||
attribute =
|
attribute =
|
||||||
name: 'icon'
|
name: 'icon'
|
||||||
display: ''
|
display: ''
|
||||||
translation: false
|
translation: false
|
||||||
style: 'width: 28px'
|
style: 'width: 28px'
|
||||||
header.unshift(0)
|
headers.unshift(0)
|
||||||
header[0] = attribute
|
headers[0] = attribute
|
||||||
header
|
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) ->
|
callbackIcon = (value, object, attribute, header, refObject) ->
|
||||||
value = ' '
|
value = ' '
|
||||||
attribute.class = object.iconClass()
|
attribute.class = object.iconClass()
|
||||||
|
@ -294,7 +307,7 @@ class Table extends App.Controller
|
||||||
# customer_id:
|
# customer_id:
|
||||||
# events:
|
# events:
|
||||||
# 'mouseover': popOver
|
# 'mouseover': popOver
|
||||||
callbackHeader: callbackIconHeader
|
callbackHeader: [ callbackIconHeader, callbackSortOrderHeader ]
|
||||||
callbackAttributes:
|
callbackAttributes:
|
||||||
icon:
|
icon:
|
||||||
[ callbackIcon ]
|
[ callbackIcon ]
|
||||||
|
|
|
@ -107,7 +107,7 @@ class Index extends App.Controller
|
||||||
model: App.User
|
model: App.User
|
||||||
objects: users
|
objects: users
|
||||||
class: 'user-list'
|
class: 'user-list'
|
||||||
callbackHeader: callbackHeader
|
callbackHeader: [callbackHeader]
|
||||||
callbackAttributes:
|
callbackAttributes:
|
||||||
switch_to: [
|
switch_to: [
|
||||||
callbackAttributes
|
callbackAttributes
|
||||||
|
|
|
@ -46,7 +46,7 @@ class App.TicketList extends App.Controller
|
||||||
overview: [ 'number', 'title', 'customer', 'group', 'created_at' ]
|
overview: [ 'number', 'title', 'customer', 'group', 'created_at' ]
|
||||||
model: App.Ticket
|
model: App.Ticket
|
||||||
objects: list
|
objects: list
|
||||||
callbackHeader: callbackIconHeader
|
callbackHeader: [ callbackIconHeader ]
|
||||||
callbackAttributes:
|
callbackAttributes:
|
||||||
icon:
|
icon:
|
||||||
[ callbackIcon ]
|
[ callbackIcon ]
|
||||||
|
|
Loading…
Reference in a new issue