Merge branch 'open-master' into open1170b

Conflicts:
	platform/commonUI/general/res/sass/plots.scss
	platform/commonUI/inspect/src/InfoConstants.js
	platform/features/imagery/src/policies/ImageryViewPolicy.js
	platform/features/static-markup/res/markup.html
This commit is contained in:
Charles Hacskaylo 2015-06-18 09:55:26 -07:00
commit 69f4b4975e
56 changed files with 3393 additions and 420 deletions

View File

@ -7,6 +7,7 @@
"platform/commonUI/edit",
"platform/commonUI/dialog",
"platform/commonUI/general",
"platform/commonUI/inspect",
"platform/containment",
"platform/telemetry",
"platform/features/imagery",

View File

@ -57,7 +57,8 @@
{
"key": "grid-item",
"templateUrl": "templates/items/grid-item.html",
"uses": [ "type", "action" ]
"uses": [ "type", "action" ],
"gestures": [ "info", "menu" ]
},
{
"key": "object-header",

View File

@ -21,14 +21,12 @@
-->
<span>
<div class="object-browse-bar bar abs">
<div class="items-select left abs">
<mct-representation key="'object-header'" mct-object="domainObject">
</mct-representation>
</div>
<div class="view-controls sort-controls btn-bar right abs">
<div class="btn-bar right abs">
<mct-representation key="'action-group'"
mct-object="domainObject"
parameters="{ category: 'view-control' }">
@ -39,7 +37,6 @@
ng-model="representation">
</mct-representation>
</div>
</div>
<div class='object-holder abs vscroll'>

View File

@ -20,9 +20,11 @@
at runtime from the About dialog for additional information.
-->
<div class='object-header'>
<span class='type-icon icon ui-symbol'>{{type.getGlyph()}}</span>
<span ng-if="parameters.mode" class='action'>{{parameters.mode}}</span>
<span class='type'>{{type.getName()}}</span>
<span class='title'>{{model.name}}</span>
<a id='actions-menu' class='ui-symbol invoke-menu' onclick="alert('Not yet functional. This will display a dropdown menu of options for this object.');">v</a>
<span class="label s-label">
<span class='type-icon icon ui-symbol'>{{type.getGlyph()}}</span>
<span ng-if="parameters.mode" class='action'>{{parameters.mode}}</span>
<span class='type-name'>{{type.getName()}}</span>
<span class='title-label'>{{model.name}}</span>
<!--a id='actions-menu' class='ui-symbol context-available' onclick="alert('Not yet functional. This will display a dropdown menu of options for this object.');">v</a-->
</span>
</div>

View File

@ -21,7 +21,7 @@
-->
<div class="menu-element wrapper" ng-controller="ClickAwayController as createController">
<div class="btn btn-menu create-btn major" ng-click="createController.toggle()">
<span class='ui-symbol major' href=''>+</span> Create<!--span class='ui-symbol invoke-menu'>v</span-->
<span class='ui-symbol' href=''>+</span> Create
</div>
<div class="menu dropdown super-menu" ng-show="createController.isActive()">
<mct-representation mct-object="domainObject" key="'create-menu'">

View File

@ -77,7 +77,19 @@ define(
return undefined;
}
return parentPersistence.persist();
return parentPersistence.persist().then(function () {
// Locate and return new Object in context of parent.
return parent
.useCapability('composition')
.then(function (children) {
var i;
for (i = 0; i < children.length; i += 1) {
if (children[i].getId() === id) {
return children[i];
}
}
});
});
});
}
@ -126,4 +138,4 @@ define(
return CreationService;
}
);
);

View File

