Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2015-11-20 12:03:30 +01:00
commit f530720435
11 changed files with 158 additions and 133 deletions

View file

@ -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

View file

@ -40,9 +40,7 @@ class App.TicketZoom extends App.Controller
@interval(update, 1800000, 'pull_check')
# fetch new data if triggered
@bind(
'Ticket:update Ticket:touch'
(data) =>
@bind('Ticket:update Ticket:touch', (data) =>
# check if current ticket has changed
return if data.id.toString() isnt @ticket_id.toString()
@ -56,17 +54,9 @@ class App.TicketZoom extends App.Controller
)
# rerender view, e. g. on langauge change
@bind 'ui:rerender', =>
return if !@authenticate(true)
# reset controllers state vars
@shown = false
@initDone = false
@activeState = false
@renderDone = false
# rerender view
@render()
@bind('ui:rerender', =>
@fetch(@ticket_id, true)
)
meta: =>
@ -343,7 +333,7 @@ class App.TicketZoom extends App.Controller
ticket_id: @ticket.id
)
@article_view = new App.TicketZoomArticleView(
@articleView = new App.TicketZoomArticleView(
ticket: @ticket
el: @$('.ticket-article')
ui: @
@ -369,7 +359,7 @@ class App.TicketZoom extends App.Controller
)
# show article
@article_view.execute(
@articleView.execute(
ticket_article_ids: @ticket_article_ids
)

View file

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

View file

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

View file

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

View file

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

View file

@ -4,12 +4,21 @@ class App.TicketZoomTitle extends App.Controller
constructor: ->
super
@render()
@ticket = App.Ticket.fullLocal( @ticket.id )
@subscribeId = @ticket.subscribe(@render)
@render(@ticket)
# rerender, e. g. on language change
@bind('ui:rerender', =>
@render()
)
render: (ticket) =>
if !ticket
ticket = App.Ticket.fullLocal(@ticket.id)
if !@subscribeId
@subscribeId = @ticket.subscribe(@render)
@title = ticket.title
# check if render is needed
if @lastTitle && @lastTitle is ticket.title
@ -30,13 +39,14 @@ class App.TicketZoomTitle extends App.Controller
title = $(e.target).ceg() || ''
# update title
if title isnt @ticket.title
@ticket.title = title
if title isnt @title
ticket = App.Ticket.find(@ticket.id)
ticket.title = title
# 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)

View file

@ -34,7 +34,7 @@ class Widget extends App.Controller
$('body')
.on 'focus.translation', '.translation', (e) ->
element = $(e.target)
element.data 'before', element.html()
element.data 'before', element.text()
element
.on 'blur.translation', '.translation', (e) =>
console.log('blur')
@ -42,12 +42,7 @@ class Widget extends App.Controller
source = element.attr('title')
# get new translation
translation_new = element.html()
translation_new = ('' + translation_new)
.replace(/<.+?>/g, '')
# set new translation
element.html(translation_new)
translation_new = element.text()
# update translation
return if element.data('before') is translation_new
@ -58,7 +53,7 @@ class Widget extends App.Controller
App.i18n.setMap(source, translation_new)
# replace rest in page
$(".translation[title='#{source}']").html(translation_new)
$(".translation[title='#{source}']").text(translation_new)
# update permanent translation mapString
translation = App.Translation.findByAttribute('source', source)

View file

@ -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,8 +34,6 @@ 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)
@ -48,7 +46,7 @@ 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) ->
@ -124,8 +122,8 @@ class App extends Spine.Controller
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) ->
@ -202,7 +200,6 @@ class App extends Spine.Controller
result = result + App.Utils.htmlEscape(item.name) + ' '
if item.address
result = result + " <span class=\"text-muted\">&lt;#{App.Utils.htmlEscape(item.address)}&gt</span>"
result
# define file size helper

View file

@ -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)

View file

@ -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) ] %>