Only do resizing of columns if table is shown. Followup for issue #2031.

This commit is contained in:
Martin Edenhofer 2018-11-26 07:50:41 +01:00
parent aa6dd3f2ca
commit 50c2a8540e
18 changed files with 149 additions and 69 deletions

View file

@ -425,9 +425,15 @@ class App.ControllerSubContent extends App.Controller
super
show: =>
if @genericController && @genericController.show
@genericController.show()
return if !@header
@title @header, true
hide: =>
if @genericController && @genericController.hide
@genericController.hide()
class App.ControllerContent extends App.Controller
constructor: ->
if @requiredPermission

View file

@ -132,6 +132,14 @@ class App.ControllerGenericIndex extends App.Controller
clear: true
)
show: =>
if @table
@table.show()
hide: =>
if @table
@table.hide()
release: =>
if @subscribeId
App[ @genericObject ].unsubscribe(@subscribeId)
@ -371,6 +379,18 @@ class App.ControllerTabs extends App.Controller
if !@permissionCheckRedirect(@requiredPermission)
throw "No permission for #{@requiredPermission}"
show: =>
return if !@controllerList
for localeController in @controllerList
if localeController && localeController.show
localeController.show()
hide: =>
return if !@controllerList
for localeController in @controllerList
if localeController && localeController.hide
localeController.hide()
render: ->
@html App.view('generic/tabs')(
header: @header
@ -387,7 +407,8 @@ class App.ControllerTabs extends App.Controller
params.name = tab.name
params.target = tab.target
params.el = @$("##{tab.target}")
new tab.controller( params )
@controllerList ||= []
@controllerList.push new tab.controller(params)
# check if tabs need to be show / cant' use .tab(), because tabs are note shown (only one tab exists)
if @tabs.length <= 1
@ -422,9 +443,10 @@ class App.ControllerNavSidbar extends App.Controller
@updateNavigation(true)
)
show: (params) =>
show: (params = {}) =>
@navupdate ''
@shown = true
if params
for key, value of params
if key isnt 'el' && key isnt 'shown' && key isnt 'match'
@[key] = value

View file

@ -171,8 +171,15 @@ class App.ControllerTable extends App.Controller
@renderQueue()
show: =>
return if @windowIsResized isnt true
@windowIsResized = false
@onResize()
hide: ->
release: =>
$(window).off 'resize.table', @onResize
$(window).off('resize.table', @onResize)
update: (params) =>
if params.sync is true
@ -214,12 +221,12 @@ class App.ControllerTable extends App.Controller
if _.isEmpty(@objects)
@renderState = 'emptyList'
@el.html(@renderEmptyList())
$(window).on 'resize.table', @onResize
$(window).on('resize.table', @onResize)
return ['emptyList.new']
else
@renderState = 'List'
@renderTableFull()
$(window).on 'resize.table', @onResize
$(window).on('resize.table', @onResize)
return ['fullRender.new']
else if @renderState is 'emptyList' && !_.isEmpty(@objects)
@renderState = 'List'
@ -378,8 +385,8 @@ class App.ControllerTable extends App.Controller
if @tableId
# enable resize column
container.on 'mousedown', '.js-col-resize', @onColResizeMousedown
container.on 'click', '.js-col-resize', @stopPropagation
container.on('mousedown', '.js-col-resize', @onColResizeMousedown)
container.on('click', '.js-col-resize', @stopPropagation)
# enable checkbox bulk selection
if @checkbox
@ -628,17 +635,16 @@ class App.ControllerTable extends App.Controller
@headers.push
name: 'action'
display: 'Action'
width: '38px'
displayWidth: 38
unresizeable: true
width: '50px'
displayWidth: 50
align: 'right'
parentClass: 'noTruncate no-padding'
unresizable: true
@bindCol['action'] =
events:
click: @toggleActionDropdown
if @tableId
@calculateHeaderWidths()
@columnsLength = @headers.length
@ -818,6 +824,7 @@ class App.ControllerTable extends App.Controller
@runAction(name, id)
calculateHeaderWidths: ->
return if !@tableId
return if !@headers
availableWidth = @availableWidth
@ -838,7 +845,7 @@ class App.ControllerTable extends App.Controller
if roundingLeftOver > 0 && roundingLeftOver < 10
@headers[@headers.length - 1].displayWidth = @headers[@headers.length - 1].displayWidth + roundingLeftOver
@storeHeaderWidths()
true
getShrinkableHeadersCount: ->
_.reduce @headers, (memo, col) ->
@ -868,11 +875,13 @@ class App.ControllerTable extends App.Controller
widths
setHeaderWidths: =>
@calculateHeaderWidths()
return if !@calculateHeaderWidths()
@$('.js-tableHead').each (i, el) =>
el.style.width = @headers[i].displayWidth + 'px'
@storeHeaderWidths()
storeHeaderWidths: ->
widths = {}
@ -882,7 +891,12 @@ class App.ControllerTable extends App.Controller
App.LocalStorage.set(@preferencesStoreKey(), { headerWidth: widths }, @Session.get('id'))
onResize: =>
@availableWidth = @el.width()
localWidth = @el.width()
if localWidth is 0
@windowIsResized = true
return
@availableWidth = localWidth
localDelay = =>
localSetHeaderWidths = =>
@setHeaderWidths()
@ -901,8 +915,8 @@ class App.ControllerTable extends App.Controller
@resizeLeftStartWidth = @resizeTargetLeft.width()
@resizeRightStartWidth = @resizeTargetRight.width()
$(document).on 'mousemove.resizeCol', @onColResizeMousemove
$(document).one 'mouseup', @onColResizeMouseup
$(document).on('mousemove.resizeCol', @onColResizeMousemove)
$(document).one('mouseup', @onColResizeMouseup)
@tableWidth = @el.width()
@ -920,7 +934,7 @@ class App.ControllerTable extends App.Controller
@resizeTargetRight.width @resizeRightStartWidth - difference
onColResizeMouseup: =>
$(document).off 'mousemove.resizeCol'
$(document).off('mousemove.resizeCol')
# switch to percentage
resizeBaseWidth = @resizeTargetLeft.parents('table').width()