@ -34,8 +34,10 @@ define(
mockQ,
mockLog,
mockParentObject,
mockNewObject,
mockMutationCapability,
mockPersistenceCapability,
mockCompositionCapability,
mockCapabilities,
creationService;
@ -69,6 +71,10 @@ define(
"parentObject",
[ "getId", "getCapability", "useCapability" ]
);
mockNewObject = jasmine.createSpyObj(
"newObject",
[ "getId" ]
);
mockMutationCapability = jasmine.createSpyObj(
"mutation",
[ "invoke" ]
@ -77,9 +83,14 @@ define(
"persistence",
[ "persist", "getSpace" ]
);
mockCompositionCapability = jasmine.createSpyObj(
"composition",
["invoke"]
);
mockCapabilities = {
mutation: mockMutationCapability,
persistence: mockPersistenceCapability
persistence: mockPersistenceCapability,
composition: mockCompositionCapability
};
mockPersistenceService.createObject.andReturn(
@ -93,8 +104,15 @@ define(
return mockCapabilities[key].invoke(value);
});
mockPersistenceCapability.persist.andReturn(
mockPromise(true)
);
mockMutationCapability.invoke.andReturn(mockPromise(true));
mockPersistenceCapability.getSpace.andReturn("testSpace");
mockCompositionCapability.invoke.andReturn(
mockPromise([mockNewObject])
);
creationService = new CreationService(
mockPersistenceService,

View File

@ -25,7 +25,7 @@
<a href=""
ng-click="ngModel.cancel()"
ng-if="ngModel.cancel"
class="btn normal outline ui-symbol close">
class="btn normal ui-symbol close">
x
</a>
<div class="abs contents" ng-transclude>

View File

@ -33,8 +33,6 @@
<mct-representation key="'edit-action-buttons'"
mct-object="domainObject"
class='conclude-editing'>
<!--a class='btn major' href=''>Save<span id='save-actions-menu' class='ui-symbol invoke-menu'>v</span></a>
<a class='btn subtle' href=''>Cancel</a-->
</mct-representation>
</div>
</div>

View File

@ -181,7 +181,7 @@
"key": "label",
"templateUrl": "templates/label.html",
"uses": [ "type" ],
"gestures": [ "drag", "menu" ]
"gestures": [ "drag", "menu", "info" ]
},
{
"key": "node",

View File

@ -1,350 +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.
*****************************************************************************/
/*****************************************************************************
* 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.
*****************************************************************************/
/*****************************************************************************
* 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.
*****************************************************************************/
/*****************************************************************************
* 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.
*****************************************************************************/
/* line 31, ../sass/plots/_plots-main.scss */
.gl-plot {
color: #999;
font-size: 0.7rem;
position: relative;
width: 100%;
height: 100%;
/****************************** Limits and Out-of-Bounds data */ }
/* line 38, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-axis-area {
position: absolute; }
/* line 41, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-axis-area.gl-plot-x {
top: auto;
right: 0;
bottom: 5px;
left: 60px;
height: 32px;
width: auto;
overflow: hidden; }
/* line 50, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-axis-area.gl-plot-y {
top: 29px;
right: auto;
bottom: 37px;
left: 0;
width: 60px; }
/* line 59, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-coords {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
background: black;
color: #e6e6e6;
padding: 2px 5px;
position: absolute;
top: 39px;
right: auto;
bottom: auto;
left: 70px;
z-index: 10; }
/* line 71, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-coords:empty {
display: none; }
/* line 76, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-display-area {
position: absolute;
top: 29px;
right: 0;
bottom: 37px;
left: 60px;
cursor: crosshair;
border: 1px solid #4d4d4d; }
/* line 86, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-label,
.gl-plot .l-plot-label {
color: #cccccc;
position: absolute;
text-align: center; }
/* line 94, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-label.gl-plot-x-label, .gl-plot .gl-plot-label.l-plot-x-label,
.gl-plot .l-plot-label.gl-plot-x-label,
.gl-plot .l-plot-label.l-plot-x-label {
top: auto;
right: 0;
bottom: 0;
left: 0;
height: auto; }
/* line 103, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-label.gl-plot-y-label, .gl-plot .gl-plot-label.l-plot-y-label,
.gl-plot .l-plot-label.gl-plot-y-label,
.gl-plot .l-plot-label.l-plot-y-label {
-moz-transform-origin: 50% 0;
-ms-transform-origin: 50% 0;
-webkit-transform-origin: 50% 0;
transform-origin: 50% 0;
-moz-transform: translateX(-50%) rotate(-90deg);
-ms-transform: translateX(-50%) rotate(-90deg);
-webkit-transform: translateX(-50%) rotate(-90deg);
transform: translateX(-50%) rotate(-90deg);
display: inline-block;
margin-left: 5px;
left: 0;
top: 50%;
white-space: nowrap; }
/* line 117, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-y-options {
position: absolute;
top: 50%;
right: auto;
bottom: auto;
left: auto5px;
margin-top: -16px;
height: auto;
min-height: 32px;
width: 32px; }
/* line 131, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-hash {
position: absolute;
border: 0 rgba(255, 255, 255, 0.3) dashed; }
/* line 134, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-hash.hash-v {
border-right-width: 1px;
height: 100%; }
/* line 138, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-hash.hash-h {
border-bottom-width: 1px;
width: 100%; }
/* line 144, ../sass/plots/_plots-main.scss */
.gl-plot .gl-plot-legend {
position: absolute;
top: 0;
right: 0;
bottom: auto;
left: 0;
height: 24px;
overflow-x: hidden;
overflow-y: auto; }
/* line 157, ../sass/plots/_plots-main.scss */
.gl-plot .l-limit-bar,
.gl-plot .l-oob-data {
position: absolute;
left: 0;
right: 0;
width: auto; }
/* line 165, ../sass/plots/_plots-main.scss */
.gl-plot .l-limit-bar {
height: auto;
z-index: 0; }
/* line 173, ../sass/plots/_plots-main.scss */
.gl-plot .l-limit-bar.s-limit-yellow {
background: rgba(157, 117, 0, 0.2); }
/* line 174, ../sass/plots/_plots-main.scss */
.gl-plot .l-limit-bar.s-limit-red {
background: rgba(170, 0, 0, 0.2); }
/* line 177, ../sass/plots/_plots-main.scss */
.gl-plot .l-oob-data {
overflow: hidden;
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
width: auto;
height: auto;
pointer-events: none;
height: 10px;
z-index: 1; }
/* line 185, ../sass/plots/_plots-main.scss */
.gl-plot .l-oob-data.l-oob-data-up {
top: 0;
bottom: auto;
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjEuMCIgeDI9IjAuNSIgeTI9IjAuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzc3NDhkNiIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3NzQ4ZDYiIHN0b3Atb3BhY2l0eT0iMC41Ii8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
background-size: 100%;
background-image: -moz-linear-gradient(90deg, rgba(119, 72, 214, 0), rgba(119, 72, 214, 0.5) 100%);
background-image: -webkit-linear-gradient(90deg, rgba(119, 72, 214, 0), rgba(119, 72, 214, 0.5) 100%);
background-image: linear-gradient(0deg, rgba(119, 72, 214, 0), rgba(119, 72, 214, 0.5) 100%); }
/* line 190, ../sass/plots/_plots-main.scss */
.gl-plot .l-oob-data.l-oob-data-dwn {
bottom: 0;
top: auto;
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzc3NDhkNiIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3NzQ4ZDYiIHN0b3Atb3BhY2l0eT0iMC41Ii8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
background-size: 100%;
background-image: -moz-linear-gradient(270deg, rgba(119, 72, 214, 0), rgba(119, 72, 214, 0.5) 100%);
background-image: -webkit-linear-gradient(270deg, rgba(119, 72, 214, 0), rgba(119, 72, 214, 0.5) 100%);
background-image: linear-gradient(180deg, rgba(119, 72, 214, 0), rgba(119, 72, 214, 0.5) 100%); }
/* line 200, ../sass/plots/_plots-main.scss */
.gl-plot-legend .plot-legend-item,
.gl-plot-legend .legend-item,
.legend .plot-legend-item,
.legend .legend-item {
display: inline-block;
margin-right: 10px; }
/* line 204, ../sass/plots/_plots-main.scss */
.gl-plot-legend .plot-legend-item span,
.gl-plot-legend .legend-item span,
.legend .plot-legend-item span,
.legend .legend-item span {
vertical-align: middle; }
/* line 207, ../sass/plots/_plots-main.scss */
.gl-plot-legend .plot-legend-item .plot-color-swatch,
.gl-plot-legend .plot-legend-item .color-swatch,
.gl-plot-legend .legend-item .plot-color-swatch,
.gl-plot-legend .legend-item .color-swatch,
.legend .plot-legend-item .plot-color-swatch,
.legend .plot-legend-item .color-swatch,
.legend .legend-item .plot-color-swatch,
.legend .legend-item .color-swatch {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
display: inline-block;
height: 8px;
width: 8px; }
/* line 220, ../sass/plots/_plots-main.scss */
.gl-plot-legend .plot-legend-item {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
color: #fff;
line-height: 1.5em;
padding: 0px 5px; }
/* line 226, ../sass/plots/_plots-main.scss */
.gl-plot-legend .plot-legend-item .plot-color-swatch {
border: 1px solid #333;
height: 9px;
width: 9px; }
/* line 234, ../sass/plots/_plots-main.scss */
.tick {
position: absolute;
border: 0 rgba(255, 255, 255, 0.3) solid; }
/* line 237, ../sass/plots/_plots-main.scss */
.tick.tick-x {
border-right-width: 1px;
height: 100%; }
/* line 243, ../sass/plots/_plots-main.scss */
.gl-plot-tick,
.tick-label {
font-size: 0.7rem;
position: absolute;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis; }
/* line 251, ../sass/plots/_plots-main.scss */
.gl-plot-tick.gl-plot-x-tick-label, .gl-plot-tick.tick-label-x,
.tick-label.gl-plot-x-tick-label,
.tick-label.tick-label-x {
right: auto;
bottom: auto;
left: auto;
height: auto;
width: 20%;
margin-left: -10%;
text-align: center; }
/* line 261, ../sass/plots/_plots-main.scss */
.gl-plot-tick.gl-plot-y-tick-label, .gl-plot-tick.tick-label-y,
.tick-label.gl-plot-y-tick-label,
.tick-label.tick-label-y {
top: auto;
height: 1em;
width: auto;
margin-bottom: -0.5em;
text-align: right; }
/* line 273, ../sass/plots/_plots-main.scss */
.gl-plot-tick.gl-plot-x-tick-label {
top: 5px; }
/* line 276, ../sass/plots/_plots-main.scss */
.gl-plot-tick.gl-plot-y-tick-label {
right: 5px;
left: 5px; }
/* line 283, ../sass/plots/_plots-main.scss */
.tick-label.tick-label-x {
top: 0; }
/* line 286, ../sass/plots/_plots-main.scss */
.tick-label.tick-label-y {
right: 0;
left: 0; }

View File

@ -19,7 +19,7 @@
this source code distribution or the Licensing information page available
at runtime from the About dialog for additional information.
-->
<a class="t-btn l-btn s-btn s-icon-btn s-very-subtle key-{{parameters.action.getMetadata().key}}"
<a class="btn s-btn s-icon-btn s-very-subtle key-{{parameters.action.getMetadata().key}}"
ng-class="{ labeled: parameters.labeled }"
title="{{parameters.action.getMetadata().description}}"
ng-click="parameters.action.perform()">

View File

@ -21,25 +21,29 @@
-->
<span ng-controller="ViewSwitcherController">
<div class="menu-element btn icon-btn very-subtle btn-menu dropdown click-invoke"
ng-if="view.length > 1"
ng-controller="ClickAwayController as toggle">
<div
class="view-switcher menu-element btn btn-menu dropdown click-invoke"
ng-if="view.length > 1"
ng-controller="ClickAwayController as toggle"
>
<span class="l-click-area" ng-click="toggle.toggle()"></span>
<span
class="l-click-area"
ng-click="toggle.toggle()"
title="{{ngModel.selected.name}}"
></span>
<span class="ui-symbol icon type-icon">{{ngModel.selected.glyph}}</span>
<span>{{ngModel.selected.name}}</span>
<span class='ui-symbol icon invoke-menu'>v</span>
<span class="name">{{ngModel.selected.name}}</span>
<span class='ui-symbol invoke-menu'>v</span>
<div class="menu dropdown" ng-show="toggle.isActive()">
<ul>
<li ng-repeat="option in view">
<a href="" ng-click="ngModel.selected = option; toggle.setState(false)">
<span class="ui-symbol type-icon icon">
{{option.glyph}}
</span>
{{option.name}}
<a ng-click="ngModel.selected = option; toggle.setState(false)">
<span class="ui-symbol type-icon icon">{{option.glyph}}</span>
{{option.name}}
</a>
</li>
</ul>

View File

@ -1,20 +1,50 @@
{
"extensions": {
"types": [
"templates": [
{
"key": "infobubble",
"name": "Info Bubble",
"glyph": "\u00EA",
"description": "Static markup for info bubbles",
"features": [ "creation" ]
"key": "info-table",
"templateUrl": "info-table.html"
},
{
"key": "info-bubble",
"templateUrl": "info-bubble.html"
}
],
"views": [
"containers": [
{
"templateUrl": "infobubble.html",
"name": "Info Bubble",
"type": "infobubble",
"key": "infobubble"
"key": "bubble",
"templateUrl": "bubble.html",
"attributes": [ "bubbleTitle", "bubbleLayout" ],
"alias": "bubble"
}
],
"gestures": [
{
"key": "info",
"implementation": "gestures/InfoGesture.js",
"depends": [
"$timeout",
"infoService",
"INFO_HOVER_DELAY"
]
}
],
"services": [
{
"key": "infoService",
"implementation": "services/InfoService.js",
"depends": [
"$compile",
"$document",
"$window",
"$rootScope"
]
}
],
"constants": [
{
"key": "INFO_HOVER_DELAY",
"value": 500
}
]
}

View File

@ -0,0 +1,9 @@
<div class="t-infobubble s-infobubble l-infobubble-wrapper {{bubble.bubbleLayout}}">
<div class="l-infobubble">
<div ng-show="bubble.bubbleTitle.length > 0"
class="title">
{{bubble.bubbleTitle}}
</div>
<span ng-transclude></span>
</div>
</div>

View File

@ -0,0 +1,7 @@
<mct-container key="bubble"
bubble-title="{{parameters.title}}"
bubble-layout="{{parameters.layout}}">
<mct-include key="info-table"
ng-model="ngModel">
</mct-include>
</mct-container>

View File

@ -0,0 +1,8 @@
<table>
<tr ng-repeat="property in ngModel">
<td class="label">{{property.name}}</td>
<td title="{{property.value}}" class="value align-{{property.align}}">
{{property.value}}
</td>
</tr>
</table>

View File

@ -0,0 +1,35 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define({
BUBBLE_TEMPLATE: "<mct-container key=\"bubble\" " +
"bubble-title=\"{{bubbleTitle}}\" " +
"bubble-layout=\"{{bubbleLayout}}\">" +
"<mct-include key=\"bubbleTemplate\" ng-model=\"bubbleModel\">" +
"</mct-include>" +
"</mct-container>",
// Pixel offset for bubble, to align arrow position
BUBBLE_OFFSET: [ 0, -26 ],
// Max width and margins allowed for bubbles; defined in /platform/commonUI/general/res/sass/_constants.scss
BUBBLE_MARGIN_LR: 10,
BUBBLE_MAX_WIDTH: 300
});

View File

@ -0,0 +1,121 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define(
[],
function () {
"use strict";
/**
* The `info` gesture displays domain object metadata in a
* bubble on hover.
*
* @constructor
* @param $timeout Angular's `$timeout`
* @param {InfoService} infoService a service which shows info bubbles
* @param {number} DELAY delay, in milliseconds, before bubble appears
* @param element jqLite-wrapped DOM element
* @param {DomainObject} domainObject the domain object for which to
* show information
*/
function InfoGesture($timeout, infoService, DELAY, element, domainObject) {
var dismissBubble,
pendingBubble,
mousePosition,
scopeOff;
function trackPosition(event) {
// Record mouse position, so bubble can be shown at latest
// mouse position (not just where the mouse entered)
mousePosition = [ event.clientX, event.clientY ];
}
function hideBubble() {
// If a bubble is showing, dismiss it
if (dismissBubble) {
dismissBubble();
element.off('mouseleave', hideBubble);
dismissBubble = undefined;
}
// If a bubble will be shown on a timeout, cancel that
if (pendingBubble) {
$timeout.cancel(pendingBubble);
element.off('mousemove', trackPosition);
element.off('mouseleave', hideBubble);
pendingBubble = undefined;
}
// Also clear mouse position so we don't have a ton of tiny
// arrays allocated while user mouses over things
mousePosition = undefined;
}
function showBubble(event) {
trackPosition(event);
// Also need to track position during hover
element.on('mousemove', trackPosition);
// Show the bubble, after a suitable delay (if mouse has
// left before this time is up, this will be canceled.)
pendingBubble = $timeout(function () {
dismissBubble = infoService.display(
"info-table",
domainObject.getModel().name,
domainObject.useCapability('metadata'),
mousePosition
);
element.off('mousemove', trackPosition);
pendingBubble = undefined;
}, DELAY);
element.on('mouseleave', hideBubble);
}
// Show bubble (on a timeout) on mouse over
element.on('mouseenter', showBubble);
// Also make sure we dismiss bubble if representation is destroyed
// before the mouse actually leaves it
scopeOff = element.scope().$on('$destroy', hideBubble);
return {
/**
* Detach any event handlers associated with this gesture.
* @memberof InfoGesture
* @method
*/
destroy: function () {
// Dismiss any active bubble...
hideBubble();
// ...and detach listeners
element.off('mouseenter', showBubble);
scopeOff();
}
};
}
return InfoGesture;
}
);

View File

@ -0,0 +1,95 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define(
['../InfoConstants'],
function (InfoConstants) {
"use strict";
var BUBBLE_TEMPLATE = InfoConstants.BUBBLE_TEMPLATE,
OFFSET = InfoConstants.BUBBLE_OFFSET;
/**
* Displays informative content ("info bubbles") for the user.
* @constructor
*/
function InfoService($compile, $document, $window, $rootScope) {
function display(templateKey, title, content, position) {
var body = $document.find('body'),
scope = $rootScope.$new(),
winDim = [$window.innerWidth, $window.innerHeight],
bubbleSpaceLR = InfoConstants.BUBBLE_MARGIN_LR + InfoConstants.BUBBLE_MAX_WIDTH,
goLeft = position[0] > (winDim[0] - bubbleSpaceLR),
goUp = position[1] > (winDim[1] / 2),
bubble;
// Pass model & container parameters into the scope
scope.bubbleModel = content;
scope.bubbleTemplate = templateKey;
scope.bubbleLayout = (goUp ? 'arw-btm' : 'arw-top') + ' ' +
(goLeft ? 'arw-right' : 'arw-left');
scope.bubbleTitle = title;
// Create the context menu
bubble = $compile(BUBBLE_TEMPLATE)(scope);
// Position the bubble
bubble.css('position', 'absolute');
if (goLeft) {
bubble.css('right', (winDim[0] - position[0] + OFFSET[0]) + 'px');
} else {
bubble.css('left', position[0] + OFFSET[0] + 'px');
}
if (goUp) {
bubble.css('bottom', (winDim[1] - position[1] + OFFSET[1]) + 'px');
} else {
bubble.css('top', position[1] + OFFSET[1] + 'px');
}
// Add the menu to the body
body.append(bubble);
// Return a function to dismiss the bubble
return function () { bubble.remove(); };
}
return {
/**
* Display an info bubble at the specified location.
* @param {string} templateKey template to place in bubble
* @param {string} title title for the bubble
* @param {*} content content to pass to the template, via
* `ng-model`
* @param {number[]} x,y position of the info bubble, in
* pixel coordinates.
* @returns {Function} a function that may be invoked to
* dismiss the info bubble
*/
display: display
};
}
return InfoService;
}
);

View File

@ -0,0 +1,157 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
['../../src/gestures/InfoGesture'],
function (InfoGesture) {
"use strict";
describe("The info gesture", function () {
var mockTimeout,
mockInfoService,
testDelay = 12321,
mockElement,
mockDomainObject,
mockScope,
mockOff,
testMetadata,
mockPromise,
mockHide,
gesture;
function fireEvent(evt, value) {
mockElement.on.calls.forEach(function (call) {
if (call.args[0] === evt) {
call.args[1](value);
}
});
}
beforeEach(function () {
mockTimeout = jasmine.createSpy('$timeout');
mockTimeout.cancel = jasmine.createSpy('cancel');
mockInfoService = jasmine.createSpyObj(
'infoService',
[ 'display' ]
);
mockElement = jasmine.createSpyObj(
'element',
[ 'on', 'off', 'scope', 'css' ]
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getCapability', 'useCapability', 'getModel' ]
);
mockScope = jasmine.createSpyObj('$scope', [ '$on' ]);
mockOff = jasmine.createSpy('$off');
testMetadata = [ { name: "Test name", value: "Test value" } ];
mockPromise = jasmine.createSpyObj('promise', ['then']);
mockHide = jasmine.createSpy('hide');
mockDomainObject.getModel.andReturn({ name: "Test Object" });
mockDomainObject.useCapability.andCallFake(function (c) {
return (c === 'metadata') ? testMetadata : undefined;
});
mockElement.scope.andReturn(mockScope);
mockScope.$on.andReturn(mockOff);
mockTimeout.andReturn(mockPromise);
mockInfoService.display.andReturn(mockHide);
gesture = new InfoGesture(
mockTimeout,
mockInfoService,
testDelay,
mockElement,
mockDomainObject
);
});
it("listens for mouseenter on the representation", function () {
expect(mockElement.on)
.toHaveBeenCalledWith('mouseenter', jasmine.any(Function));
});
it("displays an info bubble on a delay after mouseenter", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
expect(mockTimeout)
.toHaveBeenCalledWith(jasmine.any(Function), testDelay);
mockTimeout.mostRecentCall.args[0]();
expect(mockInfoService.display).toHaveBeenCalledWith(
jasmine.any(String),
"Test Object",
testMetadata,
[ 1977, 42 ]
);
});
it("does not display info bubble if mouse leaves too soon", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
fireEvent("mouseleave", { clientX: 1977, clientY: 42 });
expect(mockTimeout.cancel).toHaveBeenCalledWith(mockPromise);
expect(mockInfoService.display).not.toHaveBeenCalled();
});
it("hides a shown bubble when mouse leaves", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
mockTimeout.mostRecentCall.args[0]();
expect(mockHide).not.toHaveBeenCalled(); // verify precondition
fireEvent("mouseleave", {});
expect(mockHide).toHaveBeenCalled();
});
it("tracks mouse position", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
fireEvent("mousemove", { clientX: 1999, clientY: 11 });
fireEvent("mousemove", { clientX: 1984, clientY: 11 });
mockTimeout.mostRecentCall.args[0]();
// Should have displayed at the latest observed mouse position
expect(mockInfoService.display).toHaveBeenCalledWith(
jasmine.any(String),
"Test Object",
testMetadata,
[ 1984, 11 ]
);
});
it("hides shown bubbles when destroyed", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
mockTimeout.mostRecentCall.args[0]();
expect(mockHide).not.toHaveBeenCalled(); // verify precondition
gesture.destroy();
expect(mockHide).toHaveBeenCalled();
});
it("detaches listeners when destroyed", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
gesture.destroy();
mockElement.on.calls.forEach(function (call) {
expect(mockElement.off).toHaveBeenCalledWith(
call.args[0],
call.args[1]
);
});
});
});
}
);

