Reducred render() count on ui:rerender (e. g. language change).

This commit is contained in:
Martin Edenhofer 2016-07-07 18:32:26 +02:00
parent 2894764697
commit 4e01b0c229
18 changed files with 184 additions and 154 deletions

View file

@ -463,7 +463,7 @@ class App.Controller extends Spine.Controller
fetch = (params) =>
@ajax(
type: 'GET'
url: @Config.get('api_path') + '/ticket_customer'
url: "#{@Config.get('api_path')}/ticket_customer"
data:
customer_id: params.user_id
processData: true

View file

@ -768,6 +768,7 @@ class App.CollectionController extends App.Controller
sortBy: 'name'
order: 'ASC',
insertPosition: 'after'
globalRerender: true
constructor: ->
@events = @constructor.events unless @events
@ -788,6 +789,7 @@ class App.CollectionController extends App.Controller
@subscribeId = App[@model].subscribe(@collectionSync)
# render on generic ui call
if @globalRerender
@bind('ui:rerender', =>
@queue.push ['renderAll']
@uIRunner()
@ -1074,6 +1076,7 @@ class App.CollectionController extends App.Controller
class App.ObserverController extends App.Controller
model: 'Ticket'
template: 'ticket_zoom/title'
globalRerender: true
###
observe:
@ -1096,7 +1099,9 @@ class App.ObserverController extends App.Controller
@maybeRender(object)
# rerender, e. g. on language change
if @globalRerender
@bind('ui:rerender', =>
console.log('REREN')
@lastAttributres = undefined
object = App[@model].fullLocal(@object_id)
@maybeRender(object)

View file

@ -10,11 +10,6 @@ class App.OrganizationProfile extends App.Controller
# fetch new data if needed
App.Organization.full(@organization_id, @render)
# rerender view, e. g. on langauge change
@bind 'ui:rerender', =>
return if !@authenticate(true)
@render(App.Organization.fullLocal(@organization_id))
meta: =>
meta =
url: @url()
@ -48,6 +43,11 @@ class App.OrganizationProfile extends App.Controller
organization: organization
))
new ActionRow(
el: elLocal.find('.js-action')
object_id: organization.id
)
new Object(
el: elLocal.find('.js-object-container')
object_id: organization.id
@ -65,6 +65,50 @@ class App.OrganizationProfile extends App.Controller
genericObject: organization
)
class ActionRow extends App.ObserverController
model: 'Organization'
observe:
member_ids: true
render: (organization) =>
# start action controller
showHistory = ->
new App.OrganizationHistory(
organization_id: organization.id
container: @el.closest('.content')
)
editOrganization = =>
new App.ControllerGenericEdit(
id: organization.id
genericObject: 'Organization'
screen: 'edit'
pageData:
title: 'Organizations'
object: 'Organization'
objects: 'Organizations'
container: @el.closest('.content')
)
actions = [
{
name: 'edit'
title: 'Edit'
callback: editOrganization
}
{
name: 'history'
title: 'History'
callback: showHistory
}
]
new App.ActionRow(
el: @el
items: actions
)
class Object extends App.ObserverController
model: 'Organization'
observeNot:
@ -124,43 +168,6 @@ class Object extends App.ObserverController
members.push el
@$('.js-userList').html(members)
# start action controller
showHistory = ->
new App.OrganizationHistory(
organization_id: organization.id
container: @el.closest('.content')
)
editOrganization = =>
new App.ControllerGenericEdit(
id: organization.id
genericObject: 'Organization'
screen: 'edit'
pageData:
title: 'Organizations'
object: 'Organization'
objects: 'Organizations'
container: @el.closest('.content')
)
actions = [
{
name: 'edit'
title: 'Edit'
callback: editOrganization
}
{
name: 'history'
title: 'History'
callback: showHistory
}
]
new App.ActionRow(
el: @el.find('.js-action')
items: actions
)
update: (e) =>
name = $(e.target).attr('data-name')
value = $(e.target).html()
@ -179,6 +186,7 @@ class Member extends App.ObserverController
lastname: true
login: true
email: true
globalRerender: false
render: (user) =>
@html App.view('organization_profile/member')(

View file

@ -53,17 +53,10 @@ class App.TicketZoom extends App.Controller
@delay(update, 1200, "ticket-zoom-#{@ticket_id}")
)
# rerender view, e. g. on langauge change
@bind('ui:rerender', =>
@fetch(true)
)
fetchStart: (force) =>
if !force && @fetchIsRunning
fetchStart: =>
if @fetchIsRunning
@fetchIsRunningAgain = true
return false
if force
@fetchIsRunningAgain = false
@fetchIsRunning = true
true
@ -73,9 +66,9 @@ class App.TicketZoom extends App.Controller
@fetchIsRunningAgain = false
@fetch()
fetch: (force) =>
fetch: =>
return if !@Session.get()
return if !@fetchStart(force)
return if !@fetchStart()
# get data
@ajax(
@ -88,7 +81,7 @@ class App.TicketZoom extends App.Controller
# check if ticket has changed
newTicketRaw = data.assets.Ticket[@ticket_id]
if @ticketUpdatedAtLastCall && !force
if @ticketUpdatedAtLastCall
# return if ticket hasnt changed
return if @ticketUpdatedAtLastCall is newTicketRaw.updated_at

View file

@ -244,7 +244,7 @@ class ArticleViewItem extends App.ObserverController
metaTop = article.find('.article-content-meta.top')
metaBottom = article.find('.article-content-meta.bottom')
if @elementContainsSelection( article.get(0) )
if @elementContainsSelection(article.get(0))
@stopPropagation(e)
return false

View file

@ -2,6 +2,7 @@ class App.TicketCustomerAvatar extends App.ObserverController
model: 'Ticket'
observe:
customer_id: true
globalRerender: false
render: (ticket) =>
new App.WidgetAvatar(

View file

@ -3,6 +3,7 @@ class Edit extends App.ObserverController
observeNot:
created_at: true
updated_at: true
globalRerender: false
render: (ticket, diff) =>
defaults = ticket.attributes()

View file

@ -3,6 +3,7 @@ class App.TicketZoomTitle extends App.ObserverController
template: 'ticket_zoom/title'
observe:
title: true
globalRerender: false
events:
'blur .js-objectTitle': 'update'

View file

@ -10,11 +10,6 @@ class App.UserProfile extends App.Controller
# fetch new data if needed
App.User.full(@user_id, @render)
# rerender view, e. g. on langauge change
@bind 'ui:rerender', =>
return if !@authenticate(true)
@render(App.User.fullLocal(@user_id))
meta: =>
meta =
url: @url()
@ -48,6 +43,11 @@ class App.UserProfile extends App.Controller
user: user
))
new ActionRow(
el: elLocal.find('.js-action')
object_id: user.id
)
new Object(
el: elLocal.find('.js-object-container')
object_id: user.id
@ -65,6 +65,50 @@ class App.UserProfile extends App.Controller
genericObject: user
)
class ActionRow extends App.ObserverController
model: 'User'
observe:
organization_id: true
render: (user) =>
# start action controller
showHistory = =>
new App.UserHistory(
user_id: user.id
container: @el.closest('.content')
)
editUser = =>
new App.ControllerGenericEdit(
id: user.id
genericObject: 'User'
screen: 'edit'
pageData:
title: 'Users'
object: 'User'
objects: 'Users'
container: @el.closest('.content')
)
actions = [
{
name: 'edit'
title: 'Edit'
callback: editUser
}
{
name: 'history'
title: 'History'
callback: showHistory
}
]
new App.ActionRow(
el: @el
items: actions
)
class Object extends App.ObserverController
model: 'User'
observeNot:
@ -122,43 +166,6 @@ class Object extends App.ObserverController
el: @$('.js-organization')
)
# start action controller
showHistory = =>
new App.UserHistory(
user_id: user.id
container: @el.closest('.content')
)
editUser = =>
new App.ControllerGenericEdit(
id: user.id
genericObject: 'User'
screen: 'edit'
pageData:
title: 'Users'
object: 'User'
objects: 'Users'
container: @el.closest('.content')
)
actions = [
{
name: 'edit'
title: 'Edit'
callback: editUser
}
{
name: 'history'
title: 'History'
callback: showHistory
}
]
new App.ActionRow(
el: @el.find('.js-action')
items: actions
)
update: (e) =>
name = $(e.target).attr('data-name')
value = $(e.target).html()

