From 9847c40e3421b2d580c360c893c10c0be83daf71 Mon Sep 17 00:00:00 2001 From: Alex M Date: Thu, 1 Sep 2016 23:01:57 +0300 Subject: [PATCH 01/24] [Edit] SaveAction not navigating anymore --- .../commonUI/edit/src/actions/SaveAction.js | 29 ++++--------------- .../edit/test/actions/SaveActionSpec.js | 6 ---- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/platform/commonUI/edit/src/actions/SaveAction.js b/platform/commonUI/edit/src/actions/SaveAction.js index 6f96e84192..8d3ea7f509 100644 --- a/platform/commonUI/edit/src/actions/SaveAction.js +++ b/platform/commonUI/edit/src/actions/SaveAction.js @@ -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); }; diff --git a/platform/commonUI/edit/test/actions/SaveActionSpec.js b/platform/commonUI/edit/test/actions/SaveActionSpec.js index 0243f89a11..7324b53085 100644 --- a/platform/commonUI/edit/test/actions/SaveActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveActionSpec.js @@ -105,12 +105,6 @@ define( expect(mockEditorCapability.save).toHaveBeenCalled(); }); - it("navigates to the object after saving", - function () { - action.perform(); - expect(mockActionCapability.perform).toHaveBeenCalledWith("navigate"); - }); - describe("a blocking dialog", function () { var mockDialogHandle; From 90c13a3959c695fd30e43c6a69a848fee692c2a7 Mon Sep 17 00:00:00 2001 From: Alex M Date: Thu, 1 Sep 2016 23:16:31 +0300 Subject: [PATCH 02/24] [Edit] EditorCapability continues edit on save --- .../commonUI/edit/src/capabilities/EditorCapability.js | 10 +++++----- .../edit/test/capabilities/EditorCapabilitySpec.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index aa7670d8aa..a997eb3033 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -81,14 +81,14 @@ 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(); }); }; diff --git a/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js index 3ffb81921d..e72793be53 100644 --- a/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js +++ b/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js @@ -134,8 +134,8 @@ define( it("commits the transaction", function () { expect(mockTransactionService.commit).toHaveBeenCalled(); }); - it("resets the edit state", function () { - expect(mockStatusCapability.set).toHaveBeenCalledWith('editing', false); + it("begins a new transaction", function () { + expect(mockTransactionService.startTransaction).toHaveBeenCalled(); }); }); From ab4ce0caba1cac308d0db3f2fc2334a490bf1e5f Mon Sep 17 00:00:00 2001 From: Alex M Date: Sat, 3 Sep 2016 17:25:21 +0300 Subject: [PATCH 03/24] [Edit] Introduced SaveAndStopEditingAction It replaces SaveAction in the bundle. --- platform/commonUI/edit/bundle.js | 6 +- .../src/actions/SaveAndStopEditingAction.js | 73 +++++++++++ .../actions/SaveAndStopEditingActionSpec.js | 118 ++++++++++++++++++ 3 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js create mode 100644 platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js diff --git a/platform/commonUI/edit/bundle.js b/platform/commonUI/edit/bundle.js index 2c5a79bda3..b81e057764 100644 --- a/platform/commonUI/edit/bundle.js +++ b/platform/commonUI/edit/bundle.js @@ -30,7 +30,7 @@ define([ "./src/actions/EditAction", "./src/actions/PropertiesAction", "./src/actions/RemoveAction", - "./src/actions/SaveAction", + "./src/actions/SaveAndStopEditingAction", "./src/actions/SaveAsAction", "./src/actions/CancelAction", "./src/policies/EditActionPolicy", @@ -69,7 +69,7 @@ define([ EditAction, PropertiesAction, RemoveAction, - SaveAction, + SaveAndStopEditingAction, SaveAsAction, CancelAction, EditActionPolicy, @@ -205,7 +205,7 @@ define([ { "key": "save", "category": "conclude-editing", - "implementation": SaveAction, + "implementation": SaveAndStopEditingAction, "name": "Save", "cssclass": "icon-save labeled", "description": "Save changes made to these objects.", diff --git a/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js b/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js new file mode 100644 index 0000000000..a6a1eb9e62 --- /dev/null +++ b/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js @@ -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").cancel(); + } + + 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; + } +); \ No newline at end of file diff --git a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js new file mode 100644 index 0000000000..a5d14e3d6d --- /dev/null +++ b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js @@ -0,0 +1,118 @@ +/***************************************************************************** + * 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( + ["../../src/actions/SaveAndStopEditingAction"], + function (SaveAndStopEditingAction) { + + describe("The Save and Stop Editing action", function () { + + var mockDomainObject, + mockEditorCapability, + actionContext, + dialogService, + mockActionCapability, + capabilities = {}, + action; + + function mockPromise(value) { + return { + then: function (callback) { + return mockPromise(callback(value)); + }, + catch: function (callback) { + return mockPromise(callback(value)); + } + }; + } + + beforeEach(function () { + mockDomainObject = jasmine.createSpyObj( + "domainObject", + [ + "getCapability", + "hasCapability", + "getModel", + "getOriginalObject" + ] + ); + mockEditorCapability = jasmine.createSpyObj( + "editor", + ["save", "cancel", "isEditContextRoot"] + ); + mockActionCapability = jasmine.createSpyObj( + "actionCapability", + ["perform"] + ); + capabilities.editor = mockEditorCapability; + capabilities.action = mockActionCapability; + + actionContext = { + domainObject: mockDomainObject + }; + dialogService = jasmine.createSpyObj( + "dialogService", + ["showBlockingMessage"] + ); + + mockDomainObject.hasCapability.andReturn(true); + mockDomainObject.getCapability.andCallFake(function (capability) { + return capabilities[capability]; + }); + mockDomainObject.getModel.andReturn({ persisted: 0 }); + mockEditorCapability.save.andReturn(mockPromise(true)); + mockEditorCapability.isEditContextRoot.andReturn(true); + + action = new SaveAndStopEditingAction(dialogService, actionContext); + }); + + + it("only applies to domain object with an editor capability", function () { + expect(SaveAndStopEditingAction.appliesTo(actionContext)).toBe(true); + expect(mockDomainObject.hasCapability).toHaveBeenCalledWith("editor"); + + mockDomainObject.hasCapability.andReturn(false); + mockDomainObject.getCapability.andReturn(undefined); + expect(SaveAndStopEditingAction.appliesTo(actionContext)).toBe(false); + }); + + it("only applies to domain object that has already been persisted", function () { + mockDomainObject.getModel.andReturn({ persisted: undefined }); + expect(SaveAndStopEditingAction.appliesTo(actionContext)).toBe(false); + }); + + it("does not close the editor before completing the save", function () { + mockEditorCapability.save.andReturn(new Promise(function () { + })); + action.perform(); + expect(mockEditorCapability.save).toHaveBeenCalled(); + expect(mockEditorCapability.cancel).not.toHaveBeenCalled(); + }); + + it("closes the editor after saving", function () { + action.perform(); + expect(mockEditorCapability.save).toHaveBeenCalled(); + expect(mockEditorCapability.cancel).toHaveBeenCalled(); + }); + }); + } +); \ No newline at end of file From ded52b8d199ec96c787db78e94d5920786836f9e Mon Sep 17 00:00:00 2001 From: Alex M Date: Sat, 3 Sep 2016 17:45:23 +0300 Subject: [PATCH 04/24] [Edit] Rename cancel() to finish() --- platform/commonUI/edit/src/actions/CancelAction.js | 2 +- .../commonUI/edit/src/actions/SaveAndStopEditingAction.js | 2 +- .../commonUI/edit/src/capabilities/EditorCapability.js | 4 ++-- platform/commonUI/edit/test/actions/CancelActionSpec.js | 8 ++++---- .../edit/test/actions/SaveAndStopEditingActionSpec.js | 6 +++--- .../edit/test/capabilities/EditorCapabilitySpec.js | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/platform/commonUI/edit/src/actions/CancelAction.js b/platform/commonUI/edit/src/actions/CancelAction.js index 13b005958e..a48ceec996 100644 --- a/platform/commonUI/edit/src/actions/CancelAction.js +++ b/platform/commonUI/edit/src/actions/CancelAction.js @@ -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 diff --git a/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js b/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js index a6a1eb9e62..6145ecd05b 100644 --- a/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js +++ b/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js @@ -52,7 +52,7 @@ define( saveAction = new SaveAction(this.dialogService, this.context); function closeEditor() { - return domainObject.getCapability("editor").cancel(); + return domainObject.getCapability("editor").finish(); } return saveAction.perform() diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index a997eb3033..53dea8c91c 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -95,11 +95,11 @@ define( 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); diff --git a/platform/commonUI/edit/test/actions/CancelActionSpec.js b/platform/commonUI/edit/test/actions/CancelActionSpec.js index 3bd0cee72f..7fdc51b0e9 100644 --- a/platform/commonUI/edit/test/actions/CancelActionSpec.js +++ b/platform/commonUI/edit/test/actions/CancelActionSpec.js @@ -63,7 +63,7 @@ define( capabilities.editor = jasmine.createSpyObj( "editor", - ["save", "cancel", "isEditContextRoot"] + ["save", "finish", "isEditContextRoot"] ); capabilities.action = jasmine.createSpyObj( "actionCapability", @@ -105,7 +105,7 @@ define( return !!capabilities[name]; }); - capabilities.editor.cancel.andReturn(mockPromise(true)); + capabilities.editor.finish.andReturn(mockPromise(true)); action = new CancelAction(actionContext); @@ -130,8 +130,8 @@ define( capabilities.action.perform.andReturn(mockPromise(true)); action.perform(); - // Should have called cancel - expect(capabilities.editor.cancel).toHaveBeenCalled(); + // Should have called finish + expect(capabilities.editor.finish).toHaveBeenCalled(); // Definitely shouldn't call save! expect(capabilities.editor.save).not.toHaveBeenCalled(); diff --git a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js index a5d14e3d6d..6570dd6037 100644 --- a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js @@ -57,7 +57,7 @@ define( ); mockEditorCapability = jasmine.createSpyObj( "editor", - ["save", "cancel", "isEditContextRoot"] + ["save", "finish", "isEditContextRoot"] ); mockActionCapability = jasmine.createSpyObj( "actionCapability", @@ -105,13 +105,13 @@ define( })); action.perform(); expect(mockEditorCapability.save).toHaveBeenCalled(); - expect(mockEditorCapability.cancel).not.toHaveBeenCalled(); + expect(mockEditorCapability.finish).not.toHaveBeenCalled(); }); it("closes the editor after saving", function () { action.perform(); expect(mockEditorCapability.save).toHaveBeenCalled(); - expect(mockEditorCapability.cancel).toHaveBeenCalled(); + expect(mockEditorCapability.finish).toHaveBeenCalled(); }); }); } diff --git a/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js index e72793be53..77fbd9b74f 100644 --- a/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js +++ b/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js @@ -139,10 +139,10 @@ define( }); }); - describe("cancel", function () { + describe("finish", function () { beforeEach(function () { capability.edit(); - capability.cancel(); + capability.finish(); }); it("cancels the transaction", function () { expect(mockTransactionService.cancel).toHaveBeenCalled(); @@ -158,7 +158,7 @@ define( beforeEach(function () { mockDomainObject.getModel.andReturn(model); capability.edit(); - capability.cancel(); + capability.finish(); }); it("returns true if the object has been modified since it" + " was last persisted", function () { From 7d52d348b25a6f318de902bf953faf74b3a70bea Mon Sep 17 00:00:00 2001 From: Alex M Date: Sat, 3 Sep 2016 18:33:27 +0300 Subject: [PATCH 05/24] [Edit] Fix style issues --- .../commonUI/edit/src/actions/SaveAndStopEditingAction.js | 4 ++-- platform/commonUI/edit/src/capabilities/EditorCapability.js | 2 +- .../edit/test/actions/SaveAndStopEditingActionSpec.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js b/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js index 6145ecd05b..a0a0583048 100644 --- a/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js +++ b/platform/commonUI/edit/src/actions/SaveAndStopEditingAction.js @@ -50,7 +50,7 @@ define( SaveAndStopEditingAction.prototype.perform = function () { var domainObject = this.domainObject, saveAction = new SaveAction(this.dialogService, this.context); - + function closeEditor() { return domainObject.getCapability("editor").finish(); } @@ -70,4 +70,4 @@ define( return SaveAndStopEditingAction; } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index 53dea8c91c..2280b04e0c 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -81,7 +81,7 @@ define( }; /** - * Save any unsaved changes from this editing session. This will + * Save any unsaved changes from this editing session. This will * end the current transaction and continue with a new one. * @returns {*} */ diff --git a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js index 6570dd6037..cfed63c0d3 100644 --- a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js @@ -115,4 +115,4 @@ define( }); }); } -); \ No newline at end of file +); From 3dee0821410becb0e89209c376a3051cd5f5f925 Mon Sep 17 00:00:00 2001 From: Alex M Date: Sat, 3 Sep 2016 19:02:05 +0300 Subject: [PATCH 06/24] [Edit] Add reason for redundant mocks --- .../edit/test/actions/SaveAndStopEditingActionSpec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js index cfed63c0d3..1fb8fa6492 100644 --- a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js @@ -26,6 +26,11 @@ define( describe("The Save and Stop Editing action", function () { + // Some mocks appear unused because the + // underlying SaveAction that this action + // depends on is not mocked, so we mock some + // of SaveAction's own dependencies to make + // it run. var mockDomainObject, mockEditorCapability, actionContext, From 79b16ddda643239e555a8807300bc0650e3b795e Mon Sep 17 00:00:00 2001 From: Alex M Date: Tue, 13 Sep 2016 21:24:20 +0300 Subject: [PATCH 07/24] [Edit] SaveAs now calls finish() --- platform/commonUI/edit/src/actions/SaveAsAction.js | 10 ++++++++-- .../commonUI/edit/test/actions/SaveAsActionSpec.js | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/platform/commonUI/edit/src/actions/SaveAsAction.js b/platform/commonUI/edit/src/actions/SaveAsAction.js index 57a055429a..402fccb86c 100644 --- a/platform/commonUI/edit/src/actions/SaveAsAction.js +++ b/platform/commonUI/edit/src/actions/SaveAsAction.js @@ -166,11 +166,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 +187,8 @@ define([ .then(getParent) .then(cloneIntoParent) .then(undirtyOriginals) - .then(commitEditingAfterClone) + .then(saveAfterClone) + .then(finishEditing) .then(hideBlockingDialog) .catch(onFailure); }; diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index fd8ce18c07..6bf631feed 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -78,9 +78,8 @@ define( mockEditorCapability = jasmine.createSpyObj( "editor", - ["save", "cancel", "isEditContextRoot"] + ["save", "isEditContextRoot"] ); - mockEditorCapability.cancel.andReturn(mockPromise(undefined)); mockEditorCapability.save.andReturn(mockPromise(true)); mockEditorCapability.isEditContextRoot.andReturn(true); capabilities.editor = mockEditorCapability; From 438274501231e46a2049054312fa67e2085385d5 Mon Sep 17 00:00:00 2001 From: Alex M Date: Tue, 13 Sep 2016 22:35:11 +0300 Subject: [PATCH 08/24] [Edit] Final two actions now use finish() --- platform/commonUI/edit/src/actions/EditAction.js | 2 +- platform/commonUI/edit/src/creation/CreateAction.js | 2 +- platform/commonUI/edit/test/actions/EditActionSpec.js | 6 +++--- platform/commonUI/edit/test/creation/CreateActionSpec.js | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/platform/commonUI/edit/src/actions/EditAction.js b/platform/commonUI/edit/src/actions/EditAction.js index bd30968289..9c14abad2a 100644 --- a/platform/commonUI/edit/src/actions/EditAction.js +++ b/platform/commonUI/edit/src/actions/EditAction.js @@ -71,7 +71,7 @@ define( EditAction.prototype.perform = function () { var self = this; function cancelEditing() { - self.domainObject.getCapability('editor').cancel(); + self.domainObject.getCapability('editor').finish(); self.navigationService.removeListener(cancelEditing); } //If this is not the currently navigated object, then navigate diff --git a/platform/commonUI/edit/src/creation/CreateAction.js b/platform/commonUI/edit/src/creation/CreateAction.js index 14b8443462..3cfbdb0ef9 100644 --- a/platform/commonUI/edit/src/creation/CreateAction.js +++ b/platform/commonUI/edit/src/creation/CreateAction.js @@ -72,7 +72,7 @@ define( } function onCancel() { - return editorCapability.cancel(); + return editorCapability.finish(); } newModel.type = this.type.getKey(); diff --git a/platform/commonUI/edit/test/actions/EditActionSpec.js b/platform/commonUI/edit/test/actions/EditActionSpec.js index c896e83dd1..5e54b67e15 100644 --- a/platform/commonUI/edit/test/actions/EditActionSpec.js +++ b/platform/commonUI/edit/test/actions/EditActionSpec.js @@ -58,7 +58,7 @@ define( ); mockEditor = jasmine.createSpyObj( "editorCapability", - ["edit", "isEditContextRoot", "cancel"] + ["edit", "isEditContextRoot", "finish"] ); capabilities = { @@ -98,11 +98,11 @@ define( expect(EditAction.appliesTo(actionContext)).toBe(false); }); - it ("cancels editing when user navigates away", function () { + it ("finishes editing when user navigates away", function () { action.perform(); expect(mockNavigationService.addListener).toHaveBeenCalled(); mockNavigationService.addListener.mostRecentCall.args[0](); - expect(mockEditor.cancel).toHaveBeenCalled(); + expect(mockEditor.finish).toHaveBeenCalled(); }); it ("invokes the Edit capability on the object", function () { diff --git a/platform/commonUI/edit/test/creation/CreateActionSpec.js b/platform/commonUI/edit/test/creation/CreateActionSpec.js index d65621f9a8..19dc46896f 100644 --- a/platform/commonUI/edit/test/creation/CreateActionSpec.js +++ b/platform/commonUI/edit/test/creation/CreateActionSpec.js @@ -103,7 +103,7 @@ define( [ "edit", "save", - "cancel" + "finish" ] ); @@ -178,10 +178,10 @@ define( expect(capabilities.editor.save).toHaveBeenCalled(); }); - it("to cancel the edit if user cancels dialog", function () { + it("to finish the edit if user cancels dialog", function () { action.perform(); promise.then.mostRecentCall.args[1](); - expect(capabilities.editor.cancel).toHaveBeenCalled(); + expect(capabilities.editor.finish).toHaveBeenCalled(); }); }); }); From d87ed1414e41e3a8fa4555c910aa615ac5da52c5 Mon Sep 17 00:00:00 2001 From: Alex M Date: Tue, 13 Sep 2016 22:36:27 +0300 Subject: [PATCH 09/24] [Edit] Update EditorCapability comments --- platform/commonUI/edit/src/capabilities/EditorCapability.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index 2280b04e0c..1cbf239d7d 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -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(); From 0be84a4e5166d8f5eacc0b98df9bd1ddab3df2b1 Mon Sep 17 00:00:00 2001 From: Alex M Date: Tue, 13 Sep 2016 23:59:28 +0300 Subject: [PATCH 10/24] [Edit] CreateAction closes editor after save --- .../commonUI/edit/src/capabilities/EditorCapability.js | 1 - platform/commonUI/edit/src/creation/CreateAction.js | 9 +++++++-- platform/commonUI/edit/test/creation/CreateActionSpec.js | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index 1cbf239d7d..2ea532f6a6 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -103,7 +103,6 @@ define( var domainObject = this.domainObject; return this.transactionService.cancel().then(function () { domainObject.getCapability("status").set("editing", false); - return domainObject; }); }; diff --git a/platform/commonUI/edit/src/creation/CreateAction.js b/platform/commonUI/edit/src/creation/CreateAction.js index 3cfbdb0ef9..711e4001a6 100644 --- a/platform/commonUI/edit/src/creation/CreateAction.js +++ b/platform/commonUI/edit/src/creation/CreateAction.js @@ -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.finish(); + return closeEditor(); } newModel.type = this.type.getKey(); diff --git a/platform/commonUI/edit/test/creation/CreateActionSpec.js b/platform/commonUI/edit/test/creation/CreateActionSpec.js index 19dc46896f..60040b5410 100644 --- a/platform/commonUI/edit/test/creation/CreateActionSpec.js +++ b/platform/commonUI/edit/test/creation/CreateActionSpec.js @@ -142,6 +142,7 @@ define( }); describe("the perform function", function () { + var promise = jasmine.createSpyObj("promise", ["then"]); beforeEach(function () { capabilities.action.getActions.andReturn([mockEditAction]); }); @@ -160,15 +161,16 @@ define( " available", function () { capabilities.action.getActions.andReturn([]); capabilities.action.perform.andReturn(mockPromise(undefined)); + capabilities.editor.save.andReturn(promise); action.perform(); expect(capabilities.action.perform).toHaveBeenCalledWith("save"); }); describe("uses to editor capability", function () { - var promise = jasmine.createSpyObj("promise", ["then"]); beforeEach(function () { capabilities.action.getActions.andReturn([]); capabilities.action.perform.andReturn(promise); + capabilities.editor.save.andReturn(promise); }); it("to save the edit if user saves dialog", function () { From 1ea7fa30842dcaa387c9263939d3f1408d23814a Mon Sep 17 00:00:00 2001 From: Alex M Date: Thu, 15 Sep 2016 20:28:29 +0300 Subject: [PATCH 11/24] [Edit] SaveAsAction tests cover save and finish --- .../edit/test/actions/SaveAsActionSpec.js | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index 6bf631feed..a51e165688 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global describe,it,expect,beforeEach,jasmine*/ +/*global describe,it,expect,beforeEach,jasmine,runs,waitsFor,spyOn*/ define( ["../../src/actions/SaveAsAction"], @@ -78,9 +78,10 @@ define( mockEditorCapability = jasmine.createSpyObj( "editor", - ["save", "isEditContextRoot"] + ["save", "finish", "isEditContextRoot"] ); mockEditorCapability.save.andReturn(mockPromise(true)); + mockEditorCapability.finish.andReturn(mockPromise(true)); mockEditorCapability.isEditContextRoot.andReturn(true); capabilities.editor = mockEditorCapability; @@ -154,6 +155,28 @@ define( mockDomainObject.getModel.andReturn({persisted: 0}); expect(SaveAsAction.appliesTo(actionContext)).toBe(false); }); + + it("uses the editor capability to save the object", function () { + mockEditorCapability.save.andReturn(new Promise(function () {})); + runs(function () { + action.perform(); + }); + waitsFor(function () { + return mockEditorCapability.save.calls.length > 0; + }, "perform() should call EditorCapability.save"); + runs(function () { + expect(mockEditorCapability.finish).not.toHaveBeenCalled(); + }); + }); + + it("uses the editor capability to finish editing the object", function () { + runs(function () { + action.perform(); + }); + waitsFor(function () { + return mockEditorCapability.finish.calls.length > 0; + }, "perform() should call EditorCapability.finish"); + }); it("returns to browse after save", function () { spyOn(action, "save"); From 31ee92b7110b52ce432994a3dcc126eef2daf844 Mon Sep 17 00:00:00 2001 From: Alex M Date: Thu, 15 Sep 2016 20:39:02 +0300 Subject: [PATCH 12/24] [Edit] Remove editor.cancel from SaveActionSpec --- platform/commonUI/edit/test/actions/SaveActionSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/commonUI/edit/test/actions/SaveActionSpec.js b/platform/commonUI/edit/test/actions/SaveActionSpec.js index 7324b53085..7230c09448 100644 --- a/platform/commonUI/edit/test/actions/SaveActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveActionSpec.js @@ -56,7 +56,7 @@ define( ); mockEditorCapability = jasmine.createSpyObj( "editor", - ["save", "cancel", "isEditContextRoot"] + ["save", "isEditContextRoot"] ); mockActionCapability = jasmine.createSpyObj( "actionCapability", From d1f67fd8b9f8eaa82cc1c1b04504a2c4210e1cd8 Mon Sep 17 00:00:00 2001 From: Alex M Date: Thu, 15 Sep 2016 22:40:02 +0300 Subject: [PATCH 13/24] [Edit] Introduce dropdown Save menu And fix style issues in SaveAsActionSpec --- platform/commonUI/edit/bundle.js | 24 +++++-- .../res/templates/edit-action-buttons.html | 23 ++++++- .../src/controllers/EditActionController.js | 30 +++++++-- .../edit/test/actions/SaveAsActionSpec.js | 2 +- .../controllers/EditActionControllerSpec.js | 66 +++++++++++++++++-- 5 files changed, 124 insertions(+), 21 deletions(-) diff --git a/platform/commonUI/edit/bundle.js b/platform/commonUI/edit/bundle.js index 787f02d9c4..b1af2f6f50 100644 --- a/platform/commonUI/edit/bundle.js +++ b/platform/commonUI/edit/bundle.js @@ -30,6 +30,7 @@ define([ "./src/actions/EditAction", "./src/actions/PropertiesAction", "./src/actions/RemoveAction", + "./src/actions/SaveAction", "./src/actions/SaveAndStopEditingAction", "./src/actions/SaveAsAction", "./src/actions/CancelAction", @@ -69,6 +70,7 @@ define([ EditAction, PropertiesAction, RemoveAction, + SaveAction, SaveAndStopEditingAction, SaveAsAction, CancelAction, @@ -203,20 +205,30 @@ define([ ] }, { - "key": "save", - "category": "conclude-editing", + "key": "save-and-stop-editing", + "category": "save", "implementation": SaveAndStopEditingAction, - "name": "Save", + "name": "Save and Done Editing", "cssclass": "icon-save labeled", "description": "Save changes made to these objects.", "depends": [ "dialogService" - ], - "priority": "mandatory" + ] }, { "key": "save", - "category": "conclude-editing", + "category": "save", + "implementation": SaveAction, + "name": "Save and Continue Editing", + "cssclass": "icon-save labeled", + "description": "Save changes made to these objects.", + "depends": [ + "dialogService" + ] + }, + { + "key": "save-as", + "category": "save", "implementation": SaveAsAction, "name": "Save As...", "cssclass": "icon-save labeled", diff --git a/platform/commonUI/edit/res/templates/edit-action-buttons.html b/platform/commonUI/edit/res/templates/edit-action-buttons.html index fc46b31f57..7884373d18 100644 --- a/platform/commonUI/edit/res/templates/edit-action-buttons.html +++ b/platform/commonUI/edit/res/templates/edit-action-buttons.html @@ -20,11 +20,30 @@ at runtime from the About dialog for additional information. --> - + + + + {{saveActions[0].getMetadata().name}} + + + + + + + + + + ng-class="{ major: $index === 0 && saveActions.length === 0 }"> {{currentAction.getMetadata().name}} diff --git a/platform/commonUI/edit/src/controllers/EditActionController.js b/platform/commonUI/edit/src/controllers/EditActionController.js index 19fddf931d..7c33799ebb 100644 --- a/platform/commonUI/edit/src/controllers/EditActionController.js +++ b/platform/commonUI/edit/src/controllers/EditActionController.js @@ -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,11 +36,30 @@ 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) : []; } diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index a51e165688..a175118f16 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -155,7 +155,7 @@ define( mockDomainObject.getModel.andReturn({persisted: 0}); expect(SaveAsAction.appliesTo(actionContext)).toBe(false); }); - + it("uses the editor capability to save the object", function () { mockEditorCapability.save.andReturn(new Promise(function () {})); runs(function () { diff --git a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js index 36faf7beb8..7905368e05 100644 --- a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js @@ -19,22 +19,54 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ +/*global describe,it,expect,beforeEach,jasmine,spyOn*/ define( ["../../src/controllers/EditActionController"], function (EditActionController) { describe("The Edit Action controller", function () { + function FakeSaveAction() { + } + + var fakeSaveActionMetadata = { + name: "mocked-save-action", + cssclass: "mocked-save-action-css" + }; + + FakeSaveAction.prototype.getMetadata = function () { + return fakeSaveActionMetadata; + }; + + FakeSaveAction.prototype.perform = function () { + }; + + function fakeGetActions(actionContext) { + if (actionContext.category === "save") { + return [new FakeSaveAction(), new FakeSaveAction()]; + } else if (actionContext.category === "conclude-editing") { + return ["a", "b", "c"]; + } else { + throw "EditActionController uses a context that's not covered by tests."; + } + } + var mockScope, mockActions, controller; beforeEach(function () { mockActions = jasmine.createSpyObj("action", ["getActions"]); + mockActions.getActions.andCallFake(fakeGetActions); mockScope = jasmine.createSpyObj("$scope", ["$watch"]); + mockScope.action = mockActions; controller = new EditActionController(mockScope); }); + function makeControllerUpdateActions() { + mockScope.$watch.mostRecentCall.args[1](); + } + it("watches scope that may change applicable actions", function () { // The action capability expect(mockScope.$watch).toHaveBeenCalledWith( @@ -43,16 +75,36 @@ define( ); }); - it("populates the scope with grouped and ungrouped actions", function () { - mockScope.action = mockActions; + it("populates the scope with 'save' actions", function () { + makeControllerUpdateActions(); + expect(mockScope.saveActions.length).toEqual(2); + }); - mockActions.getActions.andReturn(["a", "b", "c"]); + it("converts 'save' actions to their menu counterparts", function () { + makeControllerUpdateActions(); + var menuOptions = mockScope.saveActionsAsMenuOptions; - // Call the watch - mockScope.$watch.mostRecentCall.args[1](); + expect(menuOptions.length).toEqual(2); + expect(menuOptions[0].key).toEqual(mockScope.saveActions[0]); + expect(menuOptions[1].key).toEqual(mockScope.saveActions[1]); + menuOptions.forEach(function (option) { + expect(option.name).toEqual(fakeSaveActionMetadata.name); + expect(option.cssclass).toEqual(fakeSaveActionMetadata.cssclass); + }); + }); - // Should have grouped and ungrouped actions in scope now - expect(mockScope.editActions.length).toEqual(3); + it("uses a click handler to perform the clicked action", function () { + makeControllerUpdateActions(); + var sampleSaveAction = mockScope.saveActions[0]; + + spyOn(sampleSaveAction, "perform"); + mockScope.saveActionMenuClickHandler(sampleSaveAction); + expect(sampleSaveAction.perform).toHaveBeenCalled(); + }); + + it("populates the scope with other 'conclude-editing' actions", function () { + makeControllerUpdateActions(); + expect(mockScope.otherEditActions).toEqual(["a", "b", "c"]); }); }); } From d3db26499c6cc3c7e5ff67c0b490c55988b9de48 Mon Sep 17 00:00:00 2001 From: Alex M Date: Thu, 15 Sep 2016 23:14:12 +0300 Subject: [PATCH 14/24] [Edit] CreateAction needs to perform("save-as") --- platform/commonUI/edit/src/creation/CreateAction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/edit/src/creation/CreateAction.js b/platform/commonUI/edit/src/creation/CreateAction.js index 711e4001a6..b83351544f 100644 --- a/platform/commonUI/edit/src/creation/CreateAction.js +++ b/platform/commonUI/edit/src/creation/CreateAction.js @@ -90,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); } }; From f03003b366c21c8e3aba882f7853c407deddd471 Mon Sep 17 00:00:00 2001 From: Alex M Date: Thu, 15 Sep 2016 23:18:53 +0300 Subject: [PATCH 15/24] [Edit] Fix CreateActionSpec --- platform/commonUI/edit/test/creation/CreateActionSpec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/edit/test/creation/CreateActionSpec.js b/platform/commonUI/edit/test/creation/CreateActionSpec.js index 60040b5410..cd3d3fbc91 100644 --- a/platform/commonUI/edit/test/creation/CreateActionSpec.js +++ b/platform/commonUI/edit/test/creation/CreateActionSpec.js @@ -157,13 +157,13 @@ define( expect(mockEditAction.perform).toHaveBeenCalled(); }); - it("uses the save action if object does not have an edit action" + + it("uses the save-as action if object does not have an edit action" + " available", function () { capabilities.action.getActions.andReturn([]); capabilities.action.perform.andReturn(mockPromise(undefined)); capabilities.editor.save.andReturn(promise); action.perform(); - expect(capabilities.action.perform).toHaveBeenCalledWith("save"); + expect(capabilities.action.perform).toHaveBeenCalledWith("save-as"); }); describe("uses to editor capability", function () { From 1446b16e77f1df668784e05c8047f591deba07c2 Mon Sep 17 00:00:00 2001 From: Alex M Date: Fri, 16 Sep 2016 03:15:10 +0300 Subject: [PATCH 16/24] [Edit] Using spy objects as save action mocks --- .../controllers/EditActionControllerSpec.js | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js index 7905368e05..6b7b52debc 100644 --- a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js @@ -26,24 +26,21 @@ define( function (EditActionController) { describe("The Edit Action controller", function () { - function FakeSaveAction() { - } - - var fakeSaveActionMetadata = { + var mockSaveActionMetadata = { name: "mocked-save-action", cssclass: "mocked-save-action-css" }; - FakeSaveAction.prototype.getMetadata = function () { - return fakeSaveActionMetadata; - }; - - FakeSaveAction.prototype.perform = function () { - }; - function fakeGetActions(actionContext) { if (actionContext.category === "save") { - return [new FakeSaveAction(), new FakeSaveAction()]; + var mockedSaveActions = [ + jasmine.createSpyObj("mockSaveAction", ["getMetadata", "perform"]), + jasmine.createSpyObj("mockSaveAction", ["getMetadata", "perform"]) + ]; + mockedSaveActions.forEach(function (action) { + action.getMetadata.andReturn(mockSaveActionMetadata); + }); + return mockedSaveActions; } else if (actionContext.category === "conclude-editing") { return ["a", "b", "c"]; } else { @@ -88,21 +85,19 @@ define( expect(menuOptions[0].key).toEqual(mockScope.saveActions[0]); expect(menuOptions[1].key).toEqual(mockScope.saveActions[1]); menuOptions.forEach(function (option) { - expect(option.name).toEqual(fakeSaveActionMetadata.name); - expect(option.cssclass).toEqual(fakeSaveActionMetadata.cssclass); + expect(option.name).toEqual(mockSaveActionMetadata.name); + expect(option.cssclass).toEqual(mockSaveActionMetadata.cssclass); }); }); it("uses a click handler to perform the clicked action", function () { makeControllerUpdateActions(); var sampleSaveAction = mockScope.saveActions[0]; - - spyOn(sampleSaveAction, "perform"); mockScope.saveActionMenuClickHandler(sampleSaveAction); expect(sampleSaveAction.perform).toHaveBeenCalled(); }); - it("populates the scope with other 'conclude-editing' actions", function () { + it("populates the scope with other editing actions", function () { makeControllerUpdateActions(); expect(mockScope.otherEditActions).toEqual(["a", "b", "c"]); }); From 2a2e9ef99df364a9b9c2780178caff40c174833f Mon Sep 17 00:00:00 2001 From: Alex M Date: Fri, 16 Sep 2016 03:24:00 +0300 Subject: [PATCH 17/24] [Edit] Make linter happy --- .../commonUI/edit/test/controllers/EditActionControllerSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js index 6b7b52debc..bd5c8a9524 100644 --- a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global describe,it,expect,beforeEach,jasmine,spyOn*/ +/*global describe,it,expect,beforeEach,jasmine*/ define( ["../../src/controllers/EditActionController"], From ae89dcd62dd013db63dcda4e9a09ea1126003b5e Mon Sep 17 00:00:00 2001 From: Alex M Date: Sat, 17 Sep 2016 00:39:49 +0300 Subject: [PATCH 18/24] [Edit] Make single save button use mct-control --- .../edit/res/templates/edit-action-buttons.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/platform/commonUI/edit/res/templates/edit-action-buttons.html b/platform/commonUI/edit/res/templates/edit-action-buttons.html index 7884373d18..0cc21b02ca 100644 --- a/platform/commonUI/edit/res/templates/edit-action-buttons.html +++ b/platform/commonUI/edit/res/templates/edit-action-buttons.html @@ -22,11 +22,13 @@ - - {{saveActions[0].getMetadata().name}} - + + @@ -39,7 +41,7 @@ - + Date: Sat, 17 Sep 2016 01:05:46 +0300 Subject: [PATCH 19/24] [Edit] Rename action to Save and Finish Editing --- platform/commonUI/edit/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/commonUI/edit/bundle.js b/platform/commonUI/edit/bundle.js index b1af2f6f50..48f38d7ee9 100644 --- a/platform/commonUI/edit/bundle.js +++ b/platform/commonUI/edit/bundle.js @@ -208,7 +208,7 @@ define([ "key": "save-and-stop-editing", "category": "save", "implementation": SaveAndStopEditingAction, - "name": "Save and Done Editing", + "name": "Save and Finish Editing", "cssclass": "icon-save labeled", "description": "Save changes made to these objects.", "depends": [ From b50278e92fa6217bc4c890458b8f7a447045ed51 Mon Sep 17 00:00:00 2001 From: Alex M Date: Mon, 19 Sep 2016 20:22:46 +0300 Subject: [PATCH 20/24] [Edit] Remove mocked unused UrlService --- platform/commonUI/edit/test/actions/SaveAsActionSpec.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index a175118f16..c1b0eee003 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -33,7 +33,6 @@ define( mockDialogService, mockCopyService, mockParent, - mockUrlService, actionContext, capabilities = {}, action; @@ -112,12 +111,7 @@ define( "perform" ] ); - - mockUrlService = jasmine.createSpyObj( - "urlService", - ["urlForLocation"] - ); - + actionContext = { domainObject: mockDomainObject }; From f60fc2ebad09085fd71d80d1d900483c2999e025 Mon Sep 17 00:00:00 2001 From: Alex M Date: Mon, 19 Sep 2016 20:33:12 +0300 Subject: [PATCH 21/24] [Edit] EditorCapability.finish returns domainObj --- platform/commonUI/edit/src/capabilities/EditorCapability.js | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index 2ea532f6a6..1cbf239d7d 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -103,6 +103,7 @@ define( var domainObject = this.domainObject; return this.transactionService.cancel().then(function () { domainObject.getCapability("status").set("editing", false); + return domainObject; }); }; From e08704e6d30413cf5533e62be68f003334a3ff1c Mon Sep 17 00:00:00 2001 From: Alex M Date: Mon, 19 Sep 2016 20:39:54 +0300 Subject: [PATCH 22/24] [Edit] Make checkstyle happy --- platform/commonUI/edit/test/actions/SaveAsActionSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index c1b0eee003..95f0209800 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -111,7 +111,7 @@ define( "perform" ] ); - + actionContext = { domainObject: mockDomainObject }; From abfabc85b56f7b335484b4f30249362179d93371 Mon Sep 17 00:00:00 2001 From: Alex M Date: Mon, 19 Sep 2016 20:41:50 +0300 Subject: [PATCH 23/24] [Edit] Fix edit-action-buttons indent --- platform/commonUI/edit/res/templates/edit-action-buttons.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/commonUI/edit/res/templates/edit-action-buttons.html b/platform/commonUI/edit/res/templates/edit-action-buttons.html index 0cc21b02ca..4bc020612f 100644 --- a/platform/commonUI/edit/res/templates/edit-action-buttons.html +++ b/platform/commonUI/edit/res/templates/edit-action-buttons.html @@ -41,7 +41,7 @@ - + Date: Mon, 19 Sep 2016 23:52:30 +0300 Subject: [PATCH 24/24] [Edit] Remove CreationService dep from SaveAs --- platform/commonUI/edit/bundle.js | 1 - platform/commonUI/edit/src/actions/SaveAsAction.js | 2 -- platform/commonUI/edit/test/actions/SaveAsActionSpec.js | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/platform/commonUI/edit/bundle.js b/platform/commonUI/edit/bundle.js index 48f38d7ee9..60da900176 100644 --- a/platform/commonUI/edit/bundle.js +++ b/platform/commonUI/edit/bundle.js @@ -237,7 +237,6 @@ define([ "$injector", "policyService", "dialogService", - "creationService", "copyService" ], "priority": "mandatory" diff --git a/platform/commonUI/edit/src/actions/SaveAsAction.js b/platform/commonUI/edit/src/actions/SaveAsAction.js index 402fccb86c..2befea07fd 100644 --- a/platform/commonUI/edit/src/actions/SaveAsAction.js +++ b/platform/commonUI/edit/src/actions/SaveAsAction.js @@ -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; } diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index 95f0209800..f87cf4766f 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -116,7 +116,7 @@ define( domainObject: mockDomainObject }; - action = new SaveAsAction(undefined, undefined, mockDialogService, undefined, mockCopyService, actionContext); + action = new SaveAsAction(undefined, undefined, mockDialogService, mockCopyService, actionContext); spyOn(action, "getObjectService"); action.getObjectService.andReturn(mockObjectService);