View File

@ -0,0 +1,131 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
['../../src/services/InfoService', '../../src/InfoConstants'],
function (InfoService, InfoConstants) {
"use strict";
describe("The info service", function () {
var mockCompile,
mockDocument,
testWindow,
mockRootScope,
mockCompiledTemplate,
testScope,
mockBody,
mockElement,
service;
beforeEach(function () {
mockCompile = jasmine.createSpy('$compile');
mockDocument = jasmine.createSpyObj('$document', ['find']);
testWindow = { innerWidth: 1000, innerHeight: 100 };
mockRootScope = jasmine.createSpyObj('$rootScope', ['$new']);
mockCompiledTemplate = jasmine.createSpy('template');
testScope = {};
mockBody = jasmine.createSpyObj('body', ['append']);
mockElement = jasmine.createSpyObj('element', ['css', 'remove']);
mockDocument.find.andCallFake(function (tag) {
return tag === 'body' ? mockBody : undefined;
});
mockCompile.andReturn(mockCompiledTemplate);
mockCompiledTemplate.andReturn(mockElement);
mockRootScope.$new.andReturn(testScope);
service = new InfoService(
mockCompile,
mockDocument,
testWindow,
mockRootScope
);
});
it("creates elements and appends them to the body to display", function () {
service.display('', '', {}, [0, 0]);
expect(mockBody.append).toHaveBeenCalledWith(mockElement);
});
it("provides a function to remove displayed info bubbles", function () {
var fn = service.display('', '', {}, [0, 0]);
expect(mockElement.remove).not.toHaveBeenCalled();
fn();
expect(mockElement.remove).toHaveBeenCalled();
});
describe("depending on mouse position", function () {
// Positioning should vary based on quadrant in window,
// which is 1000 x 100 in this test case.
it("displays from the top-left in the top-left quadrant", function () {
service.display('', '', {}, [250, 25]);
expect(mockElement.css).toHaveBeenCalledWith(
'left',
(250 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
);
expect(mockElement.css).toHaveBeenCalledWith(
'top',
(25 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
);
});
it("displays from the top-right in the top-right quadrant", function () {
service.display('', '', {}, [700, 25]);
expect(mockElement.css).toHaveBeenCalledWith(
'right',
(300 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
);
expect(mockElement.css).toHaveBeenCalledWith(
'top',
(25 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
);
});
it("displays from the bottom-left in the bottom-left quadrant", function () {
service.display('', '', {}, [250, 70]);
expect(mockElement.css).toHaveBeenCalledWith(
'left',
(250 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
);
expect(mockElement.css).toHaveBeenCalledWith(
'bottom',
(30 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
);
});
it("displays from the bottom-right in the bottom-right quadrant", function () {
service.display('', '', {}, [800, 60]);
expect(mockElement.css).toHaveBeenCalledWith(
'right',
(200 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
);
expect(mockElement.css).toHaveBeenCalledWith(
'bottom',
(40 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
);
});
});
});
}
);

View File

@ -0,0 +1,4 @@
[
"gestures/InfoGesture",
"services/InfoService"
]

View File

@ -165,6 +165,10 @@
"implementation": "capabilities/PersistenceCapability.js",
"depends": [ "persistenceService", "PERSISTENCE_SPACE" ]
},
{
"key": "metadata",
"implementation": "capabilities/MetadataCapability.js"
},
{
"key": "mutation",
"implementation": "capabilities/MutationCapability.js",

View File

@ -0,0 +1,92 @@
/*global define*/
define(
['moment'],
function (moment) {
"use strict";
/**
* A piece of information about a domain object.
* @typedef {Object} MetadataProperty
* @property {string} name the human-readable name of this property
* @property {string} value the human-readable value of this property,
* for this specific domain object
*/
var TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
/**
* Implements the `metadata` capability of a domain object, providing
* properties of that object for display.
*
* Usage: `domainObject.useCapability("metadata")`
*
* ...which will return an array of objects containing `name` and
* `value` properties describing that domain object (suitable for
* display.)
*
* @constructor
*/
function MetadataCapability(domainObject) {
var model = domainObject.getModel();
function hasDisplayableValue(metadataProperty) {
var t = typeof metadataProperty.value;
return (t === 'string' || t === 'number');
}
function formatTimestamp(timestamp) {
return typeof timestamp === 'number' ?
(moment.utc(timestamp).format(TIME_FORMAT) + " UTC") :
undefined;
}
function getProperties() {
var type = domainObject.getCapability('type');
function lookupProperty(typeProperty) {
return {
name: typeProperty.getDefinition().name,
value: typeProperty.getValue(model)
};
}
return (type ? type.getProperties() : []).map(lookupProperty);
}
function getCommonMetadata() {
var type = domainObject.getCapability('type');
// Note that invalid values will be filtered out later
return [
{
name: "Updated",
value: formatTimestamp(model.modified)
},
{
name: "Type",
value: type && type.getName()
},
{
name: "ID",
value: domainObject.getId()
}
];
}
function getMetadata() {
return getProperties().concat(getCommonMetadata())
.filter(hasDisplayableValue);
}
return {
/**
* Get metadata about this object.
* @returns {MetadataProperty[]} metadata about this object
*/
invoke: getMetadata
};
}
return MetadataCapability;
}
);

View File

@ -0,0 +1,101 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
['../../src/capabilities/MetadataCapability'],
function (MetadataCapability) {
"use strict";
describe("The metadata capability", function () {
var mockDomainObject,
mockType,
mockProperties,
testModel,
metadata;
function getCapability(key) {
return key === 'type' ? mockType : undefined;
}
function findValue(properties, name) {
var i;
for (i = 0; i < properties.length; i += 1) {
if (properties[i].name === name) {
return properties[i].value;
}
}
}
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
'domainObject',
['getId', 'getCapability', 'useCapability', 'getModel']
);
mockType = jasmine.createSpyObj(
'type',
['getProperties', 'getName']
);
mockProperties = ['a', 'b', 'c'].map(function (k) {
var mockProperty = jasmine.createSpyObj(
'property-' + k,
['getValue', 'getDefinition']
);
mockProperty.getValue.andReturn("Value " + k);
mockProperty.getDefinition.andReturn({ name: "Property " + k});
return mockProperty;
});
testModel = { name: "" };
mockDomainObject.getId.andReturn("Test id");
mockDomainObject.getModel.andReturn(testModel);
mockDomainObject.getCapability.andCallFake(getCapability);
mockDomainObject.useCapability.andCallFake(getCapability);
mockType.getProperties.andReturn(mockProperties);
mockType.getName.andReturn("Test type");
metadata = new MetadataCapability(mockDomainObject);
});
it("reads properties from the domain object model", function () {
metadata.invoke();
mockProperties.forEach(function (mockProperty) {
expect(mockProperty.getValue).toHaveBeenCalledWith(testModel);
});
});
it("reports type-specific properties", function () {
var properties = metadata.invoke();
expect(findValue(properties, 'Property a')).toEqual("Value a");
expect(findValue(properties, 'Property b')).toEqual("Value b");
expect(findValue(properties, 'Property c')).toEqual("Value c");
});
it("reports generic properties", function () {
var properties = metadata.invoke();
expect(findValue(properties, 'ID')).toEqual("Test id");
expect(findValue(properties, 'Type')).toEqual("Test type");
});
});
}
);

View File

@ -9,6 +9,7 @@
"capabilities/ContextualDomainObject",
"capabilities/CoreCapabilityProvider",
"capabilities/DelegationCapability",
"capabilities/MetadataCapability",
"capabilities/MutationCapability",
"capabilities/PersistenceCapability",
"capabilities/RelationshipCapability",

View File

@ -0,0 +1,24 @@
# Entanglement
Entanglement is the process of moving, copying, and linking domain objects
in such a way that their relationships are impossible to discern.
This bundle provides move, copy, and link functionality. Acheiving a state of
entanglement is left up to the end user.
## Services implement logic
Each method (move, copy, link) is implemented as a service, and each service
provides two functions: `validate` and `perform`.
`validate(object, parentCandidate)` returns true if the `object` can be
move/copy/linked into the `parentCandidate`'s composition.
`perform(object, parentObject)` move/copy/links the `object` into the
`parentObject`'s composition.
## Actions implement user interactions
Actions are used to expose move/copy/link to the user. They prompt for input
where necessary, and complete the actions.

View File

@ -0,0 +1,75 @@
{
"name": "Entanglement",
"description": "Tools to assist you in entangling the world of WARP.",
"configuration": {},
"extensions": {
"actions": [
{
"key": "move",
"name": "Move",
"description": "Move object to another location.",
"glyph": "f",
"category": "contextual",
"implementation": "actions/MoveAction.js",
"depends": ["locationService", "moveService"]
},
{
"key": "copy",
"name": "Duplicate",
"description": "Duplicate object to another location.",
"glyph": "+",
"category": "contextual",
"implementation": "actions/CopyAction.js",
"depends": ["locationService", "copyService"]
},
{
"key": "link",
"name": "Create Link",
"description": "Create Link to object in another location.",
"glyph": "\u00E8",
"category": "contextual",
"implementation": "actions/LinkAction.js",
"depends": ["locationService", "linkService"]
}
],
"components": [
],
"controllers": [
],
"capabilities": [
],
"services": [
{
"key": "moveService",
"name": "Move Service",
"description": "Provides a service for moving objects",
"implementation": "services/MoveService.js",
"depends": ["policyService", "linkService"]
},
{
"key": "linkService",
"name": "Link Service",
"description": "Provides a service for linking objects",
"implementation": "services/LinkService.js",
"depends": ["policyService"]
},
{
"key": "copyService",
"name": "Copy Service",
"description": "Provides a service for copying objects",
"implementation": "services/CopyService.js",
"depends": ["$q", "creationService", "policyService"]
},
{
"key": "locationService",
"name": "Location Service",
"description": "Provides a service for prompting a user for locations.",
"implementation": "services/LocationService.js",
"depends": ["dialogService"]
}
],
"licenses": [
]
}
}

View File

@ -0,0 +1,92 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define */
define(
function () {
"use strict";
/**
* The CopyAction is available from context menus and allows a user to
* deep copy an object to another location of their choosing.
*
* @implements Action
*/
function CopyAction(locationService, copyService, context) {
var object,
newParent,
currentParent;
if (context.selectedObject) {
newParent = context.domainObject;
object = context.selectedObject;
} else {
object = context.domainObject;
}
currentParent = object
.getCapability('context')
.getParent();
return {
perform: function () {
if (newParent) {
return copyService
.perform(object, newParent);
}
var dialogTitle,
label,
validateLocation;
dialogTitle = [
"Duplicate ",
object.getModel().name,
" to a location"
].join("");
label = "Duplicate To";
validateLocation = function (newParent) {
return copyService
.validate(object, newParent);
};
return locationService.getLocationFromUser(
dialogTitle,
label,
validateLocation,
currentParent
).then(function (newParent) {
return copyService
.perform(object, newParent);
});
}
};
}
return CopyAction;
}
);

View File

@ -0,0 +1,89 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define */
define(
function () {
"use strict";
/**
* The LinkAction is available from context menus and allows a user to
* link an object to another location of their choosing.
*
* @implements Action
*/
function LinkAction(locationService, linkService, context) {
var object,
newParent,
currentParent;
if (context.selectedObject) {
newParent = context.domainObject;
object = context.selectedObject;
} else {
object = context.domainObject;
}
currentParent = object
.getCapability('context')
.getParent();
return {
perform: function () {
if (newParent) {
return linkService
.perform(object, newParent);
}
var dialogTitle,
label,
validateLocation;
dialogTitle = [
"Link ",
object.getModel().name,
" to a new location"
].join("");
label = "Link To";
validateLocation = function (newParent) {
return linkService
.validate(object, newParent);
};
return locationService.getLocationFromUser(
dialogTitle,
label,
validateLocation,
currentParent
).then(function (newParent) {
return linkService
.perform(object, newParent);
});
}
};
}
return LinkAction;
}
);

View File

@ -0,0 +1,90 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define */
define(
function () {
"use strict";
/**
* The MoveAction is available from context menus and allows a user to
* move an object to another location of their choosing.
*
* @implements Action
*/
function MoveAction(locationService, moveService, context) {
var object,
newParent,
currentParent;
if (context.selectedObject) {
newParent = context.domainObject;
object = context.selectedObject;
} else {
object = context.domainObject;
}
currentParent = object
.getCapability('context')
.getParent();
return {
perform: function () {
if (newParent) {
return moveService
.perform(object, newParent);
}
var dialogTitle,
label,
validateLocation;
dialogTitle = [
"Move ",
object.getModel().name,
" to a new location"
].join("");
label = "Move To";
validateLocation = function (newParent) {
return moveService
.validate(object, newParent);
};
return locationService.getLocationFromUser(
dialogTitle,
label,
validateLocation,
currentParent
).then(function (newParent) {
return moveService
.perform(object, newParent);
});
}
};
}
return MoveAction;
}
);

View File

@ -0,0 +1,106 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define */
define(
function () {
"use strict";
/**
* CopyService provides an interface for deep copying objects from one
* location to another. It also provides a method for determining if
* an object can be copied to a specific location.
*/
function CopyService($q, creationService, policyService) {
/**
* duplicateObject duplicates a `domainObject` into the composition
* of `parent`, and then duplicates the composition of
* `domainObject` into the new object.
*
* This function is a recursive deep copy.
*
* @param {DomainObject} domainObject - the domain object to
* duplicate.
* @param {DomainObject} parent - the parent domain object to
* create the duplicate in.
* @returns {Promise} A promise that is fulfilled when the
* duplicate operation has completed.
*/
function duplicateObject(domainObject, parent) {
var model = JSON.parse(JSON.stringify(domainObject.getModel()));
if (domainObject.hasCapability('composition')) {
model.composition = [];
}
return creationService
.createObject(model, parent)
.then(function (newObject) {
if (!domainObject.hasCapability('composition')) {
return;
}
return domainObject
.useCapability('composition')
.then(function (composees) {
// Duplicate composition serially to prevent
// write conflicts.
return composees.reduce(function (promise, composee) {
return promise.then(function () {
return duplicateObject(composee, newObject);
});
}, $q.when(undefined));
});
});
}
return {
/**
* Returns true if `object` can be copied into
* `parentCandidate`'s composition.
*/
validate: function (object, parentCandidate) {
if (!parentCandidate || !parentCandidate.getId) {
return false;
}
if (parentCandidate.getId() === object.getId()) {
return false;
}
return policyService.allow(
"composition",
parentCandidate.getCapability('type'),
object.getCapability('type')
);
},
/**
* Wrapper, @see {@link duplicateObject} for implementation.
*/
perform: function (object, parentObject) {
return duplicateObject(object, parentObject);
}
};
}
return CopyService;
}
);

View File

@ -0,0 +1,76 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define */
define(
function () {
"use strict";
/**
* LinkService provides an interface for linking objects to additional
* locations. It also provides a method for determining if an object
* can be copied to a specific location.
*/
function LinkService(policyService) {
return {
/**
* Returns `true` if `object` can be linked into
* `parentCandidate`'s composition.
*/
validate: function (object, parentCandidate) {
if (!parentCandidate || !parentCandidate.getId) {
return false;
}
if (parentCandidate.getId() === object.getId()) {
return false;
}
if (parentCandidate.getModel().composition.indexOf(object.getId()) !== -1) {
return false;
}
return policyService.allow(
"composition",
parentCandidate.getCapability('type'),
object.getCapability('type')
);
},
/**
* Link `object` into `parentObject`'s composition.
*
* @returns {Promise} A promise that is fulfilled when the
* linking operation has completed.
*/
perform: function (object, parentObject) {
return parentObject.useCapability('mutation', function (model) {
if (model.composition.indexOf(object.getId()) === -1) {
model.composition.push(object.getId());
}
}).then(function () {
return parentObject.getCapability('persistence').persist();
});
}
};
}
return LinkService;
}
);

View File

@ -0,0 +1,83 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define */
define(
function () {
"use strict";
/**
* The LocationService allows for easily prompting the user for a
* location in the root tree.
*/
function LocationService(dialogService) {
return {
/** Prompt the user to select a location. Returns a promise
* that is resolved with a domainObject representing the
* location selected by the user.
*
* @param {string} title - title of location dialog
* @param {string} label - label for location input field
* @param {function} validate - function that validates
* selections.
* @param {domainObject} initialLocation - tree location to
* display at start
* @returns {Promise} promise for a domain object.
*/
getLocationFromUser: function (title, label, validate, initialLocation) {
var formStructure,
formState;
formStructure = {
sections: [
{
name: 'Location',
rows: [
{
name: label,
control: "locator",
validate: validate,
key: 'location'
}
]
}
],
name: title
};
formState = {
location: initialLocation
};
return dialogService
.getUserInput(formStructure, formState)
.then(function (formState) {
return formState.location;
});
}
};
}
return LocationService;
}
);

View File

@ -0,0 +1,83 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define */
define(
function () {
"use strict";
/**
* MoveService provides an interface for moving objects from one
* location to another. It also provides a method for determining if
* an object can be copied to a specific location.
*/
function MoveService(policyService, linkService) {
return {
/**
* Returns `true` if `object` can be moved into
* `parentCandidate`'s composition.
*/
validate: function (object, parentCandidate) {
var currentParent = object
.getCapability('context')
.getParent();
if (!parentCandidate || !parentCandidate.getId) {
return false;
}
if (parentCandidate.getId() === currentParent.getId()) {
return false;
}
if (parentCandidate.getId() === object.getId()) {
return false;
}
if (parentCandidate.getModel().composition.indexOf(object.getId()) !== -1) {
return false;
}
return policyService.allow(
"composition",
parentCandidate.getCapability('type'),
object.getCapability('type')
);
},
/**
* Move `object` into `parentObject`'s composition.
*
* @returns {Promise} A promise that is fulfilled when the
* move operation has completed.
*/
perform: function (object, parentObject) {
return linkService
.perform(object, parentObject)
.then(function () {
return object
.getCapability('action')
.perform('remove');
});
}
};
}
return MoveService;
}
);

View File

@ -0,0 +1,158 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define, jasmine, */
define(
function () {
"use strict";
/**
* @typedef DomainObjectConfig
* @type {object}
* @property {string} [name] a name for the underlying jasmine spy
* object mockDomainObject. Used as
* @property {string} [id] initial id value for the domainOBject.
* @property {object} [model] initial values for the object's model.
* @property {object} [capabilities] an object containing
* capability definitions.
*/
var configObjectProps = ['model', 'capabilities'];
/**
* Internal function for ensuring an object is an instance of a
* DomainObjectConfig.
*/
function ensureValidConfigObject(config) {
if (!config || !config.hasOwnProperty) {
config = {};
}
if (!config.name) {
config.name = 'domainObject';
}
configObjectProps.forEach(function (prop) {
if (!config[prop] || !config[prop].hasOwnProperty) {
config[prop] = {};
}
});
return config;
}
/**
* Defines a factory function which takes a `config` object and returns
* a mock domainObject. The config object is an easy way to provide
* initial properties for the domainObject-- they can be changed at any
* time by directly modifying the domainObject's properties.
*
* @param {Object} [config] initial configuration for a domain object.
* @returns {Object} mockDomainObject
*/
function domainObjectFactory(config) {
config = ensureValidConfigObject(config);
var domainObject = jasmine.createSpyObj(config.name, [
'getId',
'getModel',
'getCapability',
'hasCapability',
'useCapability'
]);
domainObject.model = JSON.parse(JSON.stringify(config.model));
domainObject.capabilities = config.capabilities;
domainObject.id = config.id;
/**
* getId: Returns `domainObject.id`.
*
* @returns {string} id
*/
domainObject.getId.andCallFake(function () {
return domainObject.id;
});
/**
* getModel: Returns `domainObject.model`.
*
* @returns {object} model
*/
domainObject.getModel.andCallFake(function () {
return domainObject.model;
});
/**
* getCapability: returns a `capability` object defined in
* domainObject.capabilities. Returns undefined if capability
* does not exist.
*
* @param {string} capability name of the capability to return.
* @returns {*} capability object
*/
domainObject.getCapability.andCallFake(function (capability) {
if (config.capabilities.hasOwnProperty(capability)) {
return config.capabilities[capability];
}
});
/**
* hasCapability: return true if domainObject.capabilities has a
* property named `capability`, otherwise returns false.
*
* @param {string} capability name of the capability to test for
* existence of.
* @returns {boolean}
*/
domainObject.hasCapability.andCallFake(function (capability) {
return config.capabilities.hasOwnProperty(capability);
});
/**
* useCapability: find a capability in domainObject.capabilities
* and call that capabilities' invoke method. If the capability
* does not have an invoke method, will throw an error.
*
* @param {string} capability name of a capability to invoke.
* @param {...*} params to pass to the capability's `invoke` method.
* @returns {*} result whatever was returned by `invoke`.
*/
domainObject.useCapability.andCallFake(function (capability) {
if (config.capabilities.hasOwnProperty(capability)) {
if (!config.capabilities[capability].invoke) {
throw new Error(
capability + ' missing invoke function.'
);
}
var passThroughArgs = [].slice.call(arguments, 1);
return config
.capabilities[capability]
.invoke
.apply(null, passThroughArgs);
}
});
return domainObject;
}
return domainObjectFactory;
}
);

View File

@ -0,0 +1,174 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,describe,beforeEach,it,jasmine,expect */
define(
[
'../../src/actions/CopyAction',
'../services/MockCopyService',
'../DomainObjectFactory'
],
function (CopyAction, MockCopyService, domainObjectFactory) {
"use strict";
describe("Copy Action", function () {
var copyAction,
locationService,
locationServicePromise,
copyService,
context,
selectedObject,
selectedObjectContextCapability,
currentParent,
newParent;
beforeEach(function () {
selectedObjectContextCapability = jasmine.createSpyObj(
'selectedObjectContextCapability',
[
'getParent'
]
);
selectedObject = domainObjectFactory({
name: 'selectedObject',
model: {
name: 'selectedObject'
},
capabilities: {
context: selectedObjectContextCapability
}
});
currentParent = domainObjectFactory({
name: 'currentParent'
});
selectedObjectContextCapability
.getParent
.andReturn(currentParent);
newParent = domainObjectFactory({
name: 'newParent'
});
locationService = jasmine.createSpyObj(
'locationService',
[
'getLocationFromUser'
]
);
locationServicePromise = jasmine.createSpyObj(
'locationServicePromise',
[
'then'
]
);
locationService
.getLocationFromUser
.andReturn(locationServicePromise);
copyService = new MockCopyService();
});
describe("with context from context-action", function () {
beforeEach(function () {
context = {
domainObject: selectedObject
};
copyAction = new CopyAction(
locationService,
copyService,
context
);
});
it("initializes happily", function () {
expect(copyAction).toBeDefined();
});
describe("when performed it", function () {
beforeEach(function () {
copyAction.perform();
});
it("prompts for location", function () {
expect(locationService.getLocationFromUser)
.toHaveBeenCalledWith(
"Duplicate selectedObject to a location",
"Duplicate To",
jasmine.any(Function),
currentParent
);
});
it("waits for location from user", function () {
expect(locationServicePromise.then)
.toHaveBeenCalledWith(jasmine.any(Function));
});
it("copys object to selected location", function () {
locationServicePromise
.then
.mostRecentCall
.args[0](newParent);
expect(copyService.perform)
.toHaveBeenCalledWith(selectedObject, newParent);
});
});
});
describe("with context from drag-drop", function () {
beforeEach(function () {
context = {
selectedObject: selectedObject,
domainObject: newParent
};
copyAction = new CopyAction(
locationService,
copyService,
context
);
});
it("initializes happily", function () {
expect(copyAction).toBeDefined();
});
it("performs copy immediately", function () {
copyAction.perform();
expect(copyService.perform)
.toHaveBeenCalledWith(selectedObject, newParent);
});
});
});
}
);

View File

@ -0,0 +1,174 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,describe,beforeEach,it,jasmine,expect */
define(
[
'../../src/actions/LinkAction',
'../services/MockLinkService',
'../DomainObjectFactory'
],
function (LinkAction, MockLinkService, domainObjectFactory) {
"use strict";
describe("Link Action", function () {
var linkAction,
locationService,
locationServicePromise,
linkService,
context,
selectedObject,
selectedObjectContextCapability,
currentParent,
newParent;
beforeEach(function () {
selectedObjectContextCapability = jasmine.createSpyObj(
'selectedObjectContextCapability',
[
'getParent'
]
);
selectedObject = domainObjectFactory({
name: 'selectedObject',
model: {
name: 'selectedObject'
},
capabilities: {
context: selectedObjectContextCapability
}
});
currentParent = domainObjectFactory({
name: 'currentParent'
});
selectedObjectContextCapability
.getParent
.andReturn(currentParent);
newParent = domainObjectFactory({
name: 'newParent'
});
locationService = jasmine.createSpyObj(
'locationService',
[
'getLocationFromUser'
]
);
locationServicePromise = jasmine.createSpyObj(
'locationServicePromise',
[
'then'
]
);
locationService
.getLocationFromUser
.andReturn(locationServicePromise);
linkService = new MockLinkService();
});
describe("with context from context-action", function () {
beforeEach(function () {
context = {
domainObject: selectedObject
};
linkAction = new LinkAction(
locationService,
linkService,
context
);
});
it("initializes happily", function () {
expect(linkAction).toBeDefined();
});
describe("when performed it", function () {
beforeEach(function () {
linkAction.perform();
});
it("prompts for location", function () {
expect(locationService.getLocationFromUser)
.toHaveBeenCalledWith(
"Link selectedObject to a new location",
"Link To",
jasmine.any(Function),
currentParent
);
});
it("waits for location from user", function () {
expect(locationServicePromise.then)
.toHaveBeenCalledWith(jasmine.any(Function));
});
it("links object to selected location", function () {
locationServicePromise
.then
.mostRecentCall
.args[0](newParent);
expect(linkService.perform)
.toHaveBeenCalledWith(selectedObject, newParent);
});
});
});
describe("with context from drag-drop", function () {
beforeEach(function () {
context = {
selectedObject: selectedObject,
domainObject: newParent
};
linkAction = new LinkAction(
locationService,
linkService,
context
);
});
it("initializes happily", function () {
expect(linkAction).toBeDefined();
});
it("performs link immediately", function () {
linkAction.perform();
expect(linkService.perform)
.toHaveBeenCalledWith(selectedObject, newParent);
});
});
});
}
);

View File

@ -0,0 +1,174 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,describe,beforeEach,it,jasmine,expect */
define(
[
'../../src/actions/MoveAction',
'../services/MockMoveService',
'../DomainObjectFactory'
],
function (MoveAction, MockMoveService, domainObjectFactory) {
"use strict";
describe("Move Action", function () {
var moveAction,
locationService,
locationServicePromise,
moveService,
context,
selectedObject,
selectedObjectContextCapability,
currentParent,
newParent;
beforeEach(function () {
selectedObjectContextCapability = jasmine.createSpyObj(
'selectedObjectContextCapability',
[
'getParent'
]
);
selectedObject = domainObjectFactory({
name: 'selectedObject',
model: {
name: 'selectedObject'
},
capabilities: {
context: selectedObjectContextCapability
}
});
currentParent = domainObjectFactory({
name: 'currentParent'
});
selectedObjectContextCapability
.getParent
.andReturn(currentParent);
newParent = domainObjectFactory({
name: 'newParent'
});
locationService = jasmine.createSpyObj(
'locationService',
[
'getLocationFromUser'
]
);
locationServicePromise = jasmine.createSpyObj(
'locationServicePromise',
[
'then'
]
);
locationService
.getLocationFromUser
.andReturn(locationServicePromise);
moveService = new MockMoveService();
});
describe("with context from context-action", function () {
beforeEach(function () {
context = {
domainObject: selectedObject
};
moveAction = new MoveAction(
locationService,
moveService,
context
);
});
it("initializes happily", function () {
expect(moveAction).toBeDefined();
});
describe("when performed it", function () {
beforeEach(function () {
moveAction.perform();
});
it("prompts for location", function () {
expect(locationService.getLocationFromUser)
.toHaveBeenCalledWith(
"Move selectedObject to a new location",
"Move To",
jasmine.any(Function),
currentParent
);
});
it("waits for location from user", function () {
expect(locationServicePromise.then)
.toHaveBeenCalledWith(jasmine.any(Function));
});
it("moves object to selected location", function () {
locationServicePromise
.then
.mostRecentCall
.args[0](newParent);
expect(moveService.perform)
.toHaveBeenCalledWith(selectedObject, newParent);
});
});
});
describe("with context from drag-drop", function () {
beforeEach(function () {
context = {
selectedObject: selectedObject,
domainObject: newParent
};
moveAction = new MoveAction(
locationService,
moveService,
context
);
});
it("initializes happily", function () {
expect(moveAction).toBeDefined();
});
it("performs move immediately", function () {
moveAction.perform();
expect(moveService.perform)
.toHaveBeenCalledWith(selectedObject, newParent);
});
});
});
}
);

View File

@ -0,0 +1,272 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,describe,beforeEach,it,jasmine,expect,spyOn */
define(
[
'../../src/services/CopyService',
'../DomainObjectFactory'
],
function (CopyService, domainObjectFactory) {
"use strict";
function synchronousPromise(value) {
var promise = {
then: function (callback) {
return synchronousPromise(callback(value));
}
};
spyOn(promise, 'then').andCallThrough();
return promise;
}
describe("CopyService", function () {
describe("validate", function () {
var policyService,
copyService,
object,
parentCandidate,
validate;
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
['allow']
);
copyService = new CopyService(
null,
null,
policyService
);
object = domainObjectFactory({
name: 'object',
capabilities: {
type: { type: 'object' }
}
});
parentCandidate = domainObjectFactory({
name: 'parentCandidate',
capabilities: {
type: { type: 'parentCandidate' }
}
});
validate = function () {
return copyService.validate(object, parentCandidate);
};
});
it("does not allow invalid parentCandidate", function () {
parentCandidate = undefined;
expect(validate()).toBe(false);
parentCandidate = {};
expect(validate()).toBe(false);
});
it("does not allow copying into source object", function () {
object.id = parentCandidate.id = 'abc';
expect(validate()).toBe(false);
});
describe("defers to policyService", function () {
beforeEach(function () {
object.id = 'a';
parentCandidate.id = 'b';
});
it("calls policy service with correct args", function () {
validate();
expect(policyService.allow).toHaveBeenCalledWith(
"composition",
parentCandidate.capabilities.type,
object.capabilities.type
);
});
it("and returns false", function () {
policyService.allow.andReturn(false);
expect(validate()).toBe(false);
});
it("and returns true", function () {
policyService.allow.andReturn(true);
expect(validate()).toBe(true);
});
});
});
describe("perform", function () {
var mockQ,
creationService,
createObjectPromise,
copyService,
object,
newParent,
copyResult,
copyFinished;
describe("on domain object without composition", function () {
beforeEach(function () {
object = domainObjectFactory({
name: 'object',
id: 'abc',
model: {
name: 'some object'
}
});
newParent = domainObjectFactory({
name: 'newParent',
id: '456',
model: {
composition: []
}
});
creationService = jasmine.createSpyObj(
'creationService',
['createObject']
);
createObjectPromise = synchronousPromise(undefined);
creationService.createObject.andReturn(createObjectPromise);
copyService = new CopyService(null, creationService);
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);
});
it("uses creation service", function () {
expect(creationService.createObject)
.toHaveBeenCalledWith(jasmine.any(Object), newParent);
expect(createObjectPromise.then)
.toHaveBeenCalledWith(jasmine.any(Function));
});
it("deep clones object model", function () {
var newModel = creationService
.createObject
.mostRecentCall
.args[0];
expect(newModel).toEqual(object.model);
expect(newModel).not.toBe(object.model);
});
it("returns a promise", function () {
expect(copyResult).toBeDefined();
expect(copyFinished).toHaveBeenCalled();
});
});
describe("on domainObject with composition", function () {
var childObject,
compositionCapability,
compositionPromise;
beforeEach(function () {
mockQ = jasmine.createSpyObj('mockQ', ['when']);
mockQ.when.andCallFake(synchronousPromise);
childObject = domainObjectFactory({
name: 'childObject',
id: 'def',
model: {
name: 'a child object'
}
});
compositionCapability = jasmine.createSpyObj(
'compositionCapability',
['invoke']
);
compositionPromise = jasmine.createSpyObj(
'compositionPromise',
['then']
);
compositionCapability
.invoke
.andReturn(compositionPromise);
object = domainObjectFactory({
name: 'object',
id: 'abc',
model: {
name: 'some object',
composition: ['def']
},
capabilities: {
composition: compositionCapability
}
});
newParent = domainObjectFactory({
name: 'newParent',
id: '456',
model: {
composition: []
}
});
creationService = jasmine.createSpyObj(
'creationService',
['createObject']
);
createObjectPromise = synchronousPromise(undefined);
creationService.createObject.andReturn(createObjectPromise);
copyService = new CopyService(mockQ, creationService);
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);
});
it("uses creation service", function () {
expect(creationService.createObject)
.toHaveBeenCalledWith(jasmine.any(Object), newParent);
expect(createObjectPromise.then)
.toHaveBeenCalledWith(jasmine.any(Function));
});
it("clears model composition", function () {
var newModel = creationService
.createObject
.mostRecentCall
.args[0];
expect(newModel.composition.length).toBe(0);
expect(newModel.name).toBe('some object');
});
it("recursively clones it's children", function () {
expect(creationService.createObject.calls.length).toBe(1);
expect(compositionCapability.invoke).toHaveBeenCalled();
compositionPromise.then.mostRecentCall.args[0]([childObject]);
expect(creationService.createObject.calls.length).toBe(2);
});
it("returns a promise", function () {
expect(copyResult.then).toBeDefined();
expect(copyFinished).toHaveBeenCalled();
});
});
});
});
}
);

View File

@ -0,0 +1,183 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,describe,beforeEach,it,jasmine,expect */
define(
[
'../../src/services/LinkService',
'../DomainObjectFactory'
],
function (LinkService, domainObjectFactory) {
"use strict";
describe("LinkService", function () {
var linkService,
mockPolicyService;
beforeEach(function () {
mockPolicyService = jasmine.createSpyObj(
'policyService',
['allow']
);
linkService = new LinkService(mockPolicyService);
});
describe("validate", function () {
var object,
parentCandidate,
validate;
beforeEach(function () {
object = domainObjectFactory({
name: 'object'
});
parentCandidate = domainObjectFactory({
name: 'parentCandidate'
});
validate = function () {
return linkService.validate(object, parentCandidate);
};
});
it("does not allow invalid parentCandidate", function () {
parentCandidate = undefined;
expect(validate()).toBe(false);
parentCandidate = {};
expect(validate()).toBe(false);
});
it("does not allow parent to be object", function () {
parentCandidate.id = object.id = 'abc';
expect(validate()).toBe(false);
});
it("does not allow parent that contains object", function () {
object.id = 'abc';
parentCandidate.id = 'xyz';
parentCandidate.model.composition = ['abc'];
expect(validate()).toBe(false);
});
describe("defers to policyService", function () {
beforeEach(function () {
object.id = 'abc';
object.capabilities.type = { type: 'object' };
parentCandidate.id = 'xyz';
parentCandidate.capabilities.type = {
type: 'parentCandidate'
};
parentCandidate.model.composition = [];
});
it("calls policy service with correct args", function () {
validate();
expect(mockPolicyService.allow).toHaveBeenCalledWith(
"composition",
parentCandidate.capabilities.type,
object.capabilities.type
);
});
it("and returns false", function () {
mockPolicyService.allow.andReturn(true);
expect(validate()).toBe(true);
expect(mockPolicyService.allow).toHaveBeenCalled();
});
it("and returns true", function () {
mockPolicyService.allow.andReturn(false);
expect(validate()).toBe(false);
expect(mockPolicyService.allow).toHaveBeenCalled();
});
});
});
describe("perform", function () {
var object,
parentModel,
parentObject,
mutationPromise,
persistenceCapability;
beforeEach(function () {
mutationPromise = jasmine.createSpyObj(
'promise',
['then']
);
persistenceCapability = jasmine.createSpyObj(
'persistenceCapability',
['persist']
);
parentModel = {
composition: []
};
parentObject = domainObjectFactory({
name: 'parentObject',
model: parentModel,
capabilities: {
mutation: {
invoke: function (mutator) {
mutator(parentModel);
return mutationPromise;
}
},
persistence: persistenceCapability
}
});
object = domainObjectFactory({
name: 'object',
id: 'xyz'
});
parentObject.getCapability.andReturn(persistenceCapability);
});
it("modifies parent model composition", function () {
expect(parentModel.composition.length).toBe(0);
linkService.perform(object, parentObject);
expect(parentObject.useCapability).toHaveBeenCalledWith(
'mutation',
jasmine.any(Function)
);
expect(parentModel.composition).toContain('xyz');
});
it("persists parent", function () {
linkService.perform(object, parentObject);
expect(mutationPromise.then).toHaveBeenCalled();
mutationPromise.then.calls[0].args[0]();
expect(parentObject.getCapability)
.toHaveBeenCalledWith('persistence');
expect(persistenceCapability.persist).toHaveBeenCalled();
});
});
});
}
);

