Merge branch 'master' into orphan-navigation-765
This commit is contained in:
4
.jscsrc
4
.jscsrc
@@ -1,3 +1,5 @@
|
|||||||
{
|
{
|
||||||
"preset": "crockford"
|
"preset": "crockford",
|
||||||
|
"requireMultipleVarDecl": false,
|
||||||
|
"requireVarDeclFirst": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"eqeqeq": true,
|
"eqeqeq": true,
|
||||||
"forin": true,
|
"forin": true,
|
||||||
"freeze": true,
|
"freeze": true,
|
||||||
"funcscope": true,
|
"funcscope": false,
|
||||||
"futurehostile": true,
|
"futurehostile": true,
|
||||||
"latedef": true,
|
"latedef": true,
|
||||||
"noarg": true,
|
"noarg": true,
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
"define",
|
"define",
|
||||||
"Promise"
|
"Promise"
|
||||||
],
|
],
|
||||||
|
"shadow": "outer",
|
||||||
"strict": "implied",
|
"strict": "implied",
|
||||||
"undef": true,
|
"undef": true,
|
||||||
"unused": "vars"
|
"unused": "vars"
|
||||||
|
|||||||
@@ -22,17 +22,19 @@
|
|||||||
#* at runtime from the About dialog for additional information.
|
#* at runtime from the About dialog for additional information.
|
||||||
#*****************************************************************************
|
#*****************************************************************************
|
||||||
|
|
||||||
# Script to build and deploy docs to github pages.
|
# Script to build and deploy docs.
|
||||||
|
|
||||||
OUTPUT_DIRECTORY="target/docs"
|
OUTPUT_DIRECTORY="target/docs"
|
||||||
REPOSITORY_URL="git@github.com:nasa/openmctweb.git"
|
# Docs, once built, are pushed to the private website repo
|
||||||
|
REPOSITORY_URL="git@github.com:nasa/openmct-website.git"
|
||||||
|
WEBSITE_DIRECTORY="website"
|
||||||
|
|
||||||
BUILD_SHA=`git rev-parse head`
|
BUILD_SHA=`git rev-parse HEAD`
|
||||||
|
|
||||||
# A remote will be created for the git repository we are pushing to.
|
# A remote will be created for the git repository we are pushing to.
|
||||||
# Don't worry, as this entire directory will get trashed inbetween builds.
|
# Don't worry, as this entire directory will get trashed inbetween builds.
|
||||||
REMOTE_NAME="documentation"
|
REMOTE_NAME="documentation"
|
||||||
WEBSITE_BRANCH="gh-pages"
|
WEBSITE_BRANCH="master"
|
||||||
|
|
||||||
# Clean output directory, JSDOC will recreate
|
# Clean output directory, JSDOC will recreate
|
||||||
if [ -d $OUTPUT_DIRECTORY ]; then
|
if [ -d $OUTPUT_DIRECTORY ]; then
|
||||||
@@ -40,23 +42,21 @@ if [ -d $OUTPUT_DIRECTORY ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
npm run docs
|
npm run docs
|
||||||
cd $OUTPUT_DIRECTORY || exit 1
|
|
||||||
|
|
||||||
echo "git init"
|
echo "git clone $REPOSITORY_URL website"
|
||||||
git init
|
git clone $REPOSITORY_URL website || exit 1
|
||||||
|
echo "cp -r $OUTPUT_DIRECTORY $WEBSITE_DIRECTORY/docs"
|
||||||
|
cp -r $OUTPUT_DIRECTORY $WEBSITE_DIRECTORY/docs
|
||||||
|
echo "cd $WEBSITE_DIRECTORY"
|
||||||
|
cd $WEBSITE_DIRECTORY || exit 1
|
||||||
|
|
||||||
# Configure github for CircleCI user.
|
# Configure github for CircleCI user.
|
||||||
git config user.email "buildbot@circleci.com"
|
git config user.email "buildbot@circleci.com"
|
||||||
git config user.name "BuildBot"
|
git config user.name "BuildBot"
|
||||||
|
|
||||||
echo "git remote add $REMOTE_NAME $REPOSITORY_URL"
|
|
||||||
git remote add $REMOTE_NAME $REPOSITORY_URL
|
|
||||||
echo "git add ."
|
echo "git add ."
|
||||||
git add .
|
git add .
|
||||||
echo "git commit -m \"Generate docs from build $BUILD_SHA\""
|
echo "git commit -m \"Docs updated from build $BUILD_SHA\""
|
||||||
git commit -m "Generate docs from build $BUILD_SHA"
|
git commit -m "Docs updated from build $BUILD_SHA"
|
||||||
|
# Push to the website repo
|
||||||
echo "git push $REMOTE_NAME HEAD:$WEBSITE_BRANCH -f"
|
git push
|
||||||
git push $REMOTE_NAME HEAD:$WEBSITE_BRANCH -f
|
|
||||||
|
|
||||||
echo "Documentation pushed to gh-pages branch."
|
|
||||||
|
|||||||
13
circle.yml
13
circle.yml
@@ -1,8 +1,11 @@
|
|||||||
deployment:
|
deployment:
|
||||||
production:
|
production:
|
||||||
branch: master
|
branch: master
|
||||||
heroku:
|
commands:
|
||||||
appname: openmctweb-demo
|
- npm install canvas nomnoml
|
||||||
|
- ./build-docs.sh
|
||||||
|
- git fetch --unshallow
|
||||||
|
- git push git@heroku.com:openmctweb-demo.git $CIRCLE_SHA1:refs/heads/master
|
||||||
openmct-demo:
|
openmct-demo:
|
||||||
branch: live_demo
|
branch: live_demo
|
||||||
heroku:
|
heroku:
|
||||||
@@ -14,3 +17,9 @@ deployment:
|
|||||||
test:
|
test:
|
||||||
post:
|
post:
|
||||||
- gulp lint
|
- gulp lint
|
||||||
|
- gulp checkstyle
|
||||||
|
|
||||||
|
general:
|
||||||
|
branches:
|
||||||
|
ignore:
|
||||||
|
- gh-pages
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -45,11 +45,12 @@ define(
|
|||||||
function buildTaxonomy(dictionary){
|
function buildTaxonomy(dictionary){
|
||||||
var models = {};
|
var models = {};
|
||||||
|
|
||||||
function addMeasurement(measurement){
|
function addMeasurement(measurement, parent){
|
||||||
var format = FORMAT_MAPPINGS[measurement.type];
|
var format = FORMAT_MAPPINGS[measurement.type];
|
||||||
models[makeId(measurement)] = {
|
models[makeId(measurement)] = {
|
||||||
type: "msl.measurement",
|
type: "msl.measurement",
|
||||||
name: measurement.name,
|
name: measurement.name,
|
||||||
|
location: parent,
|
||||||
telemetry: {
|
telemetry: {
|
||||||
key: measurement.identifier,
|
key: measurement.identifier,
|
||||||
ranges: [{
|
ranges: [{
|
||||||
@@ -62,17 +63,24 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function addInstrument(subsystem) {
|
function addInstrument(subsystem, spacecraftId) {
|
||||||
var measurements = (subsystem.measurements || []);
|
var measurements = (subsystem.measurements || []),
|
||||||
models[makeId(subsystem)] = {
|
instrumentId = makeId(subsystem);
|
||||||
|
|
||||||
|
models[instrumentId] = {
|
||||||
type: "msl.instrument",
|
type: "msl.instrument",
|
||||||
name: subsystem.name,
|
name: subsystem.name,
|
||||||
|
location: spacecraftId,
|
||||||
composition: measurements.map(makeId)
|
composition: measurements.map(makeId)
|
||||||
};
|
};
|
||||||
measurements.forEach(addMeasurement);
|
measurements.forEach(function(measurement) {
|
||||||
|
addMeasurement(measurement, instrumentId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
(dictionary.instruments || []).forEach(addInstrument);
|
(dictionary.instruments || []).forEach(function(instrument) {
|
||||||
|
addInstrument(instrument, "msl:curiosity");
|
||||||
|
});
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,6 @@ gulp.task('develop', ['serve', 'stylesheets', 'watch']);
|
|||||||
|
|
||||||
gulp.task('install', [ 'static', 'scripts' ]);
|
gulp.task('install', [ 'static', 'scripts' ]);
|
||||||
|
|
||||||
gulp.task('verify', [ 'lint', 'test' ]);
|
gulp.task('verify', [ 'lint', 'test', 'checkstyle' ]);
|
||||||
|
|
||||||
gulp.task('build', [ 'verify', 'install' ]);
|
gulp.task('build', [ 'verify', 'install' ]);
|
||||||
|
|||||||
@@ -24,24 +24,15 @@ define([
|
|||||||
"./src/BrowseController",
|
"./src/BrowseController",
|
||||||
"./src/PaneController",
|
"./src/PaneController",
|
||||||
"./src/BrowseObjectController",
|
"./src/BrowseObjectController",
|
||||||
"./src/creation/CreateMenuController",
|
|
||||||
"./src/creation/LocatorController",
|
|
||||||
"./src/MenuArrowController",
|
"./src/MenuArrowController",
|
||||||
"./src/navigation/NavigationService",
|
"./src/navigation/NavigationService",
|
||||||
"./src/creation/CreationPolicy",
|
|
||||||
"./src/navigation/NavigateAction",
|
"./src/navigation/NavigateAction",
|
||||||
"./src/navigation/OrphanNavigationHandler",
|
"./src/navigation/OrphanNavigationHandler",
|
||||||
"./src/windowing/NewTabAction",
|
"./src/windowing/NewTabAction",
|
||||||
"./src/windowing/FullscreenAction",
|
"./src/windowing/FullscreenAction",
|
||||||
"./src/creation/CreateActionProvider",
|
|
||||||
"./src/creation/AddActionProvider",
|
|
||||||
"./src/creation/CreationService",
|
|
||||||
"./src/windowing/WindowTitler",
|
"./src/windowing/WindowTitler",
|
||||||
"text!./res/templates/browse.html",
|
"text!./res/templates/browse.html",
|
||||||
"text!./res/templates/create/locator.html",
|
|
||||||
"text!./res/templates/browse-object.html",
|
"text!./res/templates/browse-object.html",
|
||||||
"text!./res/templates/create/create-button.html",
|
|
||||||
"text!./res/templates/create/create-menu.html",
|
|
||||||
"text!./res/templates/items/grid-item.html",
|
"text!./res/templates/items/grid-item.html",
|
||||||
"text!./res/templates/browse/object-header.html",
|
"text!./res/templates/browse/object-header.html",
|
||||||
"text!./res/templates/menu-arrow.html",
|
"text!./res/templates/menu-arrow.html",
|
||||||
@@ -54,24 +45,15 @@ define([
|
|||||||
BrowseController,
|
BrowseController,
|
||||||
PaneController,
|
PaneController,
|
||||||
BrowseObjectController,
|
BrowseObjectController,
|
||||||
CreateMenuController,
|
|
||||||
LocatorController,
|
|
||||||
MenuArrowController,
|
MenuArrowController,
|
||||||
NavigationService,
|
NavigationService,
|
||||||
CreationPolicy,
|
|
||||||
NavigateAction,
|
NavigateAction,
|
||||||
OrphanNavigationHandler,
|
OrphanNavigationHandler,
|
||||||
NewTabAction,
|
NewTabAction,
|
||||||
FullscreenAction,
|
FullscreenAction,
|
||||||
CreateActionProvider,
|
|
||||||
AddActionProvider,
|
|
||||||
CreationService,
|
|
||||||
WindowTitler,
|
WindowTitler,
|
||||||
browseTemplate,
|
browseTemplate,
|
||||||
locatorTemplate,
|
|
||||||
browseObjectTemplate,
|
browseObjectTemplate,
|
||||||
createButtonTemplate,
|
|
||||||
createMenuTemplate,
|
|
||||||
gridItemTemplate,
|
gridItemTemplate,
|
||||||
objectHeaderTemplate,
|
objectHeaderTemplate,
|
||||||
menuArrowTemplate,
|
menuArrowTemplate,
|
||||||
@@ -138,22 +120,6 @@ define([
|
|||||||
"$route"
|
"$route"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"key": "CreateMenuController",
|
|
||||||
"implementation": CreateMenuController,
|
|
||||||
"depends": [
|
|
||||||
"$scope"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "LocatorController",
|
|
||||||
"implementation": LocatorController,
|
|
||||||
"depends": [
|
|
||||||
"$scope",
|
|
||||||
"$timeout",
|
|
||||||
"objectService"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"key": "MenuArrowController",
|
"key": "MenuArrowController",
|
||||||
"implementation": MenuArrowController,
|
"implementation": MenuArrowController,
|
||||||
@@ -162,12 +128,6 @@ define([
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"controls": [
|
|
||||||
{
|
|
||||||
"key": "locator",
|
|
||||||
"template": locatorTemplate
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"representations": [
|
"representations": [
|
||||||
{
|
{
|
||||||
"key": "view-object",
|
"key": "view-object",
|
||||||
@@ -183,17 +143,6 @@ define([
|
|||||||
"view"
|
"view"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"key": "create-button",
|
|
||||||
"template": createButtonTemplate
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "create-menu",
|
|
||||||
"template": createMenuTemplate,
|
|
||||||
"uses": [
|
|
||||||
"action"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"key": "grid-item",
|
"key": "grid-item",
|
||||||
"template": gridItemTemplate,
|
"template": gridItemTemplate,
|
||||||
@@ -246,12 +195,6 @@ define([
|
|||||||
"implementation": NavigationService
|
"implementation": NavigationService
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"policies": [
|
|
||||||
{
|
|
||||||
"implementation": CreationPolicy,
|
|
||||||
"category": "creation"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"key": "navigate",
|
"key": "navigate",
|
||||||
@@ -304,42 +247,6 @@ define([
|
|||||||
"editable": false
|
"editable": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"key": "CreateActionProvider",
|
|
||||||
"provides": "actionService",
|
|
||||||
"type": "provider",
|
|
||||||
"implementation": CreateActionProvider,
|
|
||||||
"depends": [
|
|
||||||
"$q",
|
|
||||||
"typeService",
|
|
||||||
"navigationService",
|
|
||||||
"policyService"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "AddActionProvider",
|
|
||||||
"provides": "actionService",
|
|
||||||
"type": "provider",
|
|
||||||
"implementation": AddActionProvider,
|
|
||||||
"depends": [
|
|
||||||
"$q",
|
|
||||||
"typeService",
|
|
||||||
"dialogService",
|
|
||||||
"policyService"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "CreationService",
|
|
||||||
"provides": "creationService",
|
|
||||||
"type": "provider",
|
|
||||||
"implementation": CreationService,
|
|
||||||
"depends": [
|
|
||||||
"$q",
|
|
||||||
"$log"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"runs": [
|
"runs": [
|
||||||
{
|
{
|
||||||
"implementation": WindowTitler,
|
"implementation": WindowTitler,
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
/*****************************************************************************
|
|
||||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
|
||||||
* as represented by the Administrator of the National Aeronautics and Space
|
|
||||||
* Administration. All rights reserved.
|
|
||||||
*
|
|
||||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
* Open MCT Web includes source code licensed under additional open source
|
|
||||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
|
||||||
* this source code distribution or the Licensing information page available
|
|
||||||
* at runtime from the About dialog for additional information.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
|
|
||||||
*/
|
|
||||||
define(
|
|
||||||
["../../src/creation/CreateAction"],
|
|
||||||
function (CreateAction) {
|
|
||||||
|
|
||||||
describe("The create action", function () {
|
|
||||||
var mockType,
|
|
||||||
mockParent,
|
|
||||||
mockContext,
|
|
||||||
mockDialogService,
|
|
||||||
mockCreationService,
|
|
||||||
action;
|
|
||||||
|
|
||||||
function mockPromise(value) {
|
|
||||||
return {
|
|
||||||
then: function (callback) {
|
|
||||||
return mockPromise(callback(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
mockType = jasmine.createSpyObj(
|
|
||||||
"type",
|
|
||||||
[
|
|
||||||
"getKey",
|
|
||||||
"getGlyph",
|
|
||||||
"getName",
|
|
||||||
"getDescription",
|
|
||||||
"getProperties",
|
|
||||||
"getInitialModel"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
mockParent = jasmine.createSpyObj(
|
|
||||||
"domainObject",
|
|
||||||
[
|
|
||||||
"getId",
|
|
||||||
"getModel",
|
|
||||||
"getCapability"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
mockContext = {
|
|
||||||
domainObject: mockParent
|
|
||||||
};
|
|
||||||
mockDialogService = jasmine.createSpyObj(
|
|
||||||
"dialogService",
|
|
||||||
[ "getUserInput" ]
|
|
||||||
);
|
|
||||||
mockCreationService = jasmine.createSpyObj(
|
|
||||||
"creationService",
|
|
||||||
[ "createObject" ]
|
|
||||||
);
|
|
||||||
|
|
||||||
mockType.getKey.andReturn("test");
|
|
||||||
mockType.getGlyph.andReturn("T");
|
|
||||||
mockType.getDescription.andReturn("a test type");
|
|
||||||
mockType.getName.andReturn("Test");
|
|
||||||
mockType.getProperties.andReturn([]);
|
|
||||||
mockType.getInitialModel.andReturn({});
|
|
||||||
|
|
||||||
mockDialogService.getUserInput.andReturn(mockPromise({}));
|
|
||||||
|
|
||||||
action = new CreateAction(
|
|
||||||
mockType,
|
|
||||||
mockParent,
|
|
||||||
mockContext,
|
|
||||||
mockDialogService,
|
|
||||||
mockCreationService
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("exposes type-appropriate metadata", function () {
|
|
||||||
var metadata = action.getMetadata();
|
|
||||||
|
|
||||||
expect(metadata.name).toEqual("Test");
|
|
||||||
expect(metadata.description).toEqual("a test type");
|
|
||||||
expect(metadata.glyph).toEqual("T");
|
|
||||||
});
|
|
||||||
|
|
||||||
//TODO: Disabled for NEM Beta
|
|
||||||
xit("invokes the creation service when performed", function () {
|
|
||||||
action.perform();
|
|
||||||
expect(mockCreationService.createObject).toHaveBeenCalledWith(
|
|
||||||
{ type: "test" },
|
|
||||||
mockParent
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
//TODO: Disabled for NEM Beta
|
|
||||||
xit("does not create an object if the user cancels", function () {
|
|
||||||
mockDialogService.getUserInput.andReturn({
|
|
||||||
then: function (callback, fail) {
|
|
||||||
fail();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
action.perform();
|
|
||||||
|
|
||||||
expect(mockCreationService.createObject)
|
|
||||||
.not.toHaveBeenCalled();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@@ -26,7 +26,7 @@ define([
|
|||||||
"./src/controllers/ElementsController",
|
"./src/controllers/ElementsController",
|
||||||
"./src/controllers/EditObjectController",
|
"./src/controllers/EditObjectController",
|
||||||
"./src/directives/MCTBeforeUnload",
|
"./src/directives/MCTBeforeUnload",
|
||||||
"./src/actions/LinkAction",
|
"./src/actions/EditAndComposeAction",
|
||||||
"./src/actions/EditAction",
|
"./src/actions/EditAction",
|
||||||
"./src/actions/PropertiesAction",
|
"./src/actions/PropertiesAction",
|
||||||
"./src/actions/RemoveAction",
|
"./src/actions/RemoveAction",
|
||||||
@@ -43,6 +43,15 @@ define([
|
|||||||
"./src/capabilities/EditorCapability",
|
"./src/capabilities/EditorCapability",
|
||||||
"./src/capabilities/TransactionCapabilityDecorator",
|
"./src/capabilities/TransactionCapabilityDecorator",
|
||||||
"./src/services/TransactionService",
|
"./src/services/TransactionService",
|
||||||
|
"./src/creation/CreateMenuController",
|
||||||
|
"./src/creation/LocatorController",
|
||||||
|
"./src/creation/CreationPolicy",
|
||||||
|
"./src/creation/CreateActionProvider",
|
||||||
|
"./src/creation/AddActionProvider",
|
||||||
|
"./src/creation/CreationService",
|
||||||
|
"text!./res/templates/create/locator.html",
|
||||||
|
"text!./res/templates/create/create-button.html",
|
||||||
|
"text!./res/templates/create/create-menu.html",
|
||||||
"text!./res/templates/library.html",
|
"text!./res/templates/library.html",
|
||||||
"text!./res/templates/edit-object.html",
|
"text!./res/templates/edit-object.html",
|
||||||
"text!./res/templates/edit-action-buttons.html",
|
"text!./res/templates/edit-action-buttons.html",
|
||||||
@@ -55,7 +64,7 @@ define([
|
|||||||
ElementsController,
|
ElementsController,
|
||||||
EditObjectController,
|
EditObjectController,
|
||||||
MCTBeforeUnload,
|
MCTBeforeUnload,
|
||||||
LinkAction,
|
EditAndComposeAction,
|
||||||
EditAction,
|
EditAction,
|
||||||
PropertiesAction,
|
PropertiesAction,
|
||||||
RemoveAction,
|
RemoveAction,
|
||||||
@@ -72,6 +81,15 @@ define([
|
|||||||
EditorCapability,
|
EditorCapability,
|
||||||
TransactionCapabilityDecorator,
|
TransactionCapabilityDecorator,
|
||||||
TransactionService,
|
TransactionService,
|
||||||
|
CreateMenuController,
|
||||||
|
LocatorController,
|
||||||
|
CreationPolicy,
|
||||||
|
CreateActionProvider,
|
||||||
|
AddActionProvider,
|
||||||
|
CreationService,
|
||||||
|
locatorTemplate,
|
||||||
|
createButtonTemplate,
|
||||||
|
createMenuTemplate,
|
||||||
libraryTemplate,
|
libraryTemplate,
|
||||||
editObjectTemplate,
|
editObjectTemplate,
|
||||||
editActionButtonsTemplate,
|
editActionButtonsTemplate,
|
||||||
@@ -112,6 +130,22 @@ define([
|
|||||||
"$location",
|
"$location",
|
||||||
"policyService"
|
"policyService"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "CreateMenuController",
|
||||||
|
"implementation": CreateMenuController,
|
||||||
|
"depends": [
|
||||||
|
"$scope"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "LocatorController",
|
||||||
|
"implementation": LocatorController,
|
||||||
|
"depends": [
|
||||||
|
"$scope",
|
||||||
|
"$timeout",
|
||||||
|
"objectService"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"directives": [
|
"directives": [
|
||||||
@@ -126,7 +160,7 @@ define([
|
|||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"key": "compose",
|
"key": "compose",
|
||||||
"implementation": LinkAction
|
"implementation": EditAndComposeAction
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "edit",
|
"key": "edit",
|
||||||
@@ -221,8 +255,11 @@ define([
|
|||||||
"category": "navigation",
|
"category": "navigation",
|
||||||
"message": "There are unsaved changes.",
|
"message": "There are unsaved changes.",
|
||||||
"implementation": EditNavigationPolicy
|
"implementation": EditNavigationPolicy
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"implementation": CreationPolicy,
|
||||||
|
"category": "creation"
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
"templates": [
|
"templates": [
|
||||||
{
|
{
|
||||||
@@ -261,6 +298,17 @@ define([
|
|||||||
{
|
{
|
||||||
"key": "topbar-edit",
|
"key": "topbar-edit",
|
||||||
"template": topbarEditTemplate
|
"template": topbarEditTemplate
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "create-button",
|
||||||
|
"template": createButtonTemplate
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "create-menu",
|
||||||
|
"template": createMenuTemplate,
|
||||||
|
"uses": [
|
||||||
|
"action"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"components": [
|
"components": [
|
||||||
@@ -282,7 +330,40 @@ define([
|
|||||||
"$q",
|
"$q",
|
||||||
"$log"
|
"$log"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "CreateActionProvider",
|
||||||
|
"provides": "actionService",
|
||||||
|
"type": "provider",
|
||||||
|
"implementation": CreateActionProvider,
|
||||||
|
"depends": [
|
||||||
|
"typeService",
|
||||||
|
"policyService"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "AddActionProvider",
|
||||||
|
"provides": "actionService",
|
||||||
|
"type": "provider",
|
||||||
|
"implementation": AddActionProvider,
|
||||||
|
"depends": [
|
||||||
|
"$q",
|
||||||
|
"typeService",
|
||||||
|
"dialogService",
|
||||||
|
"policyService"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "CreationService",
|
||||||
|
"provides": "creationService",
|
||||||
|
"type": "provider",
|
||||||
|
"implementation": CreationService,
|
||||||
|
"depends": [
|
||||||
|
"$q",
|
||||||
|
"$log"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
"representers": [
|
"representers": [
|
||||||
{
|
{
|
||||||
@@ -317,6 +398,12 @@ define([
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"controls": [
|
||||||
|
{
|
||||||
|
"key": "locator",
|
||||||
|
"template": locatorTemplate
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,6 +74,12 @@ define(
|
|||||||
self.domainObject.getCapability('editor').cancel();
|
self.domainObject.getCapability('editor').cancel();
|
||||||
self.navigationService.removeListener(cancelEditing);
|
self.navigationService.removeListener(cancelEditing);
|
||||||
}
|
}
|
||||||
|
//If this is not the currently navigated object, then navigate
|
||||||
|
// to it.
|
||||||
|
if (this.navigationService.getNavigation() !== this.domainObject) {
|
||||||
|
this.navigationService.setNavigation(this.domainObject);
|
||||||
|
}
|
||||||
|
|
||||||
this.navigationService.addListener(cancelEditing);
|
this.navigationService.addListener(cancelEditing);
|
||||||
this.domainObject.useCapability("editor");
|
this.domainObject.useCapability("editor");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,13 +31,14 @@ define(
|
|||||||
* @memberof platform/commonUI/edit
|
* @memberof platform/commonUI/edit
|
||||||
* @implements {Action}
|
* @implements {Action}
|
||||||
*/
|
*/
|
||||||
function LinkAction(context) {
|
function EditAndComposeAction(context) {
|
||||||
this.domainObject = (context || {}).domainObject;
|
this.domainObject = (context || {}).domainObject;
|
||||||
this.selectedObject = (context || {}).selectedObject;
|
this.selectedObject = (context || {}).selectedObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkAction.prototype.perform = function () {
|
EditAndComposeAction.prototype.perform = function () {
|
||||||
var self = this;
|
var self = this,
|
||||||
|
editAction = this.domainObject.getCapability('action').getActions("edit")[0];
|
||||||
|
|
||||||
// Persist changes to the domain object
|
// Persist changes to the domain object
|
||||||
function doPersist() {
|
function doPersist() {
|
||||||
@@ -54,9 +55,13 @@ define(
|
|||||||
.then(doPersist);
|
.then(doPersist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (editAction) {
|
||||||
|
editAction.perform();
|
||||||
|
}
|
||||||
|
|
||||||
return this.selectedObject && doLink();
|
return this.selectedObject && doLink();
|
||||||
};
|
};
|
||||||
|
|
||||||
return LinkAction;
|
return EditAndComposeAction;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -63,10 +63,10 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showDialog(type) {
|
function showDialog(objType) {
|
||||||
// Create a dialog object to generate the form structure, etc.
|
// Create a dialog object to generate the form structure, etc.
|
||||||
var dialog =
|
var dialog =
|
||||||
new PropertiesDialog(type, domainObject.getModel());
|
new PropertiesDialog(objType, domainObject.getModel());
|
||||||
|
|
||||||
// Show the dialog
|
// Show the dialog
|
||||||
return dialogService.getUserInput(
|
return dialogService.getUserInput(
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ define(
|
|||||||
* Invoke persistence on a domain object. This will be called upon
|
* Invoke persistence on a domain object. This will be called upon
|
||||||
* the removed object's parent (as its composition will have changed.)
|
* the removed object's parent (as its composition will have changed.)
|
||||||
*/
|
*/
|
||||||
function doPersist(domainObject) {
|
function doPersist(domainObj) {
|
||||||
var persistence = domainObject.getCapability('persistence');
|
var persistence = domainObj.getCapability('persistence');
|
||||||
return persistence && persistence.persist();
|
return persistence && persistence.persist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['../../../browse/src/creation/CreateWizard'],
|
['../creation/CreateWizard'],
|
||||||
function (CreateWizard) {
|
function (CreateWizard) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,11 +43,8 @@ define(
|
|||||||
* override this)
|
* override this)
|
||||||
* @param {ActionContext} context the context in which the
|
* @param {ActionContext} context the context in which the
|
||||||
* action is being performed
|
* action is being performed
|
||||||
* @param {NavigationService} navigationService the navigation service,
|
|
||||||
* which handles changes in navigation. It allows the object
|
|
||||||
* being browsed/edited to be set.
|
|
||||||
*/
|
*/
|
||||||
function CreateAction(type, parent, context, $q, navigationService) {
|
function CreateAction(type, parent, context) {
|
||||||
this.metadata = {
|
this.metadata = {
|
||||||
key: 'create',
|
key: 'create',
|
||||||
glyph: type.getGlyph(),
|
glyph: type.getGlyph(),
|
||||||
@@ -56,24 +53,8 @@ define(
|
|||||||
description: type.getDescription(),
|
description: type.getDescription(),
|
||||||
context: context
|
context: context
|
||||||
};
|
};
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.navigationService = navigationService;
|
|
||||||
this.$q = $q;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a count of views which are not flagged as non-editable.
|
|
||||||
function countEditableViews(domainObject) {
|
|
||||||
var views = domainObject && domainObject.useCapability('view'),
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
// A view is editable unless explicitly flagged as not
|
|
||||||
(views || []).forEach(function (view) {
|
|
||||||
count += (view.editable !== false) ? 1 : 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,26 +63,31 @@ define(
|
|||||||
*/
|
*/
|
||||||
CreateAction.prototype.perform = function () {
|
CreateAction.prototype.perform = function () {
|
||||||
var newModel = this.type.getInitialModel(),
|
var newModel = this.type.getInitialModel(),
|
||||||
parentObject = this.navigationService.getNavigation(),
|
newObject,
|
||||||
editorCapability,
|
editAction,
|
||||||
newObject;
|
editorCapability;
|
||||||
|
|
||||||
|
function onSave() {
|
||||||
|
return editorCapability.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCancel() {
|
||||||
|
return editorCapability.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
newModel.type = this.type.getKey();
|
newModel.type = this.type.getKey();
|
||||||
newModel.location = parentObject.getId();
|
newModel.location = this.parent.getId();
|
||||||
newObject = parentObject.useCapability('instantiation', newModel);
|
newObject = this.parent.useCapability('instantiation', newModel);
|
||||||
|
editorCapability = newObject.hasCapability('editor') && newObject.getCapability("editor");
|
||||||
|
|
||||||
editorCapability = newObject.getCapability("editor");
|
editAction = newObject.getCapability("action").getActions("edit")[0];
|
||||||
|
//If an edit action is available, perform it
|
||||||
if (countEditableViews(newObject) > 0 && newObject.hasCapability('composition')) {
|
if (editAction) {
|
||||||
this.navigationService.setNavigation(newObject);
|
return editAction.perform();
|
||||||
return newObject.getCapability("action").perform("edit");
|
} else if (editorCapability) {
|
||||||
} else {
|
//otherwise, use the save action
|
||||||
editorCapability.edit();
|
editorCapability.edit();
|
||||||
return newObject.useCapability("action").perform("save").then(function () {
|
return newObject.getCapability("action").perform("save").then(onSave, onCancel);
|
||||||
return editorCapability.save();
|
|
||||||
}, function () {
|
|
||||||
return editorCapability.cancel();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,10 +44,8 @@ define(
|
|||||||
* introduced in this bundle), responsible for handling actual
|
* introduced in this bundle), responsible for handling actual
|
||||||
* object creation.
|
* object creation.
|
||||||
*/
|
*/
|
||||||
function CreateActionProvider($q, typeService, navigationService, policyService) {
|
function CreateActionProvider(typeService, policyService) {
|
||||||
this.typeService = typeService;
|
this.typeService = typeService;
|
||||||
this.navigationService = navigationService;
|
|
||||||
this.$q = $q;
|
|
||||||
this.policyService = policyService;
|
this.policyService = policyService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +70,7 @@ define(
|
|||||||
return new CreateAction(
|
return new CreateAction(
|
||||||
type,
|
type,
|
||||||
destination,
|
destination,
|
||||||
context,
|
context
|
||||||
self.$q,
|
|
||||||
self.navigationService
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -56,7 +56,10 @@ define(
|
|||||||
// A view is editable unless explicitly flagged as not
|
// A view is editable unless explicitly flagged as not
|
||||||
(views || []).forEach(function (view) {
|
(views || []).forEach(function (view) {
|
||||||
if (view.editable === true ||
|
if (view.editable === true ||
|
||||||
(view.key === 'plot' && type.getKey() === 'telemetry.panel')) {
|
(view.key === 'plot' && type.getKey() === 'telemetry.panel') ||
|
||||||
|
(view.key === 'table' && type.getKey() === 'table') ||
|
||||||
|
(view.key === 'rt-table' && type.getKey() === 'rttable')
|
||||||
|
) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -81,18 +84,15 @@ define(
|
|||||||
var key = action.getMetadata().key,
|
var key = action.getMetadata().key,
|
||||||
category = (context || {}).category;
|
category = (context || {}).category;
|
||||||
|
|
||||||
// Only worry about actions in the view-control category
|
|
||||||
if (category === 'view-control') {
|
|
||||||
// Restrict 'edit' to cases where there are editable
|
// Restrict 'edit' to cases where there are editable
|
||||||
// views (similarly, restrict 'properties' to when
|
// views (similarly, restrict 'properties' to when
|
||||||
// the converse is true), and where the domain object is not
|
// the converse is true), and where the domain object is not
|
||||||
// already being edited.
|
// already being edited.
|
||||||
if (key === 'edit') {
|
if (key === 'edit') {
|
||||||
return this.countEditableViews(context) > 0 && !isEditing(context);
|
return this.countEditableViews(context) > 0 && !isEditing(context);
|
||||||
} else if (key === 'properties') {
|
} else if (key === 'properties' && category === 'view-control') {
|
||||||
return this.countEditableViews(context) < 1 && !isEditing(context);
|
return this.countEditableViews(context) < 1 && !isEditing(context);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Like all policies, allow by default.
|
// Like all policies, allow by default.
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -91,14 +91,8 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setEditable(editableDomainObject) {
|
|
||||||
self.domainObject = editableDomainObject;
|
|
||||||
scope.model = editableDomainObject.getModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Place the "commit" method in the scope
|
// Place the "commit" method in the scope
|
||||||
scope.commit = commit;
|
scope.commit = commit;
|
||||||
scope.setEditable = setEditable;
|
|
||||||
|
|
||||||
// Clean up when the scope is destroyed
|
// Clean up when the scope is destroyed
|
||||||
scope.$on("$destroy", function () {
|
scope.$on("$destroy", function () {
|
||||||
|
|||||||
@@ -24,8 +24,12 @@ define(
|
|||||||
function () {
|
function () {
|
||||||
|
|
||||||
// Utility functions for reducing truth arrays
|
// Utility functions for reducing truth arrays
|
||||||
function and(a, b) { return a && b; }
|
function and(a, b) {
|
||||||
function or(a, b) { return a || b; }
|
return a && b;
|
||||||
|
}
|
||||||
|
function or(a, b) {
|
||||||
|
return a || b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,7 +223,7 @@ define(
|
|||||||
|
|
||||||
// Update value for this property in all elements of the
|
// Update value for this property in all elements of the
|
||||||
// selection which have this property.
|
// selection which have this property.
|
||||||
function updateProperties(property, value) {
|
function updateProperties(property, val) {
|
||||||
var changed = false;
|
var changed = false;
|
||||||
|
|
||||||
// Update property in a selected element
|
// Update property in a selected element
|
||||||
@@ -229,12 +233,12 @@ define(
|
|||||||
// Check if this is a setter, or just assignable
|
// Check if this is a setter, or just assignable
|
||||||
if (typeof selected[property] === 'function') {
|
if (typeof selected[property] === 'function') {
|
||||||
changed =
|
changed =
|
||||||
changed || (selected[property]() !== value);
|
changed || (selected[property]() !== val);
|
||||||
selected[property](value);
|
selected[property](val);
|
||||||
} else {
|
} else {
|
||||||
changed =
|
changed =
|
||||||
changed || (selected[property] !== value);
|
changed || (selected[property] !== val);
|
||||||
selected[property] = value;
|
selected[property] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,11 +133,11 @@ define(
|
|||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
// Initialize toolbar (expose object to parent scope)
|
// Initialize toolbar (expose object to parent scope)
|
||||||
function initialize(definition) {
|
function initialize(def) {
|
||||||
// If we have been asked to expose toolbar state...
|
// If we have been asked to expose toolbar state...
|
||||||
if (self.attrs.toolbar) {
|
if (self.attrs.toolbar) {
|
||||||
// Initialize toolbar object
|
// Initialize toolbar object
|
||||||
self.toolbar = new EditToolbar(definition, self.commit);
|
self.toolbar = new EditToolbar(def, self.commit);
|
||||||
// Ensure toolbar state is exposed
|
// Ensure toolbar state is exposed
|
||||||
self.exposeToolbar();
|
self.exposeToolbar();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
["../../src/actions/LinkAction"],
|
["../../src/actions/EditAndComposeAction"],
|
||||||
function (LinkAction) {
|
function (EditAndComposeAction) {
|
||||||
|
|
||||||
describe("The Link action", function () {
|
describe("The Link action", function () {
|
||||||
var mockQ,
|
var mockQ,
|
||||||
@@ -31,6 +31,8 @@ define(
|
|||||||
mockContext,
|
mockContext,
|
||||||
mockComposition,
|
mockComposition,
|
||||||
mockPersistence,
|
mockPersistence,
|
||||||
|
mockActionCapability,
|
||||||
|
mockEditAction,
|
||||||
mockType,
|
mockType,
|
||||||
actionContext,
|
actionContext,
|
||||||
model,
|
model,
|
||||||
@@ -67,18 +69,23 @@ define(
|
|||||||
mockContext = jasmine.createSpyObj("context", ["getParent"]);
|
mockContext = jasmine.createSpyObj("context", ["getParent"]);
|
||||||
mockComposition = jasmine.createSpyObj("composition", ["invoke", "add"]);
|
mockComposition = jasmine.createSpyObj("composition", ["invoke", "add"]);
|
||||||
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
|
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
|
||||||
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
|
mockType = jasmine.createSpyObj("type", ["hasFeature", "getKey"]);
|
||||||
|
mockActionCapability = jasmine.createSpyObj("actionCapability", ["getActions"]);
|
||||||
|
mockEditAction = jasmine.createSpyObj("editAction", ["perform"]);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn("test");
|
mockDomainObject.getId.andReturn("test");
|
||||||
mockDomainObject.getCapability.andReturn(mockContext);
|
mockDomainObject.getCapability.andReturn(mockContext);
|
||||||
mockContext.getParent.andReturn(mockParent);
|
mockContext.getParent.andReturn(mockParent);
|
||||||
mockType.hasFeature.andReturn(true);
|
mockType.hasFeature.andReturn(true);
|
||||||
|
mockType.getKey.andReturn("layout");
|
||||||
mockComposition.invoke.andReturn(mockPromise(true));
|
mockComposition.invoke.andReturn(mockPromise(true));
|
||||||
mockComposition.add.andReturn(mockPromise(true));
|
mockComposition.add.andReturn(mockPromise(true));
|
||||||
|
mockActionCapability.getActions.andReturn([]);
|
||||||
|
|
||||||
capabilities = {
|
capabilities = {
|
||||||
composition: mockComposition,
|
composition: mockComposition,
|
||||||
persistence: mockPersistence,
|
persistence: mockPersistence,
|
||||||
|
action: mockActionCapability,
|
||||||
type: mockType
|
type: mockType
|
||||||
};
|
};
|
||||||
model = {
|
model = {
|
||||||
@@ -90,7 +97,7 @@ define(
|
|||||||
selectedObject: mockDomainObject
|
selectedObject: mockDomainObject
|
||||||
};
|
};
|
||||||
|
|
||||||
action = new LinkAction(actionContext);
|
action = new EditAndComposeAction(actionContext);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -105,6 +112,21 @@ define(
|
|||||||
expect(mockPersistence.persist).toHaveBeenCalled();
|
expect(mockPersistence.persist).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("enables edit mode for objects that have an edit action", function () {
|
||||||
|
mockActionCapability.getActions.andReturn([mockEditAction]);
|
||||||
|
action.perform();
|
||||||
|
expect(mockEditAction.perform).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Does not enable edit mode for objects that do not have an" +
|
||||||
|
" edit action", function () {
|
||||||
|
mockActionCapability.getActions.andReturn([]);
|
||||||
|
action.perform();
|
||||||
|
expect(mockEditAction.perform).not.toHaveBeenCalled();
|
||||||
|
expect(mockComposition.add)
|
||||||
|
.toHaveBeenCalledWith(mockDomainObject);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -38,7 +38,9 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
capabilities = {
|
capabilities = {
|
||||||
type: {
|
type: {
|
||||||
getProperties: function () { return []; },
|
getProperties: function () {
|
||||||
|
return [];
|
||||||
|
},
|
||||||
hasFeature: jasmine.createSpy('hasFeature')
|
hasFeature: jasmine.createSpy('hasFeature')
|
||||||
},
|
},
|
||||||
persistence: jasmine.createSpyObj("persistence", ["persist"]),
|
persistence: jasmine.createSpyObj("persistence", ["persist"]),
|
||||||
@@ -47,11 +49,21 @@ define(
|
|||||||
model = {};
|
model = {};
|
||||||
input = {};
|
input = {};
|
||||||
object = {
|
object = {
|
||||||
getId: function () { return 'test-id'; },
|
getId: function () {
|
||||||
getCapability: function (k) { return capabilities[k]; },
|
return 'test-id';
|
||||||
getModel: function () { return model; },
|
},
|
||||||
useCapability: function (k, v) { return capabilities[k](v); },
|
getCapability: function (k) {
|
||||||
hasCapability: function () { return true; }
|
return capabilities[k];
|
||||||
|
},
|
||||||
|
getModel: function () {
|
||||||
|
return model;
|
||||||
|
},
|
||||||
|
useCapability: function (k, v) {
|
||||||
|
return capabilities[k](v);
|
||||||
|
},
|
||||||
|
hasCapability: function () {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
context = { someKey: "some value", domainObject: object };
|
context = { someKey: "some value", domainObject: object };
|
||||||
dialogService = {
|
dialogService = {
|
||||||
|
|||||||
@@ -30,14 +30,22 @@ define(
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
type = {
|
type = {
|
||||||
getProperties: function () { return properties; }
|
getProperties: function () {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
model = { x: "initial value" };
|
model = { x: "initial value" };
|
||||||
properties = ["x", "y", "z"].map(function (k) {
|
properties = ["x", "y", "z"].map(function (k) {
|
||||||
return {
|
return {
|
||||||
getValue: function (model) { return model[k]; },
|
getValue: function (m) {
|
||||||
setValue: function (model, v) { model[k] = v; },
|
return m[k];
|
||||||
getDefinition: function () { return { control: 'textfield '}; }
|
},
|
||||||
|
setValue: function (m, v) {
|
||||||
|
m[k] = v;
|
||||||
|
},
|
||||||
|
getDefinition: function () {
|
||||||
|
return { control: 'textfield '};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,10 @@ define(
|
|||||||
|
|
||||||
describe("The create action provider", function () {
|
describe("The create action provider", function () {
|
||||||
var mockTypeService,
|
var mockTypeService,
|
||||||
mockDialogService,
|
|
||||||
mockNavigationService,
|
|
||||||
mockPolicyService,
|
mockPolicyService,
|
||||||
mockCreationPolicy,
|
mockCreationPolicy,
|
||||||
mockPolicyMap = {},
|
mockPolicyMap = {},
|
||||||
mockTypes,
|
mockTypes,
|
||||||
mockQ,
|
|
||||||
provider;
|
provider;
|
||||||
|
|
||||||
function createMockType(name) {
|
function createMockType(name) {
|
||||||
@@ -61,14 +58,6 @@ define(
|
|||||||
"typeService",
|
"typeService",
|
||||||
["listTypes"]
|
["listTypes"]
|
||||||
);
|
);
|
||||||
mockDialogService = jasmine.createSpyObj(
|
|
||||||
"dialogService",
|
|
||||||
[ "getUserInput" ]
|
|
||||||
);
|
|
||||||
mockNavigationService = jasmine.createSpyObj(
|
|
||||||
"navigationService",
|
|
||||||
[ "setNavigation" ]
|
|
||||||
);
|
|
||||||
mockPolicyService = jasmine.createSpyObj(
|
mockPolicyService = jasmine.createSpyObj(
|
||||||
"policyService",
|
"policyService",
|
||||||
["allow"]
|
["allow"]
|
||||||
@@ -91,9 +80,7 @@ define(
|
|||||||
mockTypeService.listTypes.andReturn(mockTypes);
|
mockTypeService.listTypes.andReturn(mockTypes);
|
||||||
|
|
||||||
provider = new CreateActionProvider(
|
provider = new CreateActionProvider(
|
||||||
mockQ,
|
|
||||||
mockTypeService,
|
mockTypeService,
|
||||||
mockNavigationService,
|
|
||||||
mockPolicyService
|
mockPolicyService
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
190
platform/commonUI/edit/test/creation/CreateActionSpec.js
Normal file
190
platform/commonUI/edit/test/creation/CreateActionSpec.js
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
["../../src/creation/CreateAction"],
|
||||||
|
function (CreateAction) {
|
||||||
|
|
||||||
|
describe("The create action", function () {
|
||||||
|
var mockType,
|
||||||
|
mockParent,
|
||||||
|
mockContext,
|
||||||
|
mockDomainObject,
|
||||||
|
capabilities = {},
|
||||||
|
mockEditAction,
|
||||||
|
mockSaveAction,
|
||||||
|
action;
|
||||||
|
|
||||||
|
function mockPromise(value) {
|
||||||
|
return {
|
||||||
|
then: function (callback) {
|
||||||
|
return mockPromise(callback(value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockType = jasmine.createSpyObj(
|
||||||
|
"type",
|
||||||
|
[
|
||||||
|
"getKey",
|
||||||
|
"getGlyph",
|
||||||
|
"getName",
|
||||||
|
"getDescription",
|
||||||
|
"getProperties",
|
||||||
|
"getInitialModel"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
mockParent = jasmine.createSpyObj(
|
||||||
|
"domainObject",
|
||||||
|
[
|
||||||
|
"getId",
|
||||||
|
"getModel",
|
||||||
|
"getCapability",
|
||||||
|
"useCapability"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
|
"domainObject",
|
||||||
|
[
|
||||||
|
"getId",
|
||||||
|
"getModel",
|
||||||
|
"getCapability",
|
||||||
|
"hasCapability",
|
||||||
|
"useCapability"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
mockDomainObject.hasCapability.andCallFake(function (name) {
|
||||||
|
return !!capabilities[name];
|
||||||
|
});
|
||||||
|
mockDomainObject.getCapability.andCallFake(function (name) {
|
||||||
|
return capabilities[name];
|
||||||
|
});
|
||||||
|
mockSaveAction = jasmine.createSpyObj(
|
||||||
|
"saveAction",
|
||||||
|
[
|
||||||
|
"perform"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
capabilities.action = jasmine.createSpyObj(
|
||||||
|
"actionCapability",
|
||||||
|
[
|
||||||
|
"getActions",
|
||||||
|
"perform"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
capabilities.editor = jasmine.createSpyObj(
|
||||||
|
"editorCapability",
|
||||||
|
[
|
||||||
|
"edit",
|
||||||
|
"save",
|
||||||
|
"cancel"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
mockEditAction = jasmine.createSpyObj(
|
||||||
|
"editAction",
|
||||||
|
[
|
||||||
|
"perform"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
mockContext = {
|
||||||
|
domainObject: mockParent
|
||||||
|
};
|
||||||
|
mockParent.useCapability.andReturn(mockDomainObject);
|
||||||
|
|
||||||
|
mockType.getKey.andReturn("test");
|
||||||
|
mockType.getGlyph.andReturn("T");
|
||||||
|
mockType.getDescription.andReturn("a test type");
|
||||||
|
mockType.getName.andReturn("Test");
|
||||||
|
mockType.getProperties.andReturn([]);
|
||||||
|
mockType.getInitialModel.andReturn({});
|
||||||
|
|
||||||
|
action = new CreateAction(
|
||||||
|
mockType,
|
||||||
|
mockParent,
|
||||||
|
mockContext
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("exposes type-appropriate metadata", function () {
|
||||||
|
var metadata = action.getMetadata();
|
||||||
|
|
||||||
|
expect(metadata.name).toEqual("Test");
|
||||||
|
expect(metadata.description).toEqual("a test type");
|
||||||
|
expect(metadata.glyph).toEqual("T");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("the perform function", function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
capabilities.action.getActions.andReturn([mockEditAction]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses the instantiation capability when performed", function () {
|
||||||
|
action.perform();
|
||||||
|
expect(mockParent.useCapability).toHaveBeenCalledWith("instantiation", jasmine.any(Object));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses the edit action if available", function () {
|
||||||
|
action.perform();
|
||||||
|
expect(mockEditAction.perform).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses the save action if object does not have an edit action" +
|
||||||
|
" available", function () {
|
||||||
|
capabilities.action.getActions.andReturn([]);
|
||||||
|
capabilities.action.perform.andReturn(mockPromise(undefined));
|
||||||
|
action.perform();
|
||||||
|
expect(capabilities.action.perform).toHaveBeenCalledWith("save");
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("uses to editor capability", function () {
|
||||||
|
var promise = jasmine.createSpyObj("promise", ["then"]);
|
||||||
|
beforeEach(function () {
|
||||||
|
capabilities.action.getActions.andReturn([]);
|
||||||
|
capabilities.action.perform.andReturn(promise);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("to save the edit if user saves dialog", function () {
|
||||||
|
action.perform();
|
||||||
|
expect(promise.then).toHaveBeenCalled();
|
||||||
|
promise.then.mostRecentCall.args[0]();
|
||||||
|
expect(capabilities.editor.save).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("to cancel the edit if user cancels dialog", function () {
|
||||||
|
action.perform();
|
||||||
|
promise.then.mostRecentCall.args[1]();
|
||||||
|
expect(capabilities.editor.cancel).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -152,7 +152,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("validates selection types using policy", function () {
|
it("validates selection types using policy", function () {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject',
|
'domainObject',
|
||||||
['getCapability']
|
['getCapability']
|
||||||
),
|
),
|
||||||
@@ -166,8 +166,8 @@ define(
|
|||||||
rows = structure.sections[sections.length - 1].rows,
|
rows = structure.sections[sections.length - 1].rows,
|
||||||
locationRow = rows[rows.length - 1];
|
locationRow = rows[rows.length - 1];
|
||||||
|
|
||||||
mockDomainObject.getCapability.andReturn(mockOtherType);
|
mockDomainObj.getCapability.andReturn(mockOtherType);
|
||||||
locationRow.validate(mockDomainObject);
|
locationRow.validate(mockDomainObj);
|
||||||
|
|
||||||
// Should check policy to see if the user-selected location
|
// Should check policy to see if the user-selected location
|
||||||
// can actually contain objects of this type
|
// can actually contain objects of this type
|
||||||
@@ -126,7 +126,9 @@ define(
|
|||||||
it("reads properties from getters", function () {
|
it("reads properties from getters", function () {
|
||||||
var structure, state;
|
var structure, state;
|
||||||
|
|
||||||
testABC.a = function () { return "from a getter!"; };
|
testABC.a = function () {
|
||||||
|
return "from a getter!";
|
||||||
|
};
|
||||||
|
|
||||||
toolbar.setSelection([testABC]);
|
toolbar.setSelection([testABC]);
|
||||||
structure = toolbar.getStructure();
|
structure = toolbar.getStructure();
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ define(
|
|||||||
});
|
});
|
||||||
// Return constructors
|
// Return constructors
|
||||||
mockFormats = KEYS.map(function (k, i) {
|
mockFormats = KEYS.map(function (k, i) {
|
||||||
function MockFormat() { return mockFormatInstances[i]; }
|
function MockFormat() {
|
||||||
|
return mockFormatInstances[i];
|
||||||
|
}
|
||||||
MockFormat.key = k;
|
MockFormat.key = k;
|
||||||
return MockFormat;
|
return MockFormat;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -145,3 +145,8 @@
|
|||||||
.flex-justify-end {
|
.flex-justify-end {
|
||||||
@include justify-content(flex-end);
|
@include justify-content(flex-end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************************* POPUPS */
|
||||||
|
.t-popup {
|
||||||
|
z-index: 75;
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ $uePaneMiniTabW: 10px;
|
|||||||
$uePaneMiniTabCollapsedW: 11px;
|
$uePaneMiniTabCollapsedW: 11px;
|
||||||
$ueEditLeftPaneW: 75%;
|
$ueEditLeftPaneW: 75%;
|
||||||
$treeSearchInputBarH: 25px;
|
$treeSearchInputBarH: 25px;
|
||||||
$ueTimeControlH: (33px, 20px, 20px);
|
$ueTimeControlH: (33px, 18px, 20px);
|
||||||
// Panes
|
// Panes
|
||||||
$ueBrowseLeftPaneTreeMinW: 150px;
|
$ueBrowseLeftPaneTreeMinW: 150px;
|
||||||
$ueBrowseLeftPaneTreeMaxW: 35%;
|
$ueBrowseLeftPaneTreeMaxW: 35%;
|
||||||
|
|||||||
@@ -63,9 +63,10 @@ input, textarea {
|
|||||||
font-family: Helvetica, Arial, sans-serif;
|
font-family: Helvetica, Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"] {
|
input[type="text"],
|
||||||
|
input[type="search"] {
|
||||||
vertical-align: baseline;
|
vertical-align: baseline;
|
||||||
padding: 3px 5px !important;
|
padding: 3px 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, h3 {
|
h1, h2, h3 {
|
||||||
|
|||||||
@@ -139,6 +139,17 @@
|
|||||||
background-size: $d $d;
|
background-size: $d $d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mixin bgStripes($c: yellow, $a: 0.1, $bgsize: 5px, $angle: 90deg) {
|
||||||
|
@include background-image(linear-gradient($angle,
|
||||||
|
rgba($c, $a) 25%, transparent 25%,
|
||||||
|
transparent 50%, rgba($c, $a) 50%,
|
||||||
|
rgba($c, $a) 75%, transparent 75%,
|
||||||
|
transparent 100%
|
||||||
|
));
|
||||||
|
background-repeat: repeat;
|
||||||
|
background-size: $bgsize $bgsize;
|
||||||
|
}
|
||||||
|
|
||||||
@mixin bgVertStripes($c: yellow, $a: 0.1, $d: 40px) {
|
@mixin bgVertStripes($c: yellow, $a: 0.1, $d: 40px) {
|
||||||
@include background-image(linear-gradient(-90deg,
|
@include background-image(linear-gradient(-90deg,
|
||||||
rgba($c, $a) 0%, rgba($c, $a) 50%,
|
rgba($c, $a) 0%, rgba($c, $a) 50%,
|
||||||
@@ -322,13 +333,13 @@
|
|||||||
color: $fg;
|
color: $fg;
|
||||||
outline: none;
|
outline: none;
|
||||||
&.error {
|
&.error {
|
||||||
background: rgba(red, 0.5);
|
background-color: $colorFormFieldErrorBg;
|
||||||
|
color: $colorFormFieldErrorFg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin nice-input($bg: $colorInputBg, $fg: $colorInputFg) {
|
@mixin nice-input($bg: $colorInputBg, $fg: $colorInputFg) {
|
||||||
@include input-base($bg, $fg);
|
@include input-base($bg, $fg);
|
||||||
padding: 0 $interiorMarginSm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin contextArrow() {
|
@mixin contextArrow() {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
.accordion-head {
|
.accordion-head {
|
||||||
$op: 0.2;
|
$op: 0.2;
|
||||||
border-radius: $basicCr * 0.75;
|
border-radius: $basicCr * 0.75;
|
||||||
box-sizing: "border-box";
|
box-sizing: border-box;
|
||||||
background: rgba($colorBodyFg, $op);
|
background: rgba($colorBodyFg, $op);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
@@ -396,11 +396,11 @@ input[type="search"] {
|
|||||||
left: auto;
|
left: auto;
|
||||||
}
|
}
|
||||||
.knob-l {
|
.knob-l {
|
||||||
@include border-left-radius($sliderKnobW);
|
@include border-left-radius($sliderKnobR);
|
||||||
cursor: w-resize;
|
cursor: w-resize;
|
||||||
}
|
}
|
||||||
.knob-r {
|
.knob-r {
|
||||||
@include border-right-radius($sliderKnobW);
|
@include border-right-radius($sliderKnobR);
|
||||||
cursor: e-resize;
|
cursor: e-resize;
|
||||||
}
|
}
|
||||||
.range {
|
.range {
|
||||||
@@ -426,7 +426,6 @@ input[type="search"] {
|
|||||||
@include user-select(none);
|
@include user-select(none);
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
padding: $interiorMarginLg !important;
|
padding: $interiorMarginLg !important;
|
||||||
width: 230px;
|
|
||||||
.l-month-year-pager {
|
.l-month-year-pager {
|
||||||
$pagerW: 20px;
|
$pagerW: 20px;
|
||||||
height: $r1H;
|
height: $r1H;
|
||||||
@@ -518,6 +517,19 @@ input[type="search"] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@include phone {
|
||||||
|
.l-datetime-picker {
|
||||||
|
padding: $interiorMargin !important;
|
||||||
|
}
|
||||||
|
.l-calendar {
|
||||||
|
ul.l-cal-row {
|
||||||
|
li {
|
||||||
|
padding: 2px $interiorMargin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************** TEXTAREA */
|
/******************************************************** TEXTAREA */
|
||||||
textarea {
|
textarea {
|
||||||
@include nice-textarea($colorInputBg, $colorInputFg);
|
@include nice-textarea($colorInputBg, $colorInputFg);
|
||||||
|
|||||||
@@ -10,25 +10,24 @@
|
|||||||
$knobHOffset: 0px;
|
$knobHOffset: 0px;
|
||||||
$knobM: ($sliderKnobW + $knobHOffset) * -1;
|
$knobM: ($sliderKnobW + $knobHOffset) * -1;
|
||||||
$rangeValPad: $interiorMargin;
|
$rangeValPad: $interiorMargin;
|
||||||
$rangeValOffset: $sliderKnobW;
|
$rangeValOffset: $sliderKnobW + $interiorMargin;
|
||||||
$timeRangeSliderLROffset: 130px + $sliderKnobW + $rangeValOffset;
|
$timeRangeSliderLROffset: 150px + ($sliderKnobW * 2);
|
||||||
$r1H: nth($ueTimeControlH,1);
|
$r1H: nth($ueTimeControlH,1); // Not currently used
|
||||||
$r2H: nth($ueTimeControlH,2);
|
$r2H: nth($ueTimeControlH,2);
|
||||||
$r3H: nth($ueTimeControlH,3);
|
$r3H: nth($ueTimeControlH,3);
|
||||||
|
|
||||||
display: block;
|
|
||||||
height: $r1H + $r2H + $r3H + ($interiorMargin * 2);
|
|
||||||
min-width: $minW;
|
min-width: $minW;
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder,
|
.l-time-range-inputs-holder,
|
||||||
.l-time-range-slider-holder,
|
.l-time-range-slider-holder,
|
||||||
.l-time-range-ticks-holder
|
.l-time-range-ticks-holder
|
||||||
{
|
{
|
||||||
@include absPosDefault(0, visible);
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
top: auto;
|
position: relative;
|
||||||
|
&:not(:first-child) {
|
||||||
|
margin-top: $interiorMargin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.l-time-range-slider,
|
.l-time-range-slider,
|
||||||
.l-time-range-ticks {
|
.l-time-range-ticks {
|
||||||
@@ -37,14 +36,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
.l-time-range-inputs-holder {
|
||||||
height: $r1H; bottom: $r2H + $r3H + ($interiorMarginSm * 2);
|
|
||||||
padding-top: $interiorMargin;
|
|
||||||
border-top: 1px solid $colorInteriorBorder;
|
border-top: 1px solid $colorInteriorBorder;
|
||||||
|
padding-top: $interiorMargin;
|
||||||
|
&.l-flex-row,
|
||||||
|
.l-flex-row {
|
||||||
|
@include align-items(center);
|
||||||
|
.flex-elem {
|
||||||
|
height: auto;
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
.type-icon {
|
.type-icon {
|
||||||
font-size: 120%;
|
font-size: 120%;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
.l-time-range-input,
|
.l-time-range-input-w,
|
||||||
.l-time-range-inputs-elem {
|
.l-time-range-inputs-elem {
|
||||||
margin-right: $interiorMargin;
|
margin-right: $interiorMargin;
|
||||||
.lbl {
|
.lbl {
|
||||||
@@ -52,13 +58,27 @@
|
|||||||
}
|
}
|
||||||
.ui-symbol.icon {
|
.ui-symbol.icon {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
width: 11px;
|
}
|
||||||
|
}
|
||||||
|
.l-time-range-input-w {
|
||||||
|
// Wraps a datetime text input field
|
||||||
|
position: relative;
|
||||||
|
input[type="text"] {
|
||||||
|
width: 200px;
|
||||||
|
&.picker-icon {
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.icon-calendar {
|
||||||
|
position: absolute;
|
||||||
|
right: 5px;
|
||||||
|
top: 5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.l-time-range-slider-holder {
|
.l-time-range-slider-holder {
|
||||||
height: $r2H; bottom: $r3H + ($interiorMarginSm * 1);
|
height: $r2H;
|
||||||
.range-holder {
|
.range-holder {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
background: none;
|
background: none;
|
||||||
@@ -73,24 +93,13 @@
|
|||||||
width: $myW;
|
width: $myW;
|
||||||
height: auto;
|
height: auto;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
&:before,
|
|
||||||
&:after {
|
|
||||||
background-color: $myC;
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
&:before {
|
&:before {
|
||||||
// Vert line
|
// Vert line
|
||||||
|
background-color: $myC;
|
||||||
|
position: absolute;
|
||||||
|
content: "";
|
||||||
top: 0; right: auto; bottom: -10px; left: floor($myW/2) - 1;
|
top: 0; right: auto; bottom: -10px; left: floor($myW/2) - 1;
|
||||||
width: 2px;
|
width: 1px;
|
||||||
}
|
|
||||||
&:after {
|
|
||||||
// Circle element
|
|
||||||
border-radius: $myW;
|
|
||||||
@include transform(translateY(-50%));
|
|
||||||
top: 50%; right: 0; bottom: auto; left: 0;
|
|
||||||
width: auto;
|
|
||||||
height: $myW;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:hover .toi-line {
|
&:hover .toi-line {
|
||||||
@@ -126,9 +135,9 @@
|
|||||||
@include webkitProp(transform, translateX(-50%));
|
@include webkitProp(transform, translateX(-50%));
|
||||||
color: $colorPlotLabelFg;
|
color: $colorPlotLabelFg;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-size: 0.9em;
|
font-size: 0.7rem;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 8px;
|
top: 5px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
@@ -138,16 +147,29 @@
|
|||||||
|
|
||||||
.knob {
|
.knob {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
&:before {
|
||||||
|
$mTB: 2px;
|
||||||
|
$grippyW: 3px;
|
||||||
|
$mLR: ($sliderKnobW - $grippyW)/2;
|
||||||
|
@include bgStripes($c: pullForward($sliderColorKnob, 20%), $a: 1, $bgsize: 4px, $angle: 0deg);
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: $mTB; right: $mLR; bottom: $mTB; left: $mLR;
|
||||||
|
}
|
||||||
.range-value {
|
.range-value {
|
||||||
@include trans-prop-nice-fade(.25s);
|
@include trans-prop-nice-fade(.25s);
|
||||||
padding: 0 $rangeValOffset;
|
font-size: 0.7rem;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: $r2H;
|
height: $r2H;
|
||||||
line-height: $r2H;
|
line-height: $r2H;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
&:hover .range-value {
|
&:hover {
|
||||||
|
.range-value {
|
||||||
color: $sliderColorKnobHov;
|
color: $sliderColorKnobHov;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&.knob-l {
|
&.knob-l {
|
||||||
margin-left: $knobM;
|
margin-left: $knobM;
|
||||||
@@ -170,7 +192,7 @@
|
|||||||
.l-time-domain-selector {
|
.l-time-domain-selector {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
bottom: 46px;
|
top: $interiorMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -181,174 +203,64 @@
|
|||||||
padding: 1px 1px 0 $interiorMargin;
|
padding: 1px 1px 0 $interiorMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************** MOBILE */
|
||||||
|
|
||||||
@include phoneandtablet {
|
@include phoneandtablet {
|
||||||
.l-time-controller, .l-time-range-inputs-holder {
|
|
||||||
min-width: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-controller {
|
.l-time-controller {
|
||||||
|
min-width: 0;
|
||||||
.l-time-domain-selector {
|
.l-time-range-slider-holder,
|
||||||
select {
|
.l-time-range-ticks-holder {
|
||||||
height: 25px;
|
|
||||||
margin-bottom: 0px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-range-slider-holder, .l-time-range-ticks-holder {
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.time-range-start, .time-range-end, {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
|
||||||
.l-time-range-input {
|
|
||||||
display: block;
|
|
||||||
.s-btn {
|
|
||||||
padding-right: 18px;
|
|
||||||
white-space: nowrap;
|
|
||||||
input {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.l-time-range-inputs-elem {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@include phone {
|
@include phone {
|
||||||
.l-time-controller {
|
.l-time-controller {
|
||||||
height: 48px;
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
.l-time-range-inputs-holder {
|
||||||
bottom: 24px;
|
&.l-flex-row,
|
||||||
}
|
.l-flex-row {
|
||||||
|
@include align-items(flex-start);
|
||||||
.l-time-domain-selector {
|
|
||||||
width: 33%;
|
|
||||||
bottom: -9px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
|
||||||
.l-time-range-input {
|
|
||||||
margin-bottom: 5px;
|
|
||||||
.s-btn {
|
|
||||||
width: 66%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.l-time-range-inputs-elem {
|
.l-time-range-inputs-elem {
|
||||||
&.ui-symbol {
|
&.type-icon {
|
||||||
display: none;
|
margin-top: 3px;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
&.lbl {
|
.t-inputs-w {
|
||||||
width: 33%;
|
@include flex-direction(column);
|
||||||
right: 0px;
|
.l-time-range-input-w:not(:first-child) {
|
||||||
top: 5px;
|
&:not(:first-child) {
|
||||||
display: block;
|
margin-top: $interiorMargin;
|
||||||
height: 25px;
|
}
|
||||||
margin: 0;
|
margin-right: 0;
|
||||||
line-height: 25px;
|
}
|
||||||
position: absolute;
|
.l-time-range-inputs-elem {
|
||||||
|
&.lbl { display: none; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@include phonePortrait {
|
||||||
@include tablet {
|
|
||||||
.l-time-controller {
|
.l-time-controller {
|
||||||
height: 17px;
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
.l-time-range-inputs-holder {
|
||||||
bottom: -7px;
|
.t-inputs-w {
|
||||||
left: -5px;
|
@include flex(1 1 auto);
|
||||||
}
|
padding-top: 25px; // Make room for the ever lovin' Time Domain Selector
|
||||||
|
.flex-elem {
|
||||||
.l-time-domain-selector {
|
@include flex(1 1 auto);
|
||||||
width: 23%;
|
width: 100%;
|
||||||
right: -4px;
|
}
|
||||||
bottom: -10px;
|
input[type="text"] {
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
|
||||||
.l-time-range-input {
|
|
||||||
float: left;
|
|
||||||
.s-btn {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-left: 4px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@include tabletLandscape {
|
|
||||||
.l-time-controller {
|
|
||||||
height: 17px;
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
|
||||||
bottom: -7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-domain-selector {
|
.l-time-domain-selector {
|
||||||
width: 23%;
|
|
||||||
right: auto;
|
right: auto;
|
||||||
bottom: -10px;
|
left: 20px;
|
||||||
left: 391px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
|
||||||
.l-time-range-inputs-elem {
|
|
||||||
&.ui-symbol, &.lbl {
|
|
||||||
display: block;
|
|
||||||
float: left;
|
|
||||||
line-height: 25px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.pane-tree-hidden .l-time-controller {
|
|
||||||
.l-time-domain-selector {
|
|
||||||
left: 667px;
|
|
||||||
}
|
|
||||||
.l-time-range-inputs-holder {
|
|
||||||
padding-left: 277px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@include tabletPortrait {
|
|
||||||
.l-time-controller {
|
|
||||||
height: 17px;
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
|
||||||
bottom: -7px;
|
|
||||||
left: -5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-domain-selector {
|
|
||||||
width: 23%;
|
|
||||||
right: -4px;
|
|
||||||
bottom: -10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.l-time-range-inputs-holder {
|
|
||||||
.l-time-range-input {
|
|
||||||
width: 38%;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
.l-time-range-inputs-elem {
|
|
||||||
&.ui-symbol, &.lbl {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ body.desktop .pane .mini-tab-icon.toggle-pane {
|
|||||||
.holder.holder-treeview-elements {
|
.holder.holder-treeview-elements {
|
||||||
top: $bodyMargin;
|
top: $bodyMargin;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: $bodyMargin;
|
bottom: $interiorMargin;
|
||||||
left: $bodyMargin;
|
left: $bodyMargin;
|
||||||
.create-btn-holder {
|
.create-btn-holder {
|
||||||
&.s-status-editing {
|
&.s-status-editing {
|
||||||
@@ -215,17 +215,17 @@ body.desktop .pane .mini-tab-icon.toggle-pane {
|
|||||||
left: 0;
|
left: 0;
|
||||||
.holder-object {
|
.holder-object {
|
||||||
top: $bodyMargin;
|
top: $bodyMargin;
|
||||||
bottom: $bodyMargin;
|
bottom: $interiorMargin;
|
||||||
}
|
}
|
||||||
.holder-inspector {
|
.holder-inspector {
|
||||||
top: $bodyMargin;
|
top: $bodyMargin;
|
||||||
bottom: $bodyMargin;
|
bottom: $interiorMargin;
|
||||||
left: $bodyMargin;
|
left: $bodyMargin;
|
||||||
right: $bodyMargin;
|
right: $bodyMargin;
|
||||||
}
|
}
|
||||||
.holder-elements {
|
.holder-elements {
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: $bodyMargin;
|
bottom: $interiorMargin;
|
||||||
left: $bodyMargin;
|
left: $bodyMargin;
|
||||||
right: $bodyMargin;
|
right: $bodyMargin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,18 +19,17 @@
|
|||||||
this source code distribution or the Licensing information page available
|
this source code distribution or the Licensing information page available
|
||||||
at runtime from the About dialog for additional information.
|
at runtime from the About dialog for additional information.
|
||||||
-->
|
-->
|
||||||
<span class="s-btn"
|
<span ng-controller="DateTimeFieldController">
|
||||||
ng-controller="DateTimeFieldController">
|
|
||||||
<input type="text"
|
<input type="text"
|
||||||
ng-model="textValue"
|
ng-model="textValue"
|
||||||
ng-blur="restoreTextValue(); ngBlur()"
|
ng-blur="restoreTextValue(); ngBlur()"
|
||||||
ng-class="{
|
ng-class="{
|
||||||
error: textInvalid ||
|
error: textInvalid ||
|
||||||
(structure.validate &&
|
(structure.validate &&
|
||||||
!structure.validate(ngModel[field]))
|
!structure.validate(ngModel[field])),
|
||||||
|
'picker-icon': structure.format === 'utc' || !structure.format
|
||||||
}">
|
}">
|
||||||
</input>
|
</input><a class="ui-symbol icon icon-calendar"
|
||||||
<a class="ui-symbol icon icon-calendar"
|
|
||||||
ng-if="structure.format === 'utc' || !structure.format"
|
ng-if="structure.format === 'utc' || !structure.format"
|
||||||
ng-click="picker.active = !picker.active">
|
ng-click="picker.active = !picker.active">
|
||||||
</a>
|
</a>
|
||||||
@@ -38,8 +37,7 @@
|
|||||||
<div mct-click-elsewhere="picker.active = false">
|
<div mct-click-elsewhere="picker.active = false">
|
||||||
<mct-control key="'datetime-picker'"
|
<mct-control key="'datetime-picker'"
|
||||||
ng-model="pickerModel"
|
ng-model="pickerModel"
|
||||||
field="'value'"
|
field="'value'">
|
||||||
options="{ hours: true }">
|
|
||||||
</mct-control>
|
</mct-control>
|
||||||
</div>
|
</div>
|
||||||
</mct-popup>
|
</mct-popup>
|
||||||
|
|||||||
@@ -19,11 +19,12 @@
|
|||||||
this source code distribution or the Licensing information page available
|
this source code distribution or the Licensing information page available
|
||||||
at runtime from the About dialog for additional information.
|
at runtime from the About dialog for additional information.
|
||||||
-->
|
-->
|
||||||
<div ng-controller="TimeRangeController as trCtrl">
|
<div ng-controller="TimeRangeController as trCtrl" class="l-flex-col">
|
||||||
<form class="l-time-range-inputs-holder"
|
<form class="l-time-range-inputs-holder l-flex-row flex-elem"
|
||||||
ng-submit="trCtrl.updateBoundsFromForm()">
|
ng-submit="trCtrl.updateBoundsFromForm()">
|
||||||
<span class="l-time-range-inputs-elem ui-symbol type-icon">C</span>
|
<span class="l-time-range-inputs-elem ui-symbol type-icon flex-elem">C</span>
|
||||||
<span class="l-time-range-input">
|
<span class="l-time-range-inputs-elem t-inputs-w l-flex-row flex-elem">
|
||||||
|
<span class="l-time-range-input-w flex-elem">
|
||||||
<mct-control key="'datetime-field'"
|
<mct-control key="'datetime-field'"
|
||||||
structure="{
|
structure="{
|
||||||
format: parameters.format,
|
format: parameters.format,
|
||||||
@@ -36,9 +37,9 @@
|
|||||||
</mct-control>
|
</mct-control>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="l-time-range-inputs-elem lbl">to</span>
|
<span class="l-time-range-inputs-elem lbl flex-elem">to</span>
|
||||||
|
|
||||||
<span class="l-time-range-input" ng-controller="ToggleController as t2">
|
<span class="l-time-range-input-w flex-elem" ng-controller="ToggleController as t2">
|
||||||
<mct-control key="'datetime-field'"
|
<mct-control key="'datetime-field'"
|
||||||
structure="{
|
structure="{
|
||||||
format: parameters.format,
|
format: parameters.format,
|
||||||
@@ -48,13 +49,13 @@
|
|||||||
ng-blur="trCtrl.updateBoundsFromForm()"
|
ng-blur="trCtrl.updateBoundsFromForm()"
|
||||||
field="'end'"
|
field="'end'"
|
||||||
class="time-range-end">
|
class="time-range-end">
|
||||||
</mct-control>
|
</mct-control>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<input type="submit" class="hidden">
|
<input type="submit" class="hidden">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="l-time-range-slider-holder">
|
<div class="l-time-range-slider-holder flex-elem">
|
||||||
<div class="l-time-range-slider">
|
<div class="l-time-range-slider">
|
||||||
<div class="slider"
|
<div class="slider"
|
||||||
mct-resize="spanWidth = bounds.width">
|
mct-resize="spanWidth = bounds.width">
|
||||||
@@ -85,7 +86,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="l-time-range-ticks-holder">
|
<div class="l-time-range-ticks-holder flex-elem">
|
||||||
<div class="l-time-range-ticks">
|
<div class="l-time-range-ticks">
|
||||||
<div
|
<div
|
||||||
ng-repeat="tick in ticks track by $index"
|
ng-repeat="tick in ticks track by $index"
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ define(
|
|||||||
function updateList(ids) {
|
function updateList(ids) {
|
||||||
function updateSelectedObjects(objects) {
|
function updateSelectedObjects(objects) {
|
||||||
// Look up from the
|
// Look up from the
|
||||||
function getObject(id) { return objects[id]; }
|
function getObject(id) {
|
||||||
|
return objects[id];
|
||||||
|
}
|
||||||
self.selectedObjects =
|
self.selectedObjects =
|
||||||
ids.filter(getObject).map(getObject);
|
ids.filter(getObject).map(getObject);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,10 +49,7 @@ define(
|
|||||||
position = [rect.left, rect.top],
|
position = [rect.left, rect.top],
|
||||||
popup = popupService.display(div, position);
|
popup = popupService.display(div, position);
|
||||||
|
|
||||||
// TODO: Handle in CSS;
|
div.addClass('t-popup');
|
||||||
// https://github.com/nasa/openmctweb/issues/298
|
|
||||||
div.css('z-index', 75);
|
|
||||||
|
|
||||||
transclude(function (clone) {
|
transclude(function (clone) {
|
||||||
div.append(clone);
|
div.append(clone);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ define(
|
|||||||
var context = domainObject &&
|
var context = domainObject &&
|
||||||
domainObject.getCapability('context'),
|
domainObject.getCapability('context'),
|
||||||
objectPath = context ? context.getPath() : [],
|
objectPath = context ? context.getPath() : [],
|
||||||
ids = objectPath.map(function (domainObject) {
|
ids = objectPath.map(function (domainObj) {
|
||||||
return domainObject.getId();
|
return domainObj.getId();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Parses the path together. Starts with the
|
// Parses the path together. Starts with the
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ define([
|
|||||||
function getIdPath(domainObject) {
|
function getIdPath(domainObject) {
|
||||||
var context = domainObject && domainObject.getCapability('context');
|
var context = domainObject && domainObject.getCapability('context');
|
||||||
|
|
||||||
function getId(domainObject) {
|
function getId(domainObj) {
|
||||||
return domainObject.getId();
|
return domainObj.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return context ? context.getPath().map(getId) : [];
|
return context ? context.getPath().map(getId) : [];
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ define([
|
|||||||
var self = this,
|
var self = this,
|
||||||
domainObject = this.activeObject;
|
domainObject = this.activeObject;
|
||||||
|
|
||||||
function addNode(domainObject, index) {
|
function addNode(domainObj, index) {
|
||||||
self.nodeViews[index].model(domainObject);
|
self.nodeViews[index].model(domainObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNodes(domainObjects) {
|
function addNodes(domainObjects) {
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ define(
|
|||||||
);
|
);
|
||||||
|
|
||||||
testIndicatorA = {};
|
testIndicatorA = {};
|
||||||
testIndicatorB = function () { return mockIndicator; };
|
testIndicatorB = function () {
|
||||||
|
return mockIndicator;
|
||||||
|
};
|
||||||
testIndicatorC = { template: "someTemplate" };
|
testIndicatorC = { template: "someTemplate" };
|
||||||
|
|
||||||
testIndicators = [
|
testIndicators = [
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ define(
|
|||||||
|
|
||||||
function TestObject(id, context) {
|
function TestObject(id, context) {
|
||||||
return {
|
return {
|
||||||
getId: function () { return id; },
|
getId: function () {
|
||||||
|
return id;
|
||||||
|
},
|
||||||
getCapability: function (key) {
|
getCapability: function (key) {
|
||||||
return key === 'context' ? context : undefined;
|
return key === 'context' ? context : undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
||||||
mockTimeout = jasmine.createSpy("$timeout");
|
mockTimeout = jasmine.createSpy("$timeout");
|
||||||
mockTimeout.andCallFake(function (cb) { cb(); });
|
mockTimeout.andCallFake(function (cb) {
|
||||||
|
cb();
|
||||||
|
});
|
||||||
mockScope.ngModel = {};
|
mockScope.ngModel = {};
|
||||||
controller = new ViewSwitcherController(mockScope, mockTimeout);
|
controller = new ViewSwitcherController(mockScope, mockTimeout);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,15 @@ define(
|
|||||||
["../../src/directives/MCTPopup"],
|
["../../src/directives/MCTPopup"],
|
||||||
function (MCTPopup) {
|
function (MCTPopup) {
|
||||||
|
|
||||||
var JQLITE_METHODS = [ "on", "off", "find", "parent", "css", "append" ];
|
var JQLITE_METHODS = [
|
||||||
|
"on",
|
||||||
|
"off",
|
||||||
|
"find",
|
||||||
|
"parent",
|
||||||
|
"css",
|
||||||
|
"addClass",
|
||||||
|
"append"
|
||||||
|
];
|
||||||
|
|
||||||
describe("The mct-popup directive", function () {
|
describe("The mct-popup directive", function () {
|
||||||
var mockCompile,
|
var mockCompile,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ define([
|
|||||||
treeView;
|
treeView;
|
||||||
|
|
||||||
function makeMockDomainObject(id, model, capabilities) {
|
function makeMockDomainObject(id, model, capabilities) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
[
|
[
|
||||||
'getId',
|
'getId',
|
||||||
@@ -46,18 +46,18 @@ define([
|
|||||||
'useCapability'
|
'useCapability'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockDomainObj.getId.andReturn(id);
|
||||||
mockDomainObject.getModel.andReturn(model);
|
mockDomainObj.getModel.andReturn(model);
|
||||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
mockDomainObj.hasCapability.andCallFake(function (c) {
|
||||||
return !!(capabilities[c]);
|
return !!(capabilities[c]);
|
||||||
});
|
});
|
||||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
mockDomainObj.getCapability.andCallFake(function (c) {
|
||||||
return capabilities[c];
|
return capabilities[c];
|
||||||
});
|
});
|
||||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
mockDomainObj.useCapability.andCallFake(function (c) {
|
||||||
return capabilities[c] && capabilities[c].invoke();
|
return capabilities[c] && capabilities[c].invoke();
|
||||||
});
|
});
|
||||||
return mockDomainObject;
|
return mockDomainObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@@ -99,24 +99,16 @@ define([
|
|||||||
var mockComposition;
|
var mockComposition;
|
||||||
|
|
||||||
function makeGenericCapabilities() {
|
function makeGenericCapabilities() {
|
||||||
var mockContext =
|
var mockStatus =
|
||||||
jasmine.createSpyObj('context', [ 'getPath' ]),
|
|
||||||
mockType =
|
|
||||||
jasmine.createSpyObj('type', [ 'getGlyph' ]),
|
|
||||||
mockLocation =
|
|
||||||
jasmine.createSpyObj('location', [ 'isLink' ]),
|
|
||||||
mockMutation =
|
|
||||||
jasmine.createSpyObj('mutation', [ 'listen' ]),
|
|
||||||
mockStatus =
|
|
||||||
jasmine.createSpyObj('status', ['listen', 'list']);
|
jasmine.createSpyObj('status', ['listen', 'list']);
|
||||||
|
|
||||||
mockStatus.list.andReturn([]);
|
mockStatus.list.andReturn([]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
context: mockContext,
|
context: jasmine.createSpyObj('context', ['getPath']),
|
||||||
type: mockType,
|
type: jasmine.createSpyObj('type', ['getGlyph']),
|
||||||
mutation: mockMutation,
|
location: jasmine.createSpyObj('location', ['isLink']),
|
||||||
location: mockLocation,
|
mutation: jasmine.createSpyObj('mutation', ['listen']),
|
||||||
status: mockStatus
|
status: mockStatus
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -133,11 +125,11 @@ define([
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
||||||
var testCapabilities = makeGenericCapabilities(),
|
var testCaps = makeGenericCapabilities(),
|
||||||
mockChild =
|
mockChild =
|
||||||
makeMockDomainObject(id, {}, testCapabilities);
|
makeMockDomainObject(id, {}, testCaps);
|
||||||
|
|
||||||
testCapabilities.context.getPath
|
testCaps.context.getPath
|
||||||
.andReturn([mockDomainObject, mockChild]);
|
.andReturn([mockDomainObject, mockChild]);
|
||||||
|
|
||||||
return mockChild;
|
return mockChild;
|
||||||
@@ -207,11 +199,11 @@ define([
|
|||||||
|
|
||||||
describe("when a context-less object is selected", function () {
|
describe("when a context-less object is selected", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var testCapabilities = makeGenericCapabilities(),
|
var testCaps = makeGenericCapabilities(),
|
||||||
mockDomainObject =
|
mockDomainObj =
|
||||||
makeMockDomainObject('xyz', {}, testCapabilities);
|
makeMockDomainObject('xyz', {}, testCaps);
|
||||||
delete testCapabilities.context;
|
delete testCaps.context;
|
||||||
treeView.value(mockDomainObject);
|
treeView.value(mockDomainObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears all selection state", function () {
|
it("clears all selection state", function () {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ define(
|
|||||||
function InfoGestureButton($document, agentService, infoService, element, domainObject) {
|
function InfoGestureButton($document, agentService, infoService, element, domainObject) {
|
||||||
var dismissBubble,
|
var dismissBubble,
|
||||||
touchPosition,
|
touchPosition,
|
||||||
scopeOff,
|
|
||||||
body = $document.find('body');
|
body = $document.find('body');
|
||||||
|
|
||||||
function trackPosition(event) {
|
function trackPosition(event) {
|
||||||
@@ -79,8 +78,8 @@ define(
|
|||||||
// On any touch on the body, default body touches/events
|
// On any touch on the body, default body touches/events
|
||||||
// are prevented, the bubble is dismissed, and the touchstart
|
// are prevented, the bubble is dismissed, and the touchstart
|
||||||
// body event is unbound, reallowing gestures
|
// body event is unbound, reallowing gestures
|
||||||
body.on('touchstart', function (event) {
|
body.on('touchstart', function (evt) {
|
||||||
event.preventDefault();
|
evt.preventDefault();
|
||||||
hideBubble();
|
hideBubble();
|
||||||
body.unbind('touchstart');
|
body.unbind('touchstart');
|
||||||
});
|
});
|
||||||
@@ -94,10 +93,6 @@ define(
|
|||||||
element.on('click', showBubble);
|
element.on('click', showBubble);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also make sure we dismiss bubble if representation is destroyed
|
|
||||||
// before the mouse actually leaves it
|
|
||||||
scopeOff = element.scope().$on('$destroy', hideBubble);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Detach any event handlers associated with this gesture.
|
* Detach any event handlers associated with this gesture.
|
||||||
@@ -109,7 +104,6 @@ define(
|
|||||||
hideBubble();
|
hideBubble();
|
||||||
// ...and detach listeners
|
// ...and detach listeners
|
||||||
element.off('click', showBubble);
|
element.off('click', showBubble);
|
||||||
scopeOff();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,11 @@ define(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://github.com/nasa/openmct/issues/948
|
||||||
|
it("does not try to access scope", function () {
|
||||||
|
expect(mockElement.scope).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("detects display orientation", function () {
|
it("detects display orientation", function () {
|
||||||
var agentService = new AgentService(testWindow);
|
agentService = new AgentService(testWindow);
|
||||||
testWindow.innerWidth = 1024;
|
testWindow.innerWidth = 1024;
|
||||||
testWindow.innerHeight = 400;
|
testWindow.innerHeight = 400;
|
||||||
expect(agentService.isPortrait()).toBeFalsy();
|
expect(agentService.isPortrait()).toBeFalsy();
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ define(
|
|||||||
*/
|
*/
|
||||||
function InspectorController($scope, policyService) {
|
function InspectorController($scope, policyService) {
|
||||||
var domainObject = $scope.domainObject,
|
var domainObject = $scope.domainObject,
|
||||||
typeCapability = domainObject.getCapability('type');
|
typeCapability = domainObject.getCapability('type'),
|
||||||
|
statusListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters region parts to only those allowed by region policies
|
* Filters region parts to only those allowed by region policies
|
||||||
@@ -50,6 +51,11 @@ define(
|
|||||||
$scope.regions = filterRegions(typeCapability.getDefinition().inspector || new InspectorRegion());
|
$scope.regions = filterRegions(typeCapability.getDefinition().inspector || new InspectorRegion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
statusListener = domainObject.getCapability("status").listen(setRegions);
|
||||||
|
$scope.$on("$destroy", function () {
|
||||||
|
statusListener();
|
||||||
|
});
|
||||||
|
|
||||||
setRegions();
|
setRegions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ define(
|
|||||||
mockTypeCapability,
|
mockTypeCapability,
|
||||||
mockTypeDefinition,
|
mockTypeDefinition,
|
||||||
mockPolicyService,
|
mockPolicyService,
|
||||||
|
mockStatusCapability,
|
||||||
|
capabilities = {},
|
||||||
controller;
|
controller;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@@ -47,19 +49,29 @@ define(
|
|||||||
'getDefinition'
|
'getDefinition'
|
||||||
]);
|
]);
|
||||||
mockTypeCapability.getDefinition.andReturn(mockTypeDefinition);
|
mockTypeCapability.getDefinition.andReturn(mockTypeDefinition);
|
||||||
|
capabilities.type = mockTypeCapability;
|
||||||
|
|
||||||
|
mockStatusCapability = jasmine.createSpyObj('statusCapability', [
|
||||||
|
'listen'
|
||||||
|
]);
|
||||||
|
capabilities.status = mockStatusCapability;
|
||||||
|
|
||||||
mockDomainObject = jasmine.createSpyObj('domainObject', [
|
mockDomainObject = jasmine.createSpyObj('domainObject', [
|
||||||
'getCapability'
|
'getCapability'
|
||||||
]);
|
]);
|
||||||
mockDomainObject.getCapability.andReturn(mockTypeCapability);
|
mockDomainObject.getCapability.andCallFake(function (name) {
|
||||||
|
return capabilities[name];
|
||||||
|
});
|
||||||
|
|
||||||
mockPolicyService = jasmine.createSpyObj('policyService', [
|
mockPolicyService = jasmine.createSpyObj('policyService', [
|
||||||
'allow'
|
'allow'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
mockScope = {
|
mockScope = jasmine.createSpyObj('$scope',
|
||||||
domainObject: mockDomainObject
|
['$on']
|
||||||
};
|
);
|
||||||
|
|
||||||
|
mockScope.domainObject = mockDomainObject;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("filters out regions disallowed by region policy", function () {
|
it("filters out regions disallowed by region policy", function () {
|
||||||
@@ -73,6 +85,25 @@ define(
|
|||||||
controller = new InspectorController(mockScope, mockPolicyService);
|
controller = new InspectorController(mockScope, mockPolicyService);
|
||||||
expect(mockScope.regions.length).toBe(2);
|
expect(mockScope.regions.length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Responds to status changes", function () {
|
||||||
|
mockPolicyService.allow.andReturn(true);
|
||||||
|
controller = new InspectorController(mockScope, mockPolicyService);
|
||||||
|
expect(mockScope.regions.length).toBe(2);
|
||||||
|
expect(mockStatusCapability.listen).toHaveBeenCalled();
|
||||||
|
mockPolicyService.allow.andReturn(false);
|
||||||
|
mockStatusCapability.listen.mostRecentCall.args[0]();
|
||||||
|
expect(mockScope.regions.length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Unregisters status listener", function () {
|
||||||
|
var mockListener = jasmine.createSpy('listener');
|
||||||
|
mockStatusCapability.listen.andReturn(mockListener);
|
||||||
|
controller = new InspectorController(mockScope, mockPolicyService);
|
||||||
|
expect(mockScope.$on).toHaveBeenCalledWith("$destroy", jasmine.any(Function));
|
||||||
|
mockScope.$on.mostRecentCall.args[1]();
|
||||||
|
expect(mockListener).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ $sliderColorBase: $colorKey;
|
|||||||
$sliderColorRangeHolder: rgba(black, 0.1);
|
$sliderColorRangeHolder: rgba(black, 0.1);
|
||||||
$sliderColorRange: rgba($sliderColorBase, 0.3);
|
$sliderColorRange: rgba($sliderColorBase, 0.3);
|
||||||
$sliderColorRangeHov: rgba($sliderColorBase, 0.5);
|
$sliderColorRangeHov: rgba($sliderColorBase, 0.5);
|
||||||
$sliderColorKnob: rgba($sliderColorBase, 0.6);
|
$sliderColorKnob: $sliderColorBase;
|
||||||
$sliderColorKnobHov: $sliderColorBase;
|
$sliderColorKnobHov: pullForward($sliderColorKnob, $ltGamma);
|
||||||
$sliderColorRangeValHovBg: rgba($sliderColorBase, 0.1);
|
$sliderColorRangeValHovBg: rgba($sliderColorBase, 0.1);
|
||||||
$sliderColorRangeValHovFg: $colorKeyFg;
|
$sliderColorRangeValHovFg: $colorKeyFg;
|
||||||
$sliderKnobW: nth($ueTimeControlH,2)/2;
|
$sliderKnobW: 15px;
|
||||||
|
$sliderKnobR: 2px;
|
||||||
$timeControllerToiLineColor: #00c2ff;
|
$timeControllerToiLineColor: #00c2ff;
|
||||||
$timeControllerToiLineColorHov: #fff;
|
$timeControllerToiLineColorHov: #fff;
|
||||||
|
|
||||||
@@ -69,8 +70,10 @@ $colorCreateMenuText: $colorMenuFg;
|
|||||||
$colorCheck: $colorKey;
|
$colorCheck: $colorKey;
|
||||||
$colorFormRequired: $colorAlt1;
|
$colorFormRequired: $colorAlt1;
|
||||||
$colorFormValid: #33cc33;
|
$colorFormValid: #33cc33;
|
||||||
$colorFormError: #cc0000;
|
$colorFormError: #990000;
|
||||||
$colorFormInvalid: #ff3300;
|
$colorFormInvalid: #ff3300;
|
||||||
|
$colorFormFieldErrorBg: $colorFormError;
|
||||||
|
$colorFormFieldErrorFg: rgba(#fff, 0.6);
|
||||||
$colorFormLines: rgba(#fff, 0.1);
|
$colorFormLines: rgba(#fff, 0.1);
|
||||||
$colorFormSectionHeader: rgba(#fff, 0.1);
|
$colorFormSectionHeader: rgba(#fff, 0.1);
|
||||||
$colorInputBg: rgba(#000, 0.1);
|
$colorInputBg: rgba(#000, 0.1);
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ $sliderColorBase: $colorKey;
|
|||||||
$sliderColorRangeHolder: rgba(black, 0.07);
|
$sliderColorRangeHolder: rgba(black, 0.07);
|
||||||
$sliderColorRange: rgba($sliderColorBase, 0.2);
|
$sliderColorRange: rgba($sliderColorBase, 0.2);
|
||||||
$sliderColorRangeHov: rgba($sliderColorBase, 0.4);
|
$sliderColorRangeHov: rgba($sliderColorBase, 0.4);
|
||||||
$sliderColorKnob: rgba($sliderColorBase, 0.5);
|
$sliderColorKnob: pushBack($sliderColorBase, 20%);
|
||||||
$sliderColorKnobHov: rgba($sliderColorBase, 0.7);
|
$sliderColorKnobHov: rgba($sliderColorBase, 0.7);
|
||||||
$sliderColorRangeValHovBg: $sliderColorRange; //rgba($sliderColorBase, 0.1);
|
$sliderColorRangeValHovBg: $sliderColorRange;
|
||||||
$sliderColorRangeValHovFg: $colorBodyFg;
|
$sliderColorRangeValHovFg: $colorBodyFg;
|
||||||
$sliderKnobW: nth($ueTimeControlH,2)/2;
|
$sliderKnobW: 15px;
|
||||||
|
$sliderKnobR: 2px;
|
||||||
$timeControllerToiLineColor: $colorBodyFg;
|
$timeControllerToiLineColor: $colorBodyFg;
|
||||||
$timeControllerToiLineColorHov: #0052b5;
|
$timeControllerToiLineColorHov: #0052b5;
|
||||||
|
|
||||||
@@ -69,8 +70,10 @@ $colorCreateMenuText: $colorBodyFg;
|
|||||||
$colorCheck: $colorKey;
|
$colorCheck: $colorKey;
|
||||||
$colorFormRequired: $colorKey;
|
$colorFormRequired: $colorKey;
|
||||||
$colorFormValid: #33cc33;
|
$colorFormValid: #33cc33;
|
||||||
$colorFormError: #cc0000;
|
$colorFormError: #990000;
|
||||||
$colorFormInvalid: #ff2200;
|
$colorFormInvalid: #ff2200;
|
||||||
|
$colorFormFieldErrorBg: $colorFormError;
|
||||||
|
$colorFormFieldErrorFg: rgba(#fff, 0.6);
|
||||||
$colorFormLines: rgba(#000, 0.1);
|
$colorFormLines: rgba(#000, 0.1);
|
||||||
$colorFormSectionHeader: rgba(#000, 0.05);
|
$colorFormSectionHeader: rgba(#000, 0.05);
|
||||||
$colorInputBg: $colorGenBg;
|
$colorInputBg: $colorGenBg;
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ define(
|
|||||||
// additionally fills in the action's getMetadata method
|
// additionally fills in the action's getMetadata method
|
||||||
// with the extension definition (if no getMetadata
|
// with the extension definition (if no getMetadata
|
||||||
// method was supplied.)
|
// method was supplied.)
|
||||||
function instantiateAction(Action, context) {
|
function instantiateAction(Action, ctxt) {
|
||||||
var action = new Action(context),
|
var action = new Action(ctxt),
|
||||||
metadata;
|
metadata;
|
||||||
|
|
||||||
// Provide a getMetadata method that echos
|
// Provide a getMetadata method that echos
|
||||||
@@ -90,7 +90,7 @@ define(
|
|||||||
// unless the action has defined its own.
|
// unless the action has defined its own.
|
||||||
if (!action.getMetadata) {
|
if (!action.getMetadata) {
|
||||||
metadata = Object.create(Action.definition || {});
|
metadata = Object.create(Action.definition || {});
|
||||||
metadata.context = context;
|
metadata.context = ctxt;
|
||||||
action.getMetadata = function () {
|
action.getMetadata = function () {
|
||||||
return metadata;
|
return metadata;
|
||||||
};
|
};
|
||||||
@@ -103,14 +103,14 @@ define(
|
|||||||
// applicable in a given context, according to the static
|
// applicable in a given context, according to the static
|
||||||
// appliesTo method of given actions (if defined), and
|
// appliesTo method of given actions (if defined), and
|
||||||
// instantiate those applicable actions.
|
// instantiate those applicable actions.
|
||||||
function createIfApplicable(actions, context) {
|
function createIfApplicable(actions, ctxt) {
|
||||||
function isApplicable(Action) {
|
function isApplicable(Action) {
|
||||||
return Action.appliesTo ? Action.appliesTo(context) : true;
|
return Action.appliesTo ? Action.appliesTo(ctxt) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function instantiate(Action) {
|
function instantiate(Action) {
|
||||||
try {
|
try {
|
||||||
return instantiateAction(Action, context);
|
return instantiateAction(Action, ctxt);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$log.error([
|
$log.error([
|
||||||
"Could not instantiate action",
|
"Could not instantiate action",
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ define(
|
|||||||
return mutationResult && self.invoke().then(findObject);
|
return mutationResult && self.invoke().then(findObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addIdToModel(model) {
|
function addIdToModel(objModel) {
|
||||||
// Pick a specific index if needed.
|
// Pick a specific index if needed.
|
||||||
index = isNaN(index) ? composition.length : index;
|
index = isNaN(index) ? composition.length : index;
|
||||||
// Also, don't put past the end of the array
|
// Also, don't put past the end of the array
|
||||||
@@ -90,11 +90,11 @@ define(
|
|||||||
|
|
||||||
// Remove the existing instance of the id
|
// Remove the existing instance of the id
|
||||||
if (oldIndex !== -1) {
|
if (oldIndex !== -1) {
|
||||||
model.composition.splice(oldIndex, 1);
|
objModel.composition.splice(oldIndex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...and add it back at the appropriate index.
|
// ...and add it back at the appropriate index.
|
||||||
model.composition.splice(index, 0, id);
|
objModel.composition.splice(index, 0, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no index has been specified already and the id is already
|
// If no index has been specified already and the id is already
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Package capabilities as key-value pairs
|
// Package capabilities as key-value pairs
|
||||||
function packageCapabilities(capabilities) {
|
function packageCapabilities(caps) {
|
||||||
var result = {};
|
var result = {};
|
||||||
capabilities.forEach(function (capability) {
|
caps.forEach(function (capability) {
|
||||||
if (capability.key) {
|
if (capability.key) {
|
||||||
result[capability.key] =
|
result[capability.key] =
|
||||||
result[capability.key] || capability;
|
result[capability.key] || capability;
|
||||||
|
|||||||
@@ -124,9 +124,9 @@ define(
|
|||||||
clone = JSON.parse(JSON.stringify(model)),
|
clone = JSON.parse(JSON.stringify(model)),
|
||||||
useTimestamp = arguments.length > 1;
|
useTimestamp = arguments.length > 1;
|
||||||
|
|
||||||
function notifyListeners(model) {
|
function notifyListeners(newModel) {
|
||||||
generalTopic.notify(domainObject);
|
generalTopic.notify(domainObject);
|
||||||
specificTopic.notify(model);
|
specificTopic.notify(newModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to handle copying values to the actual
|
// Function to handle copying values to the actual
|
||||||
|
|||||||
@@ -124,8 +124,8 @@ define(
|
|||||||
this.persistenceService.createObject;
|
this.persistenceService.createObject;
|
||||||
|
|
||||||
// Update persistence timestamp...
|
// Update persistence timestamp...
|
||||||
domainObject.useCapability("mutation", function (model) {
|
domainObject.useCapability("mutation", function (m) {
|
||||||
model.persisted = modified;
|
m.persisted = modified;
|
||||||
}, modified);
|
}, modified);
|
||||||
|
|
||||||
// ...and persist
|
// ...and persist
|
||||||
|
|||||||
@@ -82,9 +82,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Package the result as id->model
|
// Package the result as id->model
|
||||||
function packageResult(parsedIds, models) {
|
function packageResult(parsedIdsToPackage, models) {
|
||||||
var result = {};
|
var result = {};
|
||||||
parsedIds.forEach(function (parsedId, index) {
|
parsedIdsToPackage.forEach(function (parsedId, index) {
|
||||||
var id = parsedId.id;
|
var id = parsedId.id;
|
||||||
if (models[index]) {
|
if (models[index]) {
|
||||||
result[id] = models[index];
|
result[id] = models[index];
|
||||||
@@ -93,11 +93,11 @@ define(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadModels(parsedIds) {
|
function loadModels(parsedIdsToLoad) {
|
||||||
return $q.all(parsedIds.map(loadModel))
|
return $q.all(parsedIdsToLoad.map(loadModel))
|
||||||
.then(function (models) {
|
.then(function (models) {
|
||||||
return packageResult(
|
return packageResult(
|
||||||
parsedIds,
|
parsedIdsToLoad,
|
||||||
models.map(addPersistedTimestamp)
|
models.map(addPersistedTimestamp)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ define(
|
|||||||
*/
|
*/
|
||||||
function RootModelProvider(roots, $q, $log) {
|
function RootModelProvider(roots, $q, $log) {
|
||||||
// Pull out identifiers to used as ROOT's
|
// Pull out identifiers to used as ROOT's
|
||||||
var ids = roots.map(function (root) { return root.id; });
|
var ids = roots.map(function (root) {
|
||||||
|
return root.id;
|
||||||
|
});
|
||||||
|
|
||||||
// Assign an initial location to root models
|
// Assign an initial location to root models
|
||||||
roots.forEach(function (root) {
|
roots.forEach(function (root) {
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ define(
|
|||||||
* corresponding keys in the recursive step.
|
* corresponding keys in the recursive step.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param a the first object to be merged
|
* @param modelA the first object to be merged
|
||||||
* @param b the second object to be merged
|
* @param modelB the second object to be merged
|
||||||
* @param merger the merger, as described above
|
* @param merger the merger, as described above
|
||||||
* @returns {*} the result of merging `a` and `b`
|
* @returns {*} the result of merging `modelA` and `modelB`
|
||||||
* @constructor
|
* @constructor
|
||||||
* @memberof platform/core
|
* @memberof platform/core
|
||||||
*/
|
*/
|
||||||
function mergeModels(a, b, merger) {
|
function mergeModels(modelA, modelB, merger) {
|
||||||
var mergeFunction;
|
var mergeFunction;
|
||||||
|
|
||||||
function mergeArrays(a, b) {
|
function mergeArrays(a, b) {
|
||||||
@@ -93,11 +93,11 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
|
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
|
||||||
(Array.isArray(a) && Array.isArray(b)) ? mergeArrays :
|
(Array.isArray(modelA) && Array.isArray(modelB)) ? mergeArrays :
|
||||||
(a instanceof Object && b instanceof Object) ? mergeObjects :
|
(modelA instanceof Object && modelB instanceof Object) ? mergeObjects :
|
||||||
mergeOther;
|
mergeOther;
|
||||||
|
|
||||||
return mergeFunction(a, b);
|
return mergeFunction(modelA, modelB);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeModels;
|
return mergeModels;
|
||||||
|
|||||||
@@ -33,8 +33,12 @@ define(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
identity: {
|
identity: {
|
||||||
toModelValue: function (v) { return v; },
|
toModelValue: function (v) {
|
||||||
toFormValue: function (v) { return v; }
|
return v;
|
||||||
|
},
|
||||||
|
toFormValue: function (v) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ARRAY_SUFFIX = '[]';
|
ARRAY_SUFFIX = '[]';
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lookupTypeDef(typeKey) {
|
function lookupTypeDef(typeKey) {
|
||||||
function buildTypeDef(typeKey) {
|
function buildTypeDef(typeKeyToBuild) {
|
||||||
var typeDefs = typeDefinitions[typeKey] || [],
|
var typeDefs = typeDefinitions[typeKeyToBuild] || [],
|
||||||
inherits = typeDefs.map(function (typeDef) {
|
inherits = typeDefs.map(function (typeDef) {
|
||||||
return asArray(typeDef.inherits || []);
|
return asArray(typeDef.inherits || []);
|
||||||
}).reduce(function (a, b) {
|
}).reduce(function (a, b) {
|
||||||
|
|||||||
@@ -105,15 +105,15 @@ define(
|
|||||||
// Check if an object has all capabilities designated as `needs`
|
// Check if an object has all capabilities designated as `needs`
|
||||||
// for a view. Exposing a capability via delegation is taken to
|
// for a view. Exposing a capability via delegation is taken to
|
||||||
// satisfy this filter if `allowDelegation` is true.
|
// satisfy this filter if `allowDelegation` is true.
|
||||||
function capabilitiesMatch(domainObject, capabilities, allowDelegation) {
|
function capabilitiesMatch(domainObj, capabilities, allowDelegation) {
|
||||||
var delegation = domainObject.getCapability("delegation");
|
var delegation = domainObj.getCapability("delegation");
|
||||||
|
|
||||||
allowDelegation = allowDelegation && (delegation !== undefined);
|
allowDelegation = allowDelegation && (delegation !== undefined);
|
||||||
|
|
||||||
// Check if an object has (or delegates, if allowed) a
|
// Check if an object has (or delegates, if allowed) a
|
||||||
// capability.
|
// capability.
|
||||||
function hasCapability(c) {
|
function hasCapability(c) {
|
||||||
return domainObject.hasCapability(c) ||
|
return domainObj.hasCapability(c) ||
|
||||||
(allowDelegation && delegation.doesDelegateCapability(c));
|
(allowDelegation && delegation.doesDelegateCapability(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,13 +128,13 @@ define(
|
|||||||
|
|
||||||
// Check if a view and domain object type can be paired;
|
// Check if a view and domain object type can be paired;
|
||||||
// both can restrict the others they accept.
|
// both can restrict the others they accept.
|
||||||
function viewMatchesType(view, type) {
|
function viewMatchesType(view, objType) {
|
||||||
var views = type && (type.getDefinition() || {}).views,
|
var views = objType && (objType.getDefinition() || {}).views,
|
||||||
matches = true;
|
matches = true;
|
||||||
|
|
||||||
// View is restricted to a certain type
|
// View is restricted to a certain type
|
||||||
if (view.type) {
|
if (view.type) {
|
||||||
matches = matches && type && type.instanceOf(view.type);
|
matches = matches && objType && objType.instanceOf(view.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type wishes to restrict its specific views
|
// Type wishes to restrict its specific views
|
||||||
|
|||||||
@@ -33,29 +33,41 @@ define(
|
|||||||
actionProvider;
|
actionProvider;
|
||||||
|
|
||||||
function SimpleAction() {
|
function SimpleAction() {
|
||||||
return { perform: function () { return "simple"; } };
|
return { perform: function () {
|
||||||
|
return "simple";
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
|
|
||||||
function CategorizedAction() {
|
function CategorizedAction() {
|
||||||
return { perform: function () { return "categorized"; } };
|
return { perform: function () {
|
||||||
|
return "categorized";
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
CategorizedAction.category = "someCategory";
|
CategorizedAction.category = "someCategory";
|
||||||
|
|
||||||
function KeyedAction() {
|
function KeyedAction() {
|
||||||
return { perform: function () { return "keyed"; } };
|
return { perform: function () {
|
||||||
|
return "keyed";
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
KeyedAction.key = "someKey";
|
KeyedAction.key = "someKey";
|
||||||
|
|
||||||
function CategorizedKeyedAction() {
|
function CategorizedKeyedAction() {
|
||||||
return { perform: function () { return "both"; } };
|
return { perform: function () {
|
||||||
|
return "both";
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
CategorizedKeyedAction.key = "someKey";
|
CategorizedKeyedAction.key = "someKey";
|
||||||
CategorizedKeyedAction.category = "someCategory";
|
CategorizedKeyedAction.category = "someCategory";
|
||||||
|
|
||||||
function MetadataAction() {
|
function MetadataAction() {
|
||||||
return {
|
return {
|
||||||
perform: function () { return "metadata"; },
|
perform: function () {
|
||||||
getMetadata: function () { return "custom metadata"; }
|
return "metadata";
|
||||||
|
},
|
||||||
|
getMetadata: function () {
|
||||||
|
return "custom metadata";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
MetadataAction.key = "metadata";
|
MetadataAction.key = "metadata";
|
||||||
|
|||||||
@@ -114,7 +114,9 @@ define(
|
|||||||
mockObjectService.getObjects.andReturn(mockPromise({x: mockChild}));
|
mockObjectService.getObjects.andReturn(mockPromise({x: mockChild}));
|
||||||
mockChild.getCapability.andReturn(undefined);
|
mockChild.getCapability.andReturn(undefined);
|
||||||
|
|
||||||
composition.invoke().then(function (c) { result = c; });
|
composition.invoke().then(function (c) {
|
||||||
|
result = c;
|
||||||
|
});
|
||||||
|
|
||||||
// Should have been added by a wrapper
|
// Should have been added by a wrapper
|
||||||
expect(result[0].getCapability('context')).toBeDefined();
|
expect(result[0].getCapability('context')).toBeDefined();
|
||||||
|
|||||||
@@ -31,16 +31,22 @@ define(
|
|||||||
var mockLog,
|
var mockLog,
|
||||||
provider;
|
provider;
|
||||||
|
|
||||||
function BasicCapability() { return; }
|
function BasicCapability() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
BasicCapability.key = "basic";
|
BasicCapability.key = "basic";
|
||||||
|
|
||||||
function ApplicableCapability() { return; }
|
function ApplicableCapability() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ApplicableCapability.key = "applicable";
|
ApplicableCapability.key = "applicable";
|
||||||
ApplicableCapability.appliesTo = function (model) {
|
ApplicableCapability.appliesTo = function (model) {
|
||||||
return !model.isNotApplicable;
|
return !model.isNotApplicable;
|
||||||
};
|
};
|
||||||
|
|
||||||
function KeylessCapability() { return; }
|
function KeylessCapability() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockLog = jasmine.createSpyObj(
|
mockLog = jasmine.createSpyObj(
|
||||||
|
|||||||
@@ -36,7 +36,11 @@ define(
|
|||||||
object = {},
|
object = {},
|
||||||
delegation;
|
delegation;
|
||||||
|
|
||||||
function capture(k) { return function (v) { captured[k] = v; }; }
|
function capture(k) {
|
||||||
|
return function (v) {
|
||||||
|
captured[k] = v;
|
||||||
|
};
|
||||||
|
}
|
||||||
function TestDomainObject(caps, id) {
|
function TestDomainObject(caps, id) {
|
||||||
return {
|
return {
|
||||||
getId: function () {
|
getId: function () {
|
||||||
@@ -68,11 +72,15 @@ define(
|
|||||||
captured = {};
|
captured = {};
|
||||||
typeDef = {};
|
typeDef = {};
|
||||||
typeDef.delegates = ["foo"];
|
typeDef.delegates = ["foo"];
|
||||||
type = { getDefinition: function () { return typeDef; } };
|
type = { getDefinition: function () {
|
||||||
|
return typeDef;
|
||||||
|
} };
|
||||||
children = [];
|
children = [];
|
||||||
capabilities = {
|
capabilities = {
|
||||||
type: type,
|
type: type,
|
||||||
composition: { invoke: function () { return mockPromise(children); } }
|
composition: { invoke: function () {
|
||||||
|
return mockPromise(children);
|
||||||
|
} }
|
||||||
};
|
};
|
||||||
object = new TestDomainObject(capabilities);
|
object = new TestDomainObject(capabilities);
|
||||||
|
|
||||||
|
|||||||
@@ -73,16 +73,16 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("uses the instantiate service to create domain objects", function () {
|
it("uses the instantiate service to create domain objects", function () {
|
||||||
var mockDomainObject = jasmine.createSpyObj('domainObject', [
|
var mockDomainObj = jasmine.createSpyObj('domainObject', [
|
||||||
'getId',
|
'getId',
|
||||||
'getModel',
|
'getModel',
|
||||||
'getCapability',
|
'getCapability',
|
||||||
'useCapability',
|
'useCapability',
|
||||||
'hasCapability'
|
'hasCapability'
|
||||||
]), testModel = { someKey: "some value" };
|
]), testModel = { someKey: "some value" };
|
||||||
mockInstantiate.andReturn(mockDomainObject);
|
mockInstantiate.andReturn(mockDomainObj);
|
||||||
expect(instantiation.instantiate(testModel))
|
expect(instantiation.instantiate(testModel))
|
||||||
.toBe(mockDomainObject);
|
.toBe(mockDomainObj);
|
||||||
expect(mockInstantiate)
|
expect(mockInstantiate)
|
||||||
.toHaveBeenCalledWith({
|
.toHaveBeenCalledWith({
|
||||||
someKey: "some value",
|
someKey: "some value",
|
||||||
|
|||||||
@@ -35,8 +35,12 @@ define(
|
|||||||
topic,
|
topic,
|
||||||
mockNow,
|
mockNow,
|
||||||
domainObject = {
|
domainObject = {
|
||||||
getId: function () { return "test-id"; },
|
getId: function () {
|
||||||
getModel: function () { return testModel; }
|
return "test-id";
|
||||||
|
},
|
||||||
|
getModel: function () {
|
||||||
|
return testModel;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mutation;
|
mutation;
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,12 @@ define(
|
|||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject = {
|
mockDomainObject = {
|
||||||
getId: function () { return id; },
|
getId: function () {
|
||||||
getModel: function () { return model; },
|
return id;
|
||||||
|
},
|
||||||
|
getModel: function () {
|
||||||
|
return model;
|
||||||
|
},
|
||||||
useCapability: jasmine.createSpy()
|
useCapability: jasmine.createSpy()
|
||||||
};
|
};
|
||||||
// Simulate mutation capability
|
// Simulate mutation capability
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("ensures a single object instance, even for multiple concurrent calls", function () {
|
it("ensures a single object instance, even for multiple concurrent calls", function () {
|
||||||
var promiseA, promiseB, mockCallback = jasmine.createSpy();
|
var promiseA, promiseB;
|
||||||
|
|
||||||
promiseA = fakePromise();
|
promiseA = fakePromise();
|
||||||
promiseB = fakePromise();
|
promiseB = fakePromise();
|
||||||
@@ -126,7 +126,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("is robust against updating with undefined values", function () {
|
it("is robust against updating with undefined values", function () {
|
||||||
var promiseA, promiseB, mockCallback = jasmine.createSpy();
|
var promiseA, promiseB;
|
||||||
|
|
||||||
promiseA = fakePromise();
|
promiseA = fakePromise();
|
||||||
promiseB = fakePromise();
|
promiseB = fakePromise();
|
||||||
|
|||||||
@@ -61,14 +61,18 @@ define(
|
|||||||
it("provides models for any IDs which are missing", function () {
|
it("provides models for any IDs which are missing", function () {
|
||||||
var models;
|
var models;
|
||||||
decorator.getModels(['testId', 'otherId'])
|
decorator.getModels(['testId', 'otherId'])
|
||||||
.then(function (m) { models = m; });
|
.then(function (m) {
|
||||||
|
models = m;
|
||||||
|
});
|
||||||
expect(models.otherId).toBeDefined();
|
expect(models.otherId).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not overwrite existing models", function () {
|
it("does not overwrite existing models", function () {
|
||||||
var models;
|
var models;
|
||||||
decorator.getModels(['testId', 'otherId'])
|
decorator.getModels(['testId', 'otherId'])
|
||||||
.then(function (m) { models = m; });
|
.then(function (m) {
|
||||||
|
models = m;
|
||||||
|
});
|
||||||
expect(models.testId).toEqual({ someKey: "some value" });
|
expect(models.testId).toEqual({ someKey: "some value" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
mockQ.all.andReturn({
|
mockQ.all.andReturn({
|
||||||
then: function (c) { return c(modelList); }
|
then: function (c) {
|
||||||
|
return c(modelList);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
aggregator = new ModelAggregator(mockQ, mockProviders);
|
aggregator = new ModelAggregator(mockQ, mockProviders);
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function capture(value) { captured = value; }
|
function capture(value) {
|
||||||
|
captured = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("provides models from extension declarations", function () {
|
it("provides models from extension declarations", function () {
|
||||||
var mockPromise = { then: function () { return; } };
|
var mockPromise = { then: function () {
|
||||||
|
return;
|
||||||
|
} };
|
||||||
mockQ.when.andReturn(mockPromise);
|
mockQ.when.andReturn(mockPromise);
|
||||||
|
|
||||||
// Verify that we got the promise as the return value
|
// Verify that we got the promise as the return value
|
||||||
|
|||||||
@@ -74,10 +74,14 @@ define(
|
|||||||
|
|
||||||
it("supports instance-of checks by type object", function () {
|
it("supports instance-of checks by type object", function () {
|
||||||
expect(type.instanceOf({
|
expect(type.instanceOf({
|
||||||
getKey: function () { return 'test-parent-1'; }
|
getKey: function () {
|
||||||
|
return 'test-parent-1';
|
||||||
|
}
|
||||||
})).toBeTruthy();
|
})).toBeTruthy();
|
||||||
expect(type.instanceOf({
|
expect(type.instanceOf({
|
||||||
getKey: function () { return 'some-other-type'; }
|
getKey: function () {
|
||||||
|
return 'some-other-type';
|
||||||
|
}
|
||||||
})).toBeFalsy();
|
})).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ define(
|
|||||||
it("restricts typed views to matching types", function () {
|
it("restricts typed views to matching types", function () {
|
||||||
var testType = "testType",
|
var testType = "testType",
|
||||||
testView = { key: "x", type: testType },
|
testView = { key: "x", type: testType },
|
||||||
provider = new ViewProvider([testView], mockLog);
|
viewProvider = new ViewProvider([testView], mockLog);
|
||||||
|
|
||||||
// Include a "type" capability
|
// Include a "type" capability
|
||||||
capabilities.type = jasmine.createSpyObj(
|
capabilities.type = jasmine.createSpyObj(
|
||||||
@@ -120,21 +120,21 @@ define(
|
|||||||
|
|
||||||
// Should be included when types match
|
// Should be included when types match
|
||||||
capabilities.type.instanceOf.andReturn(true);
|
capabilities.type.instanceOf.andReturn(true);
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([testView]);
|
.toEqual([testView]);
|
||||||
expect(capabilities.type.instanceOf)
|
expect(capabilities.type.instanceOf)
|
||||||
.toHaveBeenCalledWith(testType);
|
.toHaveBeenCalledWith(testType);
|
||||||
|
|
||||||
// ...but not when they don't
|
// ...but not when they don't
|
||||||
capabilities.type.instanceOf.andReturn(false);
|
capabilities.type.instanceOf.andReturn(false);
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([]);
|
.toEqual([]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("enforces view restrictions from types", function () {
|
it("enforces view restrictions from types", function () {
|
||||||
var testView = { key: "x" },
|
var testView = { key: "x" },
|
||||||
provider = new ViewProvider([testView], mockLog);
|
viewProvider = new ViewProvider([testView], mockLog);
|
||||||
|
|
||||||
// Include a "type" capability
|
// Include a "type" capability
|
||||||
capabilities.type = jasmine.createSpyObj(
|
capabilities.type = jasmine.createSpyObj(
|
||||||
@@ -146,13 +146,13 @@ define(
|
|||||||
// Should be included when view keys match
|
// Should be included when view keys match
|
||||||
capabilities.type.getDefinition
|
capabilities.type.getDefinition
|
||||||
.andReturn({ views: [testView.key]});
|
.andReturn({ views: [testView.key]});
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([testView]);
|
.toEqual([testView]);
|
||||||
|
|
||||||
// ...but not when they don't
|
// ...but not when they don't
|
||||||
capabilities.type.getDefinition
|
capabilities.type.getDefinition
|
||||||
.andReturn({ views: ["somethingElse"]});
|
.andReturn({ views: ["somethingElse"]});
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([]);
|
.toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -126,11 +126,11 @@ define(
|
|||||||
|
|
||||||
label = this.verb + " To";
|
label = this.verb + " To";
|
||||||
|
|
||||||
validateLocation = function (newParent) {
|
validateLocation = function (newParentObj) {
|
||||||
var newContext = self.cloneContext();
|
var newContext = self.cloneContext();
|
||||||
newContext.selectedObject = object;
|
newContext.selectedObject = object;
|
||||||
newContext.domainObject = newParent;
|
newContext.domainObject = newParentObj;
|
||||||
return composeService.validate(object, newParent) &&
|
return composeService.validate(object, newParentObj) &&
|
||||||
self.policyService.allow("action", self, newContext);
|
self.policyService.allow("action", self, newContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,8 +139,8 @@ define(
|
|||||||
label,
|
label,
|
||||||
validateLocation,
|
validateLocation,
|
||||||
currentParent
|
currentParent
|
||||||
).then(function (newParent) {
|
).then(function (newParentObj) {
|
||||||
return composeService.perform(object, newParent);
|
return composeService.perform(object, newParentObj);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ define(
|
|||||||
|
|
||||||
// Combines caller-provided filter (if any) with the
|
// Combines caller-provided filter (if any) with the
|
||||||
// baseline behavior of respecting creation policy.
|
// baseline behavior of respecting creation policy.
|
||||||
function filterWithPolicy(domainObject) {
|
function filterWithPolicy(domainObj) {
|
||||||
return (!filter || filter(domainObject)) &&
|
return (!filter || filter(domainObj)) &&
|
||||||
policyService.allow(
|
policyService.allow(
|
||||||
"creation",
|
"creation",
|
||||||
domainObject.getCapability("type")
|
domainObj.getCapability("type")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,8 @@ define(
|
|||||||
// set, however linked objects will not.
|
// set, however linked objects will not.
|
||||||
return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee);
|
return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee);
|
||||||
});
|
});
|
||||||
});}, self.$q.when(undefined)
|
});
|
||||||
|
}, self.$q.when(undefined)
|
||||||
).then(function () {
|
).then(function () {
|
||||||
//Replace any references in the cloned parent to
|
//Replace any references in the cloned parent to
|
||||||
// contained objects that have been composed with the
|
// contained objects that have been composed with the
|
||||||
|
|||||||
@@ -67,7 +67,9 @@ define(
|
|||||||
.then(function (objectInNewContext) {
|
.then(function (objectInNewContext) {
|
||||||
return parentObject.getCapability('persistence')
|
return parentObject.getCapability('persistence')
|
||||||
.persist()
|
.persist()
|
||||||
.then(function () { return objectInNewContext; });
|
.then(function () {
|
||||||
|
return objectInNewContext;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ define(
|
|||||||
|
|
||||||
return dialogService
|
return dialogService
|
||||||
.getUserInput(formStructure, formState)
|
.getUserInput(formStructure, formState)
|
||||||
.then(function (formState) {
|
.then(function (userFormState) {
|
||||||
return formState.location;
|
return userFormState.location;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user