From 4a9f448de7131fff9a234ae384668e7a33972ab0 Mon Sep 17 00:00:00 2001 From: Mantas Masalskis Date: Mon, 30 Aug 2021 14:25:48 +0200 Subject: [PATCH] Fixes #457 - Scheduler Time offset --- .../controllers/_application_controller/_base.coffee | 7 ++++++- .../app/controllers/_ui_element/timer.coffee | 3 ++- app/assets/javascripts/app/index.coffee | 11 ++++++++++- app/assets/javascripts/app/models/job.coffee | 4 ++-- .../javascripts/app/views/generic/timeplan.jst.eco | 2 +- .../javascripts/app/views/generic/timer.jst.eco | 9 +++++---- app/assets/stylesheets/zammad.scss | 2 +- app/views/tests/model_ui.html.erb | 2 +- public/assets/tests/form_timer.js | 8 ++++---- public/assets/tests/model_ui.js | 9 +++++++++ 10 files changed, 41 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller/_base.coffee b/app/assets/javascripts/app/controllers/_application_controller/_base.coffee index 5e6a85268..93a5c2c87 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/_base.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/_base.coffee @@ -304,7 +304,12 @@ class App.Controller extends Spine.Controller # only do dom updates on changes return if time is currentVal - item.attr('title', App.i18n.translateTimestamp(timestamp)) + + newTitle = App.i18n.translateTimestamp(timestamp) + if item.attr('timezone') + newTitle += ' ' + item.attr('timezone') + + item.attr('title', newTitle) item.html(time) recentView: (object, o_id) => diff --git a/app/assets/javascripts/app/controllers/_ui_element/timer.coffee b/app/assets/javascripts/app/controllers/_ui_element/timer.coffee index d6fd28adf..6f90703ba 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/timer.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/timer.coffee @@ -112,8 +112,9 @@ class App.UiElement.timer days = @joinItems days hours = @joinItems hours + timezone = App.Config.get('timezone_default') || 'UTC' - formGroup.find('.js-timerResult').text(App.i18n.translateInline('Run every %s at %s', days, hours)) + formGroup.find('.js-timerResult').text(App.i18n.translateInline('Run every %s at %s in %s time', days, hours, timezone)) @injectMinutes: (hours, minutes) -> newHours = [] # hours.length x minutes.length long diff --git a/app/assets/javascripts/app/index.coffee b/app/assets/javascripts/app/index.coffee index 438554c90..128fd9838 100644 --- a/app/assets/javascripts/app/index.coffee +++ b/app/assets/javascripts/app/index.coffee @@ -134,14 +134,23 @@ class App extends Spine.Controller else if attributeConfig.tag is 'datetime' isHtmlEscape = true timestamp = App.i18n.translateTimestamp(resultLocal) + escalation = false cssClass = attributeConfig.class || '' if cssClass.match 'escalation' escalation = true + humanTime = '' if !table humanTime = App.PrettyDate.humanTime(resultLocal, escalation) - resultLocal = "" + + title = timestamp + timezone = '' + if attributeConfig.include_timezone + timezone = " timezone=\"#{App.Config.get('timezone_default')}\"" + title += ' ' + App.Config.get('timezone_default') + + resultLocal = "" if !isHtmlEscape && typeof resultLocal is 'string' resultLocal = App.Utils.htmlEscape(resultLocal) diff --git a/app/assets/javascripts/app/models/job.coffee b/app/assets/javascripts/app/models/job.coffee index abdee338f..8b7c71df2 100644 --- a/app/assets/javascripts/app/models/job.coffee +++ b/app/assets/javascripts/app/models/job.coffee @@ -12,8 +12,8 @@ class App.Job extends App.Model { name: 'active', display: 'Active', tag: 'active', default: true }, { name: 'matching', display: 'Will process', readonly: 1 }, { name: 'processed', display: 'Has processed', readonly: 1 }, - { name: 'last_run_at', display: 'Last run', tag: 'datetime', readonly: 1 }, - { name: 'next_run_at', display: 'Scheduled for', tag: 'datetime', readonly: 1 }, + { name: 'last_run_at', display: 'Last run', tag: 'datetime', readonly: 1, include_timezone: true }, + { name: 'next_run_at', display: 'Scheduled for', tag: 'datetime', readonly: 1, include_timezone: true }, { name: 'running', display: 'Running', tag: 'boolean', readonly: 1 }, { name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 }, { name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1 }, diff --git a/app/assets/javascripts/app/views/generic/timeplan.jst.eco b/app/assets/javascripts/app/views/generic/timeplan.jst.eco index 1e809facf..0a09e4e0a 100644 --- a/app/assets/javascripts/app/views/generic/timeplan.jst.eco +++ b/app/assets/javascripts/app/views/generic/timeplan.jst.eco @@ -8,4 +8,4 @@ - \ No newline at end of file + diff --git a/app/assets/javascripts/app/views/generic/timer.jst.eco b/app/assets/javascripts/app/views/generic/timer.jst.eco index 4e1f5a727..1084675ea 100644 --- a/app/assets/javascripts/app/views/generic/timer.jst.eco +++ b/app/assets/javascripts/app/views/generic/timer.jst.eco @@ -1,6 +1,7 @@ -

- -

+ +

+
+
<%- @T('Day') %>
@@ -23,4 +24,4 @@ <% end %>
-
\ No newline at end of file + diff --git a/app/assets/stylesheets/zammad.scss b/app/assets/stylesheets/zammad.scss index fe75ceddf..4e21e5cea 100644 --- a/app/assets/stylesheets/zammad.scss +++ b/app/assets/stylesheets/zammad.scss @@ -9930,7 +9930,7 @@ label + .wizard-buttonList { output { border-bottom: 1px solid hsl(200,71%,59%); - margin: 14px 0 0; + margin: 14px 0 19px; display: inline-block; padding: 10px 12px 8px; background: hsl(201,62%,93%); diff --git a/app/views/tests/model_ui.html.erb b/app/views/tests/model_ui.html.erb index 7aa4f623c..3452c5332 100644 --- a/app/views/tests/model_ui.html.erb +++ b/app/views/tests/model_ui.html.erb @@ -1,6 +1,6 @@ -<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/model_ui.js", nonce: true %> +<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/sinon-9.2.4", "/assets/tests/model_ui.js", nonce: true %>