View File

@ -0,0 +1,151 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,describe,beforeEach,it,jasmine,expect */
define(
[
'../../src/services/LocationService'
],
function (LocationService) {
"use strict";
describe("LocationService", function () {
var dialogService,
locationService,
dialogServicePromise,
chainedPromise;
beforeEach(function () {
dialogService = jasmine.createSpyObj(
'dialogService',
['getUserInput']
);
dialogServicePromise = jasmine.createSpyObj(
'dialogServicePromise',
['then']
);
chainedPromise = jasmine.createSpyObj(
'chainedPromise',
['then']
);
dialogServicePromise.then.andReturn(chainedPromise);
dialogService.getUserInput.andReturn(dialogServicePromise);
locationService = new LocationService(dialogService);
});
describe("getLocationFromUser", function () {
var title,
label,
validate,
initialLocation,
locationResult,
formStructure,
formState;
beforeEach(function () {
title = "Get a location to do something";
label = "a location";
validate = function () { return true; };
initialLocation = { key: "a key" };
locationResult = locationService.getLocationFromUser(
title,
label,
validate,
initialLocation
);
formStructure = dialogService
.getUserInput
.mostRecentCall
.args[0];
formState = dialogService
.getUserInput
.mostRecentCall
.args[1];
});
it("calls through to dialogService", function () {
expect(dialogService.getUserInput).toHaveBeenCalledWith(
jasmine.any(Object),
jasmine.any(Object)
);
expect(formStructure.name).toBe(title);
});
it("returns a promise", function () {
expect(locationResult.then).toBeDefined();
});
describe("formStructure", function () {
var locationSection,
inputRow;
beforeEach(function () {
locationSection = formStructure.sections[0];
inputRow = locationSection.rows[0];
});
it("has a location section", function () {
expect(locationSection).toBeDefined();
expect(locationSection.name).toBe('Location');
});
it("has a input row", function () {
expect(inputRow.control).toBe('locator');
expect(inputRow.key).toBe('location');
expect(inputRow.name).toBe(label);
expect(inputRow.validate).toBe(validate);
});
});
describe("formState", function () {
it("has an initial location", function () {
expect(formState.location).toBe(initialLocation);
});
});
describe("resolution of dialog service promise", function () {
var resolution,
resolver,
dialogResult,
selectedLocation;
beforeEach(function () {
resolver =
dialogServicePromise.then.mostRecentCall.args[0];
selectedLocation = { key: "i'm a location key" };
dialogResult = {
location: selectedLocation
};
resolution = resolver(dialogResult);
});
it("returns selectedLocation", function () {
expect(resolution).toBe(selectedLocation);
});
});
});
});
}
);

