[Time Conductor] Update model on submit/blur

This commit is contained in:
Victor Woeltjen 2015-11-25 11:09:11 -08:00
parent 87a51a9eb3
commit 976ecce075
2 changed files with 21 additions and 5 deletions

View File

@ -26,7 +26,7 @@
<span class="l-time-range-input">
<mct-control key="'datetime-field'"
structure="{ format: parameters.format, submit: updateBoundsFromForm }"
ng-model="ngModel.outer"
ng-model="formModel"
field="'start'"
class="time-range-start">
</mct-control>
@ -37,7 +37,7 @@
<span class="l-time-range-input" ng-controller="ToggleController as t2">
<mct-control key="'datetime-field'"
structure="{ format: parameters.format, submit: updateBoundsFromForm }"
ng-model="ngModel.outer"
ng-model="formModel"
field="'end'"
class="time-range-end">
</mct-control>&nbsp;

View File

@ -175,6 +175,13 @@ define(
updateViewFromModel($scope.ngModel);
}
function updateFormModel() {
$scope.formModel = {
start: (($scope.ngModel || {}).outer || {}).start,
end: (($scope.ngModel || {}).outer || {}).end
};
}
function updateOuterStart(t) {
var ngModel = $scope.ngModel;
@ -192,6 +199,7 @@ define(
ngModel.inner.end
);
updateFormModel();
updateViewForInnerSpanFromModel(ngModel);
updateTicks();
}
@ -213,6 +221,7 @@ define(
ngModel.inner.start
);
updateFormModel();
updateViewForInnerSpanFromModel(ngModel);
updateTicks();
}
@ -223,6 +232,14 @@ define(
updateTicks();
}
function updateBoundsFromForm() {
$scope.ngModel = $scope.ngModel || {};
$scope.ngModel.outer = {
start: $scope.formModel.start,
end: $scope.formModel.end
};
}
$scope.startLeftDrag = startLeftDrag;
$scope.startRightDrag = startRightDrag;
$scope.startMiddleDrag = startMiddleDrag;
@ -230,14 +247,13 @@ define(
$scope.rightDrag = rightDrag;
$scope.middleDrag = middleDrag;
$scope.updateBoundsFromForm = function () {
// TODO: update outer bounds
};
$scope.updateBoundsFromForm = updateBoundsFromForm;
$scope.ticks = [];
// Initialize scope to defaults
updateViewFromModel($scope.ngModel);
updateFormModel();
$scope.$watchCollection("ngModel", updateViewFromModel);
$scope.$watch("spanWidth", updateSpanWidth);