From bf4765fcb6f807562cfd3310725c5abb07c5dbda Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 3 Sep 2015 15:13:03 -0700 Subject: [PATCH] [Time Controller] Bind displayed control to state Bind changes to the displayed time controller to changes to the underlying state of the time conductor, WTD-1515. --- platform/features/conductor/bundle.json | 15 +++++++++- .../conductor/src/ConductorRepresenter.js | 30 +++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/platform/features/conductor/bundle.json b/platform/features/conductor/bundle.json index d9905b6f24..139f9942c3 100644 --- a/platform/features/conductor/bundle.json +++ b/platform/features/conductor/bundle.json @@ -3,7 +3,20 @@ "representers": [ { "implementation": "ConductorRepresenter.js", - "depends": [ "$compile", "views[]" ] + "depends": [ "conductorService", "$compile", "views[]" ] + } + ], + "components": [ + { + "implementation": "ConductorCapabilityDecorator.js", + "depends": [ "conductorService" ] + } + ], + "services": [ + { + "key": "conductorService", + "implementation": "ConductorService.js", + "depends": [ "now" ] } ] } diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index 5cbf1ce6e8..e7fc76aec5 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -32,7 +32,8 @@ define( '"position: absolute; bottom: 0; width: 100%; ', 'overflow: hidden; ', 'height: ' + CONDUCTOR_HEIGHT + '">', - "", + "", + "", '' ].join(''), GLOBAL_SHOWING = false; @@ -45,7 +46,7 @@ define( * @implements {Representer} * @constructor */ - function ConductorRepresenter($compile, views, scope, element) { + function ConductorRepresenter(conductorService, $compile, views, scope, element) { var conductorScope; // Angular doesn't like objects to retain references to scope @@ -54,6 +55,7 @@ define( return (conductorScope = arguments.length > 0 ? s : conductorScope); }; + this.conductorService = conductorService; this.element = element; this.showing = false; this.views = views; @@ -63,6 +65,29 @@ define( this.hadAbs = element.hasClass('abs'); } + // Update the time conductor from the scope + ConductorRepresenter.prototype.wireScope = function () { + var scope = this.conductorScope(), + conductor = this.conductorService.getConductor(); + + function updateConductor() { + conductor.queryStart(scope.conductor.outer[0]); + conductor.queryEnd(scope.conductor.outer[1]); + conductor.displayStart(scope.conductor.inner[0]); + conductor.displayEnd(scope.conductor.inner[1]); + } + + scope.conductor = { + outer: [ conductor.queryStart(), conductor.queryEnd() ], + inner: [ conductor.displayStart(), conductor.displayEnd() ] + }; + + scope.$watch('conductor.outer[0]', updateConductor); + scope.$watch('conductor.outer[1]', updateConductor); + scope.$watch('conductor.inner[0]', updateConductor); + scope.$watch('conductor.inner[1]', updateConductor); + }; + // Handle a specific representation of a specific domain object ConductorRepresenter.prototype.represent = function represent(representation, representedObject) { this.destroy(); @@ -70,6 +95,7 @@ define( if (this.views.indexOf(representation) !== -1 && !GLOBAL_SHOWING) { // Create a new scope for the conductor this.conductorScope(this.getScope().$new()); + this.wireScope(); this.conductorElement = this.$compile(TEMPLATE)(this.conductorScope()); this.element.after(this.conductorElement[0]);