View File

@ -0,0 +1,99 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,jasmine */
define(
function () {
"use strict";
/**
* MockCopyService provides the same interface as the copyService,
* returning promises where it would normally do so. At it's core,
* it is a jasmine spy object, but it also tracks the promises it
* returns and provides shortcut methods for resolving those promises
* synchronously.
*
* Usage:
*
* ```javascript
* var copyService = new MockCopyService();
*
* // validate is a standard jasmine spy.
* copyService.validate.andReturn(true);
* var isValid = copyService.validate(object, parentCandidate);
* expect(isValid).toBe(true);
*
* // perform returns promises and tracks them.
* var whenCopied = jasmine.createSpy('whenCopied');
* copyService.perform(object, parentObject).then(whenCopied);
* expect(whenCopied).not.toHaveBeenCalled();
* copyService.perform.mostRecentCall.resolve('someArg');
* expect(whenCopied).toHaveBeenCalledWith('someArg');
* ```
*/
function MockCopyService() {
// track most recent call of a function,
// perform automatically returns
var mockCopyService = jasmine.createSpyObj(
'MockCopyService',
[
'validate',
'perform'
]
);
mockCopyService.perform.andCallFake(function () {
var performPromise,
callExtensions,
spy;
performPromise = jasmine.createSpyObj(
'performPromise',
['then']
);
callExtensions = {
promise: performPromise,
resolve: function (resolveWith) {
performPromise.then.calls.forEach(function (call) {
call.args[0](resolveWith);
});
}
};
spy = this.perform;
Object.keys(callExtensions).forEach(function (key) {
spy.mostRecentCall[key] = callExtensions[key];
spy.calls[spy.calls.length - 1][key] = callExtensions[key];
});
return performPromise;
});
return mockCopyService;
}
return MockCopyService;
}
);

