Fixed issue #1290 - Missing replacement of Config and Current User objects in text modules.
This commit is contained in:
parent
6130927566
commit
dab9fe995a
6 changed files with 28 additions and 0 deletions
|
@ -330,6 +330,9 @@ class App.TicketCreate extends App.Controller
|
|||
# show text module UI
|
||||
@textModule = new App.WidgetTextModule(
|
||||
el: @$('[data-name="body"]').parent()
|
||||
data:
|
||||
config: App.Config.all()
|
||||
user: App.Session.get()
|
||||
)
|
||||
|
||||
new Sidebar(
|
||||
|
|
|
@ -465,6 +465,9 @@ class ChatWindow extends App.Controller
|
|||
# show text module UI
|
||||
new App.WidgetTextModule(
|
||||
el: @input
|
||||
data:
|
||||
user: App.Session.get()
|
||||
config: App.Config.all()
|
||||
)
|
||||
|
||||
focus: =>
|
||||
|
|
|
@ -310,6 +310,7 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
data:
|
||||
ticket: ticket
|
||||
user: App.Session.get()
|
||||
config: App.Config.all()
|
||||
)
|
||||
callback = (ticket) ->
|
||||
textModule.reload(
|
||||
|
|
|
@ -649,6 +649,7 @@ class App.Utils
|
|||
# textReplaced = App.Utils.replaceTags( template, { user: { firstname: 'Bob', lastname: 'Smith' } } )
|
||||
@replaceTags: (template, objects) ->
|
||||
template = template.replace( /#\{\s{0,2}(.+?)\s{0,2}\}/g, (index, key) ->
|
||||
key = key.replace(/<.+?>/g, '')
|
||||
levels = key.split(/\./)
|
||||
dataRef = objects
|
||||
for level in levels
|
||||
|
|
|
@ -1100,6 +1100,16 @@ test("check replace tags", function() {
|
|||
verify = App.Utils.replaceTags(message, data)
|
||||
equal(verify, result)
|
||||
|
||||
message = "<div>#{user.firstname} #{<a href=\"/test\">user.lastname</a>}</div>"
|
||||
result = '<div>Bob Smith</div>'
|
||||
data = {
|
||||
user: {
|
||||
firstname: 'Bob',
|
||||
lastname: 'Smith',
|
||||
},
|
||||
}
|
||||
verify = App.Utils.replaceTags(message, data)
|
||||
equal(verify, result)
|
||||
});
|
||||
|
||||
// check attibute validation
|
||||
|
|
|
@ -148,6 +148,16 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
|
|||
).render
|
||||
assert_equal(CGI.escapeHTML(ticket.title), result)
|
||||
|
||||
template = "\#{<a href=\"/test123\">ticket.\" title</a>}"
|
||||
result = described_class.new(
|
||||
{
|
||||
ticket: ticket,
|
||||
},
|
||||
'en-us',
|
||||
template,
|
||||
).render
|
||||
assert_equal(CGI.escapeHTML(ticket.title), result)
|
||||
|
||||
template = "some test<br>\#{article.body}"
|
||||
result = described_class.new(
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue