Improved performance of large object tables.
This commit is contained in:
parent
8800b6b61a
commit
9447a08e6e
4 changed files with 71 additions and 58 deletions
|
@ -264,6 +264,7 @@ class App.ControllerTable extends App.Controller
|
|||
table = App.view('generic/table')(
|
||||
table_id: @table_id
|
||||
header: @headers
|
||||
attributes: attributes
|
||||
objects: @objects
|
||||
checkbox: @checkbox
|
||||
radio: @radio
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
|
||||
#= require_self
|
||||
#= require_tree ./lib/app_init
|
||||
#= require ./config.coffee
|
||||
|
@ -10,7 +9,8 @@
|
|||
#= require_tree ./lib/app_post
|
||||
|
||||
class App extends Spine.Controller
|
||||
@viewPrint: (object, attribute_name) ->
|
||||
@viewPrint: (object, attribute_name, attributes) ->
|
||||
if !attributes
|
||||
attributes = {}
|
||||
if object.constructor.attributesGet
|
||||
attributes = object.constructor.attributesGet()
|
||||
|
@ -34,11 +34,9 @@ class App extends Spine.Controller
|
|||
if parts[0] && parts[1] && object[ parts[0] ]
|
||||
value = object[ parts[0] ][ parts[1] ]
|
||||
|
||||
#console.log('Pa', attribute_name, object, attribute_config, object[attribute_name], valueRef, value)
|
||||
|
||||
# if we have no config, get output this way
|
||||
if !attribute_config
|
||||
return @viewPrintItem( value )
|
||||
return @viewPrintItem(value)
|
||||
|
||||
# check if valueRef already exists, no lookup needed later
|
||||
if !valueRef
|
||||
|
@ -48,10 +46,10 @@ class App extends Spine.Controller
|
|||
if object[attribute_name_without_ref]
|
||||
valueRef = object[attribute_name_without_ref]
|
||||
|
||||
return @viewPrintItem( value, attribute_config, valueRef )
|
||||
@viewPrintItem(value, attribute_config, valueRef)
|
||||
|
||||
# define print name helper
|
||||
@viewPrintItem: ( item, attribute_config = {}, valueRef ) ->
|
||||
@viewPrintItem: (item, attribute_config = {}, valueRef) ->
|
||||
return '-' if item is undefined
|
||||
return '-' if item is ''
|
||||
return item if !item
|
||||
|
@ -77,13 +75,13 @@ class App extends Spine.Controller
|
|||
|
||||
# execute callback on content
|
||||
if attribute_config.callback
|
||||
result = attribute_config.callback( result, attribute_config )
|
||||
result = attribute_config.callback(result, attribute_config)
|
||||
|
||||
# text2html in textarea view
|
||||
isHtmlEscape = false
|
||||
if attribute_config.tag is 'textarea'
|
||||
isHtmlEscape = true
|
||||
result = App.Utils.text2html( result )
|
||||
result = App.Utils.text2html(result)
|
||||
|
||||
# remember, html snippets are already escaped
|
||||
else if attribute_config.tag is 'richtext'
|
||||
|
@ -95,9 +93,9 @@ class App extends Spine.Controller
|
|||
result = attribute_config.options[result]
|
||||
|
||||
# translate content
|
||||
if attribute_config.translate || ( isObject && item.translate && item.translate() )
|
||||
if attribute_config.translate || (isObject && item.translate && item.translate())
|
||||
isHtmlEscape = true
|
||||
result = App.i18n.translateContent( result )
|
||||
result = App.i18n.translateContent(result)
|
||||
|
||||
# transform date
|
||||
if attribute_config.tag is 'date'
|
||||
|
@ -121,71 +119,71 @@ class App extends Spine.Controller
|
|||
result
|
||||
|
||||
@view: (name) ->
|
||||
template = ( params = {} ) ->
|
||||
template = (params = {}) ->
|
||||
|
||||
# define print name helper
|
||||
params.P = ( object, attribute_name ) ->
|
||||
App.viewPrint( object, attribute_name )
|
||||
params.P = (object, attribute_name, attributes) ->
|
||||
App.viewPrint(object, attribute_name, attributes)
|
||||
|
||||
# define date format helper
|
||||
params.date = ( time ) ->
|
||||
params.date = (time) ->
|
||||
return '' if !time
|
||||
|
||||
timeObject = new Date(time)
|
||||
d = App.Utils.formatTime( timeObject.getDate(), 2 )
|
||||
m = App.Utils.formatTime( timeObject.getMonth() + 1, 2 )
|
||||
d = App.Utils.formatTime(timeObject.getDate(), 2)
|
||||
m = App.Utils.formatTime(timeObject.getMonth() + 1, 2)
|
||||
y = timeObject.getFullYear()
|
||||
"#{y}-#{m}-#{d}"
|
||||
|
||||
# define datetime format helper
|
||||
params.datetime = ( time ) ->
|
||||
params.datetime = (time) ->
|
||||
return '' if !time
|
||||
|
||||
timeObject = new Date(time)
|
||||
d = App.Utils.formatTime( timeObject.getDate(), 2 )
|
||||
m = App.Utils.formatTime( timeObject.getMonth() + 1, 2 )
|
||||
d = App.Utils.formatTime(timeObject.getDate(), 2)
|
||||
m = App.Utils.formatTime(timeObject.getMonth() + 1, 2)
|
||||
y = timeObject.getFullYear()
|
||||
S = App.Utils.formatTime( timeObject.getSeconds(), 2 )
|
||||
M = App.Utils.formatTime( timeObject.getMinutes(), 2 )
|
||||
H = App.Utils.formatTime( timeObject.getHours(), 2 )
|
||||
S = App.Utils.formatTime(timeObject.getSeconds(), 2)
|
||||
M = App.Utils.formatTime(timeObject.getMinutes(), 2)
|
||||
H = App.Utils.formatTime(timeObject.getHours(), 2)
|
||||
"#{y}-#{m}-#{d} #{H}:#{M}:#{S}"
|
||||
|
||||
# define decimal format helper
|
||||
params.decimal = ( data, positions = 2 ) ->
|
||||
params.decimal = (data, positions = 2) ->
|
||||
App.Utils.decimal(data, positions)
|
||||
|
||||
# define translation helper
|
||||
params.T = ( item, args... ) ->
|
||||
App.i18n.translateContent( item, args... )
|
||||
params.T = (item, args...) ->
|
||||
App.i18n.translateContent(item, args...)
|
||||
|
||||
# define translation inline helper
|
||||
params.Ti = ( item, args... ) ->
|
||||
App.i18n.translateInline( item, args... )
|
||||
params.Ti = (item, args...) ->
|
||||
App.i18n.translateInline(item, args...)
|
||||
|
||||
# define translation for date helper
|
||||
params.Tdate = ( item, args... ) ->
|
||||
App.i18n.translateDate( item, args... )
|
||||
params.Tdate = (item, args...) ->
|
||||
App.i18n.translateDate(item, args...)
|
||||
|
||||
# define translation for timestamp helper
|
||||
params.Ttimestamp = ( item, args... ) ->
|
||||
App.i18n.translateTimestamp( item, args... )
|
||||
params.Ttimestamp = (item, args...) ->
|
||||
App.i18n.translateTimestamp(item, args...)
|
||||
|
||||
# define linkify helper
|
||||
params.L = ( item ) ->
|
||||
params.L = (item) ->
|
||||
if item && typeof item is 'string'
|
||||
return App.Utils.linkify( item )
|
||||
return App.Utils.linkify(item)
|
||||
item
|
||||
|
||||
# define config helper
|
||||
params.C = ( key ) ->
|
||||
App.Config.get( key )
|
||||
params.C = (key) ->
|
||||
App.Config.get(key)
|
||||
|
||||
# define session helper
|
||||
params.S = ( key ) ->
|
||||
App.Session.get( key )
|
||||
params.S = (key) ->
|
||||
App.Session.get(key)
|
||||
|
||||
# define address line helper
|
||||
params.AddressLine = ( line ) ->
|
||||
params.AddressLine = (line) ->
|
||||
return '' if !line
|
||||
items = emailAddresses.parseAddressList(line)
|
||||
|
||||
|
@ -202,15 +200,14 @@ class App extends Spine.Controller
|
|||
result = result + App.Utils.htmlEscape(item.name) + ' '
|
||||
if item.address
|
||||
result = result + " <span class=\"text-muted\"><#{App.Utils.htmlEscape(item.address)}></span>"
|
||||
|
||||
result
|
||||
|
||||
# define file size helper
|
||||
params.humanFileSize = ( size ) ->
|
||||
params.humanFileSize = (size) ->
|
||||
App.Utils.humanFileSize(size)
|
||||
|
||||
# define pretty/human time helper
|
||||
params.humanTime = ( time, escalation = false, cssClass = '') ->
|
||||
params.humanTime = (time, escalation = false, cssClass = '') ->
|
||||
timestamp = App.i18n.translateTimestamp(time)
|
||||
if escalation
|
||||
cssClass += ' escalation'
|
||||
|
@ -222,7 +219,7 @@ class App extends Spine.Controller
|
|||
App.Utils.icon(name, className)
|
||||
|
||||
# define richtext helper
|
||||
params.RichText = ( string ) ->
|
||||
params.RichText = (string) ->
|
||||
if string.match(/@T\('/)
|
||||
string = string.replace(/@T\('(.+?)'\)/g, (match, capture) ->
|
||||
App.i18n.translateContent(capture)
|
||||
|
|
|
@ -27,6 +27,11 @@ class App.Log
|
|||
_instance ?= new _Singleton
|
||||
_instance.config( type, regex )
|
||||
|
||||
@timeTrack: (message) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance.timeTrack(message)
|
||||
|
||||
class _Singleton
|
||||
constructor: ->
|
||||
@moduleColorsMap = {}
|
||||
|
@ -116,3 +121,13 @@ class _Singleton
|
|||
@hue += goldenRatio
|
||||
@hue = @hue % 1
|
||||
@hue * 360
|
||||
|
||||
timeTrack: (message) =>
|
||||
currentTime = new Date().getTime()
|
||||
if !@lastTime
|
||||
@lastTime = currentTime
|
||||
console.log('timeTrack start', message)
|
||||
else
|
||||
diff = currentTime - @lastTime
|
||||
@lastTime = currentTime
|
||||
console.log('timeTrack start', message, diff)
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<% groupLast = '' %>
|
||||
<% for object in @objects: %>
|
||||
<% if @groupBy: %>
|
||||
<% groupByName = @P( object, @groupBy ) %>
|
||||
<% groupByName = @P( object, @groupBy, @attributes ) %>
|
||||
<% if groupLast isnt groupByName: %>
|
||||
<tr class=""><td colspan="<%= length %>"><b><%= groupByName %></b></td></tr>
|
||||
<% groupLast = groupByName %>
|
||||
|
@ -68,7 +68,7 @@
|
|||
</td>
|
||||
<% end %>
|
||||
<% for item in @header: %>
|
||||
<% value = @P( object, item.name ) %>
|
||||
<% value = @P( object, item.name, @attributes ) %>
|
||||
<% if @callbacks: %>
|
||||
<% if item.name.substr(item.name.length-3, item.name.length) is '_id' && object[ item.name.substr(0, item.name.length-3) ]: %>
|
||||
<% refObject = object[ item.name.substr(0, item.name.length-3) ] %>
|
||||
|
|
Loading…
Reference in a new issue