Merge branch 'master' into csv-export-update-751
This commit is contained in:
@@ -17,6 +17,7 @@ deployment:
|
|||||||
test:
|
test:
|
||||||
post:
|
post:
|
||||||
- gulp lint
|
- gulp lint
|
||||||
|
- gulp checkstyle
|
||||||
|
|
||||||
general:
|
general:
|
||||||
branches:
|
branches:
|
||||||
|
|||||||
@@ -24,23 +24,14 @@ define([
|
|||||||
"./src/BrowseController",
|
"./src/BrowseController",
|
||||||
"./src/PaneController",
|
"./src/PaneController",
|
||||||
"./src/BrowseObjectController",
|
"./src/BrowseObjectController",
|
||||||
"./src/creation/CreateMenuController",
|
|
||||||
"./src/creation/LocatorController",
|
|
||||||
"./src/MenuArrowController",
|
"./src/MenuArrowController",
|
||||||
"./src/navigation/NavigationService",
|
"./src/navigation/NavigationService",
|
||||||
"./src/creation/CreationPolicy",
|
|
||||||
"./src/navigation/NavigateAction",
|
"./src/navigation/NavigateAction",
|
||||||
"./src/windowing/NewTabAction",
|
"./src/windowing/NewTabAction",
|
||||||
"./src/windowing/FullscreenAction",
|
"./src/windowing/FullscreenAction",
|
||||||
"./src/creation/CreateActionProvider",
|
|
||||||
"./src/creation/AddActionProvider",
|
|
||||||
"./src/creation/CreationService",
|
|
||||||
"./src/windowing/WindowTitler",
|
"./src/windowing/WindowTitler",
|
||||||
"text!./res/templates/browse.html",
|
"text!./res/templates/browse.html",
|
||||||
"text!./res/templates/create/locator.html",
|
|
||||||
"text!./res/templates/browse-object.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/items/grid-item.html",
|
||||||
"text!./res/templates/browse/object-header.html",
|
"text!./res/templates/browse/object-header.html",
|
||||||
"text!./res/templates/menu-arrow.html",
|
"text!./res/templates/menu-arrow.html",
|
||||||
@@ -53,23 +44,14 @@ define([
|
|||||||
BrowseController,
|
BrowseController,
|
||||||
PaneController,
|
PaneController,
|
||||||
BrowseObjectController,
|
BrowseObjectController,
|
||||||
CreateMenuController,
|
|
||||||
LocatorController,
|
|
||||||
MenuArrowController,
|
MenuArrowController,
|
||||||
NavigationService,
|
NavigationService,
|
||||||
CreationPolicy,
|
|
||||||
NavigateAction,
|
NavigateAction,
|
||||||
NewTabAction,
|
NewTabAction,
|
||||||
FullscreenAction,
|
FullscreenAction,
|
||||||
CreateActionProvider,
|
|
||||||
AddActionProvider,
|
|
||||||
CreationService,
|
|
||||||
WindowTitler,
|
WindowTitler,
|
||||||
browseTemplate,
|
browseTemplate,
|
||||||
locatorTemplate,
|
|
||||||
browseObjectTemplate,
|
browseObjectTemplate,
|
||||||
createButtonTemplate,
|
|
||||||
createMenuTemplate,
|
|
||||||
gridItemTemplate,
|
gridItemTemplate,
|
||||||
objectHeaderTemplate,
|
objectHeaderTemplate,
|
||||||
menuArrowTemplate,
|
menuArrowTemplate,
|
||||||
@@ -136,22 +118,6 @@ define([
|
|||||||
"$route"
|
"$route"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"key": "CreateMenuController",
|
|
||||||
"implementation": CreateMenuController,
|
|
||||||
"depends": [
|
|
||||||
"$scope"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "LocatorController",
|
|
||||||
"implementation": LocatorController,
|
|
||||||
"depends": [
|
|
||||||
"$scope",
|
|
||||||
"$timeout",
|
|
||||||
"objectService"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"key": "MenuArrowController",
|
"key": "MenuArrowController",
|
||||||
"implementation": MenuArrowController,
|
"implementation": MenuArrowController,
|
||||||
@@ -160,12 +126,6 @@ define([
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"controls": [
|
|
||||||
{
|
|
||||||
"key": "locator",
|
|
||||||
"template": locatorTemplate
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"representations": [
|
"representations": [
|
||||||
{
|
{
|
||||||
"key": "view-object",
|
"key": "view-object",
|
||||||
@@ -181,17 +141,6 @@ define([
|
|||||||
"view"
|
"view"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"key": "create-button",
|
|
||||||
"template": createButtonTemplate
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "create-menu",
|
|
||||||
"template": createMenuTemplate,
|
|
||||||
"uses": [
|
|
||||||
"action"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"key": "grid-item",
|
"key": "grid-item",
|
||||||
"template": gridItemTemplate,
|
"template": gridItemTemplate,
|
||||||
@@ -244,12 +193,6 @@ define([
|
|||||||
"implementation": NavigationService
|
"implementation": NavigationService
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"policies": [
|
|
||||||
{
|
|
||||||
"implementation": CreationPolicy,
|
|
||||||
"category": "creation"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"key": "navigate",
|
"key": "navigate",
|
||||||
@@ -302,42 +245,6 @@ define([
|
|||||||
"editable": false
|
"editable": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"key": "CreateActionProvider",
|
|
||||||
"provides": "actionService",
|
|
||||||
"type": "provider",
|
|
||||||
"implementation": CreateActionProvider,
|
|
||||||
"depends": [
|
|
||||||
"$q",
|
|
||||||
"typeService",
|
|
||||||
"navigationService",
|
|
||||||
"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": [
|
"runs": [
|
||||||
{
|
{
|
||||||
"implementation": WindowTitler,
|
"implementation": WindowTitler,
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
/*****************************************************************************
|
|
||||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
|
||||||
* as represented by the Administrator of the National Aeronautics and Space
|
|
||||||
* Administration. All rights reserved.
|
|
||||||
*
|
|
||||||
* Open MCT Web 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 Web 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.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
|
|
||||||
*/
|
|
||||||
define(
|
|
||||||
["../../src/creation/CreateAction"],
|
|
||||||
function (CreateAction) {
|
|
||||||
|
|
||||||
describe("The create action", function () {
|
|
||||||
var mockType,
|
|
||||||
mockParent,
|
|
||||||
mockContext,
|
|
||||||
mockDialogService,
|
|
||||||
mockCreationService,
|
|
||||||
action;
|
|
||||||
|
|
||||||
function mockPromise(value) {
|
|
||||||
return {
|
|
||||||
then: function (callback) {
|
|
||||||
return mockPromise(callback(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
mockType = jasmine.createSpyObj(
|
|
||||||
"type",
|
|
||||||
[
|
|
||||||
"getKey",
|
|
||||||
"getGlyph",
|
|
||||||
"getName",
|
|
||||||
"getDescription",
|
|
||||||
"getProperties",
|
|
||||||
"getInitialModel"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
mockParent = jasmine.createSpyObj(
|
|
||||||
"domainObject",
|
|
||||||
[
|
|
||||||
"getId",
|
|
||||||
"getModel",
|
|
||||||
"getCapability"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
mockContext = {
|
|
||||||
domainObject: mockParent
|
|
||||||
};
|
|
||||||
mockDialogService = jasmine.createSpyObj(
|
|
||||||
"dialogService",
|
|
||||||
["getUserInput"]
|
|
||||||
);
|
|
||||||
mockCreationService = jasmine.createSpyObj(
|
|
||||||
"creationService",
|
|
||||||
["createObject"]
|
|
||||||
);
|
|
||||||
|
|
||||||
mockType.getKey.andReturn("test");
|
|
||||||
mockType.getGlyph.andReturn("T");
|
|
||||||
mockType.getDescription.andReturn("a test type");
|
|
||||||
mockType.getName.andReturn("Test");
|
|
||||||
mockType.getProperties.andReturn([]);
|
|
||||||
mockType.getInitialModel.andReturn({});
|
|
||||||
|
|
||||||
mockDialogService.getUserInput.andReturn(mockPromise({}));
|
|
||||||
|
|
||||||
action = new CreateAction(
|
|
||||||
mockType,
|
|
||||||
mockParent,
|
|
||||||
mockContext,
|
|
||||||
mockDialogService,
|
|
||||||
mockCreationService
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("exposes type-appropriate metadata", function () {
|
|
||||||
var metadata = action.getMetadata();
|
|
||||||
|
|
||||||
expect(metadata.name).toEqual("Test");
|
|
||||||
expect(metadata.description).toEqual("a test type");
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
action.perform();
|
|
||||||
|
|
||||||
expect(mockCreationService.createObject)
|
|
||||||
.not.toHaveBeenCalled();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@@ -43,6 +43,15 @@ define([
|
|||||||
"./src/capabilities/EditorCapability",
|
"./src/capabilities/EditorCapability",
|
||||||
"./src/capabilities/TransactionCapabilityDecorator",
|
"./src/capabilities/TransactionCapabilityDecorator",
|
||||||
"./src/services/TransactionService",
|
"./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/library.html",
|
||||||
"text!./res/templates/edit-object.html",
|
"text!./res/templates/edit-object.html",
|
||||||
"text!./res/templates/edit-action-buttons.html",
|
"text!./res/templates/edit-action-buttons.html",
|
||||||
@@ -72,6 +81,15 @@ define([
|
|||||||
EditorCapability,
|
EditorCapability,
|
||||||
TransactionCapabilityDecorator,
|
TransactionCapabilityDecorator,
|
||||||
TransactionService,
|
TransactionService,
|
||||||
|
CreateMenuController,
|
||||||
|
LocatorController,
|
||||||
|
CreationPolicy,
|
||||||
|
CreateActionProvider,
|
||||||
|
AddActionProvider,
|
||||||
|
CreationService,
|
||||||
|
locatorTemplate,
|
||||||
|
createButtonTemplate,
|
||||||
|
createMenuTemplate,
|
||||||
libraryTemplate,
|
libraryTemplate,
|
||||||
editObjectTemplate,
|
editObjectTemplate,
|
||||||
editActionButtonsTemplate,
|
editActionButtonsTemplate,
|
||||||
@@ -112,7 +130,23 @@ define([
|
|||||||
"$location",
|
"$location",
|
||||||
"policyService"
|
"policyService"
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"key": "CreateMenuController",
|
||||||
|
"implementation": CreateMenuController,
|
||||||
|
"depends": [
|
||||||
|
"$scope"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "LocatorController",
|
||||||
|
"implementation": LocatorController,
|
||||||
|
"depends": [
|
||||||
|
"$scope",
|
||||||
|
"$timeout",
|
||||||
|
"objectService"
|
||||||
|
]
|
||||||
|
},
|
||||||
],
|
],
|
||||||
"directives": [
|
"directives": [
|
||||||
{
|
{
|
||||||
@@ -221,8 +255,11 @@ define([
|
|||||||
"category": "navigation",
|
"category": "navigation",
|
||||||
"message": "There are unsaved changes.",
|
"message": "There are unsaved changes.",
|
||||||
"implementation": EditNavigationPolicy
|
"implementation": EditNavigationPolicy
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"implementation": CreationPolicy,
|
||||||
|
"category": "creation"
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
"templates": [
|
"templates": [
|
||||||
{
|
{
|
||||||
@@ -261,7 +298,18 @@ define([
|
|||||||
{
|
{
|
||||||
"key": "topbar-edit",
|
"key": "topbar-edit",
|
||||||
"template": topbarEditTemplate
|
"template": topbarEditTemplate
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"key": "create-button",
|
||||||
|
"template": createButtonTemplate
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "create-menu",
|
||||||
|
"template": createMenuTemplate,
|
||||||
|
"uses": [
|
||||||
|
"action"
|
||||||
|
]
|
||||||
|
},
|
||||||
],
|
],
|
||||||
"components": [
|
"components": [
|
||||||
{
|
{
|
||||||
@@ -282,7 +330,40 @@ define([
|
|||||||
"$q",
|
"$q",
|
||||||
"$log"
|
"$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": [
|
"representers": [
|
||||||
{
|
{
|
||||||
@@ -316,6 +397,12 @@ define([
|
|||||||
"transactionService"
|
"transactionService"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"controls": [
|
||||||
|
{
|
||||||
|
"key": "locator",
|
||||||
|
"template": locatorTemplate
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,6 +74,12 @@ define(
|
|||||||
self.domainObject.getCapability('editor').cancel();
|
self.domainObject.getCapability('editor').cancel();
|
||||||
self.navigationService.removeListener(cancelEditing);
|
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.navigationService.addListener(cancelEditing);
|
||||||
this.domainObject.useCapability("editor");
|
this.domainObject.useCapability("editor");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['../../../browse/src/creation/CreateWizard'],
|
['../creation/CreateWizard'],
|
||||||
function (CreateWizard) {
|
function (CreateWizard) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,11 +43,8 @@ define(
|
|||||||
* override this)
|
* override this)
|
||||||
* @param {ActionContext} context the context in which the
|
* @param {ActionContext} context the context in which the
|
||||||
* action is being performed
|
* 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 = {
|
this.metadata = {
|
||||||
key: 'create',
|
key: 'create',
|
||||||
glyph: type.getGlyph(),
|
glyph: type.getGlyph(),
|
||||||
@@ -56,24 +53,8 @@ define(
|
|||||||
description: type.getDescription(),
|
description: type.getDescription(),
|
||||||
context: context
|
context: context
|
||||||
};
|
};
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.parent = parent;
|
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,26 +63,31 @@ define(
|
|||||||
*/
|
*/
|
||||||
CreateAction.prototype.perform = function () {
|
CreateAction.prototype.perform = function () {
|
||||||
var newModel = this.type.getInitialModel(),
|
var newModel = this.type.getInitialModel(),
|
||||||
parentObject = this.navigationService.getNavigation(),
|
newObject,
|
||||||
editorCapability,
|
editAction,
|
||||||
newObject;
|
editorCapability;
|
||||||
|
|
||||||
|
function onSave() {
|
||||||
|
return editorCapability.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCancel() {
|
||||||
|
return editorCapability.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
newModel.type = this.type.getKey();
|
newModel.type = this.type.getKey();
|
||||||
newModel.location = parentObject.getId();
|
newModel.location = this.parent.getId();
|
||||||
newObject = parentObject.useCapability('instantiation', newModel);
|
newObject = this.parent.useCapability('instantiation', newModel);
|
||||||
|
editorCapability = newObject.hasCapability('editor') && newObject.getCapability("editor");
|
||||||
|
|
||||||
editorCapability = newObject.getCapability("editor");
|
editAction = newObject.getCapability("action").getActions("edit")[0];
|
||||||
|
//If an edit action is available, perform it
|
||||||
if (countEditableViews(newObject) > 0 && newObject.hasCapability('composition')) {
|
if (editAction) {
|
||||||
this.navigationService.setNavigation(newObject);
|
return editAction.perform();
|
||||||
return newObject.getCapability("action").perform("edit");
|
} else if (editorCapability) {
|
||||||
} else {
|
//otherwise, use the save action
|
||||||
editorCapability.edit();
|
editorCapability.edit();
|
||||||
return newObject.useCapability("action").perform("save").then(function () {
|
return newObject.getCapability("action").perform("save").then(onSave, onCancel);
|
||||||
return editorCapability.save();
|
|
||||||
}, function () {
|
|
||||||
return editorCapability.cancel();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,10 +44,8 @@ define(
|
|||||||
* introduced in this bundle), responsible for handling actual
|
* introduced in this bundle), responsible for handling actual
|
||||||
* object creation.
|
* object creation.
|
||||||
*/
|
*/
|
||||||
function CreateActionProvider($q, typeService, navigationService, policyService) {
|
function CreateActionProvider(typeService, policyService) {
|
||||||
this.typeService = typeService;
|
this.typeService = typeService;
|
||||||
this.navigationService = navigationService;
|
|
||||||
this.$q = $q;
|
|
||||||
this.policyService = policyService;
|
this.policyService = policyService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +70,7 @@ define(
|
|||||||
return new CreateAction(
|
return new CreateAction(
|
||||||
type,
|
type,
|
||||||
destination,
|
destination,
|
||||||
context,
|
context
|
||||||
self.$q,
|
|
||||||
self.navigationService
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -56,7 +56,10 @@ define(
|
|||||||
// A view is editable unless explicitly flagged as not
|
// A view is editable unless explicitly flagged as not
|
||||||
(views || []).forEach(function (view) {
|
(views || []).forEach(function (view) {
|
||||||
if (view.editable === true ||
|
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++;
|
count++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,13 +29,10 @@ define(
|
|||||||
|
|
||||||
describe("The create action provider", function () {
|
describe("The create action provider", function () {
|
||||||
var mockTypeService,
|
var mockTypeService,
|
||||||
mockDialogService,
|
|
||||||
mockNavigationService,
|
|
||||||
mockPolicyService,
|
mockPolicyService,
|
||||||
mockCreationPolicy,
|
mockCreationPolicy,
|
||||||
mockPolicyMap = {},
|
mockPolicyMap = {},
|
||||||
mockTypes,
|
mockTypes,
|
||||||
mockQ,
|
|
||||||
provider;
|
provider;
|
||||||
|
|
||||||
function createMockType(name) {
|
function createMockType(name) {
|
||||||
@@ -61,14 +58,6 @@ define(
|
|||||||
"typeService",
|
"typeService",
|
||||||
["listTypes"]
|
["listTypes"]
|
||||||
);
|
);
|
||||||
mockDialogService = jasmine.createSpyObj(
|
|
||||||
"dialogService",
|
|
||||||
["getUserInput"]
|
|
||||||
);
|
|
||||||
mockNavigationService = jasmine.createSpyObj(
|
|
||||||
"navigationService",
|
|
||||||
["setNavigation"]
|
|
||||||
);
|
|
||||||
mockPolicyService = jasmine.createSpyObj(
|
mockPolicyService = jasmine.createSpyObj(
|
||||||
"policyService",
|
"policyService",
|
||||||
["allow"]
|
["allow"]
|
||||||
@@ -91,9 +80,7 @@ define(
|
|||||||
mockTypeService.listTypes.andReturn(mockTypes);
|
mockTypeService.listTypes.andReturn(mockTypes);
|
||||||
|
|
||||||
provider = new CreateActionProvider(
|
provider = new CreateActionProvider(
|
||||||
mockQ,
|
|
||||||
mockTypeService,
|
mockTypeService,
|
||||||
mockNavigationService,
|
|
||||||
mockPolicyService
|
mockPolicyService
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
190
platform/commonUI/edit/test/creation/CreateActionSpec.js
Normal file
190
platform/commonUI/edit/test/creation/CreateActionSpec.js
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web 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 Web 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
["../../src/creation/CreateAction"],
|
||||||
|
function (CreateAction) {
|
||||||
|
|
||||||
|
describe("The create action", function () {
|
||||||
|
var mockType,
|
||||||
|
mockParent,
|
||||||
|
mockContext,
|
||||||
|
mockDomainObject,
|
||||||
|
capabilities = {},
|
||||||
|
mockEditAction,
|
||||||
|
mockSaveAction,
|
||||||
|
action;
|
||||||
|
|
||||||
|
function mockPromise(value) {
|
||||||
|
return {
|
||||||
|
then: function (callback) {
|
||||||
|
return mockPromise(callback(value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockType = jasmine.createSpyObj(
|
||||||
|
"type",
|
||||||
|
[
|
||||||
|
"getKey",
|
||||||
|
"getGlyph",
|
||||||
|
"getName",
|
||||||
|
"getDescription",
|
||||||
|
"getProperties",
|
||||||
|
"getInitialModel"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
mockParent = jasmine.createSpyObj(
|
||||||
|
"domainObject",
|
||||||
|
[
|
||||||
|
"getId",
|
||||||
|
"getModel",
|
||||||
|
"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
|
||||||
|
};
|
||||||
|
mockParent.useCapability.andReturn(mockDomainObject);
|
||||||
|
|
||||||
|
mockType.getKey.andReturn("test");
|
||||||
|
mockType.getGlyph.andReturn("T");
|
||||||
|
mockType.getDescription.andReturn("a test type");
|
||||||
|
mockType.getName.andReturn("Test");
|
||||||
|
mockType.getProperties.andReturn([]);
|
||||||
|
mockType.getInitialModel.andReturn({});
|
||||||
|
|
||||||
|
action = new CreateAction(
|
||||||
|
mockType,
|
||||||
|
mockParent,
|
||||||
|
mockContext
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("exposes type-appropriate metadata", function () {
|
||||||
|
var metadata = action.getMetadata();
|
||||||
|
|
||||||
|
expect(metadata.name).toEqual("Test");
|
||||||
|
expect(metadata.description).toEqual("a test type");
|
||||||
|
expect(metadata.glyph).toEqual("T");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("the perform function", function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
capabilities.action.getActions.andReturn([mockEditAction]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses the instantiation capability when performed", function () {
|
||||||
|
action.perform();
|
||||||
|
expect(mockParent.useCapability).toHaveBeenCalledWith("instantiation", jasmine.any(Object));
|
||||||
|
});
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -24,7 +24,15 @@ define(
|
|||||||
["../../src/directives/MCTPopup"],
|
["../../src/directives/MCTPopup"],
|
||||||
function (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 () {
|
describe("The mct-popup directive", function () {
|
||||||
var mockCompile,
|
var mockCompile,
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ define([
|
|||||||
"telemetry"
|
"telemetry"
|
||||||
],
|
],
|
||||||
"delegation": true,
|
"delegation": true,
|
||||||
"editable": true
|
"editable": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Real-time Table",
|
"name": "Real-time Table",
|
||||||
@@ -144,7 +144,7 @@ define([
|
|||||||
"telemetry"
|
"telemetry"
|
||||||
],
|
],
|
||||||
"delegation": true,
|
"delegation": true,
|
||||||
"editable": true
|
"editable": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"directives": [
|
"directives": [
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.$watch("configuration", swimlanePopulator.configure);
|
||||||
|
|
||||||
// Recalculate swimlane state on changes
|
// Recalculate swimlane state on changes
|
||||||
$scope.$watch("domainObject", swimlanePopulator.populate);
|
$scope.$watch("domainObject", swimlanePopulator.populate);
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ define(
|
|||||||
var swimlanes = [],
|
var swimlanes = [],
|
||||||
start = Number.POSITIVE_INFINITY,
|
start = Number.POSITIVE_INFINITY,
|
||||||
end = Number.NEGATIVE_INFINITY,
|
end = Number.NEGATIVE_INFINITY,
|
||||||
colors = (configuration.colors || {}),
|
assigner,
|
||||||
assigner = new TimelineColorAssigner(colors),
|
|
||||||
lastDomainObject;
|
lastDomainObject;
|
||||||
|
|
||||||
// Track extremes of start/end times
|
// Track extremes of start/end times
|
||||||
@@ -152,8 +151,15 @@ define(
|
|||||||
recalculateSwimlanes(lastDomainObject);
|
recalculateSwimlanes(lastDomainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
var colors = (configuration.colors || {});
|
||||||
|
assigner = new TimelineColorAssigner(colors);
|
||||||
|
configuration.colors = colors;
|
||||||
|
recalculateSwimlanes(lastDomainObject);
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure colors are exposed in configuration
|
// Ensure colors are exposed in configuration
|
||||||
configuration.colors = colors;
|
initialize();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
@@ -188,6 +194,15 @@ define(
|
|||||||
*/
|
*/
|
||||||
end: function () {
|
end: function () {
|
||||||
return end;
|
return end;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Pass a new configuration object (to retrieve and store
|
||||||
|
* swimlane configuration)
|
||||||
|
* @param newConfig
|
||||||
|
*/
|
||||||
|
configure: function (newConfig) {
|
||||||
|
configuration = newConfig;
|
||||||
|
initialize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 () {
|
beforeEach(function () {
|
||||||
var mockA, mockB, mockUtilization, mockPromise, mockGraph, testCapabilities;
|
var mockA, mockB, mockUtilization, mockPromise, mockGraph, testCapabilities;
|
||||||
@@ -141,9 +149,15 @@ define(
|
|||||||
expect(mockScope.scroll.y).toEqual(0);
|
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 () {
|
it("repopulates when modifications are made", function () {
|
||||||
var fnWatchCall,
|
var fnWatchCall;
|
||||||
strWatchCall;
|
|
||||||
|
|
||||||
// Find the $watch that was given a function
|
// Find the $watch that was given a function
|
||||||
mockScope.$watch.calls.forEach(function (call) {
|
mockScope.$watch.calls.forEach(function (call) {
|
||||||
@@ -151,16 +165,11 @@ define(
|
|||||||
// white-box: we know the first call is
|
// white-box: we know the first call is
|
||||||
// the one we're looking for
|
// the one we're looking for
|
||||||
fnWatchCall = fnWatchCall || call;
|
fnWatchCall = fnWatchCall || call;
|
||||||
} else if (typeof call.args[0] === 'string') {
|
|
||||||
strWatchCall = strWatchCall || call;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make sure string watch was for domainObject
|
// Make sure string watch was for domainObject
|
||||||
expect(strWatchCall.args[0]).toEqual('domainObject');
|
fireWatch('domainObject', mockDomainObject);
|
||||||
// Initially populate
|
|
||||||
strWatchCall.args[1](mockDomainObject);
|
|
||||||
|
|
||||||
// There should be to swimlanes
|
// There should be to swimlanes
|
||||||
expect(controller.swimlanes().length).toEqual(2);
|
expect(controller.swimlanes().length).toEqual(2);
|
||||||
|
|
||||||
@@ -182,23 +191,23 @@ define(
|
|||||||
// order of $watch calls in TimelineController.
|
// order of $watch calls in TimelineController.
|
||||||
|
|
||||||
// Initially populate
|
// Initially populate
|
||||||
mockScope.$watch.calls[0].args[1](mockDomainObject);
|
fireWatch('domainObject', mockDomainObject);
|
||||||
|
|
||||||
// Verify precondition - no graphs
|
// Verify precondition - no graphs
|
||||||
expect(controller.graphs().length).toEqual(0);
|
expect(controller.graphs().length).toEqual(0);
|
||||||
|
|
||||||
// Execute the watch function for graph state
|
// Execute the watch function for graph state
|
||||||
tmp = mockScope.$watch.calls[2].args[0]();
|
tmp = mockScope.$watch.calls[3].args[0]();
|
||||||
|
|
||||||
// Change graph state
|
// Change graph state
|
||||||
testConfiguration.graph = { a: true, b: true };
|
testConfiguration.graph = { a: true, b: true };
|
||||||
|
|
||||||
// Verify that this would have triggered a watch
|
// 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);
|
.not.toEqual(tmp);
|
||||||
|
|
||||||
// Run the function the watch would have triggered
|
// 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
|
// Should have some graphs now
|
||||||
expect(controller.graphs().length).toEqual(2);
|
expect(controller.graphs().length).toEqual(2);
|
||||||
@@ -211,7 +220,7 @@ define(
|
|||||||
mockZoom.duration.andReturn(12345);
|
mockZoom.duration.andReturn(12345);
|
||||||
|
|
||||||
// Initially populate
|
// Initially populate
|
||||||
mockScope.$watch.calls[0].args[1](mockDomainObject);
|
fireWatch('domainObject', mockDomainObject);
|
||||||
|
|
||||||
expect(controller.width(mockZoom)).toEqual(54321);
|
expect(controller.width(mockZoom)).toEqual(54321);
|
||||||
// Verify interactions; we took zoom's duration for our start/end,
|
// Verify interactions; we took zoom's duration for our start/end,
|
||||||
|
|||||||
@@ -177,6 +177,10 @@ define(
|
|||||||
// representation to store local variables into.
|
// representation to store local variables into.
|
||||||
$scope.representation = {};
|
$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.
|
// Any existing representers are no longer valid; release them.
|
||||||
destroyRepresenters();
|
destroyRepresenters();
|
||||||
|
|
||||||
@@ -222,10 +226,6 @@ define(
|
|||||||
// next change object/key pair changes
|
// next change object/key pair changes
|
||||||
toClear = uses.concat(['model']);
|
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
|
// Update the representation when the key changes (e.g. if a
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ define(
|
|||||||
// Find the relevant scope...
|
// Find the relevant scope...
|
||||||
var rect,
|
var rect,
|
||||||
scope = element.scope && element.scope();
|
scope = element.scope && element.scope();
|
||||||
|
|
||||||
if (scope && scope.$broadcast) {
|
if (scope && scope.$broadcast) {
|
||||||
// Get the representation's bounds, to convert
|
// Get the representation's bounds, to convert
|
||||||
// drop position
|
// drop position
|
||||||
|
|||||||
@@ -194,21 +194,6 @@ define(
|
|||||||
.toHaveBeenCalledWith(testViews[1]);
|
.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 () {
|
it("does not load templates until there is an object", function () {
|
||||||
mockScope.key = "xyz";
|
mockScope.key = "xyz";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user