openmct/platform/commonUI/edit/src/EditController.js
Victor Woeltjen d950fe14e5 [Common UI] Finish JSDoc for edit mode
Complete in-line documentation for bundle
platform/commonUI/edit (Edit Mode), one of the
common user interface bundles being transitioned
for WTD-574.
2014-11-25 12:50:06 -08:00

34 lines
1.1 KiB
JavaScript

/*global define,Promise*/
/**
* Module defining EditController. Created by vwoeltje on 11/14/14.
*/
define(
["./objects/EditableDomainObject"],
function (EditableDomainObject) {
"use strict";
/**
* Controller which is responsible for populating the scope for
* Edit mode; introduces an editable version of the currently
* navigated domain object into the scope.
* @constructor
*/
function EditController($scope, navigationService) {
function setNavigation(domainObject) {
// Wrap the domain object such that all mutation is
// confined to edit mode (until Save)
$scope.navigatedObject =
domainObject && new EditableDomainObject(domainObject);
}
setNavigation(navigationService.getNavigation());
navigationService.addListener(setNavigation);
$scope.$on("$destroy", function () {
navigationService.removeListener(setNavigation);
});
}
return EditController;
}
);