[Edit] SaveAction not navigating anymore
This commit is contained in:
@@ -25,9 +25,8 @@ define(
|
|||||||
function (SaveInProgressDialog) {
|
function (SaveInProgressDialog) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "Save" action; the action triggered by clicking Save from
|
* The "Save" action; it invokes object capabilities to persist
|
||||||
* Edit Mode. Exits the editing user interface and invokes object
|
* the changes that have been made.
|
||||||
* capabilities to persist the changes that have been made.
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @implements {Action}
|
* @implements {Action}
|
||||||
* @memberof platform/commonUI/edit
|
* @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
|
* @returns {Promise} a promise that will be fulfilled when
|
||||||
* cancellation has completed
|
* cancellation has completed
|
||||||
@@ -51,40 +50,22 @@ define(
|
|||||||
var domainObject = this.domainObject,
|
var domainObject = this.domainObject,
|
||||||
dialog = new SaveInProgressDialog(this.dialogService);
|
dialog = new SaveInProgressDialog(this.dialogService);
|
||||||
|
|
||||||
function resolveWith(object) {
|
|
||||||
return function () {
|
|
||||||
return object;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Invoke any save behavior introduced by the editor capability;
|
// Invoke any save behavior introduced by the editor capability;
|
||||||
// this is introduced by EditableDomainObject which is
|
// this is introduced by EditableDomainObject which is
|
||||||
// used to insulate underlying objects from changes made
|
// used to insulate underlying objects from changes made
|
||||||
// during editing.
|
// during editing.
|
||||||
function doSave() {
|
function doSave() {
|
||||||
return domainObject.getCapability("editor").save()
|
return domainObject.getCapability("editor").save();
|
||||||
.then(resolveWith(domainObject));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard the current root view (which will be the editing
|
function hideBlockingDialog() {
|
||||||
// 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) {
|
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
return object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
return doSave()
|
return doSave()
|
||||||
.then(hideBlockingDialog)
|
.then(hideBlockingDialog)
|
||||||
.then(returnToBrowse)
|
|
||||||
.catch(hideBlockingDialog);
|
.catch(hideBlockingDialog);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -105,12 +105,6 @@ define(
|
|||||||
expect(mockEditorCapability.save).toHaveBeenCalled();
|
expect(mockEditorCapability.save).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("navigates to the object after saving",
|
|
||||||
function () {
|
|
||||||
action.perform();
|
|
||||||
expect(mockActionCapability.perform).toHaveBeenCalledWith("navigate");
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("a blocking dialog", function () {
|
describe("a blocking dialog", function () {
|
||||||
var mockDialogHandle;
|
var mockDialogHandle;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user