Added inline translation support.

This commit is contained in:
Martin Edenhofer 2015-11-20 10:49:22 +01:00
parent 9447a08e6e
commit da047e6286
6 changed files with 84 additions and 67 deletions

View file

@ -40,9 +40,7 @@ class App.TicketZoom extends App.Controller
@interval(update, 1800000, 'pull_check') @interval(update, 1800000, 'pull_check')
# fetch new data if triggered # fetch new data if triggered
@bind( @bind('Ticket:update Ticket:touch', (data) =>
'Ticket:update Ticket:touch'
(data) =>
# check if current ticket has changed # check if current ticket has changed
return if data.id.toString() isnt @ticket_id.toString() return if data.id.toString() isnt @ticket_id.toString()
@ -50,23 +48,15 @@ class App.TicketZoom extends App.Controller
# check if we already have the request queued # check if we already have the request queued
#@log 'notice', 'TRY', @ticket_id, new Date(data.updated_at), new Date(@ticketUpdatedAtLastCall) #@log 'notice', 'TRY', @ticket_id, new Date(data.updated_at), new Date(@ticketUpdatedAtLastCall)
update = => update = =>
@fetch( @ticket_id, false ) @fetch(@ticket_id, false)
if !@ticketUpdatedAtLastCall || ( new Date(data.updated_at).toString() isnt new Date(@ticketUpdatedAtLastCall).toString() ) if !@ticketUpdatedAtLastCall || ( new Date(data.updated_at).toString() isnt new Date(@ticketUpdatedAtLastCall).toString() )
@delay( update, 1200, 'ticket-zoom-' + @ticket_id ) @delay( update, 1200, 'ticket-zoom-' + @ticket_id )
) )
# rerender view, e. g. on langauge change # rerender view, e. g. on langauge change
@bind 'ui:rerender', => @bind('ui:rerender', =>
return if !@authenticate(true) @fetch(@ticket_id, true)
)
# reset controllers state vars
@shown = false
@initDone = false
@activeState = false
@renderDone = false
# rerender view
@render()
meta: => meta: =>
@ -343,7 +333,7 @@ class App.TicketZoom extends App.Controller
ticket_id: @ticket.id ticket_id: @ticket.id
) )
@article_view = new App.TicketZoomArticleView( @articleView = new App.TicketZoomArticleView(
ticket: @ticket ticket: @ticket
el: @$('.ticket-article') el: @$('.ticket-article')
ui: @ ui: @
@ -369,7 +359,7 @@ class App.TicketZoom extends App.Controller
) )
# show article # show article
@article_view.execute( @articleView.execute(
ticket_article_ids: @ticket_article_ids ticket_article_ids: @ticket_article_ids
) )

View file

