Only do resizing of columns if table is shown. Followup for issue #2031.
This commit is contained in:
parent
aa6dd3f2ca
commit
50c2a8540e
18 changed files with 149 additions and 69 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -386,8 +406,9 @@ class App.ControllerTabs extends App.Controller
|
|||
params = tab.params || {}
|
||||
params.name = tab.name
|
||||
params.target = tab.target
|
||||
params.el = @$( "##{tab.target}" )
|
||||
new tab.controller( params )
|
||||
params.el = @$("##{tab.target}")
|
||||
@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,12 +443,13 @@ class App.ControllerNavSidbar extends App.Controller
|
|||
@updateNavigation(true)
|
||||
)
|
||||
|
||||
show: (params) =>
|
||||
show: (params = {}) =>
|
||||
@navupdate ''
|
||||
@shown = true
|
||||
for key, value of params
|
||||
if key isnt 'el' && key isnt 'shown' && key isnt 'match'
|
||||
@[key] = value
|
||||
if params
|
||||
for key, value of params
|
||||
if key isnt 'el' && key isnt 'shown' && key isnt 'match'
|
||||
@[key] = value
|
||||
@updateNavigation()
|
||||
if @activeController && _.isFunction(@activeController.show)
|
||||
@activeController.show(params)
|
||||
|
|
|
@ -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'
|
||||
|
@ -342,7 +349,7 @@ class App.ControllerTable extends App.Controller
|
|||
do (container, event, callback) ->
|
||||
if cursorMap[event]
|
||||
container.find("tbody > tr > td:nth-child(#{position})").css('cursor', cursorMap[event])
|
||||
container.on( event, "tbody > tr > td:nth-child(#{position})",
|
||||
container.on(event, "tbody > tr > td:nth-child(#{position})",
|
||||
(e) ->
|
||||
e.stopPropagation()
|
||||
id = $(e.target).parents('tr').data('id')
|
||||
|
@ -356,7 +363,7 @@ class App.ControllerTable extends App.Controller
|
|||
do (container, event, callback) ->
|
||||
if cursorMap[event]
|
||||
container.find('tbody > tr').css( 'cursor', cursorMap[event] )
|
||||
container.on( event, 'tbody > tr',
|
||||
container.on(event, 'tbody > tr',
|
||||
(e) ->
|
||||
id = $(e.target).parents('tr').data('id')
|
||||
callback(id, e)
|
||||
|
@ -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
|
||||
|
@ -626,20 +633,19 @@ class App.ControllerTable extends App.Controller
|
|||
|
||||
if @actions.length
|
||||
@headers.push
|
||||
name: 'action'
|
||||
display: 'Action'
|
||||
width: '38px'
|
||||
displayWidth: 38
|
||||
unresizeable: true
|
||||
align: 'right'
|
||||
parentClass: 'noTruncate no-padding'
|
||||
name: 'action'
|
||||
display: 'Action'
|
||||
width: '50px'
|
||||
displayWidth: 50
|
||||
align: 'right'
|
||||
parentClass: 'noTruncate no-padding'
|
||||
unresizable: true
|
||||
|
||||
@bindCol['action'] =
|
||||
events:
|
||||
click: @toggleActionDropdown
|
||||
|
||||
if @tableId
|
||||
@calculateHeaderWidths()
|
||||
@calculateHeaderWidths()
|
||||
|
||||
@columnsLength = @headers.length
|
||||
if @checkbox || @radio
|
||||
|
@ -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()
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
new App.ControllerGenericIndex(
|
||||
@genericController = new App.ControllerGenericIndex(
|
||||
el: @el
|
||||
id: @id
|
||||
genericObject: 'Group'
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
new App.ControllerGenericIndex(
|
||||
@genericController = new App.ControllerGenericIndex(
|
||||
el: @el
|
||||
id: @id
|
||||
genericObject: 'Job'
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
new App.ControllerGenericIndex(
|
||||
@genericController = new App.ControllerGenericIndex(
|
||||
el: @el
|
||||
id: @id
|
||||
genericObject: 'Macro'
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
new App.ControllerGenericIndex(
|
||||
@genericController = new App.ControllerGenericIndex(
|
||||
el: @el
|
||||
id: @id
|
||||
genericObject: 'Organization'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -307,12 +307,12 @@ class Download extends App.Controller
|
|||
value
|
||||
callbackIconHeader = (headers) ->
|
||||
attribute =
|
||||
name: 'icon'
|
||||
display: ''
|
||||
translation: false
|
||||
width: '28px'
|
||||
displayWidth:28
|
||||
unresizable: true
|
||||
name: 'icon'
|
||||
display: ''
|
||||
translation: false
|
||||
width: '28px'
|
||||
displayWidth: 28
|
||||
unresizable: true
|
||||
headers.unshift(0)
|
||||
headers[0] = attribute
|
||||
headers
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
new App.ControllerGenericIndex(
|
||||
@genericController = new App.ControllerGenericIndex(
|
||||
el: @el
|
||||
id: @id
|
||||
genericObject: 'ReportProfile'
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
new App.ControllerGenericIndex(
|
||||
@genericController = new App.ControllerGenericIndex(
|
||||
el: @el
|
||||
id: @id
|
||||
genericObject: 'Role'
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
new App.ControllerGenericIndex(
|
||||
@genericController = new App.ControllerGenericIndex(
|
||||
el: @el
|
||||
id: @id
|
||||
genericObject: 'TextModule'
|
||||
|
|
|
@ -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)
|
||||
|
@ -1123,12 +1138,12 @@ class Table extends App.Controller
|
|||
@lastChecked = e.currentTarget
|
||||
callbackIconHeader = (headers) ->
|
||||
attribute =
|
||||
name: 'icon'
|
||||
display: ''
|
||||
translation: false
|
||||
width: '28px'
|
||||
displayWidth:28
|
||||
unresizable: true
|
||||
name: 'icon'
|
||||
display: ''
|
||||
translation: false
|
||||
width: '28px'
|
||||
displayWidth: 28
|
||||
unresizable: true
|
||||
headers.unshift(0)
|
||||
headers[0] = attribute
|
||||
headers
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
new App.ControllerGenericIndex(
|
||||
@genericController = new App.ControllerGenericIndex(
|
||||
el: @el
|
||||
id: @id
|
||||
genericObject: 'Trigger'
|
||||
|
|
|
@ -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'
|
||||
|
@ -47,11 +57,13 @@ class Index extends App.ControllerSubContent
|
|||
|
||||
callbackHeader = (header) ->
|
||||
attribute =
|
||||
name: 'switch_to'
|
||||
display: 'Action'
|
||||
className: 'actionCell'
|
||||
translation: true
|
||||
width: '200px'
|
||||
name: 'switch_to'
|
||||
display: 'Action'
|
||||
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
|
||||
|
|
|
@ -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) =>
|
||||
|
@ -40,12 +47,12 @@ class App.TicketList extends App.Controller
|
|||
|
||||
callbackIconHeader = (headers) ->
|
||||
attribute =
|
||||
name: 'icon'
|
||||
display: ''
|
||||
translation: false
|
||||
width: '28px'
|
||||
displayWidth:28
|
||||
unresizable: true
|
||||
name: 'icon'
|
||||
display: ''
|
||||
translation: false
|
||||
width: '28px'
|
||||
displayWidth: 28
|
||||
unresizable: true
|
||||
headers.unshift(0)
|
||||
headers[0] = attribute
|
||||
headers
|
||||
|
@ -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' ]
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue