Follow up #3543 - Translate link text of link template in organisation sidebar in ticket zoom.

This commit is contained in:
Rolf Schmidt 2021-05-06 12:11:53 +00:00 committed by Thorsten Eckel
parent bd10f8d134
commit 7de5ec9037
2 changed files with 24 additions and 5 deletions

View file

@ -115,8 +115,8 @@ class App extends Spine.Controller
isHtmlEscape = true
resultLocal = App.i18n.translateDate(resultLocal)
linktemplate = @_placeholderReplacement(object, attributeConfig, resultLocal)
if linktemplate && isHtmlEscape is false
linktemplate = @_placeholderReplacement(object, attributeConfig, resultLocal, isHtmlEscape)
if linktemplate
resultLocal = linktemplate
isHtmlEscape = true
@ -152,7 +152,7 @@ class App extends Spine.Controller
result
@_placeholderReplacement: (object, attributeConfig, resultLocal) ->
@_placeholderReplacement: (object, attributeConfig, resultLocal, isHtmlEscape) ->
return if !object
return if !attributeConfig
return if _.isEmpty(attributeConfig.linktemplate)
@ -161,7 +161,12 @@ class App extends Spine.Controller
return if _.isEmpty(object[attributeConfig.name])
placeholderObjects = { attribute: attributeConfig, session: App.Session.get(), config: App.Config.all() }
placeholderObjects[object.constructor.className.toLowerCase()] = object
"<a href=\"#{App.Utils.replaceTags(attributeConfig.linktemplate, placeholderObjects, true)}\" target=\"blank\">#{App.i18n.translateInline(resultLocal)}</a>"
value = resultLocal
if !isHtmlEscape
value = App.Utils.htmlEscape(value)
"<a href=\"#{App.Utils.replaceTags(attributeConfig.linktemplate, placeholderObjects, true)}\" target=\"blank\">#{value}</a>"
@view: (name) ->
template = (params = {}) ->

View file

@ -27,6 +27,14 @@ test( "model ui basic tests", function() {
name: 'textarea', display: 'textarea 1', tag: 'textarea', null: true
};
App.Ticket.configure_attributes.push( attribute2 )
var attribute3 = {
name: 'link1', display: 'link 1', linktemplate: 'http://zammad.com', tag: 'input', null: true, translate: true
};
App.Ticket.configure_attributes.push( attribute3 )
var attribute4 = {
name: 'link2', display: 'link 1', linktemplate: 'http://zammad.com', tag: 'input', null: true
};
App.Ticket.configure_attributes.push( attribute4 )
var ticket = new App.Ticket()
ticket.load({
@ -35,7 +43,9 @@ test( "model ui basic tests", function() {
state_id: 2,
updated_at: '2014-11-07T23:43:08.000Z',
date: '2015-02-07',
textarea: "some new\nline"
textarea: "some new\nline",
link1: 'closed',
link2: 'closed',
})
App.i18n.set('en-us')
@ -47,6 +57,8 @@ test( "model ui basic tests", function() {
equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="11/07/2014 23:43">11/07/2014</time>')
equal( App.viewPrint( ticket, 'date' ), '02/07/2015')
equal( App.viewPrint( ticket, 'textarea' ), '<div>some new</div><div>line</div>')
equal( App.viewPrint( ticket, 'link1' ), '<a href="http://zammad.com" target="blank">closed</a>')
equal( App.viewPrint( ticket, 'link2' ), '<a href="http://zammad.com" target="blank">closed</a>')
App.i18n.set('de-de')
@ -58,6 +70,8 @@ test( "model ui basic tests", function() {
equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="07.11.2014 23:43">07.11.2014</time>')
equal( App.viewPrint( ticket, 'date' ), '07.02.2015')
equal( App.viewPrint( ticket, 'textarea' ), '<div>some new</div><div>line</div>')
equal( App.viewPrint( ticket, 'link1' ), '<a href="http://zammad.com" target="blank">geschlossen</a>')
equal( App.viewPrint( ticket, 'link2' ), '<a href="http://zammad.com" target="blank">closed</a>')
App.i18n.set('en-us')