Improved @P(), small bugfixes.

This commit is contained in:
Martin Edenhofer 2015-02-07 23:54:54 +01:00
parent 64794c3767
commit b518c5d2b8
2 changed files with 18 additions and 3 deletions

View file

@ -80,9 +80,14 @@ class App extends Spine.Controller
result = attribute_config.callback( result, attribute_config )
# text2html in textarea view
isHtmlEscape = false
if attribute_config.tag is 'textarea'
isHtmlEscape = true
result = App.Utils.text2html( result )
else if attribute_config.tag is 'richtext'
isHtmlEscape = true
# fillup options
if !_.isEmpty(attribute_config.options)
if attribute_config.options[result]
@ -92,20 +97,22 @@ class App extends Spine.Controller
isTranslated = false
if attribute_config.translate || ( isObject && item.translate && item.translate() )
isTranslated = true
isHtmlEscape = true
result = App.i18n.translateContent( result )
# transform date
if attribute_config.tag is 'date'
isHtmlEscape = true
result = App.i18n.translateDate(result)
# use pretty time for datetime
else if attribute_config.tag is 'datetime'
isHtmlEscape = true
result = "<span class=\"humanTimeFromNow #{attribute_config.class}\" data-time=\"#{result}\">?</span>"
#result = App.i18n.translateTimestamp(result)
else if !isTranslated
if typeof result is 'string'
result = App.Utils.htmlEscape(result)
if !isHtmlEscape && typeof result is 'string'
result = App.Utils.htmlEscape(result)
result

View file

@ -23,6 +23,10 @@ test( "model ui basic tests", function() {
name: 'date', display: 'date 1', tag: 'date', null: true
};
App.Ticket.configure_attributes.push( attribute1 )
var attribute2 = {
name: 'textarea', display: 'textarea 1', tag: 'textarea', null: true
};
App.Ticket.configure_attributes.push( attribute2 )
var ticket = new App.Ticket()
ticket.load({
@ -31,6 +35,7 @@ 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"
})
App.i18n.set('en')
@ -41,6 +46,7 @@ test( "model ui basic tests", function() {
equal( App.viewPrint( ticket, 'not_existing' ), '-')
equal( App.viewPrint( ticket, 'updated_at' ), "<span class=\"humanTimeFromNow undefined\" data-time=\"2014-11-07T23:43:08.000Z\">?</span>")
equal( App.viewPrint( ticket, 'date' ), '2015-02-07')
equal( App.viewPrint( ticket, 'textarea' ), '<div>some new</div><div>line</div>')
App.i18n.set('de')
@ -51,6 +57,8 @@ test( "model ui basic tests", function() {
equal( App.viewPrint( ticket, 'not_existing' ), '-')
equal( App.viewPrint( ticket, 'updated_at' ), "<span class=\"humanTimeFromNow undefined\" data-time=\"2014-11-07T23:43:08.000Z\">?</span>")
equal( App.viewPrint( ticket, 'date' ), '07.02.2015')
equal( App.viewPrint( ticket, 'textarea' ), '<div>some new</div><div>line</div>')
App.i18n.set('en')
ticket.state_id = 3