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 super
show: => show: =>
if @genericController && @genericController.show
@genericController.show()
return if !@header return if !@header
@title @header, true @title @header, true
hide: =>
if @genericController && @genericController.hide
@genericController.hide()
class App.ControllerContent extends App.Controller class App.ControllerContent extends App.Controller
constructor: -> constructor: ->
if @requiredPermission if @requiredPermission

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,9 +4,16 @@ class App.TicketList extends App.Controller
constructor: -> constructor: ->
super super
@render() @render()
show: =>
if @table
@table.show()
hide: =>
if @table
@table.hide()
render: => render: =>
openTicket = (id,e) => openTicket = (id,e) =>
@ -62,7 +69,7 @@ class App.TicketList extends App.Controller
ticketItem = App.Ticket.fullLocal(ticket_id) ticketItem = App.Ticket.fullLocal(ticket_id)
list.push ticketItem list.push ticketItem
@el.html('') @el.html('')
new App.ControllerTable( @table = new App.ControllerTable(
tableId: @tableId tableId: @tableId
el: @el el: @el
overview: @columns || [ 'number', 'title', 'customer', 'group', 'created_at' ] 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-title"><%- @T(header.display) %></div>
<div class="table-column-sortIcon"><% if header.sortOrderIcon: %><%- @Icon(header.sortOrderIcon[0], header.sortOrderIcon[1]) %><% end %></div> <div class="table-column-sortIcon"><% if header.sortOrderIcon: %><%- @Icon(header.sortOrderIcon[0], header.sortOrderIcon[1]) %><% end %></div>
</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> <div class="table-col-resize js-col-resize"></div>
<% end %> <% end %>
</th> </th>