mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 22:50:49 +00:00
[Edit] Rename cancel() to finish()
This commit is contained in:
parent
ab4ce0caba
commit
ded52b8d19
@ -62,7 +62,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cancel(allowed) {
|
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
|
//Do navigation first in order to trigger unsaved changes dialog
|
||||||
|
@ -52,7 +52,7 @@ define(
|
|||||||
saveAction = new SaveAction(this.dialogService, this.context);
|
saveAction = new SaveAction(this.dialogService, this.context);
|
||||||
|
|
||||||
function closeEditor() {
|
function closeEditor() {
|
||||||
return domainObject.getCapability("editor").cancel();
|
return domainObject.getCapability("editor").finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
return saveAction.perform()
|
return saveAction.perform()
|
||||||
|
@ -95,11 +95,11 @@ define(
|
|||||||
EditorCapability.prototype.invoke = EditorCapability.prototype.edit;
|
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
|
* persist operations
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
EditorCapability.prototype.cancel = function () {
|
EditorCapability.prototype.finish = function () {
|
||||||
var domainObject = this.domainObject;
|
var domainObject = this.domainObject;
|
||||||
return this.transactionService.cancel().then(function () {
|
return this.transactionService.cancel().then(function () {
|
||||||
domainObject.getCapability("status").set("editing", false);
|
domainObject.getCapability("status").set("editing", false);
|
||||||
|
@ -63,7 +63,7 @@ define(
|
|||||||
|
|
||||||
capabilities.editor = jasmine.createSpyObj(
|
capabilities.editor = jasmine.createSpyObj(
|
||||||
"editor",
|
"editor",
|
||||||
["save", "cancel", "isEditContextRoot"]
|
["save", "finish", "isEditContextRoot"]
|
||||||
);
|
);
|
||||||
capabilities.action = jasmine.createSpyObj(
|
capabilities.action = jasmine.createSpyObj(
|
||||||
"actionCapability",
|
"actionCapability",
|
||||||
@ -105,7 +105,7 @@ define(
|
|||||||
return !!capabilities[name];
|
return !!capabilities[name];
|
||||||
});
|
});
|
||||||
|
|
||||||
capabilities.editor.cancel.andReturn(mockPromise(true));
|
capabilities.editor.finish.andReturn(mockPromise(true));
|
||||||
|
|
||||||
action = new CancelAction(actionContext);
|
action = new CancelAction(actionContext);
|
||||||
|
|
||||||
@ -130,8 +130,8 @@ define(
|
|||||||
capabilities.action.perform.andReturn(mockPromise(true));
|
capabilities.action.perform.andReturn(mockPromise(true));
|
||||||
action.perform();
|
action.perform();
|
||||||
|
|
||||||
// Should have called cancel
|
// Should have called finish
|
||||||
expect(capabilities.editor.cancel).toHaveBeenCalled();
|
expect(capabilities.editor.finish).toHaveBeenCalled();
|
||||||
|
|
||||||
// Definitely shouldn't call save!
|
// Definitely shouldn't call save!
|
||||||
expect(capabilities.editor.save).not.toHaveBeenCalled();
|
expect(capabilities.editor.save).not.toHaveBeenCalled();
|
||||||
|
@ -57,7 +57,7 @@ define(
|
|||||||
);
|
);
|
||||||
mockEditorCapability = jasmine.createSpyObj(
|
mockEditorCapability = jasmine.createSpyObj(
|
||||||
"editor",
|
"editor",
|
||||||
["save", "cancel", "isEditContextRoot"]
|
["save", "finish", "isEditContextRoot"]
|
||||||
);
|
);
|
||||||
mockActionCapability = jasmine.createSpyObj(
|
mockActionCapability = jasmine.createSpyObj(
|
||||||
"actionCapability",
|
"actionCapability",
|
||||||
@ -105,13 +105,13 @@ define(
|
|||||||
}));
|
}));
|
||||||
action.perform();
|
action.perform();
|
||||||
expect(mockEditorCapability.save).toHaveBeenCalled();
|
expect(mockEditorCapability.save).toHaveBeenCalled();
|
||||||
expect(mockEditorCapability.cancel).not.toHaveBeenCalled();
|
expect(mockEditorCapability.finish).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("closes the editor after saving", function () {
|
it("closes the editor after saving", function () {
|
||||||
action.perform();
|
action.perform();
|
||||||
expect(mockEditorCapability.save).toHaveBeenCalled();
|
expect(mockEditorCapability.save).toHaveBeenCalled();
|
||||||
expect(mockEditorCapability.cancel).toHaveBeenCalled();
|
expect(mockEditorCapability.finish).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -139,10 +139,10 @@ define(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("cancel", function () {
|
describe("finish", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
capability.edit();
|
capability.edit();
|
||||||
capability.cancel();
|
capability.finish();
|
||||||
});
|
});
|
||||||
it("cancels the transaction", function () {
|
it("cancels the transaction", function () {
|
||||||
expect(mockTransactionService.cancel).toHaveBeenCalled();
|
expect(mockTransactionService.cancel).toHaveBeenCalled();
|
||||||
@ -158,7 +158,7 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockDomainObject.getModel.andReturn(model);
|
mockDomainObject.getModel.andReturn(model);
|
||||||
capability.edit();
|
capability.edit();
|
||||||
capability.cancel();
|
capability.finish();
|
||||||
});
|
});
|
||||||
it("returns true if the object has been modified since it" +
|
it("returns true if the object has been modified since it" +
|
||||||
" was last persisted", function () {
|
" was last persisted", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user