Improved memory management.

This commit is contained in:
Martin Edenhofer 2016-10-15 21:21:44 +02:00
parent f5de9086b7
commit d092db4cd8
11 changed files with 78 additions and 66 deletions

View file

@ -152,8 +152,9 @@ class App.ControllerTable extends App.Controller
# check if table is empty
if _.isEmpty(@objects)
table = App.view('generic/admin/empty')
table = App.view('generic/admin/empty')(
explanation: @explanation
)
return $(table)
# get header data
@ -234,7 +235,7 @@ class App.ControllerTable extends App.Controller
# if we need to sort a relation
if header.relation
if item[header.name]
App[header.relation].find(item[header.name]).displayName()
App[header.relation].findNative(item[header.name]).displayName()
else
''
else

View file

@ -8,36 +8,36 @@ class App.UiElement.ApplicationUiElement
return if !attribute.options
# arrays can only get ordered
if _.isArray(attribute.options)
# reverse if we have to exit early, if configured
if attribute.order
if attribute.order == 'DESC'
attribute.options = attribute.options.reverse()
return
options_by_name = []
for i in attribute.options
options_by_name.push i['name'].toString().toLowerCase()
options_by_name = options_by_name.sort()
options_new = []
options_new_used = {}
for i in options_by_name
for ii, vv in attribute.options
if !options_new_used[ ii['value'] ] && i.toString().toLowerCase() is ii['name'].toString().toLowerCase()
options_new_used[ ii['value'] ] = 1
options_new.push ii
attribute.options = options_new
# do a final reverse, if configured
if attribute.order
if attribute.order == 'DESC'
# reverse - we have to exit early
if attribute.order && attribute.order == 'DESC'
attribute.options = attribute.options.reverse()
return
# sort by name
optionsByName = []
optionsByNameWithValue = {}
for i, value of attribute.options
valueTmp = value.toString().toLowerCase()
optionsByName.push valueTmp
optionsByNameWithValue[valueTmp] = i
optionsByName = optionsByName.sort()
# do a reverse, if needed
if attribute.order && attribute.order == 'DESC'
optionsByName = optionsByName.reverse()
optionsNew = []
for i in optionsByName
optionsNew.push optionsByNameWithValue[i]
attribute.options = optionsNew
@addNullOption: (attribute) ->
return if !attribute.options
return if !attribute.nulloption
if _.isArray( attribute.options )
if _.isArray(attribute.options)
attribute.options.unshift({ name: '-', value: '' })
else
attribute.options[''] = '-'
@ -64,6 +64,7 @@ class App.UiElement.ApplicationUiElement
name: name_new
value: key
}
attribute.sortBy = null
@getRelationOptionList: (attribute, params) ->
@ -154,19 +155,21 @@ class App.UiElement.ApplicationUiElement
# if active or if active doesn't exist
if item.active || !activeSupport || isSelected
name_new = '?'
nameNew = '?'
if item.displayName
name_new = item.displayName()
nameNew = item.displayName()
else if item.name
name_new = item.name
nameNew = item.name
if attribute.translate
name_new = App.i18n.translateInline(name_new)
nameNew = App.i18n.translateInline(nameNew)
attribute.options.push {
name: name_new,
name: nameNew,
value: item.id,
note: item.note,
}
attribute.sortBy = null
# execute filter
@filterOption: (attribute) ->
return if !attribute.filter

View file

