Merge remote-tracking branch 'origin/master' into persist-on-mutation-825

This commit is contained in:
Victor Woeltjen
2016-10-07 11:27:58 -07:00
314 changed files with 6153 additions and 7464 deletions

View File

@ -62,7 +62,7 @@ define(
}
function cancel(allowed) {
return allowed && domainObject.getCapability("editor").cancel();
return allowed && domainObject.getCapability("editor").finish();
}
//Do navigation first in order to trigger unsaved changes dialog

View File

@ -69,18 +69,13 @@ define(
* Enter edit mode.
*/
EditAction.prototype.perform = function () {
var self = this;
function cancelEditing() {
self.domainObject.getCapability('editor').cancel();
self.navigationService.removeListener(cancelEditing);
}
//If this is not the currently navigated object, then navigate
// to it.
if (this.navigationService.getNavigation() !== this.domainObject) {
this.navigationService.setNavigation(this.domainObject);
}
this.navigationService.addListener(cancelEditing);
this.domainObject.useCapability("editor");
};

View File

@ -25,9 +25,8 @@ define(
function (SaveInProgressDialog) {
/**
* The "Save" action; the action triggered by clicking Save from
* Edit Mode. Exits the editing user interface and invokes object
* capabilities to persist the changes that have been made.
* The "Save" action; it invokes object capabilities to persist
* the changes that have been made.
* @constructor
* @implements {Action}
* @memberof platform/commonUI/edit
@ -41,7 +40,7 @@ define(
}
/**
* Save changes and conclude editing.
* Save changes.
*
* @returns {Promise} a promise that will be fulfilled when
* cancellation has completed
@ -51,40 +50,22 @@ define(
var domainObject = this.domainObject,
dialog = new SaveInProgressDialog(this.dialogService);
function resolveWith(object) {
return function () {
return object;
};
}
// Invoke any save behavior introduced by the editor capability;
// this is introduced by EditableDomainObject which is
// used to insulate underlying objects from changes made
// during editing.
function doSave() {
return domainObject.getCapability("editor").save()
.then(resolveWith(domainObject));
return domainObject.getCapability("editor").save();
}
// Discard the current root view (which will be the editing
// UI, which will have been pushed atop the Browse UI.)
function returnToBrowse(object) {
if (object) {
object.getCapability("action").perform("navigate");
}
return object;
}
function hideBlockingDialog(object) {
function hideBlockingDialog() {
dialog.hide();
return object;
}
dialog.show();
return doSave()
.then(hideBlockingDialog)
.then(returnToBrowse)
.catch(hideBlockingDialog);
};

View File

@ -0,0 +1,73 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2016, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(
["./SaveAction"],
function (SaveAction) {
/**
* The "Save and Stop Editing" action performs a [Save action]{@link SaveAction}
* on the object under edit followed by exiting the edit user interface.
* @constructor
* @implements {Action}
* @memberof platform/commonUI/edit
*/
function SaveAndStopEditingAction(
dialogService,
context
) {
this.context = context;
this.domainObject = (context || {}).domainObject;
this.dialogService = dialogService;
}
/**
* Trigger a save operation and exit edit mode.
*
* @returns {Promise} a promise that will be fulfilled when
* cancellation has completed
* @memberof platform/commonUI/edit.SaveAndStopEditingAction#
*/
SaveAndStopEditingAction.prototype.perform = function () {
var domainObject = this.domainObject,
saveAction = new SaveAction(this.dialogService, this.context);
function closeEditor() {
return domainObject.getCapability("editor").finish();
}
return saveAction.perform()
.then(closeEditor)
.catch(closeEditor);
};
/**
* Check if this action is applicable in a given context.
* This will ensure that a domain object is present in the context,
* and that this domain object is in Edit mode.
* @returns true if applicable
*/
SaveAndStopEditingAction.appliesTo = SaveAction.appliesTo;
return SaveAndStopEditingAction;
}
);

View File

@ -42,7 +42,6 @@ define([
$injector,
policyService,
dialogService,
creationService,
copyService,
context
) {
@ -52,7 +51,6 @@ define([
};
this.policyService = policyService;
this.dialogService = dialogService;
this.creationService = creationService;
this.copyService = copyService;
}
@ -166,11 +164,16 @@ define([
.then(resolveWith(object));
}
function commitEditingAfterClone(clonedObject) {
function saveAfterClone(clonedObject) {
return domainObject.getCapability("editor").save()
.then(resolveWith(clonedObject));
}
function finishEditing(clonedObject) {
return domainObject.getCapability("editor").finish()
.then(resolveWith(clonedObject));
}
function onFailure() {
hideBlockingDialog();
return false;
@ -182,7 +185,8 @@ define([
.then(getParent)
.then(cloneIntoParent)
.then(undirtyOriginals)
.then(commitEditingAfterClone)
.then(saveAfterClone)
.then(finishEditing)
.then(hideBlockingDialog)
.catch(onFailure);
};

View File

@ -9,7 +9,8 @@ define([], function () {
title: "Saving...",
hint: "Do not navigate away from this page or close this browser tab while this message is displayed.",
unknownProgress: true,
severity: "info"
severity: "info",
delay: true
});
};

View File

@ -28,8 +28,8 @@ define(
* A capability that implements an editing 'session' for a domain
* object. An editing session is initiated via a call to .edit().
* Once initiated, any persist operations will be queued pending a
* subsequent call to [.save()](@link #save) or [.cancel()](@link
* #cancel).
* subsequent call to [.save()](@link #save) or [.finish()](@link
* #finish).
* @param transactionService
* @param domainObject
* @constructor
@ -45,7 +45,7 @@ define(
/**
* Initiate an editing session. This will start a transaction during
* which any persist operations will be deferred until either save()
* or cancel() are called.
* or finish() are called.
*/
EditorCapability.prototype.edit = function () {
this.transactionService.startTransaction();
@ -81,25 +81,25 @@ define(
};
/**
* Save any changes from this editing session. This will flush all
* pending persists and end the current transaction
* Save any unsaved changes from this editing session. This will
* end the current transaction and continue with a new one.
* @returns {*}
*/
EditorCapability.prototype.save = function () {
var domainObject = this.domainObject;
return this.transactionService.commit().then(function () {
domainObject.getCapability('status').set('editing', false);
var transactionService = this.transactionService;
return transactionService.commit().then(function () {
transactionService.startTransaction();
});
};
EditorCapability.prototype.invoke = EditorCapability.prototype.edit;
/**
* Cancel the current editing session. This will discard any pending
* Finish the current editing session. This will discard any pending
* persist operations
* @returns {*}
*/
EditorCapability.prototype.cancel = function () {
EditorCapability.prototype.finish = function () {
var domainObject = this.domainObject;
return this.transactionService.cancel().then(function () {
domainObject.getCapability("status").set("editing", false);

View File

@ -27,7 +27,8 @@ define(
[],
function () {
var ACTION_CONTEXT = { category: 'conclude-editing' };
var SAVE_ACTION_CONTEXT = { category: 'save' };
var OTHERS_ACTION_CONTEXT = { category: 'conclude-editing' };
/**
* Controller which supplies action instances for Save/Cancel.
@ -35,12 +36,37 @@ define(
* @constructor
*/
function EditActionController($scope) {
// Maintain all "conclude-editing" actions in the present
// context.
function actionToMenuOption(action) {
return {
key: action,
name: action.getMetadata().name,
cssclass: action.getMetadata().cssclass
};
}
// Maintain all "conclude-editing" and "save" actions in the
// present context.
function updateActions() {
$scope.editActions = $scope.action ?
$scope.action.getActions(ACTION_CONTEXT) :
$scope.saveActions = $scope.action ?
$scope.action.getActions(SAVE_ACTION_CONTEXT) :
[];
$scope.saveActionsAsMenuOptions = $scope.saveActions.map(actionToMenuOption);
$scope.saveActionMenuClickHandler = function (clickedAction) {
clickedAction.perform();
};
$scope.otherEditActions = $scope.action ?
$scope.action.getActions(OTHERS_ACTION_CONTEXT) :
[];
// Required because Angular does not allow 'bind'
// in expressions.
$scope.actionPerformer = function (action) {
return action.perform.bind(action);
};
}
// Update set of actions whenever the action capability

View File

@ -51,7 +51,7 @@ define(
function AddAction(type, parent, context, $q, dialogService, policyService) {
this.metadata = {
key: 'add',
glyph: type.getGlyph(),
cssclass: type.getCssClass(),
name: type.getName(),
type: type.getKey(),
description: type.getDescription(),

View File

@ -47,7 +47,7 @@ define(
function CreateAction(type, parent, context) {
this.metadata = {
key: 'create',
glyph: type.getGlyph(),
cssclass: type.getCssClass(),
name: type.getName(),
type: type.getKey(),
description: type.getDescription(),
@ -67,12 +67,17 @@ define(
editAction,
editorCapability;
function closeEditor() {
return editorCapability.finish();
}
function onSave() {
return editorCapability.save();
return editorCapability.save()
.then(closeEditor);
}
function onCancel() {
return editorCapability.cancel();
return closeEditor();
}
newModel.type = this.type.getKey();
@ -85,9 +90,9 @@ define(
if (editAction) {
return editAction.perform();
} else if (editorCapability) {
//otherwise, use the save action
//otherwise, use the save as action
editorCapability.edit();
return newObject.getCapability("action").perform("save").then(onSave, onCancel);
return newObject.getCapability("action").perform("save-as").then(onSave, onCancel);
}
};

View File

@ -90,7 +90,9 @@ define(
// Ensure there is always a "save in" section
if (includeLocation) {
sections.push({
name: 'Location', rows: [{
name: 'Location',
cssclass: "grows",
rows: [{
name: "Save In",
control: "locator",
validate: validateLocation,

View File

@ -50,10 +50,7 @@ define(
$scope.rootObject =
(context && context.getRoot()) || $scope.rootObject;
}, 0);
} else if (!contextRoot) {
//If no context root is available, default to the root
// object
$scope.rootObject = undefined;
} else if (!contextRoot && !$scope.rootObject) {
// Update the displayed tree on a timeout to avoid
// an infinite digest exception.
objectService.getObjects(['ROOT'])