From 7adc2ea9193ca24dff1a1f255c956e255f25e0b1 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 16 Aug 2015 17:46:57 +0200 Subject: [PATCH] Improved humanTime helper method. --- app/assets/javascripts/app/index.js.coffee | 21 +++++++++---------- .../views/dashboard/activity_stream.jst.eco | 2 +- .../app/views/generic/history.jst.eco | 2 +- .../javascripts/app/views/link/info.jst.eco | 2 +- .../javascripts/app/views/session.jst.eco | 4 ++-- .../views/ticket_zoom/article_view.jst.eco | 2 +- .../app/views/ticket_zoom/meta.jst.eco | 2 +- .../online_notification_content.jst.eco | 2 +- .../views/widget/ticket_stats_list.jst.eco | 2 +- public/assets/tests/model-ui.js | 4 ++-- public/assets/tests/table.js | 18 ++++++++-------- 11 files changed, 30 insertions(+), 31 deletions(-) diff --git a/app/assets/javascripts/app/index.js.coffee b/app/assets/javascripts/app/index.js.coffee index c4046e373..c7ea196c3 100644 --- a/app/assets/javascripts/app/index.js.coffee +++ b/app/assets/javascripts/app/index.js.coffee @@ -108,12 +108,11 @@ class App extends Spine.Controller else if attribute_config.tag is 'datetime' isHtmlEscape = true timestamp = App.i18n.translateTimestamp(result) - escalation = undefined - if attribute_config.class is 'escalation' - escalation + escalation = false + if attribute_config.class && attribute_config.class.match 'escalation' + escalation = true humanTime = App.PrettyDate.humanTime(result, escalation) - result = "#{humanTime}" - #result = App.i18n.translateTimestamp(result) + result = "" if !isHtmlEscape && typeof result is 'string' result = App.Utils.htmlEscape(result) @@ -222,12 +221,12 @@ class App extends Spine.Controller App.Utils.humanFileSize(size) # define pretty/human time helper - params.humanTime = ( time, escalation ) -> - App.PrettyDate.humanTime(time, escalation) - - # define pretty/human time helper - params.timestamp = ( time ) -> - App.i18n.translateTimestamp(time) + params.humanTime = ( time, escalation = false, cssClass = '') -> + timestamp = App.i18n.translateTimestamp(time) + if escalation + cssClass += ' escalation' + humanTime = App.PrettyDate.humanTime(time, escalation) + "" # define template JST["app/views/#{name}"](params) diff --git a/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco b/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco index af16e255f..825d6e473 100644 --- a/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco +++ b/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco @@ -5,7 +5,7 @@ <%= @item.created_by.displayName() %> <%- @T( @item.type ) %> <%- @T( @item.object_name ) %><% if @item.title: %> (<%= @item.title %>)<% end %> - <%- @humanTime(@item.created_at) %> + <%- @humanTime(@item.created_at, false, 'activity-time') %> diff --git a/app/assets/javascripts/app/views/generic/history.jst.eco b/app/assets/javascripts/app/views/generic/history.jst.eco index 281923ec8..d074af13d 100644 --- a/app/assets/javascripts/app/views/generic/history.jst.eco +++ b/app/assets/javascripts/app/views/generic/history.jst.eco @@ -5,7 +5,7 @@ <% for item in @items: %> <%= item.created_by.displayName() %> - - <%- @humanTime(item.created_at) %> + <%- @humanTime(item.created_at) %>