From 2db4aa6235bb019e3457f35e14cf0784fb5e2606 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 23 Sep 2016 13:06:22 -0700 Subject: [PATCH] [Time Conductor] Added zoom level label --- .../commonUI/formats/src/UTCTimeFormat.js | 32 +++++++++++++++++++ .../features/conductor-v2/conductor/bundle.js | 3 +- .../res/templates/time-conductor.html | 3 +- .../src/ui/TimeConductorController.js | 13 ++++++-- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/platform/commonUI/formats/src/UTCTimeFormat.js b/platform/commonUI/formats/src/UTCTimeFormat.js index 3faab7a620..5d1fba0117 100644 --- a/platform/commonUI/formats/src/UTCTimeFormat.js +++ b/platform/commonUI/formats/src/UTCTimeFormat.js @@ -95,6 +95,38 @@ define([ })[0][0]; } + UTCTimeFormat.prototype.timeUnits = function (timeRange) { + var momentified = moment.duration(timeRange); + return [ + ["Decades", function (r) { + return r.years() > 15; + }], + ["Years", function (r) { + return r.years() > 0; + }], + ["Months", function (r) { + return r.months() > 0; + }], + ["Days", function (r) { + return r.days() > 0; + }], + ["Hours", function (r) { + return r.hours() > 0; + }], + ["Minutes", function (r) { + return r.minutes() > 0; + }], + ["Seconds", function (r) { + return r.seconds() > 0; + }], + ["Milliseconds", function (r) { + return true; + }] + ].filter(function (row){ + return row[1](momentified); + })[0][0]; + }; + /** * * @param value diff --git a/platform/features/conductor-v2/conductor/bundle.js b/platform/features/conductor-v2/conductor/bundle.js index 7c49ccd7c4..122e2a69ac 100644 --- a/platform/features/conductor-v2/conductor/bundle.js +++ b/platform/features/conductor-v2/conductor/bundle.js @@ -69,7 +69,8 @@ define([ "$window", "timeConductor", "timeConductorViewService", - "timeSystems[]" + "timeSystems[]", + "formatService" ] }, { diff --git a/platform/features/conductor-v2/conductor/res/templates/time-conductor.html b/platform/features/conductor-v2/conductor/res/templates/time-conductor.html index 37ad80b8ff..2826bc86a0 100644 --- a/platform/features/conductor-v2/conductor/res/templates/time-conductor.html +++ b/platform/features/conductor-v2/conductor/res/templates/time-conductor.html @@ -115,7 +115,8 @@
- + {{timeUnits}}