From cff7cd57bdaa940cabfd6f6dbfbb5d8ca9af4105 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 29 Oct 2015 10:20:43 +0100 Subject: [PATCH] Fixed table content group by. --- .../_application_controller_table.coffee | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_table.coffee b/app/assets/javascripts/app/controllers/_application_controller_table.coffee index 30bd831b7..c53bb37eb 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_table.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_table.coffee @@ -128,42 +128,6 @@ class App.ControllerTable extends App.Controller explanation: @explanation return $(table) - # group by - if @groupBy - - # remove group by attribute from header - overview = _.filter( - overview - (item) => - return item if item isnt @groupBy - return - ) - - # get new order - groupObjects = _.groupBy( - @objects - (item) => - return '' if !item[@groupBy] - return item[@groupBy].displayName() if item[@groupBy].displayName - item[@groupBy] - ) - groupOrder = [] - for group, value of groupObjects - groupOrder.push group - - # sort new groups - groupOrder = _.sortBy( - groupOrder - (item) -> - item - ) - - # create new data array - @objects = [] - for group in groupOrder - @objects = @objects.concat groupObjects[group] - groupObjects[group] = [] # release old array - # get header data headers = [] for item in overview @@ -221,6 +185,42 @@ class App.ControllerTable extends App.Controller headers = @adjustHeaderWidths headers + # group by + if @groupBy + + # remove group by attribute from header + overview = _.filter( + overview + (item) => + return item if item isnt @groupBy + return + ) + + # get new order + groupObjects = _.groupBy( + @objects + (item) => + return '' if !item[@groupBy] + return item[@groupBy].displayName() if item[@groupBy].displayName + item[@groupBy] + ) + groupOrder = [] + for group, value of groupObjects + groupOrder.push group + + # sort new groups + groupOrder = _.sortBy( + groupOrder + (item) -> + item + ) + + # create new data array + @objects = [] + for group in groupOrder + @objects = @objects.concat groupObjects[group] + groupObjects[group] = [] # release old array + # get content @log 'debug', 'table', 'header', headers, 'overview', 'objects', @objects table = App.view('generic/table')(