[Time Conductor] Try to rewrite datetime picker as control

This commit is contained in:
Victor Woeltjen 2015-09-15 18:34:27 -07:00
parent 6c497f3c36
commit 9a78b63065
6 changed files with 24 additions and 16 deletions

View File

@ -54,10 +54,6 @@
{
"key": "time-controller",
"templateUrl": "templates/controls/time-controller.html"
},
{
"key": "datetime-picker",
"templateUrl": "templates/controls/datetime-picker.html"
}
],
"controllers": [
@ -249,6 +245,10 @@
{
"key": "selector",
"templateUrl": "templates/controls/selector.html"
},
{
"key": "datetime-picker",
"templateUrl": "templates/controls/datetime-picker.html"
}
],
"licenses": [

View File

@ -51,7 +51,7 @@
</div>
<div style="vertical-align: top; display: inline-block"
ng-repeat="key in ['hours', 'minutes', 'seconds']"
ng-if="parameters[key]">
ng-if="options[key]">
<div>{{nameFor(key)}}</div>
<select size="10"
ng-model="time[key]"

View File

@ -22,7 +22,7 @@
<div class="l-time-controller" ng-controller="TimeRangeController">
<div class="l-time-range-inputs-holder">
Start: <input type="date" ng-model="startOuterDate"/>
Start: {{ngModel.outer.start}}
<span ng-controller="ToggleController as t">
<a class="ui-symbol" ng-click="t.toggle()">
@ -31,10 +31,11 @@
<mct-popup ng-if="t.isActive()">
<div style="background: #555;"
mct-click-elsewhere="t.setState(false)">
<mct-include key="'datetime-picker'"
ng-model="ngModel.outer.start"
parameters="{ hours: true }">
</mct-include>
<mct-control key="'datetime-picker'"
ng-model="ngModel.outer"
field="'start'"
options="{ hours: true }">
</mct-control>
</div>
</mct-popup>
</span>

View File

@ -136,7 +136,7 @@ define(
minute: $scope.time.minutes,
second: $scope.time.seconds
});
$scope.ngModel = m.valueOf();
$scope.ngModel[$scope.field] = m.valueOf();
}
$scope.isSelectable = function (cell) {
@ -189,10 +189,11 @@ define(
updateScopeForMonth();
// Ensure some useful default
$scope.ngModel = $scope.ngModel === undefined ?
now() : $scope.ngModel;
$scope.ngModel[$scope.field] =
$scope.ngModel[$scope.field] === undefined ?
now() : $scope.ngModel[$scope.field];
$scope.$watch('ngModel', updateFromModel);
$scope.$watch('ngModel[field]', updateFromModel);
$scope.$watchCollection('date', updateFromView);
$scope.$watchCollection('time', updateFromView);
}

View File

@ -26,6 +26,13 @@ define(
function () {
"use strict";
/**
* The `mct-click-elsewhere` directive will evaluate its
* associated expression whenever a `mousedown` occurs anywhere
* outside of the element that has the `mct-click-elsewhere`
* directive attached. This is useful for dismissing popups
* and the like.
*/
function MCTClickElsewhere($document) {
// Link; install event handlers.

View File

@ -25,7 +25,7 @@ define(
function () {
var TEMPLATE = "<div></div>";
function MCTPopup($window, $document, $compile, $interval) {
function MCTPopup($window, $document, $compile) {
function link(scope, element, attrs, ctrl, transclude) {
var body = $document.find('body'),
popup = $compile(TEMPLATE)(scope),
@ -52,7 +52,6 @@ define(
scope.$on('$destroy', function () {
popup.remove();
$interval.cancel(activeInterval);
});
}