View file

@ -6,6 +6,7 @@ class App.WidgetAvatar extends App.ObserverController
lastname: true
email: true
image: true
globalRerender: false
render: (user) =>
@html(user.avatar @size, @position, undefined, false, false, @type)

View file

@ -51,6 +51,12 @@ class App.OnlineNotificationWidget extends App.Controller
@createContainer()
# rerender view, e. g. on langauge change
@bind('ui:rerender', =>
@createContainer()
'online_notification'
)
release: ->
$(window).off 'click.notifications'
$(window).off 'keydown.notifications'
@ -202,6 +208,7 @@ class App.OnlineNotificationContentWidget extends App.CollectionController
order: 'DESC'
alreadyShown: {}
insertPosition: 'before'
globalRerender: false
onRenderEnd: =>
@container.counterGen()

View file

@ -14,9 +14,14 @@ class App.TicketStats extends App.Controller
# subscribe and reload data / fetch new data if triggered
if @user
@subscribeIdUser = App.User.full( @user.id, @load, false, true )
@subscribeIdUser = App.User.full(@user.id, @load, false, true)
else if @organization
@subscribeIdOrganization = App.Organization.full( @organization.id, @load, false, true )
@subscribeIdOrganization = App.Organization.full(@organization.id, @load, false, true)
# rerender view, e. g. on langauge change
@bind 'ui:rerender', =>
return if !@authenticate(true)
@render()
release: =>
if @subscribeIdUser
@ -35,13 +40,14 @@ class App.TicketStats extends App.Controller
user_id: @user.id
organization_id: @user.organization_id
@ajax(
id: 'ticket_stats_' + ajaxKey
id: "ticket_stats_#{ajaxKey}"
type: 'GET'
url: @apiPath + '/ticket_stats'
url: "#{@apiPath}/ticket_stats"
data: data
processData: true
success: (data) =>
App.Collection.loadAssets( data.assets )
App.Collection.loadAssets(data.assets)
@data = data
@render(data)
)
@ -58,6 +64,8 @@ class App.TicketStats extends App.Controller
@orgTab.addClass('hide')
render: (data) =>
if !data
data = @data
@html App.view('widget/ticket_stats')(
user: @user

View file

@ -359,8 +359,8 @@ class App.Model extends Spine.Model
if param.clear is true || param.clear is false
clear = param.clear
if !@initFetchActive
@one 'refresh', (collection) =>
@initFetchActive = true
@one 'refresh', (collection) ->
callback(collection)
@fetchFull(
->

View file

@ -1,5 +1,12 @@
<div class="profile">
<div class="profile-window">
<div class="profile-section vertical centered">
<div class="align-right profile-action js-action"></div>
<div class="profile-organizationIcon">
<%- @Icon('organization') %>
</div>
<h1><%= @organization.displayName() %></h1>
</div>
<div class="js-object-container"></div>
<div class="profile-section js-ticket-stats"></div>
</div>

View file

@ -1,23 +1,16 @@
<div class="profile-section vertical centered">
<div class="align-right profile-action js-action"></div>
<div class="profile-organizationIcon">
<%- @Icon('organization') %>
</div>
<h1><%= @organization.displayName() %></h1>
</div>
<div class="profile-section">
<div class="profile-details horizontal wrap">
<% for row in @organizationData: %>
<% if row.tag is 'richtext': %>
<div class="profile-detailsEntry" style="width: 100%;">
<label><%- @Ti( row.display ) %></label>
<label><%- @T(row.display) %></label>
<div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @Ti('Add a Note') %>"><%- @organization[row.name] %></div>
</div>
<% else: %>
<% if @organization[row.name]: %>
<div class="profile-detailsEntry">
<label><%- @Ti( row.display ) %></label>
<%- @P( @organization, row.name ) %>
<label><%- @T(row.display) %></label>
<%- @P(@organization, row.name) %>
</div>
<% end %>
<% end %>

View file

@ -3,25 +3,25 @@
<div class="article-meta top">
<% if @article.from: %>
<div class="horizontal article-meta-row">
<div class="article-meta-key u-textTruncate"><%- @T( 'From' ) %></div>
<div class="article-meta-key u-textTruncate"><%- @T('From') %></div>
<div class="article-meta-value flex contain-text"><%- @AddressLine(@article.from) %></div>
</div>
<% end %>
<% if @article.to: %>
<div class="horizontal article-meta-row">
<div class="article-meta-key u-textTruncate"><%- @T( 'To' ) %></div>
<div class="article-meta-key u-textTruncate"><%- @T('To') %></div>
<div class="article-meta-value flex contain-text"><%- @AddressLine(@article.to) %></div>
</div>
<% end %>
<% if @article.cc: %>
<div class="horizontal article-meta-row">
<div class="article-meta-key u-textTruncate"><%- @T( 'Cc' ) %></div>
<div class="article-meta-key u-textTruncate"><%- @T('Cc') %></div>
<div class="article-meta-value flex contain-text"><%- @AddressLine(@article.cc) %></div>
</div>
<% end %>
<% if @article.subject: %>
<div class="horizontal article-meta-row">
<div class="article-meta-key u-textTruncate"><%- @T( 'Subject' ) %></div>
<div class="article-meta-key u-textTruncate"><%- @T('Subject') %></div>
<div class="article-meta-value flex contain-text"><%= @article.subject %></div>
</div>
<% end %>
@ -67,7 +67,7 @@
<div class="article-content-meta bottom hide">
<div class="article-meta bottom">
<div class="horizontal article-meta-row">
<div class="article-meta-key"><%- @T( 'Channel' ) %></div>
<div class="article-meta-key"><%- @T('Channel') %></div>
<div class="article-meta-value">
<%- @Icon(@article.type.name, 'article-meta-icon') %>
<%- @T(@article.type.name) %>

View file

@ -1,6 +1,14 @@
<div class="profile">
<div class="profile-window">
<div class="js-object-container"></div>
<div class="profile-section vertical centered">
<div class="align-right profile-action js-action"></div>
<%- @user.avatar("80") %>
<h1><%= @user.displayName() %></h1>
<% if @user.organization: %>
<div class="profile-organization js-organization"></div>
<% end %>
</div>
<div class="profile-section js-object-container"></div>
<div class="profile-section js-ticket-stats"></div>
</div>
</div>

View file

@ -1,27 +1,17 @@
<div class="profile-section vertical centered">
<div class="align-right profile-action js-action"></div>
<%- @user.avatar("80") %>
<h1><%= @user.displayName() %></h1>
<% if @user.organization: %>
<div class="profile-organization js-organization"></div>
<% end %>
</div>
<div class="profile-section">
<div class="profile-details horizontal wrap">
<div class="profile-details horizontal wrap">
<% for row in @userData: %>
<% if row.tag is 'richtext': %>
<div class="profile-detailsEntry" style="width: 100%;">
<label><%- @Ti( row.display ) %></label>
<label><%- @T(row.display) %></label>
<div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @Ti('Add a Note') %>"><%- @user[row.name] %></div>
</div>
<% else: %>
<% if @user[row.name]: %>
<div class="profile-detailsEntry">
<label><%- @Ti( row.display ) %></label>
<%- @P( @user, row.name ) %>
<label><%- @T(row.display) %></label>
<%- @P(@user, row.name) %>
</div>
<% end %>
<% end %>
<% end %>
</div>
</div>