From 1c007ea2561ce1047ecc88e113e641d0c86f84d0 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 23 May 2016 14:55:04 -0700 Subject: [PATCH 01/13] [Code Style] Remove trailing whitespace ...to fix build after changes for #142. --- platform/representation/src/gestures/DropGesture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/representation/src/gestures/DropGesture.js b/platform/representation/src/gestures/DropGesture.js index 7f94dad223..966618d88c 100644 --- a/platform/representation/src/gestures/DropGesture.js +++ b/platform/representation/src/gestures/DropGesture.js @@ -46,7 +46,7 @@ define( // Find the relevant scope... var rect, scope = element.scope && element.scope(); - + if (scope && scope.$broadcast) { // Get the representation's bounds, to convert // drop position From ab64b682c3ccc5d69e7aa27ba6f81c506ba4c876 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 23 May 2016 14:58:23 -0700 Subject: [PATCH 02/13] [Code Style] Run checkstyle on CircleCI Run the full gulp verify task for testing on CircleCI, to handle unit tests as well as code style checks and linting (and other verification steps that may be added in the future.) --- circle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index 7caa57740d..3b245f7941 100644 --- a/circle.yml +++ b/circle.yml @@ -15,8 +15,8 @@ deployment: heroku: appname: openmctweb-staging-deux test: - post: - - gulp lint + override: + - gulp verify general: branches: From eff46b076c296ce3346121551dd19aeb51ed7f20 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 23 May 2016 15:03:20 -0700 Subject: [PATCH 03/13] [New Edit Mode] #628 Removed duplicate logic from Create Action --- .../browse/src/creation/CreateAction.js | 30 +++++++++++-------- .../commonUI/edit/src/actions/EditAction.js | 6 ++++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/platform/commonUI/browse/src/creation/CreateAction.js b/platform/commonUI/browse/src/creation/CreateAction.js index c5097e166d..2e04a0b07e 100644 --- a/platform/commonUI/browse/src/creation/CreateAction.js +++ b/platform/commonUI/browse/src/creation/CreateAction.js @@ -83,25 +83,29 @@ define( CreateAction.prototype.perform = function () { var newModel = this.type.getInitialModel(), parentObject = this.navigationService.getNavigation(), - editorCapability, - newObject; + newObject, + editAction, + editorCapability; + + function onSave() { + return editorCapability.save(); + } + + function onCancel() { + return editorCapability.cancel(); + } newModel.type = this.type.getKey(); newModel.location = parentObject.getId(); newObject = parentObject.useCapability('instantiation', newModel); + editorCapability = newObject.hasCapability('editor') && newObject.getCapability("editor"); - editorCapability = newObject.getCapability("editor"); - - if (countEditableViews(newObject) > 0 && newObject.hasCapability('composition')) { - this.navigationService.setNavigation(newObject); - return newObject.getCapability("action").perform("edit"); - } else { + editAction = newObject.getCapability("action").getActions("edit")[0]; + if (editAction) { + return editAction.perform("edit"); + } else if (editorCapability) { editorCapability.edit(); - return newObject.useCapability("action").perform("save").then(function () { - return editorCapability.save(); - }, function () { - return editorCapability.cancel(); - }); + return newObject.useCapability("action").perform("save").then(onSave, onCancel); } }; diff --git a/platform/commonUI/edit/src/actions/EditAction.js b/platform/commonUI/edit/src/actions/EditAction.js index b2aae8fa1b..9e5c90d897 100644 --- a/platform/commonUI/edit/src/actions/EditAction.js +++ b/platform/commonUI/edit/src/actions/EditAction.js @@ -74,6 +74,12 @@ define( 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"); }; From 9a8bcc055002729a791656529781c5f413f8cc5f Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 23 May 2016 15:10:05 -0700 Subject: [PATCH 04/13] [Code Style] Specify lint, codestyle in CircleCI config ...to work around unexpected failure running test suite via gulp verify, https://circleci.com/gh/nasa/openmct/1981 --- circle.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index 3b245f7941..b075c1f5fe 100644 --- a/circle.yml +++ b/circle.yml @@ -15,8 +15,9 @@ deployment: heroku: appname: openmctweb-staging-deux test: - override: - - gulp verify + post: + - gulp lint + - gulp checkstyle general: branches: From 96af931c0b8a9aaa89085c935c3aecbcdd8f4304 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 23 May 2016 16:48:31 -0700 Subject: [PATCH 05/13] Modified EditActionPolicy to prevent editing of table views unless object is a table type --- platform/commonUI/edit/src/policies/EditActionPolicy.js | 5 ++++- platform/features/table/bundle.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/commonUI/edit/src/policies/EditActionPolicy.js b/platform/commonUI/edit/src/policies/EditActionPolicy.js index f0c2910c11..cc40c32d9f 100644 --- a/platform/commonUI/edit/src/policies/EditActionPolicy.js +++ b/platform/commonUI/edit/src/policies/EditActionPolicy.js @@ -56,7 +56,10 @@ define( // A view is editable unless explicitly flagged as not (views || []).forEach(function (view) { if (view.editable === true || - (view.key === 'plot' && type.getKey() === 'telemetry.panel')) { + (view.key === 'plot' && type.getKey() === 'telemetry.panel') || + (view.key === 'table' && type.getKey() === 'table') || + (view.key === 'rt-table' && type.getKey() === 'rttable') + ) { count++; } }); diff --git a/platform/features/table/bundle.js b/platform/features/table/bundle.js index ee907bc963..cdcb6603d9 100644 --- a/platform/features/table/bundle.js +++ b/platform/features/table/bundle.js @@ -133,7 +133,7 @@ define([ "telemetry" ], "delegation": true, - "editable": true + "editable": false }, { "name": "Real-time Table", @@ -144,7 +144,7 @@ define([ "telemetry" ], "delegation": true, - "editable": true + "editable": false } ], "directives": [ From f0ab817e87ce3f66941a637fdd19721804b13ab4 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 24 May 2016 10:23:48 -0700 Subject: [PATCH 06/13] Added tests, and fixed failing ones --- platform/commonUI/browse/bundle.js | 2 - .../browse/src/creation/CreateAction.js | 32 +---- .../src/creation/CreateActionProvider.js | 8 +- .../test/creation/CreateActionProviderSpec.js | 13 -- .../browse/test/creation/CreateActionSpec.js | 128 +++++++++++++----- 5 files changed, 103 insertions(+), 80 deletions(-) diff --git a/platform/commonUI/browse/bundle.js b/platform/commonUI/browse/bundle.js index 73b3f44de7..8a694c57a7 100644 --- a/platform/commonUI/browse/bundle.js +++ b/platform/commonUI/browse/bundle.js @@ -309,9 +309,7 @@ define([ "type": "provider", "implementation": CreateActionProvider, "depends": [ - "$q", "typeService", - "navigationService", "policyService" ] }, diff --git a/platform/commonUI/browse/src/creation/CreateAction.js b/platform/commonUI/browse/src/creation/CreateAction.js index 2e04a0b07e..6ea0d513a5 100644 --- a/platform/commonUI/browse/src/creation/CreateAction.js +++ b/platform/commonUI/browse/src/creation/CreateAction.js @@ -43,11 +43,8 @@ define( * override this) * @param {ActionContext} context the context in which the * action is being performed - * @param {NavigationService} navigationService the navigation service, - * which handles changes in navigation. It allows the object - * being browsed/edited to be set. */ - function CreateAction(type, parent, context, $q, navigationService) { + function CreateAction(type, parent, context) { this.metadata = { key: 'create', glyph: type.getGlyph(), @@ -56,24 +53,8 @@ define( description: type.getDescription(), context: context }; - this.type = type; this.parent = parent; - this.navigationService = navigationService; - this.$q = $q; - } - - // Get a count of views which are not flagged as non-editable. - function countEditableViews(domainObject) { - var views = domainObject && domainObject.useCapability('view'), - count = 0; - - // A view is editable unless explicitly flagged as not - (views || []).forEach(function (view) { - count += (view.editable !== false) ? 1 : 0; - }); - - return count; } /** @@ -82,7 +63,6 @@ define( */ CreateAction.prototype.perform = function () { var newModel = this.type.getInitialModel(), - parentObject = this.navigationService.getNavigation(), newObject, editAction, editorCapability; @@ -96,16 +76,18 @@ define( } newModel.type = this.type.getKey(); - newModel.location = parentObject.getId(); - newObject = parentObject.useCapability('instantiation', newModel); + newModel.location = this.parent.getId(); + newObject = this.parent.useCapability('instantiation', newModel); editorCapability = newObject.hasCapability('editor') && newObject.getCapability("editor"); editAction = newObject.getCapability("action").getActions("edit")[0]; + //If an edit action is available, perform it if (editAction) { - return editAction.perform("edit"); + return editAction.perform(); } else if (editorCapability) { + //otherwise, use the save action editorCapability.edit(); - return newObject.useCapability("action").perform("save").then(onSave, onCancel); + return newObject.getCapability("action").perform("save").then(onSave, onCancel); } }; diff --git a/platform/commonUI/browse/src/creation/CreateActionProvider.js b/platform/commonUI/browse/src/creation/CreateActionProvider.js index 82f57343da..5039149104 100644 --- a/platform/commonUI/browse/src/creation/CreateActionProvider.js +++ b/platform/commonUI/browse/src/creation/CreateActionProvider.js @@ -44,10 +44,8 @@ define( * introduced in this bundle), responsible for handling actual * object creation. */ - function CreateActionProvider($q, typeService, navigationService, policyService) { + function CreateActionProvider(typeService, policyService) { this.typeService = typeService; - this.navigationService = navigationService; - this.$q = $q; this.policyService = policyService; } @@ -72,9 +70,7 @@ define( return new CreateAction( type, destination, - context, - self.$q, - self.navigationService + context ); }); }; diff --git a/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js b/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js index fbfc4a1140..d8aefe17fa 100644 --- a/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js +++ b/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js @@ -29,13 +29,10 @@ define( describe("The create action provider", function () { var mockTypeService, - mockDialogService, - mockNavigationService, mockPolicyService, mockCreationPolicy, mockPolicyMap = {}, mockTypes, - mockQ, provider; function createMockType(name) { @@ -61,14 +58,6 @@ define( "typeService", ["listTypes"] ); - mockDialogService = jasmine.createSpyObj( - "dialogService", - ["getUserInput"] - ); - mockNavigationService = jasmine.createSpyObj( - "navigationService", - ["setNavigation"] - ); mockPolicyService = jasmine.createSpyObj( "policyService", ["allow"] @@ -91,9 +80,7 @@ define( mockTypeService.listTypes.andReturn(mockTypes); provider = new CreateActionProvider( - mockQ, mockTypeService, - mockNavigationService, mockPolicyService ); }); diff --git a/platform/commonUI/browse/test/creation/CreateActionSpec.js b/platform/commonUI/browse/test/creation/CreateActionSpec.js index 5fa89512e0..b37339fa40 100644 --- a/platform/commonUI/browse/test/creation/CreateActionSpec.js +++ b/platform/commonUI/browse/test/creation/CreateActionSpec.js @@ -31,8 +31,10 @@ define( var mockType, mockParent, mockContext, - mockDialogService, - mockCreationService, + mockDomainObject, + capabilities = {}, + mockEditAction, + mockSaveAction, action; function mockPromise(value) { @@ -60,20 +62,61 @@ define( [ "getId", "getModel", - "getCapability" + "getCapability", + "useCapability" ] ); + mockDomainObject = jasmine.createSpyObj( + "domainObject", + [ + "getId", + "getModel", + "getCapability", + "hasCapability", + "useCapability" + ] + ); + mockDomainObject.hasCapability.andCallFake(function (name) { + return !!capabilities[name]; + }); + mockDomainObject.getCapability.andCallFake(function (name) { + return capabilities[name]; + }); + mockSaveAction = jasmine.createSpyObj( + "saveAction", + [ + "perform" + ] + ); + + capabilities.action = jasmine.createSpyObj( + "actionCapability", + [ + "getActions", + "perform" + ] + ); + + capabilities.editor = jasmine.createSpyObj( + "editorCapability", + [ + "edit", + "save", + "cancel" + ] + ); + + mockEditAction = jasmine.createSpyObj( + "editAction", + [ + "perform" + ] + ); + mockContext = { domainObject: mockParent }; - mockDialogService = jasmine.createSpyObj( - "dialogService", - ["getUserInput"] - ); - mockCreationService = jasmine.createSpyObj( - "creationService", - ["createObject"] - ); + mockParent.useCapability.andReturn(mockDomainObject); mockType.getKey.andReturn("test"); mockType.getGlyph.andReturn("T"); @@ -82,14 +125,10 @@ define( mockType.getProperties.andReturn([]); mockType.getInitialModel.andReturn({}); - mockDialogService.getUserInput.andReturn(mockPromise({})); - action = new CreateAction( mockType, mockParent, - mockContext, - mockDialogService, - mockCreationService + mockContext ); }); @@ -101,28 +140,49 @@ define( expect(metadata.glyph).toEqual("T"); }); - //TODO: Disabled for NEM Beta - xit("invokes the creation service when performed", function () { - action.perform(); - expect(mockCreationService.createObject).toHaveBeenCalledWith( - { type: "test" }, - mockParent - ); - }); - - //TODO: Disabled for NEM Beta - xit("does not create an object if the user cancels", function () { - mockDialogService.getUserInput.andReturn({ - then: function (callback, fail) { - fail(); - } + describe("the perform function", function () { + beforeEach(function () { + capabilities.action.getActions.andReturn([mockEditAction]); }); - action.perform(); + it("uses the instantiation capability when performed", function () { + action.perform(); + expect(mockParent.useCapability).toHaveBeenCalledWith("instantiation", jasmine.any(Object)); + }); - expect(mockCreationService.createObject) - .not.toHaveBeenCalled(); + it("uses the edit action if available", function () { + action.perform(); + expect(mockEditAction.perform).toHaveBeenCalled(); + }); + it("uses the save action if object does not have an edit action" + + " available", function () { + capabilities.action.getActions.andReturn([]); + capabilities.action.perform.andReturn(mockPromise(undefined)); + 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); + }); + + it("to save the edit if user saves dialog", function () { + action.perform(); + expect(promise.then).toHaveBeenCalled(); + promise.then.mostRecentCall.args[0](); + expect(capabilities.editor.save).toHaveBeenCalled(); + }); + + it("to cancel the edit if user cancels dialog", function () { + action.perform(); + promise.then.mostRecentCall.args[1](); + expect(capabilities.editor.cancel).toHaveBeenCalled(); + }); + }); }); }); From 32d7187db6a57ad9cf0423a3e7c48023b86b7b9f Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 24 May 2016 17:08:12 -0700 Subject: [PATCH 07/13] Relocated creation package to edit bundle --- platform/commonUI/browse/bundle.js | 91 ------------------ platform/commonUI/edit/bundle.js | 93 ++++++++++++++++++- .../res/templates/create/create-button.html | 0 .../res/templates/create/create-menu.html | 0 .../res/templates/create/locator.html | 0 .../commonUI/edit/src/actions/SaveAsAction.js | 2 +- .../src/creation/AddAction.js | 0 .../src/creation/AddActionProvider.js | 0 .../src/creation/CreateAction.js | 0 .../src/creation/CreateActionProvider.js | 0 .../src/creation/CreateMenuController.js | 0 .../src/creation/CreateWizard.js | 0 .../src/creation/CreationPolicy.js | 0 .../src/creation/CreationService.js | 0 .../src/creation/LocatorController.js | 0 .../test/creation/AddActionProviderSpec.js | 0 .../test/creation/CreateActionProviderSpec.js | 0 .../test/creation/CreateActionSpec.js | 0 .../test/creation/CreateMenuControllerSpec.js | 0 .../test/creation/CreateWizardSpec.js | 0 .../test/creation/CreationPolicySpec.js | 0 .../test/creation/CreationServiceSpec.js | 0 .../test/creation/LocatorControllerSpec.js | 0 23 files changed, 91 insertions(+), 95 deletions(-) rename platform/commonUI/{browse => edit}/res/templates/create/create-button.html (100%) rename platform/commonUI/{browse => edit}/res/templates/create/create-menu.html (100%) rename platform/commonUI/{browse => edit}/res/templates/create/locator.html (100%) rename platform/commonUI/{browse => edit}/src/creation/AddAction.js (100%) rename platform/commonUI/{browse => edit}/src/creation/AddActionProvider.js (100%) rename platform/commonUI/{browse => edit}/src/creation/CreateAction.js (100%) rename platform/commonUI/{browse => edit}/src/creation/CreateActionProvider.js (100%) rename platform/commonUI/{browse => edit}/src/creation/CreateMenuController.js (100%) rename platform/commonUI/{browse => edit}/src/creation/CreateWizard.js (100%) rename platform/commonUI/{browse => edit}/src/creation/CreationPolicy.js (100%) rename platform/commonUI/{browse => edit}/src/creation/CreationService.js (100%) rename platform/commonUI/{browse => edit}/src/creation/LocatorController.js (100%) rename platform/commonUI/{browse => edit}/test/creation/AddActionProviderSpec.js (100%) rename platform/commonUI/{browse => edit}/test/creation/CreateActionProviderSpec.js (100%) rename platform/commonUI/{browse => edit}/test/creation/CreateActionSpec.js (100%) rename platform/commonUI/{browse => edit}/test/creation/CreateMenuControllerSpec.js (100%) rename platform/commonUI/{browse => edit}/test/creation/CreateWizardSpec.js (100%) rename platform/commonUI/{browse => edit}/test/creation/CreationPolicySpec.js (100%) rename platform/commonUI/{browse => edit}/test/creation/CreationServiceSpec.js (100%) rename platform/commonUI/{browse => edit}/test/creation/LocatorControllerSpec.js (100%) diff --git a/platform/commonUI/browse/bundle.js b/platform/commonUI/browse/bundle.js index 8a694c57a7..443660cc8b 100644 --- a/platform/commonUI/browse/bundle.js +++ b/platform/commonUI/browse/bundle.js @@ -24,23 +24,14 @@ define([ "./src/BrowseController", "./src/PaneController", "./src/BrowseObjectController", - "./src/creation/CreateMenuController", - "./src/creation/LocatorController", "./src/MenuArrowController", "./src/navigation/NavigationService", - "./src/creation/CreationPolicy", "./src/navigation/NavigateAction", "./src/windowing/NewTabAction", "./src/windowing/FullscreenAction", - "./src/creation/CreateActionProvider", - "./src/creation/AddActionProvider", - "./src/creation/CreationService", "./src/windowing/WindowTitler", "text!./res/templates/browse.html", - "text!./res/templates/create/locator.html", "text!./res/templates/browse-object.html", - "text!./res/templates/create/create-button.html", - "text!./res/templates/create/create-menu.html", "text!./res/templates/items/grid-item.html", "text!./res/templates/browse/object-header.html", "text!./res/templates/menu-arrow.html", @@ -53,23 +44,14 @@ define([ BrowseController, PaneController, BrowseObjectController, - CreateMenuController, - LocatorController, MenuArrowController, NavigationService, - CreationPolicy, NavigateAction, NewTabAction, FullscreenAction, - CreateActionProvider, - AddActionProvider, - CreationService, WindowTitler, browseTemplate, - locatorTemplate, browseObjectTemplate, - createButtonTemplate, - createMenuTemplate, gridItemTemplate, objectHeaderTemplate, menuArrowTemplate, @@ -136,22 +118,6 @@ define([ "$route" ] }, - { - "key": "CreateMenuController", - "implementation": CreateMenuController, - "depends": [ - "$scope" - ] - }, - { - "key": "LocatorController", - "implementation": LocatorController, - "depends": [ - "$scope", - "$timeout", - "objectService" - ] - }, { "key": "MenuArrowController", "implementation": MenuArrowController, @@ -160,12 +126,6 @@ define([ ] } ], - "controls": [ - { - "key": "locator", - "template": locatorTemplate - } - ], "representations": [ { "key": "view-object", @@ -181,17 +141,6 @@ define([ "view" ] }, - { - "key": "create-button", - "template": createButtonTemplate - }, - { - "key": "create-menu", - "template": createMenuTemplate, - "uses": [ - "action" - ] - }, { "key": "grid-item", "template": gridItemTemplate, @@ -244,12 +193,6 @@ define([ "implementation": NavigationService } ], - "policies": [ - { - "implementation": CreationPolicy, - "category": "creation" - } - ], "actions": [ { "key": "navigate", @@ -302,40 +245,6 @@ define([ "editable": false } ], - "components": [ - { - "key": "CreateActionProvider", - "provides": "actionService", - "type": "provider", - "implementation": CreateActionProvider, - "depends": [ - "typeService", - "policyService" - ] - }, - { - "key": "AddActionProvider", - "provides": "actionService", - "type": "provider", - "implementation": AddActionProvider, - "depends": [ - "$q", - "typeService", - "dialogService", - "policyService" - ] - }, - { - "key": "CreationService", - "provides": "creationService", - "type": "provider", - "implementation": CreationService, - "depends": [ - "$q", - "$log" - ] - } - ], "runs": [ { "implementation": WindowTitler, diff --git a/platform/commonUI/edit/bundle.js b/platform/commonUI/edit/bundle.js index 527c6b60a1..5107329bfb 100644 --- a/platform/commonUI/edit/bundle.js +++ b/platform/commonUI/edit/bundle.js @@ -43,6 +43,15 @@ define([ "./src/capabilities/EditorCapability", "./src/capabilities/TransactionCapabilityDecorator", "./src/services/TransactionService", + "./src/creation/CreateMenuController", + "./src/creation/LocatorController", + "./src/creation/CreationPolicy", + "./src/creation/CreateActionProvider", + "./src/creation/AddActionProvider", + "./src/creation/CreationService", + "text!./res/templates/create/locator.html", + "text!./res/templates/create/create-button.html", + "text!./res/templates/create/create-menu.html", "text!./res/templates/library.html", "text!./res/templates/edit-object.html", "text!./res/templates/edit-action-buttons.html", @@ -72,6 +81,15 @@ define([ EditorCapability, TransactionCapabilityDecorator, TransactionService, + CreateMenuController, + LocatorController, + CreationPolicy, + CreateActionProvider, + AddActionProvider, + CreationService, + locatorTemplate, + createButtonTemplate, + createMenuTemplate, libraryTemplate, editObjectTemplate, editActionButtonsTemplate, @@ -112,7 +130,23 @@ define([ "$location", "policyService" ] - } + }, + { + "key": "CreateMenuController", + "implementation": CreateMenuController, + "depends": [ + "$scope" + ] + }, + { + "key": "LocatorController", + "implementation": LocatorController, + "depends": [ + "$scope", + "$timeout", + "objectService" + ] + }, ], "directives": [ { @@ -221,8 +255,11 @@ define([ "category": "navigation", "message": "There are unsaved changes.", "implementation": EditNavigationPolicy + }, + { + "implementation": CreationPolicy, + "category": "creation" } - ], "templates": [ { @@ -261,7 +298,18 @@ define([ { "key": "topbar-edit", "template": topbarEditTemplate - } + }, + { + "key": "create-button", + "template": createButtonTemplate + }, + { + "key": "create-menu", + "template": createMenuTemplate, + "uses": [ + "action" + ] + }, ], "components": [ { @@ -282,7 +330,40 @@ define([ "$q", "$log" ] + }, + { + "key": "CreateActionProvider", + "provides": "actionService", + "type": "provider", + "implementation": CreateActionProvider, + "depends": [ + "typeService", + "policyService" + ] + }, + { + "key": "AddActionProvider", + "provides": "actionService", + "type": "provider", + "implementation": AddActionProvider, + "depends": [ + "$q", + "typeService", + "dialogService", + "policyService" + ] + }, + { + "key": "CreationService", + "provides": "creationService", + "type": "provider", + "implementation": CreationService, + "depends": [ + "$q", + "$log" + ] } + ], "representers": [ { @@ -316,6 +397,12 @@ define([ "transactionService" ] } + ], + "controls": [ + { + "key": "locator", + "template": locatorTemplate + } ] } }); diff --git a/platform/commonUI/browse/res/templates/create/create-button.html b/platform/commonUI/edit/res/templates/create/create-button.html similarity index 100% rename from platform/commonUI/browse/res/templates/create/create-button.html rename to platform/commonUI/edit/res/templates/create/create-button.html diff --git a/platform/commonUI/browse/res/templates/create/create-menu.html b/platform/commonUI/edit/res/templates/create/create-menu.html similarity index 100% rename from platform/commonUI/browse/res/templates/create/create-menu.html rename to platform/commonUI/edit/res/templates/create/create-menu.html diff --git a/platform/commonUI/browse/res/templates/create/locator.html b/platform/commonUI/edit/res/templates/create/locator.html similarity index 100% rename from platform/commonUI/browse/res/templates/create/locator.html rename to platform/commonUI/edit/res/templates/create/locator.html diff --git a/platform/commonUI/edit/src/actions/SaveAsAction.js b/platform/commonUI/edit/src/actions/SaveAsAction.js index 05a9fe7918..cee67ebbfe 100644 --- a/platform/commonUI/edit/src/actions/SaveAsAction.js +++ b/platform/commonUI/edit/src/actions/SaveAsAction.js @@ -22,7 +22,7 @@ define( - ['../../../browse/src/creation/CreateWizard'], + ['../creation/CreateWizard'], function (CreateWizard) { /** diff --git a/platform/commonUI/browse/src/creation/AddAction.js b/platform/commonUI/edit/src/creation/AddAction.js similarity index 100% rename from platform/commonUI/browse/src/creation/AddAction.js rename to platform/commonUI/edit/src/creation/AddAction.js diff --git a/platform/commonUI/browse/src/creation/AddActionProvider.js b/platform/commonUI/edit/src/creation/AddActionProvider.js similarity index 100% rename from platform/commonUI/browse/src/creation/AddActionProvider.js rename to platform/commonUI/edit/src/creation/AddActionProvider.js diff --git a/platform/commonUI/browse/src/creation/CreateAction.js b/platform/commonUI/edit/src/creation/CreateAction.js similarity index 100% rename from platform/commonUI/browse/src/creation/CreateAction.js rename to platform/commonUI/edit/src/creation/CreateAction.js diff --git a/platform/commonUI/browse/src/creation/CreateActionProvider.js b/platform/commonUI/edit/src/creation/CreateActionProvider.js similarity index 100% rename from platform/commonUI/browse/src/creation/CreateActionProvider.js rename to platform/commonUI/edit/src/creation/CreateActionProvider.js diff --git a/platform/commonUI/browse/src/creation/CreateMenuController.js b/platform/commonUI/edit/src/creation/CreateMenuController.js similarity index 100% rename from platform/commonUI/browse/src/creation/CreateMenuController.js rename to platform/commonUI/edit/src/creation/CreateMenuController.js diff --git a/platform/commonUI/browse/src/creation/CreateWizard.js b/platform/commonUI/edit/src/creation/CreateWizard.js similarity index 100% rename from platform/commonUI/browse/src/creation/CreateWizard.js rename to platform/commonUI/edit/src/creation/CreateWizard.js diff --git a/platform/commonUI/browse/src/creation/CreationPolicy.js b/platform/commonUI/edit/src/creation/CreationPolicy.js similarity index 100% rename from platform/commonUI/browse/src/creation/CreationPolicy.js rename to platform/commonUI/edit/src/creation/CreationPolicy.js diff --git a/platform/commonUI/browse/src/creation/CreationService.js b/platform/commonUI/edit/src/creation/CreationService.js similarity index 100% rename from platform/commonUI/browse/src/creation/CreationService.js rename to platform/commonUI/edit/src/creation/CreationService.js diff --git a/platform/commonUI/browse/src/creation/LocatorController.js b/platform/commonUI/edit/src/creation/LocatorController.js similarity index 100% rename from platform/commonUI/browse/src/creation/LocatorController.js rename to platform/commonUI/edit/src/creation/LocatorController.js diff --git a/platform/commonUI/browse/test/creation/AddActionProviderSpec.js b/platform/commonUI/edit/test/creation/AddActionProviderSpec.js similarity index 100% rename from platform/commonUI/browse/test/creation/AddActionProviderSpec.js rename to platform/commonUI/edit/test/creation/AddActionProviderSpec.js diff --git a/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js b/platform/commonUI/edit/test/creation/CreateActionProviderSpec.js similarity index 100% rename from platform/commonUI/browse/test/creation/CreateActionProviderSpec.js rename to platform/commonUI/edit/test/creation/CreateActionProviderSpec.js diff --git a/platform/commonUI/browse/test/creation/CreateActionSpec.js b/platform/commonUI/edit/test/creation/CreateActionSpec.js similarity index 100% rename from platform/commonUI/browse/test/creation/CreateActionSpec.js rename to platform/commonUI/edit/test/creation/CreateActionSpec.js diff --git a/platform/commonUI/browse/test/creation/CreateMenuControllerSpec.js b/platform/commonUI/edit/test/creation/CreateMenuControllerSpec.js similarity index 100% rename from platform/commonUI/browse/test/creation/CreateMenuControllerSpec.js rename to platform/commonUI/edit/test/creation/CreateMenuControllerSpec.js diff --git a/platform/commonUI/browse/test/creation/CreateWizardSpec.js b/platform/commonUI/edit/test/creation/CreateWizardSpec.js similarity index 100% rename from platform/commonUI/browse/test/creation/CreateWizardSpec.js rename to platform/commonUI/edit/test/creation/CreateWizardSpec.js diff --git a/platform/commonUI/browse/test/creation/CreationPolicySpec.js b/platform/commonUI/edit/test/creation/CreationPolicySpec.js similarity index 100% rename from platform/commonUI/browse/test/creation/CreationPolicySpec.js rename to platform/commonUI/edit/test/creation/CreationPolicySpec.js diff --git a/platform/commonUI/browse/test/creation/CreationServiceSpec.js b/platform/commonUI/edit/test/creation/CreationServiceSpec.js similarity index 100% rename from platform/commonUI/browse/test/creation/CreationServiceSpec.js rename to platform/commonUI/edit/test/creation/CreationServiceSpec.js diff --git a/platform/commonUI/browse/test/creation/LocatorControllerSpec.js b/platform/commonUI/edit/test/creation/LocatorControllerSpec.js similarity index 100% rename from platform/commonUI/browse/test/creation/LocatorControllerSpec.js rename to platform/commonUI/edit/test/creation/LocatorControllerSpec.js From 2ff0c7b06ae1d3c7964d387979d259906d9e2522 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Wed, 25 May 2016 10:11:34 -0700 Subject: [PATCH 08/13] [Test] Add spy method for addClass Add spy method, fix a merge conflict that was improperly resolved in https://github.com/nasa/openmct/pull/922 --- .../commonUI/general/test/directives/MCTPopupSpec.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/commonUI/general/test/directives/MCTPopupSpec.js b/platform/commonUI/general/test/directives/MCTPopupSpec.js index 372dd4b042..fa26b6f6f7 100644 --- a/platform/commonUI/general/test/directives/MCTPopupSpec.js +++ b/platform/commonUI/general/test/directives/MCTPopupSpec.js @@ -24,7 +24,15 @@ define( ["../../src/directives/MCTPopup"], function (MCTPopup) { - var JQLITE_METHODS = ["on", "off", "find", "parent", "css", "append"]; + var JQLITE_METHODS = [ + "on", + "off", + "find", + "parent", + "css", + "addClass", + "append" + ]; describe("The mct-popup directive", function () { var mockCompile, From ed69a65f9b1c7c36947a4f6ba7a0127cae2e84c2 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 25 May 2016 11:03:32 -0700 Subject: [PATCH 09/13] [Representation] Restore ordering in mct-representation Revert "[Timeline] Change ordering in mct-representation" This reverts commit 20ecf168f238b9a4b2341508650f4b573bfd4f0b. These changes introduced a regression due to ordering expected by time conductor, #957 --- platform/representation/src/MCTRepresentation.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/representation/src/MCTRepresentation.js b/platform/representation/src/MCTRepresentation.js index 953ed7cf5a..331139b793 100644 --- a/platform/representation/src/MCTRepresentation.js +++ b/platform/representation/src/MCTRepresentation.js @@ -177,6 +177,10 @@ define( // representation to store local variables into. $scope.representation = {}; + // Change templates (passing in undefined to clear + // if we don't have enough info to show a template.) + changeTemplate(canRepresent ? representation : undefined); + // Any existing representers are no longer valid; release them. destroyRepresenters(); @@ -222,10 +226,6 @@ define( // next change object/key pair changes toClear = uses.concat(['model']); } - - // Change templates (passing in undefined to clear - // if we don't have enough info to show a template.) - changeTemplate(canRepresent ? representation : undefined); } // Update the representation when the key changes (e.g. if a From 70b593e28a4b3657cabf86a6d005f51d2d419817 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 25 May 2016 11:21:20 -0700 Subject: [PATCH 10/13] [Timeline] Watch for configuration object ...to address #908 in a manner which does not cause #957 --- .../src/controllers/TimelineController.js | 2 ++ .../swimlane/TimelineSwimlanePopulator.js | 21 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/platform/features/timeline/src/controllers/TimelineController.js b/platform/features/timeline/src/controllers/TimelineController.js index 796807c76a..64900b586c 100644 --- a/platform/features/timeline/src/controllers/TimelineController.js +++ b/platform/features/timeline/src/controllers/TimelineController.js @@ -97,6 +97,8 @@ define( } } + $scope.$watch("configuration", swimlanePopulator.configure); + // Recalculate swimlane state on changes $scope.$watch("domainObject", swimlanePopulator.populate); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js index ccc6148997..74c28b46b8 100644 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js +++ b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js @@ -43,8 +43,7 @@ define( var swimlanes = [], start = Number.POSITIVE_INFINITY, end = Number.NEGATIVE_INFINITY, - colors = (configuration.colors || {}), - assigner = new TimelineColorAssigner(colors), + assigner, lastDomainObject; // Track extremes of start/end times @@ -152,8 +151,15 @@ define( recalculateSwimlanes(lastDomainObject); } + function initialize() { + var colors = (configuration.colors || {}); + assigner = new TimelineColorAssigner(colors); + configuration.colors = colors; + recalculateSwimlanes(lastDomainObject); + } + // Ensure colors are exposed in configuration - configuration.colors = colors; + initialize(); return { /** @@ -188,6 +194,15 @@ define( */ end: function () { return end; + }, + /** + * Pass a new configuration object (to retrieve and store + * swimlane configuration) + * @param newConfig + */ + configure: function (newConfig) { + configuration = newConfig; + initialize(); } }; } From 0a75a5be1f1f086f572fcc4e970e784afa7dea10 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 25 May 2016 11:27:16 -0700 Subject: [PATCH 11/13] [Timeline] Add minimal test case --- .../timeline/test/controllers/TimelineControllerSpec.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/features/timeline/test/controllers/TimelineControllerSpec.js b/platform/features/timeline/test/controllers/TimelineControllerSpec.js index 9e777b0d8e..2b78829c3a 100644 --- a/platform/features/timeline/test/controllers/TimelineControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineControllerSpec.js @@ -141,6 +141,13 @@ define( expect(mockScope.scroll.y).toEqual(0); }); + it("watches for a configuration object", function () { + expect(mockScope.$watch).toHaveBeenCalledWith( + "configuration", + jasmine.any(Function) + ); + }); + it("repopulates when modifications are made", function () { var fnWatchCall, strWatchCall; From 952f95aa4c9b19fe0a081ab9e073a2087c3a3221 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 25 May 2016 11:33:51 -0700 Subject: [PATCH 12/13] [Timeline] Update failing specs --- .../controllers/TimelineControllerSpec.js | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/platform/features/timeline/test/controllers/TimelineControllerSpec.js b/platform/features/timeline/test/controllers/TimelineControllerSpec.js index 2b78829c3a..aa88866ebc 100644 --- a/platform/features/timeline/test/controllers/TimelineControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineControllerSpec.js @@ -68,6 +68,14 @@ define( }; } + function fireWatch(expr, value) { + mockScope.$watch.calls.forEach(function (call) { + if (call.args[0] === expr) { + call.args[1](value); + } + }); + } + beforeEach(function () { var mockA, mockB, mockUtilization, mockPromise, mockGraph, testCapabilities; @@ -149,8 +157,7 @@ define( }); it("repopulates when modifications are made", function () { - var fnWatchCall, - strWatchCall; + var fnWatchCall; // Find the $watch that was given a function mockScope.$watch.calls.forEach(function (call) { @@ -158,16 +165,11 @@ define( // white-box: we know the first call is // the one we're looking for fnWatchCall = fnWatchCall || call; - } else if (typeof call.args[0] === 'string') { - strWatchCall = strWatchCall || call; } }); // Make sure string watch was for domainObject - expect(strWatchCall.args[0]).toEqual('domainObject'); - // Initially populate - strWatchCall.args[1](mockDomainObject); - + fireWatch('domainObject', mockDomainObject); // There should be to swimlanes expect(controller.swimlanes().length).toEqual(2); @@ -189,23 +191,23 @@ define( // order of $watch calls in TimelineController. // Initially populate - mockScope.$watch.calls[0].args[1](mockDomainObject); + fireWatch('domainObject', mockDomainObject); // Verify precondition - no graphs expect(controller.graphs().length).toEqual(0); // Execute the watch function for graph state - tmp = mockScope.$watch.calls[2].args[0](); + tmp = mockScope.$watch.calls[3].args[0](); // Change graph state testConfiguration.graph = { a: true, b: true }; // Verify that this would have triggered a watch - expect(mockScope.$watch.calls[2].args[0]()) + expect(mockScope.$watch.calls[3].args[0]()) .not.toEqual(tmp); // Run the function the watch would have triggered - mockScope.$watch.calls[2].args[1](); + mockScope.$watch.calls[3].args[1](); // Should have some graphs now expect(controller.graphs().length).toEqual(2); @@ -218,7 +220,7 @@ define( mockZoom.duration.andReturn(12345); // Initially populate - mockScope.$watch.calls[0].args[1](mockDomainObject); + fireWatch('domainObject', mockDomainObject); expect(controller.width(mockZoom)).toEqual(54321); // Verify interactions; we took zoom's duration for our start/end, From 3935378b0c1f832bde5e64359443fa500a95dd67 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 25 May 2016 11:34:29 -0700 Subject: [PATCH 13/13] Revert "[Timeline] Test mct-representation ordering" This reverts commit 2a4004fd5bcddc8249c8911606d14dad8303d14b. --- .../representation/test/MCTRepresentationSpec.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/platform/representation/test/MCTRepresentationSpec.js b/platform/representation/test/MCTRepresentationSpec.js index 98da386c91..025ab0f14d 100644 --- a/platform/representation/test/MCTRepresentationSpec.js +++ b/platform/representation/test/MCTRepresentationSpec.js @@ -194,21 +194,6 @@ define( .toHaveBeenCalledWith(testViews[1]); }); - it("exposes configuration before changing templates", function () { - var observedConfiguration; - - mockChangeTemplate.andCallFake(function () { - observedConfiguration = mockScope.configuration; - }); - - mockScope.key = "xyz"; - mockScope.domainObject = mockDomainObject; - fireWatch('key', mockScope.key); - fireWatch('domainObject', mockDomainObject); - - expect(observedConfiguration).toBeDefined(); - }); - it("does not load templates until there is an object", function () { mockScope.key = "xyz";