View File

@ -0,0 +1,99 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,jasmine */
define(
function () {
"use strict";
/**
* MockLinkService provides the same interface as the linkService,
* returning promises where it would normally do so. At it's core,
* it is a jasmine spy object, but it also tracks the promises it
* returns and provides shortcut methods for resolving those promises
* synchronously.
*
* Usage:
*
* ```javascript
* var linkService = new MockLinkService();
*
* // validate is a standard jasmine spy.
* linkService.validate.andReturn(true);
* var isValid = linkService.validate(object, parentObject);
* expect(isValid).toBe(true);
*
* // perform returns promises and tracks them.
* var whenLinked = jasmine.createSpy('whenLinked');
* linkService.perform(object, parentObject).then(whenLinked);
* expect(whenLinked).not.toHaveBeenCalled();
* linkService.perform.mostRecentCall.resolve('someArg');
* expect(whenLinked).toHaveBeenCalledWith('someArg');
* ```
*/
function MockLinkService() {
// track most recent call of a function,
// perform automatically returns
var mockLinkService = jasmine.createSpyObj(
'MockLinkService',
[
'validate',
'perform'
]
);
mockLinkService.perform.andCallFake(function () {
var performPromise,
callExtensions,
spy;
performPromise = jasmine.createSpyObj(
'performPromise',
['then']
);
callExtensions = {
promise: performPromise,
resolve: function (resolveWith) {
performPromise.then.calls.forEach(function (call) {
call.args[0](resolveWith);
});
}
};
spy = this.perform;
Object.keys(callExtensions).forEach(function (key) {
spy.mostRecentCall[key] = callExtensions[key];
spy.calls[spy.calls.length - 1][key] = callExtensions[key];
});
return performPromise;
});
return mockLinkService;
}
return MockLinkService;
}
);

