From c6411fd91486c261138797aa568ad89c2a4ab4e2 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 19 Nov 2018 18:43:44 +0100 Subject: [PATCH] Fixed resizing of table by browser window resize. Related to issue #2031. --- .../_application_controller_table.coffee | 22 +++++++++++-------- .../app/controllers/ticket_overview.coffee | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_table.coffee b/app/assets/javascripts/app/controllers/_application_controller_table.coffee index 6db5b370b..76d1c6f7f 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_table.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_table.coffee @@ -100,9 +100,6 @@ class App.ControllerTable extends App.Controller destroyColWidth: 70 cloneColWidth: 70 - elements: - '.js-tableHead': 'tableHead' - events: 'click .js-sort': 'sortByColumn' @@ -167,9 +164,10 @@ class App.ControllerTable extends App.Controller for key, value of data.headerWidth @headerWidth[key] = value - @availableWidth = @el.width() - if @availableWidth is 0 - @availableWidth = @minTableWidth + if !@availableWidth + @availableWidth = @el.width() + if @availableWidth is 0 + @availableWidth = @minTableWidth @renderQueue() @@ -837,7 +835,7 @@ class App.ControllerTable extends App.Controller roundingLeftOver = availableWidth - @getHeaderWidths() # but only if there is something left over (will get negative when there are too many columns for each column to stay in their min width) - if roundingLeftOver > 0 + if roundingLeftOver > 0 && roundingLeftOver < 10 @headers[@headers.length - 1].displayWidth = @headers[@headers.length - 1].displayWidth + roundingLeftOver @storeHeaderWidths() @@ -872,7 +870,7 @@ class App.ControllerTable extends App.Controller setHeaderWidths: => @calculateHeaderWidths() - @tableHead.each (i, el) => + @$('.js-tableHead').each (i, el) => el.style.width = @headers[i].displayWidth + 'px' storeHeaderWidths: -> @@ -885,7 +883,13 @@ class App.ControllerTable extends App.Controller onResize: => @availableWidth = @el.width() - @setHeaderWidths() + localDelay = => + localSetHeaderWidths = => + @setHeaderWidths() + App.QueueManager.add('tableRender', localSetHeaderWidths) + App.QueueManager.run('tableRender') + + @delay(localDelay, 200, 'table-resize-finish') stopPropagation: (event) -> event.stopPropagation() diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index 3c186591c..8da834f17 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -1181,7 +1181,7 @@ class Table extends App.Controller if @el.width() != 0 @elWidth = @el.width() if @elWidth - tableArguments.minTableWidth = @elWidth + tableArguments.availableWidth = @elWidth @table = new App.ControllerTable(tableArguments)