@ -93,9 +93,7 @@ class App.TicketZoomArticleNew extends App.Controller
@openTextarea(null, true) @openTextarea(null, true)
# set article type and expand text area # set article type and expand text area
@bind( @bind('ui::ticket::setArticleType', (data) =>
'ui::ticket::setArticleType'
(data) =>
return if data.ticket.id isnt @ticket_id return if data.ticket.id isnt @ticket_id
#@setArticleType(data.type.name) #@setArticleType(data.type.name)
@ -111,15 +109,18 @@ class App.TicketZoomArticleNew extends App.Controller
) )
# reset new article screen # reset new article screen
@bind( @bind('ui::ticket::taskReset', (data) =>
'ui::ticket::taskReset'
(data) =>
return if data.ticket_id isnt @ticket_id return if data.ticket_id isnt @ticket_id
@type = 'note' @type = 'note'
@defaults = {} @defaults = {}
@render() @render()
) )
# rerender, e. g. on language change
@bind('ui:rerender', =>
@render()
)
isIE10: -> isIE10: ->
Function('/*@cc_on return document.documentMode===10@*/')() Function('/*@cc_on return document.documentMode===10@*/')()
@ -135,7 +136,7 @@ class App.TicketZoomArticleNew extends App.Controller
render: -> render: ->
ticket = App.Ticket.fullLocal( @ticket_id ) ticket = App.Ticket.fullLocal(@ticket_id)
@html App.view('ticket_zoom/article_new')( @html App.view('ticket_zoom/article_new')(
ticket: ticket ticket: ticket

View file

@ -40,9 +40,7 @@ class ArticleViewItem extends App.Controller
@render() @render()
# set expand of text area only once # set expand of text area only once
@bind( @bind('ui::ticket::shown', (data) =>
'ui::ticket::shown'
(data) =>
return if data.ticket_id.toString() isnt @ticket.id.toString() return if data.ticket_id.toString() isnt @ticket.id.toString()
# set highlighter # set highlighter
@ -52,6 +50,11 @@ class ArticleViewItem extends App.Controller
@setSeeMore() @setSeeMore()
) )
# rerender, e. g. on language change
@bind('ui:rerender', =>
@render(undefined, true)
)
# subscribe to changes # subscribe to changes
@subscribeId = App.TicketArticle.full(@ticket_article_id, @render, false, true) @subscribeId = App.TicketArticle.full(@ticket_article_id, @render, false, true)
@ -84,7 +87,7 @@ class ArticleViewItem extends App.Controller
@articleAttributesLastUpdate = articleAttributesLastUpdateCheck @articleAttributesLastUpdate = articleAttributesLastUpdateCheck
true true
render: (article) => render: (article, force = false) =>
# get articles # get articles
@article = App.TicketArticle.fullLocal( @ticket_article_id ) @article = App.TicketArticle.fullLocal( @ticket_article_id )
@ -103,7 +106,7 @@ class ArticleViewItem extends App.Controller
@el.removeClass('is-internal') @el.removeClass('is-internal')
# check if rerender is needed # check if rerender is needed
if !@hasChanged(@article) if !force && !@hasChanged(@article)
@lastArticle = @article.attributes() @lastArticle = @article.attributes()
return return

View file

@ -19,6 +19,11 @@ class App.TicketZoomAttributeBar extends App.Controller
@subscribeId = App.Macro.subscribe(@render) @subscribeId = App.Macro.subscribe(@render)
@render() @render()
# rerender, e. g. on language change
@bind('ui:rerender', =>
@render()
)
release: => release: =>
App.Macro.unsubscribe(@subscribeId) App.Macro.unsubscribe(@subscribeId)

View file

@ -1,12 +1,20 @@
class App.TicketZoomMeta extends App.Controller class App.TicketZoomMeta extends App.Controller
constructor: -> constructor: ->
super super
@render()
@ticket = App.Ticket.fullLocal(@ticket.id) # rerender, e. g. on language change
@render(@ticket) @bind('ui:rerender', =>
@subscribeId = @ticket.subscribe(@render) @render()
)
render: (ticket) => render: (ticket) =>
if !ticket
ticket = App.Ticket.fullLocal(@ticket.id)
if !@subscribeId
@subscribeId = @ticket.subscribe(@render)
@html App.view('ticket_zoom/meta')( @html App.view('ticket_zoom/meta')(
ticket: ticket ticket: ticket
isCustomer: @isRole('Customer') isCustomer: @isRole('Customer')

View file

@ -4,12 +4,21 @@ class App.TicketZoomTitle extends App.Controller
constructor: -> constructor: ->
super super
@render()
@ticket = App.Ticket.fullLocal( @ticket.id ) # rerender, e. g. on language change
@subscribeId = @ticket.subscribe(@render) @bind('ui:rerender', =>
@render(@ticket) @render()
)
render: (ticket) => render: (ticket) =>
if !ticket
ticket = App.Ticket.fullLocal(@ticket.id)
if !@subscribeId
@subscribeId = @ticket.subscribe(@render)
@title = ticket.title
# check if render is needed # check if render is needed
if @lastTitle && @lastTitle is ticket.title if @lastTitle && @lastTitle is ticket.title
@ -30,18 +39,19 @@ class App.TicketZoomTitle extends App.Controller
title = $(e.target).ceg() || '' title = $(e.target).ceg() || ''
# update title # update title
if title isnt @ticket.title if title isnt @title
@ticket.title = title ticket = App.Ticket.find(@ticket.id)
ticket.title = title
# reset article - should not be resubmited on next ticket update # reset article - should not be resubmited on next ticket update
@ticket.article = undefined ticket.article = undefined
@ticket.save() ticket.save()
App.TaskManager.mute( @task_key ) App.TaskManager.mute(@task_key)
# update taskbar with new meta data # update taskbar with new meta data
App.Event.trigger 'task:render' App.Event.trigger 'task:render'
release: => release: =>
App.Ticket.unsubscribe( @subscribeId ) App.Ticket.unsubscribe(@subscribeId)