View file

@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
constructor: ->
super
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'Group'

View file

@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
constructor: ->
super
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'Job'

View file

@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
constructor: ->
super
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'Macro'

View file

@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
constructor: ->
super
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'Organization'

View file

@ -9,7 +9,7 @@ class Index extends App.ControllerSubContent
if attribute.name is 'group_by'
attribute.options = App.Overview.groupByAttributes()
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'Overview'

View file

@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
constructor: ->
super
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'ReportProfile'

View file

@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
constructor: ->
super
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'Role'

View file

@ -55,6 +55,8 @@ class App.Search extends App.Controller
'#search'
show: (params) =>
if @table
@table.show()
@navupdate(url: '#search', type: 'menu')
return if _.isEmpty(params.query)
@$('.js-search').val(params.query).trigger('change')
@ -63,6 +65,8 @@ class App.Search extends App.Controller
hide: ->
@shown = false
if @table
@table.hide()
changed: ->
# nothing
@ -158,7 +162,7 @@ class App.Search extends App.Controller
ticket_ids = []
for item in localList
ticket_ids.push item.id
new App.TicketList(
@table = new App.TicketList(
tableId: "find_#{model}"
el: @$('.js-content')
columns: [ 'number', 'title', 'customer', 'group', 'owner', 'created_at' ]
@ -169,7 +173,7 @@ class App.Search extends App.Controller
openObject = (id,e) =>
object = App[@model].fullLocal(id)
@navigate object.uiUrl()
new App.ControllerTable(
@table = new App.ControllerTable(
tableId: "find_#{model}"
el: @$('.js-content')
model: App[model]

View file

@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
constructor: ->
super
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'TextModule'

View file

@ -669,17 +669,22 @@ class App.TicketOverview extends App.Controller
# build nav bar
if @navBarController
@navBarController.update
@navBarController.update(
view: @view
activeState: true
)
if @navBarControllerVertical
@navBarControllerVertical.update
@navBarControllerVertical.update(
view: @view
activeState: true
)
# do not rerender overview if current overview is requested again
return if @viewLast is @view
if @viewLast is @view
if @contentController
@contentController.show()
return
# remember last view
@viewLast = @view
@ -699,6 +704,8 @@ class App.TicketOverview extends App.Controller
@navBarController.active(false)
if @navBarControllerVertical
@navBarControllerVertical.active(false)
if @contentController
@contentController.hide()
setPosition: (position) =>
@$('.main').scrollTop(position)
@ -945,6 +952,14 @@ class Table extends App.Controller
return if !@view
@render(App.OverviewListCollection.get(@view))
show: =>
if @table
@table.show()
hide: =>
if @table
@table.hide()
release: =>
if @bindId
App.OverviewListCollection.unbind(@bindId)

View file

@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
constructor: ->
super
new App.ControllerGenericIndex(
@genericController = new App.ControllerGenericIndex(
el: @el
id: @id
genericObject: 'Trigger'

View file

@ -11,6 +11,16 @@ class Index extends App.ControllerSubContent
super
@render()
show: =>
super
return if !@table
@table.show()
hide: =>
super
return if !@table
@table.hide()
render: ->
@html App.view('user')(
head: 'Users'
@ -52,6 +62,8 @@ class Index extends App.ControllerSubContent
className: 'actionCell'
translation: true
width: '200px'
displayWidth: 200
unresizable: true
header.push attribute
header
@ -111,7 +123,7 @@ class Index extends App.ControllerSubContent
users.push user
@$('.table-overview').html('')
new App.ControllerTable(
@table = new App.ControllerTable(
tableId: 'users_admin_overview'
el: @$('.table-overview')
model: App.User

View file

@ -4,9 +4,16 @@ class App.TicketList extends App.Controller
constructor: ->
super
@render()
show: =>
if @table
@table.show()
hide: =>
if @table
@table.hide()
render: =>
openTicket = (id,e) =>
@ -62,7 +69,7 @@ class App.TicketList extends App.Controller
ticketItem = App.Ticket.fullLocal(ticket_id)
list.push ticketItem
@el.html('')
new App.ControllerTable(
@table = new App.ControllerTable(
tableId: @tableId
el: @el
overview: @columns || [ 'number', 'title', 'customer', 'group', 'created_at' ]

View file

@ -24,7 +24,7 @@
<div class="table-column-title"><%- @T(header.display) %></div>
<div class="table-column-sortIcon"><% if header.sortOrderIcon: %><%- @Icon(header.sortOrderIcon[0], header.sortOrderIcon[1]) %><% end %></div>
</div>
<% if @tableId && !header.unresizable && i < @headers.length - 1: %>
<% if @tableId && !header.unresizable && i < @headers.length - 1 && (@headers.length - 1 != i && @headers[ i + 1 ] && !@headers[ i + 1 ].unresizable): %>
<div class="table-col-resize js-col-resize"></div>
<% end %>
</th>