@ -174,9 +174,6 @@ class App.Navigation extends App.ControllerWidgetPermanent
render: ->
# reset result cache
@searchResultCache = {}
user = App.Session.get()
@html App.view('navigation')(
user: user

View file

@ -338,12 +338,12 @@ class Table extends App.Controller
tickets = data.tickets
# get ticket list
ticket_list_show = []
ticketListShow = []
for ticket in tickets
ticket_list_show.push App.Ticket.fullLocal(ticket.id)
ticketListShow.push App.Ticket.fullLocal(ticket.id)
# if customer and no ticket exists, show the following message only
if !ticket_list_show[0] && @permissionCheck('ticket.customer')
if !ticketListShow[0] && @permissionCheck('ticket.customer')
@html App.view('customer_not_ticket_exists')()
return
@ -388,7 +388,7 @@ class Table extends App.Controller
if @view_mode is 'm'
table = App.view('agent_ticket_view/detail')(
overview: @overview
objects: ticket_list_show
objects: ticketListShow
checkbox: checkbox
)
table = $(table)
@ -403,9 +403,9 @@ class Table extends App.Controller
openTicket = (id,e) =>
# open ticket via task manager to provide task with overview info
ticket = App.Ticket.fullLocal(id)
ticket = App.Ticket.findNative(id)
App.TaskManager.execute(
key: 'Ticket-' + ticket.id
key: "Ticket-#{ticket.id}"
controller: 'TicketZoom'
params:
ticket_id: ticket.id
@ -457,7 +457,7 @@ class Table extends App.Controller
overview: @overview.view.s
el: @$('.table-overview')
model: App.Ticket
objects: ticket_list_show
objects: ticketListShow
checkbox: checkbox
groupBy: @overview.group_by
orderBy: @overview.order.by
@ -524,16 +524,16 @@ class Table extends App.Controller
getSelected: ->
@ticketIDs = []
@$('.table-overview').find('[name="bulk"]:checked').each( (index, element) =>
ticket_id = $(element).val()
@ticketIDs.push ticket_id
ticketId = $(element).val()
@ticketIDs.push ticketId
)
@ticketIDs
setSelected: (ticketIDs) ->
@$('.table-overview').find('[name="bulk"]').each( (index, element) ->
ticket_id = $(element).val()
for ticket_id_selected in ticketIDs
if ticket_id_selected is ticket_id
ticketId = $(element).val()
for ticketIdSelected in ticketIDs
if ticketIdSelected is ticketId
$(element).attr('checked', true)
)

View file

@ -75,6 +75,9 @@ class App.TicketZoom extends App.Controller
fetch: (ignoreSame = false) =>
return if !@Session.get()
queue = false
if !@initFetched
queue = true
# get data
@ajax(
@ -82,7 +85,7 @@ class App.TicketZoom extends App.Controller
type: 'GET'
url: "#{@apiPath}/tickets/#{@ticket_id}?all=true"
processData: true
queue: true
queue: queue
success: (data, status, xhr) =>
@load(data, ignoreSame)
App.SessionStorage.set(@key, data)
@ -196,7 +199,7 @@ class App.TicketZoom extends App.Controller
# set icon and title based on ticket
if @ticket_id && App.Ticket.exists(@ticket_id)
ticket = App.Ticket.find(@ticket_id)
ticket = App.Ticket.findNative(@ticket_id)
meta.head = ticket.title
meta.title = "##{ticket.number} - #{ticket.title}"
meta.class = "task-state-#{ ticket.getState() }"
@ -489,6 +492,7 @@ class App.TicketZoom extends App.Controller
if @article_id
@pagePositionData = @article_id
@pagePosition(type: 'init')
@positionPageHeaderStart()
@initDone = true
return

View file

@ -7,7 +7,7 @@ class App.TicketList extends App.Controller
render: =>
openTicket = (id,e) =>
ticket = App.Ticket.fullLocal(id)
ticket = App.Ticket.findNative(id)
@navigate ticket.uiUrl()
callbackTicketTitleAdd = (value, object, attribute, attributes, refObject) ->
attribute.title = object.title

View file

@ -102,13 +102,13 @@ class _collectionSingleton extends Spine.Module
@log 'debug', 'refresh try', params.type, key
# check if new object is newer, just load newer objects
if object.updated_at && appObject.exists(key)
exists = appObject.find(key)
if object.updated_at
currentUpdatedAt = appObject.updatedAt(key)
objectToLoad = undefined
if exists.updated_at
if exists.updated_at < object.updated_at
if currentUpdatedAt
if currentUpdatedAt < object.updated_at
objectToLoad = object
@log 'debug', 'refresh newser', params.type, key
@log 'debug', 'refresh newer', params.type, key
else
objectToLoad = object
@log 'debug', 'refresh try no updated_at', params.type, key

View file

@ -588,7 +588,7 @@ class App.Model extends Spine.Model
# only if relation record exists in collection
if App[ attribute.relation ].exists(data[attribute.name])
item = App[attribute.relation].find(data[attribute.name])
item = App[attribute.relation].findNative(data[attribute.name])
item = App[attribute.relation]._fillUp(item, classNames.concat(@className))
data[withoutId] = item
else
@ -630,11 +630,11 @@ class App.Model extends Spine.Model
all_complied = []
if !params
for item in all
item_new = @find(item.id)
item_new = @findNative(item.id)
all_complied.push @_fillUp(item_new)
return all_complied
for item in all
item_new = @find(item.id)
item_new = @findNative(item.id)
all_complied.push @_fillUp(item_new)
# filter search
@ -693,7 +693,7 @@ class App.Model extends Spine.Model
collection
@_filterExtended: (collection, filters) ->
collection = _.filter( collection, (item) ->
collection = _.filter(collection, (item) ->
# check all filters
for filter in filters
@ -704,7 +704,7 @@ class App.Model extends Spine.Model
if matchInner isnt false
reg = new RegExp( value, 'i' )
if item[ key ] isnt undefined && item[ key ] isnt null && item[ key ].match( reg )
if item[ key ] isnt undefined && item[ key ] isnt null && item[ key ].match(reg)
matchInner = true
else
matchInner = false
@ -729,3 +729,10 @@ class App.Model extends Spine.Model
else if item.updated_at > updated_at
updated_at = item.updated_at
updated_at
@updatedAt: (id) ->
return if !@irecords[id]
@irecords[id].updated_at
@findNative: (id) ->
@irecords[id] or notFound?(id)

View file

@ -25,7 +25,7 @@ Mit **Organisationen** können Sie Kunden **gruppieren**. Dies hat u. a. zwei be
'''
uiUrl: ->
'#organization/profile/' + @id
"#organization/profile/#{@id}"
icon: ->
'organization'
@ -37,7 +37,7 @@ Mit **Organisationen** können Sie Kunden **gruppieren**. Dies hat u. a. zwei be
data['members'] = []
for user_id in data['member_ids']
if App.User.exists(user_id)
user = App.User.find(user_id)
user = App.User.findNative(user_id)
data['members'].push user
data

View file

@ -30,7 +30,7 @@ class App.Role extends App.Model
data['permissions'] = []
for permission_id in data['permission_ids']
if App.Permission.exists(permission_id)
permission = App.Permission.find(permission_id)
permission = App.Permission.findNative(permission_id)
data['permissions'].push permission
data

View file

@ -120,20 +120,20 @@ class App.User extends App.Model
data['accounts'][account]['link'] = 'https://www.facebook.com/profile.php?id=' + data['accounts'][account]['uid']
if data.organization_id
data.organization = App.Organization.find(data.organization_id)
data.organization = App.Organization.findNative(data.organization_id)
if data['role_ids']
data['roles'] = []
for role_id in data['role_ids']
if App.Role.exists(role_id)
role = App.Role.find(role_id)
role = App.Role.findNative(role_id)
data['roles'].push role
if data['group_ids']
data['groups'] = []
for group_id in data['group_ids']
if App.Group.exists(group_id)
group = App.Group.find(group_id)
group = App.Group.findNative(group_id)
data['groups'].push group
data
@ -191,10 +191,10 @@ class App.User extends App.Model
# get all permissions of user
permissions = {}
for role_id in @role_ids
role = App.Role.find(role_id)
role = App.Role.findNative(role_id)
if role.active is true
for permission_id in role.permission_ids
permission = App.Permission.find(permission_id)
permission = App.Permission.findNative(permission_id)
permissions[permission.name] = true
for localKey in keys