View File

@ -0,0 +1,99 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,jasmine */
define(
function () {
"use strict";
/**
* MockMoveService provides the same interface as the moveService,
* returning promises where it would normally do so. At it's core,
* it is a jasmine spy object, but it also tracks the promises it
* returns and provides shortcut methods for resolving those promises
* synchronously.
*
* Usage:
*
* ```javascript
* var moveService = new MockMoveService();
*
* // validate is a standard jasmine spy.
* moveService.validate.andReturn(true);
* var isValid = moveService.validate(object, parentCandidate);
* expect(isValid).toBe(true);
*
* // perform returns promises and tracks them.
* var whenCopied = jasmine.createSpy('whenCopied');
* moveService.perform(object, parentObject).then(whenCopied);
* expect(whenCopied).not.toHaveBeenCalled();
* moveService.perform.mostRecentCall.resolve('someArg');
* expect(whenCopied).toHaveBeenCalledWith('someArg');
* ```
*/
function MockMoveService() {
// track most recent call of a function,
// perform automatically returns
var mockMoveService = jasmine.createSpyObj(
'MockMoveService',
[
'validate',
'perform'
]
);
mockMoveService.perform.andCallFake(function () {
var performPromise,
callExtensions,
spy;
performPromise = jasmine.createSpyObj(
'performPromise',
['then']
);
callExtensions = {
promise: performPromise,
resolve: function (resolveWith) {
performPromise.then.calls.forEach(function (call) {
call.args[0](resolveWith);
});
}
};
spy = this.perform;
Object.keys(callExtensions).forEach(function (key) {
spy.mostRecentCall[key] = callExtensions[key];
spy.calls[spy.calls.length - 1][key] = callExtensions[key];
});
return performPromise;
});
return mockMoveService;
}
return MockMoveService;
}
);

View File

@ -0,0 +1,189 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define,describe,beforeEach,it,jasmine,expect */
define(
[
'../../src/services/MoveService',
'../services/MockLinkService',
'../DomainObjectFactory'
],
function (MoveService, MockLinkService, domainObjectFactory) {
"use strict";
describe("MoveService", function () {
var moveService,
policyService,
linkService;
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
['allow']
);
linkService = new MockLinkService();
moveService = new MoveService(policyService, linkService);
});
describe("validate", function () {
var object,
objectContextCapability,
currentParent,
parentCandidate,
validate;
beforeEach(function () {
objectContextCapability = jasmine.createSpyObj(
'objectContextCapability',
[
'getParent'
]
);
object = domainObjectFactory({
name: 'object',
id: 'a',
capabilities: {
context: objectContextCapability,
type: { type: 'object' }
}
});
currentParent = domainObjectFactory({
name: 'currentParent',
id: 'b'
});
objectContextCapability.getParent.andReturn(currentParent);
parentCandidate = domainObjectFactory({
name: 'parentCandidate',
model: { composition: [] },
id: 'c',
capabilities: {
type: { type: 'parentCandidate' }
}
});
validate = function () {
return moveService.validate(object, parentCandidate);
};
});
it("does not allow an invalid parent", function () {
parentCandidate = undefined;
expect(validate()).toBe(false);
parentCandidate = {};
expect(validate()).toBe(false);
});
it("does not allow moving to current parent", function () {
parentCandidate.id = currentParent.id = 'xyz';
expect(validate()).toBe(false);
});
it("does not allow moving to self", function () {
object.id = parentCandidate.id = 'xyz';
expect(validate()).toBe(false);
});
it("does not allow moving to the same location", function () {
object.id = 'abc';
parentCandidate.model.composition = ['abc'];
expect(validate()).toBe(false);
});
describe("defers to policyService", function () {
it("calls policy service with correct args", function () {
validate();
expect(policyService.allow).toHaveBeenCalledWith(
"composition",
parentCandidate.capabilities.type,
object.capabilities.type
);
});
it("and returns false", function () {
policyService.allow.andReturn(false);
expect(validate()).toBe(false);
});
it("and returns true", function () {
policyService.allow.andReturn(true);
expect(validate()).toBe(true);
});
});
});
describe("perform", function () {
var object,
parentObject,
actionCapability;
beforeEach(function () {
actionCapability = jasmine.createSpyObj(
'actionCapability',
['perform']
);
object = domainObjectFactory({
name: 'object',
capabilities: {
action: actionCapability
}
});
parentObject = domainObjectFactory({
name: 'parentObject'
});
moveService.perform(object, parentObject);
});
it("links object to parentObject", function () {
expect(linkService.perform).toHaveBeenCalledWith(
object,
parentObject
);
});
it("waits for result of link", function () {
expect(linkService.perform.mostRecentCall.promise.then)
.toHaveBeenCalledWith(jasmine.any(Function));
});
it("removes object when link is completed", function () {
linkService.perform.mostRecentCall.resolve();
expect(object.getCapability)
.toHaveBeenCalledWith('action');
expect(actionCapability.perform)
.toHaveBeenCalledWith('remove');
});
});
});
}
);

View File

@ -0,0 +1,9 @@
[
"actions/CopyAction",
"actions/LinkAction",
"actions/MoveAction",
"services/CopyService",
"services/LinkService",
"services/MoveService",
"services/LocationService"
]

View File

@ -8,6 +8,7 @@
"glyph": "6",
"templateUrl": "templates/plot.html",
"needs": [ "telemetry" ],
"priority": "preferred",
"delegation": true
}
],

View File

@ -108,7 +108,7 @@
<span class="ui-symbol icon">I</span>
</a>
<div class="menu-element btn icon-btn very-subtle btn-menu dropdown click-invoke"
<div class="menu-element btn s-very-subtle btn-menu dropdown menus-to-left"
ng-if="plot.getModeOptions().length > 1"
ng-controller="ClickAwayController as toggle">
@ -116,7 +116,7 @@
<span class="ui-symbol icon type-icon">{{plot.getMode().glyph}}</span>
<span>{{plot.getMode().name}}</span>
<span class='ui-symbol icon invoke-menu'>v</span>
<span class='ui-symbol invoke-menu'>v</span>
<div class="menu dropdown" ng-show="toggle.isActive()">
<ul>

View File

@ -1,21 +0,0 @@
{
"extensions": {
"types": [
{
"key": "static.markup",
"name": "Static Markup",
"glyph": "\u0070",
"description": "Static markup sandbox",
"features": [ "creation" ]
}
],
"views": [
{
"templateUrl": "markup.html",
"name": "Static Markup",
"type": "static.markup",
"key": "static.markup"
}
]
}
}

View File

@ -30,7 +30,7 @@
<span class="title-label" ng-if="structure.text">
{{structure.text}}
</span>
<span class='ui-symbol icon invoke-menu' ng-if="!structure.text">v</span>
<span class='ui-symbol invoke-menu' ng-if="!structure.text">v</span>
<div

View File

@ -28,7 +28,7 @@
<span class="title-label" ng-if="structure.text">
{{structure.text}}
</span>
<span class='ui-symbol icon invoke-menu'
<span class='ui-symbol invoke-menu'
ng-if="!structure.text">
v
</span>

View File

@ -84,6 +84,22 @@ define(
// Should have cleared out the time stamp
expect(mockScope.ngModel.test).toBeUndefined();
});
it("initializes form fields with values from ng-model", function () {
mockScope.ngModel = { test: 1417215313000 };
mockScope.field = "test";
mockScope.$watch.calls.forEach(function (call) {
if (call.args[0] === 'ngModel[field]') {
call.args[1](mockScope.ngModel.test);
}
});
expect(mockScope.datetime).toEqual({
date: "2014-332",
hour: "22",
min: "55",
sec: "13"
});
});
});
}
);
);

View File

@ -22,8 +22,8 @@
/*global define,moment*/
define(
['../lib/moment.min.js'],
function () {
['moment'],
function (moment) {
"use strict";
// Date format to use for domain values; in particular,

View File

@ -6,7 +6,7 @@
<groupId>gov.nasa.arc.wtd</groupId>
<artifactId>open-mct-web</artifactId>
<name>Open MCT Web</name>
<version>0.7.0-SNAPSHOT</version>
<version>0.7.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>