diff --git a/.jscsrc b/.jscsrc index ac17b5dc9c..7229391def 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,3 +1,5 @@ { - "preset": "crockford" + "preset": "crockford", + "requireMultipleVarDecl": false, + "requireVarDeclFirst": false } diff --git a/.jshintrc b/.jshintrc index a8e18932fd..dc2b733533 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,4 +1,23 @@ { - "validthis": true, - "laxbreak": true + "bitwise": true, + "browser": true, + "curly": true, + "eqeqeq": true, + "forin": true, + "freeze": true, + "funcscope": false, + "futurehostile": true, + "latedef": true, + "noarg": true, + "nocomma": true, + "nonbsp": true, + "nonew": true, + "predef": [ + "define", + "Promise" + ], + "shadow": "outer", + "strict": "implied", + "undef": true, + "unused": "vars" } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e726007800..29dbbc46cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -# Contributing to Open MCT Web +# Contributing to Open MCT -This document describes the process of contributing to Open MCT Web as well +This document describes the process of contributing to Open MCT as well as the standards that will be applied when evaluating contributions. Please be aware that additional agreements will be necessary before we can @@ -21,9 +21,9 @@ The short version: ## Contribution Process -Open MCT Web uses git for software version control, and for branching and +Open MCT uses git for software version control, and for branching and merging. The central repository is at -https://github.com/nasa/openmctweb.git. +https://github.com/nasa/openmct.git. ### Roles @@ -116,18 +116,18 @@ the merge back to the master branch. ## Standards -Contributions to Open MCT Web are expected to meet the following standards. +Contributions to Open MCT are expected to meet the following standards. In addition, reviewers should use general discretion before accepting changes. ### Code Standards -JavaScript sources in Open MCT Web must satisfy JSLint under its default +JavaScript sources in Open MCT must satisfy JSLint under its default settings. This is verified by the command line build. #### Code Guidelines -JavaScript sources in Open MCT Web should: +JavaScript sources in Open MCT should: * Use four spaces for indentation. Tabs should not be used. * Include JSDoc for any exposed API (e.g. public methods, constructors.) @@ -159,7 +159,7 @@ JavaScript sources in Open MCT Web should: * Third, imperative statements. * Finally, the returned value. -Deviations from Open MCT Web code style guidelines require two-party agreement, +Deviations from Open MCT code style guidelines require two-party agreement, typically from the author of the change and its reviewer. #### Code Example @@ -260,7 +260,7 @@ these standards. ## Issue Reporting -Issues are tracked at https://github.com/nasa/openmctweb/issues +Issues are tracked at https://github.com/nasa/openmct/issues Issues should include: diff --git a/README.md b/README.md index ed488a0e5c..dc18671dd3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Open MCT Web +# Open MCT -Open MCT Web is a web-based platform for mission operations user interface +Open MCT is a web-based platform for mission operations user interface software. ## Bundles @@ -8,7 +8,7 @@ software. A bundle is a group of software components (including source code, declared as AMD modules, as well as resources such as images and HTML templates) that are intended to be added or removed as a single unit. A plug-in for -Open MCT Web will be expressed as a bundle; platform components are also +Open MCT will be expressed as a bundle; platform components are also expressed as bundles. A bundle is also just a directory which contains a file `bundle.json`, @@ -16,7 +16,7 @@ which declares its contents. The file `bundles.json` (note the plural), at the top level of the repository, is a JSON file containing an array of all bundles (expressed as -directory names) to include in a running instance of Open MCT Web. Adding or +directory names) to include in a running instance of Open MCT. Adding or removing paths from this list will add or remove bundles from the running application. @@ -56,7 +56,7 @@ To run: ## Build -Open MCT Web is built using [`npm`](http://npmjs.com/) +Open MCT is built using [`npm`](http://npmjs.com/) and [`gulp`](http://gulpjs.com/). To build: @@ -64,18 +64,18 @@ To build: `npm run prepublish` This will compile and minify JavaScript sources, as well as copy over assets. -The contents of the `dist` folder will contain a runnable Open MCT Web +The contents of the `dist` folder will contain a runnable Open MCT instance (e.g. by starting an HTTP server in that directory), including: -* A `main.js` file containing Open MCT Web source code. +* A `main.js` file containing Open MCT source code. * Various assets in the `example` and `platform` directories. -* An `index.html` that runs Open MCT Web in its default configuration. +* An `index.html` that runs Open MCT in its default configuration. Additional `gulp` tasks are defined in [the gulpfile](gulpfile.js). ### Building Documentation -Open MCT Web's documentation is generated by an +Open MCT's documentation is generated by an [npm](https://www.npmjs.com/)-based build. It has additional dependencies that may not be available on every platform and thus is not covered in the standard npm install. Ensure your system has [libcairo](http://cairographics.org/) @@ -89,7 +89,7 @@ Documentation will be generated in `target/docs`. # Glossary -Certain terms are used throughout Open MCT Web with consistent meanings +Certain terms are used throughout Open MCT with consistent meanings or conventions. Any deviations from the below are issues and should be addressed (either by updating this glossary or changing code to reflect correct usage.) Other developer documentation, particularly in-line @@ -112,7 +112,7 @@ documentation, may presume an understanding of these terms. (Most often used in the context of extensions, domain object models, or other similar application-specific objects.) * _domain object_: A meaningful object to the user; a distinct thing in - the work support by Open MCT Web. Anything that appears in the left-hand + the work support by Open MCT. Anything that appears in the left-hand tree is a domain object. * _extension_: An extension is a unit of functionality exposed to the platform in a declarative fashion by a bundle. For more diff --git a/app.js b/app.js index 90c30c9e26..8e7bb15ec2 100644 --- a/app.js +++ b/app.js @@ -19,6 +19,7 @@ // Defaults options.port = options.port || options.p || 8080; + options.directory = options.directory || options.D || '.'; ['include', 'exclude', 'i', 'x'].forEach(function (opt) { options[opt] = options[opt] || []; // Make sure includes/excludes always end up as arrays @@ -36,6 +37,7 @@ console.log(" --port, -p Specify port."); console.log(" --include, -i Include the specified bundle."); console.log(" --exclude, -x Exclude the specified bundle."); + console.log(" --directory, -D Serve files from specified directory."); console.log(""); process.exit(0); } @@ -71,7 +73,7 @@ }); // Expose everything else as static files - app.use(express['static']('.')); + app.use(express['static'](options.directory)); // Finally, open the HTTP server app.listen(options.port); diff --git a/bower.json b/bower.json index 7285aad9e2..7c913754cf 100644 --- a/bower.json +++ b/bower.json @@ -1,10 +1,10 @@ { - "name": "openmctweb", - "description": "The OpenMCTWeb core platform", + "name": "openmct", + "description": "The Open MCT core platform", "main": "", "license": "Apache-2.0", "moduleType": [], - "homepage": "http://nasa.github.io/openmctweb/", + "homepage": "http://nasa.github.io/openmct/", "private": true, "dependencies": { "angular": "1.4.4", diff --git a/build-docs.sh b/build-docs.sh index c318a0dbda..87ada35524 100755 --- a/build-docs.sh +++ b/build-docs.sh @@ -22,17 +22,19 @@ #* 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" -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. # Don't worry, as this entire directory will get trashed inbetween builds. REMOTE_NAME="documentation" -WEBSITE_BRANCH="gh-pages" +WEBSITE_BRANCH="master" # Clean output directory, JSDOC will recreate if [ -d $OUTPUT_DIRECTORY ]; then @@ -40,23 +42,21 @@ if [ -d $OUTPUT_DIRECTORY ]; then fi npm run docs -cd $OUTPUT_DIRECTORY || exit 1 -echo "git init" -git init +echo "git clone $REPOSITORY_URL website" +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. git config user.email "buildbot@circleci.com" git config user.name "BuildBot" -echo "git remote add $REMOTE_NAME $REPOSITORY_URL" -git remote add $REMOTE_NAME $REPOSITORY_URL echo "git add ." git add . -echo "git commit -m \"Generate docs from build $BUILD_SHA\"" -git commit -m "Generate docs from build $BUILD_SHA" - -echo "git push $REMOTE_NAME HEAD:$WEBSITE_BRANCH -f" -git push $REMOTE_NAME HEAD:$WEBSITE_BRANCH -f - -echo "Documentation pushed to gh-pages branch." +echo "git commit -m \"Docs updated from build $BUILD_SHA\"" +git commit -m "Docs updated from build $BUILD_SHA" +# Push to the website repo +git push diff --git a/circle.yml b/circle.yml index d163b3ee0c..7caa57740d 100644 --- a/circle.yml +++ b/circle.yml @@ -2,17 +2,23 @@ deployment: production: branch: master commands: - - npm install canvas nomnoml - - ./build-docs.sh - - git push git@heroku.com:openmctweb-demo.git $CIRCLE_SHA1:refs/heads/master - openmctweb-staging-un: - branch: nem_prototype + - 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: + branch: live_demo heroku: - appname: openmctweb-staging-un + appname: openmct-demo openmctweb-staging-deux: branch: mobile heroku: appname: openmctweb-staging-deux test: post: - - npm run jshint --silent + - gulp lint + +general: + branches: + ignore: + - gh-pages diff --git a/docs/footer.html b/docs/footer.html index e4e5daee87..a6878b0cac 100644 --- a/docs/footer.html +++ b/docs/footer.html @@ -1,9 +1,3 @@
- - This document is styled using - - https://github.com/jasonm23/markdown-css-themes - . - diff --git a/docs/header.html b/docs/header.html index e6be56f543..c945996f4a 100644 --- a/docs/header.html +++ b/docs/header.html @@ -1,7 +1,9 @@ + href="//nasa.github.io/openmct/static/res/css/styles.css"> + diff --git a/docs/src/architecture/framework.md b/docs/src/architecture/framework.md index 229bee39c4..e269e38f61 100644 --- a/docs/src/architecture/framework.md +++ b/docs/src/architecture/framework.md @@ -5,7 +5,7 @@ software components to communicate. The software components it recognizes are: * _Extensions_: Individual units of functionality that can be added to - or removed from Open MCT Web. _Extension categories_ distinguish what + or removed from Open MCT. _Extension categories_ distinguish what type of functionality is being added/removed. * _Bundles_: A grouping of related extensions (named after an analogous concept from [OSGi](http://www.osgi.org/)) @@ -19,7 +19,7 @@ manner which the framework layer can understand. ```nomnoml #direction: down -[Open MCT Web| +[Open MCT| [Dependency injection framework]-->[Platform bundle #1] [Dependency injection framework]-->[Platform bundle #2] [Dependency injection framework]-->[Plugin bundle #1] @@ -35,7 +35,7 @@ manner which the framework layer can understand. ``` The "dependency injection framework" in this case is -[AngularJS](https://angularjs.org/). Open MCT Web's framework layer +[AngularJS](https://angularjs.org/). Open MCT's framework layer is really just a thin wrapper over Angular that recognizes the concepts of bundles and extensions (as declared in JSON files) and registering extensions with Angular. It additionally acts as a @@ -60,7 +60,7 @@ activities which were performed by the framework component. ## Application Initialization -The framework component initializes an Open MCT Web application following +The framework component initializes an Open MCT application following a simple sequence of steps. ```nomnoml @@ -97,7 +97,7 @@ a simple sequence of steps. [Extension]o->[Dependency #3] ``` -Open MCT Web's architecture relies on a simple premise: Individual units +Open MCT's architecture relies on a simple premise: Individual units (extensions) only have access to the dependencies they declare that they need, and they acquire references to these dependencies via dependency injection. This has several desirable traits: @@ -121,11 +121,11 @@ injection. This has several desirable traits: the framework. A drawback to this approach is that it makes it difficult to define -"the architecture" of Open MCT Web, in terms of describing the specific +"the architecture" of Open MCT, in terms of describing the specific units that interact at run-time. The run-time architecture is determined by the framework as the consequence of wiring together dependencies. As such, the specific architecture of any given application built on -Open MCT Web can look very different. +Open MCT can look very different. Keeping that in mind, there are a few useful patterns supported by the framework that are useful to keep in mind. @@ -229,4 +229,4 @@ otherwise a single provider) will be exposed as a single service that other extensions can acquire through dependency injection. Because all components of the same type of service expose the same interface, users of that service do not need to be aware that they are talking to an -aggregator or a provider, for instance. \ No newline at end of file +aggregator or a provider, for instance. diff --git a/docs/src/architecture/index.md b/docs/src/architecture/index.md index 7354402d0c..a4586a3542 100644 --- a/docs/src/architecture/index.md +++ b/docs/src/architecture/index.md @@ -1,14 +1,14 @@ # Introduction The purpose of this document is to familiarize developers with the -overall architecture of Open MCT Web. +overall architecture of Open MCT. The target audience includes: * _Platform maintainers_: Individuals involved in developing, extending, and maintaing capabilities of the platform. * _Integration developers_: Individuals tasked with integrated - Open MCT Web into a larger system, who need to understand + Open MCT into a larger system, who need to understand its inner workings sufficiently to complete this integration. As the focus of this document is on architecture, whenever possible @@ -17,25 +17,25 @@ omitted. These details may be found in the developer guide. # Overview -Open MCT Web is client software: It runs in a web browser and +Open MCT is client software: It runs in a web browser and provides a user interface, while communicating with various server-side resources through browser APIs. ```nomnoml #direction: right -[Client|[Browser|[Open MCT Web]->[Browser APIs]]] +[Client|[Browser|[Open MCT]->[Browser APIs]]] [Server|[Web services]] [Client]<->[Server] ``` -While Open MCT Web can be configured to run as a standalone client, +While Open MCT can be configured to run as a standalone client, this is rarely very useful. Instead, it is intended to be used as a display and interaction layer for information obtained from a variety of back-end services. Doing so requires authoring or utilizing -adapter plugins which allow Open MCT Web to interact with these services. +adapter plugins which allow Open MCT to interact with these services. Typically, the pattern here is to provide a known interface that -Open MCT Web can utilize, and implement it such that it interacts with +Open MCT can utilize, and implement it such that it interacts with whatever back-end provides the relevant information. Examples of back-ends that can be utilized in this fashion include databases for the persistence of user-created objects, or sources of @@ -43,13 +43,13 @@ telemetry data. ## Software Architecture -The simplest overview of Open MCT Web is to look at it as a "layered" +The simplest overview of Open MCT is to look at it as a "layered" architecture, where each layer more clearly specifies the behavior of the software. ```nomnoml #direction: down -[Open MCT Web| +[Open MCT| [Platform]<->[Application] [Framework]->[Application] [Framework]->[Platform] @@ -64,14 +64,14 @@ These layers are: established an abstraction by which different software components may communicate and/or interact. * [_Platform_](platform.md): The platform layer defines the general look, - feel, and behavior of Open MCT Web. This includes user-facing components like + feel, and behavior of Open MCT. This includes user-facing components like Browse mode and Edit mode, as well as underlying elements of the information model and the general service infrastructure. * _Application_: The application layer defines specific features of - an application built on Open MCT Web. This includes adapters to + an application built on Open MCT. This includes adapters to specific back-ends, new types of things for users to create, and new ways of visualizing objects within the system. This layer - typically consists of a mix of custom plug-ins to Open MCT Web, + typically consists of a mix of custom plug-ins to Open MCT, as well as optional features (such as Plot view) included alongside the platform. diff --git a/docs/src/architecture/platform.md b/docs/src/architecture/platform.md index a59a6ebf9c..1f5e087a11 100644 --- a/docs/src/architecture/platform.md +++ b/docs/src/architecture/platform.md @@ -1,6 +1,6 @@ # Overview -The Open MCT Web platform utilizes the [framework layer](Framework.md) +The Open MCT platform utilizes the [framework layer](Framework.md) to provide an extensible baseline for applications which includes: * A common user interface (and user interface paradigm) for dealing with @@ -16,7 +16,7 @@ building application, the platform adds more specificity by defining additional extension types and allowing for integration with back end components. -The run-time architecture of an Open MCT Web application can be categorized +The run-time architecture of an Open MCT application can be categorized into certain high-level tiers: ```nomnoml @@ -29,7 +29,7 @@ into certain high-level tiers: [Browser APIs]->[Back-end] ``` -Applications built using Open MCT Web may add or configure functionality +Applications built using Open MCT may add or configure functionality in __any of these tiers__. * _DOM_: The rendered HTML document, composed from HTML templates which @@ -60,7 +60,7 @@ in __any of these tiers__. functionality needed to support the information model. This includes exposing underlying sets of extensions and mediating with the back-end. -* _Back-end_: The back-end is out of the scope of Open MCT Web, except +* _Back-end_: The back-end is out of the scope of Open MCT, except for the interfaces which are utilized by adapters participating in the service infrastructure. Includes the underlying persistence stores, telemetry  streams, and so forth which the Open MCT Web client is being used to interact  @@ -70,15 +70,15 @@ in __any of these tiers__. Once the [application has been initialized](Framework.md#application-initialization) -Open MCT Web primarily operates in an event-driven paradigm; various +Open MCT primarily operates in an event-driven paradigm; various events (mouse clicks, timers firing, receiving responses to XHRs) trigger the invocation of functions, typically in the presentation layer for user actions or in the service infrastructure for server responses. -The "main point of entry" into an initialized Open MCT Web application +The "main point of entry" into an initialized Open MCT application is effectively the [route](https://docs.angularjs.org/api/ngRoute/service/$route#example) -which is associated with the URL used to access Open MCT Web (or a +which is associated with the URL used to access Open MCT (or a default route.) This route will be associated with a template which will be displayed; this template will include references to directives and controllers which will be interpreted by Angular and used to @@ -107,11 +107,11 @@ both the information model and the service infrastructure. # Presentation Layer -The presentation layer of Open MCT Web is responsible for providing +The presentation layer of Open MCT is responsible for providing information to display within templates, and for handling interactions which are initiated from templated DOM elements. AngularJS acts as an intermediary between the web page as the user sees it, and the -presentation layer implemented as Open MCT Web extensions. +presentation layer implemented as Open MCT extensions. ```nomnoml [Presentation Layer| @@ -143,12 +143,12 @@ to primitives from AngularJS: attributes and tags. * [_Routes_](https://docs.angularjs.org/api/ngRoute/service/$route#example) are used to associate specific URLs (including the fragment identifier) - with specific application states. (In Open MCT Web, these are used to + with specific application states. (In Open MCT, these are used to describe the mode of usage - e.g. browse or edit - as well as to identify the object being used.) * [_Templates_](https://docs.angularjs.org/guide/templates) are partial HTML documents that will be rendered and kept up-to-date by AngularJS. - Open MCT Web introduces a custom `mct-include` directive which acts + Open MCT introduces a custom `mct-include` directive which acts as a wrapper around `ng-include` to allow templates to be referred to by symbolic names. @@ -189,10 +189,10 @@ to displaying domain objects. ] ``` -Domain objects are the most fundamental component of Open MCT Web's +Domain objects are the most fundamental component of Open MCT's information model. A domain object is some distinct thing relevant to a user's work flow, such as a telemetry channel, display, or similar. -Open MCT Web is a tool for viewing, browsing, manipulating, and otherwise +Open MCT is a tool for viewing, browsing, manipulating, and otherwise interacting with a graph of domain objects. A domain object should be conceived of as the union of the following: @@ -254,7 +254,7 @@ Concrete examples of capabilities which follow this pattern # Service Infrastructure -Most services exposed by the Open MCT Web platform follow the +Most services exposed by the Open MCT platform follow the [composite services](Framework.md#composite-services) to permit a higher degree of flexibility in how a service can be modified or customized for specific applications. @@ -327,7 +327,7 @@ A short summary of the roles of these services: [DomainObjectProvider]o-[CapabilityService] ``` -As domain objects are central to Open MCT Web's information model, +As domain objects are central to Open MCT's information model, acquiring domain objects is equally important. ```nomnoml @@ -338,7 +338,7 @@ acquiring domain objects is equally important. [ Instantiate DomainObject]->[ End] ``` -Open MCT Web includes an implementation of an `ObjectService` which +Open MCT includes an implementation of an `ObjectService` which satisfies this capability by: * Consulting the [Model Service](#model-service) to acquire domain object @@ -437,9 +437,9 @@ objects (this allows failures to be recognized and handled in groups.) The telemetry service is responsible for acquiring telemetry data. Notably, the platform does not include any providers for -`TelemetryService`; applications built on Open MCT Web will need to +`TelemetryService`; applications built on Open MCT will need to implement a provider for this service if they wish to expose telemetry -data. This is usually the most important step for integrating Open MCT Web +data. This is usually the most important step for integrating Open MCT into an existing telemetry system. Requests for telemetry data are usually initiated in the @@ -721,6 +721,6 @@ disallow. ``` The type service provides metadata about the different types of domain -objects that exist within an Open MCT Web application. The platform +objects that exist within an Open MCT application. The platform implementation reads these types in from extension category `types` -and wraps them in a JavaScript interface. \ No newline at end of file +and wraps them in a JavaScript interface. diff --git a/docs/src/guide/index.md b/docs/src/guide/index.md index 93cb95bb7a..081f1df45a 100644 --- a/docs/src/guide/index.md +++ b/docs/src/guide/index.md @@ -1,4 +1,4 @@ -# Open MCT Web Developer Guide +# Open MCT Developer Guide Victor Woeltjen [victor.woeltjen@nasa.gov](mailto:victor.woeltjen@nasa.gov) @@ -6,35 +6,36 @@ Victor Woeltjen September 23, 2015 Document Version 1.1 -Date | Version | Summary of Changes | Author -------------------- | --------- | ----------------------- | --------------- -April 29, 2015 | 0 | Initial Draft | Victor Woeltjen -May 12, 2015 | 0.1 | | Victor Woeltjen -June 4, 2015 | 1.0 | Name Changes | Victor Woeltjen -October 4, 2015 | 1.1 | Conversion to MarkDown | Andrew Henry +Date | Version | Summary of Changes | Author +------------------- | --------- | ------------------------- | --------------- +April 29, 2015 | 0 | Initial Draft | Victor Woeltjen +May 12, 2015 | 0.1 | | Victor Woeltjen +June 4, 2015 | 1.0 | Name Changes | Victor Woeltjen +October 4, 2015 | 1.1 | Conversion to MarkDown | Andrew Henry +April 5, 2016 | 1.2 | Added Mct-table directive | Andrew Henry # Introduction The purpose of this guide is to familiarize software developers with the Open MCT Web platform. -## What is Open MCT Web -Open MCT Web is a platform for building user interface and display tools, +## What is Open MCT +Open MCT is a platform for building user interface and display tools, developed at the NASA Ames Research Center in collaboration with teams at the Jet Propulsion Laboratory. It is written in HTML5, CSS3, and JavaScript, using [AngularJS](http://www.angularjs.org) as a framework. Its intended use is to create single-page web applications which integrate data and behavior from a variety of sources and domains. -Open MCT Web has been developed to support the remote operation of space +Open MCT has been developed to support the remote operation of space vehicles, so some of its features are specific to that task; however, it is flexible enough to be adapted to a variety of other application domains where a display tool oriented toward browsing, composing, and visualizing would be useful. -Open MCT Web provides: +Open MCT provides: * A common user interface paradigm which can be applied to a variety of domains -and tasks. Open MCT Web is more than a widget toolkit - it provides a standard +and tasks. Open MCT is more than a widget toolkit - it provides a standard tree-on-the-left, view-on-the-right browsing environment which you customize by adding new browsable object types, visualizations, and back-end adapters. * A plugin framework and an extensible API for introducing new application @@ -43,17 +44,17 @@ features of a variety of types. visualizations and infrastructure specific to telemetry display. ## Client-Server Relationship -Open MCT Web is client software - it runs entirely in the user's web browser. As +Open MCT is client software - it runs entirely in the user's web browser. As such, it is largely 'server agnostic'; any web server capable of serving files -from paths is capable of providing Open MCT Web. +from paths is capable of providing Open MCT. -While Open MCT Web can be configured to run as a standalone client, this is +While Open MCT can be configured to run as a standalone client, this is rarely very useful. Instead, it is intended to be used as a display and interaction layer for information obtained from a variety of back-end services. Doing so requires authoring or utilizing adapter plugins which allow Open MCT Web to interact with these services. -Typically, the pattern here is to provide a known interface that Open MCT Web +Typically, the pattern here is to provide a known interface that Open MCT can utilize, and implement it such that it interacts with whatever back-end provides the relevant information. Examples of back-ends that can be utilized in this fashion include databases for the persistence of user-created objects, or @@ -62,52 +63,52 @@ sources of telemetry data. See the [Architecture Guide](../architecture/index.md#Overview) for information on the client-server relationship. -## Developing with Open MCT Web -Building applications with Open MCT Web typically means authoring and utilizing +## Developing with Open MCT +Building applications with Open MCT typically means authoring and utilizing a set of plugins which provide application-specific details about how Open MCT Web should behave. ### Technologies -Open MCT Web sources are written in JavaScript, with a number of configuration +Open MCT sources are written in JavaScript, with a number of configuration files written in JSON. Displayable components are written in HTML5 and CSS3. -Open MCT Web is built using [AngularJS](http://www.angularjs.org) from Google. A +Open MCT is built using [AngularJS](http://www.angularjs.org) from Google. A good understanding of Angular is recommended for developers working with Open MCT Web. ### Forking -Open MCT Web does not currently have a single stand-alone artifact that can be +Open MCT does not currently have a single stand-alone artifact that can be used as a library. Instead, the recommended approach for creating a new -application is to start by forking/branching Open MCT Web, and then adding new -features from there. Put another way, Open MCT Web's source structure is built +application is to start by forking/branching Open MCT, and then adding new +features from there. Put another way, Open MCT's source structure is built to serve as a template for specific applications. -Forking in this manner should not require that you edit Open MCT Web's sources. +Forking in this manner should not require that you edit Open MCT's sources. The preferred approach is to create a new directory (peer to `index.html`) for the new application, then add new bundles (as described in the Framework chapter) within that directory. -To initially clone the Open MCT Web repository: +To initially clone the Open MCT repository: `git clone -b open-master` -To create a fork to begin working on a new application using Open MCT Web: +To create a fork to begin working on a new application using Open MCT: cd git checkout open-master git checkout -b -As a convention used internally, applications built using Open MCT Web have +As a convention used internally, applications built using Open MCT have master branch names with an identifying prefix. For instance, if building an application called 'Foo', the last statement above would look like: git checkout -b foo-master -This convention is not enforced or understood by Open MCT Web in any way; it is +This convention is not enforced or understood by Open MCT in any way; it is mentioned here as a more general recommendation. # Overview -Open MCT Web is implemented as a framework component which manages a set of +Open MCT is implemented as a framework component which manages a set of other components. These components, called _bundles_, act as containers to group sets of related functionality; individual units of functionality are expressed within these bundles as _extensions_. @@ -118,7 +119,7 @@ run-time to satisfy these declared dependency. This dependency injection approach allows software components which have been authored separately (e.g. as plugins) but to collaborate at run-time. -Open MCT Web's framework layer is implemented on top of AngularJS's [dependency +Open MCT's framework layer is implemented on top of AngularJS's [dependency injection mechanism](https://docs.angularjs.org/guide/di) and is modelled after [OSGi](hhttp://www.osgi.org/) and its [Declarative Services component model](http://wiki.osgi.org/wiki/Declarative_Services). In particular, this is where the term _bundle_ comes from. @@ -133,7 +134,7 @@ The framework is described in more detail in the [Framework Overview](../archite architecture guide. ### Tiers -While all bundles in a running Open MCT Web instance are effectively peers, it +While all bundles in a running Open MCT instance are effectively peers, it is useful to think of them as a tiered architecture, where each tier adds more specificity to the application. ```nomnoml @@ -151,7 +152,7 @@ It additionally interprets bundle definitions (see explanation below, as well as further detail in the Framework chapter.) At this tier, we are at our most general: We know only that we are a plugin-based application. * __Platform__: Components in the Platform tier describe both the general user -interface and corresponding developer-facing interfaces of Open MCT Web. This +interface and corresponding developer-facing interfaces of Open MCT. This tier provides the general infrastructure for applications. It is less general than the framework tier, insofar as this tier introduces a specific user interface paradigm, but it is still non-specific as to what useful features @@ -159,7 +160,7 @@ will be provided. Although they can be removed or replaced easily, bundles provided by the Platform tier generally should not be thought of as optional. * __Application__: The application tier consists of components which utilize the infrastructure provided by the Platform to provide functionality which will (or -could) be useful to specific applications built using Open MCT Web. These +could) be useful to specific applications built using Open MCT. These include adapters to specific persistence back-ends (such as ElasticSearch or CouchDB) as well as bundles which describe more user-facing features (such as _Plot_ views for visualizing time series data, or _Layout_ objects for @@ -168,20 +169,20 @@ compromising basic application functionality, with the caveat that at least one persistence adapter needs to be present. * __Plugins__: Conceptually, this tier is not so different from the application tier; it consists of bundles describing new features, back-end adapters, that -are specific to the application being built on Open MCT Web. It is described as +are specific to the application being built on Open MCT. It is described as a separate tier here because it has one important distinction from the application tier: It consists of bundles that are not included with the platform (either authored anew for the specific application, or obtained from elsewhere.) Note that bundles in any tier can go off and consult back-end services. In practice, this responsibility is handled at the Application and/or Plugin tiers; -Open MCT Web is built to be server-agnostic, so any back-end is considered an +Open MCT is built to be server-agnostic, so any back-end is considered an application-specific detail. ## Platform Overview The "tiered" architecture described in the preceding text describes a way of -thinking of and categorizing software components of a Open MCT Web application, +thinking of and categorizing software components of a Open MCT application, as well as the framework layer's role in mediating between these components. Once the framework layer has wired these software components together, however, the application's logical architecture emerges. @@ -192,7 +193,7 @@ section of the Platform guide ### Web Services -As mentioned in the Introduction, Open MCT Web is a platform single-page +As mentioned in the Introduction, Open MCT is a platform single-page applications which runs entirely in the browser. Most applications will want to additionally interact with server-side resources, to (for example) read telemetry data or store user-created objects. This interaction is handled by @@ -205,7 +206,7 @@ individual bundles using APIs which are supported in browser (such as [Web Service #2] <- [Web Browser] [Web Service #3] <- [Web Browser] [ Web Browser | - [ Open MCT Web | + [ Open MCT | [Plugin Bundle #1]-->[Core API] [Core API]<--[Plugin Bundle #2] [Platform Bundle #1]-->[Core API] @@ -215,16 +216,16 @@ individual bundles using APIs which are supported in browser (such as [Core API]<--[Platform Bundle #5] [Core API]<--[Plugin Bundle #3] ] - [Open MCT Web] ->[Browser APIs] + [Open MCT] ->[Browser APIs] ] ``` This architectural approach ensures a loose coupling between applications built -using Open MCT Web and the backends which support them. +using Open MCT and the backends which support them. ### Glossary -Certain terms are used throughout Open MCT Web with consistent meanings or +Certain terms are used throughout Open MCT with consistent meanings or conventions. Other developer documentation, particularly in-line documentation, may presume an understanding of these terms. @@ -246,7 +247,7 @@ readable description of a thing; usually a single sentence or short paragraph. (Most often used in the context of extensions, domain object models, or other similar application-specific objects.) * __domain object__: A meaningful object to the user; a distinct thing in the -work support by Open MCT Web. Anything that appears in the left-hand tree is a +work support by Open MCT. Anything that appears in the left-hand tree is a domain object. * __extension__: An extension is a unit of functionality exposed to the platform in a declarative fashion by a bundle. The term 'extension category' is used to @@ -278,10 +279,10 @@ side-by-side without conflicting. # Framework -Open MCT Web is built on the [AngularJS framework]( http://www.angularjs.org ). A +Open MCT is built on the [AngularJS framework]( http://www.angularjs.org ). A good understanding of that framework is recommended. -Open MCT Web adds an extra layer on top of AngularJS to (a) generalize its +Open MCT adds an extra layer on top of AngularJS to (a) generalize its dependency injection mechanism slightly, particularly to handle many-to-one relationships; and (b) handle script loading. Combined, these features become a plugin mechanism. @@ -300,7 +301,7 @@ MCT Web.) are collected together in bundles, and may interact with other extensions. The framework layer, loaded and initiated from `index.html`, is the main point -of entry for an application built on Open MCT Web. It is responsible for wiring +of entry for an application built on Open MCT. It is responsible for wiring together the application at run time (much of this responsibility is actually delegated to Angular); at a high-level, the framework does this by proceeding through four stages: @@ -320,7 +321,7 @@ have been registered. ## Bundles -The basic configurable unit of Open MCT Web is the _bundle_. This term has been +The basic configurable unit of Open MCT is the _bundle_. This term has been used a bit already; now we'll get to a more formal definition. A bundle is a directory which contains: @@ -328,13 +329,13 @@ A bundle is a directory which contains: * A bundle definition; a file named `bundle.json`. * Subdirectories for sources, resources, and tests. * Optionally, a `README.md` Markdown file describing its contents (this is not -used by Open MCT Web in any way, but it's a helpful convention to follow.) +used by Open MCT in any way, but it's a helpful convention to follow.) The bundle definition is the main point of entry for the bundle. The framework looks at this to determine which components need to be loaded and how they interact. -A plugin in Open MCT Web is a bundle. The platform itself is also decomposed +A plugin in Open MCT is a bundle. The platform itself is also decomposed into bundles, each of which provides some category of functionality. The difference between a _bundle_ and a _plugin_ is purely a matter of the intended use; a plugin is just a bundle that is meant to be easily added or removed. When @@ -355,7 +356,7 @@ For instance, if `bundles.json` contained: "example/extensions" ] -...then the Open MCT Web framework would look for bundle definitions at +...then the Open MCT framework would look for bundle definitions at `example/builtins/bundle.json` and `example/extensions/bundle.json`, relative to the path of `index.html`. No other bundles would be loaded. @@ -456,7 +457,7 @@ arrays of extension definitions. ### General Extensions Extensions are intended as a general-purpose mechanism for adding new types of -functionality to Open MCT Web. +functionality to Open MCT. An extension category is registered with Angular under the name of the extension, plus a suffix of two square brackets; so, an Angular service (or, @@ -465,7 +466,7 @@ extensions, from all bundles, by including this string (e.g. `types[]` to get all type definitions) in a dependency declaration. As a convention, extension categories are given single-word, plural nouns for -names within Open MCT Web (e.g. `types`.) This convention is not enforced by the +names within Open MCT (e.g. `types`.) This convention is not enforced by the platform in any way. For extension categories introduced by external plugins, it is recommended to prefix the extension category with a vendor identifier (or similar) followed by a dot, to avoid collisions. @@ -504,7 +505,7 @@ the Angular-supported method for dependency injection is (effectively) constructor-style injection; so, both declared dependencies and run-time arguments are competing for space in a constructor's arguments. -To resolve this, the Open MCT Web framework registers extension instances in a +To resolve this, the Open MCT framework registers extension instances in a partially constructed form. That is, the constructor exposed by the extension's implementation is effectively decomposed into two calls; the first takes the dependencies, and returns the constructor in its second form, which takes the @@ -548,7 +549,7 @@ sorted according to these conventions when using them. ### Angular Built-ins Several entities supported Angular are expressed and managed as extensions in -Open MCT Web. Specifically, these extension categories are _directives_, +Open MCT. Specifically, these extension categories are _directives_, _controllers_, _services_, _constants_, _runs_, and _routes_. #### Angular Directives @@ -591,7 +592,7 @@ property value , which is the constant value that will be registered. In some cases, you want to register code to run as soon as the application starts; these can be registered as extensions of the [ runs category](https://docs.angularjs.org/api/ng/type/angular.Module#run ). Implementations registered in this category will be invoked (with their declared -dependencies) when the Open MCT Web application first starts. (Note that, in +dependencies) when the Open MCT application first starts. (Note that, in this case, the implementation is better thought of as just a function, as opposed to a constructor function.) @@ -626,13 +627,13 @@ providers of the same service (that is, with matching `provides` properties); for a decorator, this will be whichever provider, decorator, or aggregator is next in the sequence of decorators. -Services exposed by the Open MCT Web platform are often declared as composite +Services exposed by the Open MCT platform are often declared as composite services, as this form is open for a variety of common modifications. # Core API -Most of Open MCT Web's relevant API is provided and/or mediated by the -framework; that is, much of developing for Open MCT Web is a matter of adding +Most of Open MCT's relevant API is provided and/or mediated by the +framework; that is, much of developing for Open MCT is a matter of adding extensions which access other parts of the platform by means of dependency injection. @@ -641,9 +642,9 @@ to be passed along by other services. ## Domain Objects -Domain objects are the most fundamental component of Open MCT Web's information +Domain objects are the most fundamental component of Open MCT's information model. A domain object is some distinct thing relevant to a user's work flow, -such as a telemetry channel, display, or similar. Open MCT Web is a tool for +such as a telemetry channel, display, or similar. Open MCT is a tool for viewing, browsing, manipulating, and otherwise interacting with a graph of domain objects. @@ -680,7 +681,7 @@ exposed. ### Identifier Syntax For most purposes, a domain object identifier can be treated as a purely -symbolic string; these are typically generated by Open MCT Web and plug-ins +symbolic string; these are typically generated by Open MCT and plug-ins should rarely be concerned with its internal structure. A domain object identifier has one or two parts, separated by a colon. @@ -723,7 +724,7 @@ exposed it to be removed from its container. containing: * `name`: Human-readable name. * `description`: Human-readable summary of this action. - * `glyph`: Single character to be displayed in Open MCT Web's icon font set. + * `glyph`: Single character to be displayed in Open MCT's icon font set. * `context`: The context in which this action is being performed (see below) Action instances are typically obtained via a domain object's `action` @@ -739,7 +740,7 @@ dragged object in a drag-and-drop operation.) ## Telemetry -Telemetry series data in Open MCT Web is represented by a common interface, and +Telemetry series data in Open MCT is represented by a common interface, and packaged in a consistent manner to facilitate passing telemetry updates around multiple visualizations. @@ -752,7 +753,7 @@ is useful when multiple distinct data sources are in use side-by-side. * `key`: A machine-readable identifier for a unique series of telemetry within that source. * _Note: This API is still under development; additional properties, such as -start and end time, should be present in future versions of Open MCT Web._ +start and end time, should be present in future versions of Open MCT._ Additional properties may be included in telemetry requests which have specific interpretations for specific sources. @@ -776,7 +777,7 @@ not. (Typically, domain values are interpreted as UTC timestamps in milliseconds relative to the UNIX epoch.) A series must have at least one domain and one range, and may have more than one. -Telemetry series data in Open MCT Web is expressed via the following +Telemetry series data in Open MCT is expressed via the following `TelemetrySeries` interface: * `getPointCount()`: Returns the number of unique points/samples in this series. @@ -815,7 +816,7 @@ interface: * `getName()`: Get the human-readable name for this type. * `getDescription()`: Get a human-readable summary of this type. * `getGlyph()`: Get the single character to be rendered as an icon for this type -in Open MCT Web's custom font set. +in Open MCT's custom font set. * `getInitialModel()`: Get a domain object model that represents the initial state (before user specification of properties) for domain objects of this type. * `getDefinition()`: Get the extension definition for this type, as a JavaScript @@ -831,7 +832,7 @@ an array of `TypeProperty` instances. ### Type Features Features of a domain object type are expressed as symbolic string identifiers. -They are defined in practice by usage; currently, the Open MCT Web platform only +They are defined in practice by usage; currently, the Open MCT platform only uses the creation feature to determine which domain object types should appear in the Create menu. @@ -885,7 +886,7 @@ Categories supported by the platform include: * `key`: A machine-readable identifier for this action. * `name`: A human-readable name for this action (e.g. to show in a menu) * `description`: A human-readable summary of the behavior of this action. -* `glyph`: A single character which will be rendered in Open MCT Web's custom +* `glyph`: A single character which will be rendered in Open MCT's custom font set as an icon for this action. ## Capabilities Category @@ -996,7 +997,7 @@ of unremoved listeners. ## Indicators Category An indicator is an element that should appear in the status area at the bottom -of a running Open MCT Web client instance. +of a running Open MCT client instance. ### Standard Indicators @@ -1006,7 +1007,7 @@ provide implementations with the following methods: * `getText()`: Provides the human-readable text that will be displayed for this indicator. * `getGlyph()`: Provides a single-character string that will be displayed as an -icon in Open MCT Web's custom font set. +icon in Open MCT's custom font set. * `getDescription()`: Provides a human-readable summary of the current state of this indicator; will be displayed in a tooltip on hover. * `getClass()`: Get a CSS class that will be applied to this indicator. @@ -1032,7 +1033,7 @@ this variety do not need to provide an implementation. ## Licenses Category The extension category `licenses` can be used to add entries into the 'Licensing -information' page, reachable from Open MCT Web's About dialog. +information' page, reachable from Open MCT's About dialog. Licenses may have the following properties, all of which are strings: @@ -1045,11 +1046,11 @@ Licenses may have the following properties, all of which are strings: ## Policies Category -Policies are used to handle decisions made using Open MCT Web's `policyService`; +Policies are used to handle decisions made using Open MCT's `policyService`; examples of these decisions are determining the applicability of certain actions, or checking whether or not a domain object of one type can contain a domain object of a different type. See the section on the Policies for an -overview of Open MCT Web's policy model. +overview of Open MCT's policy model. A policy's extension definition should include: @@ -1065,7 +1066,7 @@ context)`. The specific types used for `candidate` and `context` vary by policy category; in general, what is being asked is 'is this candidate allowed in this context?' This method should return a boolean value. -Open MCT Web's policy model requires consensus; a policy decision is allowed +Open MCT's policy model requires consensus; a policy decision is allowed when and only when all policies choose to allow it. As such, policies should generally be written to reject a certain case, and allow (by returning `true`) anything else. @@ -1194,7 +1195,7 @@ Templates do not have implementations. ## Types Category The types extension category describes types of domain objects which may -appear within Open MCT Web. +appear within Open MCT. A type's extension definition should have the following properties: @@ -1202,7 +1203,7 @@ A type's extension definition should have the following properties: stored to and matched against the type property of domain object models. * `name`: The human-readable name for this domain object type. * `description`: A human-readable summary of this domain object type. -* `glyph`: A single character to be rendered as an icon in Open MCT Web's custom +* `glyph`: A single character to be rendered as an icon in Open MCT's custom font set. * `model`: A domain object model, used as the initial state for created domain objects of this type (before any properties are specified.) @@ -1251,7 +1252,7 @@ utilized via `mct-representation`); additionally: * `name`: The human-readable name for this view type. * description : A human-readable summary of this view type. -* `glyph`: A single character to be rendered as an icon in Open MCT Web's custom +* `glyph`: A single character to be rendered as an icon in Open MCT's custom font set. * `type`: Optional; if present, this representation is only applicable for domain object's of this type. @@ -1293,7 +1294,7 @@ are visible, and what state they manage and/or behavior they invoke. This set may contain up to two different objects: The _view proxy_, which is used to make changes to the view as a whole, and the _selected object_, which is -used to represent some state within the view. (Future versions of Open MCT Web +used to represent some state within the view. (Future versions of Open MCT may support multiple selected objects.) The `selection` object made available during Edit mode has the following @@ -1329,14 +1330,14 @@ are supported: # Directives -Open MCT Web defines several Angular directives that are intended for use both +Open MCT defines several Angular directives that are intended for use both internally within the platform, and by plugins. ## Before Unload The `mct-before-unload` directive is used to listen for (and prompt for user confirmation) of navigation changes in the browser. This includes reloading, -following links out of Open MCT Web, or changing routes. It is used to hook into +following links out of Open MCT, or changing routes. It is used to hook into both `onbeforeunload` event handling as well as route changes from within Angular. @@ -1448,7 +1449,7 @@ Passed as plain text in the attribute. ### Form Structure -Forms in Open MCT Web have a common structure to permit consistent display. A +Forms in Open MCT have a common structure to permit consistent display. A form is broken down into sections, which will be displayed in groups; each section is broken down into rows, each of which provides a control for a single property. Input from this form is two-way bound to the object passed via @@ -1600,9 +1601,64 @@ there are items . ] } +## Table + +The `mct-table` directive provides a generic table component, with optional +sorting and filtering capabilities. The table can be pre-populated with data +by setting the `rows` parameter, and it can be updated in real-time using the +`add:row` and `remove:row` broadcast events. The table will expand to occupy +100% of the size of its containing element. The table is highly optimized for +very large data sets. + +### Events + +The table supports two events for notifying that the rows have changed. For +performance reasons, the table does not monitor the content of `rows` +constantly. + +* `add:row`: A `$broadcast` event that will notify the table that a new row +has been added to the table. + +eg. The code below adds a new row, and alerts the table using the `add:row` +event. Sorting and filtering will be applied automatically by the table component. + +``` +$scope.rows.push(newRow); +$scope.$broadcast('add:row', $scope.rows.length-1); +``` + +* `remove:row`: A `$broadcast` event that will notify the table that a row +should be removed from the table. + +eg. The code below removes a row from the rows array, and then alerts the table +to its removal. + +``` +$scope.rows.slice(5, 1); +$scope.$broadcast('remove:row', 5); +``` + +### Parameters + +* `headers`: An array of string values which will constitute the column titles + that appear at the top of the table. Corresponding values are specified in + the rows using the header title provided here. +* `rows`: An array of objects containing row values. Each element in the +array must be an associative array, where the key corresponds to a column header. +* `enableFilter`: A boolean that if true, will enable searching and result +filtering. When enabled, each column will have a text input field that can be +used to filter the table rows in real time. +* `enableSort`: A boolean determining whether rows can be sorted. If true, +sorting will be enabled allowing sorting by clicking on column headers. Only +one column may be sorted at a time. +* `autoScroll`: A boolean value that if true, will cause the table to automatically +scroll to the bottom as new data arrives. Auto-scroll can be disengaged manually +by scrolling away from the bottom of the table, and can also be enabled manually +by scrolling to the bottom of the table rows. + # Services -The Open MCT Web platform provides a variety of services which can be retrieved +The Open MCT platform provides a variety of services which can be retrieved and utilized via dependency injection. These services fall into two categories: * _Composite Services_ are defined by a set of components extensions; plugins may @@ -1614,7 +1670,7 @@ utilized by plugins but are not intended to be modified or augmented. ## Composite Type Services -This section describes the composite services exposed by Open MCT Web, +This section describes the composite services exposed by Open MCT, specifically focusing on their interface and contract. In many cases, the platform will include a provider for a service which consumes @@ -1932,7 +1988,7 @@ The `workerService` may be used to run web workers defined via the as a shared worker); if the `key` is unknown, returns `undefined`. # Models -Domain object models in Open MCT Web are JavaScript objects describing the +Domain object models in Open MCT are JavaScript objects describing the persistent state of the domain objects they describe. Their contents include a mix of commonly understood metadata attributes; attributes which are recognized by and/or determine the applicability of specific extensions; and properties @@ -1948,7 +2004,7 @@ MCT Web and can be utilized directly: ## Extension-specific Properties Other properties of domain object models have specific meaning imposed by other -extensions within the Open MCT Web platform. +extensions within the Open MCT platform. ### Capability-specific Properties @@ -2232,7 +2288,7 @@ way of its `composition` capability.) # Policies -Policies are consulted to determine when certain behavior in Open MCT Web is +Policies are consulted to determine when certain behavior in Open MCT is allowed. Policy questions are assigned to certain categories, which broadly describe the type of decision being made; within each category, policies have a candidate (the thing which may or may not be allowed) and, optionally, a context @@ -2257,13 +2313,13 @@ The candidate argument is the view's extension definition; the context argument is the `DomainObject` to be viewed. # Build-Test-Deploy -Open MCT Web is designed to support a broad variety of build and deployment +Open MCT is designed to support a broad variety of build and deployment options. The sources can be deployed in the same directory structure used during development. A few utilities are included to support development processes. ## Command-line Build -Open MCT Web is built using [`npm`](http://npmjs.com/) +Open MCT is built using [`npm`](http://npmjs.com/) and [`gulp`](http://gulpjs.com/). To install build dependencies (only needs to be run once): @@ -2275,12 +2331,12 @@ To build: `npm run prepublish` This will compile and minify JavaScript sources, as well as copy over assets. -The contents of the `dist` folder will contain a runnable Open MCT Web +The contents of the `dist` folder will contain a runnable Open MCT instance (e.g. by starting an HTTP server in that directory), including: -* A `main.js` file containing Open MCT Web source code. +* A `main.js` file containing Open MCT source code. * Various assets in the `example` and `platform` directories. -* An `index.html` that runs Open MCT Web in its default configuration. +* An `index.html` that runs Open MCT in its default configuration. Additional `gulp` tasks are defined in [the gulpfile](gulpfile.js). @@ -2289,7 +2345,7 @@ download build dependencies. ## Test Suite -Open MCT Web uses [Jasmine 1.3](http://jasmine.github.io/) and +Open MCT uses [Jasmine 1.3](http://jasmine.github.io/) and [Karma](http://karma-runner.github.io) for automated testing. The test suite is configured to load any scripts ending with `Spec.js` found @@ -2327,8 +2383,8 @@ information using [Blanket.JS](http://blanketjs.org/) and display this at the bottom of the screen. Currently, only statement coverage is displayed. ## Deployment -Open MCT Web is built to be flexible in terms of the deployment strategies it -supports. In order to run in the browser, Open MCT Web needs: +Open MCT is built to be flexible in terms of the deployment strategies it +supports. In order to run in the browser, Open MCT needs: 1. HTTP access to sources/resources for the framework, platform, and all active bundles. @@ -2337,13 +2393,13 @@ external services need to support HTTP or some other web-accessible interface, like WebSockets.) Any HTTP server capable of serving flat files is sufficient for the first point. -The command-line build also packages Open MCT Web into a `.war` file for easier +The command-line build also packages Open MCT into a `.war` file for easier deployment on containers such as Apache Tomcat. The second point may be less flexible, as it depends upon the specific services -to be utilized by Open MCT Web. Because of this, it is often the set of external +to be utilized by Open MCT. Because of this, it is often the set of external services (and the manner in which they are exposed) that determine how to deploy -Open MCT Web. +Open MCT. One important constraint to consider in this context is the browser's same origin policy. If external services are not on the same apparent host and port @@ -2360,7 +2416,7 @@ configuration does not create a security vulnerability. Examples of deployment strategies (and the conditions under which they make the most sense) include: -* If the external services that Open MCT Web will utilize are all running on +* If the external services that Open MCT will utilize are all running on [Apache Tomcat](https://tomcat.apache.org/), then it makes sense to run Open MCT Web from the same Tomcat instance as a separate web application. The `.war` artifact produced by the command line build facilitates this deployment @@ -2371,28 +2427,28 @@ hosts/ports, then it may make sense to use a web server that supports proxying, such as the [Apache HTTP Server](http://httpd.apache.org/). In this configuration, the HTTP server would be configured to proxy (or reverse proxy) requests at specific paths to the various external services, while providing -Open MCT Web as flat files from a different path. +Open MCT as flat files from a different path. * If a single server component is being developed to handle all server-side -needs of an Open MCT Web instance, it can make sense to serve Open MCT Web (as +needs of an Open MCT instance, it can make sense to serve Open MCT (as flat files) from the same component using an embedded HTTP server such as [Nancy](http://nancyfx.org/). * If no external services are needed (or if the 'external services' will just be generating flat files to read) it makes sense to utilize a lightweight flat file HTTP server such as [Lighttpd](http://www.lighttpd.net/). In this -configuration, Open MCT Web sources/resources would be placed at one path, while +configuration, Open MCT sources/resources would be placed at one path, while the files generated by the external service are placed at another path. * If all external services support CORS, it may make sense to have an HTTP -server that is solely responsible for making Open MCT Web sources/resources -available, and to have Open MCT Web contact these external services directly. +server that is solely responsible for making Open MCT sources/resources +available, and to have Open MCT contact these external services directly. Again, lightweight HTTP servers such as [Lighttpd](http://www.lighttpd.net/) are useful in this circumstance. The downside of this option is that additional configuration effort is required, both to enable CORS on the external services, -and to ensure that Open MCT Web can correctly locate these services. +and to ensure that Open MCT can correctly locate these services. -Another important consideration is authentication. By design, Open MCT Web does +Another important consideration is authentication. By design, Open MCT does not handle user authentication. Instead, this should typically be treated as a deployment-time concern, where authentication is handled by the HTTP server -which provides Open MCT Web, or an external access management system. +which provides Open MCT, or an external access management system. ### Configuration In most of the deployment options above, some level of configuration is likely @@ -2400,7 +2456,7 @@ to be needed or desirable to make sure that bundles can reach the external services they need to reach. Most commonly this means providing the path or URL to an external service. -Configurable parameters within Open MCT Web are specified via constants +Configurable parameters within Open MCT are specified via constants (literally, as extensions of the `constants` category) and accessed via dependency injection by the scripts which need them. Reasonable defaults for these constants are provided in the bundle where they are used. Plugins are @@ -2419,7 +2475,7 @@ for error, but is viable if there are a small number of constants to change. constants. This is particularly appropriate when multiple configurations (e.g. development, test, production) need to be managed easily; these can be swapped quickly by changing the set of active bundles in bundles.json. -* Deploy Open MCT Web and its external services in such a fashion that the +* Deploy Open MCT and its external services in such a fashion that the default paths to reach external services are all correct. ### Configuration Constants @@ -2430,7 +2486,7 @@ The following constants have global significance: to be overridden by other bundles, but persistence adapters may wish to consume this constant in order to provide persistence for that space. -The following configuration constants are recognized by Open MCT Web bundles: +The following configuration constants are recognized by Open MCT bundles: * Common UI elements - `platform/commonUI/general` * `THEME`: A string identifying the current theme symbolically. Individual stylesheets (the `stylesheets` extension category) may specify an optional diff --git a/docs/src/index.md b/docs/src/index.md index dbb1d36220..3b4d767106 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,13 +1,13 @@ -# Open MCT Web Documentation +# Open MCT Documentation ## Overview Documentation is provided to support the use and development of - Open MCT Web. It's recommended that before doing - any development with Open MCT Web you take some time to familiarize yourself + Open MCT. It's recommended that before doing + any development with Open MCT you take some time to familiarize yourself with the documentation below. - Open MCT Web provides functionality out of the box, but it's also a platform for + Open MCT provides functionality out of the box, but it's also a platform for building rich mission operations applications based on modern web technology. The platform is configured declaratively, and defines conventions for building on the provided capabilities by creating modular 'bundles' that @@ -17,7 +17,7 @@ ## Sections * The [Architecture Overview](architecture/) describes the concepts used - throughout Open MCT Web, and gives a high level overview of the platform's design. + throughout Open MCT, and gives a high level overview of the platform's design. * The [Developer's Guide](guide/) goes into more detail about how to use the platform and the functionality that it provides. @@ -31,5 +31,4 @@ functions that make up the software platform. * Finally, the [Development Process](process/) document describes the - Open MCT Web software development cycle. - \ No newline at end of file + Open MCT software development cycle. diff --git a/docs/src/process/cycle.md b/docs/src/process/cycle.md index 4618fe0433..b07a76e8eb 100644 --- a/docs/src/process/cycle.md +++ b/docs/src/process/cycle.md @@ -1,6 +1,6 @@ # Development Cycle -Development of Open MCT Web occurs on an iterative cycle of +Development of Open MCT occurs on an iterative cycle of sprints and releases. * A _sprint_ is three weeks in duration, and represents a diff --git a/docs/src/process/index.md b/docs/src/process/index.md index 78f919e4c2..fc8f7e6e91 100644 --- a/docs/src/process/index.md +++ b/docs/src/process/index.md @@ -1,6 +1,6 @@ # Development Process -The process used to develop Open MCT Web is described in the following +The process used to develop Open MCT is described in the following documents: * The [Development Cycle](cycle.md) describes how and when specific @@ -9,7 +9,7 @@ documents: Open MCT (both semantics and process.) * Testing is described in two documents: * The [Test Plan](testing/plan.md) summarizes the approaches used - to test Open MCT Web. + to test Open MCT. * The [Test Procedures](testing/procedures.md) document what specific tests are performed to verify correctness, and how they should be carried out. diff --git a/docs/src/process/testing/plan.md b/docs/src/process/testing/plan.md index fead5f5a50..47ab60ee34 100644 --- a/docs/src/process/testing/plan.md +++ b/docs/src/process/testing/plan.md @@ -2,7 +2,7 @@ ## Test Levels -Testing for Open MCT Web includes: +Testing for Open MCT includes: * _Smoke testing_: Brief, informal testing to verify that no major issues or regressions are present in the software, or in specific features of diff --git a/docs/src/process/testing/procedures.md b/docs/src/process/testing/procedures.md index b33f88c6d1..5ccf0def5b 100644 --- a/docs/src/process/testing/procedures.md +++ b/docs/src/process/testing/procedures.md @@ -4,7 +4,7 @@ This document is intended to be used: -* By testers, to verify that Open MCT Web behaves as specified. +* By testers, to verify that Open MCT behaves as specified. * By the development team, to document new test cases and to provide guidance on how to author these. @@ -62,7 +62,7 @@ Test cases should be narrow in scope; if a list of steps is excessively long (or must be written vaguely to be kept short) it should be broken down into multiple tests which reference one another. -All requirements satisfied by Open MCT Web should be verifiable using +All requirements satisfied by Open MCT should be verifiable using one or more test procedures. ## Glossary @@ -166,4 +166,4 @@ Eval. criteria | Visual inspection * Logs should not contain any unexpected warnings or errors ("expected" warnings or errors are those that have been documented and prioritized as known issues, or those that are explained by transient conditions - external to the software, such as network outages.) \ No newline at end of file + external to the software, such as network outages.) diff --git a/docs/src/tutorials/index.md b/docs/src/tutorials/index.md index 1bda1d8848..84c571bec8 100644 --- a/docs/src/tutorials/index.md +++ b/docs/src/tutorials/index.md @@ -1,4 +1,4 @@ -# Open MCT Web Tutorials +# Open MCT Tutorials Victor Woeltjen victor.woeltjen@nasa.gov @@ -23,9 +23,9 @@ been added or removed as part of the tutorial. In these cases, any lines added will be indicated with a '+' at the start of the line. Any lines removed will be indicated with a '-'. -## Setting Up Open MCT Web +## Setting Up Open MCT -In this section, we will cover the steps necessary to get a minimal Open MCT Web +In this section, we will cover the steps necessary to get a minimal Open MCT developer environment up and running. Once we have this, we will be able to proceed with writing plugins as described in this tutorial. @@ -40,99 +40,44 @@ more recent versions, but this cannot be guaranteed. * Google Chrome v42: https://www.google.com/chrome/ * A text editor. -Open MCT Web can be run without any of these tools, provided suitable -alternatives are taken; see the [Open MCT Web Developer Guide](../guide/index.md) -for a more general overview of how to run and deploy a Open MCT Web application. +Open MCT can be run without any of these tools, provided suitable +alternatives are taken; see the [Open MCT Developer Guide](../guide/index.md) +for a more general overview of how to run and deploy a Open MCT application. -### Check out Open MCT Web Sources +### Check out Open MCT Sources -First step is to check out Open MCT Web from the source repository. +First step is to check out Open MCT from the source repository. `git clone https://github.com/nasa/openmctweb.git openmctweb` -This will create a copy of the Open MCT Web source code repository in the folder +This will create a copy of the Open MCT source code repository in the folder `openmctweb` (relative to the path from which you ran the command.) If you have a repository URL, use that as the "path to repo" above. Alternately, -if you received Open MCT Web as a git bundle, the path to that bundle on the +if you received Open MCT as a git bundle, the path to that bundle on the local filesystem can be used instead. -At this point, it will also be useful to branch off of Open MCT Web v0.6.2 +At this point, it will also be useful to branch off of Open MCT v0.6.2 (which was used when writing these tutorials) to begin adding plugins. cd openmctweb git branch open-v0.6.2 git checkout -### Configuring Persistence -In its default configuration, Open MCT Web will try to use ElasticSearch -(expected to be deployed at /elastic on the same HTTP server running Open MCT -Web) to persist user-created domain objects. We don't need that for these -tutorials, so we will replace the ElasticSearch plugin with the example -persistence plugin. This doesn't actually persist, so anything we create within -Open MCT Web will be lost on reload, but that's fine for purposes of these -tutorials. +### Building Open MCT +Once downloaded, Open MCT can be built with the following command: -To change this configuration, edit bundles.json (at the top level of the Open -MCT Web repository) and replace platform/persistence/elastic with -example/persistence. + npm install -#### Bundle Before -```diff -[ - "platform/framework", - "platform/core", - "platform/representation", - "platform/commonUI/about", - "platform/commonUI/browse", - "platform/commonUI/edit", - "platform/commonUI/dialog", - "platform/commonUI/general", - "platform/containment", - "platform/telemetry", - "platform/features/layout", - "platform/features/pages", - "platform/features/plot", - "platform/features/scrolling", - "platform/forms", - "platform/persistence/queue", -- "platform/persistence/elastic", - "platform/policy", +This will install various dependencies, build CSS from Sass files, run tests, +and lint the source code. - "example/generator" -] -``` -__bundles.json__ +It's not necessary to do this after every code change, unless you are making +changes to stylesheets, or you are running the minified version of the app +(under `dist`). -#### Bundle After -```diff -[ - "platform/framework", - "platform/core", - "platform/representation", - "platform/commonUI/about", - "platform/commonUI/browse", - "platform/commonUI/edit", - "platform/commonUI/dialog", - "platform/commonUI/general", - "platform/containment", - "platform/telemetry", - "platform/features/layout", - "platform/features/pages", - "platform/features/plot", - "platform/features/scrolling", - "platform/forms", - "platform/persistence/queue", - "platform/policy", - -+ "example/persistence", - "example/generator" -] -``` -__bundles.json__ - ### Run a Web Server -The next step is to run a web server so that you can view the Open MCT Web +The next step is to run a web server so that you can view the Open MCT client (including the plugins you add to it) in browser. Any web server can be used for hosting OpenMCTWeb, and a trivial web server is provided in this package for the purposes of running the tutorials. The provided web server @@ -140,15 +85,15 @@ should not be used in a production environment To run the tutorial web server - node app.js + npm start ### Viewing in Browser -Once running, you should be able to view Open MCT Web from your browser at +Once running, you should be able to view Open MCT from your browser at http://localhost:8080/ (assuming the web server is running on port 8080, and OpenMCTWeb is installed at the server's root path). [Google Chrome](https://www.google.com/chrome/) is recommended for these -tutorials, as Chrome is Open MCT Web's "test-to" browser. The browser cache +tutorials, as Chrome is Open MCT's "test-to" browser. The browser cache can sometimes interfere with development (masking changes by using older versions of sources); to avoid this, it is easiest to run Chrome with Developer Tools expanded, and "Disable cache" selected from the Network @@ -158,7 +103,7 @@ tab, as shown below. # Tutorials -These tutorials cover three of the common tasks in Open MCT Web: +These tutorials cover three of the common tasks in Open MCT: * The "to-do list" tutorial illustrates how to add a new application feature. * The "bar graph" tutorial illustrates how to add a new telemetry visualization. @@ -167,17 +112,17 @@ backend. ## To-do List -The goal of this tutorial is to add a new application feature to Open MCT Web: +The goal of this tutorial is to add a new application feature to Open MCT: To-do lists. Users should be able to create and manage these to track items that they need to do. This is modelled after the to-do lists at http://todomvc.com/. ### Step 1-Create the Plugin -The first step to adding a new feature to Open MCT Web is to create the plugin -which will expose that feature. A plugin in Open MCT Web is represented by what +The first step to adding a new feature to Open MCT is to create the plugin +which will expose that feature. A plugin in Open MCT is represented by what is called a bundle; a bundle, in turn, is a directory which contains a file -bundle.json, which in turn describes where other relevant sources & resources -will be. The syntax of this file is described in more detail in the Open MCT Web +bundle.js, which in turn describes where other relevant sources & resources +will be. The syntax of this file is described in more detail in the Open MCT Developer Guide. We will create this file in the directory tutorials/todo (we can hereafter refer @@ -185,76 +130,205 @@ to this plugin as tutorials/todo as well.) We will start with an "empty bundle", one which exposes no extensions - which looks like: ```diff -{ - "name": "To-do Plugin", - "description": "Allows creating and editing to-do lists.", - "extensions": { - } -} +define([ + 'legacyRegistry' +], function ( + legacyRegistry +) { + legacyRegistry.register("tutorials/todo", { + "name": "To-do Plugin", + "description": "Allows creating and editing to-do lists.", + "extensions": + { + } + }); +}); + ``` -__tutorials/todo/bundle.json__ +__tutorials/todo/bundle.js__ -We will also include this in our list of active bundles. +With the new bundle defined, it is now necessary to register the bundle with +the application. The details of how a new bundle is defined are in the +process of changing. The Open MCT codebase has started to shift from a +declarative registration style toward an imperative registration style. +The tutorials will be updated with the new bundle registration mechanism once it +has been finalized. #### Before ```diff -[ - "platform/framework", - "platform/core", - "platform/representation", - "platform/commonUI/about", - "platform/commonUI/browse", - "platform/commonUI/edit", - "platform/commonUI/dialog", - "platform/commonUI/general", - "platform/containment", - "platform/telemetry", - "platform/features/layout", - "platform/features/pages", - "platform/features/plot", - "platform/features/scrolling", - "platform/forms", - "platform/persistence/queue", - "platform/policy", +requirejs.config({ + "paths": { + "legacyRegistry": "src/legacyRegistry", + "angular": "bower_components/angular/angular.min", + "angular-route": "bower_components/angular-route/angular-route.min", + "csv": "bower_components/comma-separated-values/csv.min", + "es6-promise": "bower_components/es6-promise/promise.min", + "moment": "bower_components/moment/moment", + "moment-duration-format": "bower_components/moment-duration-format/lib/moment-duration-format", + "saveAs": "bower_components/FileSaver.js/FileSaver.min", + "screenfull": "bower_components/screenfull/dist/screenfull.min", + "text": "bower_components/text/text", + "uuid": "bower_components/node-uuid/uuid", + "zepto": "bower_components/zepto/zepto.min" + }, + "shim": { + "angular": { + "exports": "angular" + }, + "angular-route": { + "deps": [ "angular" ] + }, + "moment-duration-format": { + "deps": [ "moment" ] + }, + "screenfull": { + "exports": "screenfull" + }, + "zepto": { + "exports": "Zepto" + } + } +}); - "example/persistence", - "example/generator" -] +define([ + './platform/framework/src/Main', + 'legacyRegistry', + + './platform/framework/bundle', + './platform/core/bundle', + './platform/representation/bundle', + './platform/commonUI/about/bundle', + './platform/commonUI/browse/bundle', + './platform/commonUI/edit/bundle', + './platform/commonUI/dialog/bundle', + './platform/commonUI/formats/bundle', + './platform/commonUI/general/bundle', + './platform/commonUI/inspect/bundle', + './platform/commonUI/mobile/bundle', + './platform/commonUI/themes/espresso/bundle', + './platform/commonUI/notification/bundle', + './platform/containment/bundle', + './platform/execution/bundle', + './platform/exporters/bundle', + './platform/telemetry/bundle', + './platform/features/clock/bundle', + './platform/features/imagery/bundle', + './platform/features/layout/bundle', + './platform/features/pages/bundle', + './platform/features/plot/bundle', + './platform/features/timeline/bundle', + './platform/features/table/bundle', + './platform/forms/bundle', + './platform/identity/bundle', + './platform/persistence/aggregator/bundle', + './platform/persistence/local/bundle', + './platform/persistence/queue/bundle', + './platform/policy/bundle', + './platform/entanglement/bundle', + './platform/search/bundle', + './platform/status/bundle', + './platform/commonUI/regions/bundle' +], function (Main, legacyRegistry) { + return { + legacyRegistry: legacyRegistry, + run: function () { + return new Main().run(legacyRegistry); + } + }; +}); ``` -__bundles.json__ +__main.js__ #### After ```diff -[ - "platform/framework", - "platform/core", - "platform/representation", - "platform/commonUI/about", - "platform/commonUI/browse", - "platform/commonUI/edit", - "platform/commonUI/dialog", - "platform/commonUI/general", - "platform/containment", - "platform/telemetry", - "platform/features/layout", - "platform/features/pages", - "platform/features/plot", - "platform/features/scrolling", - "platform/forms", - "platform/persistence/queue", - "platform/policy", +requirejs.config({ + "paths": { + "legacyRegistry": "src/legacyRegistry", + "angular": "bower_components/angular/angular.min", + "angular-route": "bower_components/angular-route/angular-route.min", + "csv": "bower_components/comma-separated-values/csv.min", + "es6-promise": "bower_components/es6-promise/promise.min", + "moment": "bower_components/moment/moment", + "moment-duration-format": "bower_components/moment-duration-format/lib/moment-duration-format", + "saveAs": "bower_components/FileSaver.js/FileSaver.min", + "screenfull": "bower_components/screenfull/dist/screenfull.min", + "text": "bower_components/text/text", + "uuid": "bower_components/node-uuid/uuid", + "zepto": "bower_components/zepto/zepto.min" + }, + "shim": { + "angular": { + "exports": "angular" + }, + "angular-route": { + "deps": [ "angular" ] + }, + "moment-duration-format": { + "deps": [ "moment" ] + }, + "screenfull": { + "exports": "screenfull" + }, + "zepto": { + "exports": "Zepto" + } + } +}); - "example/persistence", - "example/generator", +define([ + './platform/framework/src/Main', + 'legacyRegistry', -+ "tutorials/todo" -] + './platform/framework/bundle', + './platform/core/bundle', + './platform/representation/bundle', + './platform/commonUI/about/bundle', + './platform/commonUI/browse/bundle', + './platform/commonUI/edit/bundle', + './platform/commonUI/dialog/bundle', + './platform/commonUI/formats/bundle', + './platform/commonUI/general/bundle', + './platform/commonUI/inspect/bundle', + './platform/commonUI/mobile/bundle', + './platform/commonUI/themes/espresso/bundle', + './platform/commonUI/notification/bundle', + './platform/containment/bundle', + './platform/execution/bundle', + './platform/exporters/bundle', + './platform/telemetry/bundle', + './platform/features/clock/bundle', + './platform/features/imagery/bundle', + './platform/features/layout/bundle', + './platform/features/pages/bundle', + './platform/features/plot/bundle', + './platform/features/timeline/bundle', + './platform/features/table/bundle', + './platform/forms/bundle', + './platform/identity/bundle', + './platform/persistence/aggregator/bundle', + './platform/persistence/local/bundle', + './platform/persistence/queue/bundle', + './platform/policy/bundle', + './platform/entanglement/bundle', + './platform/search/bundle', + './platform/status/bundle', + './platform/commonUI/regions/bundle', + ++ './tutorials/todo/bundle' +], function (Main, legacyRegistry) { + return { + legacyRegistry: legacyRegistry, + run: function () { + return new Main().run(legacyRegistry); + } + }; +}); ``` -__bundles.json__ +__main.js__ -At this point, we can reload Open MCT Web. We haven't introduced any new +At this point, we can reload Open MCT. We haven't introduced any new functionality, so we don't see anything different, but if we run with logging enabled ( http://localhost:8080/?log=info ) and check the browser console, we should see: @@ -265,33 +339,40 @@ should see: ### Step 2-Add a Domain Object Type -Features in a Open MCT Web application are most commonly expressed as domain +Features in a Open MCT application are most commonly expressed as domain objects and/or views thereof. A domain object is some thing that is relevant to -the work that the Open MCT Web application is meant to support. Domain objects +the work that the Open MCT application is meant to support. Domain objects can be created, organized, edited, placed in layouts, and so forth. (For a -deeper explanation of domain objects, see the Open MCT Web Developer Guide.) +deeper explanation of domain objects, see the Open MCT Developer Guide.) In the case of our to-do list feature, the to-do list itself is the thing we'll want users to be able to create and edit. So, we will add that as a new type in our bundle definition: ```diff -{ - "name": "To-do Plugin", - "description": "Allows creating and editing to-do lists.", - "extensions": { -+ "types": [ +define([ + 'legacyRegistry' +], function ( + legacyRegistry +) { + legacyRegistry.register("tutorials/todo", { + "name": "To-do Plugin", + "description": "Allows creating and editing to-do lists.", + "extensions": + { ++ "types": [ + { + "key": "example.todo", + "name": "To-Do List", -+ "glyph": "j", ++ "glyph": "2", + "description": "A list of things that need to be done.", + "features": ["creation"] + } - ] - } -} ++ ]} + }); +}); + ``` -__tutorials/todo/bundle.json__ +__tutorials/todo/bundle.js__ What have we done here? We've stated that this bundle includes extensions of the category _types_, which is used to describe domain object types. Then, we've @@ -303,7 +384,7 @@ Going through the properties we've defined: domain objects of this type. * The `name` of "To-Do List" is the human-readable name for this type, and will be shown to users. -* The `glyph` refers to a special character in Open MCT Web's custom font set; +* The `glyph` refers to a special character in Open MCT's custom font set; this will be used as an icon. * The `description` is also human-readable, and will be used whenever a longer explanation of what this type is should be shown. @@ -312,7 +393,7 @@ this type. Including `creation` here means that we want users to be able to create this (in other cases, we may wish to expose things as domain objects which aren't user-created, in which case we would omit this.) -If we reload Open MCT Web, we see that our new domain object type appears in the +If we reload Open MCT, we see that our new domain object type appears in the Create menu: ![To-Do List](images/todo.png) @@ -324,10 +405,10 @@ because we haven't defined any yet. ### Step 3-Add a View In order to allow a to-do list to be used, we need to define and display its -contents. In Open MCT Web, the pattern that the user expects is that they'll +contents. In Open MCT, the pattern that the user expects is that they'll click on an object in the left-hand tree, and see a visualization of it to the -right; in Open MCT Web, these visualizations are called views. -A view in Open MCT Web is defined by an Angular template. We'll add that in the +right; in Open MCT, these visualizations are called views. +A view in Open MCT is defined by an Angular template. We'll add that in the directory `tutorials/todo/res/templates` (`res` is, by default, the directory where bundle-related resources are kept, and `templates` is where HTML templates are stored by convention.) @@ -357,16 +438,21 @@ to filter down to either complete or incomplete tasks. of the domain object being viewed; this contains all of the persistent state associated with that object. This model is effectively just a JSON document, so we can choose what goes into it (so long as we take care not to collide with -platform-defined properties; see the Open MCT Web Developer Guide.) Here, we +platform-defined properties; see the Open MCT Developer Guide.) Here, we assume that all tasks will be stored in a property `tasks`, and that each will be an object containing a `description` (the readable summary of the task) and a boolean `completed` flag. -To expose this view in Open MCT Web, we need to declare it in our bundle +To expose this view in Open MCT, we need to declare it in our bundle definition: ```diff -{ +define([ + 'legacyRegistry' +], function ( + legacyRegistry +) { + legacyRegistry.register("tutorials/todo", { "name": "To-do Plugin", "description": "Allows creating and editing to-do lists.", "extensions": { @@ -374,7 +460,7 @@ definition: { "key": "example.todo", "name": "To-Do List", - "glyph": "j", + "glyph": "2", "description": "A list of things that need to be done.", "features": ["creation"] } @@ -383,15 +469,17 @@ definition: + { + "key": "example.todo", + "type": "example.todo", -+ "glyph": "j", ++ "glyph": "2", + "name": "List", -+ "templateUrl": "templates/todo.html" ++ "templateUrl": "templates/todo.html", ++ "editable": true + } + ] } -} + }); +}); ``` -__tutorials/todo/bundle.json__ +__tutorials/todo/bundle.js__ Here, we've added another extension, this time belonging to category `views`. It contains the following properties: @@ -399,7 +487,7 @@ contains the following properties: * Its `key` is its machine-readable name; we've given it the same name here as the domain object type, but could have chosen any unique name. -* The `type` property tells Open MCT Web that this view is only applicable to +* The `type` property tells Open MCT that this view is only applicable to domain objects of that type. This means that we'll see this view for To-do Lists that we create, but not for other domain objects (such as Folders.) @@ -416,7 +504,12 @@ will specify an initial state for To-do List domain object models in the definition of that type. ```diff -{ +define([ + 'legacyRegistry' +], function ( + legacyRegistry +) { + legacyRegistry.register("tutorials/todo", { "name": "To-do Plugin", "description": "Allows creating and editing to-do lists.", "extensions": { @@ -424,7 +517,7 @@ definition of that type. { "key": "example.todo", "name": "To-Do List", - "glyph": "j", + "glyph": "2", "description": "A list of things that need to be done.", "features": ["creation"], + "model": { @@ -439,20 +532,22 @@ definition of that type. { "key": "example.todo", "type": "example.todo", - "glyph": "j", + "glyph": "2", "name": "List", - "templateUrl": "templates/todo.html" + "templateUrl": "templates/todo.html", + "editable": true } ] } -} + }); +}); ``` -__tutorials/todo/bundle.json__ +__tutorials/todo/bundle.js__ -Now, when To-do List objects are created in Open MCT Web, they will initially +Now, when To-do List objects are created in Open MCT, they will initially have the state described by that model property. -If we reload Open MCT Web, create a To-do List, and navigate to it in the tree, +If we reload Open MCT, create a To-do List, and navigate to it in the tree, we should now see: ![To-Do List](images/todo-list.png) @@ -527,7 +622,7 @@ first argument is falsy.) * `toggleCompletion` changes whether or not a task is complete. We make the change via the domain object's `mutation` capability, and then persist the -change via its `persistence` capability. See the Open MCT Web Developer Guide +change via its `persistence` capability. See the Open MCT Developer Guide for more information on these capabilities. * `showTask` is meant to be used to help decide if a task should be shown, based @@ -537,7 +632,7 @@ the use of the double-not !! to coerce the completed flag to a boolean, for equality testing.) Note that these functions make reference to `$scope.domainObject;` this is the -domain object being viewed, which is passed into the scope by Open MCT Web +domain object being viewed, which is passed into the scope by Open MCT prior to our template being utilized. On its own, this controller merely exposes these functions; the next step is to @@ -580,7 +675,14 @@ If we were to try to run at this point, we'd run into problems because the it in our bundle definition, as an extension of category `controllers`: ```diff -{ +define([ + 'legacyRegistry', + './src/controllers/TodoController' +], function ( + legacyRegistry, + TodoController +) { + legacyRegistry.register("tutorials/todo", { "name": "To-do Plugin", "description": "Allows creating and editing to-do lists.", "extensions": { @@ -588,7 +690,7 @@ it in our bundle definition, as an extension of category `controllers`: { "key": "example.todo", "name": "To-Do List", - "glyph": "j", + "glyph": "2", "description": "A list of things that need to be done.", "features": ["creation"], "model": { @@ -603,22 +705,24 @@ it in our bundle definition, as an extension of category `controllers`: { "key": "example.todo", "type": "example.todo", - "glyph": "j", + "glyph": "2", "name": "List", - "templateUrl": "templates/todo.html" + "templateUrl": "templates/todo.html", + "editable": true } ], + "controllers": [ + { + "key": "TodoController", -+ "implementation": "controllers/TodoController.js", ++ "implementation": TodoController, + "depends": [ "$scope" ] + } + ] } -} + }); +}); ``` -__tutorials/todo/bundle.json__ +__tutorials/todo/bundle.js__ In this extension definition we have: @@ -640,7 +744,7 @@ if we go to My Items and come back. We now have a somewhat-functional view of our To-Do List, but we're still missing some important functionality: Adding and removing tasks! -This is a good place to discuss the user interface style of Open MCT Web. Open +This is a good place to discuss the user interface style of Open MCT. Open MCT Web draws a distinction between "using" and "editing" a domain object; in general, you can only make changes to a domain object while in Edit mode, which is reachable from the button with a pencil icon. This distinction helps users @@ -665,7 +769,14 @@ view. The contents of this tool bar are defined declaratively in a view's extension definition. ```diff -{ +define([ + 'legacyRegistry', + './src/controllers/TodoController' +], function ( + legacyRegistry, + TodoController +) { + legacyRegistry.register("tutorials/todo", { "name": "To-do Plugin", "description": "Allows creating and editing to-do lists.", "extensions": { @@ -673,7 +784,7 @@ extension definition. { "key": "example.todo", "name": "To-Do List", - "glyph": "j", + "glyph": "2", "description": "A list of things that need to be done.", "features": ["creation"], "model": { @@ -688,9 +799,10 @@ extension definition. { "key": "example.todo", "type": "example.todo", - "glyph": "j", + "glyph": "2", "name": "List", "templateUrl": "templates/todo.html", + "editable": true, + "toolbar": { + "sections": [ + { @@ -719,27 +831,28 @@ extension definition. "controllers": [ { "key": "TodoController", - "implementation": "controllers/TodoController.js", + "implementation": TodoController, "depends": [ "$scope" ] } ] } -} + }); +}); ``` -__tutorials/todo/bundle.json__ +__tutorials/todo/bundle.js__ What we've stated here is that the To-Do List's view will have a toolbar which contains two sections (which will be visually separated by a divider), each of which contains one button. The first is a button labelled "Add Task" that will invoke an `addTask` method; the second is a button with a glyph (which will appear -as a trash can in Open MCT Web's custom font set) which will invoke a `removeTask` -method. For more information on forms and tool bars in Open MCT Web, see the -Open MCT Web Developer Guide. +as a trash can in Open MCT's custom font set) which will invoke a `removeTask` +method. For more information on forms and tool bars in Open MCT, see the +Open MCT Developer Guide. -If we reload and run Open MCT Web, we won't see any tool bar when we switch over +If we reload and run Open MCT, we won't see any tool bar when we switch over to Edit mode. This is because the aforementioned methods are expected to be found on currently-selected elements; we haven't done anything with selections -in our view yet, so the Open MCT Web platform will filter this tool bar down to +in our view yet, so the Open MCT platform will filter this tool bar down to all the applicable controls, which means no controls at all. To support selection, we will need to make some changes to our controller: @@ -842,7 +955,7 @@ click the _Add Task_ button. This form is described declaratively, and populates an object that has the same format as tasks in the `tasks` array of our To-Do List's model. * We've added an argument to the `TodoController`: The `dialogService`, which is -exposed by the Open MCT Web platform to handle showing dialogs. +exposed by the Open MCT platform to handle showing dialogs. * Some utility functions for handling the actual adding and removing of tasks. These use the `mutation` capability to modify the tasks in the To-Do List's model. @@ -884,7 +997,14 @@ __tutorials/todo/res/templates/todo.html__ Finally, the `TodoController` uses the `dialogService` now, so we need to declare that dependency in its extension definition: ```diff -{ +define([ + 'legacyRegistry', + './src/controllers/TodoController' +], function ( + legacyRegistry, + TodoController +) { + legacyRegistry.register("tutorials/todo", { "name": "To-do Plugin", "description": "Allows creating and editing to-do lists.", "extensions": { @@ -892,7 +1012,7 @@ declare that dependency in its extension definition: { "key": "example.todo", "name": "To-Do List", - "glyph": "j", + "glyph": "2", "description": "A list of things that need to be done.", "features": ["creation"], "model": { @@ -907,9 +1027,10 @@ declare that dependency in its extension definition: { "key": "example.todo", "type": "example.todo", - "glyph": "j", + "glyph": "2", "name": "List", "templateUrl": "templates/todo.html", + "editable": true, "toolbar": { "sections": [ { @@ -938,16 +1059,17 @@ declare that dependency in its extension definition: "controllers": [ { "key": "TodoController", - "implementation": "controllers/TodoController.js", + "implementation": TodoController, + "depends": [ "$scope", "dialogService" ] } ] } -} + }); +}); ``` -__tutorials/todo/bundle.json__ +__tutorials/todo/bundle.js__ -If we now reload Open MCT Web, we'll be able to see the new functionality we've +If we now reload Open MCT, we'll be able to see the new functionality we've added. If we Create a new To-Do List, navigate to it, and click the button with the Pencil icon in the top-right, we'll be in edit mode. We see, first, that our "Add Task" button appears in the tool bar: @@ -1136,11 +1258,18 @@ Here, we have defined classes and appearances for: * A message, which we will add next, to display when there are no tasks (`example-message`). -To include this CSS file in our running instance of Open MCT Web, we need to +To include this CSS file in our running instance of Open MCT, we need to declare it in our bundle definition, this time as an extension of category `stylesheets`: ```diff -{ +define([ + 'legacyRegistry', + './src/controllers/TodoController' +], function ( + legacyRegistry, + TodoController +) { + legacyRegistry.register("tutorials/todo", { "name": "To-do Plugin", "description": "Allows creating and editing to-do lists.", "extensions": { @@ -1148,7 +1277,7 @@ declare it in our bundle definition, this time as an extension of category { "key": "example.todo", "name": "To-Do List", - "glyph": "j", + "glyph": "2", "description": "A list of things that need to be done.", "features": ["creation"], "model": { @@ -1160,9 +1289,10 @@ declare it in our bundle definition, this time as an extension of category { "key": "example.todo", "type": "example.todo", - "glyph": "j", + "glyph": "2", "name": "List", "templateUrl": "templates/todo.html", + "editable": true, "toolbar": { "sections": [ { @@ -1191,7 +1321,7 @@ declare it in our bundle definition, this time as an extension of category "controllers": [ { "key": "TodoController", - "implementation": "controllers/TodoController.js", + "implementation": TodoController, "depends": [ "$scope", "dialogService" ] } ], @@ -1201,14 +1331,16 @@ declare it in our bundle definition, this time as an extension of category + } + ] } -} + }); +}); ``` -__tutorials/todo/bundle.json__ +__tutorials/todo/bundle.js__ Note that we've also removed our placeholder tasks from the `model` of the To-Do List's type above; now To-Do Lists will start off empty. Finally, let's utilize these changes from our view's template: + ```diff +
+
@@ -1270,7 +1402,12 @@ well. We'll be creating this plugin in `tutorials/bargraph`, so our initial bundle definition looks like: ```diff -{ +define([ + 'legacyRegistry' +], function ( + legacyRegistry +) { + legacyRegistry.register("tutorials/bargraph", { "name": "Bar Graph", "description": "Provides the Bar Graph view of telemetry elements.", "extensions": { @@ -1290,10 +1427,11 @@ bundle definition looks like: } ] } -} + }); +}); ``` -__tutorials/bargraph/bundle.json__ +__tutorials/bargraph/bundle.js__ The view definition should look familiar after the To-Do List tutorial, with some additions: @@ -1435,8 +1573,8 @@ The corresponding CSS file which styles and positions these elements: ``` __tutorials/bargraph/res/css/bargraph.css__ -This is already enough that, if we add `"tutorials/bargraph"` to `bundles.json`, -we should be able to run Open MCT Web and see our Bar Graph as an available view +This is already enough that, if we add `"tutorials/bargraph"` to `main.js`, +we should be able to run Open MCT and see our Bar Graph as an available view for domain objects which provide telemetry (such as the example _Sine Wave Generator_) as well as for _Telemetry Panel_ objects: @@ -1502,7 +1640,7 @@ will help support some positioning in the template. to real-time telemetry updates. This will deal with most of the complexity of dealing with telemetry (e.g. differentiating between individual telemetry points and telemetry panels, monitoring latest values) and provide us with a useful -interface for populating our view. The the Open MCT Web Developer Guide for more +interface for populating our view. The the Open MCT Developer Guide for more information on dealing with telemetry. Whenever the telemetry handler invokes its callbacks, we update the set of @@ -1510,7 +1648,7 @@ telemetry objects in view, as well as the width for each bar. We will also utilize this from our template: ```diff -
++
+
+
diff --git a/main.js b/main.js index 33e45c0125..4fba458a4c 100644 --- a/main.js +++ b/main.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define, window, requirejs*/ +/*global requirejs*/ requirejs.config({ "paths": { @@ -41,10 +41,13 @@ requirejs.config({ "exports": "angular" }, "angular-route": { - "deps": [ "angular" ] + "deps": ["angular"] }, "moment-duration-format": { - "deps": [ "moment" ] + "deps": ["moment"] + }, + "screenfull": { + "exports": "screenfull" }, "zepto": { "exports": "Zepto" @@ -89,18 +92,12 @@ define([ './platform/entanglement/bundle', './platform/search/bundle', './platform/status/bundle', - './platform/commonUI/regions/bundle', - - './example/imagery/bundle', - './example/eventGenerator/bundle', - './example/generator/bundle' + './platform/commonUI/regions/bundle' ], function (Main, legacyRegistry) { - 'use strict'; - return { legacyRegistry: legacyRegistry, run: function () { return new Main().run(legacyRegistry); } }; -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index 6830d197e6..eb7afd1f70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "openmctweb", - "version": "0.10.0-SNAPSHOT", + "name": "openmct", + "version": "0.10.2-SNAPSHOT", "description": "The Open MCT core platform", "dependencies": { "express": "^4.13.1", @@ -34,6 +34,7 @@ "lodash": "^3.10.1", "markdown-toc": "^0.11.7", "marked": "^0.3.5", + "merge-stream": "^1.0.0", "mkdirp": "^0.5.1", "moment": "^2.11.1", "node-bourbon": "^4.2.3", @@ -53,7 +54,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/nasa/openmctweb.git" + "url": "https://github.com/nasa/openmct.git" }, "author": "", "license": "Apache-2.0", diff --git a/platform/commonUI/about/bundle.js b/platform/commonUI/about/bundle.js index aff0825f5c..a5fdd726d5 100644 --- a/platform/commonUI/about/bundle.js +++ b/platform/commonUI/about/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "text!./res/templates/about-dialog.html", @@ -48,7 +47,6 @@ define([ licensesExportMdTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/about", { "name": "About Open MCT Web", diff --git a/platform/commonUI/about/res/templates/about-dialog.html b/platform/commonUI/about/res/templates/about-dialog.html index 7b7dd436f5..bd87ce72c1 100644 --- a/platform/commonUI/about/res/templates/about-dialog.html +++ b/platform/commonUI/about/res/templates/about-dialog.html @@ -22,7 +22,7 @@
-

OpenMCT Web

+

Open MCT

Open MCT Web, Copyright © 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.

diff --git a/platform/commonUI/about/src/AboutController.js b/platform/commonUI/about/src/AboutController.js index dffd9b9471..0807166bc9 100644 --- a/platform/commonUI/about/src/AboutController.js +++ b/platform/commonUI/about/src/AboutController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** @@ -29,7 +28,6 @@ define( [], function () { - "use strict"; /** * The AboutController provides information to populate the diff --git a/platform/commonUI/about/src/LicenseController.js b/platform/commonUI/about/src/LicenseController.js index 740124641f..5d030588c9 100644 --- a/platform/commonUI/about/src/LicenseController.js +++ b/platform/commonUI/about/src/LicenseController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Provides extension-introduced licenses information to the diff --git a/platform/commonUI/about/src/LogoController.js b/platform/commonUI/about/src/LogoController.js index 85909a0552..616981e8da 100644 --- a/platform/commonUI/about/src/LogoController.js +++ b/platform/commonUI/about/src/LogoController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The LogoController provides functionality to the application diff --git a/platform/commonUI/about/test/AboutControllerSpec.js b/platform/commonUI/about/test/AboutControllerSpec.js index c4fb26c488..e3af1f5b01 100644 --- a/platform/commonUI/about/test/AboutControllerSpec.js +++ b/platform/commonUI/about/test/AboutControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../src/AboutController'], function (AboutController) { - "use strict"; describe("The About controller", function () { var testVersions, @@ -57,4 +55,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/about/test/LicenseControllerSpec.js b/platform/commonUI/about/test/LicenseControllerSpec.js index 9e281c3cfd..b5c1af4080 100644 --- a/platform/commonUI/about/test/LicenseControllerSpec.js +++ b/platform/commonUI/about/test/LicenseControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../src/LicenseController'], function (LicenseController) { - "use strict"; describe("The License controller", function () { var testLicenses, @@ -48,4 +46,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/about/test/LogoControllerSpec.js b/platform/commonUI/about/test/LogoControllerSpec.js index c7ad665319..b877658a23 100644 --- a/platform/commonUI/about/test/LogoControllerSpec.js +++ b/platform/commonUI/about/test/LogoControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../src/LogoController'], function (LogoController) { - "use strict"; describe("The About controller", function () { var mockOverlayService, @@ -50,4 +48,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/bundle.js b/platform/commonUI/browse/bundle.js index 7fd785a7f5..73b3f44de7 100644 --- a/platform/commonUI/browse/bundle.js +++ b/platform/commonUI/browse/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/BrowseController", @@ -80,7 +79,6 @@ define([ inspectorRegionTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/browse", { "extensions": { diff --git a/platform/commonUI/browse/res/templates/browse/object-header.html b/platform/commonUI/browse/res/templates/browse/object-header.html index 2136bdd416..d46cbd91cb 100644 --- a/platform/commonUI/browse/res/templates/browse/object-header.html +++ b/platform/commonUI/browse/res/templates/browse/object-header.html @@ -26,5 +26,5 @@ + class="flex-elem context-available-w"> \ No newline at end of file diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index db7d9182cb..53ddc14e79 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -19,18 +19,14 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise, confirm*/ /** * This bundle implements Browse mode. * @namespace platform/commonUI/browse */ define( - [ - '../../../representation/src/gestures/GestureConstants' - ], - function (GestureConstants) { - "use strict"; + [], + function () { var ROOT_ID = "ROOT"; @@ -45,13 +41,13 @@ define( * @constructor */ function BrowseController( - $scope, - $route, - $location, - $window, - objectService, - navigationService, - urlService, + $scope, + $route, + $location, + $window, + objectService, + navigationService, + urlService, policyService, defaultPath ) { @@ -84,12 +80,12 @@ define( function setNavigation(domainObject) { var navigationAllowed = true; - if (domainObject === $scope.navigatedObject){ + if (domainObject === $scope.navigatedObject) { //do nothing; return; } - policyService.allow("navigation", $scope.navigatedObject, domainObject, function(message){ + policyService.allow("navigation", $scope.navigatedObject, domainObject, function (message) { navigationAllowed = $window.confirm(message + "\r\n\r\n" + " Are you sure you want to continue?"); }); diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js index 71345d6f1b..441bb83d02 100644 --- a/platform/commonUI/browse/src/BrowseObjectController.js +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( [], function () { - "use strict"; /** * Controller for the `browse-object` representation of a domain @@ -35,7 +33,7 @@ define( function BrowseObjectController($scope, $location, $route) { var navigatedObject; function setViewForDomainObject(domainObject) { - + var locationViewKey = $location.search().view; function selectViewIfMatching(view) { @@ -72,7 +70,7 @@ define( $scope.$watch('domainObject', setViewForDomainObject); $scope.$watch('representation.selected.key', updateQueryParam); - $scope.doAction = function (action){ + $scope.doAction = function (action) { return $scope[action] && $scope[action](); }; diff --git a/platform/commonUI/browse/src/InspectorRegion.js b/platform/commonUI/browse/src/InspectorRegion.js index cc47ae2db8..382f6a9a0c 100644 --- a/platform/commonUI/browse/src/InspectorRegion.js +++ b/platform/commonUI/browse/src/InspectorRegion.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,window*/ define( [ '../../regions/src/Region' ], function (Region) { - "use strict"; /** * Defines the a default Inspector region. Captured in a class to @@ -47,7 +45,7 @@ define( /** * @private */ - InspectorRegion.prototype.buildRegion = function() { + InspectorRegion.prototype.buildRegion = function () { var metadataRegion = { name: 'metadata', title: 'Metadata Region', diff --git a/platform/commonUI/browse/src/MenuArrowController.js b/platform/commonUI/browse/src/MenuArrowController.js index 5c4916e099..ccb0b3b65e 100644 --- a/platform/commonUI/browse/src/MenuArrowController.js +++ b/platform/commonUI/browse/src/MenuArrowController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining MenuArrowController. Created by shale on 06/30/2015. @@ -27,12 +26,11 @@ define( [], function () { - "use strict"; - + /** - * A left-click on the menu arrow should display a - * context menu. This controller launches the context - * menu. + * A left-click on the menu arrow should display a + * context menu. This controller launches the context + * menu. * @memberof platform/commonUI/browse * @constructor */ diff --git a/platform/commonUI/browse/src/PaneController.js b/platform/commonUI/browse/src/PaneController.js index 6a59baa0e0..3fb5630fdd 100644 --- a/platform/commonUI/browse/src/PaneController.js +++ b/platform/commonUI/browse/src/PaneController.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( [], function () { - "use strict"; /** * Controller to provide the ability to show/hide the tree in diff --git a/platform/commonUI/browse/src/creation/AddAction.js b/platform/commonUI/browse/src/creation/AddAction.js index 4685e80b75..0ac56957a2 100644 --- a/platform/commonUI/browse/src/creation/AddAction.js +++ b/platform/commonUI/browse/src/creation/AddAction.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining AddAction. Created by ahenry on 01/21/16. @@ -29,7 +28,6 @@ define( './CreateWizard' ], function (CreateWizard) { - "use strict"; /** * The Add Action is performed to create new instances of @@ -83,13 +81,13 @@ define( newModel.type = this.type.getKey(); newObject = parentObject.getCapability('instantiation').instantiate(newModel); - newObject.useCapability('mutation', function(model){ + newObject.useCapability('mutation', function (model) { model.location = parentObject.getId(); }); wizard = new CreateWizard(newObject, this.parent, this.policyService); - function populateObjectFromInput (formValue) { + function populateObjectFromInput(formValue) { return wizard.populateObjectFromInput(formValue, newObject); } @@ -101,7 +99,7 @@ define( }); } - function addToParent (populatedObject) { + function addToParent(populatedObject) { parentObject.getCapability('composition').add(populatedObject); return persistAndReturn(parentObject); } @@ -127,7 +125,7 @@ define( * @returns {AddActionMetadata} metadata about this action */ AddAction.prototype.getMetadata = function () { - return this.metadata; + return this.metadata; }; return AddAction; diff --git a/platform/commonUI/browse/src/creation/AddActionProvider.js b/platform/commonUI/browse/src/creation/AddActionProvider.js index 0ac97c0013..9ae5364d95 100644 --- a/platform/commonUI/browse/src/creation/AddActionProvider.js +++ b/platform/commonUI/browse/src/creation/AddActionProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining AddActionProvider.js. Created by ahenry on 01/21/16. @@ -27,7 +26,6 @@ define( ["./AddAction"], function (AddAction) { - "use strict"; /** * The AddActionProvider is an ActionProvider which introduces diff --git a/platform/commonUI/browse/src/creation/CreateAction.js b/platform/commonUI/browse/src/creation/CreateAction.js index 83d88ba709..c5097e166d 100644 --- a/platform/commonUI/browse/src/creation/CreateAction.js +++ b/platform/commonUI/browse/src/creation/CreateAction.js @@ -19,18 +19,13 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining CreateAction. Created by vwoeltje on 11/10/14. */ define( - [ - './CreateWizard', - '../../../edit/src/objects/EditableDomainObject' - ], - function (CreateWizard, EditableDomainObject) { - "use strict"; + [], + function () { /** * The Create Action is performed to create new instances of @@ -88,22 +83,25 @@ define( CreateAction.prototype.perform = function () { var newModel = this.type.getInitialModel(), parentObject = this.navigationService.getNavigation(), - newObject, - editableObject; + editorCapability, + newObject; newModel.type = this.type.getKey(); + newModel.location = parentObject.getId(); newObject = parentObject.useCapability('instantiation', newModel); - editableObject = new EditableDomainObject(newObject, this.$q); - editableObject.setOriginalObject(parentObject); - editableObject.getCapability('status').set('editing', true); - editableObject.useCapability('mutation', function(model){ - model.location = parentObject.getId(); - }); - if (countEditableViews(editableObject) > 0 && editableObject.hasCapability('composition')) { - this.navigationService.setNavigation(editableObject); + editorCapability = newObject.getCapability("editor"); + + if (countEditableViews(newObject) > 0 && newObject.hasCapability('composition')) { + this.navigationService.setNavigation(newObject); + return newObject.getCapability("action").perform("edit"); } else { - return editableObject.getCapability('action').perform('save'); + editorCapability.edit(); + return newObject.useCapability("action").perform("save").then(function () { + return editorCapability.save(); + }, function () { + return editorCapability.cancel(); + }); } }; @@ -120,7 +118,7 @@ define( * @returns {CreateActionMetadata} metadata about this action */ CreateAction.prototype.getMetadata = function () { - return this.metadata; + return this.metadata; }; return CreateAction; diff --git a/platform/commonUI/browse/src/creation/CreateActionProvider.js b/platform/commonUI/browse/src/creation/CreateActionProvider.js index 0a8d145b4e..82f57343da 100644 --- a/platform/commonUI/browse/src/creation/CreateActionProvider.js +++ b/platform/commonUI/browse/src/creation/CreateActionProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining CreateActionProvider.js. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( ["./CreateAction"], function (CreateAction) { - "use strict"; /** * The CreateActionProvider is an ActionProvider which introduces diff --git a/platform/commonUI/browse/src/creation/CreateMenuController.js b/platform/commonUI/browse/src/creation/CreateMenuController.js index 624764c2e4..77e09a69c4 100644 --- a/platform/commonUI/browse/src/creation/CreateMenuController.js +++ b/platform/commonUI/browse/src/creation/CreateMenuController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining CreateMenuController. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Controller for the Create menu; maintains an up-to-date diff --git a/platform/commonUI/browse/src/creation/CreateWizard.js b/platform/commonUI/browse/src/creation/CreateWizard.js index f4a29d42ac..1ec234ee08 100644 --- a/platform/commonUI/browse/src/creation/CreateWizard.js +++ b/platform/commonUI/browse/src/creation/CreateWizard.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( function () { - 'use strict'; /** * A class for capturing user input data from an object creation @@ -113,12 +111,12 @@ define( * @param formValue * @returns {DomainObject} */ - CreateWizard.prototype.populateObjectFromInput = function(formValue) { + CreateWizard.prototype.populateObjectFromInput = function (formValue) { var parent = this.getLocation(formValue), formModel = this.createModel(formValue); formModel.location = parent.getId(); - this.domainObject.useCapability("mutation", function(){ + this.domainObject.useCapability("mutation", function () { return formModel; }); return this.domainObject; diff --git a/platform/commonUI/browse/src/creation/CreationPolicy.js b/platform/commonUI/browse/src/creation/CreationPolicy.js index 28749e711f..4880f884b9 100644 --- a/platform/commonUI/browse/src/creation/CreationPolicy.js +++ b/platform/commonUI/browse/src/creation/CreationPolicy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * A policy for determining whether objects of a given type can be @@ -42,4 +40,4 @@ define( return CreationPolicy; } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/src/creation/CreationService.js b/platform/commonUI/browse/src/creation/CreationService.js index 4b7c0119c9..6048d15378 100644 --- a/platform/commonUI/browse/src/creation/CreationService.js +++ b/platform/commonUI/browse/src/creation/CreationService.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining CreateService. Created by vwoeltje on 11/10/14. @@ -27,12 +26,9 @@ define( [], function () { - "use strict"; var NON_PERSISTENT_WARNING = - "Tried to create an object in non-persistent container.", - NO_COMPOSITION_WARNING = - "Could not add to composition; no composition in "; + "Tried to create an object in non-persistent container."; /** * The creation service is responsible for instantiating and diff --git a/platform/commonUI/browse/src/creation/LocatorController.js b/platform/commonUI/browse/src/creation/LocatorController.js index 3d8c6cfc7f..b8c3f6a2dc 100644 --- a/platform/commonUI/browse/src/creation/LocatorController.js +++ b/platform/commonUI/browse/src/creation/LocatorController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Controller for the "locator" control, which provides the @@ -52,14 +50,14 @@ define( $scope.rootObject = (context && context.getRoot()) || $scope.rootObject; }, 0); - } else if (!contextRoot){ + } else if (!contextRoot) { //If no context root is available, default to the root // object $scope.rootObject = undefined; // Update the displayed tree on a timeout to avoid // an infinite digest exception. objectService.getObjects(['ROOT']) - .then(function(objects){ + .then(function (objects) { $timeout(function () { $scope.rootObject = objects.ROOT; }, 0); diff --git a/platform/commonUI/browse/src/navigation/NavigateAction.js b/platform/commonUI/browse/src/navigation/NavigateAction.js index 7b258afafe..e9cc700f93 100644 --- a/platform/commonUI/browse/src/navigation/NavigateAction.js +++ b/platform/commonUI/browse/src/navigation/NavigateAction.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining NavigateAction. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * The navigate action navigates to a specific domain object. diff --git a/platform/commonUI/browse/src/navigation/NavigationService.js b/platform/commonUI/browse/src/navigation/NavigationService.js index 3b4d266bd1..05d93aa996 100644 --- a/platform/commonUI/browse/src/navigation/NavigationService.js +++ b/platform/commonUI/browse/src/navigation/NavigationService.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining NavigationService. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * The navigation service maintains the application's current diff --git a/platform/commonUI/browse/src/windowing/FullscreenAction.js b/platform/commonUI/browse/src/windowing/FullscreenAction.js index 5de4336acd..e9fcf9df76 100644 --- a/platform/commonUI/browse/src/windowing/FullscreenAction.js +++ b/platform/commonUI/browse/src/windowing/FullscreenAction.js @@ -19,15 +19,13 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,screenfull,Promise*/ /** * Module defining FullscreenAction. Created by vwoeltje on 11/18/14. */ define( ["screenfull"], - function () { - "use strict"; + function (screenfull) { var ENTER_FULLSCREEN = "Enter full screen mode", EXIT_FULLSCREEN = "Exit full screen mode"; diff --git a/platform/commonUI/browse/src/windowing/NewTabAction.js b/platform/commonUI/browse/src/windowing/NewTabAction.js index 301c204bbd..86c1dfdd94 100644 --- a/platform/commonUI/browse/src/windowing/NewTabAction.js +++ b/platform/commonUI/browse/src/windowing/NewTabAction.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining NewTabAction (Originally NewWindowAction). Created by vwoeltje on 11/18/14. @@ -27,9 +26,6 @@ define( [], function () { - "use strict"; - var ROOT_ID = "ROOT", - DEFAULT_PATH = "/mine"; /** * The new tab action allows a domain object to be opened * into a new browser tab. diff --git a/platform/commonUI/browse/src/windowing/WindowTitler.js b/platform/commonUI/browse/src/windowing/WindowTitler.js index 4ce448cb1e..eb8c499e24 100644 --- a/platform/commonUI/browse/src/windowing/WindowTitler.js +++ b/platform/commonUI/browse/src/windowing/WindowTitler.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( [], function () { - "use strict"; /** * Updates the title of the current window to reflect the name diff --git a/platform/commonUI/browse/test/BrowseControllerSpec.js b/platform/commonUI/browse/test/BrowseControllerSpec.js index cc14b4d0e5..2c20467185 100644 --- a/platform/commonUI/browse/test/BrowseControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/BrowseController"], function (BrowseController) { - "use strict"; describe("The browse controller", function () { var mockScope, @@ -80,12 +78,12 @@ define( mockScope = jasmine.createSpyObj( "$scope", - [ "$on", "$watch" ] + ["$on", "$watch"] ); mockRoute = { current: { params: {} } }; mockLocation = jasmine.createSpyObj( "$location", - [ "path" ] + ["path"] ); mockUrlService = jasmine.createSpyObj( "urlService", @@ -93,7 +91,7 @@ define( ); mockObjectService = jasmine.createSpyObj( "objectService", - [ "getObjects" ] + ["getObjects"] ); mockNavigationService = jasmine.createSpyObj( "navigationService", @@ -106,15 +104,15 @@ define( ); mockRootObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "getModel", "useCapability" ] + ["getId", "getCapability", "getModel", "useCapability"] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "getModel", "useCapability" ] + ["getId", "getCapability", "getModel", "useCapability"] ); mockNextObject = jasmine.createSpyObj( "nextObject", - [ "getId", "getCapability", "getModel", "useCapability" ] + ["getId", "getCapability", "getModel", "useCapability"] ); mockObjectService.getObjects.andReturn(mockPromise({ @@ -257,7 +255,7 @@ define( " object", function () { mockScope.navigatedObject = mockDomainObject; mockWindow.confirm.andReturn(false); - mockPolicyService.allow.andCallFake(function(category, object, context, callback){ + mockPolicyService.allow.andCallFake(function (category, object, context, callback) { callback("unsaved changes"); return false; }); diff --git a/platform/commonUI/browse/test/BrowseObjectControllerSpec.js b/platform/commonUI/browse/test/BrowseObjectControllerSpec.js index 9fc7ba3119..255badaf97 100644 --- a/platform/commonUI/browse/test/BrowseObjectControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseObjectControllerSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/BrowseObjectController"], function (BrowseObjectController) { - "use strict"; describe("The browse object controller", function () { var mockScope, @@ -46,12 +44,12 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "$on", "$watch" ] + ["$on", "$watch"] ); mockRoute = { current: { params: {} } }; mockLocation = jasmine.createSpyObj( "$location", - [ "path", "search" ] + ["path", "search"] ); mockUnlisten = jasmine.createSpy("unlisten"); @@ -71,7 +69,7 @@ define( // Allows the path index to be checked // prior to setting $route.current mockLocation.path.andReturn("/browse/"); - + // Exercise the Angular workaround mockScope.$on.mostRecentCall.args[1](); expect(mockUnlisten).toHaveBeenCalled(); diff --git a/platform/commonUI/browse/test/InspectorRegionSpec.js b/platform/commonUI/browse/test/InspectorRegionSpec.js index e455a8df4d..a5fac51a30 100644 --- a/platform/commonUI/browse/test/InspectorRegionSpec.js +++ b/platform/commonUI/browse/test/InspectorRegionSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTIncudeSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/InspectorRegion"], function (InspectorRegion) { - "use strict"; describe("The inspector region", function () { var inspectorRegion; @@ -42,4 +40,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/MenuArrowControllerSpec.js b/platform/commonUI/browse/test/MenuArrowControllerSpec.js index b8aa345489..94246b94f2 100644 --- a/platform/commonUI/browse/test/MenuArrowControllerSpec.js +++ b/platform/commonUI/browse/test/MenuArrowControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MenuArrowControllerSpec. Created by shale on 07/02/2015. @@ -27,8 +26,7 @@ define( ["../src/MenuArrowController"], function (MenuArrowController) { - "use strict"; - + describe("The menu arrow controller ", function () { var mockScope, mockDomainObject, @@ -36,43 +34,43 @@ define( mockContextMenuAction, mockActionContext, controller; - + beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "" ] + [""] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getCapability" ] + ["getCapability"] ); mockEvent = jasmine.createSpyObj( "event", - [ "preventDefault" ] + ["preventDefault"] ); mockContextMenuAction = jasmine.createSpyObj( "action", - [ "perform", "getActions" ] + ["perform", "getActions"] ); mockActionContext = jasmine.createSpyObj( "actionContext", - [ "" ] + [""] ); - + mockActionContext.domainObject = mockDomainObject; mockActionContext.event = mockEvent; mockScope.domainObject = mockDomainObject; mockDomainObject.getCapability.andReturn(mockContextMenuAction); mockContextMenuAction.perform.andReturn(jasmine.any(Function)); - + controller = new MenuArrowController(mockScope); }); - + it("calls the context menu action when clicked", function () { // Simulate a click on the menu arrow controller.showMenu(mockEvent); - - // Expect the menu action to be performed + + // Expect the menu action to be performed expect(mockDomainObject.getCapability).toHaveBeenCalledWith('action'); expect(mockContextMenuAction.perform).toHaveBeenCalled(); }); diff --git a/platform/commonUI/browse/test/PaneControllerSpec.js b/platform/commonUI/browse/test/PaneControllerSpec.js index f02da713a4..cbb792cc00 100644 --- a/platform/commonUI/browse/test/PaneControllerSpec.js +++ b/platform/commonUI/browse/test/PaneControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PaneController"], function (PaneController) { - 'use strict'; describe("The PaneController", function () { var mockScope, @@ -44,11 +42,11 @@ define( } beforeEach(function () { - mockScope = jasmine.createSpyObj("$scope", [ "$on" ]); + mockScope = jasmine.createSpyObj("$scope", ["$on"]); mockDomainObjects = ['a', 'b'].map(function (id) { var mockDomainObject = jasmine.createSpyObj( 'domainObject-' + id, - [ 'getId', 'getModel', 'getCapability' ] + ['getId', 'getModel', 'getCapability'] ); mockDomainObject.getId.andReturn(id); @@ -58,7 +56,7 @@ define( }); mockAgentService = jasmine.createSpyObj( "agentService", - [ "isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape" ] + ["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"] ); mockWindow = jasmine.createSpyObj("$window", ["open"]); }); diff --git a/platform/commonUI/browse/test/creation/AddActionProviderSpec.js b/platform/commonUI/browse/test/creation/AddActionProviderSpec.js index aaa83af8e9..121f9b193d 100644 --- a/platform/commonUI/browse/test/creation/AddActionProviderSpec.js +++ b/platform/commonUI/browse/test/creation/AddActionProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/ /** * MCTRepresentationSpec. Created by ahenry on 01/21/14. @@ -27,7 +26,6 @@ define( ["../../src/creation/AddActionProvider"], function (AddActionProvider) { - "use strict"; describe("The add action provider", function () { var mockTypeService, @@ -62,37 +60,37 @@ define( beforeEach(function () { mockTypeService = jasmine.createSpyObj( "typeService", - [ "listTypes" ] + ["listTypes"] ); mockDialogService = jasmine.createSpyObj( "dialogService", - [ "getUserInput" ] + ["getUserInput"] ); mockPolicyService = jasmine.createSpyObj( "policyService", - [ "allow" ] + ["allow"] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getCapability" ] + ["getCapability"] ); //Mocking getCapability because AddActionProvider uses the // type capability of the destination object. mockDomainObject.getCapability.andReturn({}); - mockTypes = [ "A", "B", "C" ].map(createMockType); + mockTypes = ["A", "B", "C"].map(createMockType); - mockTypes.forEach(function(type){ + mockTypes.forEach(function (type) { mockPolicyMap[type.getName()] = true; }); - mockCreationPolicy = function(type){ + mockCreationPolicy = function (type) { return mockPolicyMap[type.getName()]; }; - mockCompositionPolicy = function(){ + mockCompositionPolicy = function () { return true; }; @@ -134,4 +132,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js b/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js index 857b29fe4e..fbfc4a1140 100644 --- a/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js +++ b/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/creation/CreateActionProvider"], function (CreateActionProvider) { - "use strict"; describe("The create action provider", function () { var mockTypeService, @@ -61,32 +59,32 @@ define( beforeEach(function () { mockTypeService = jasmine.createSpyObj( "typeService", - [ "listTypes" ] + ["listTypes"] ); mockDialogService = jasmine.createSpyObj( "dialogService", - [ "getUserInput" ] + ["getUserInput"] ); mockNavigationService = jasmine.createSpyObj( "navigationService", - [ "setNavigation" ] + ["setNavigation"] ); mockPolicyService = jasmine.createSpyObj( "policyService", - [ "allow" ] + ["allow"] ); - mockTypes = [ "A", "B", "C" ].map(createMockType); + mockTypes = ["A", "B", "C"].map(createMockType); - mockTypes.forEach(function(type){ + mockTypes.forEach(function (type) { mockPolicyMap[type.getName()] = true; }); - mockCreationPolicy = function(type){ + mockCreationPolicy = function (type) { return mockPolicyMap[type.getName()]; }; - mockPolicyService.allow.andCallFake(function(category, type){ + mockPolicyService.allow.andCallFake(function (category, type) { return category === "creation" && mockCreationPolicy(type) ? true : false; }); @@ -128,4 +126,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/creation/CreateActionSpec.js b/platform/commonUI/browse/test/creation/CreateActionSpec.js index d7e357fd9e..5fa89512e0 100644 --- a/platform/commonUI/browse/test/creation/CreateActionSpec.js +++ b/platform/commonUI/browse/test/creation/CreateActionSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/creation/CreateAction"], function (CreateAction) { - "use strict"; describe("The create action", function () { var mockType, @@ -70,11 +68,11 @@ define( }; mockDialogService = jasmine.createSpyObj( "dialogService", - [ "getUserInput" ] + ["getUserInput"] ); mockCreationService = jasmine.createSpyObj( "creationService", - [ "createObject" ] + ["createObject"] ); mockType.getKey.andReturn("test"); @@ -129,4 +127,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/creation/CreateMenuControllerSpec.js b/platform/commonUI/browse/test/creation/CreateMenuControllerSpec.js index 5f10ee35e4..b2c1f4afa4 100644 --- a/platform/commonUI/browse/test/creation/CreateMenuControllerSpec.js +++ b/platform/commonUI/browse/test/creation/CreateMenuControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/creation/CreateMenuController"], function (CreateMenuController) { - "use strict"; describe("The create menu controller", function () { var mockScope, @@ -64,4 +62,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/creation/CreateWizardSpec.js b/platform/commonUI/browse/test/creation/CreateWizardSpec.js index fbb2a735e6..628fdbc447 100644 --- a/platform/commonUI/browse/test/creation/CreateWizardSpec.js +++ b/platform/commonUI/browse/test/creation/CreateWizardSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/creation/CreateWizard"], function (CreateWizard) { - "use strict"; describe("The create wizard", function () { var mockType, @@ -41,7 +39,7 @@ define( function createMockProperty(name) { var mockProperty = jasmine.createSpyObj( "property" + name, - [ "getDefinition", "getValue", "setValue" ] + ["getDefinition", "getValue", "setValue"] ); mockProperty.getDefinition.andReturn({ control: "textfield" @@ -70,7 +68,7 @@ define( "getCapability" ] ); - mockProperties = [ "A", "B", "C" ].map(createMockProperty); + mockProperties = ["A", "B", "C"].map(createMockProperty); mockPolicyService = jasmine.createSpyObj('policyService', ['allow']); testModel = { someKey: "some value" }; @@ -146,15 +144,15 @@ define( "A": "ValueA", "B": "ValueB", "C": "ValueC" - }, - compareModel = wizard.createModel(formValue); + }, + compareModel = wizard.createModel(formValue); wizard.populateObjectFromInput(formValue); expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function)); expect(mockDomainObject.useCapability.mostRecentCall.args[1]()).toEqual(compareModel); }); it("validates selection types using policy", function () { - var mockDomainObject = jasmine.createSpyObj( + var mockDomainObj = jasmine.createSpyObj( 'domainObject', ['getCapability'] ), @@ -168,8 +166,8 @@ define( rows = structure.sections[sections.length - 1].rows, locationRow = rows[rows.length - 1]; - mockDomainObject.getCapability.andReturn(mockOtherType); - locationRow.validate(mockDomainObject); + mockDomainObj.getCapability.andReturn(mockOtherType); + locationRow.validate(mockDomainObj); // Should check policy to see if the user-selected location // can actually contain objects of this type @@ -181,7 +179,7 @@ define( }); it("creates a form model without a location if not requested", function () { - expect(wizard.getFormStructure(false).sections.some(function(section){ + expect(wizard.getFormStructure(false).sections.some(function (section) { return section.name === 'Location'; })).toEqual(false); }); diff --git a/platform/commonUI/browse/test/creation/CreationPolicySpec.js b/platform/commonUI/browse/test/creation/CreationPolicySpec.js index 1f88c1b149..1c6a5421ca 100644 --- a/platform/commonUI/browse/test/creation/CreationPolicySpec.js +++ b/platform/commonUI/browse/test/creation/CreationPolicySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/creation/CreationPolicy"], function (CreationPolicy) { - "use strict"; describe("The creation policy", function () { var mockType, @@ -50,4 +48,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/creation/CreationServiceSpec.js b/platform/commonUI/browse/test/creation/CreationServiceSpec.js index e0704ba702..fe740ca87a 100644 --- a/platform/commonUI/browse/test/creation/CreationServiceSpec.js +++ b/platform/commonUI/browse/test/creation/CreationServiceSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/creation/CreationService"], function (CreationService) { - "use strict"; describe("The creation service", function () { var mockQ, @@ -63,23 +61,23 @@ define( mockQ = { when: mockPromise, reject: mockReject }; mockLog = jasmine.createSpyObj( "$log", - [ "error", "warn", "info", "debug" ] + ["error", "warn", "info", "debug"] ); mockParentObject = jasmine.createSpyObj( "parentObject", - [ "getId", "getCapability", "useCapability" ] + ["getId", "getCapability", "useCapability"] ); mockNewObject = jasmine.createSpyObj( "newObject", - [ "getId", "getCapability", "useCapability" ] + ["getId", "getCapability", "useCapability"] ); mockMutationCapability = jasmine.createSpyObj( "mutation", - [ "invoke" ] + ["invoke"] ); mockPersistenceCapability = jasmine.createSpyObj( "persistence", - [ "persist", "getSpace" ] + ["persist", "getSpace"] ); mockCompositionCapability = jasmine.createSpyObj( "composition", @@ -102,7 +100,7 @@ define( }; mockNewPersistenceCapability = jasmine.createSpyObj( "new-persistence", - [ "persist", "getSpace" ] + ["persist", "getSpace"] ); mockParentObject.getCapability.andCallFake(function (key) { @@ -149,8 +147,7 @@ define( }); it("adds new objects to the parent's composition", function () { - var model = { someKey: "some value" }, - parentModel = { composition: ["notAnyUUID"] }; + var model = { someKey: "some value" }; creationService.createObject(model, mockParentObject); // Verify that a new ID was added @@ -201,8 +198,7 @@ define( it("logs an error when mutaton fails", function () { // If mutation of the parent fails, we've lost the // created object - this is an error. - var model = { someKey: "some value" }, - parentModel = { composition: ["notAnyUUID"] }; + var model = { someKey: "some value" }; mockCompositionCapability.add.andReturn(mockPromise(false)); diff --git a/platform/commonUI/browse/test/creation/LocatorControllerSpec.js b/platform/commonUI/browse/test/creation/LocatorControllerSpec.js index 381aecf0ab..ffdf6514fb 100644 --- a/platform/commonUI/browse/test/creation/LocatorControllerSpec.js +++ b/platform/commonUI/browse/test/creation/LocatorControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/creation/LocatorController"], function (LocatorController) { - "use strict"; describe("The locator controller", function () { var mockScope, @@ -42,20 +40,20 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "$watch" ] + ["$watch"] ); mockTimeout = jasmine.createSpy("$timeout"); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getCapability" ] + ["getCapability"] ); mockRootObject = jasmine.createSpyObj( "rootObject", - [ "getCapability" ] + ["getCapability"] ); mockContext = jasmine.createSpyObj( "context", - [ "getRoot" ] + ["getRoot"] ); mockObjectService = jasmine.createSpyObj( "objectService", @@ -75,18 +73,18 @@ define( controller = new LocatorController(mockScope, mockTimeout, mockObjectService); }); - describe("when context is available", function () { + describe("when context is available", function () { - beforeEach(function () { + beforeEach(function () { mockContext.getRoot.andReturn(mockRootObject); controller = new LocatorController(mockScope, mockTimeout, mockObjectService); }); - it("adds a treeModel to scope", function () { + it("adds a treeModel to scope", function () { expect(mockScope.treeModel).toBeDefined(); }); - it("watches for changes to treeModel", function () { + it("watches for changes to treeModel", function () { // This is what the embedded tree representation // will be modifying. expect(mockScope.$watch).toHaveBeenCalledWith( @@ -95,7 +93,7 @@ define( ); }); - it("changes its own model on embedded model updates", function () { + it("changes its own model on embedded model updates", function () { // Need to pass on selection changes as updates to // the control's value mockScope.$watch.mostRecentCall.args[1](mockDomainObject); @@ -109,7 +107,7 @@ define( .toHaveBeenCalledWith("context"); }); - it("rejects changes which fail validation", function () { + it("rejects changes which fail validation", function () { mockScope.structure = { validate: jasmine.createSpy('validate') }; mockScope.structure.validate.andReturn(false); @@ -122,10 +120,10 @@ define( expect(mockScope.ngModel.someField).not.toEqual(mockDomainObject); }); - it("treats a lack of a selection as invalid", function () { + it("treats a lack of a selection as invalid", function () { mockScope.ngModelController = jasmine.createSpyObj( 'ngModelController', - [ '$setValidity' ] + ['$setValidity'] ); mockScope.$watch.mostRecentCall.args[1](mockDomainObject); @@ -138,14 +136,14 @@ define( expect(mockScope.ngModelController.$setValidity) .toHaveBeenCalledWith(jasmine.any(String), false); }); - }); - describe("when no context is available", function () { + }); + describe("when no context is available", function () { var defaultRoot = "DEFAULT_ROOT"; beforeEach(function () { mockContext.getRoot.andReturn(undefined); - getObjectsPromise.then.andCallFake(function(callback){ - callback({'ROOT':defaultRoot}); + getObjectsPromise.then.andCallFake(function (callback) { + callback({'ROOT': defaultRoot}); }); controller = new LocatorController(mockScope, mockTimeout, mockObjectService); }); diff --git a/platform/commonUI/browse/test/navigation/NavigateActionSpec.js b/platform/commonUI/browse/test/navigation/NavigateActionSpec.js index 2441087a1a..d872022049 100644 --- a/platform/commonUI/browse/test/navigation/NavigateActionSpec.js +++ b/platform/commonUI/browse/test/navigation/NavigateActionSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,12 +26,10 @@ define( ["../../src/navigation/NavigateAction"], function (NavigateAction) { - "use strict"; describe("The navigate action", function () { var mockNavigationService, mockQ, - actionContext, mockDomainObject, action; @@ -47,12 +44,12 @@ define( beforeEach(function () { mockNavigationService = jasmine.createSpyObj( "navigationService", - [ "setNavigation" ] + ["setNavigation"] ); mockQ = { when: mockPromise }; mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); action = new NavigateAction( @@ -77,4 +74,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/navigation/NavigationServiceSpec.js b/platform/commonUI/browse/test/navigation/NavigationServiceSpec.js index 410a5f1562..12b849a314 100644 --- a/platform/commonUI/browse/test/navigation/NavigationServiceSpec.js +++ b/platform/commonUI/browse/test/navigation/NavigationServiceSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/navigation/NavigationService"], function (NavigationService) { - "use strict"; describe("The navigation service", function () { var navigationService; diff --git a/platform/commonUI/browse/test/windowing/FullscreenActionSpec.js b/platform/commonUI/browse/test/windowing/FullscreenActionSpec.js index 4ef3f50a7f..3b9710184c 100644 --- a/platform/commonUI/browse/test/windowing/FullscreenActionSpec.js +++ b/platform/commonUI/browse/test/windowing/FullscreenActionSpec.js @@ -19,33 +19,30 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,afterEach,window*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. */ define( - ["../../src/windowing/FullscreenAction"], - function (FullscreenAction) { - "use strict"; + ["../../src/windowing/FullscreenAction", "screenfull"], + function (FullscreenAction, screenfull) { describe("The fullscreen action", function () { var action, - oldScreenfull; + oldToggle; beforeEach(function () { // Screenfull is not shimmed or injected, so // we need to spy on it in the global scope. - oldScreenfull = window.screenfull; + oldToggle = screenfull.toggle; - window.screenfull = {}; - window.screenfull.toggle = jasmine.createSpy("toggle"); + screenfull.toggle = jasmine.createSpy("toggle"); action = new FullscreenAction({}); }); afterEach(function () { - window.screenfull = oldScreenfull; + screenfull.toggle = oldToggle; }); it("toggles fullscreen mode when performed", function () { @@ -59,4 +56,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/windowing/NewTabActionSpec.js b/platform/commonUI/browse/test/windowing/NewTabActionSpec.js index 1371f96eda..fa820d3fcd 100644 --- a/platform/commonUI/browse/test/windowing/NewTabActionSpec.js +++ b/platform/commonUI/browse/test/windowing/NewTabActionSpec.js @@ -19,18 +19,15 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,afterEach,window*/ define( ["../../src/windowing/NewTabAction"], function (NewTabAction) { - "use strict"; - + describe("The new tab action", function () { var actionSelected, actionCurrent, mockWindow, - mockDomainObject, mockContextCurrent, mockContextSelected, mockUrlService; @@ -40,39 +37,39 @@ define( // Context if the current object is selected // For example, when the top right new tab - // button is clicked, the user is using the + // button is clicked, the user is using the // current domainObject mockContextCurrent = jasmine.createSpyObj("context", ["domainObject"]); - + // Context if the selected object is selected // For example, when an object in the left // tree is opened in a new tab using the // context menu mockContextSelected = jasmine.createSpyObj("context", ["selectedObject", "domainObject"]); - + // Mocks the urlService used to make the new tab's url from a // domainObject and mode mockUrlService = jasmine.createSpyObj("urlService", ["urlForNewTab"]); - + // Action done using the current context or mockContextCurrent actionCurrent = new NewTabAction(mockUrlService, mockWindow, mockContextCurrent); - + // Action done using the selected context or mockContextSelected actionSelected = new NewTabAction(mockUrlService, mockWindow, mockContextSelected); - + }); - + it("new tab with current url is opened", function () { actionCurrent.perform(); }); - + it("new tab with a selected url is opened", function () { actionSelected.perform(); }); - + }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js b/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js index d9c71a86dd..095fa9923e 100644 --- a/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js +++ b/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * WindowTitlerSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/windowing/WindowTitler"], function (WindowTitler) { - "use strict"; describe("The window titler", function () { var mockNavigationService, @@ -39,11 +37,11 @@ define( beforeEach(function () { mockNavigationService = jasmine.createSpyObj( 'navigationService', - [ 'getNavigation' ] + ['getNavigation'] ); mockRootScope = jasmine.createSpyObj( '$rootScope', - [ '$watch' ] + ['$watch'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', @@ -77,4 +75,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/dialog/bundle.js b/platform/commonUI/dialog/bundle.js index 3d99408478..ef1384c3d4 100644 --- a/platform/commonUI/dialog/bundle.js +++ b/platform/commonUI/dialog/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/DialogService", @@ -44,7 +43,6 @@ define([ overlayTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/dialog", { "extensions": { diff --git a/platform/commonUI/dialog/src/DialogService.js b/platform/commonUI/dialog/src/DialogService.js index 0d480f3455..778a172147 100644 --- a/platform/commonUI/dialog/src/DialogService.js +++ b/platform/commonUI/dialog/src/DialogService.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle implements the dialog service, which can be used to @@ -29,7 +28,6 @@ define( [], function () { - "use strict"; /** * The dialog service is responsible for handling window-modal * communication with the user, such as displaying forms for user @@ -157,8 +155,8 @@ define( * @returns {boolean} true if dialog is currently visible, false * otherwise */ - DialogService.prototype.canShowDialog = function(dialogModel){ - if (this.dialogVisible){ + DialogService.prototype.canShowDialog = function (dialogModel) { + if (this.dialogVisible) { // Only one dialog should be shown at a time. // The application design should be such that // we never even try to do this. @@ -226,7 +224,7 @@ define( * @param {typeClass} string tells overlayService that this overlay should use appropriate CSS class * @returns {boolean} */ - DialogService.prototype.showBlockingMessage = function(dialogModel) { + DialogService.prototype.showBlockingMessage = function (dialogModel) { if (this.canShowDialog(dialogModel)) { // Add the overlay using the OverlayService, which // will handle actual insertion into the DOM diff --git a/platform/commonUI/dialog/src/OverlayService.js b/platform/commonUI/dialog/src/OverlayService.js index 5e9703cb42..084342603f 100644 --- a/platform/commonUI/dialog/src/OverlayService.js +++ b/platform/commonUI/dialog/src/OverlayService.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; // Template to inject into the DOM to show the dialog; really just points to // the a specific template that can be included via mct-include diff --git a/platform/commonUI/dialog/test/DialogServiceSpec.js b/platform/commonUI/dialog/test/DialogServiceSpec.js index 2dc109ac44..2d801eb028 100644 --- a/platform/commonUI/dialog/test/DialogServiceSpec.js +++ b/platform/commonUI/dialog/test/DialogServiceSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTIncudeSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/DialogService"], function (DialogService) { - "use strict"; describe("The dialog service", function () { var mockOverlayService, @@ -40,23 +38,23 @@ define( beforeEach(function () { mockOverlayService = jasmine.createSpyObj( "overlayService", - [ "createOverlay" ] + ["createOverlay"] ); mockQ = jasmine.createSpyObj( "$q", - [ "defer" ] + ["defer"] ); mockLog = jasmine.createSpyObj( "$log", - [ "warn", "info", "debug" ] + ["warn", "info", "debug"] ); mockOverlay = jasmine.createSpyObj( "overlay", - [ "dismiss" ] + ["dismiss"] ); mockDeferred = jasmine.createSpyObj( "deferred", - [ "resolve", "reject"] + ["resolve", "reject"] ); mockDeferred.promise = "mock promise"; @@ -122,7 +120,7 @@ define( }); it("invokes the overlay service with the correct parameters when" + - " a blocking dialog is requested", function() { + " a blocking dialog is requested", function () { var dialogModel = {}; expect(dialogService.showBlockingMessage(dialogModel)).toBe(true); expect(mockOverlayService.createOverlay).toHaveBeenCalledWith( diff --git a/platform/commonUI/dialog/test/OverlayServiceSpec.js b/platform/commonUI/dialog/test/OverlayServiceSpec.js index cdeffb9f24..7756cdf2c6 100644 --- a/platform/commonUI/dialog/test/OverlayServiceSpec.js +++ b/platform/commonUI/dialog/test/OverlayServiceSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTIncudeSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/OverlayService"], function (OverlayService) { - "use strict"; describe("The overlay service", function () { var mockDocument, @@ -40,13 +38,13 @@ define( overlayService; beforeEach(function () { - mockDocument = jasmine.createSpyObj("$document", [ "find" ]); + mockDocument = jasmine.createSpyObj("$document", ["find"]); mockCompile = jasmine.createSpy("$compile"); - mockRootScope = jasmine.createSpyObj("$rootScope", [ "$new" ]); - mockBody = jasmine.createSpyObj("body", [ "prepend" ]); + mockRootScope = jasmine.createSpyObj("$rootScope", ["$new"]); + mockBody = jasmine.createSpyObj("body", ["prepend"]); mockTemplate = jasmine.createSpy("template"); - mockElement = jasmine.createSpyObj("element", [ "remove" ]); - mockScope = jasmine.createSpyObj("scope", [ "$destroy" ]); + mockElement = jasmine.createSpyObj("element", ["remove"]); + mockScope = jasmine.createSpyObj("scope", ["$destroy"]); mockDocument.find.andReturn(mockBody); mockCompile.andReturn(mockTemplate); @@ -98,4 +96,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/bundle.js b/platform/commonUI/edit/bundle.js index f2e684a69f..527c6b60a1 100644 --- a/platform/commonUI/edit/bundle.js +++ b/platform/commonUI/edit/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/controllers/EditActionController", @@ -27,7 +26,7 @@ define([ "./src/controllers/ElementsController", "./src/controllers/EditObjectController", "./src/directives/MCTBeforeUnload", - "./src/actions/LinkAction", + "./src/actions/EditAndComposeAction", "./src/actions/EditAction", "./src/actions/PropertiesAction", "./src/actions/RemoveAction", @@ -41,6 +40,9 @@ define([ "./src/policies/EditContextualActionPolicy", "./src/representers/EditRepresenter", "./src/representers/EditToolbarRepresenter", + "./src/capabilities/EditorCapability", + "./src/capabilities/TransactionCapabilityDecorator", + "./src/services/TransactionService", "text!./res/templates/library.html", "text!./res/templates/edit-object.html", "text!./res/templates/edit-action-buttons.html", @@ -53,7 +55,7 @@ define([ ElementsController, EditObjectController, MCTBeforeUnload, - LinkAction, + EditAndComposeAction, EditAction, PropertiesAction, RemoveAction, @@ -67,6 +69,9 @@ define([ EditContextualActionPolicy, EditRepresenter, EditToolbarRepresenter, + EditorCapability, + TransactionCapabilityDecorator, + TransactionService, libraryTemplate, editObjectTemplate, editActionButtonsTemplate, @@ -74,7 +79,6 @@ define([ topbarEditTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/edit", { "extensions": { @@ -122,7 +126,7 @@ define([ "actions": [ { "key": "compose", - "implementation": LinkAction + "implementation": EditAndComposeAction }, { "key": "edit", @@ -130,8 +134,7 @@ define([ "depends": [ "$location", "navigationService", - "$log", - "$q" + "$log" ], "description": "Edit this object.", "category": "view-control", @@ -193,10 +196,7 @@ define([ "implementation": CancelAction, "name": "Cancel", "description": "Discard changes made to these objects.", - "depends": [ - "$injector", - "navigationService" - ] + "depends": [] } ], "policies": [ @@ -207,7 +207,7 @@ define([ { "category": "action", "implementation": EditContextualActionPolicy, - "depends": ["navigationService"] + "depends": ["navigationService", "editModeBlacklist", "nonEditContextBlacklist"] }, { "category": "action", @@ -263,6 +263,27 @@ define([ "template": topbarEditTemplate } ], + "components": [ + { + "type": "decorator", + "provides": "capabilityService", + "implementation": TransactionCapabilityDecorator, + "depends": [ + "$q", + "transactionService" + ], + "priority": "fallback" + }, + { + "type": "provider", + "provides": "transactionService", + "implementation": TransactionService, + "depends": [ + "$q", + "$log" + ] + } + ], "representers": [ { "implementation": EditRepresenter, @@ -274,6 +295,27 @@ define([ { "implementation": EditToolbarRepresenter } + ], + "constants": [ + { + "key": "editModeBlacklist", + "value": ["copy", "follow", "window", "link", "locate"] + }, + { + "key": "nonEditContextBlacklist", + "value": ["copy", "follow", "properties", "move", "link", "remove", "locate"] + } + ], + "capabilities": [ + { + "key": "editor", + "name": "Editor Capability", + "description": "Provides transactional editing capabilities", + "implementation": EditorCapability, + "depends": [ + "transactionService" + ] + } ] } }); diff --git a/platform/commonUI/edit/res/templates/elements.html b/platform/commonUI/edit/res/templates/elements.html index 23884e0a54..12d83a47fc 100644 --- a/platform/commonUI/edit/res/templates/elements.html +++ b/platform/commonUI/edit/res/templates/elements.html @@ -26,7 +26,7 @@
    -
  • +
  • 0; }; return EditorCapability; diff --git a/platform/commonUI/edit/src/capabilities/TransactionCapabilityDecorator.js b/platform/commonUI/edit/src/capabilities/TransactionCapabilityDecorator.js new file mode 100644 index 0000000000..c3a405f099 --- /dev/null +++ b/platform/commonUI/edit/src/capabilities/TransactionCapabilityDecorator.js @@ -0,0 +1,73 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define*/ + +define( + ['./TransactionalPersistenceCapability'], + function (TransactionalPersistenceCapability) { + + /** + * Wraps the [PersistenceCapability]{@link PersistenceCapability} with + * transactional capabilities. + * @param $q + * @param transactionService + * @param capabilityService + * @see TransactionalPersistenceCapability + * @constructor + */ + function TransactionCapabilityDecorator( + $q, + transactionService, + capabilityService + ) { + this.capabilityService = capabilityService; + this.transactionService = transactionService; + this.$q = $q; + } + + /** + * Decorate PersistenceCapability to queue persistence calls when a + * transaction is in progress. + */ + TransactionCapabilityDecorator.prototype.getCapabilities = function (model) { + var self = this, + capabilities = this.capabilityService.getCapabilities(model), + persistenceCapability = capabilities.persistence; + + capabilities.persistence = function (domainObject) { + var original = + (typeof persistenceCapability === 'function') ? + persistenceCapability(domainObject) : + persistenceCapability; + return new TransactionalPersistenceCapability( + self.$q, + self.transactionService, + original, + domainObject + ); + }; + return capabilities; + }; + + return TransactionCapabilityDecorator; + } +); diff --git a/platform/commonUI/edit/src/capabilities/TransactionalPersistenceCapability.js b/platform/commonUI/edit/src/capabilities/TransactionalPersistenceCapability.js new file mode 100644 index 0000000000..ffa6097125 --- /dev/null +++ b/platform/commonUI/edit/src/capabilities/TransactionalPersistenceCapability.js @@ -0,0 +1,98 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define*/ + +define( + [], + function () { + + /** + * Wraps persistence capability to enable transactions. Transactions + * will cause persist calls not to be invoked immediately, but + * rather queued until [EditorCapability.save()]{@link EditorCapability#save} + * or [EditorCapability.cancel()]{@link EditorCapability#cancel} are + * called. + * @memberof platform/commonUI/edit/capabilities + * @param $q + * @param transactionService + * @param persistenceCapability + * @param domainObject + * @constructor + */ + function TransactionalPersistenceCapability( + $q, + transactionService, + persistenceCapability, + domainObject + ) { + this.transactionService = transactionService; + this.persistenceCapability = persistenceCapability; + this.domainObject = domainObject; + this.$q = $q; + this.persistPending = false; + } + + /** + * The wrapped persist function. If a transaction is active, persist + * will be queued until the transaction is committed or cancelled. + * @returns {*} + */ + TransactionalPersistenceCapability.prototype.persist = function () { + var self = this; + + function onCommit() { + return self.persistenceCapability.persist().then(function (result) { + self.persistPending = false; + return result; + }); + } + + function onCancel() { + return self.persistenceCapability.refresh().then(function (result) { + self.persistPending = false; + return result; + }); + } + + if (this.transactionService.isActive()) { + if (!this.persistPending) { + this.transactionService.addToTransaction(onCommit, onCancel); + this.persistPending = true; + } + //Need to return a promise from this function + return this.$q.when(true); + } else { + return this.persistenceCapability.persist(); + } + }; + + TransactionalPersistenceCapability.prototype.refresh = function () { + return this.persistenceCapability.refresh(); + }; + + TransactionalPersistenceCapability.prototype.getSpace = function () { + return this.persistenceCapability.getSpace(); + }; + + return TransactionalPersistenceCapability; + } +); diff --git a/platform/commonUI/edit/src/controllers/EditActionController.js b/platform/commonUI/edit/src/controllers/EditActionController.js index 4ea38f9bb5..85a0550182 100644 --- a/platform/commonUI/edit/src/controllers/EditActionController.js +++ b/platform/commonUI/edit/src/controllers/EditActionController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining EditActionController. Created by vwoeltje on 11/17/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; var ACTION_CONTEXT = { category: 'conclude-editing' }; diff --git a/platform/commonUI/edit/src/controllers/EditObjectController.js b/platform/commonUI/edit/src/controllers/EditObjectController.js index d6121106ec..b398398f63 100644 --- a/platform/commonUI/edit/src/controllers/EditObjectController.js +++ b/platform/commonUI/edit/src/controllers/EditObjectController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * This bundle implements Edit mode. @@ -28,7 +27,6 @@ define( [], function () { - "use strict"; /** * Controller which is responsible for populating the scope for @@ -61,7 +59,7 @@ define( $scope.$watch('domainObject', setViewForDomainObject); - $scope.doAction = function (action){ + $scope.doAction = function (action) { return $scope[action] && $scope[action](); }; } @@ -76,8 +74,8 @@ define( var navigatedObject = this.scope.domainObject, policyMessage; - this.policyService.allow("navigation", navigatedObject, undefined, function(message) { - policyMessage = message; + this.policyService.allow("navigation", navigatedObject, undefined, function (message) { + policyMessage = message; }); return policyMessage; diff --git a/platform/commonUI/edit/src/controllers/EditPanesController.js b/platform/commonUI/edit/src/controllers/EditPanesController.js index 7dedc251ec..83562c6ffc 100644 --- a/platform/commonUI/edit/src/controllers/EditPanesController.js +++ b/platform/commonUI/edit/src/controllers/EditPanesController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Supports the Library and Elements panes in Edit mode. diff --git a/platform/commonUI/edit/src/controllers/ElementsController.js b/platform/commonUI/edit/src/controllers/ElementsController.js index c62e999fa2..6d1f552081 100644 --- a/platform/commonUI/edit/src/controllers/ElementsController.js +++ b/platform/commonUI/edit/src/controllers/ElementsController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( [], function () { - "use strict"; /** * The ElementsController prepares the elements view for display @@ -32,16 +30,27 @@ define( * @constructor */ function ElementsController($scope) { - function filterBy(text){ + function filterBy(text) { if (typeof text === 'undefined') { return $scope.searchText; } else { $scope.searchText = text; } } + + function searchElements(value) { + if ($scope.searchText) { + return value.getModel().name.toLowerCase().search( + $scope.searchText.toLowerCase()) !== -1; + } else { + return true; + } + } + $scope.filterBy = filterBy; + $scope.searchElements = searchElements; } return ElementsController; } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/src/directives/MCTBeforeUnload.js b/platform/commonUI/edit/src/directives/MCTBeforeUnload.js index 3e7501c788..a5dfc852ed 100644 --- a/platform/commonUI/edit/src/directives/MCTBeforeUnload.js +++ b/platform/commonUI/edit/src/directives/MCTBeforeUnload.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Defines the `mct-before-unload` directive. The expression bound diff --git a/platform/commonUI/edit/src/objects/EditableDomainObject.js b/platform/commonUI/edit/src/objects/EditableDomainObject.js deleted file mode 100644 index 253947181d..0000000000 --- a/platform/commonUI/edit/src/objects/EditableDomainObject.js +++ /dev/null @@ -1,132 +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. - *****************************************************************************/ -/*global define*/ - -/** - * Defines EditableDomainObject, which wraps domain objects - * such that user code may work with and mutate a copy of the - * domain object model; these changes may then be propagated - * up to the real domain object (or not) by way of invoking - * save or cancel behaviors of the "editor.completion" - * capability (a capability intended as internal to edit - * mode; invoked by way of the Save and Cancel actions.) - */ -define( - [ - '../capabilities/EditablePersistenceCapability', - '../capabilities/EditableContextCapability', - '../capabilities/EditableCompositionCapability', - '../capabilities/EditableRelationshipCapability', - '../capabilities/EditableInstantiationCapability', - '../capabilities/EditorCapability', - '../capabilities/EditableActionCapability', - './EditableDomainObjectCache' - ], - function ( - EditablePersistenceCapability, - EditableContextCapability, - EditableCompositionCapability, - EditableRelationshipCapability, - EditableInstantiationCapability, - EditorCapability, - EditableActionCapability, - EditableDomainObjectCache - ) { - "use strict"; - - var capabilityFactories = { - persistence: EditablePersistenceCapability, - context: EditableContextCapability, - composition: EditableCompositionCapability, - relationship: EditableRelationshipCapability, - instantiation: EditableInstantiationCapability, - editor: EditorCapability - }; - - // Handle special case where "editor.completion" wraps persistence - // (other capability overrides wrap capabilities of the same type.) - function getDelegateArguments(name, args) { - return name === "editor" ? ['persistence'] : args; - } - - /** - * An EditableDomainObject overrides capabilities - * which need to behave differently in edit mode, - * and provides a "working copy" of the object's - * model to allow changes to be easily cancelled. - * @constructor - * @memberof platform/commonUI/edit - * @implements {DomainObject} - */ - function EditableDomainObject(domainObject, $q) { - // The cache will hold all domain objects reached from - // the initial EditableDomainObject; this ensures that - // different versions of the same editable domain object - // are not shown in different sections of the same Edit - // UI, which might thereby fall out of sync. - var cache, - originalObject = domainObject, - cachedObject; - - // Constructor for EditableDomainObject, which adheres - // to the same shared cache. - function EditableDomainObjectImpl(domainObject, model) { - var editableObject = Object.create(domainObject); - - // Only provide the cloned model. - editableObject.getModel = function () { return model; }; - - // Override certain capabilities - editableObject.getCapability = function (name) { - var delegateArguments = getDelegateArguments(name, arguments), - capability = domainObject.getCapability.apply( - this, - delegateArguments - ), - Factory = capabilityFactories[name]; - - return (Factory && capability) ? - new Factory(capability, editableObject, domainObject, cache) : - capability; - }; - - - editableObject.setOriginalObject = function(object) { - originalObject = object; - }; - - editableObject.getOriginalObject = function() { - return originalObject; - }; - - return editableObject; - } - - cache = new EditableDomainObjectCache(EditableDomainObjectImpl, $q); - cachedObject = cache.getEditableObject(domainObject); - - return cachedObject; - } - - return EditableDomainObject; - } -); diff --git a/platform/commonUI/edit/src/objects/EditableDomainObjectCache.js b/platform/commonUI/edit/src/objects/EditableDomainObjectCache.js deleted file mode 100644 index 32a11604de..0000000000 --- a/platform/commonUI/edit/src/objects/EditableDomainObjectCache.js +++ /dev/null @@ -1,173 +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. - *****************************************************************************/ -/*global define*/ - - -/* - * An editable domain object cache stores domain objects that have been - * made editable, in a group that can be saved all-at-once. This supports - * Edit mode, which is launched for a specific object but may contain - * changes across many objects. - * - * Editable domain objects have certain specific capabilities overridden - * to ensure that changes made while in edit mode do not propagate up - * to the objects used in browse mode (or to persistence) until the user - * initiates a Save. - */ -define( - ["./EditableModelCache"], - function (EditableModelCache) { - 'use strict'; - - /** - * Construct a new cache for editable domain objects. This can be used - * to get-or-create editable objects, particularly to support wrapping - * of objects retrieved via composition or context capabilities as - * editable domain objects. - * - * @param {Constructor} EditableDomainObject a - * constructor function which takes a regular domain object as - * an argument, and returns an editable domain object as its - * result. - * @param $q Angular's $q, for promise handling - * @memberof platform/commonUI/edit - * @constructor - */ - function EditableDomainObjectCache(EditableDomainObject, $q) { - this.cache = new EditableModelCache(); - this.dirtyObjects = {}; - this.root = undefined; - this.$q = $q; - this.EditableDomainObject = EditableDomainObject; - } - - /** - * Wrap this domain object in an editable form, or pull such - * an object from the cache if one already exists. - * - * @param {DomainObject} domainObject the regular domain object - * @returns {DomainObject} the domain object in an editable form - */ - EditableDomainObjectCache.prototype.getEditableObject = function (domainObject) { - var type = domainObject.getCapability('type'), - EditableDomainObject = this.EditableDomainObject, - editableObject, - statusListener; - - // Track the top-level domain object; this will have - // some special behavior for its context capability. - this.root = this.root || domainObject; - - // Avoid double-wrapping (WTD-1017) - if (domainObject.hasCapability('editor')) { - return domainObject; - } - - // Don't bother wrapping non-editable objects - if (!type || !type.hasFeature('creation')) { - return domainObject; - } - - // Provide an editable form of the object - editableObject = new EditableDomainObject( - domainObject, - this.cache.getCachedModel(domainObject) - ); - - return editableObject; - }; - - /** - * Check if a domain object is (effectively) the top-level - * object in this editable subgraph. - * @returns {boolean} true if it is the root - */ - EditableDomainObjectCache.prototype.isRoot = function (domainObject) { - return domainObject === this.root; - }; - - /** - * Mark an editable domain object (presumably already cached) - * as having received modifications during editing; it should be - * included in the bulk save invoked when editing completes. - * - * @param {DomainObject} domainObject the domain object - * @memberof platform/commonUI/edit.EditableDomainObjectCache# - */ - EditableDomainObjectCache.prototype.markDirty = function (domainObject) { - this.dirtyObjects[domainObject.getId()] = domainObject; - return this.$q.when(true); - }; - - /** - * Mark an object (presumably already cached) as having had its - * changes saved (and thus no longer needing to be subject to a - * save operation.) - * - * @param {DomainObject} domainObject the domain object - */ - EditableDomainObjectCache.prototype.markClean = function (domainObject) { - var self = this; - if (!domainObject) { - Object.keys(this.dirtyObjects).forEach(function(key) { - delete self.dirtyObjects[key]; - }); - } else { - delete this.dirtyObjects[domainObject.getId()]; - } - }; - - /** - * Initiate a save on all objects that have been cached. - * @return {Promise} A promise which will resolve when all objects are - * persisted. - */ - EditableDomainObjectCache.prototype.saveAll = function () { - // Get a list of all dirty objects - var dirty = this.dirtyObjects, - objects = Object.keys(dirty).map(function (k) { - return dirty[k]; - }); - - // Clear dirty set, since we're about to save. - this.dirtyObjects = {}; - - // Most save logic is handled by the "editor.completion" - // capability, so that is delegated here. - return this.$q.all(objects.map(function (object) { - // Save; pass a nonrecursive flag to avoid looping - return object.getCapability('editor').save(true); - })); - }; - - /** - * Check if any objects have been marked dirty in this cache. - * @returns {boolean} true if objects are dirty - */ - EditableDomainObjectCache.prototype.dirty = function () { - return Object.keys(this.dirtyObjects).length > 0; - }; - - return EditableDomainObjectCache; - } -); - diff --git a/platform/commonUI/edit/src/objects/EditableModelCache.js b/platform/commonUI/edit/src/objects/EditableModelCache.js deleted file mode 100644 index 30ca3d774a..0000000000 --- a/platform/commonUI/edit/src/objects/EditableModelCache.js +++ /dev/null @@ -1,62 +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. - *****************************************************************************/ -/*global define*/ - -define( - [], - function () { - "use strict"; - - /** - * An editable model cache stores domain object models that have been - * made editable, to support a group that can be saved all-at-once. - * This is useful in Edit mode, which is launched for a specific - * object but may contain changes across many objects. - * @memberof platform/commonUI/edit - * @constructor - */ - function EditableModelCache() { - this.cache = {}; - } - - // Deep-copy a model. Models are JSONifiable, so this can be - // done by stringification then destringification - function clone(model) { - return JSON.parse(JSON.stringify(model)); - } - - /** - * Get this domain object's model from the cache (or - * place it in the cache if it isn't in the cache yet) - * @returns a clone of the domain object's model - */ - EditableModelCache.prototype.getCachedModel = function (domainObject) { - var id = domainObject.getId(), - cache = this.cache; - - return (cache[id] = - cache[id] || clone(domainObject.getModel())); - }; - - return EditableModelCache; - } -); diff --git a/platform/commonUI/edit/src/policies/EditActionPolicy.js b/platform/commonUI/edit/src/policies/EditActionPolicy.js index 502577ade9..f0c2910c11 100644 --- a/platform/commonUI/edit/src/policies/EditActionPolicy.js +++ b/platform/commonUI/edit/src/policies/EditActionPolicy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Policy controlling when the `edit` and/or `properties` actions @@ -47,7 +45,7 @@ define( count = 0, type, views; - if (!domainObject){ + if (!domainObject) { return count; } @@ -74,26 +72,23 @@ define( */ function isEditing(context) { var domainObject = (context || {}).domainObject; - return domainObject - && domainObject.hasCapability('status') - && domainObject.getCapability('status').get('editing'); + return domainObject && + domainObject.hasCapability('editor') && + domainObject.getCapability('editor').isEditContextRoot(); } EditActionPolicy.prototype.allow = function (action, context) { var key = action.getMetadata().key, category = (context || {}).category; - // Only worry about actions in the view-control category - if (category === 'view-control') { - // Restrict 'edit' to cases where there are editable - // views (similarly, restrict 'properties' to when - // the converse is true), and where the domain object is not - // already being edited. - if (key === 'edit') { - return this.countEditableViews(context) > 0 && !isEditing(context); - } else if (key === 'properties') { - return this.countEditableViews(context) < 1 && !isEditing(context); - } + // Restrict 'edit' to cases where there are editable + // views (similarly, restrict 'properties' to when + // the converse is true), and where the domain object is not + // already being edited. + if (key === 'edit') { + return this.countEditableViews(context) > 0 && !isEditing(context); + } else if (key === 'properties' && category === 'view-control') { + return this.countEditableViews(context) < 1 && !isEditing(context); } // Like all policies, allow by default. diff --git a/platform/commonUI/edit/src/policies/EditContextualActionPolicy.js b/platform/commonUI/edit/src/policies/EditContextualActionPolicy.js index 06fe9de640..53fd7f6395 100644 --- a/platform/commonUI/edit/src/policies/EditContextualActionPolicy.js +++ b/platform/commonUI/edit/src/policies/EditContextualActionPolicy.js @@ -19,27 +19,35 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Policy controlling whether the context menu is visible when * objects are being edited - * @memberof platform/commonUI/edit + * @param navigationService + * @param editModeBlacklist A blacklist of actions disallowed from + * context menu when navigated object is being edited + * @param nonEditContextBlacklist A blacklist of actions disallowed + * from context menu of non-editable objects, when navigated object + * is being edited * @constructor + * @param editModeBlacklist A blacklist of actions disallowed from + * context menu when navigated object is being edited + * @param nonEditContextBlacklist A blacklist of actions disallowed + * from context menu of non-editable objects, when navigated object * @implements {Policy.} */ - function EditContextualActionPolicy(navigationService) { + function EditContextualActionPolicy(navigationService, editModeBlacklist, nonEditContextBlacklist) { this.navigationService = navigationService; + //The list of objects disallowed on target object when in edit mode - this.editBlacklist = ["copy", "follow", "window"]; + this.editModeBlacklist = editModeBlacklist; //The list of objects disallowed on target object that is not in // edit mode (ie. the context menu in the tree on the LHS). - this.nonEditBlacklist = ["copy", "follow", "properties", "move", "link", "remove"]; + this.nonEditContextBlacklist = nonEditContextBlacklist; } EditContextualActionPolicy.prototype.allow = function (action, context) { @@ -47,12 +55,12 @@ define( navigatedObject = this.navigationService.getNavigation(), actionMetadata = action.getMetadata ? action.getMetadata() : {}; - if (navigatedObject.hasCapability('editor')) { - if (!selectedObject.hasCapability('editor')){ - //Target is in the context menu - return this.nonEditBlacklist.indexOf(actionMetadata.key) === -1; + if (navigatedObject.hasCapability("editor") && navigatedObject.getCapability("editor").isEditContextRoot()) { + if (selectedObject.hasCapability("editor") && selectedObject.getCapability("editor").inEditContext()) { + return this.editModeBlacklist.indexOf(actionMetadata.key) === -1; } else { - return this.editBlacklist.indexOf(actionMetadata.key) === -1; + //Target is in the context menu + return this.nonEditContextBlacklist.indexOf(actionMetadata.key) === -1; } } else { return true; diff --git a/platform/commonUI/edit/src/policies/EditNavigationPolicy.js b/platform/commonUI/edit/src/policies/EditNavigationPolicy.js index 882e64935e..b4b9855d4b 100644 --- a/platform/commonUI/edit/src/policies/EditNavigationPolicy.js +++ b/platform/commonUI/edit/src/policies/EditNavigationPolicy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Policy controlling whether navigation events should proceed @@ -40,15 +38,14 @@ define( /** * @private */ - EditNavigationPolicy.prototype.isDirty = function(domainObject) { + EditNavigationPolicy.prototype.isDirty = function (domainObject) { var navigatedObject = domainObject, editorCapability = navigatedObject && - navigatedObject.getCapability("editor"), - statusCapability = navigatedObject && - navigatedObject.getCapability("status"); + navigatedObject.getCapability("editor"); - return statusCapability && statusCapability.get('editing') - && editorCapability && editorCapability.dirty(); + return editorCapability && + editorCapability.isEditContextRoot() && + editorCapability.dirty(); }; /** diff --git a/platform/commonUI/edit/src/policies/EditableLinkPolicy.js b/platform/commonUI/edit/src/policies/EditableLinkPolicy.js index ad3043df2d..c6a2a36290 100644 --- a/platform/commonUI/edit/src/policies/EditableLinkPolicy.js +++ b/platform/commonUI/edit/src/policies/EditableLinkPolicy.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([], function () { - "use strict"; /** * Policy suppressing links when the linked-to domain object is in @@ -37,11 +35,12 @@ define([], function () { } EditableLinkPolicy.prototype.allow = function (action, context) { - var key = action.getMetadata().key; + var key = action.getMetadata().key, + object; if (key === 'link') { - return !((context.selectedObject || context.domainObject) - .hasCapability('editor')); + object = context.selectedObject || context.domainObject; + return !(object.hasCapability("editor") && object.getCapability("editor").inEditContext()); } // Like all policies, allow by default. diff --git a/platform/commonUI/edit/src/policies/EditableMovePolicy.js b/platform/commonUI/edit/src/policies/EditableMovePolicy.js index 37fe68263a..bb36c86746 100644 --- a/platform/commonUI/edit/src/policies/EditableMovePolicy.js +++ b/platform/commonUI/edit/src/policies/EditableMovePolicy.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([], function () { - "use strict"; /** * Policy suppressing move actions among editable and non-editable @@ -37,10 +35,13 @@ define([], function () { EditableMovePolicy.prototype.allow = function (action, context) { var domainObject = context.domainObject, selectedObject = context.selectedObject, - key = action.getMetadata().key; + key = action.getMetadata().key, + isDomainObjectEditing = domainObject.hasCapability('editor') && + domainObject.getCapability('editor').inEditContext(); - if (key === 'move' && domainObject.hasCapability('editor')) { - return !!selectedObject && selectedObject.hasCapability('editor'); + if (key === 'move' && isDomainObjectEditing) { + return !!selectedObject && selectedObject.hasCapability('editor') && + selectedObject.getCapability('editor').inEditContext(); } // Like all policies, allow by default. diff --git a/platform/commonUI/edit/src/policies/EditableViewPolicy.js b/platform/commonUI/edit/src/policies/EditableViewPolicy.js index 17194064b0..312bafff05 100644 --- a/platform/commonUI/edit/src/policies/EditableViewPolicy.js +++ b/platform/commonUI/edit/src/policies/EditableViewPolicy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Policy controlling which views should be visible in Edit mode. @@ -39,7 +37,7 @@ define( // If a view is flagged as non-editable, only allow it // while we're not in Edit mode. if ((view || {}).editable === false) { - return !domainObject.hasCapability('editor'); + return !(domainObject.hasCapability('editor') && domainObject.getCapability('editor').inEditContext()); } // Like all policies, allow by default. diff --git a/platform/commonUI/edit/src/representers/EditRepresenter.js b/platform/commonUI/edit/src/representers/EditRepresenter.js index 689bb183d0..ffe7f24d11 100644 --- a/platform/commonUI/edit/src/representers/EditRepresenter.js +++ b/platform/commonUI/edit/src/representers/EditRepresenter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The EditRepresenter is responsible for implementing @@ -93,14 +91,8 @@ define( } } - function setEditable(editableDomainObject) { - self.domainObject = editableDomainObject; - scope.model = editableDomainObject.getModel(); - } - // Place the "commit" method in the scope scope.commit = commit; - scope.setEditable = setEditable; // Clean up when the scope is destroyed scope.$on("$destroy", function () { @@ -111,8 +103,8 @@ define( // Handle a specific representation of a specific domain object EditRepresenter.prototype.represent = function represent(representation, representedObject) { - var scope = this.scope, - self = this; + var scope = this.scope; + // Track the key, to know which view configuration to save to. this.key = (representation || {}).key; // Track the represented object @@ -121,7 +113,7 @@ define( // Ensure existing watches are released this.destroy(); - function setEditing(){ + function setEditing() { scope.viewObjectTemplate = 'edit-object'; } @@ -130,15 +122,15 @@ define( * editable then change the view and inspector regions * object representation accordingly */ - this.listenHandle = this.domainObject.getCapability('status').listen(function(statuses){ - if (statuses.indexOf('editing')!=-1){ + this.listenHandle = this.domainObject.getCapability('status').listen(function (statuses) { + if (statuses.indexOf('editing') !== -1) { setEditing(); } else { delete scope.viewObjectTemplate; } }); - if (representedObject.getCapability('status').get('editing')){ + if (representedObject.hasCapability('editor') && representedObject.getCapability('editor').isEditContextRoot()) { setEditing(); } }; diff --git a/platform/commonUI/edit/src/representers/EditToolbar.js b/platform/commonUI/edit/src/representers/EditToolbar.js index 367eaf1705..5184d73086 100644 --- a/platform/commonUI/edit/src/representers/EditToolbar.js +++ b/platform/commonUI/edit/src/representers/EditToolbar.js @@ -19,15 +19,17 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; // Utility functions for reducing truth arrays - function and(a, b) { return a && b; } - function or(a, b) { return a || b; } + function and(a, b) { + return a && b; + } + function or(a, b) { + return a || b; + } /** @@ -221,7 +223,7 @@ define( // Update value for this property in all elements of the // selection which have this property. - function updateProperties(property, value) { + function updateProperties(property, val) { var changed = false; // Update property in a selected element @@ -231,12 +233,12 @@ define( // Check if this is a setter, or just assignable if (typeof selected[property] === 'function') { changed = - changed || (selected[property]() !== value); - selected[property](value); + changed || (selected[property]() !== val); + selected[property](val); } else { changed = - changed || (selected[property] !== value); - selected[property] = value; + changed || (selected[property] !== val); + selected[property] = val; } } } diff --git a/platform/commonUI/edit/src/representers/EditToolbarRepresenter.js b/platform/commonUI/edit/src/representers/EditToolbarRepresenter.js index daf3645b69..a4146f5965 100644 --- a/platform/commonUI/edit/src/representers/EditToolbarRepresenter.js +++ b/platform/commonUI/edit/src/representers/EditToolbarRepresenter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./EditToolbar', './EditToolbarSelection'], function (EditToolbar, EditToolbarSelection) { - "use strict"; // No operation var NOOP_REPRESENTER = { @@ -135,11 +133,11 @@ define( self = this; // Initialize toolbar (expose object to parent scope) - function initialize(definition) { + function initialize(def) { // If we have been asked to expose toolbar state... if (self.attrs.toolbar) { // Initialize toolbar object - self.toolbar = new EditToolbar(definition, self.commit); + self.toolbar = new EditToolbar(def, self.commit); // Ensure toolbar state is exposed self.exposeToolbar(); } diff --git a/platform/commonUI/edit/src/representers/EditToolbarSelection.js b/platform/commonUI/edit/src/representers/EditToolbarSelection.js index 318ae935b5..f6cdedeadd 100644 --- a/platform/commonUI/edit/src/representers/EditToolbarSelection.js +++ b/platform/commonUI/edit/src/representers/EditToolbarSelection.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Tracks selection state for editable views. Selection is diff --git a/platform/commonUI/edit/src/services/TransactionService.js b/platform/commonUI/edit/src/services/TransactionService.js new file mode 100644 index 0000000000..8d6c465959 --- /dev/null +++ b/platform/commonUI/edit/src/services/TransactionService.js @@ -0,0 +1,148 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define*/ +define( + [], + function () { + /** + * Implements an application-wide transaction state. Once a + * transaction is started, calls to + * [PersistenceCapability.persist()]{@link PersistenceCapability#persist} + * will be deferred until a subsequent call to + * [TransactionService.commit]{@link TransactionService#commit} is made. + * + * @memberof platform/commonUI/edit/services + * @param $q + * @constructor + */ + function TransactionService($q, $log) { + this.$q = $q; + this.$log = $log; + this.transaction = false; + + this.onCommits = []; + this.onCancels = []; + } + + /** + * Starts a transaction. While a transaction is active all calls to + * [PersistenceCapability.persist](@link PersistenceCapability#persist) + * will be queued until [commit]{@link #commit} or [cancel]{@link + * #cancel} are called + */ + TransactionService.prototype.startTransaction = function () { + if (this.transaction) { + //Log error because this is a programming error if it occurs. + this.$log.error("Transaction already in progress"); + } + this.transaction = true; + }; + + /** + * @returns {boolean} If true, indicates that a transaction is in progress + */ + TransactionService.prototype.isActive = function () { + return this.transaction; + }; + + /** + * Adds provided functions to a queue to be called on + * [.commit()]{@link #commit} or + * [.cancel()]{@link #commit} + * @param onCommit A function to call on commit + * @param onCancel A function to call on cancel + */ + TransactionService.prototype.addToTransaction = function (onCommit, onCancel) { + if (this.transaction) { + this.onCommits.push(onCommit); + if (onCancel) { + this.onCancels.push(onCancel); + } + } else { + //Log error because this is a programming error if it occurs. + this.$log.error("No transaction in progress"); + } + }; + + /** + * All persist calls deferred since the beginning of the transaction + * will be committed. + * + * @returns {Promise} resolved when all persist operations have + * completed. Will reject if any commit operations fail + */ + TransactionService.prototype.commit = function () { + var self = this, + promises = [], + onCommit; + + while (this.onCommits.length > 0) { // ...using a while in case some onCommit adds to transaction + onCommit = this.onCommits.pop(); + try { // ...also don't want to fail mid-loop... + promises.push(onCommit()); + } catch (e) { + this.$log.error("Error committing transaction."); + } + } + return this.$q.all(promises).then(function () { + self.transaction = false; + + self.onCommits = []; + self.onCancels = []; + }); + }; + + /** + * Cancel the current transaction, replacing any dirty objects from + * persistence. Not a true rollback, as it cannot be used to undo any + * persist calls that were successful in the event one of a batch of + * persists failing. + * + * @returns {*} + */ + TransactionService.prototype.cancel = function () { + var self = this, + results = [], + onCancel; + + while (this.onCancels.length > 0) { + onCancel = this.onCancels.pop(); + try { + results.push(onCancel()); + } catch (error) { + this.$log.error("Error committing transaction."); + } + } + return this.$q.all(results).then(function () { + self.transaction = false; + + self.onCommits = []; + self.onCancels = []; + }); + }; + + TransactionService.prototype.size = function () { + return this.onCommits.length; + }; + + return TransactionService; + }); diff --git a/platform/commonUI/edit/test/actions/CancelActionSpec.js b/platform/commonUI/edit/test/actions/CancelActionSpec.js index 4a06ad9649..411fdb1659 100644 --- a/platform/commonUI/edit/test/actions/CancelActionSpec.js +++ b/platform/commonUI/edit/test/actions/CancelActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit,xdescribe*/ define( ["../../src/actions/CancelAction"], function (CancelAction) { - "use strict"; //TODO: Disabled for NEM Beta xdescribe("The Cancel action", function () { @@ -46,15 +44,15 @@ define( beforeEach(function () { mockLocation = jasmine.createSpyObj( "$location", - [ "path" ] + ["path"] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getCapability", "hasCapability" ] + ["getCapability", "hasCapability"] ); mockEditorCapability = jasmine.createSpyObj( "editor", - [ "save", "cancel" ] + ["save", "cancel"] ); mockUrlService = jasmine.createSpyObj( "urlService", @@ -102,4 +100,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/actions/EditActionSpec.js b/platform/commonUI/edit/test/actions/EditActionSpec.js index 4858d9cf0a..fe6fcb1eae 100644 --- a/platform/commonUI/edit/test/actions/EditActionSpec.js +++ b/platform/commonUI/edit/test/actions/EditActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit,xdescribe*/ define( ["../../src/actions/EditAction"], function (EditAction) { - "use strict"; describe("The Edit action", function () { var mockLocation, @@ -32,32 +30,46 @@ define( mockLog, mockDomainObject, mockType, + mockEditor, actionContext, + capabilities, action; beforeEach(function () { mockLocation = jasmine.createSpyObj( "$location", - [ "path" ] + ["path"] ); mockNavigationService = jasmine.createSpyObj( "navigationService", - [ "setNavigation", "getNavigation" ] + ["setNavigation", "getNavigation", "addListener", "removeListener"] ); mockLog = jasmine.createSpyObj( "$log", - [ "error", "warn", "info", "debug" ] + ["error", "warn", "info", "debug"] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability", "hasCapability", "useCapability"] ); mockType = jasmine.createSpyObj( "type", - [ "hasFeature" ] + ["hasFeature"] + ); + mockEditor = jasmine.createSpyObj( + "editorCapability", + ["edit", "isEditContextRoot", "cancel"] ); - mockDomainObject.getCapability.andReturn(mockType); + capabilities = { + type: mockType, + editor: mockEditor + }; + + mockDomainObject.getCapability.andCallFake(function (name) { + return capabilities[name]; + }); + mockDomainObject.hasCapability.andReturn(true); mockType.hasFeature.andReturn(true); actionContext = { domainObject: mockDomainObject }; @@ -70,51 +82,34 @@ define( ); }); - it("is only applicable when a domain object is present", function () { + it("is only applicable when an editable domain object is present", function () { expect(EditAction.appliesTo(actionContext)).toBeTruthy(); expect(EditAction.appliesTo({})).toBeFalsy(); + + expect(mockDomainObject.hasCapability).toHaveBeenCalledWith('editor'); // Should have checked for creatability expect(mockType.hasFeature).toHaveBeenCalledWith('creation'); }); - //TODO: Disabled for NEM Beta - xit("changes URL path to edit mode when performed", function () { + it("is only applicable to objects not already in edit mode", function () { + mockEditor.isEditContextRoot.andReturn(false); + expect(EditAction.appliesTo(actionContext)).toBe(true); + mockEditor.isEditContextRoot.andReturn(true); + expect(EditAction.appliesTo(actionContext)).toBe(false); + }); + + it ("cancels editing when user navigates away", function () { action.perform(); - expect(mockLocation.path).toHaveBeenCalledWith("/edit"); + expect(mockNavigationService.addListener).toHaveBeenCalled(); + mockNavigationService.addListener.mostRecentCall.args[0](); + expect(mockEditor.cancel).toHaveBeenCalled(); }); - //TODO: Disabled for NEM Beta - xit("ensures that the edited object is navigated-to", function () { + it ("invokes the Edit capability on the object", function () { action.perform(); - expect(mockNavigationService.setNavigation) - .toHaveBeenCalledWith(mockDomainObject); + expect(mockDomainObject.useCapability).toHaveBeenCalledWith("editor"); }); - //TODO: Disabled for NEM Beta - xit("logs a warning if constructed when inapplicable", function () { - // Verify precondition (ensure warn wasn't called during setup) - expect(mockLog.warn).not.toHaveBeenCalled(); - - // Should not have hit an exception... - new EditAction( - mockLocation, - mockNavigationService, - mockLog, - {} - ).perform(); - - // ...but should have logged a warning - expect(mockLog.warn).toHaveBeenCalled(); - - // And should not have had other interactions - expect(mockLocation.path) - .not.toHaveBeenCalled(); - expect(mockNavigationService.setNavigation) - .not.toHaveBeenCalled(); - }); - - - }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/actions/LinkActionSpec.js b/platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js similarity index 70% rename from platform/commonUI/edit/test/actions/LinkActionSpec.js rename to platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js index 96ea30e2b3..fa1d21b1e8 100644 --- a/platform/commonUI/edit/test/actions/LinkActionSpec.js +++ b/platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,spyOn*/ define( - ["../../src/actions/LinkAction"], - function (LinkAction) { - "use strict"; + ["../../src/actions/EditAndComposeAction"], + function (EditAndComposeAction) { describe("The Link action", function () { var mockQ, @@ -33,6 +31,8 @@ define( mockContext, mockComposition, mockPersistence, + mockActionCapability, + mockEditAction, mockType, actionContext, model, @@ -52,7 +52,7 @@ define( mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability" ] + ["getId", "getCapability"] ); mockQ = { when: mockPromise }; mockParent = { @@ -66,25 +66,30 @@ define( return capabilities[k].invoke(v); } }; - mockContext = jasmine.createSpyObj("context", [ "getParent" ]); - mockComposition = jasmine.createSpyObj("composition", [ "invoke", "add" ]); - mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]); - mockType = jasmine.createSpyObj("type", [ "hasFeature" ]); + mockContext = jasmine.createSpyObj("context", ["getParent"]); + mockComposition = jasmine.createSpyObj("composition", ["invoke", "add"]); + mockPersistence = jasmine.createSpyObj("persistence", ["persist"]); + mockType = jasmine.createSpyObj("type", ["hasFeature", "getKey"]); + mockActionCapability = jasmine.createSpyObj("actionCapability", ["getActions"]); + mockEditAction = jasmine.createSpyObj("editAction", ["perform"]); mockDomainObject.getId.andReturn("test"); mockDomainObject.getCapability.andReturn(mockContext); mockContext.getParent.andReturn(mockParent); mockType.hasFeature.andReturn(true); + mockType.getKey.andReturn("layout"); mockComposition.invoke.andReturn(mockPromise(true)); mockComposition.add.andReturn(mockPromise(true)); + mockActionCapability.getActions.andReturn([]); capabilities = { composition: mockComposition, persistence: mockPersistence, + action: mockActionCapability, type: mockType }; model = { - composition: [ "a", "b", "c" ] + composition: ["a", "b", "c"] }; actionContext = { @@ -92,7 +97,7 @@ define( selectedObject: mockDomainObject }; - action = new LinkAction(actionContext); + action = new EditAndComposeAction(actionContext); }); @@ -107,6 +112,21 @@ define( 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); + }); + }); } ); diff --git a/platform/commonUI/edit/test/actions/PropertiesActionSpec.js b/platform/commonUI/edit/test/actions/PropertiesActionSpec.js index 1621a34ab6..785ac24d35 100644 --- a/platform/commonUI/edit/test/actions/PropertiesActionSpec.js +++ b/platform/commonUI/edit/test/actions/PropertiesActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,xit,expect,beforeEach,jasmine*/ define( ['../../src/actions/PropertiesAction'], function (PropertiesAction) { - "use strict"; describe("Properties action", function () { var capabilities, model, object, context, input, dialogService, action; @@ -40,7 +38,9 @@ define( beforeEach(function () { capabilities = { type: { - getProperties: function () { return []; }, + getProperties: function () { + return []; + }, hasFeature: jasmine.createSpy('hasFeature') }, persistence: jasmine.createSpyObj("persistence", ["persist"]), @@ -49,11 +49,21 @@ define( model = {}; input = {}; object = { - getId: function () { return 'test-id'; }, - getCapability: function (k) { return capabilities[k]; }, - getModel: function () { return model; }, - useCapability: function (k, v) { return capabilities[k](v); }, - hasCapability: function () { return true; } + getId: function () { + return 'test-id'; + }, + getCapability: function (k) { + 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 }; dialogService = { diff --git a/platform/commonUI/edit/test/actions/PropertiesDialogSpec.js b/platform/commonUI/edit/test/actions/PropertiesDialogSpec.js index a9077e8ec6..00d245a256 100644 --- a/platform/commonUI/edit/test/actions/PropertiesDialogSpec.js +++ b/platform/commonUI/edit/test/actions/PropertiesDialogSpec.js @@ -19,27 +19,33 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,xit,expect,beforeEach*/ define( ["../../src/actions/PropertiesDialog"], function (PropertiesDialog) { - "use strict"; describe("Properties dialog", function () { - var type, properties, domainObject, model, dialog; + var type, properties, model, dialog; beforeEach(function () { type = { - getProperties: function () { return properties; } + getProperties: function () { + return properties; + } }; model = { x: "initial value" }; properties = ["x", "y", "z"].map(function (k) { return { - getValue: function (model) { return model[k]; }, - setValue: function (model, v) { model[k] = v; }, - getDefinition: function () { return { control: 'textfield '}; } + getValue: function (m) { + return m[k]; + }, + setValue: function (m, v) { + m[k] = v; + }, + getDefinition: function () { + return { control: 'textfield '}; + } }; }); diff --git a/platform/commonUI/edit/test/actions/RemoveActionSpec.js b/platform/commonUI/edit/test/actions/RemoveActionSpec.js index 116627c87d..a9ae1143af 100644 --- a/platform/commonUI/edit/test/actions/RemoveActionSpec.js +++ b/platform/commonUI/edit/test/actions/RemoveActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,spyOn*/ define( ["../../src/actions/RemoveAction"], function (RemoveAction) { - "use strict"; describe("The Remove action", function () { var mockQ, @@ -59,19 +57,19 @@ define( mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability" ] + ["getId", "getCapability"] ); mockChildObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability" ] + ["getId", "getCapability"] ); mockGrandchildObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability" ] + ["getId", "getCapability"] ); mockRootObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability" ] + ["getId", "getCapability"] ); mockQ = { when: mockPromise }; mockParent = { @@ -85,13 +83,13 @@ define( return capabilities[k].invoke(v); } }; - mockContext = jasmine.createSpyObj("context", [ "getParent" ]); - mockChildContext = jasmine.createSpyObj("context", [ "getParent" ]); - mockGrandchildContext = jasmine.createSpyObj("context", [ "getParent" ]); - mockRootContext = jasmine.createSpyObj("context", [ "getParent" ]); - mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]); - mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]); - mockType = jasmine.createSpyObj("type", [ "hasFeature" ]); + mockContext = jasmine.createSpyObj("context", ["getParent"]); + mockChildContext = jasmine.createSpyObj("context", ["getParent"]); + mockGrandchildContext = jasmine.createSpyObj("context", ["getParent"]); + mockRootContext = jasmine.createSpyObj("context", ["getParent"]); + mockMutation = jasmine.createSpyObj("mutation", ["invoke"]); + mockPersistence = jasmine.createSpyObj("persistence", ["persist"]); + mockType = jasmine.createSpyObj("type", ["hasFeature"]); mockNavigationService = jasmine.createSpyObj( "navigationService", [ @@ -102,8 +100,8 @@ define( ] ); mockNavigationService.getNavigation.andReturn(mockDomainObject); - - + + mockDomainObject.getId.andReturn("test"); mockDomainObject.getCapability.andReturn(mockContext); mockContext.getParent.andReturn(mockParent); @@ -115,7 +113,7 @@ define( type: mockType }; model = { - composition: [ "a", "test", "b" ] + composition: ["a", "test", "b"] }; actionContext = { domainObject: mockDomainObject }; @@ -160,60 +158,60 @@ define( // Finally, should have persisted expect(mockPersistence.persist).toHaveBeenCalled(); }); - + it("removes parent of object currently navigated to", function () { // Navigates to child object mockNavigationService.getNavigation.andReturn(mockChildObject); - + // Test is id of object being removed // Child object has different id mockDomainObject.getId.andReturn("test"); mockChildObject.getId.andReturn("not test"); - + // Sets context for the child and domainObject mockDomainObject.getCapability.andReturn(mockContext); mockChildObject.getCapability.andReturn(mockChildContext); - + // Parents of child and domainObject are set mockContext.getParent.andReturn(mockParent); mockChildContext.getParent.andReturn(mockDomainObject); - + mockType.hasFeature.andReturn(true); - + action.perform(); - + // Expects navigation to parent of domainObject (removed object) expect(mockNavigationService.setNavigation).toHaveBeenCalledWith(mockParent); }); - + it("checks if removing object not in ascendent path (reaches ROOT)", function () { // Navigates to grandchild of ROOT mockNavigationService.getNavigation.andReturn(mockGrandchildObject); - + // domainObject (grandparent) is set as ROOT, child and grandchild // are set objects not being removed mockDomainObject.getId.andReturn("test 1"); mockRootObject.getId.andReturn("ROOT"); mockChildObject.getId.andReturn("not test 2"); mockGrandchildObject.getId.andReturn("not test 3"); - + // Sets context for the grandchild, child, and domainObject mockRootObject.getCapability.andReturn(mockRootContext); mockChildObject.getCapability.andReturn(mockChildContext); mockGrandchildObject.getCapability.andReturn(mockGrandchildContext); - + // Parents of grandchild and child are set mockChildContext.getParent.andReturn(mockRootObject); mockGrandchildContext.getParent.andReturn(mockChildObject); - + mockType.hasFeature.andReturn(true); - + action.perform(); - + // Expects no navigation to occur expect(mockNavigationService.setNavigation).not.toHaveBeenCalled(); }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/actions/SaveActionSpec.js b/platform/commonUI/edit/test/actions/SaveActionSpec.js index 98279e39b1..2d15b46679 100644 --- a/platform/commonUI/edit/test/actions/SaveActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit,xdescribe*/ define( ["../../src/actions/SaveAction"], function (SaveAction) { - "use strict"; describe("The Save action", function () { var mockDomainObject, @@ -54,11 +52,11 @@ define( ); mockEditorCapability = jasmine.createSpyObj( "editor", - [ "save", "cancel" ] + ["save", "cancel", "isEditContextRoot"] ); mockActionCapability = jasmine.createSpyObj( "actionCapability", - [ "perform"] + ["perform"] ); capabilities.editor = mockEditorCapability; capabilities.action = mockActionCapability; @@ -73,7 +71,7 @@ define( }); mockDomainObject.getModel.andReturn({persisted: 0}); mockEditorCapability.save.andReturn(mockPromise(true)); - mockDomainObject.getOriginalObject.andReturn(mockDomainObject); + mockEditorCapability.isEditContextRoot.andReturn(true); action = new SaveAction(actionContext); @@ -92,13 +90,20 @@ define( function () { mockDomainObject.getModel.andReturn({persisted: undefined}); expect(SaveAction.appliesTo(actionContext)).toBe(false); - }); + }); it("uses the editor capability to save the object", function () { action.perform(); expect(mockEditorCapability.save).toHaveBeenCalled(); }); + + it("navigates to the object after saving", + function () { + action.perform(); + expect(mockActionCapability.perform).toHaveBeenCalledWith("navigate"); + }); + }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index 866447a874..8ea603b623 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -19,12 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit,xdescribe*/ +/*global describe,it,expect,beforeEach,jasmine*/ define( ["../../src/actions/SaveAsAction"], function (SaveAsAction) { - "use strict"; describe("The Save As action", function () { var mockDomainObject, @@ -39,7 +38,7 @@ define( capabilities = {}, action; - function noop () {} + function noop() {} function mockPromise(value) { return (value || {}).then ? value : @@ -50,7 +49,7 @@ define( catch: function (callback) { return mockPromise(callback(value)); } - } ; + } ; } beforeEach(function () { @@ -79,10 +78,11 @@ define( mockEditorCapability = jasmine.createSpyObj( "editor", - [ "save", "cancel" ] + ["save", "cancel", "isEditContextRoot"] ); mockEditorCapability.cancel.andReturn(mockPromise(undefined)); mockEditorCapability.save.andReturn(mockPromise(true)); + mockEditorCapability.isEditContextRoot.andReturn(true); capabilities.editor = mockEditorCapability; mockActionCapability = jasmine.createSpyObj( @@ -130,7 +130,7 @@ define( action.createWizard.andReturn({ getFormStructure: noop, getInitialFormValue: noop, - populateObjectFromInput: function() { + populateObjectFromInput: function () { return mockDomainObject; } }); @@ -171,4 +171,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/capabilities/EditableCompositionCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditableCompositionCapabilitySpec.js deleted file mode 100644 index eed6222202..0000000000 --- a/platform/commonUI/edit/test/capabilities/EditableCompositionCapabilitySpec.js +++ /dev/null @@ -1,75 +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. - *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ - -define( - ["../../src/capabilities/EditableCompositionCapability"], - function (EditableCompositionCapability) { - "use strict"; - - describe("An editable composition capability", function () { - var mockContext, - mockEditableObject, - mockDomainObject, - mockTestObject, - someValue, - mockFactory, - capability; - - beforeEach(function () { - // EditableContextCapability should watch ALL - // methods for domain objects, so give it an - // arbitrary interface to wrap. - mockContext = - jasmine.createSpyObj("context", [ "getDomainObject" ]); - mockTestObject = jasmine.createSpyObj( - "domainObject", - [ "getId", "getModel", "getCapability" ] - ); - mockFactory = - jasmine.createSpyObj("factory", ["getEditableObject"]); - - someValue = { x: 42 }; - - mockContext.getDomainObject.andReturn(mockTestObject); - mockFactory.getEditableObject.andReturn(someValue); - - capability = new EditableCompositionCapability( - mockContext, - mockEditableObject, - mockDomainObject, - mockFactory - ); - - }); - - // Most behavior is tested for EditableLookupCapability, - // so just verify that this isse - it("presumes non-idempotence of its wrapped capability", function () { - expect(capability.getDomainObject()) - .toEqual(capability.getDomainObject()); - expect(mockContext.getDomainObject.calls.length).toEqual(2); - }); - - }); - } -); \ No newline at end of file diff --git a/platform/commonUI/edit/test/capabilities/EditableContextCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditableContextCapabilitySpec.js deleted file mode 100644 index 9967ffa076..0000000000 --- a/platform/commonUI/edit/test/capabilities/EditableContextCapabilitySpec.js +++ /dev/null @@ -1,89 +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. - *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ - -define( - ["../../src/capabilities/EditableContextCapability"], - function (EditableContextCapability) { - "use strict"; - - describe("An editable context capability", function () { - var mockContext, - mockEditableObject, - mockDomainObject, - mockTestObject, - someValue, - mockFactory, - capability; - - beforeEach(function () { - // EditableContextCapability should watch ALL - // methods for domain objects, so give it an - // arbitrary interface to wrap. - mockContext = - jasmine.createSpyObj("context", [ "getDomainObject", "getRoot" ]); - mockTestObject = jasmine.createSpyObj( - "domainObject", - [ "getId", "getModel", "getCapability" ] - ); - mockFactory = jasmine.createSpyObj( - "factory", - ["getEditableObject", "isRoot"] - ); - - someValue = { x: 42 }; - - mockContext.getRoot.andReturn(mockTestObject); - mockContext.getDomainObject.andReturn(mockTestObject); - mockFactory.getEditableObject.andReturn(someValue); - mockFactory.isRoot.andReturn(true); - - capability = new EditableContextCapability( - mockContext, - mockEditableObject, - mockDomainObject, - mockFactory - ); - - }); - - it("presumes idempotence of its wrapped capability", function () { - expect(capability.getDomainObject()) - .toEqual(capability.getDomainObject()); - expect(mockContext.getDomainObject.calls.length).toEqual(1); - }); - - it("hides the root object", function () { - expect(capability.getRoot()).toEqual(mockEditableObject); - expect(capability.getPath()).toEqual([mockEditableObject]); - }); - - it("exposes the root object through a different method", function () { - // Should still go through the factory... - expect(capability.getTrueRoot()).toEqual(someValue); - // ...with value of the unwrapped capability's getRoot - expect(mockFactory.getEditableObject) - .toHaveBeenCalledWith(mockTestObject); - }); - }); - } -); \ No newline at end of file diff --git a/platform/commonUI/edit/test/capabilities/EditableLookupCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditableLookupCapabilitySpec.js deleted file mode 100644 index 16bcee88b1..0000000000 --- a/platform/commonUI/edit/test/capabilities/EditableLookupCapabilitySpec.js +++ /dev/null @@ -1,146 +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. - *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ - -define( - ["../../src/capabilities/EditableLookupCapability"], - function (EditableLookupCapability) { - "use strict"; - - describe("An editable lookup capability", function () { - var mockContext, - mockEditableObject, - mockDomainObject, - mockTestObject, - someValue, - factory, - capability; - - beforeEach(function () { - // EditableContextCapability should watch ALL - // methods for domain objects, so give it an - // arbitrary interface to wrap. - mockContext = jasmine.createSpyObj( - "context", - [ - "getSomething", - "getDomainObject", - "getDomainObjectArray" - ] - ); - mockTestObject = jasmine.createSpyObj( - "domainObject", - [ "getId", "getModel", "getCapability" ] - ); - factory = { - getEditableObject: function (v) { - return { - isFromTestFactory: true, - calledWith: v - }; - } - }; - - someValue = { x: 42 }; - - mockContext.getSomething.andReturn(someValue); - mockContext.getDomainObject.andReturn(mockTestObject); - mockContext.getDomainObjectArray.andReturn([mockTestObject]); - - capability = new EditableLookupCapability( - mockContext, - mockEditableObject, - mockDomainObject, - factory, - false - ); - - }); - - it("wraps retrieved domain objects", function () { - var object = capability.getDomainObject(); - expect(object.isFromTestFactory).toBe(true); - expect(object.calledWith).toEqual(mockTestObject); - }); - - it("wraps retrieved domain object arrays", function () { - var object = capability.getDomainObjectArray()[0]; - expect(object.isFromTestFactory).toBe(true); - expect(object.calledWith).toEqual(mockTestObject); - }); - - it("does not wrap non-domain-objects", function () { - expect(capability.getSomething()).toEqual(someValue); - }); - - it("caches idempotent lookups", function () { - capability = new EditableLookupCapability( - mockContext, - mockEditableObject, - mockDomainObject, - factory, - true // idempotent - ); - expect(capability.getDomainObject()) - .toEqual(capability.getDomainObject()); - expect(mockContext.getDomainObject.calls.length).toEqual(1); - }); - - it("does not cache non-idempotent lookups", function () { - capability = new EditableLookupCapability( - mockContext, - mockEditableObject, - mockDomainObject, - factory, - false // Not idempotent - ); - expect(capability.getDomainObject()) - .toEqual(capability.getDomainObject()); - expect(mockContext.getDomainObject.calls.length).toEqual(2); - }); - - it("wraps inherited methods", function () { - var CapabilityClass = function(){ - }; - CapabilityClass.prototype.inheritedMethod=function () { - return "an inherited method"; - }; - - mockContext = new CapabilityClass(); - - capability = new EditableLookupCapability( - mockContext, - mockEditableObject, - mockDomainObject, - factory, - false - ); - expect(capability.inheritedMethod()).toEqual("an inherited method"); - expect(capability.hasOwnProperty('inheritedMethod')).toBe(true); - // The presence of an own property indicates that the method - // has been wrapped on the object itself and this is a valid - // test that the inherited method has been wrapped. - }); - - }); - } -); \ No newline at end of file diff --git a/platform/commonUI/edit/test/capabilities/EditablePersistenceCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditablePersistenceCapabilitySpec.js deleted file mode 100644 index 7fa0ac0dd7..0000000000 --- a/platform/commonUI/edit/test/capabilities/EditablePersistenceCapabilitySpec.js +++ /dev/null @@ -1,96 +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. - *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ - -define( - ["../../src/capabilities/EditablePersistenceCapability"], - function (EditablePersistenceCapability) { - "use strict"; - - describe("An editable persistence capability", function () { - var mockPersistence, - mockEditableObject, - mockDomainObject, - mockCache, - mockPromise, - capability; - - beforeEach(function () { - mockPersistence = jasmine.createSpyObj( - "persistence", - [ "persist", "refresh" ] - ); - mockEditableObject = jasmine.createSpyObj( - "editableObject", - [ "getId", "getModel", "getCapability" ] - ); - mockDomainObject = jasmine.createSpyObj( - "editableObject", - [ "getId", "getModel", "getCapability" ] - ); - mockCache = jasmine.createSpyObj( - "cache", - [ "markDirty" ] - ); - mockPromise = jasmine.createSpyObj("promise", ["then"]); - - mockCache.markDirty.andReturn(mockPromise); - mockDomainObject.getCapability.andReturn(mockPersistence); - - capability = new EditablePersistenceCapability( - mockPersistence, - mockEditableObject, - mockDomainObject, - mockCache - ); - }); - - it("marks objects as dirty (in the cache) upon persist", function () { - capability.persist(); - expect(mockCache.markDirty) - .toHaveBeenCalledWith(mockEditableObject); - }); - - it("does not invoke the underlying persistence capability", function () { - capability.persist(); - expect(mockPersistence.persist).not.toHaveBeenCalled(); - }); - - it("refreshes using the original domain object's persistence", function () { - // Refreshing needs to delegate via the unwrapped domain object. - // Otherwise, only the editable version of the object will be updated; - // we instead want the real version of the object to receive these - // changes. - expect(mockDomainObject.getCapability).not.toHaveBeenCalled(); - expect(mockPersistence.refresh).not.toHaveBeenCalled(); - capability.refresh(); - expect(mockDomainObject.getCapability).toHaveBeenCalledWith('persistence'); - expect(mockPersistence.refresh).toHaveBeenCalled(); - }); - - it("returns a promise from persist", function () { - expect(capability.persist().then).toEqual(jasmine.any(Function)); - }); - - }); - } -); \ No newline at end of file diff --git a/platform/commonUI/edit/test/capabilities/EditableRelationshipCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditableRelationshipCapabilitySpec.js deleted file mode 100644 index 366818e861..0000000000 --- a/platform/commonUI/edit/test/capabilities/EditableRelationshipCapabilitySpec.js +++ /dev/null @@ -1,75 +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. - *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ - -define( - ["../../src/capabilities/EditableRelationshipCapability"], - function (EditableRelationshipCapability) { - "use strict"; - - describe("An editable relationship capability", function () { - var mockContext, - mockEditableObject, - mockDomainObject, - mockTestObject, - someValue, - mockFactory, - capability; - - beforeEach(function () { - // EditableContextCapability should watch ALL - // methods for domain objects, so give it an - // arbitrary interface to wrap. - mockContext = - jasmine.createSpyObj("context", [ "getDomainObject" ]); - mockTestObject = jasmine.createSpyObj( - "domainObject", - [ "getId", "getModel", "getCapability" ] - ); - mockFactory = - jasmine.createSpyObj("factory", ["getEditableObject"]); - - someValue = { x: 42 }; - - mockContext.getDomainObject.andReturn(mockTestObject); - mockFactory.getEditableObject.andReturn(someValue); - - capability = new EditableRelationshipCapability( - mockContext, - mockEditableObject, - mockDomainObject, - mockFactory - ); - - }); - - // Most behavior is tested for EditableLookupCapability, - // so just verify that this isse - it("presumes non-idempotence of its wrapped capability", function () { - expect(capability.getDomainObject()) - .toEqual(capability.getDomainObject()); - expect(mockContext.getDomainObject.calls.length).toEqual(2); - }); - - }); - } -); \ No newline at end of file diff --git a/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js index 4e16a01170..fa4d1a43b6 100644 --- a/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js +++ b/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js @@ -19,102 +19,155 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,runs,jasmine,xit,xdescribe*/ define( ["../../src/capabilities/EditorCapability"], function (EditorCapability) { - "use strict"; describe("The editor capability", function () { - var mockPersistence, - mockEditableObject, - mockDomainObject, - mockCache, - mockCallback, - model, + var mockDomainObject, + capabilities, + mockParentObject, + mockTransactionService, + mockStatusCapability, + mockParentStatus, + mockContextCapability, capability; - beforeEach(function () { - mockPersistence = jasmine.createSpyObj( - "persistence", - [ "persist" ] - ); - mockEditableObject = { - getModel: function () { return model; } + function fastPromise(val) { + return { + then: function (callback) { + return callback(val); + } }; + } + + beforeEach(function () { mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability", "useCapability" ] + ["getId", "getModel", "hasCapability", "getCapability", "useCapability"] ); - mockCache = jasmine.createSpyObj( - "cache", - [ "saveAll", "markClean" ] + mockParentObject = jasmine.createSpyObj( + "domainObject", + ["getId", "getModel", "hasCapability", "getCapability", "useCapability"] ); - mockCallback = jasmine.createSpy("callback"); + mockTransactionService = jasmine.createSpyObj( + "transactionService", + [ + "startTransaction", + "size", + "commit", + "cancel" + ] + ); + mockTransactionService.commit.andReturn(fastPromise()); + mockTransactionService.cancel.andReturn(fastPromise()); - mockDomainObject.getCapability.andReturn(mockPersistence); + mockStatusCapability = jasmine.createSpyObj( + "statusCapability", + ["get", "set"] + ); + mockParentStatus = jasmine.createSpyObj( + "statusCapability", + ["get", "set"] + ); + mockContextCapability = jasmine.createSpyObj( + "contextCapability", + ["getParent"] + ); + mockContextCapability.getParent.andReturn(mockParentObject); - model = { someKey: "some value", x: 42 }; + capabilities = { + context: mockContextCapability, + status: mockStatusCapability + }; + + mockDomainObject.hasCapability.andCallFake(function (name) { + return capabilities[name] !== undefined; + }); + + mockDomainObject.getCapability.andCallFake(function (name) { + return capabilities[name]; + }); + + mockParentObject.getCapability.andReturn(mockParentStatus); + mockParentObject.hasCapability.andReturn(false); capability = new EditorCapability( - mockPersistence, - mockEditableObject, - mockDomainObject, - mockCache + mockTransactionService, + mockDomainObject ); }); - //TODO: Disabled for NEM Beta - xit("mutates the real domain object on nonrecursive save", function () { - capability.save(true).then(mockCallback); + it("starts a transaction when edit is invoked", function () { + capability.edit(); + expect(mockTransactionService.startTransaction).toHaveBeenCalled(); + }); - // Wait for promise to resolve - waitsFor(function () { - return mockCallback.calls.length > 0; - }, 250); + it("sets editing status on object", function () { + capability.edit(); + expect(mockStatusCapability.set).toHaveBeenCalledWith("editing", true); + }); - runs(function () { - expect(mockDomainObject.useCapability) - .toHaveBeenCalledWith("mutation", jasmine.any(Function)); - // We should get the model from the editable object back - expect( - mockDomainObject.useCapability.mostRecentCall.args[1]() - ).toEqual(model); + it("uses editing status to determine editing context root", function () { + capability.edit(); + mockStatusCapability.get.andReturn(false); + expect(capability.isEditContextRoot()).toBe(false); + mockStatusCapability.get.andReturn(true); + expect(capability.isEditContextRoot()).toBe(true); + }); + + it("inEditingContext returns true if parent object is being" + + " edited", function () { + mockStatusCapability.get.andReturn(false); + mockParentStatus.get.andReturn(false); + expect(capability.inEditContext()).toBe(false); + mockParentStatus.get.andReturn(true); + expect(capability.inEditContext()).toBe(true); + }); + + describe("save", function () { + beforeEach(function () { + capability.edit(); + capability.save(); + }); + it("commits the transaction", function () { + expect(mockTransactionService.commit).toHaveBeenCalled(); + }); + it("resets the edit state", function () { + expect(mockStatusCapability.set).toHaveBeenCalledWith('editing', false); }); }); - //TODO: Disabled for NEM Beta - xit("tells the cache to save others", function () { - capability.save().then(mockCallback); - - // Wait for promise to resolve - waitsFor(function () { - return mockCallback.calls.length > 0; - }, 250); - - runs(function () { - expect(mockCache.saveAll).toHaveBeenCalled(); + describe("cancel", function () { + beforeEach(function () { + capability.edit(); + capability.cancel(); + }); + it("cancels the transaction", function () { + expect(mockTransactionService.cancel).toHaveBeenCalled(); + }); + it("resets the edit state", function () { + expect(mockStatusCapability.set).toHaveBeenCalledWith('editing', false); }); }); - //TODO: Disabled for NEM Beta - xit("has no interactions on cancel", function () { - capability.cancel().then(mockCallback); + describe("dirty", function () { + var model = {}; - // Wait for promise to resolve - waitsFor(function () { - return mockCallback.calls.length > 0; - }, 250); - - runs(function () { - expect(mockDomainObject.useCapability).not.toHaveBeenCalled(); - expect(mockCache.markClean).not.toHaveBeenCalled(); - expect(mockCache.saveAll).not.toHaveBeenCalled(); + beforeEach(function () { + mockDomainObject.getModel.andReturn(model); + capability.edit(); + capability.cancel(); + }); + it("returns true if the object has been modified since it" + + " was last persisted", function () { + mockTransactionService.size.andReturn(0); + expect(capability.dirty()).toBe(false); + mockTransactionService.size.andReturn(1); + expect(capability.dirty()).toBe(true); }); }); - - }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/src/capabilities/EditableActionCapability.js b/platform/commonUI/edit/test/capabilities/TransactionCapabilityDecoratorSpec.js similarity index 50% rename from platform/commonUI/edit/src/capabilities/EditableActionCapability.js rename to platform/commonUI/edit/test/capabilities/TransactionCapabilityDecoratorSpec.js index b5bad72dc0..e1a48af7d1 100644 --- a/platform/commonUI/edit/src/capabilities/EditableActionCapability.js +++ b/platform/commonUI/edit/test/capabilities/TransactionCapabilityDecoratorSpec.js @@ -19,42 +19,36 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ - define( - function () { - 'use strict'; - var DISALLOWED_ACTIONS = ["move", "copy", "link", "window", "follow"]; - /** - * Editable Action Capability. Overrides the action capability - * normally exhibited by a domain object and filters out certain - * actions not applicable when an object is in edit mode. - * - * Meant specifically for use by EditableDomainObject and the - * associated cache; the constructor signature is particular - * to a pattern used there and may contain unused arguments. - * @constructor - * @memberof platform/commonUI/edit - * @implements {PersistenceCapability} - */ - function EditableActionCapability( - actionCapability, - editableObject, - domainObject, - cache - ) { - var action = Object.create(actionCapability); + [ + "../../src/capabilities/TransactionalPersistenceCapability", + "../../src/capabilities/TransactionCapabilityDecorator" + ], + function (TransactionalPersistenceCapability, TransactionCapabilityDecorator) { - action.getActions = function(domainObject) { - return actionCapability.getActions(domainObject).filter(function(action){ - return DISALLOWED_ACTIONS.indexOf(action.getMetadata().key) === -1; + describe("The transaction capability decorator", function () { + var mockQ, + mockTransactionService, + mockCapabilityService, + provider; + + beforeEach(function () { + mockQ = {}; + mockTransactionService = {}; + mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]); + mockCapabilityService.getCapabilities.andReturn({ + persistence: function () {} }); - }; - return action; - } + provider = new TransactionCapabilityDecorator(mockQ, mockTransactionService, mockCapabilityService); - return EditableActionCapability; + }); + it("decorates the persistence capability", function () { + var capabilities = provider.getCapabilities(); + expect(capabilities.persistence({}) instanceof TransactionalPersistenceCapability).toBe(true); + }); + + }); } ); diff --git a/platform/commonUI/edit/test/capabilities/TransactionalPersistenceCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/TransactionalPersistenceCapabilitySpec.js new file mode 100644 index 0000000000..63a9119826 --- /dev/null +++ b/platform/commonUI/edit/test/capabilities/TransactionalPersistenceCapabilitySpec.js @@ -0,0 +1,92 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define,describe,it,expect,beforeEach,jasmine*/ + +define( + [ + "../../src/capabilities/TransactionalPersistenceCapability" + ], + function (TransactionalPersistenceCapability) { + + function fastPromise(val) { + return { + then: function (callback) { + return callback(val); + } + }; + } + + describe("The transactional persistence decorator", function () { + var mockQ, + mockTransactionService, + mockPersistence, + mockDomainObject, + capability; + + beforeEach(function () { + mockQ = jasmine.createSpyObj("$q", ["when"]); + mockQ.when.andCallFake(function (val) { + return fastPromise(val); + }); + mockTransactionService = jasmine.createSpyObj( + "transactionService", + ["isActive", "addToTransaction"] + ); + mockPersistence = jasmine.createSpyObj( + "persistenceCapability", + ["persist", "refresh"] + ); + mockPersistence.persist.andReturn(fastPromise()); + mockPersistence.refresh.andReturn(fastPromise()); + capability = new TransactionalPersistenceCapability(mockQ, mockTransactionService, mockPersistence, mockDomainObject); + }); + + it("if no transaction is active, passes through to persistence" + + " provider", function () { + mockTransactionService.isActive.andReturn(false); + capability.persist(); + expect(mockPersistence.persist).toHaveBeenCalled(); + }); + + it("if transaction is active, persist and cancel calls are" + + " queued", function () { + mockTransactionService.isActive.andReturn(true); + capability.persist(); + expect(mockTransactionService.addToTransaction).toHaveBeenCalled(); + mockTransactionService.addToTransaction.mostRecentCall.args[0](); + expect(mockPersistence.persist).toHaveBeenCalled(); + mockTransactionService.addToTransaction.mostRecentCall.args[1](); + expect(mockPersistence.refresh).toHaveBeenCalled(); + }); + + it("persist call is only added to transaction once", function () { + mockTransactionService.isActive.andReturn(true); + capability.persist(); + expect(mockTransactionService.addToTransaction).toHaveBeenCalled(); + capability.persist(); + expect(mockTransactionService.addToTransaction.calls.length).toBe(1); + + }); + + }); + } +); diff --git a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js index 0ac30d6ef5..2fe3e32d63 100644 --- a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/controllers/EditActionController"], function (EditActionController) { - "use strict"; describe("The Edit Action controller", function () { var mockScope, @@ -58,4 +56,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/controllers/EditControllerSpec.js b/platform/commonUI/edit/test/controllers/EditControllerSpec.js index 0ed0ddecc7..b616d6006d 100644 --- a/platform/commonUI/edit/test/controllers/EditControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/controllers/EditObjectController"], function (EditObjectController) { - "use strict"; describe("The Edit mode controller", function () { var mockScope, @@ -54,15 +52,15 @@ define( ); mockScope = jasmine.createSpyObj( "$scope", - [ "$on", "$watch" ] + ["$on", "$watch"] ); mockObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ] + ["getId", "getModel", "getCapability", "hasCapability", "useCapability"] ); mockType = jasmine.createSpyObj( "type", - [ "hasFeature" ] + ["hasFeature"] ); mockStatusCapability = jasmine.createSpyObj('statusCapability', ["get"] @@ -95,15 +93,14 @@ define( }); it("exposes a warning message for unload", function () { - var obj = mockObject, - errorMessage = "Unsaved changes"; + var errorMessage = "Unsaved changes"; // Normally, should be undefined expect(controller.getUnloadWarning()).toBeUndefined(); // Override the policy service to prevent navigation - mockPolicyService.allow.andCallFake(function(category, object, context, callback){ - callback(errorMessage); + mockPolicyService.allow.andCallFake(function (category, object, context, callback) { + callback(errorMessage); }); // Should have some warning message here now diff --git a/platform/commonUI/edit/test/controllers/EditPanesControllerSpec.js b/platform/commonUI/edit/test/controllers/EditPanesControllerSpec.js index fd1d56e67c..4d6291ae7f 100644 --- a/platform/commonUI/edit/test/controllers/EditPanesControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditPanesControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/controllers/EditPanesController"], function (EditPanesController) { - "use strict"; describe("The Edit Panes controller", function () { var mockScope, @@ -36,11 +34,11 @@ define( mockScope = jasmine.createSpyObj("$scope", ["$watch"]); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getCapability' ] + ['getId', 'getCapability'] ); mockContext = jasmine.createSpyObj( 'context', - [ 'getTrueRoot' ] + ['getTrueRoot'] ); mockDomainObject.getId.andReturn('test-id'); @@ -112,4 +110,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/controllers/ElementsControllerSpec.js b/platform/commonUI/edit/test/controllers/ElementsControllerSpec.js new file mode 100644 index 0000000000..a40c318c51 --- /dev/null +++ b/platform/commonUI/edit/test/controllers/ElementsControllerSpec.js @@ -0,0 +1,68 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global describe,it,expect,beforeEach,jasmine*/ + +define( + ["../../src/controllers/ElementsController"], + function (ElementsController) { + + describe("The Elements Pane controller", function () { + var mockScope, + controller; + + beforeEach(function () { + mockScope = jasmine.createSpy("$scope"); + controller = new ElementsController(mockScope); + }); + + function getModel(model) { + return function () { + return model; + }; + } + + it("filters objects in elements pool based on input text and" + + " object name", function () { + var objects = [ + { + getModel: getModel({name: "first element"}) + }, + { + getModel: getModel({name: "second element"}) + }, + { + getModel: getModel({name: "third element"}) + }, + { + getModel: getModel({name: "THIRD Element 1"}) + } + ]; + + mockScope.filterBy("third element"); + expect(objects.filter(mockScope.searchElements).length).toBe(2); + mockScope.filterBy("element"); + expect(objects.filter(mockScope.searchElements).length).toBe(4); + }); + + }); + } +); diff --git a/platform/commonUI/edit/test/directives/MCTBeforeUnloadSpec.js b/platform/commonUI/edit/test/directives/MCTBeforeUnloadSpec.js index 41070d76f5..ab108f6feb 100644 --- a/platform/commonUI/edit/test/directives/MCTBeforeUnloadSpec.js +++ b/platform/commonUI/edit/test/directives/MCTBeforeUnloadSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/directives/MCTBeforeUnload"], function (MCTBeforeUnload) { - "use strict"; describe("The mct-before-unload directive", function () { var mockWindow, @@ -113,4 +111,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/objects/EditableDomainObjectCacheSpec.js b/platform/commonUI/edit/test/objects/EditableDomainObjectCacheSpec.js deleted file mode 100644 index 4eea727e26..0000000000 --- a/platform/commonUI/edit/test/objects/EditableDomainObjectCacheSpec.js +++ /dev/null @@ -1,180 +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. - *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ - -define( - ["../../src/objects/EditableDomainObjectCache"], - function (EditableDomainObjectCache) { - 'use strict'; - - describe("Editable domain object cache", function () { - - var captured, - completionCapability, - object, - mockQ, - mockType, - cache; - - - // Constructors for test objects - function TestObject(id) { - return { - getId: function () { return id; }, - getModel: function () { return {}; }, - getCapability: function (key) { - return { - editor: completionCapability, - type: mockType - }[key]; - }, - hasCapability: function (key) { - return false; - } - }; - } - - function WrapObject(domainObject, model) { - var result = Object.create(domainObject); - result.wrapped = true; - result.wrappedModel = model; - result.hasCapability = function (name) { - return name === 'editor'; - }; - captured.wraps = (captured.wraps || 0) + 1; - return result; - } - - beforeEach(function () { - mockQ = jasmine.createSpyObj('$q', ['when', 'all']); - mockType = jasmine.createSpyObj('type', ['hasFeature']); - mockType.hasFeature.andReturn(true); - captured = {}; - completionCapability = { - save: function () { - captured.saved = (captured.saved || 0) + 1; - } - }; - - cache = new EditableDomainObjectCache(WrapObject, mockQ); - }); - - it("wraps objects using provided constructor", function () { - var domainObject = new TestObject('test-id'), - wrappedObject = cache.getEditableObject(domainObject); - expect(wrappedObject.wrapped).toBeTruthy(); - expect(wrappedObject.getId()).toEqual(domainObject.getId()); - }); - - it("wraps objects repeatedly, wraps models once", function () { - var domainObject = new TestObject('test-id'), - wrappedObjects = []; - - // Verify precondition - expect(captured.wraps).toBeUndefined(); - - // Invoke a few more times; expect count not to increment - wrappedObjects.push(cache.getEditableObject(domainObject)); - expect(captured.wraps).toEqual(1); - wrappedObjects.push(cache.getEditableObject(domainObject)); - expect(captured.wraps).toEqual(2); - wrappedObjects.push(cache.getEditableObject(domainObject)); - expect(captured.wraps).toEqual(3); - - // Verify that the last call still gave us a wrapped object - expect(wrappedObjects[0].wrapped).toBeTruthy(); - expect(wrappedObjects[0].getId()).toEqual(domainObject.getId()); - - // Verify that objects are distinct but models are identical - expect(wrappedObjects[0].wrappedModel) - .toBe(wrappedObjects[1].wrappedModel); - expect(wrappedObjects[0]).not - .toBe(wrappedObjects[1]); - }); - - it("saves objects that have been marked dirty", function () { - var objects = ['a', 'b', 'c'].map(TestObject).map(function (domainObject) { - return cache.getEditableObject(domainObject); - }); - - cache.markDirty(objects[0]); - cache.markDirty(objects[2]); - - cache.saveAll(); - - expect(captured.saved).toEqual(2); - }); - - it("does not save objects that have been marked clean", function () { - var objects = ['a', 'b', 'c'].map(TestObject).map(function (domainObject) { - return cache.getEditableObject(domainObject); - }); - - cache.markDirty(objects[0]); - cache.markDirty(objects[2]); - cache.markClean(objects[0]); - - cache.saveAll(); - - expect(captured.saved).toEqual(1); - }); - - it("tracks the root object of the Edit mode subgraph", function () { - // Root object is the first object exposed to the cache - var domainObjects = ['a', 'b', 'c'].map(TestObject); - domainObjects.forEach(function (obj) { - cache.getEditableObject(obj); - }); - expect(cache.isRoot(domainObjects[0])).toBeTruthy(); - expect(cache.isRoot(domainObjects[1])).toBeFalsy(); - expect(cache.isRoot(domainObjects[2])).toBeFalsy(); - }); - - it("does not double-wrap objects", function () { - var domainObject = new TestObject('test-id'), - wrappedObject = cache.getEditableObject(domainObject); - - // Same instance should be returned if you try to wrap - // twice. This is necessary, since it's possible to (e.g.) - // use a context capability on an object retrieved via - // composition, in which case a result will already be - // wrapped. - expect(cache.getEditableObject(wrappedObject)) - .toBe(wrappedObject); - }); - - it("does not wrap non-editable objects", function () { - var domainObject = new TestObject('test-id'); - - mockType.hasFeature.andCallFake(function (key) { - return key !== 'creation'; - }); - - expect(cache.getEditableObject(domainObject)) - .toBe(domainObject); - }); - - - }); - } - -); diff --git a/platform/commonUI/edit/test/objects/EditableModelCacheSpec.js b/platform/commonUI/edit/test/objects/EditableModelCacheSpec.js deleted file mode 100644 index a12432164d..0000000000 --- a/platform/commonUI/edit/test/objects/EditableModelCacheSpec.js +++ /dev/null @@ -1,81 +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. - *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ - -define( - ["../../src/objects/EditableModelCache"], - function (EditableModelCache) { - "use strict"; - - describe("The editable model cache", function () { - var mockObject, - mockOtherObject, - testModel, - testId, - otherModel, - otherId, - cache; - - beforeEach(function () { - testId = "test"; - testModel = { someKey: "some value" }; - otherId = "other"; - otherModel = { someKey: "some other value" }; - - mockObject = jasmine.createSpyObj( - "domainObject", - [ "getId", "getModel" ] - ); - mockOtherObject = jasmine.createSpyObj( - "domainObject", - [ "getId", "getModel" ] - ); - - mockObject.getId.andReturn(testId); - mockObject.getModel.andReturn(testModel); - mockOtherObject.getId.andReturn(otherId); - mockOtherObject.getModel.andReturn(otherModel); - - cache = new EditableModelCache(); - }); - - it("provides clones of domain object models", function () { - var model = cache.getCachedModel(mockObject); - // Should be identical... - expect(model).toEqual(testModel); - // ...but not pointer-identical - expect(model).not.toBe(testModel); - }); - - it("provides only one clone per object", function () { - var model = cache.getCachedModel(mockObject); - expect(cache.getCachedModel(mockObject)).toBe(model); - }); - - it("maintains separate caches per-object", function () { - expect(cache.getCachedModel(mockObject)) - .not.toEqual(cache.getCachedModel(mockOtherObject)); - }); - }); - - } -); \ No newline at end of file diff --git a/platform/commonUI/edit/test/policies/EditActionPolicySpec.js b/platform/commonUI/edit/test/policies/EditActionPolicySpec.js index e2cf51ab97..539e37a373 100644 --- a/platform/commonUI/edit/test/policies/EditActionPolicySpec.js +++ b/platform/commonUI/edit/test/policies/EditActionPolicySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit,xdescribe*/ define( ["../../src/policies/EditActionPolicy"], function (EditActionPolicy) { - "use strict"; describe("The Edit action policy", function () { var editableView, @@ -36,7 +34,7 @@ define( mockEditAction, mockPropertiesAction, mockTypeCapability, - mockStatusCapability, + mockEditorCapability, capabilities, plotView, policy; @@ -50,21 +48,20 @@ define( 'getCapability' ] ); - mockStatusCapability = jasmine.createSpyObj('statusCapability', ['get']); - mockStatusCapability.get.andReturn(false); + mockEditorCapability = jasmine.createSpyObj('editorCapability', ['isEditContextRoot']); mockTypeCapability = jasmine.createSpyObj('type', ['getKey']); capabilities = { - 'status': mockStatusCapability, + 'editor': mockEditorCapability, 'type': mockTypeCapability }; mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']); mockPropertiesAction = jasmine.createSpyObj('edit', ['getMetadata']); - mockDomainObject.getCapability.andCallFake(function(capability){ + mockDomainObject.getCapability.andCallFake(function (capability) { return capabilities[capability]; }); - mockDomainObject.hasCapability.andCallFake(function(capability){ + mockDomainObject.hasCapability.andCallFake(function (capability) { return !!capabilities[capability]; }); @@ -91,42 +88,42 @@ define( }); it("allows the edit action when there are editable views", function () { - testViews = [ editableView ]; + testViews = [editableView]; expect(policy.allow(mockEditAction, testContext)).toBe(true); }); it("allows the edit properties action when there are no editable views", function () { - testViews = [ nonEditableView, nonEditableView ]; + testViews = [nonEditableView, nonEditableView]; expect(policy.allow(mockPropertiesAction, testContext)).toBe(true); }); it("disallows the edit action when there are no editable views", function () { - testViews = [ nonEditableView, nonEditableView ]; + testViews = [nonEditableView, nonEditableView]; expect(policy.allow(mockEditAction, testContext)).toBe(false); }); it("disallows the edit properties action when there are" + " editable views", function () { - testViews = [ editableView ]; + testViews = [editableView]; expect(policy.allow(mockPropertiesAction, testContext)).toBe(false); }); it("disallows the edit action when object is already being" + " edited", function () { - testViews = [ editableView ]; - mockStatusCapability.get.andReturn(true); + testViews = [editableView]; + mockEditorCapability.isEditContextRoot.andReturn(true); expect(policy.allow(mockEditAction, testContext)).toBe(false); }); it("allows editing of panels in plot view", function () { - testViews = [ plotView ]; + testViews = [plotView]; mockTypeCapability.getKey.andReturn('telemetry.panel'); expect(policy.allow(mockEditAction, testContext)).toBe(true); }); it("disallows editing of plot view when object not a panel type", function () { - testViews = [ plotView ]; + testViews = [plotView]; mockTypeCapability.getKey.andReturn('something.else'); expect(policy.allow(mockEditAction, testContext)).toBe(false); @@ -134,10 +131,10 @@ define( it("allows the edit properties outside of the 'view-control' category", function () { - testViews = [ nonEditableView ]; + testViews = [nonEditableView]; testContext.category = "something-else"; expect(policy.allow(mockPropertiesAction, testContext)).toBe(true); }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/policies/EditContextualActionPolicySpec.js b/platform/commonUI/edit/test/policies/EditContextualActionPolicySpec.js index 8dbf2c128c..23e7ec8c1e 100644 --- a/platform/commonUI/edit/test/policies/EditContextualActionPolicySpec.js +++ b/platform/commonUI/edit/test/policies/EditContextualActionPolicySpec.js @@ -19,12 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit,xdescribe*/ +/*global describe,it,expect,beforeEach,jasmine*/ define( ["../../src/policies/EditContextualActionPolicy"], function (EditContextualActionPolicy) { - "use strict"; describe("The Edit contextual action policy", function () { var policy, @@ -33,14 +32,22 @@ define( context, navigatedObject, mockDomainObject, - metadata; + mockEditorCapability, + metadata, + editModeBlacklist = ["copy", "follow", "window", "link", "locate"], + nonEditContextBlacklist = ["copy", "follow", "properties", "move", "link", "remove", "locate"]; beforeEach(function () { - navigatedObject = jasmine.createSpyObj("navigatedObject", ["hasCapability"]); + mockEditorCapability = jasmine.createSpyObj("editorCapability", ["isEditContextRoot", "inEditContext"]); + + navigatedObject = jasmine.createSpyObj("navigatedObject", ["hasCapability", "getCapability"]); + navigatedObject.getCapability.andReturn(mockEditorCapability); navigatedObject.hasCapability.andReturn(false); - mockDomainObject = jasmine.createSpyObj("domainObject", ["hasCapability"]); + + mockDomainObject = jasmine.createSpyObj("domainObject", ["hasCapability", "getCapability"]); mockDomainObject.hasCapability.andReturn(false); + mockDomainObject.getCapability.andReturn(mockEditorCapability); navigationService = jasmine.createSpyObj("navigationService", ["getNavigation"]); navigationService.getNavigation.andReturn(navigatedObject); @@ -51,35 +58,63 @@ define( context = {domainObject: mockDomainObject}; - policy = new EditContextualActionPolicy(navigationService); + policy = new EditContextualActionPolicy(navigationService, editModeBlacklist, nonEditContextBlacklist); }); - it('Allows all actions when navigated object not in edit mode', function() { + it('Allows all actions when navigated object not in edit mode', function () { expect(policy.allow(mockAction, context)).toBe(true); }); it('Allows "window" action when navigated object in edit mode,' + - ' but selected object not in edit mode ', function() { + ' but selected object not in edit mode ', function () { navigatedObject.hasCapability.andReturn(true); + mockEditorCapability.isEditContextRoot.andReturn(true); metadata.key = "window"; expect(policy.allow(mockAction, context)).toBe(true); }); + it('Allows "remove" action when navigated object in edit mode,' + + ' and selected object not editable, but its parent is.', + function () { + var mockParent = jasmine.createSpyObj("parentObject", ["hasCapability"]), + mockContextCapability = jasmine.createSpyObj("contextCapability", ["getParent"]); + + mockParent.hasCapability.andReturn(true); + mockContextCapability.getParent.andReturn(mockParent); + navigatedObject.hasCapability.andReturn(true); + + mockDomainObject.getCapability.andReturn(mockContextCapability); + mockDomainObject.hasCapability.andCallFake(function (capability) { + switch (capability) { + case "editor": return false; + case "context": return true; + } + }); + metadata.key = "remove"; + + expect(policy.allow(mockAction, context)).toBe(true); + }); + it('Disallows "move" action when navigated object in edit mode,' + - ' but selected object not in edit mode ', function() { + ' but selected object not in edit mode ', function () { navigatedObject.hasCapability.andReturn(true); + mockEditorCapability.isEditContextRoot.andReturn(true); + mockEditorCapability.inEditContext.andReturn(false); metadata.key = "move"; expect(policy.allow(mockAction, context)).toBe(false); }); it('Disallows copy action when navigated object and' + - ' selected object in edit mode', function() { + ' selected object in edit mode', function () { navigatedObject.hasCapability.andReturn(true); mockDomainObject.hasCapability.andReturn(true); + mockEditorCapability.isEditContextRoot.andReturn(true); + mockEditorCapability.inEditContext.andReturn(true); + metadata.key = "copy"; expect(policy.allow(mockAction, context)).toBe(false); }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/policies/EditableViewPolicySpec.js b/platform/commonUI/edit/test/policies/EditableViewPolicySpec.js index a4a4c41a6f..e849e49c5f 100644 --- a/platform/commonUI/edit/test/policies/EditableViewPolicySpec.js +++ b/platform/commonUI/edit/test/policies/EditableViewPolicySpec.js @@ -19,16 +19,13 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/policies/EditableViewPolicy"], function (EditableViewPolicy) { - "use strict"; describe("The editable view policy", function () { - var testView, - mockDomainObject, + var mockDomainObject, testMode, policy; @@ -36,8 +33,13 @@ define( testMode = true; // Act as if we're in Edit mode by default mockDomainObject = jasmine.createSpyObj( 'domainObject', - ['hasCapability'] + ['hasCapability', 'getCapability'] ); + mockDomainObject.getCapability.andReturn({ + inEditContext: function () { + return true; + } + }); mockDomainObject.hasCapability.andCallFake(function (c) { return (c === 'editor') && testMode; }); @@ -74,4 +76,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/representers/EditRepresenterSpec.js b/platform/commonUI/edit/test/representers/EditRepresenterSpec.js index 3dcaa34627..d535e19bac 100644 --- a/platform/commonUI/edit/test/representers/EditRepresenterSpec.js +++ b/platform/commonUI/edit/test/representers/EditRepresenterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/representers/EditRepresenter"], function (EditRepresenter) { - "use strict"; describe("The Edit mode representer", function () { var mockQ, @@ -34,6 +32,7 @@ define( mockDomainObject, mockPersistence, mockStatusCapability, + mockEditorCapability, mockCapabilities, representer; @@ -60,17 +59,20 @@ define( mockPersistence = jasmine.createSpyObj("persistence", ["persist"]); mockStatusCapability = - jasmine.createSpyObj("statusCapability", ["get", "listen"]); - mockStatusCapability.get.andReturn(false); + jasmine.createSpyObj("statusCapability", ["listen"]); + mockEditorCapability = + jasmine.createSpyObj("editorCapability", ["isEditContextRoot"]); + mockCapabilities = { 'persistence': mockPersistence, - 'status': mockStatusCapability + 'status': mockStatusCapability, + 'editor': mockEditorCapability }; mockDomainObject.getModel.andReturn({}); mockDomainObject.hasCapability.andReturn(true); mockDomainObject.useCapability.andReturn(true); - mockDomainObject.getCapability.andCallFake(function(capability){ + mockDomainObject.getCapability.andCallFake(function (capability) { return mockCapabilities[capability]; }); @@ -84,6 +86,7 @@ define( it("Sets edit view template on edit mode", function () { mockStatusCapability.listen.mostRecentCall.args[0](['editing']); + mockEditorCapability.isEditContextRoot.andReturn(true); expect(mockScope.viewObjectTemplate).toEqual('edit-object'); }); diff --git a/platform/commonUI/edit/test/representers/EditToolbarRepresenterSpec.js b/platform/commonUI/edit/test/representers/EditToolbarRepresenterSpec.js index c8b5bb2c91..d0833e490c 100644 --- a/platform/commonUI/edit/test/representers/EditToolbarRepresenterSpec.js +++ b/platform/commonUI/edit/test/representers/EditToolbarRepresenterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/representers/EditToolbarRepresenter"], function (EditToolbarRepresenter) { - "use strict"; describe("The Edit mode toolbar representer", function () { var mockScope, @@ -36,13 +34,13 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( '$scope', - [ '$on', '$watch', '$watchCollection', "commit" ] + ['$on', '$watch', '$watchCollection', "commit"] ); mockElement = {}; testAttrs = { toolbar: 'testToolbar' }; mockScope.$parent = jasmine.createSpyObj( '$parent', - [ '$watch', '$watchCollection' ] + ['$watch', '$watchCollection'] ); mockUnwatch = jasmine.createSpy('unwatch'); @@ -94,7 +92,7 @@ define( // Provide a view which has a toolbar representer.represent({ - toolbar: { sections: [ { items: [ { property: 'k' } ] } ] } + toolbar: { sections: [{ items: [{ property: 'k' }] }] } }); // Update the selection @@ -122,7 +120,7 @@ define( // Provide a view which has a toolbar representer.represent({ - toolbar: { sections: [ { items: [ { property: 'k' } ] } ] } + toolbar: { sections: [{ items: [{ property: 'k' }] }] } }); // Update the selection @@ -142,4 +140,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/representers/EditToolbarSelectionSpec.js b/platform/commonUI/edit/test/representers/EditToolbarSelectionSpec.js index 45cbe92136..fa762631f7 100644 --- a/platform/commonUI/edit/test/representers/EditToolbarSelectionSpec.js +++ b/platform/commonUI/edit/test/representers/EditToolbarSelectionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ['../../src/representers/EditToolbarSelection'], function (EditToolbarSelection) { - "use strict"; describe("The Edit mode selection manager", function () { var testProxy, diff --git a/platform/commonUI/edit/test/representers/EditToolbarSpec.js b/platform/commonUI/edit/test/representers/EditToolbarSpec.js index fb58015654..2e4946dd76 100644 --- a/platform/commonUI/edit/test/representers/EditToolbarSpec.js +++ b/platform/commonUI/edit/test/representers/EditToolbarSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/representers/EditToolbar'], function (EditToolbar) { - "use strict"; describe("An Edit mode toolbar", function () { var mockCommit, @@ -78,7 +76,7 @@ define( it("provides properties from the original structure", function () { expect( - new EditToolbar(testStructure, [ testABC ]) + new EditToolbar(testStructure, [testABC]) .getStructure() .sections[0] .items[1] @@ -89,7 +87,7 @@ define( // This is needed by mct-toolbar it("adds keys to form structure", function () { expect( - new EditToolbar(testStructure, [ testABC ]) + new EditToolbar(testStructure, [testABC]) .getStructure() .sections[0] .items[1] @@ -99,20 +97,20 @@ define( it("marks empty sections as hidden", function () { // Verify that all sections are included when applicable... - toolbar.setSelection([ testABCXYZ ]); + toolbar.setSelection([testABCXYZ]); expect(toolbar.getStructure().sections.map(getVisibility)) - .toEqual([ true, true, false ]); + .toEqual([true, true, false]); // ...but omitted when only some are applicable - toolbar.setSelection([ testABC ]); + toolbar.setSelection([testABC]); expect(toolbar.getStructure().sections.map(getVisibility)) - .toEqual([ true, false, false ]); + .toEqual([true, false, false]); }); it("reads properties from selections", function () { var structure, state; - toolbar.setSelection([ testABC ]); + toolbar.setSelection([testABC]); structure = toolbar.getStructure(); state = toolbar.getState(); @@ -128,9 +126,11 @@ define( it("reads properties from getters", function () { 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(); state = toolbar.getState(); @@ -139,7 +139,7 @@ define( }); it("sets properties on update", function () { - toolbar.setSelection([ testABC ]); + toolbar.setSelection([testABC]); toolbar.updateState( toolbar.getStructure().sections[0].items[0].key, "new value" @@ -149,11 +149,11 @@ define( }); it("invokes setters on update", function () { - var structure, state; + var structure; testABC.a = jasmine.createSpy('a'); - toolbar.setSelection([ testABC ]); + toolbar.setSelection([testABC]); structure = toolbar.getStructure(); toolbar.updateState( @@ -167,7 +167,7 @@ define( it("provides a return value describing update status", function () { // Should return true if actually updated, otherwise false var key; - toolbar.setSelection([ testABC ]); + toolbar.setSelection([testABC]); key = toolbar.getStructure().sections[0].items[0].key; expect(toolbar.updateState(key, testABC.a)).toBeFalsy(); expect(toolbar.updateState(key, "new value")).toBeTruthy(); @@ -175,35 +175,35 @@ define( it("removes inapplicable items", function () { // First, verify with all items - toolbar.setSelection([ testABC ]); + toolbar.setSelection([testABC]); expect(toolbar.getStructure().sections[0].items.map(getVisibility)) - .toEqual([ true, true, true ]); + .toEqual([true, true, true]); // Then, try with some items omitted - toolbar.setSelection([ testABC, testAB ]); + toolbar.setSelection([testABC, testAB]); expect(toolbar.getStructure().sections[0].items.map(getVisibility)) - .toEqual([ true, true, false ]); + .toEqual([true, true, false]); }); it("removes inconsistent states", function () { // Only two of three values match among these selections - toolbar.setSelection([ testABC, testABC2 ]); + toolbar.setSelection([testABC, testABC2]); expect(toolbar.getStructure().sections[0].items.map(getVisibility)) - .toEqual([ false, true, true ]); + .toEqual([false, true, true]); }); it("allows inclusive items", function () { // One inclusive item is in the set, property 'x' of the // second section; make sure items are pruned down // when only some of the selection has x,y,z properties - toolbar.setSelection([ testABC, testABCXYZ ]); + toolbar.setSelection([testABC, testABCXYZ]); expect(toolbar.getStructure().sections[1].items.map(getVisibility)) - .toEqual([ true, false, false ]); + .toEqual([true, false, false]); }); it("removes inclusive items when there are no matches", function () { - toolbar.setSelection([ testABCYZ ]); + toolbar.setSelection([testABCYZ]); expect(toolbar.getStructure().sections[1].items.map(getVisibility)) - .toEqual([ false, true, true ]); + .toEqual([false, true, true]); }); it("adds click functions when a method is specified", function () { diff --git a/platform/commonUI/edit/test/services/TransactionServiceSpec.js b/platform/commonUI/edit/test/services/TransactionServiceSpec.js new file mode 100644 index 0000000000..91fa859b73 --- /dev/null +++ b/platform/commonUI/edit/test/services/TransactionServiceSpec.js @@ -0,0 +1,137 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define,describe,it,expect,beforeEach,jasmine*/ + +define( + ["../../src/services/TransactionService"], + function (TransactionService) { + + describe("The Transaction Service", function () { + var mockQ, + mockLog, + transactionService; + + function fastPromise(val) { + return { + then: function (callback) { + return fastPromise(callback(val)); + } + }; + } + + beforeEach(function () { + mockQ = jasmine.createSpyObj("$q", ["all"]); + mockQ.all.andReturn(fastPromise()); + mockLog = jasmine.createSpyObj("$log", ["error"]); + transactionService = new TransactionService(mockQ, mockLog); + }); + + it("isActive returns true if a transaction is in progress", function () { + expect(transactionService.isActive()).toBe(false); + transactionService.startTransaction(); + expect(transactionService.isActive()).toBe(true); + }); + + it("addToTransaction queues onCommit and onCancel functions", function () { + var onCommit = jasmine.createSpy('onCommit'), + onCancel = jasmine.createSpy('onCancel'); + + transactionService.startTransaction(); + transactionService.addToTransaction(onCommit, onCancel); + expect(transactionService.onCommits.length).toBe(1); + expect(transactionService.onCancels.length).toBe(1); + }); + + it("size function returns size of commit and cancel queues", function () { + var onCommit = jasmine.createSpy('onCommit'), + onCancel = jasmine.createSpy('onCancel'); + + transactionService.startTransaction(); + transactionService.addToTransaction(onCommit, onCancel); + transactionService.addToTransaction(onCommit, onCancel); + transactionService.addToTransaction(onCommit, onCancel); + expect(transactionService.size()).toBe(3); + }); + + describe("commit", function () { + var onCommits; + + beforeEach(function () { + onCommits = [0, 1, 2].map(function (val) { + return jasmine.createSpy("onCommit" + val); + }); + + transactionService.startTransaction(); + onCommits.forEach(transactionService.addToTransaction.bind(transactionService)); + }); + + it("commit calls all queued commit functions", function () { + expect(transactionService.onCommits.length).toBe(3); + transactionService.commit(); + onCommits.forEach(function (spy) { + expect(spy).toHaveBeenCalled(); + }); + }); + + it("commit resets active state and clears queues", function () { + transactionService.commit(); + expect(transactionService.isActive()).toBe(false); + expect(transactionService.onCommits.length).toBe(0); + expect(transactionService.onCancels.length).toBe(0); + }); + + }); + + describe("cancel", function () { + var onCancels; + + beforeEach(function () { + onCancels = [0, 1, 2].map(function (val) { + return jasmine.createSpy("onCancel" + val); + }); + + transactionService.startTransaction(); + onCancels.forEach(function (onCancel) { + transactionService.addToTransaction(undefined, onCancel); + }); + }); + + it("cancel calls all queued cancel functions", function () { + expect(transactionService.onCancels.length).toBe(3); + transactionService.cancel(); + onCancels.forEach(function (spy) { + expect(spy).toHaveBeenCalled(); + }); + }); + + it("cancel resets active state and clears queues", function () { + transactionService.cancel(); + expect(transactionService.isActive()).toBe(false); + expect(transactionService.onCommits.length).toBe(0); + expect(transactionService.onCancels.length).toBe(0); + }); + + }); + + }); + } +); diff --git a/platform/commonUI/formats/bundle.js b/platform/commonUI/formats/bundle.js index d323d3d47a..99c384f47f 100644 --- a/platform/commonUI/formats/bundle.js +++ b/platform/commonUI/formats/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/FormatProvider", @@ -30,7 +29,6 @@ define([ UTCTimeFormat, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/formats", { "name": "Time services bundle", diff --git a/platform/commonUI/formats/src/FormatProvider.js b/platform/commonUI/formats/src/FormatProvider.js index e6d38fbcee..4df4a82d3d 100644 --- a/platform/commonUI/formats/src/FormatProvider.js +++ b/platform/commonUI/formats/src/FormatProvider.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ ], function ( ) { - "use strict"; /** * An object used to convert between numeric values and text values, diff --git a/platform/commonUI/formats/src/UTCTimeFormat.js b/platform/commonUI/formats/src/UTCTimeFormat.js index 3d216f8ff5..9e85f3ea1c 100644 --- a/platform/commonUI/formats/src/UTCTimeFormat.js +++ b/platform/commonUI/formats/src/UTCTimeFormat.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ 'moment' ], function ( moment ) { - "use strict"; var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss.SSS", DATE_FORMATS = [ diff --git a/platform/commonUI/formats/test/FormatProviderSpec.js b/platform/commonUI/formats/test/FormatProviderSpec.js index 4f68c106f7..94d951ff6a 100644 --- a/platform/commonUI/formats/test/FormatProviderSpec.js +++ b/platform/commonUI/formats/test/FormatProviderSpec.js @@ -19,18 +19,15 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../src/FormatProvider'], function (FormatProvider) { - 'use strict'; - var KEYS = [ 'a', 'b', 'c' ]; + var KEYS = ['a', 'b', 'c']; describe("The FormatProvider", function () { var mockFormats, - mockLog, mockFormatInstances, provider; @@ -38,12 +35,14 @@ define( mockFormatInstances = KEYS.map(function (k) { return jasmine.createSpyObj( 'format-' + k, - [ 'parse', 'validate', 'format' ] + ['parse', 'validate', 'format'] ); }); // Return constructors mockFormats = KEYS.map(function (k, i) { - function MockFormat() { return mockFormatInstances[i]; } + function MockFormat() { + return mockFormatInstances[i]; + } MockFormat.key = k; return MockFormat; }); diff --git a/platform/commonUI/formats/test/UTCTimeFormatSpec.js b/platform/commonUI/formats/test/UTCTimeFormatSpec.js index f8bda55b30..eebba54449 100644 --- a/platform/commonUI/formats/test/UTCTimeFormatSpec.js +++ b/platform/commonUI/formats/test/UTCTimeFormatSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../src/UTCTimeFormat', 'moment'], function (UTCTimeFormat, moment) { - 'use strict'; describe("The UTCTimeFormat", function () { var format; diff --git a/platform/commonUI/general/bundle.js b/platform/commonUI/general/bundle.js index 3e7f558e8b..daadacbc45 100644 --- a/platform/commonUI/general/bundle.js +++ b/platform/commonUI/general/bundle.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/services/UrlService", "./src/services/PopupService", "./src/SplashScreenManager", "./src/StyleSheetLoader", - "./src/UnsupportedBrowserWarning", "./src/controllers/TimeRangeController", "./src/controllers/DateTimePickerController", "./src/controllers/DateTimeFieldController", @@ -75,7 +73,6 @@ define([ PopupService, SplashScreenManager, StyleSheetLoader, - UnsupportedBrowserWarning, TimeRangeController, DateTimePickerController, DateTimeFieldController, @@ -120,7 +117,6 @@ define([ datetimeFieldTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/general", { "name": "General UI elements", @@ -153,13 +149,6 @@ define([ "THEME" ] }, - { - "implementation": UnsupportedBrowserWarning, - "depends": [ - "notificationService", - "agentService" - ] - }, { "implementation": SplashScreenManager, "depends": [ @@ -268,8 +257,8 @@ define([ "key": "ClickAwayController", "implementation": ClickAwayController, "depends": [ - "$scope", - "$document" + "$document", + "$timeout" ] }, { @@ -391,7 +380,7 @@ define([ { "key": "mctTree", "implementation": MCTTree, - "depends": [ '$parse', 'gestureService' ] + "depends": ['$parse', 'gestureService'] } ], "constants": [ diff --git a/platform/commonUI/general/res/sass/_archetypes.scss b/platform/commonUI/general/res/sass/_archetypes.scss index 84045c2520..4abad717ea 100644 --- a/platform/commonUI/general/res/sass/_archetypes.scss +++ b/platform/commonUI/general/res/sass/_archetypes.scss @@ -145,3 +145,8 @@ .flex-justify-end { @include justify-content(flex-end); } + +/********************************************* POPUPS */ +.t-popup { + z-index: 75; +} diff --git a/platform/commonUI/general/res/sass/_constants.scss b/platform/commonUI/general/res/sass/_constants.scss index 659025960f..c36a6cb00a 100644 --- a/platform/commonUI/general/res/sass/_constants.scss +++ b/platform/commonUI/general/res/sass/_constants.scss @@ -48,7 +48,7 @@ $uePaneMiniTabW: 10px; $uePaneMiniTabCollapsedW: 11px; $ueEditLeftPaneW: 75%; $treeSearchInputBarH: 25px; -$ueTimeControlH: (33px, 20px, 20px); +$ueTimeControlH: (33px, 18px, 20px); // Panes $ueBrowseLeftPaneTreeMinW: 150px; $ueBrowseLeftPaneTreeMaxW: 35%; diff --git a/platform/commonUI/general/res/sass/_global.scss b/platform/commonUI/general/res/sass/_global.scss index 27c08551df..f03aad1eb9 100644 --- a/platform/commonUI/general/res/sass/_global.scss +++ b/platform/commonUI/general/res/sass/_global.scss @@ -63,9 +63,10 @@ input, textarea { font-family: Helvetica, Arial, sans-serif; } -input[type="text"] { +input[type="text"], +input[type="search"] { vertical-align: baseline; - padding: 3px 5px !important; + padding: 3px 5px; } h1, h2, h3 { @@ -84,7 +85,11 @@ p { margin-bottom: $interiorMarginLg; } -ol, ul { padding-left: 0; } +ol, ul { + list-style: none; + margin: 0; + padding-left: 0; +} mct-container { display: block; diff --git a/platform/commonUI/general/res/sass/_mixins.scss b/platform/commonUI/general/res/sass/_mixins.scss index 02a3bb1583..d7fa694100 100644 --- a/platform/commonUI/general/res/sass/_mixins.scss +++ b/platform/commonUI/general/res/sass/_mixins.scss @@ -139,6 +139,17 @@ 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) { @include background-image(linear-gradient(-90deg, rgba($c, $a) 0%, rgba($c, $a) 50%, @@ -322,13 +333,13 @@ color: $fg; outline: none; &.error { - background: rgba(red, 0.5); + background-color: $colorFormFieldErrorBg; + color: $colorFormFieldErrorFg; } } @mixin nice-input($bg: $colorInputBg, $fg: $colorInputFg) { @include input-base($bg, $fg); - padding: 0 $interiorMarginSm; } @mixin contextArrow() { diff --git a/platform/commonUI/general/res/sass/controls/_controls.scss b/platform/commonUI/general/res/sass/controls/_controls.scss index a2bb0b73bb..9cc835348b 100644 --- a/platform/commonUI/general/res/sass/controls/_controls.scss +++ b/platform/commonUI/general/res/sass/controls/_controls.scss @@ -29,7 +29,7 @@ .accordion-head { $op: 0.2; border-radius: $basicCr * 0.75; - box-sizing: "border-box"; + box-sizing: border-box; background: rgba($colorBodyFg, $op); cursor: pointer; font-size: 0.75em; @@ -279,21 +279,13 @@ input[type="search"] { padding-right: 0.35em; // For context arrow. Done with em's so pad is relative to the scale of the text. } + .context-available-w { + z-index: 5; + } + .context-available { font-size: 0.7em; - @include webkitProp(flex, '0 0 1'); - } -} - -body.desktop .object-header { - .context-available { - @include trans-prop-nice(opacity, 0.25s); - opacity: 0; - } - &:hover { - .context-available { - opacity: 1; - } + @include flex(0 0 1); } } @@ -404,11 +396,11 @@ body.desktop .object-header { left: auto; } .knob-l { - @include border-left-radius($sliderKnobW); + @include border-left-radius($sliderKnobR); cursor: w-resize; } .knob-r { - @include border-right-radius($sliderKnobW); + @include border-right-radius($sliderKnobR); cursor: e-resize; } .range { @@ -434,7 +426,6 @@ body.desktop .object-header { @include user-select(none); font-size: 0.8rem; padding: $interiorMarginLg !important; - width: 230px; .l-month-year-pager { $pagerW: 20px; height: $r1H; @@ -526,6 +517,19 @@ body.desktop .object-header { } } +@include phone { + .l-datetime-picker { + padding: $interiorMargin !important; + } + .l-calendar { + ul.l-cal-row { + li { + padding: 2px $interiorMargin; + } + } + } +} + /******************************************************** TEXTAREA */ textarea { @include nice-textarea($colorInputBg, $colorInputFg); diff --git a/platform/commonUI/general/res/sass/controls/_time-controller.scss b/platform/commonUI/general/res/sass/controls/_time-controller.scss index f6201d60cf..ba2cf5b3ee 100644 --- a/platform/commonUI/general/res/sass/controls/_time-controller.scss +++ b/platform/commonUI/general/res/sass/controls/_time-controller.scss @@ -10,25 +10,24 @@ $knobHOffset: 0px; $knobM: ($sliderKnobW + $knobHOffset) * -1; $rangeValPad: $interiorMargin; - $rangeValOffset: $sliderKnobW; - $timeRangeSliderLROffset: 130px + $sliderKnobW + $rangeValOffset; - $r1H: nth($ueTimeControlH,1); + $rangeValOffset: $sliderKnobW + $interiorMargin; + $timeRangeSliderLROffset: 150px + ($sliderKnobW * 2); + $r1H: nth($ueTimeControlH,1); // Not currently used $r2H: nth($ueTimeControlH,2); $r3H: nth($ueTimeControlH,3); - display: block; - height: $r1H + $r2H + $r3H + ($interiorMargin * 2); min-width: $minW; font-size: 0.8rem; - .l-time-range-inputs-holder, .l-time-range-slider-holder, .l-time-range-ticks-holder { - @include absPosDefault(0, visible); box-sizing: border-box; - top: auto; + position: relative; + &:not(:first-child) { + margin-top: $interiorMargin; + } } .l-time-range-slider, .l-time-range-ticks { @@ -37,14 +36,21 @@ } .l-time-range-inputs-holder { - height: $r1H; bottom: $r2H + $r3H + ($interiorMarginSm * 2); - padding-top: $interiorMargin; 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 { font-size: 120%; vertical-align: middle; } - .l-time-range-input, + .l-time-range-input-w, .l-time-range-inputs-elem { margin-right: $interiorMargin; .lbl { @@ -52,13 +58,27 @@ } .ui-symbol.icon { 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 { - height: $r2H; bottom: $r3H + ($interiorMarginSm * 1); + height: $r2H; .range-holder { box-shadow: none; background: none; @@ -73,24 +93,13 @@ width: $myW; height: auto; z-index: 2; - &:before, - &:after { - background-color: $myC; - content: ""; - position: absolute; - } &:before { // Vert line + background-color: $myC; + position: absolute; + content: ""; top: 0; right: auto; bottom: -10px; left: floor($myW/2) - 1; - width: 2px; - } - &:after { - // Circle element - border-radius: $myW; - @include transform(translateY(-50%)); - top: 50%; right: 0; bottom: auto; left: 0; - width: auto; - height: $myW; + width: 1px; } } &:hover .toi-line { @@ -126,9 +135,9 @@ @include webkitProp(transform, translateX(-50%)); color: $colorPlotLabelFg; display: inline-block; - font-size: 0.9em; + font-size: 0.7rem; position: absolute; - top: 8px; + top: 5px; white-space: nowrap; z-index: 2; } @@ -138,16 +147,29 @@ .knob { 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 { @include trans-prop-nice-fade(.25s); - padding: 0 $rangeValOffset; + font-size: 0.7rem; position: absolute; height: $r2H; line-height: $r2H; - white-space: nowrap; + white-space: nowrap; + z-index: 1; } - &:hover .range-value { - color: $sliderColorKnobHov; + &:hover { + .range-value { + color: $sliderColorKnobHov; + } } &.knob-l { margin-left: $knobM; @@ -170,7 +192,7 @@ .l-time-domain-selector { position: absolute; right: 0px; - bottom: 46px; + top: $interiorMargin; } } @@ -181,174 +203,64 @@ padding: 1px 1px 0 $interiorMargin; } +/******************************************************************** MOBILE */ + @include phoneandtablet { - .l-time-controller, .l-time-range-inputs-holder { - min-width: 0px; - } - - .l-time-controller { - - .l-time-domain-selector { - select { - height: 25px; - margin-bottom: 0px; - } - } - - .l-time-range-slider-holder, .l-time-range-ticks-holder { - 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 { - - } - } - } + .l-time-controller { + min-width: 0; + .l-time-range-slider-holder, + .l-time-range-ticks-holder { + display: none; + } + } } @include phone { - .l-time-controller { - height: 48px; - - .l-time-range-inputs-holder { - bottom: 24px; - } - - .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 { - &.ui-symbol { - display: none; - } - - &.lbl { - width: 33%; - right: 0px; - top: 5px; - display: block; - height: 25px; - margin: 0; - line-height: 25px; - position: absolute; - } - } - } - } + .l-time-controller { + .l-time-range-inputs-holder { + &.l-flex-row, + .l-flex-row { + @include align-items(flex-start); + } + .l-time-range-inputs-elem { + &.type-icon { + margin-top: 3px; + } + } + .t-inputs-w { + @include flex-direction(column); + .l-time-range-input-w:not(:first-child) { + &:not(:first-child) { + margin-top: $interiorMargin; + } + margin-right: 0; + } + .l-time-range-inputs-elem { + &.lbl { display: none; } + } + } + } + } } - -@include tablet { - .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 { - float: left; - .s-btn { - width: 100%; - padding-left: 4px; - } - } - } - } -} - -@include tabletLandscape { - .l-time-controller { - height: 17px; - - .l-time-range-inputs-holder { - bottom: -7px; - } - - .l-time-domain-selector { - width: 23%; - right: auto; - bottom: -10px; - 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; - } - } - } - } +@include phonePortrait { + .l-time-controller { + .l-time-range-inputs-holder { + .t-inputs-w { + @include flex(1 1 auto); + padding-top: 25px; // Make room for the ever lovin' Time Domain Selector + .flex-elem { + @include flex(1 1 auto); + width: 100%; + } + input[type="text"] { + width: 100%; + } + } + } + } + .l-time-domain-selector { + right: auto; + left: 20px; + } } diff --git a/platform/commonUI/general/res/sass/user-environ/_layout.scss b/platform/commonUI/general/res/sass/user-environ/_layout.scss index 99d8fb9d14..9e8e9aaae1 100644 --- a/platform/commonUI/general/res/sass/user-environ/_layout.scss +++ b/platform/commonUI/general/res/sass/user-environ/_layout.scss @@ -194,7 +194,7 @@ body.desktop .pane .mini-tab-icon.toggle-pane { .holder.holder-treeview-elements { top: $bodyMargin; right: 0; - bottom: $bodyMargin; + bottom: $interiorMargin; left: $bodyMargin; .create-btn-holder { &.s-status-editing { @@ -215,17 +215,17 @@ body.desktop .pane .mini-tab-icon.toggle-pane { left: 0; .holder-object { top: $bodyMargin; - bottom: $bodyMargin; + bottom: $interiorMargin; } .holder-inspector { top: $bodyMargin; - bottom: $bodyMargin; + bottom: $interiorMargin; left: $bodyMargin; right: $bodyMargin; } .holder-elements { top: 0; - bottom: $bodyMargin; + bottom: $interiorMargin; left: $bodyMargin; right: $bodyMargin; } diff --git a/platform/commonUI/general/res/templates/controls/datetime-field.html b/platform/commonUI/general/res/templates/controls/datetime-field.html index 18eb9ec46d..47551fa25b 100644 --- a/platform/commonUI/general/res/templates/controls/datetime-field.html +++ b/platform/commonUI/general/res/templates/controls/datetime-field.html @@ -19,18 +19,17 @@ this source code distribution or the Licensing information page available at runtime from the About dialog for additional information. --> - + - - @@ -38,8 +37,7 @@
    + field="'value'">
    diff --git a/platform/commonUI/general/res/templates/controls/time-controller.html b/platform/commonUI/general/res/templates/controls/time-controller.html index 281447e251..cd36236358 100644 --- a/platform/commonUI/general/res/templates/controls/time-controller.html +++ b/platform/commonUI/general/res/templates/controls/time-controller.html @@ -19,42 +19,43 @@ this source code distribution or the Licensing information page available at runtime from the About dialog for additional information. --> -
    -
    + - C - - - + C + + + + + + + to + + + + + - - to - - - -   - - -
    +
    @@ -85,7 +86,7 @@
    -
    +
    ", - OFFSETS_BY_EDGE = { - left: "offsetLeft", - right: "offsetRight", - top: "offsetTop", - bottom: "offsetBottom" - }; + "mct-drag-up=\"splitter.endMove()\">
    "; /** * Implements `mct-splitter` directive. @@ -52,7 +44,6 @@ define( scope.splitter = { // Begin moving this splitter startMove: function () { - var splitter = element[0]; initialPosition = mctSplitPane.position(); mctSplitPane.toggleClass('resizing'); }, @@ -68,7 +59,7 @@ define( }, // Grab the event when the user is done moving // the splitter and pass it on - endMove: function() { + endMove: function () { mctSplitPane.toggleClass('resizing'); } }; diff --git a/platform/commonUI/general/src/directives/MCTTree.js b/platform/commonUI/general/src/directives/MCTTree.js index 47f8eecbc6..139a2feb38 100644 --- a/platform/commonUI/general/src/directives/MCTTree.js +++ b/platform/commonUI/general/src/directives/MCTTree.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ 'angular', diff --git a/platform/commonUI/general/src/filters/ReverseFilter.js b/platform/commonUI/general/src/filters/ReverseFilter.js index 16ab9bc882..6834cf3a62 100644 --- a/platform/commonUI/general/src/filters/ReverseFilter.js +++ b/platform/commonUI/general/src/filters/ReverseFilter.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define(function () { - 'use strict'; /** * Implements the `reverse` filter, which reverses text strings. diff --git a/platform/commonUI/general/src/services/Popup.js b/platform/commonUI/general/src/services/Popup.js index 6029ca29cb..e05901a4d8 100644 --- a/platform/commonUI/general/src/services/Popup.js +++ b/platform/commonUI/general/src/services/Popup.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( function () { - "use strict"; /** * A popup is an element that has been displayed at a particular diff --git a/platform/commonUI/general/src/services/PopupService.js b/platform/commonUI/general/src/services/PopupService.js index f834609f2c..d6b08e752f 100644 --- a/platform/commonUI/general/src/services/PopupService.js +++ b/platform/commonUI/general/src/services/PopupService.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./Popup'], function (Popup) { - "use strict"; /** * Displays popup elements at specific positions within the document. @@ -80,11 +78,10 @@ define( var $document = this.$document, $window = this.$window, body = $document.find('body'), - winDim = [ $window.innerWidth, $window.innerHeight ], + winDim = [$window.innerWidth, $window.innerHeight], styles = { position: 'absolute' }, margin, - offset, - bubble; + offset; function adjustNegatives(value, index) { return value < 0 ? (value + winDim[index]) : value; @@ -96,7 +93,7 @@ define( options.offsetX !== undefined ? options.offsetX : 0, options.offsetY !== undefined ? options.offsetY : 0 ]; - margin = [ options.marginX, options.marginY ].map(function (m, i) { + margin = [options.marginX, options.marginY].map(function (m, i) { return m === undefined ? (winDim[i] / 2) : m; }).map(adjustNegatives); diff --git a/platform/commonUI/general/src/services/UrlService.js b/platform/commonUI/general/src/services/UrlService.js index 5d57b03ca0..af0204c24d 100644 --- a/platform/commonUI/general/src/services/UrlService.js +++ b/platform/commonUI/general/src/services/UrlService.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining UrlService. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * The url service handles calls for url paths @@ -52,8 +50,8 @@ define( var context = domainObject && domainObject.getCapability('context'), objectPath = context ? context.getPath() : [], - ids = objectPath.map(function (domainObject) { - return domainObject.getId(); + ids = objectPath.map(function (domainObj) { + return domainObj.getId(); }); // Parses the path together. Starts with the diff --git a/platform/commonUI/general/src/ui/ToggleView.js b/platform/commonUI/general/src/ui/ToggleView.js index c347ac3837..529984bab1 100644 --- a/platform/commonUI/general/src/ui/ToggleView.js +++ b/platform/commonUI/general/src/ui/ToggleView.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ 'zepto', diff --git a/platform/commonUI/general/src/ui/TreeLabelView.js b/platform/commonUI/general/src/ui/TreeLabelView.js index 75e8efcc29..98a82c963d 100644 --- a/platform/commonUI/general/src/ui/TreeLabelView.js +++ b/platform/commonUI/general/src/ui/TreeLabelView.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ 'zepto', 'text!../../res/templates/tree/tree-label.html' ], function ($, labelTemplate) { - 'use strict'; function TreeLabelView(gestureService) { this.el = $(labelTemplate); @@ -77,7 +75,7 @@ define([ this.activeGestures = this.gestureService.attachGestures( this.elements(), domainObject, - [ 'info', 'menu', 'drag' ] + ['info', 'menu', 'drag'] ); } }; diff --git a/platform/commonUI/general/src/ui/TreeNodeView.js b/platform/commonUI/general/src/ui/TreeNodeView.js index 14ff0f3233..13b28bb473 100644 --- a/platform/commonUI/general/src/ui/TreeNodeView.js +++ b/platform/commonUI/general/src/ui/TreeNodeView.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ 'zepto', @@ -27,7 +26,6 @@ define([ './ToggleView', './TreeLabelView' ], function ($, nodeTemplate, ToggleView, TreeLabelView) { - 'use strict'; function TreeNodeView(gestureService, subtreeFactory, selectFn) { this.li = $('
  • '); @@ -107,8 +105,8 @@ define([ function getIdPath(domainObject) { var context = domainObject && domainObject.getCapability('context'); - function getId(domainObject) { - return domainObject.getId(); + function getId(domainObj) { + return domainObj.getId(); } return context ? context.getPath().map(getId) : []; diff --git a/platform/commonUI/general/src/ui/TreeView.js b/platform/commonUI/general/src/ui/TreeView.js index b1b394ae4c..07d155e960 100644 --- a/platform/commonUI/general/src/ui/TreeView.js +++ b/platform/commonUI/general/src/ui/TreeView.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ 'zepto', './TreeNodeView', 'text!../../res/templates/tree/wait-node.html' ], function ($, TreeNodeView, spinnerTemplate) { - 'use strict'; function TreeView(gestureService, selectFn) { this.ul = $('
      '); @@ -64,8 +62,8 @@ define([ var self = this, domainObject = this.activeObject; - function addNode(domainObject, index) { - self.nodeViews[index].model(domainObject); + function addNode(domainObj, index) { + self.nodeViews[index].model(domainObj); } function addNodes(domainObjects) { diff --git a/platform/commonUI/general/test/SplashScreenManagerSpec.js b/platform/commonUI/general/test/SplashScreenManagerSpec.js index b1d340fe58..1e82190326 100644 --- a/platform/commonUI/general/test/SplashScreenManagerSpec.js +++ b/platform/commonUI/general/test/SplashScreenManagerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,jasmine,it,expect*/ define([ '../src/SplashScreenManager' ], function (SplashScreenManager) { - 'use strict'; describe('SplashScreenManager', function () { var $document, @@ -54,7 +52,7 @@ define([ describe('when element exists', function () { beforeEach(function () { $document.querySelectorAll.andReturn([splashElement]); - new SplashScreenManager([$document]); + return new SplashScreenManager([$document]); }); it('adds fade out class', function () { @@ -81,7 +79,7 @@ define([ $document.querySelectorAll.andReturn([]); function run() { - new SplashScreenManager([$document]); + return new SplashScreenManager([$document]); } expect(run).not.toThrow(); diff --git a/platform/commonUI/general/test/StyleSheetLoaderSpec.js b/platform/commonUI/general/test/StyleSheetLoaderSpec.js index c1db25fb0a..fe6d8bcc50 100644 --- a/platform/commonUI/general/test/StyleSheetLoaderSpec.js +++ b/platform/commonUI/general/test/StyleSheetLoaderSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/StyleSheetLoader"], function (StyleSheetLoader) { - "use strict"; describe("The style sheet loader", function () { var testStyleSheets, @@ -49,7 +47,7 @@ define( mockPlainDocument = jasmine.createSpyObj("document", ["createElement"]); - mockDocument = [ mockPlainDocument ]; + mockDocument = [mockPlainDocument]; mockDocument.find = jasmine.createSpy("$document.find"); mockHead = jasmine.createSpyObj("head", ["append"]); mockElement = jasmine.createSpyObj("link", ["setAttribute"]); diff --git a/platform/commonUI/general/test/UnsupportedBrowserWarningSpec.js b/platform/commonUI/general/test/UnsupportedBrowserWarningSpec.js deleted file mode 100644 index 507a92c62f..0000000000 --- a/platform/commonUI/general/test/UnsupportedBrowserWarningSpec.js +++ /dev/null @@ -1,98 +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. - *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ - -define( - ["../src/UnsupportedBrowserWarning"], - function (UnsupportedBrowserWarning) { - "use strict"; - - var MOBILE_BROWSER = "Safari", - DESKTOP_BROWSER = "Chrome", - UNSUPPORTED_BROWSERS = [ - "Firefox", - "IE", - "Opera", - "Iceweasel" - ]; - - describe("The unsupported browser warning", function () { - var mockNotificationService, - mockAgentService, - testAgent; - - function instantiateWith(browser) { - testAgent = "Mozilla/5.0 " + browser + "/12.34.56"; - return new UnsupportedBrowserWarning( - mockNotificationService, - mockAgentService - ); - } - - beforeEach(function () { - testAgent = "chrome"; - mockNotificationService = jasmine.createSpyObj( - "notificationService", - [ "alert" ] - ); - mockAgentService = jasmine.createSpyObj( - "agentService", - [ "isMobile", "isBrowser" ] - ); - mockAgentService.isBrowser.andCallFake(function (substr) { - substr = substr.toLowerCase(); - return testAgent.toLowerCase().indexOf(substr) !== -1; - }); - }); - - [ false, true ].forEach(function (isMobile) { - var deviceType = isMobile ? "mobile" : "desktop", - goodBrowser = isMobile ? MOBILE_BROWSER : DESKTOP_BROWSER, - badBrowsers = UNSUPPORTED_BROWSERS.concat([ - isMobile ? DESKTOP_BROWSER : MOBILE_BROWSER - ]); - - describe("on " + deviceType + " devices", function () { - beforeEach(function () { - mockAgentService.isMobile.andReturn(isMobile); - }); - - it("is not shown for " + goodBrowser, function () { - instantiateWith(goodBrowser); - expect(mockNotificationService.alert) - .not.toHaveBeenCalled(); - }); - - badBrowsers.forEach(function (badBrowser) { - it("is shown for " + badBrowser, function () { - instantiateWith(badBrowser); - expect(mockNotificationService.alert) - .toHaveBeenCalled(); - }); - }); - }); - }); - - }); - } -); - diff --git a/platform/commonUI/general/test/controllers/ActionGroupControllerSpec.js b/platform/commonUI/general/test/controllers/ActionGroupControllerSpec.js index 5fc8b2a8b3..4e0195f09d 100644 --- a/platform/commonUI/general/test/controllers/ActionGroupControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ActionGroupControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/ActionGroupController"], function (ActionGroupController) { - "use strict"; describe("The action group controller", function () { var mockScope, @@ -94,4 +92,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/controllers/BottomBarControllerSpec.js b/platform/commonUI/general/test/controllers/BottomBarControllerSpec.js index bf008becb8..cc58d4558c 100644 --- a/platform/commonUI/general/test/controllers/BottomBarControllerSpec.js +++ b/platform/commonUI/general/test/controllers/BottomBarControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/BottomBarController"], function (BottomBarController) { - "use strict"; describe("The bottom bar controller", function () { var testIndicators, @@ -37,11 +35,13 @@ define( beforeEach(function () { mockIndicator = jasmine.createSpyObj( "indicator", - [ "getGlyph", "getText" ] + ["getGlyph", "getText"] ); testIndicatorA = {}; - testIndicatorB = function () { return mockIndicator; }; + testIndicatorB = function () { + return mockIndicator; + }; testIndicatorC = { template: "someTemplate" }; testIndicators = [ @@ -73,4 +73,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js b/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js index 96e7b6c13f..e2b9f62c91 100644 --- a/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js @@ -19,28 +19,26 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/ClickAwayController"], function (ClickAwayController) { - "use strict"; describe("The click-away controller", function () { - var mockScope, - mockDocument, + var mockDocument, + mockTimeout, controller; beforeEach(function () { - mockScope = jasmine.createSpyObj( - "$scope", - [ "$apply" ] - ); mockDocument = jasmine.createSpyObj( "$document", - [ "on", "off" ] + ["on", "off"] + ); + mockTimeout = jasmine.createSpy('timeout'); + controller = new ClickAwayController( + mockDocument, + mockTimeout ); - controller = new ClickAwayController(mockScope, mockDocument); }); it("is initially inactive", function () { @@ -79,10 +77,12 @@ define( }); it("deactivates and detaches listener on document click", function () { - var callback; + var callback, timeout; controller.setState(true); callback = mockDocument.on.mostRecentCall.args[1]; callback(); + timeout = mockTimeout.mostRecentCall.args[0]; + timeout(); expect(controller.isActive()).toEqual(false); expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback); }); @@ -91,4 +91,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/controllers/ContextMenuControllerSpec.js b/platform/commonUI/general/test/controllers/ContextMenuControllerSpec.js index f74f418bbc..0f56caa714 100644 --- a/platform/commonUI/general/test/controllers/ContextMenuControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ContextMenuControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/ContextMenuController"], function (ContextMenuController) { - "use strict"; describe("The context menu controller", function () { var mockScope, @@ -59,4 +57,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/controllers/DateTimeFieldControllerSpec.js b/platform/commonUI/general/test/controllers/DateTimeFieldControllerSpec.js index 7d71095772..a36e1e17fb 100644 --- a/platform/commonUI/general/test/controllers/DateTimeFieldControllerSpec.js +++ b/platform/commonUI/general/test/controllers/DateTimeFieldControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/DateTimeFieldController", "moment"], function (DateTimeFieldController, moment) { - 'use strict'; var TEST_FORMAT = "YYYY-MM-DD HH:mm:ss"; diff --git a/platform/commonUI/general/test/controllers/DateTimePickerControllerSpec.js b/platform/commonUI/general/test/controllers/DateTimePickerControllerSpec.js index 78f5e973ff..0f7b4069ad 100644 --- a/platform/commonUI/general/test/controllers/DateTimePickerControllerSpec.js +++ b/platform/commonUI/general/test/controllers/DateTimePickerControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/DateTimePickerController", "moment"], function (DateTimePickerController, moment) { - "use strict"; describe("The DateTimePickerController", function () { var mockScope, @@ -50,7 +48,7 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "$apply", "$watch", "$watchCollection" ] + ["$apply", "$watch", "$watchCollection"] ); mockScope.ngModel = {}; mockScope.field = "testField"; diff --git a/platform/commonUI/general/test/controllers/GetterSetterControllerSpec.js b/platform/commonUI/general/test/controllers/GetterSetterControllerSpec.js index a599dd8947..a9b1ff7440 100644 --- a/platform/commonUI/general/test/controllers/GetterSetterControllerSpec.js +++ b/platform/commonUI/general/test/controllers/GetterSetterControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/GetterSetterController"], function (GetterSetterController) { - "use strict"; describe("The getter-setter controller", function () { var mockScope, @@ -82,4 +80,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js b/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js index 496467ea2d..197a5f3745 100644 --- a/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * Created by shale on 08/24/2015. @@ -27,7 +26,6 @@ define( ["../../src/controllers/ObjectInspectorController"], function (ObjectInspectorController) { - "use strict"; describe("The object inspector controller ", function () { var mockScope, @@ -41,35 +39,35 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "$watch" ] + ["$watch"] ); mockScope.ngModel = {}; mockScope.ngModel.selectedObject = 'mock selected object'; - + mockObjectService = jasmine.createSpyObj( "objectService", - [ "getObjects" ] + ["getObjects"] ); mockPromise = jasmine.createSpyObj( "promise", - [ "then" ] + ["then"] ); mockObjectService.getObjects.andReturn(mockPromise); - + mockDomainObject = jasmine.createSpyObj( "selectedObject", - [ "hasCapability", "getCapability", "useCapability", "getModel" ] + ["hasCapability", "getCapability", "useCapability", "getModel"] ); mockDomainObject.getModel.andReturn({location: 'somewhere'}); mockDomainObject.hasCapability.andReturn(true); - + mockContextCapability = jasmine.createSpyObj( "context capability", - [ "getParent" ] + ["getParent"] ); mockLocationCapability = jasmine.createSpyObj( "location capability", - [ "isLink" ] + ["isLink"] ); mockDomainObject.getCapability.andCallFake(function (param) { if (param === 'location') { @@ -78,9 +76,9 @@ define( return mockContextCapability; } }); - + controller = new ObjectInspectorController(mockScope, mockObjectService); - + // Change the selected object to trigger the watch call mockScope.ngModel.selectedObject = mockDomainObject; }); @@ -96,17 +94,17 @@ define( it("if link, looks for primary parent objects", function () { mockLocationCapability.isLink.andReturn(true); - + mockScope.$watch.mostRecentCall.args[1](); expect(mockDomainObject.getModel).toHaveBeenCalled(); expect(mockObjectService.getObjects).toHaveBeenCalled(); mockPromise.then.mostRecentCall.args[0]({'somewhere': mockDomainObject}); }); - + it("gets metadata", function () { mockScope.$watch.mostRecentCall.args[1](); expect(mockDomainObject.useCapability).toHaveBeenCalledWith('metadata'); }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/controllers/SelectorControllerSpec.js b/platform/commonUI/general/test/controllers/SelectorControllerSpec.js index 205ef9e791..584c7fb8bb 100644 --- a/platform/commonUI/general/test/controllers/SelectorControllerSpec.js +++ b/platform/commonUI/general/test/controllers/SelectorControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/SelectorController"], function (SelectorController) { - "use strict"; describe("The controller for the 'selector' control", function () { var mockObjectService, @@ -45,7 +43,7 @@ define( function makeMockObject(id) { var mockObject = jasmine.createSpyObj( 'object-' + id, - [ 'getId' ] + ['getId'] ); mockObject.getId.andReturn(id); return mockObject; @@ -62,15 +60,15 @@ define( ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getCapability', 'hasCapability' ] + ['getCapability', 'hasCapability'] ); mockType = jasmine.createSpyObj( 'type', - [ 'instanceOf' ] + ['instanceOf'] ); mockDomainObjects = {}; - [ "ROOT", "abc", "def", "xyz" ].forEach(function (id) { + ["ROOT", "abc", "def", "xyz"].forEach(function (id) { mockDomainObjects[id] = makeMockObject(id); }); @@ -100,7 +98,7 @@ define( }); it("watches for changes in controlled property", function () { - var testValue = [ "a", "b", 1, 2 ]; + var testValue = ["a", "b", 1, 2]; // This test is sensitive to ordering of watch calls expect(mockScope.$watchCollection.calls.length).toEqual(1); // Make sure we're watching the correct object @@ -133,7 +131,7 @@ define( }); it("loads objects when the underlying list changes", function () { - var testIds = [ "abc", "def", "xyz" ]; + var testIds = ["abc", "def", "xyz"]; // This test is sensitive to ordering of watch calls expect(mockScope.$watchCollection.calls.length).toEqual(1); // Make sure we're watching the correct object diff --git a/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js b/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js index 20ad0413b6..718dd2664f 100644 --- a/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js +++ b/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/TimeRangeController", "moment"], function (TimeRangeController, moment) { - "use strict"; var SEC = 1000, MIN = 60 * SEC, @@ -58,16 +56,16 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "$apply", "$watch", "$watchCollection" ] + ["$apply", "$watch", "$watchCollection"] ); mockFormatService = jasmine.createSpyObj( "formatService", - [ "getFormat" ] + ["getFormat"] ); testDefaultFormat = 'utc'; mockFormat = jasmine.createSpyObj( "format", - [ "validate", "format", "parse" ] + ["validate", "format", "parse"] ); mockFormatService.getFormat.andReturn(mockFormat); diff --git a/platform/commonUI/general/test/controllers/ToggleControllerSpec.js b/platform/commonUI/general/test/controllers/ToggleControllerSpec.js index b690d0fe44..e4f56237ca 100644 --- a/platform/commonUI/general/test/controllers/ToggleControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ToggleControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/ToggleController"], function (ToggleController) { - "use strict"; describe("The toggle controller", function () { var controller; @@ -61,4 +59,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js b/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js index 62a40d0586..0a196b10a8 100644 --- a/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js +++ b/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/controllers/TreeNodeController"], function (TreeNodeController) { - "use strict"; describe("The tree node controller", function () { var mockScope, @@ -34,7 +32,9 @@ define( function TestObject(id, context) { return { - getId: function () { return id; }, + getId: function () { + return id; + }, getCapability: function (key) { return key === 'context' ? context : undefined; } @@ -46,7 +46,7 @@ define( mockTimeout = jasmine.createSpy("$timeout"); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "getModel", "useCapability" ] + ["getId", "getCapability", "getModel", "useCapability"] ); controller = new TreeNodeController(mockScope, mockTimeout); @@ -73,7 +73,7 @@ define( // This is needed to highlight the current selection var mockContext = jasmine.createSpyObj( "context", - [ "getParent", "getPath", "getRoot" ] + ["getParent", "getPath", "getRoot"] ), obj = new TestObject("test-object", mockContext); @@ -94,11 +94,11 @@ define( it("expands a node if it is on the navigation path", function () { var mockParentContext = jasmine.createSpyObj( "parentContext", - [ "getParent", "getPath", "getRoot" ] + ["getParent", "getPath", "getRoot"] ), mockChildContext = jasmine.createSpyObj( "childContext", - [ "getParent", "getPath", "getRoot" ] + ["getParent", "getPath", "getRoot"] ), parent = new TestObject("parent", mockParentContext), child = new TestObject("child", mockChildContext); @@ -130,11 +130,11 @@ define( it("does not expand a node if it is not on the navigation path", function () { var mockParentContext = jasmine.createSpyObj( "parentContext", - [ "getParent", "getPath", "getRoot" ] + ["getParent", "getPath", "getRoot"] ), mockChildContext = jasmine.createSpyObj( "childContext", - [ "getParent", "getPath", "getRoot" ] + ["getParent", "getPath", "getRoot"] ), parent = new TestObject("parent", mockParentContext), child = new TestObject("child", mockChildContext); @@ -163,11 +163,11 @@ define( it("does not expand a node if no context is available", function () { var mockParentContext = jasmine.createSpyObj( "parentContext", - [ "getParent", "getPath", "getRoot" ] + ["getParent", "getPath", "getRoot"] ), mockChildContext = jasmine.createSpyObj( "childContext", - [ "getParent", "getPath", "getRoot" ] + ["getParent", "getPath", "getRoot"] ), parent = new TestObject("parent", mockParentContext), child = new TestObject("child", undefined); diff --git a/platform/commonUI/general/test/controllers/ViewSwitcherControllerSpec.js b/platform/commonUI/general/test/controllers/ViewSwitcherControllerSpec.js index 125f48a7ad..fb381e680d 100644 --- a/platform/commonUI/general/test/controllers/ViewSwitcherControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ViewSwitcherControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/controllers/ViewSwitcherController"], function (ViewSwitcherController) { - "use strict"; describe("The view switcher controller", function () { var mockScope, @@ -35,9 +33,11 @@ define( controller; beforeEach(function () { - mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]); + mockScope = jasmine.createSpyObj("$scope", ["$watch"]); mockTimeout = jasmine.createSpy("$timeout"); - mockTimeout.andCallFake(function (cb) { cb(); }); + mockTimeout.andCallFake(function (cb) { + cb(); + }); mockScope.ngModel = {}; controller = new ViewSwitcherController(mockScope, mockTimeout); }); @@ -110,4 +110,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/directives/MCTClickElsewhereSpec.js b/platform/commonUI/general/test/directives/MCTClickElsewhereSpec.js index 1d8fe5e5ce..2e782a1a01 100644 --- a/platform/commonUI/general/test/directives/MCTClickElsewhereSpec.js +++ b/platform/commonUI/general/test/directives/MCTClickElsewhereSpec.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/directives/MCTClickElsewhere"], function (MCTClickElsewhere) { - "use strict"; - var JQLITE_METHODS = [ "on", "off", "find", "parent" ]; + var JQLITE_METHODS = ["on", "off", "find", "parent"]; describe("The mct-click-elsewhere directive", function () { var mockDocument, @@ -50,7 +48,7 @@ define( mockDocument = jasmine.createSpyObj("$document", JQLITE_METHODS); mockScope = - jasmine.createSpyObj("$scope", [ "$eval", "$apply", "$on" ]); + jasmine.createSpyObj("$scope", ["$eval", "$apply", "$on"]); mockElement = jasmine.createSpyObj("element", JQLITE_METHODS); mockBody = diff --git a/platform/commonUI/general/test/directives/MCTContainerSpec.js b/platform/commonUI/general/test/directives/MCTContainerSpec.js index 0c25e6c645..745131c30c 100644 --- a/platform/commonUI/general/test/directives/MCTContainerSpec.js +++ b/platform/commonUI/general/test/directives/MCTContainerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/directives/MCTContainer"], function (MCTContainer) { - "use strict"; describe("The mct-container directive", function () { var testContainers = [ @@ -37,7 +35,7 @@ define( bundle: { path: "x", resources: "y" }, template: "bar", key: "xyz", - attributes: [ "someAttr", "someOtherAttr" ] + attributes: ["someAttr", "someOtherAttr"] } ], mctContainer; @@ -87,4 +85,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/directives/MCTDragSpec.js b/platform/commonUI/general/test/directives/MCTDragSpec.js index 1d4568f72b..3160660906 100644 --- a/platform/commonUI/general/test/directives/MCTDragSpec.js +++ b/platform/commonUI/general/test/directives/MCTDragSpec.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/directives/MCTDrag"], function (MCTDrag) { - "use strict"; - var JQLITE_METHODS = [ "on", "off", "find" ]; + var JQLITE_METHODS = ["on", "off", "find"]; describe("The mct-drag directive", function () { var mockDocument, @@ -48,7 +46,7 @@ define( mockDocument = jasmine.createSpyObj("$document", JQLITE_METHODS); mockScope = - jasmine.createSpyObj("$scope", [ "$eval", "$apply" ]); + jasmine.createSpyObj("$scope", ["$eval", "$apply"]); mockElement = jasmine.createSpyObj("element", JQLITE_METHODS); mockBody = diff --git a/platform/commonUI/general/test/directives/MCTPopupSpec.js b/platform/commonUI/general/test/directives/MCTPopupSpec.js index 2cd6598180..372dd4b042 100644 --- a/platform/commonUI/general/test/directives/MCTPopupSpec.js +++ b/platform/commonUI/general/test/directives/MCTPopupSpec.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/directives/MCTPopup"], function (MCTPopup) { - "use strict"; - var JQLITE_METHODS = [ "on", "off", "find", "parent", "css", "append" ]; + var JQLITE_METHODS = ["on", "off", "find", "parent", "css", "append"]; describe("The mct-popup directive", function () { var mockCompile, @@ -42,14 +40,6 @@ define( testRect, mctPopup; - function testEvent(x, y) { - return { - pageX: x, - pageY: y, - preventDefault: jasmine.createSpy("preventDefault") - }; - } - beforeEach(function () { mockCompile = jasmine.createSpy("$compile"); @@ -58,7 +48,7 @@ define( mockPopup = jasmine.createSpyObj("popup", ["dismiss"]); mockScope = - jasmine.createSpyObj("$scope", [ "$eval", "$apply", "$on" ]); + jasmine.createSpyObj("$scope", ["$eval", "$apply", "$on"]); mockElement = jasmine.createSpyObj("element", JQLITE_METHODS); mockBody = @@ -108,7 +98,7 @@ define( it("displays as a popup", function () { expect(mockPopupService.display).toHaveBeenCalledWith( mockNewElement, - [ testRect.left, testRect.top ] + [testRect.left, testRect.top] ); }); diff --git a/platform/commonUI/general/test/directives/MCTResizeSpec.js b/platform/commonUI/general/test/directives/MCTResizeSpec.js index e5374305c2..5b29206315 100644 --- a/platform/commonUI/general/test/directives/MCTResizeSpec.js +++ b/platform/commonUI/general/test/directives/MCTResizeSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/directives/MCTResize"], function (MCTResize) { - "use strict"; describe("The mct-resize directive", function () { var mockTimeout, diff --git a/platform/commonUI/general/test/directives/MCTScrollSpec.js b/platform/commonUI/general/test/directives/MCTScrollSpec.js index 0503e9c1d1..4f59681696 100644 --- a/platform/commonUI/general/test/directives/MCTScrollSpec.js +++ b/platform/commonUI/general/test/directives/MCTScrollSpec.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,jasmine,beforeEach*/ define( ['../../src/directives/MCTScroll'], function (MCTScroll) { - "use strict"; var EVENT_PROPERTY = "testProperty", ATTRIBUTE = "testAttribute", @@ -114,4 +112,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js b/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js index 0743f1a584..6a4fc18634 100644 --- a/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js +++ b/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/directives/MCTSplitPane"], function (MCTSplitPane) { - 'use strict'; var JQLITE_METHODS = [ 'on', @@ -205,4 +203,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/directives/MCTSplitterSpec.js b/platform/commonUI/general/test/directives/MCTSplitterSpec.js index 3aae62ccc2..a6f4cd92ab 100644 --- a/platform/commonUI/general/test/directives/MCTSplitterSpec.js +++ b/platform/commonUI/general/test/directives/MCTSplitterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/directives/MCTSplitter"], function (MCTSplitter) { - 'use strict'; describe("The mct-splitter directive", function () { var mctSplitter; @@ -50,16 +48,16 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( '$scope', - [ '$on', '$watch' ] + ['$on', '$watch'] ); mockElement = jasmine.createSpyObj( 'element', - [ 'addClass' ] + ['addClass'] ); testAttrs = {}; mockSplitPane = jasmine.createSpyObj( 'mctSplitPane', - [ 'position', 'toggleClass', 'anchor' ] + ['position', 'toggleClass', 'anchor'] ); mctSplitter.link( @@ -94,7 +92,7 @@ define( }); it("repositions during drag", function () { - mockScope.splitter.move([ 10, 0 ]); + mockScope.splitter.move([10, 0]); expect(mockSplitPane.position) .toHaveBeenCalledWith(testPosition + 10); }); diff --git a/platform/commonUI/general/test/directives/MCTTreeSpec.js b/platform/commonUI/general/test/directives/MCTTreeSpec.js index 597c4c55b7..76f1fb9b02 100644 --- a/platform/commonUI/general/test/directives/MCTTreeSpec.js +++ b/platform/commonUI/general/test/directives/MCTTreeSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,jasmine,it,expect*/ define([ '../../src/directives/MCTTree' @@ -33,7 +32,7 @@ define([ beforeEach(function () { mockGestureService = jasmine.createSpyObj( 'gestureService', - [ 'attachGestures' ] + ['attachGestures'] ); mockParse = jasmine.createSpy('$parse'); mockExpr = jasmine.createSpy('expr'); diff --git a/platform/commonUI/general/test/filters/ReverseFilterSpec.js b/platform/commonUI/general/test/filters/ReverseFilterSpec.js index 91b770c5a8..712204212c 100644 --- a/platform/commonUI/general/test/filters/ReverseFilterSpec.js +++ b/platform/commonUI/general/test/filters/ReverseFilterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../../src/filters/ReverseFilter'], function (ReverseFilter) { - 'use strict'; describe("The reverse filter", function () { var reverse; diff --git a/platform/commonUI/general/test/services/PopupServiceSpec.js b/platform/commonUI/general/test/services/PopupServiceSpec.js index 741d23bd37..79c920a164 100644 --- a/platform/commonUI/general/test/services/PopupServiceSpec.js +++ b/platform/commonUI/general/test/services/PopupServiceSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/services/PopupService"], function (PopupService) { - 'use strict'; describe("PopupService", function () { var mockDocument, @@ -35,9 +33,9 @@ define( popupService; beforeEach(function () { - mockDocument = jasmine.createSpyObj('$document', [ 'find' ]); + mockDocument = jasmine.createSpyObj('$document', ['find']); testWindow = { innerWidth: 1000, innerHeight: 800 }; - mockBody = jasmine.createSpyObj('body', [ 'append' ]); + mockBody = jasmine.createSpyObj('body', ['append']); mockElement = jasmine.createSpyObj('element', [ 'css', 'remove' @@ -51,13 +49,13 @@ define( }); it("adds elements to the body of the document", function () { - popupService.display(mockElement, [ 0, 0 ]); + popupService.display(mockElement, [0, 0]); expect(mockBody.append).toHaveBeenCalledWith(mockElement); }); describe("when positioned in appropriate quadrants", function () { it("orients elements relative to the top-left", function () { - popupService.display(mockElement, [ 25, 50 ]); + popupService.display(mockElement, [25, 50]); expect(mockElement.css).toHaveBeenCalledWith({ position: 'absolute', left: '25px', @@ -66,7 +64,7 @@ define( }); it("orients elements relative to the top-right", function () { - popupService.display(mockElement, [ 800, 50 ]); + popupService.display(mockElement, [800, 50]); expect(mockElement.css).toHaveBeenCalledWith({ position: 'absolute', right: '200px', @@ -75,7 +73,7 @@ define( }); it("orients elements relative to the bottom-right", function () { - popupService.display(mockElement, [ 800, 650 ]); + popupService.display(mockElement, [800, 650]); expect(mockElement.css).toHaveBeenCalledWith({ position: 'absolute', right: '200px', @@ -84,7 +82,7 @@ define( }); it("orients elements relative to the bottom-left", function () { - popupService.display(mockElement, [ 120, 650 ]); + popupService.display(mockElement, [120, 650]); expect(mockElement.css).toHaveBeenCalledWith({ position: 'absolute', left: '120px', diff --git a/platform/commonUI/general/test/services/PopupSpec.js b/platform/commonUI/general/test/services/PopupSpec.js index 84d63953a2..3f3e4c7e4e 100644 --- a/platform/commonUI/general/test/services/PopupSpec.js +++ b/platform/commonUI/general/test/services/PopupSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/services/Popup"], function (Popup) { - 'use strict'; describe("Popup", function () { var mockElement, @@ -34,7 +32,7 @@ define( beforeEach(function () { mockElement = - jasmine.createSpyObj('element', [ 'css', 'remove' ]); + jasmine.createSpyObj('element', ['css', 'remove']); testStyles = { left: '12px', top: '14px' }; popup = new Popup(mockElement, testStyles); }); diff --git a/platform/commonUI/general/test/services/UrlServiceSpec.js b/platform/commonUI/general/test/services/UrlServiceSpec.js index f8526c4b5b..e956fb657d 100644 --- a/platform/commonUI/general/test/services/UrlServiceSpec.js +++ b/platform/commonUI/general/test/services/UrlServiceSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/services/UrlService"], function (UrlService) { - "use strict"; describe("The url service", function () { var urlService, @@ -38,19 +36,19 @@ define( testViews; beforeEach(function () { - // Creates a mockLocation, used to + // Creates a mockLocation, used to // do the view search mockLocation = jasmine.createSpyObj( "$location", - [ "path", "search" ] + ["path", "search"] ); - - // The mockDomainObject is initialized as a + + // The mockDomainObject is initialized as a // spy object to ultimately be passed into the // urlService urlFor function mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "getModel", "useCapability" ] + ["getId", "getCapability", "getModel", "useCapability"] ); mockContext = jasmine.createSpyObj('context', ['getPath']); testViews = [ @@ -59,39 +57,39 @@ define( { key: 'xyz' } ]; mockMode = "browse"; - + // The mockContext is set a path // for the mockDomainObject mockContext.getPath.andReturn( [mockDomainObject] ); - + // view capability used with the testviews made mockDomainObject.useCapability.andCallFake(function (c) { return (c === 'view') && testViews; }); - + // context capability used with the mockContext created // so the variables including context in the urlFor are // initialized and reached mockDomainObject.getCapability.andCallFake(function (c) { return c === 'context' && mockContext; }); - + // Uses the mockLocation to get the current // "mock" website's view mockLocation.search.andReturn({ view: 'def' }); - + urlService = new UrlService(mockLocation); }); - + it("get url for a location using domainObject and mode", function () { urlService.urlForLocation(mockMode, mockDomainObject); }); - + it("get url for a new tab using domainObject and mode", function () { urlService.urlForNewTab(mockMode, mockDomainObject); }); }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/general/test/ui/TreeViewSpec.js b/platform/commonUI/general/test/ui/TreeViewSpec.js index eae4d3eafd..c889c31090 100644 --- a/platform/commonUI/general/test/ui/TreeViewSpec.js +++ b/platform/commonUI/general/test/ui/TreeViewSpec.js @@ -19,13 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,jasmine,it,expect*/ +/*global describe,beforeEach,jasmine,it,expect*/ define([ '../../src/ui/TreeView', 'zepto' ], function (TreeView, $) { - 'use strict'; describe("TreeView", function () { var mockGestureService, @@ -37,7 +36,7 @@ define([ treeView; function makeMockDomainObject(id, model, capabilities) { - var mockDomainObject = jasmine.createSpyObj( + var mockDomainObj = jasmine.createSpyObj( 'domainObject-' + id, [ 'getId', @@ -47,24 +46,24 @@ define([ 'useCapability' ] ); - mockDomainObject.getId.andReturn(id); - mockDomainObject.getModel.andReturn(model); - mockDomainObject.hasCapability.andCallFake(function (c) { + mockDomainObj.getId.andReturn(id); + mockDomainObj.getModel.andReturn(model); + mockDomainObj.hasCapability.andCallFake(function (c) { return !!(capabilities[c]); }); - mockDomainObject.getCapability.andCallFake(function (c) { + mockDomainObj.getCapability.andCallFake(function (c) { return capabilities[c]; }); - mockDomainObject.useCapability.andCallFake(function (c) { + mockDomainObj.useCapability.andCallFake(function (c) { return capabilities[c] && capabilities[c].invoke(); }); - return mockDomainObject; + return mockDomainObj; } beforeEach(function () { mockGestureService = jasmine.createSpyObj( 'gestureService', - [ 'attachGestures' ] + ['attachGestures'] ); mockGestureHandle = jasmine.createSpyObj('gestures', ['destroy']); @@ -100,31 +99,23 @@ define([ var mockComposition; function makeGenericCapabilities() { - var mockContext = - 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' ]); + var mockStatus = + jasmine.createSpyObj('status', ['listen', 'list']); mockStatus.list.andReturn([]); return { - context: mockContext, - type: mockType, - mutation: mockMutation, - location: mockLocation, + context: jasmine.createSpyObj('context', ['getPath']), + type: jasmine.createSpyObj('type', ['getGlyph']), + location: jasmine.createSpyObj('location', ['isLink']), + mutation: jasmine.createSpyObj('mutation', ['listen']), status: mockStatus }; } function waitForCompositionCallback() { var calledBack = false; - testCapabilities.composition.invoke().then(function (c) { + testCapabilities.composition.invoke().then(function () { calledBack = true; }); waitsFor(function () { @@ -134,11 +125,11 @@ define([ beforeEach(function () { mockComposition = ['a', 'b', 'c'].map(function (id) { - var testCapabilities = makeGenericCapabilities(), + var testCaps = makeGenericCapabilities(), mockChild = - makeMockDomainObject(id, {}, testCapabilities); + makeMockDomainObject(id, {}, testCaps); - testCapabilities.context.getPath + testCaps.context.getPath .andReturn([mockDomainObject, mockChild]); return mockChild; @@ -208,11 +199,11 @@ define([ describe("when a context-less object is selected", function () { beforeEach(function () { - var testCapabilities = makeGenericCapabilities(), - mockDomainObject = - makeMockDomainObject('xyz', {}, testCapabilities); - delete testCapabilities.context; - treeView.value(mockDomainObject); + var testCaps = makeGenericCapabilities(), + mockDomainObj = + makeMockDomainObject('xyz', {}, testCaps); + delete testCaps.context; + treeView.value(mockDomainObj); }); it("clears all selection state", function () { @@ -232,7 +223,7 @@ define([ calledBackInner = false; newCapabilities.composition = - jasmine.createSpyObj('composition', [ 'invoke' ]); + jasmine.createSpyObj('composition', ['invoke']); newCapabilities.composition.invoke .andReturn(Promise.resolve([mockGrandchild])); mockComposition.push(mockNewChild); @@ -275,7 +266,7 @@ define([ beforeEach(function () { var mockStatus = mockComposition[1].getCapability('status'); - testStatuses = [ 'foo' ]; + testStatuses = ['foo']; mockStatus.list.andReturn(testStatuses); mockStatus.listen.mostRecentCall.args[0](testStatuses); diff --git a/platform/commonUI/inspect/bundle.js b/platform/commonUI/inspect/bundle.js index 9576a344c1..def8e2c277 100644 --- a/platform/commonUI/inspect/bundle.js +++ b/platform/commonUI/inspect/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/gestures/InfoGesture", @@ -40,7 +39,6 @@ define([ infoButtonTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/inspect", { "extensions": { diff --git a/platform/commonUI/inspect/src/InfoConstants.js b/platform/commonUI/inspect/src/InfoConstants.js index 33a0865dd9..93fa863ed6 100644 --- a/platform/commonUI/inspect/src/InfoConstants.js +++ b/platform/commonUI/inspect/src/InfoConstants.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle provides support for object inspection (specifically, metadata @@ -41,7 +40,7 @@ define({ offsetX: 0, offsetY: -26 }, - BUBBLE_MOBILE_POSITION: [ 0, -25 ], + BUBBLE_MOBILE_POSITION: [0, -25], // Max width and margins allowed for bubbles; // defined in /platform/commonUI/general/res/sass/_constants.scss BUBBLE_MARGIN_LR: 10, diff --git a/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js b/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js index 9ef0222e54..81a3fd9e84 100644 --- a/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js +++ b/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The `info` gesture displays domain object metadata in a @@ -47,7 +45,7 @@ define( // Record touch position, so bubble can be shown at latest // touch position, also offset by 22px to left (accounts for // a finger-sized touch on the info button) - touchPosition = [ event.clientX - 22, event.clientY ]; + touchPosition = [event.clientX - 22, event.clientY]; } // Hides the bubble and detaches the @@ -81,8 +79,8 @@ define( // On any touch on the body, default body touches/events // are prevented, the bubble is dismissed, and the touchstart // body event is unbound, reallowing gestures - body.on('touchstart', function (event) { - event.preventDefault(); + body.on('touchstart', function (evt) { + evt.preventDefault(); hideBubble(); body.unbind('touchstart'); }); diff --git a/platform/commonUI/inspect/src/gestures/InfoGesture.js b/platform/commonUI/inspect/src/gestures/InfoGesture.js index 688a27cb6c..de5324d490 100644 --- a/platform/commonUI/inspect/src/gestures/InfoGesture.js +++ b/platform/commonUI/inspect/src/gestures/InfoGesture.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The `info` gesture displays domain object metadata in a @@ -73,7 +71,7 @@ define( InfoGesture.prototype.trackPosition = function (event) { // Record mouse position, so bubble can be shown at latest // mouse position (not just where the mouse entered) - this.mousePosition = [ event.clientX, event.clientY ]; + this.mousePosition = [event.clientX, event.clientY]; }; InfoGesture.prototype.hideBubble = function () { diff --git a/platform/commonUI/inspect/src/services/InfoService.js b/platform/commonUI/inspect/src/services/InfoService.js index 667b7ee892..eae817d9e2 100644 --- a/platform/commonUI/inspect/src/services/InfoService.js +++ b/platform/commonUI/inspect/src/services/InfoService.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['../InfoConstants'], function (InfoConstants) { - "use strict"; var BUBBLE_TEMPLATE = InfoConstants.BUBBLE_TEMPLATE, MOBILE_POSITION = InfoConstants.BUBBLE_MOBILE_POSITION, @@ -69,7 +67,7 @@ define( // On a phone, bubble takes up more screen real estate, // so position it differently (toward the bottom) - if (this.agentService.isPhone(navigator.userAgent)) { + if (this.agentService.isPhone()) { position = MOBILE_POSITION; options = {}; } diff --git a/platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js b/platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js index 0c48f5d940..781bfd3769 100644 --- a/platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js +++ b/platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/gestures/InfoButtonGesture'], function (InfoButtonGesture) { - "use strict"; describe("The info button gesture", function () { var mockTimeout, @@ -46,28 +44,28 @@ define( beforeEach(function () { mockTimeout = jasmine.createSpy('$timeout'); mockDocument = jasmine.createSpyObj('$document', ['find']); - mockBody = jasmine.createSpyObj('body', [ 'on', 'off', 'scope', 'css', 'unbind' ]); + mockBody = jasmine.createSpyObj('body', ['on', 'off', 'scope', 'css', 'unbind']); mockDocument.find.andReturn(mockBody); mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']); mockInfoService = jasmine.createSpyObj( 'infoService', - [ 'display' ] + ['display'] ); mockElement = jasmine.createSpyObj( 'element', - [ 'on', 'off', 'scope', 'css' ] + ['on', 'off', 'scope', 'css'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getCapability', 'useCapability', 'getModel' ] + ['getId', 'getCapability', 'useCapability', 'getModel'] ); mockEvent = jasmine.createSpyObj("event", ["preventDefault", "stopPropagation"]); mockEvent.pageX = 0; mockEvent.pageY = 0; - mockScope = jasmine.createSpyObj('$scope', [ '$on' ]); + mockScope = jasmine.createSpyObj('$scope', ['$on']); mockOff = jasmine.createSpy('$off'); - testMetadata = [ { name: "Test name", value: "Test value" } ]; + testMetadata = [{ name: "Test name", value: "Test value" }]; mockHide = jasmine.createSpy('hide'); mockDomainObject.getModel.andReturn({ name: "Test Object" }); diff --git a/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js b/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js index d25fa57ed3..e135a24adb 100644 --- a/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js +++ b/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/gestures/InfoGesture'], function (InfoGesture) { - "use strict"; describe("The info gesture", function () { var mockTimeout, @@ -54,19 +52,19 @@ define( mockAgentService = jasmine.createSpyObj('agentService', ['isMobile']); mockInfoService = jasmine.createSpyObj( 'infoService', - [ 'display' ] + ['display'] ); mockElement = jasmine.createSpyObj( 'element', - [ 'on', 'off', 'scope', 'css' ] + ['on', 'off', 'scope', 'css'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getCapability', 'useCapability', 'getModel' ] + ['getId', 'getCapability', 'useCapability', 'getModel'] ); - mockScope = jasmine.createSpyObj('$scope', [ '$on' ]); + mockScope = jasmine.createSpyObj('$scope', ['$on']); mockOff = jasmine.createSpy('$off'); - testMetadata = [ { name: "Test name", value: "Test value" } ]; + testMetadata = [{ name: "Test name", value: "Test value" }]; mockPromise = jasmine.createSpyObj('promise', ['then']); mockHide = jasmine.createSpy('hide'); @@ -103,7 +101,7 @@ define( jasmine.any(String), "Test Object", testMetadata, - [ 1977, 42 ] + [1977, 42] ); }); @@ -132,7 +130,7 @@ define( jasmine.any(String), "Test Object", testMetadata, - [ 1984, 11 ] + [1984, 11] ); }); diff --git a/platform/commonUI/inspect/test/services/InfoServiceSpec.js b/platform/commonUI/inspect/test/services/InfoServiceSpec.js index ca0f20283b..de81f943e0 100644 --- a/platform/commonUI/inspect/test/services/InfoServiceSpec.js +++ b/platform/commonUI/inspect/test/services/InfoServiceSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( - ['../../src/services/InfoService', '../../src/InfoConstants'], - function (InfoService, InfoConstants) { - "use strict"; + ['../../src/services/InfoService'], + function (InfoService) { describe("The info service", function () { var mockCompile, @@ -81,7 +79,7 @@ define( service.display('', '', {}, [123, 456]); expect(mockPopupService.display).toHaveBeenCalledWith( mockElements[0], - [ 123, 456 ], + [123, 456], jasmine.any(Object) ); }); @@ -104,16 +102,16 @@ define( service.display('', '', {}, [123, 456]); expect(mockPopupService.display).toHaveBeenCalledWith( mockElements[0], - [ 0, -25 ], + [0, -25], jasmine.any(Object) ); }); - [ false, true ].forEach(function (goesLeft) { - [ false, true].forEach(function (goesUp) { + [false, true].forEach(function (goesLeft) { + [false, true].forEach(function (goesUp) { var vertical = goesUp ? "up" : "down", horizontal = goesLeft ? "left" : "right", - location = [ vertical, horizontal].join('-'); + location = [vertical, horizontal].join('-'); describe("when bubble goes " + location, function () { var expectedLocation = [ goesUp ? "bottom" : "top", @@ -125,7 +123,7 @@ define( mockPopup.goesDown.andReturn(!goesUp); mockPopup.goesLeft.andReturn(goesLeft); mockPopup.goesRight.andReturn(!goesLeft); - service.display('', '', {}, [ 10, 10 ]); + service.display('', '', {}, [10, 10]); }); it("positions the arrow in the " + expectedLocation, function () { diff --git a/platform/commonUI/mobile/bundle.js b/platform/commonUI/mobile/bundle.js index 1cec584ff0..a3597f047d 100644 --- a/platform/commonUI/mobile/bundle.js +++ b/platform/commonUI/mobile/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/MCTDevice", @@ -32,7 +31,6 @@ define([ DeviceClassifier, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/mobile", { "extensions": { diff --git a/platform/commonUI/mobile/src/AgentService.js b/platform/commonUI/mobile/src/AgentService.js index 3251950ff4..8aa94862f3 100644 --- a/platform/commonUI/mobile/src/AgentService.js +++ b/platform/commonUI/mobile/src/AgentService.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Provides features which support variant behavior on mobile devices. @@ -29,7 +28,6 @@ define( [], function () { - "use strict"; /** * The query service handles calls for browser and userAgent diff --git a/platform/commonUI/mobile/src/DeviceClassifier.js b/platform/commonUI/mobile/src/DeviceClassifier.js index ac275fa4d0..6801c00d02 100644 --- a/platform/commonUI/mobile/src/DeviceClassifier.js +++ b/platform/commonUI/mobile/src/DeviceClassifier.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( ['./DeviceMatchers'], function (DeviceMatchers) { - 'use strict'; /** * Runs at application startup and adds a subset of the following @@ -56,4 +54,4 @@ define( return MobileClassifier; } -); \ No newline at end of file +); diff --git a/platform/commonUI/mobile/src/DeviceMatchers.js b/platform/commonUI/mobile/src/DeviceMatchers.js index 9292625a79..5b6452641c 100644 --- a/platform/commonUI/mobile/src/DeviceMatchers.js +++ b/platform/commonUI/mobile/src/DeviceMatchers.js @@ -19,9 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define(function () { - "use strict"; /** * An object containing key-value pairs, where keys are symbolic of @@ -57,4 +55,4 @@ define(function () { return agentService.isTouch(); } }; -}); \ No newline at end of file +}); diff --git a/platform/commonUI/mobile/src/MCTDevice.js b/platform/commonUI/mobile/src/MCTDevice.js index 704f665a22..a98d4f0d8c 100644 --- a/platform/commonUI/mobile/src/MCTDevice.js +++ b/platform/commonUI/mobile/src/MCTDevice.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( ['./DeviceMatchers'], function (DeviceMatchers) { - 'use strict'; /** * The `mct-device` directive, when applied as an attribute, diff --git a/platform/commonUI/mobile/test/AgentServiceSpec.js b/platform/commonUI/mobile/test/AgentServiceSpec.js index be5fdaf6c5..da8c19ddc8 100644 --- a/platform/commonUI/mobile/test/AgentServiceSpec.js +++ b/platform/commonUI/mobile/test/AgentServiceSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/AgentService"], function (AgentService) { - "use strict"; var TEST_USER_AGENTS = { DESKTOP: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36", @@ -71,7 +69,7 @@ define( }); it("detects display orientation", function () { - var agentService = new AgentService(testWindow); + agentService = new AgentService(testWindow); testWindow.innerWidth = 1024; testWindow.innerHeight = 400; expect(agentService.isPortrait()).toBeFalsy(); diff --git a/platform/commonUI/mobile/test/DeviceClassifierSpec.js b/platform/commonUI/mobile/test/DeviceClassifierSpec.js index 951c06f25a..ab6ca51433 100644 --- a/platform/commonUI/mobile/test/DeviceClassifierSpec.js +++ b/platform/commonUI/mobile/test/DeviceClassifierSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/DeviceClassifier", "../src/DeviceMatchers"], function (DeviceClassifier, DeviceMatchers) { - "use strict"; var AGENT_SERVICE_METHODS = [ 'isMobile', @@ -36,11 +34,11 @@ define( 'isTouch' ], TEST_PERMUTATIONS = [ - [ 'isMobile', 'isPhone', 'isTouch', 'isPortrait' ], - [ 'isMobile', 'isPhone', 'isTouch', 'isLandscape' ], - [ 'isMobile', 'isTablet', 'isTouch', 'isPortrait' ], - [ 'isMobile', 'isTablet', 'isTouch', 'isLandscape' ], - [ 'isTouch' ], + ['isMobile', 'isPhone', 'isTouch', 'isPortrait'], + ['isMobile', 'isPhone', 'isTouch', 'isLandscape'], + ['isMobile', 'isTablet', 'isTouch', 'isPortrait'], + ['isMobile', 'isTablet', 'isTouch', 'isLandscape'], + ['isTouch'], [] ]; @@ -56,11 +54,11 @@ define( ); mockDocument = jasmine.createSpyObj( '$document', - [ 'find' ] + ['find'] ); mockBody = jasmine.createSpyObj( 'body', - [ 'addClass' ] + ['addClass'] ); mockDocument.find.andCallFake(function (sel) { return sel === 'body' && mockBody; diff --git a/platform/commonUI/mobile/test/DeviceMatchersSpec.js b/platform/commonUI/mobile/test/DeviceMatchersSpec.js index df78e49a6a..cbdce4bf91 100644 --- a/platform/commonUI/mobile/test/DeviceMatchersSpec.js +++ b/platform/commonUI/mobile/test/DeviceMatchersSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/DeviceMatchers"], function (DeviceMatchers) { - 'use strict'; describe("DeviceMatchers", function () { var mockAgentService; @@ -78,4 +76,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/mobile/test/MCTDeviceSpec.js b/platform/commonUI/mobile/test/MCTDeviceSpec.js index b7a0c8b194..aef828cf54 100644 --- a/platform/commonUI/mobile/test/MCTDeviceSpec.js +++ b/platform/commonUI/mobile/test/MCTDeviceSpec.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../src/MCTDevice'], function (MCTDevice) { - "use strict"; - var JQLITE_METHODS = [ 'replaceWith' ]; + var JQLITE_METHODS = ['replaceWith']; describe("The mct-device directive", function () { var mockAgentService, @@ -43,7 +41,7 @@ define( beforeEach(function () { mockAgentService = jasmine.createSpyObj( "agentService", - [ "isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape" ] + ["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"] ); mockTransclude = jasmine.createSpy("$transclude"); mockElement = jasmine.createSpyObj(name, JQLITE_METHODS); diff --git a/platform/commonUI/notification/bundle.js b/platform/commonUI/notification/bundle.js index d1cdbbdd33..53a9e4867d 100644 --- a/platform/commonUI/notification/bundle.js +++ b/platform/commonUI/notification/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/NotificationIndicatorController", @@ -34,7 +33,6 @@ define([ notificationIndicatorTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/notification", { "extensions": { diff --git a/platform/commonUI/notification/src/NotificationIndicator.js b/platform/commonUI/notification/src/NotificationIndicator.js index 29a831d251..d15444ef18 100644 --- a/platform/commonUI/notification/src/NotificationIndicator.js +++ b/platform/commonUI/notification/src/NotificationIndicator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,window*/ define( [], function () { - "use strict"; function NotificationIndicator() {} diff --git a/platform/commonUI/notification/src/NotificationIndicatorController.js b/platform/commonUI/notification/src/NotificationIndicatorController.js index 3c489505af..8a1bdbca2a 100644 --- a/platform/commonUI/notification/src/NotificationIndicatorController.js +++ b/platform/commonUI/notification/src/NotificationIndicatorController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Provides an indicator that is visible when there are @@ -44,7 +42,7 @@ define( /** * Launch a dialog showing a list of current notifications. */ - $scope.showNotificationsList = function(){ + $scope.showNotificationsList = function () { dialogService.getDialogResponse('overlay-message-list', { dialog: { title: "Messages", @@ -52,11 +50,11 @@ define( // from the notifications messages: notificationService.notifications }, - cancel: function(){ + cancel: function () { dialogService.dismiss(); } }); - + }; } return NotificationIndicatorController; diff --git a/platform/commonUI/notification/src/NotificationService.js b/platform/commonUI/notification/src/NotificationService.js index bbf79cf7fc..8643139f39 100644 --- a/platform/commonUI/notification/src/NotificationService.js +++ b/platform/commonUI/notification/src/NotificationService.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle implements the notification service, which can be used to @@ -34,7 +33,6 @@ define( [], function () { - "use strict"; /** * A representation of a user action. Options are provided to @@ -120,7 +118,7 @@ define( function NotificationService($timeout, topic, DEFAULT_AUTO_DISMISS, MINIMIZE_TIMEOUT) { this.notifications = []; this.$timeout = $timeout; - this.highest ={ severity: "info" }; + this.highest = { severity: "info" }; this.DEFAULT_AUTO_DISMISS = DEFAULT_AUTO_DISMISS; this.MINIMIZE_TIMEOUT = MINIMIZE_TIMEOUT; this.topic = topic; @@ -145,7 +143,7 @@ define( //Check this is a known notification var index = service.notifications.indexOf(notification); - if (service.active.timeout){ + if (service.active.timeout) { /* Method can be called manually (clicking dismiss) or automatically from an auto-timeout. this.active.timeout @@ -159,10 +157,10 @@ define( } if (index >= 0) { - notification.model.minimized=true; + notification.model.minimized = true; //Add a brief timeout before showing the next notification // in order to allow the minimize animation to run through. - service.$timeout(function() { + service.$timeout(function () { service.setActiveNotification(service.selectNextNotification()); }, service.MINIMIZE_TIMEOUT); } @@ -182,7 +180,7 @@ define( //Check this is a known notification var index = service.notifications.indexOf(notification); - if (service.active.timeout){ + if (service.active.timeout) { /* Method can be called manually (clicking dismiss) or * automatically from an auto-timeout. this.active.timeout * acts as a semaphore to prevent race conditions. Cancel any @@ -221,7 +219,7 @@ define( * Returns the notification that is currently visible in the banner area * @returns {Notification} */ - NotificationService.prototype.getActiveNotification = function (){ + NotificationService.prototype.getActiveNotification = function () { return this.active.notification; }; @@ -283,8 +281,8 @@ define( "alert": 2, "error": 3 }; - this.highest.severity = this.notifications.reduce(function(previous, notification){ - if (severity[notification.model.severity] > severity[previous]){ + this.highest.severity = this.notifications.reduce(function (previous, notification) { + if (severity[notification.model.severity] > severity[previous]) { return notification.model.severity; } else { return previous; @@ -310,23 +308,23 @@ define( notification = { model: notificationModel, - minimize: function() { + minimize: function () { self.minimize(self, notification); }, - dismiss: function(){ + dismiss: function () { self.dismiss(self, notification); topic.notify(); }, - dismissOrMinimize: function(){ + dismissOrMinimize: function () { self.dismissOrMinimize(notification); }, - onDismiss: function(callback) { + onDismiss: function (callback) { topic.listen(callback); } }; notificationModel.severity = notificationModel.severity || "info"; - if (notificationModel.autoDismiss === true){ + if (notificationModel.autoDismiss === true) { notificationModel.autoDismiss = this.DEFAULT_AUTO_DISMISS; } @@ -339,7 +337,7 @@ define( notificationModel.options = notificationModel.options || []; notificationModel.options.unshift({ label: "Dismiss", - callback: function() { + callback: function () { notification.dismiss(); } }); @@ -352,10 +350,10 @@ define( /* Check if there is already an active (ie. visible) notification */ - if (!this.active.notification){ + if (!this.active.notification) { this.setActiveNotification(notification); - } else if (!this.active.timeout){ + } else if (!this.active.timeout) { /* If there is already an active notification, time it out. If it's already got a timeout in progress (either because it has had @@ -381,17 +379,16 @@ define( */ NotificationService.prototype.setActiveNotification = function (notification) { + var timeout; - var self = this, - timeout; this.active.notification = notification; /* If autoDismiss has been specified, OR there are other notifications queued for display, setup a timeout to dismiss the dialog. */ - if (notification && (notification.model.autoDismiss - || this.selectNextNotification())) { + if (notification && (notification.model.autoDismiss || + this.selectNextNotification())) { timeout = notification.model.autoDismiss || this.DEFAULT_AUTO_DISMISS; this.active.timeout = this.$timeout(function () { @@ -400,7 +397,7 @@ define( } else { delete this.active.timeout; } - }; + }; /** * Used internally by the NotificationService @@ -409,17 +406,17 @@ define( */ NotificationService.prototype.selectNextNotification = function () { var notification, - i=0; + i = 0; /* Loop through the notifications queue and find the first one that has not already been minimized (manually or otherwise). */ - for (; i< this.notifications.length; i++) { + for (; i < this.notifications.length; i++) { notification = this.notifications[i]; - if (!notification.model.minimized - && notification!== this.active.notification) { + if (!notification.model.minimized && + notification !== this.active.notification) { return notification; } @@ -428,4 +425,4 @@ define( return NotificationService; } -); \ No newline at end of file +); diff --git a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js index 59450fd060..222c2fc87b 100644 --- a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js +++ b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js @@ -19,38 +19,36 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */ define( ['../src/NotificationIndicatorController'], function (NotificationIndicatorController) { - "use strict"; describe("The notification indicator controller ", function () { var mockNotificationService, mockScope, - mockDialogService; + mockDialogService, + controller; - beforeEach(function(){ + beforeEach(function () { mockNotificationService = jasmine.createSpy("notificationService"); mockScope = jasmine.createSpy("$scope"); mockDialogService = jasmine.createSpyObj( "dialogService", ["getDialogResponse","dismiss"] ); - }); - - it("exposes the highest notification severity to the template", function() { mockNotificationService.highest = { severity: "error" }; - var controller = new NotificationIndicatorController(mockScope, mockNotificationService, mockDialogService); + controller = new NotificationIndicatorController(mockScope, mockNotificationService, mockDialogService); + }); + + it("exposes the highest notification severity to the template", function () { expect(mockScope.highest).toBeTruthy(); expect(mockScope.highest.severity).toBe("error"); }); - it("invokes the dialog service to show list of messages", function() { - var controller = new NotificationIndicatorController(mockScope, mockNotificationService, mockDialogService); + it("invokes the dialog service to show list of messages", function () { expect(mockScope.showNotificationsList).toBeDefined(); mockScope.showNotificationsList(); expect(mockDialogService.getDialogResponse).toHaveBeenCalled(); @@ -62,8 +60,7 @@ define( expect(mockDialogService.dismiss).toHaveBeenCalled(); }); - it("provides a means of dismissing the message list", function() { - var controller = new NotificationIndicatorController(mockScope, mockNotificationService, mockDialogService); + it("provides a means of dismissing the message list", function () { expect(mockScope.showNotificationsList).toBeDefined(); mockScope.showNotificationsList(); expect(mockDialogService.getDialogResponse).toHaveBeenCalled(); diff --git a/platform/commonUI/notification/test/NotificationServiceSpec.js b/platform/commonUI/notification/test/NotificationServiceSpec.js index 25d9077f45..ebc02445c8 100644 --- a/platform/commonUI/notification/test/NotificationServiceSpec.js +++ b/platform/commonUI/notification/test/NotificationServiceSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */ define( ['../src/NotificationService'], function (NotificationService) { - "use strict"; describe("The notification service ", function () { var notificationService, @@ -36,7 +34,7 @@ define( mockTopicObject, errorModel; - beforeEach(function(){ + beforeEach(function () { mockTimeout = jasmine.createSpy("$timeout"); mockTopicFunction = jasmine.createSpy("topic"); mockTopicObject = jasmine.createSpyObj("topicObject", ["listen", "notify"]); @@ -56,14 +54,14 @@ define( }); it("gets a new success notification, making" + - " the notification active", function() { + " the notification active", function () { var activeNotification; notificationService.notify(successModel); activeNotification = notificationService.getActiveNotification(); expect(activeNotification.model).toBe(successModel); }); - it("notifies listeners on dismissal of notification", function() { + it("notifies listeners on dismissal of notification", function () { var notification, dismissListener = jasmine.createSpy("ondismiss"); notification = notificationService.notify(successModel); @@ -77,7 +75,7 @@ define( }); it("allows specification of an info notification given just a" + - " title, making the notification active", function() { + " title, making the notification active", function () { var activeNotification, notificationTitle = "Test info notification"; notificationService.info(notificationTitle); @@ -87,7 +85,7 @@ define( }); it("gets a new success notification with" + - " numerical auto-dismiss specified. ", function() { + " numerical auto-dismiss specified. ", function () { var activeNotification; successModel.autoDismiss = 1000; notificationService.notify(successModel); @@ -101,7 +99,7 @@ define( }); it("gets a new notification with" + - " boolean auto-dismiss specified. ", function() { + " boolean auto-dismiss specified. ", function () { var activeNotification; successModel.autoDismiss = true; notificationService.notify(successModel); @@ -114,7 +112,7 @@ define( expect(activeNotification).toBeUndefined(); }); - it("allows minimization of notifications", function() { + it("allows minimization of notifications", function () { var notification, activeNotification; @@ -130,7 +128,7 @@ define( expect(notificationService.notifications.length).toBe(1); }); - it("allows dismissal of notifications", function() { + it("allows dismissal of notifications", function () { var notification, activeNotification; @@ -145,9 +143,9 @@ define( expect(notificationService.notifications.length).toBe(0); }); - describe(" gets called with multiple notifications", function(){ + describe(" gets called with multiple notifications", function () { it("auto-dismisses the previously active notification, making" + - " the new notification active", function() { + " the new notification active", function () { var activeNotification; //First pre-load with a info message notificationService.notify(successModel); @@ -167,7 +165,7 @@ define( activeNotification = notificationService.getActiveNotification(); expect(activeNotification.model).toBe(errorModel); }); - it("auto-minimizes an active error notification", function() { + it("auto-minimizes an active error notification", function () { var activeNotification; //First pre-load with an error message notificationService.notify(errorModel); @@ -189,7 +187,7 @@ define( expect(errorModel.minimized).toEqual(true); }); it("auto-minimizes errors when a number of them arrive in" + - " short succession ", function() { + " short succession ", function () { var activeNotification, error2 = { title: "Second Mock Error Notification", diff --git a/platform/commonUI/regions/bundle.js b/platform/commonUI/regions/bundle.js index d361347ad4..b90d9e4780 100644 --- a/platform/commonUI/regions/bundle.js +++ b/platform/commonUI/regions/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ './src/InspectorController', @@ -30,7 +29,6 @@ define([ EditableRegionPolicy, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/regions", { "extensions": { diff --git a/platform/commonUI/regions/src/EditableRegionPolicy.js b/platform/commonUI/regions/src/EditableRegionPolicy.js index c2883c87de..f538a5459b 100644 --- a/platform/commonUI/regions/src/EditableRegionPolicy.js +++ b/platform/commonUI/regions/src/EditableRegionPolicy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * A policy for determining whether a region part should be visible or @@ -38,10 +36,10 @@ define( } EditableRegionPolicy.prototype.allow = function (regionPart, domainObject) { - if (!regionPart.modes){ + if (!regionPart.modes) { return true; } - if (domainObject.getCapability('status').get('editing')){ + if (domainObject.hasCapability('editor') && domainObject.getCapability('editor').inEditContext()) { //If the domain object is in edit mode, only include a part // if it is marked editable return regionPart.modes.indexOf('edit') !== -1; @@ -54,4 +52,4 @@ define( return EditableRegionPolicy; } -); \ No newline at end of file +); diff --git a/platform/commonUI/regions/src/InspectorController.js b/platform/commonUI/regions/src/InspectorController.js index 7bc18fd342..b182e1d137 100644 --- a/platform/commonUI/regions/src/InspectorController.js +++ b/platform/commonUI/regions/src/InspectorController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( ['../../browse/src/InspectorRegion'], function (InspectorRegion) { - "use strict"; /** * The InspectorController adds region data for a domain object's type @@ -34,7 +32,8 @@ define( */ function InspectorController($scope, policyService) { var domainObject = $scope.domainObject, - typeCapability = domainObject.getCapability('type'); + typeCapability = domainObject.getCapability('type'), + statusListener; /** * Filters region parts to only those allowed by region policies @@ -43,14 +42,23 @@ define( */ function filterRegions(inspector) { //Dupe so we're not modifying the type definition. - return inspector.regions && inspector.regions.filter(function(region) { + return inspector.regions && inspector.regions.filter(function (region) { return policyService.allow('region', region, domainObject); }); } - $scope.regions = filterRegions(typeCapability.getDefinition().inspector || new InspectorRegion()); + function setRegions() { + $scope.regions = filterRegions(typeCapability.getDefinition().inspector || new InspectorRegion()); + } + + statusListener = domainObject.getCapability("status").listen(setRegions); + $scope.$on("$destroy", function () { + statusListener(); + }); + + setRegions(); } return InspectorController; } -); \ No newline at end of file +); diff --git a/platform/commonUI/regions/src/Region.js b/platform/commonUI/regions/src/Region.js index 9e95590ca9..4d38f1eb8d 100644 --- a/platform/commonUI/regions/src/Region.js +++ b/platform/commonUI/regions/src/Region.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,window*/ define( [], function () { - "use strict"; /** * @typeDef {object} PartContents @@ -69,7 +67,7 @@ define( * @param {number} [index] the position to insert the region. By default * will add to the end */ - Region.prototype.addRegion = function (region, index){ + Region.prototype.addRegion = function (region, index) { if (index) { this.regions.splice(index, 0, region); } else { @@ -84,11 +82,11 @@ define( * string, will remove the region with the matching name. If an * object, will attempt to remove that object from the Region */ - Region.prototype.removeRegion = function (region){ + Region.prototype.removeRegion = function (region) { if (typeof region === 'number') { this.regions.splice(region, 1); - } else if (typeof region === 'string'){ - this.regions = this.regions.filter(function(thisRegion) { + } else if (typeof region === 'string') { + this.regions = this.regions.filter(function (thisRegion) { return thisRegion.name !== region; }); } else { diff --git a/platform/commonUI/regions/test/EditableRegionPolicySpec.js b/platform/commonUI/regions/test/EditableRegionPolicySpec.js index 84f1b1a3c2..ed3b9fffd3 100644 --- a/platform/commonUI/regions/test/EditableRegionPolicySpec.js +++ b/platform/commonUI/regions/test/EditableRegionPolicySpec.js @@ -19,18 +19,16 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */ define( ['../src/EditableRegionPolicy'], function (EditableRegionPolicy) { - "use strict"; describe("The editable region policy ", function () { var editableRegionPolicy, mockDomainObject, - mockStatusCapability, + mockEditorCapability, mockBrowseRegionPart = { modes: 'browse' }, @@ -39,34 +37,35 @@ define( }, mockAllModesRegionPart = {}; - beforeEach(function(){ + beforeEach(function () { editableRegionPolicy = new EditableRegionPolicy(); - mockStatusCapability = jasmine.createSpyObj("statusCapability", [ - "get" + mockEditorCapability = jasmine.createSpyObj("editorCapability", [ + "inEditContext" ]); mockDomainObject = jasmine.createSpyObj("domainObject", [ - "getCapability" + "hasCapability", "getCapability" ]); - mockDomainObject.getCapability.andReturn(mockStatusCapability); + mockDomainObject.hasCapability.andReturn(true); + mockDomainObject.getCapability.andReturn(mockEditorCapability); }); - it("includes only browse region parts for object not in edit mode", function() { - mockStatusCapability.get.andReturn(false); + it("includes only browse region parts for object not in edit mode", function () { + mockEditorCapability.inEditContext.andReturn(false); expect(editableRegionPolicy.allow(mockBrowseRegionPart, mockDomainObject)).toBe(true); expect(editableRegionPolicy.allow(mockEditRegionPart, mockDomainObject)).toBe(false); }); - it("includes only edit region parts for object in edit mode", function() { - mockStatusCapability.get.andReturn(true); + it("includes only edit region parts for object in edit mode", function () { + mockEditorCapability.inEditContext.andReturn(true); expect(editableRegionPolicy.allow(mockBrowseRegionPart, mockDomainObject)).toBe(false); expect(editableRegionPolicy.allow(mockEditRegionPart, mockDomainObject)).toBe(true); }); - it("includes region parts with no mode specification", function() { - mockStatusCapability.get.andReturn(false); + it("includes region parts with no mode specification", function () { + mockEditorCapability.inEditContext.andReturn(false); expect(editableRegionPolicy.allow(mockAllModesRegionPart, mockDomainObject)).toBe(true); - mockStatusCapability.get.andReturn(true); + mockEditorCapability.inEditContext.andReturn(true); expect(editableRegionPolicy.allow(mockAllModesRegionPart, mockDomainObject)).toBe(true); }); diff --git a/platform/commonUI/regions/test/InspectorControllerSpec.js b/platform/commonUI/regions/test/InspectorControllerSpec.js index 1fc230f01d..8acd00267c 100644 --- a/platform/commonUI/regions/test/InspectorControllerSpec.js +++ b/platform/commonUI/regions/test/InspectorControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */ define( ['../src/InspectorController'], function (InspectorController) { - "use strict"; describe("The inspector controller ", function () { var mockScope, @@ -32,9 +30,11 @@ define( mockTypeCapability, mockTypeDefinition, mockPolicyService, + mockStatusCapability, + capabilities = {}, controller; - beforeEach(function(){ + beforeEach(function () { mockTypeDefinition = { inspector: { @@ -49,32 +49,61 @@ define( 'getDefinition' ]); mockTypeCapability.getDefinition.andReturn(mockTypeDefinition); + capabilities.type = mockTypeCapability; + + mockStatusCapability = jasmine.createSpyObj('statusCapability', [ + 'listen' + ]); + capabilities.status = mockStatusCapability; mockDomainObject = jasmine.createSpyObj('domainObject', [ 'getCapability' ]); - mockDomainObject.getCapability.andReturn(mockTypeCapability); + mockDomainObject.getCapability.andCallFake(function (name) { + return capabilities[name]; + }); mockPolicyService = jasmine.createSpyObj('policyService', [ 'allow' ]); - mockScope = { - domainObject: mockDomainObject - }; + mockScope = jasmine.createSpyObj('$scope', + ['$on'] + ); + + mockScope.domainObject = mockDomainObject; }); - it("filters out regions disallowed by region policy", function() { + it("filters out regions disallowed by region policy", function () { mockPolicyService.allow.andReturn(false); controller = new InspectorController(mockScope, mockPolicyService); expect(mockScope.regions.length).toBe(0); }); - it("does not filter out regions allowed by region policy", function() { + it("does not filter out regions allowed by region policy", function () { mockPolicyService.allow.andReturn(true); controller = new InspectorController(mockScope, mockPolicyService); 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(); + }); }); } ); diff --git a/platform/commonUI/regions/test/RegionSpec.js b/platform/commonUI/regions/test/RegionSpec.js index 2e52508d04..9c2ecc296e 100644 --- a/platform/commonUI/regions/test/RegionSpec.js +++ b/platform/commonUI/regions/test/RegionSpec.js @@ -19,19 +19,17 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */ define( ['../src/Region'], function (Region) { - "use strict"; describe("The region class ", function () { var region, part2 = new Region({'name': 'part2'}); - beforeEach(function(){ + beforeEach(function () { region = new Region(); region.regions = [ new Region({name: 'part1'}), @@ -41,27 +39,27 @@ define( }); it("adding a region at a specified index adds it in that" + - " position", function() { + " position", function () { - region.addRegion(part2, 1); + region.addRegion(part2, 1); - expect(region.regions.length).toBe(4); - expect(region.regions[1]).toBe(part2); - }); + expect(region.regions.length).toBe(4); + expect(region.regions[1]).toBe(part2); + }); - it("adding a region without an index adds it at the end", function() { + it("adding a region without an index adds it at the end", function () { var partN = new Region({'name': 'partN'}); region.addRegion(partN); expect(region.regions.length).toBe(4); - expect(region.regions[region.regions.length-1]).toBe(partN); + expect(region.regions[region.regions.length - 1]).toBe(partN); }); - describe("removing a region", function(){ + describe("removing a region", function () { var partName = "part2"; - beforeEach(function(){ + beforeEach(function () { region.regions = [ new Region({name: 'part1'}), part2, @@ -70,7 +68,7 @@ define( ]; }); - it("with a string matches on region name", function() { + it("with a string matches on region name", function () { expect(region.regions.length).toBe(4); expect(region.regions.indexOf(part2)).toBe(1); @@ -80,7 +78,7 @@ define( expect(region.regions.indexOf(part2)).toBe(-1); }); - it("with a number removes by index", function() { + it("with a number removes by index", function () { expect(region.regions.length).toBe(4); expect(region.regions.indexOf(part2)).toBe(1); @@ -91,7 +89,7 @@ define( }); - it("with object matches that object", function() { + it("with object matches that object", function () { expect(region.regions.length).toBe(4); expect(region.regions.indexOf(part2)).toBe(1); diff --git a/platform/commonUI/themes/espresso/bundle.js b/platform/commonUI/themes/espresso/bundle.js index b66f015877..d583481fa9 100644 --- a/platform/commonUI/themes/espresso/bundle.js +++ b/platform/commonUI/themes/espresso/bundle.js @@ -19,16 +19,14 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ - + 'legacyRegistry' ], function ( - + legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/themes/espresso", { "name": "Espresso", diff --git a/platform/commonUI/themes/espresso/res/sass/_constants.scss b/platform/commonUI/themes/espresso/res/sass/_constants.scss index 729a813a12..bb774fb7a8 100644 --- a/platform/commonUI/themes/espresso/res/sass/_constants.scss +++ b/platform/commonUI/themes/espresso/res/sass/_constants.scss @@ -32,11 +32,12 @@ $sliderColorBase: $colorKey; $sliderColorRangeHolder: rgba(black, 0.1); $sliderColorRange: rgba($sliderColorBase, 0.3); $sliderColorRangeHov: rgba($sliderColorBase, 0.5); -$sliderColorKnob: rgba($sliderColorBase, 0.6); -$sliderColorKnobHov: $sliderColorBase; +$sliderColorKnob: $sliderColorBase; +$sliderColorKnobHov: pullForward($sliderColorKnob, $ltGamma); $sliderColorRangeValHovBg: rgba($sliderColorBase, 0.1); $sliderColorRangeValHovFg: $colorKeyFg; -$sliderKnobW: nth($ueTimeControlH,2)/2; +$sliderKnobW: 15px; +$sliderKnobR: 2px; $timeControllerToiLineColor: #00c2ff; $timeControllerToiLineColorHov: #fff; @@ -69,8 +70,10 @@ $colorCreateMenuText: $colorMenuFg; $colorCheck: $colorKey; $colorFormRequired: $colorAlt1; $colorFormValid: #33cc33; -$colorFormError: #cc0000; +$colorFormError: #990000; $colorFormInvalid: #ff3300; +$colorFormFieldErrorBg: $colorFormError; +$colorFormFieldErrorFg: rgba(#fff, 0.6); $colorFormLines: rgba(#fff, 0.1); $colorFormSectionHeader: rgba(#fff, 0.1); $colorInputBg: rgba(#000, 0.1); diff --git a/platform/commonUI/themes/snow/bundle.js b/platform/commonUI/themes/snow/bundle.js index 0438213182..6dc8b5acc0 100644 --- a/platform/commonUI/themes/snow/bundle.js +++ b/platform/commonUI/themes/snow/bundle.js @@ -19,16 +19,14 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ - + 'legacyRegistry' ], function ( - + legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/commonUI/themes/snow", { "name": "Snow", diff --git a/platform/commonUI/themes/snow/res/sass/_constants.scss b/platform/commonUI/themes/snow/res/sass/_constants.scss index 0d8430a7ec..f85b5c328f 100644 --- a/platform/commonUI/themes/snow/res/sass/_constants.scss +++ b/platform/commonUI/themes/snow/res/sass/_constants.scss @@ -32,11 +32,12 @@ $sliderColorBase: $colorKey; $sliderColorRangeHolder: rgba(black, 0.07); $sliderColorRange: rgba($sliderColorBase, 0.2); $sliderColorRangeHov: rgba($sliderColorBase, 0.4); -$sliderColorKnob: rgba($sliderColorBase, 0.5); +$sliderColorKnob: pushBack($sliderColorBase, 20%); $sliderColorKnobHov: rgba($sliderColorBase, 0.7); -$sliderColorRangeValHovBg: $sliderColorRange; //rgba($sliderColorBase, 0.1); +$sliderColorRangeValHovBg: $sliderColorRange; $sliderColorRangeValHovFg: $colorBodyFg; -$sliderKnobW: nth($ueTimeControlH,2)/2; +$sliderKnobW: 15px; +$sliderKnobR: 2px; $timeControllerToiLineColor: $colorBodyFg; $timeControllerToiLineColorHov: #0052b5; @@ -69,8 +70,10 @@ $colorCreateMenuText: $colorBodyFg; $colorCheck: $colorKey; $colorFormRequired: $colorKey; $colorFormValid: #33cc33; -$colorFormError: #cc0000; +$colorFormError: #990000; $colorFormInvalid: #ff2200; +$colorFormFieldErrorBg: $colorFormError; +$colorFormFieldErrorFg: rgba(#fff, 0.6); $colorFormLines: rgba(#000, 0.1); $colorFormSectionHeader: rgba(#000, 0.05); $colorInputBg: $colorGenBg; diff --git a/platform/containment/bundle.js b/platform/containment/bundle.js index a9f33b0149..53e44f1e8f 100644 --- a/platform/containment/bundle.js +++ b/platform/containment/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/CompositionPolicy", @@ -34,7 +33,6 @@ define([ ComposeActionPolicy, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/containment", { "extensions": { diff --git a/platform/containment/src/CapabilityTable.js b/platform/containment/src/CapabilityTable.js index db89f9e68f..311bc70567 100644 --- a/platform/containment/src/CapabilityTable.js +++ b/platform/containment/src/CapabilityTable.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Build a table indicating which types are expected to expose diff --git a/platform/containment/src/ComposeActionPolicy.js b/platform/containment/src/ComposeActionPolicy.js index fa91cfb0e7..ea9d2aa5cb 100644 --- a/platform/containment/src/ComposeActionPolicy.js +++ b/platform/containment/src/ComposeActionPolicy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Restrict `compose` actions to cases where composition diff --git a/platform/containment/src/CompositionModelPolicy.js b/platform/containment/src/CompositionModelPolicy.js index d5e5cb5f72..be51e0c040 100644 --- a/platform/containment/src/CompositionModelPolicy.js +++ b/platform/containment/src/CompositionModelPolicy.js @@ -1,9 +1,7 @@ -/*global define*/ define( [], function () { - "use strict"; /** * Policy allowing composition only for domain object types which @@ -15,7 +13,7 @@ define( function CompositionModelPolicy() { } - CompositionModelPolicy.prototype.allow = function (candidate, context) { + CompositionModelPolicy.prototype.allow = function (candidate) { return Array.isArray( (candidate.getInitialModel() || {}).composition ); diff --git a/platform/containment/src/CompositionMutabilityPolicy.js b/platform/containment/src/CompositionMutabilityPolicy.js index 8c5ef6a765..d949d6e610 100644 --- a/platform/containment/src/CompositionMutabilityPolicy.js +++ b/platform/containment/src/CompositionMutabilityPolicy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Disallow composition changes to objects which are not mutable. diff --git a/platform/containment/src/CompositionPolicy.js b/platform/containment/src/CompositionPolicy.js index 1f5239ec59..ea0b25b217 100644 --- a/platform/containment/src/CompositionPolicy.js +++ b/platform/containment/src/CompositionPolicy.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle implements "containment" rules, which determine which objects @@ -29,7 +28,6 @@ define( ['./ContainmentTable'], function (ContainmentTable) { - "use strict"; /** * Defines composition policy as driven by type metadata. diff --git a/platform/containment/src/ContainmentTable.js b/platform/containment/src/ContainmentTable.js index 823c782faf..660b046051 100644 --- a/platform/containment/src/ContainmentTable.js +++ b/platform/containment/src/ContainmentTable.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./CapabilityTable'], function (CapabilityTable) { - "use strict"; // Symbolic value for the type table for cases when any type // is allowed to be contained. diff --git a/platform/containment/test/CapabilityTableSpec.js b/platform/containment/test/CapabilityTableSpec.js index 54c61e560d..fe5a833f53 100644 --- a/platform/containment/test/CapabilityTableSpec.js +++ b/platform/containment/test/CapabilityTableSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/CapabilityTable"], function (CapabilityTable) { - "use strict"; describe("Composition policy's capability table", function () { var mockTypeService, mockCapabilityService, @@ -34,14 +32,14 @@ define( beforeEach(function () { mockTypeService = jasmine.createSpyObj( 'typeService', - [ 'listTypes' ] + ['listTypes'] ); mockCapabilityService = jasmine.createSpyObj( 'capabilityService', - [ 'getCapabilities' ] + ['getCapabilities'] ); // Both types can only contain b, let's say - mockTypes = ['a', 'b'].map(function (type, index) { + mockTypes = ['a', 'b'].map(function (type) { var mockType = jasmine.createSpyObj( 'type-' + type, ['getKey', 'getDefinition', 'getInitialModel'] @@ -84,4 +82,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/containment/test/ComposeActionPolicySpec.js b/platform/containment/test/ComposeActionPolicySpec.js index 3ec59a9a2c..a6cf3cd3d4 100644 --- a/platform/containment/test/ComposeActionPolicySpec.js +++ b/platform/containment/test/ComposeActionPolicySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/ComposeActionPolicy"], function (ComposeActionPolicy) { - "use strict"; describe("The compose action policy", function () { var mockInjector, mockPolicyService, @@ -38,7 +36,7 @@ define( mockInjector = jasmine.createSpyObj('$injector', ['get']); mockPolicyService = jasmine.createSpyObj( 'policyService', - [ 'allow' ] + ['allow'] ); mockTypes = ['a', 'b'].map(function (type) { var mockType = jasmine.createSpyObj('type-' + type, ['getKey']); @@ -92,4 +90,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/containment/test/CompositionModelPolicySpec.js b/platform/containment/test/CompositionModelPolicySpec.js index bace49246d..2b733434b7 100644 --- a/platform/containment/test/CompositionModelPolicySpec.js +++ b/platform/containment/test/CompositionModelPolicySpec.js @@ -1,9 +1,7 @@ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/CompositionModelPolicy"], function (CompositionModelPolicy) { - "use strict"; describe("The composition model policy", function () { var mockType, diff --git a/platform/containment/test/CompositionMutabilityPolicySpec.js b/platform/containment/test/CompositionMutabilityPolicySpec.js index 1f49883939..18d26d2386 100644 --- a/platform/containment/test/CompositionMutabilityPolicySpec.js +++ b/platform/containment/test/CompositionMutabilityPolicySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/CompositionMutabilityPolicy"], function (CompositionMutabilityPolicy) { - "use strict"; describe("The composition mutability policy", function () { var mockType, @@ -44,4 +42,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/containment/test/CompositionPolicySpec.js b/platform/containment/test/CompositionPolicySpec.js index 00854bc9f2..bd2d25ba58 100644 --- a/platform/containment/test/CompositionPolicySpec.js +++ b/platform/containment/test/CompositionPolicySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/CompositionPolicy"], function (CompositionPolicy) { - "use strict"; describe("Composition policy", function () { var mockInjector, mockTypeService, @@ -36,11 +34,11 @@ define( mockInjector = jasmine.createSpyObj('$injector', ['get']); mockTypeService = jasmine.createSpyObj( 'typeService', - [ 'listTypes' ] + ['listTypes'] ); mockCapabilityService = jasmine.createSpyObj( 'capabilityService', - [ 'getCapabilities' ] + ['getCapabilities'] ); // Both types can only contain b, let's say mockTypes = ['a', 'b'].map(function (type) { @@ -84,4 +82,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/containment/test/ContainmentTableSpec.js b/platform/containment/test/ContainmentTableSpec.js index 6b4c8706f8..ac45b75804 100644 --- a/platform/containment/test/ContainmentTableSpec.js +++ b/platform/containment/test/ContainmentTableSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/ContainmentTable"], function (ContainmentTable) { - "use strict"; describe("Composition policy's containment table", function () { var mockTypeService, mockCapabilityService, @@ -34,11 +32,11 @@ define( beforeEach(function () { mockTypeService = jasmine.createSpyObj( 'typeService', - [ 'listTypes' ] + ['listTypes'] ); mockCapabilityService = jasmine.createSpyObj( 'capabilityService', - [ 'getCapabilities' ] + ['getCapabilities'] ); // Both types can only contain b, let's say mockTypes = ['a', 'b', 'c'].map(function (type, index) { @@ -50,7 +48,7 @@ define( mockType.getDefinition.andReturn({ // First two contain objects with capability 'b'; // third one defines no containership rules - contains: (index < 2) ? [ { has: 'b' } ] : undefined + contains: (index < 2) ? [{ has: 'b' }] : undefined }); // Return a model to drive apparant capabilities mockType.getInitialModel.andReturn({ id: type }); @@ -95,4 +93,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/bundle.js b/platform/core/bundle.js index 1763ce88d4..270e4e7b89 100644 --- a/platform/core/bundle.js +++ b/platform/core/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/objects/DomainObjectProvider", @@ -86,7 +85,6 @@ define([ Instantiate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/core", { "name": "Open MCT Web Core", diff --git a/platform/core/src/actions/ActionAggregator.js b/platform/core/src/actions/ActionAggregator.js index 3056ab04e8..92bf8ddb43 100644 --- a/platform/core/src/actions/ActionAggregator.js +++ b/platform/core/src/actions/ActionAggregator.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( function () { - "use strict"; /** * Actions are reusable processes/behaviors performed by users within diff --git a/platform/core/src/actions/ActionCapability.js b/platform/core/src/actions/ActionCapability.js index 2164969a05..68e891a673 100644 --- a/platform/core/src/actions/ActionCapability.js +++ b/platform/core/src/actions/ActionCapability.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ActionCapability. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * The ActionCapability allows applicable Actions to be retrieved and diff --git a/platform/core/src/actions/ActionProvider.js b/platform/core/src/actions/ActionProvider.js index b16db2e52a..b0afd3e909 100644 --- a/platform/core/src/actions/ActionProvider.js +++ b/platform/core/src/actions/ActionProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ActionProvider. Created by vwoeltje on 11/7/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * An ActionProvider (implementing ActionService) provides actions @@ -83,8 +81,8 @@ define( // additionally fills in the action's getMetadata method // with the extension definition (if no getMetadata // method was supplied.) - function instantiateAction(Action, context) { - var action = new Action(context), + function instantiateAction(Action, ctxt) { + var action = new Action(ctxt), metadata; // Provide a getMetadata method that echos @@ -92,7 +90,7 @@ define( // unless the action has defined its own. if (!action.getMetadata) { metadata = Object.create(Action.definition || {}); - metadata.context = context; + metadata.context = ctxt; action.getMetadata = function () { return metadata; }; @@ -105,14 +103,14 @@ define( // applicable in a given context, according to the static // appliesTo method of given actions (if defined), and // instantiate those applicable actions. - function createIfApplicable(actions, context) { + function createIfApplicable(actions, ctxt) { function isApplicable(Action) { - return Action.appliesTo ? Action.appliesTo(context) : true; + return Action.appliesTo ? Action.appliesTo(ctxt) : true; } function instantiate(Action) { try { - return instantiateAction(Action, context); + return instantiateAction(Action, ctxt); } catch (e) { $log.error([ "Could not instantiate action", diff --git a/platform/core/src/actions/LoggingActionDecorator.js b/platform/core/src/actions/LoggingActionDecorator.js index 0d6f170261..d6b815332a 100644 --- a/platform/core/src/actions/LoggingActionDecorator.js +++ b/platform/core/src/actions/LoggingActionDecorator.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining LoggingActionDecorator. Created by vwoeltje on 11/17/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * The LoggingActionDecorator decorates an ActionService such that diff --git a/platform/core/src/capabilities/CompositionCapability.js b/platform/core/src/capabilities/CompositionCapability.js index 977d8cb418..598767a422 100644 --- a/platform/core/src/capabilities/CompositionCapability.js +++ b/platform/core/src/capabilities/CompositionCapability.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining CompositionCapability. Created by vwoeltje on 11/7/14. */ define( function () { - "use strict"; /** * Composition capability. A domain object's composition is the set of @@ -84,7 +82,7 @@ define( return mutationResult && self.invoke().then(findObject); } - function addIdToModel(model) { + function addIdToModel(objModel) { // Pick a specific index if needed. index = isNaN(index) ? composition.length : index; // Also, don't put past the end of the array @@ -92,11 +90,11 @@ define( // Remove the existing instance of the id if (oldIndex !== -1) { - model.composition.splice(oldIndex, 1); + objModel.composition.splice(oldIndex, 1); } // ...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 diff --git a/platform/core/src/capabilities/ContextCapability.js b/platform/core/src/capabilities/ContextCapability.js index 39770f9b5b..72bfb56218 100644 --- a/platform/core/src/capabilities/ContextCapability.js +++ b/platform/core/src/capabilities/ContextCapability.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ContextCapability. Created by vwoeltje on 11/17/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * The `context` capability of a domain object (retrievable with @@ -84,7 +82,7 @@ define( parentContext = parentObject && parentObject.getCapability('context'), parentPath = parentContext ? - parentContext.getPath() : [ this.parentObject ]; + parentContext.getPath() : [this.parentObject]; return parentPath.concat([this.domainObject]); }; diff --git a/platform/core/src/capabilities/ContextualDomainObject.js b/platform/core/src/capabilities/ContextualDomainObject.js index 2955515ead..88cdc5f39a 100644 --- a/platform/core/src/capabilities/ContextualDomainObject.js +++ b/platform/core/src/capabilities/ContextualDomainObject.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ContextualDomainObject. Created by vwoeltje on 11/18/14. @@ -27,7 +26,6 @@ define( ["./ContextCapability"], function (ContextCapability) { - "use strict"; /** * Wraps a domain object, such that it exposes a `context` capability. diff --git a/platform/core/src/capabilities/CoreCapabilityProvider.js b/platform/core/src/capabilities/CoreCapabilityProvider.js index 8240f9fa89..7e5d1e4b7b 100644 --- a/platform/core/src/capabilities/CoreCapabilityProvider.js +++ b/platform/core/src/capabilities/CoreCapabilityProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining CoreCapabilityProvider. Created by vwoeltje on 11/7/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * A capability provides an interface with dealing with some @@ -64,9 +62,9 @@ define( } // Package capabilities as key-value pairs - function packageCapabilities(capabilities) { + function packageCapabilities(caps) { var result = {}; - capabilities.forEach(function (capability) { + caps.forEach(function (capability) { if (capability.key) { result[capability.key] = result[capability.key] || capability; diff --git a/platform/core/src/capabilities/DelegationCapability.js b/platform/core/src/capabilities/DelegationCapability.js index 0c62c05f00..970fb226bb 100644 --- a/platform/core/src/capabilities/DelegationCapability.js +++ b/platform/core/src/capabilities/DelegationCapability.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining DelegationCapability. Created by vwoeltje on 11/18/14. @@ -27,7 +26,6 @@ define( [], function () { - 'use strict'; /** diff --git a/platform/core/src/capabilities/InstantiationCapability.js b/platform/core/src/capabilities/InstantiationCapability.js index 52e1238cc6..3302bf9fb4 100644 --- a/platform/core/src/capabilities/InstantiationCapability.js +++ b/platform/core/src/capabilities/InstantiationCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( - ['../objects/DomainObjectImpl'], - function (DomainObjectImpl) { - 'use strict'; + [], + function () { /** * Implements the `instantiation` capability. This allows new domain diff --git a/platform/core/src/capabilities/MetadataCapability.js b/platform/core/src/capabilities/MetadataCapability.js index ddb5204edb..92001f4267 100644 --- a/platform/core/src/capabilities/MetadataCapability.js +++ b/platform/core/src/capabilities/MetadataCapability.js @@ -1,9 +1,7 @@ -/*global define*/ define( ['moment'], function (moment) { - "use strict"; /** * A piece of information about a domain object. diff --git a/platform/core/src/capabilities/MutationCapability.js b/platform/core/src/capabilities/MutationCapability.js index 1f08abda6b..592f613438 100644 --- a/platform/core/src/capabilities/MutationCapability.js +++ b/platform/core/src/capabilities/MutationCapability.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining MutationCapability. Created by vwoeltje on 11/12/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; var GENERAL_TOPIC = "mutation", TOPIC_PREFIX = "mutation:"; @@ -126,9 +124,9 @@ define( clone = JSON.parse(JSON.stringify(model)), useTimestamp = arguments.length > 1; - function notifyListeners(model) { + function notifyListeners(newModel) { generalTopic.notify(domainObject); - specificTopic.notify(model); + specificTopic.notify(newModel); } // Function to handle copying values to the actual diff --git a/platform/core/src/capabilities/PersistenceCapability.js b/platform/core/src/capabilities/PersistenceCapability.js index af21618ee3..8e1990892d 100644 --- a/platform/core/src/capabilities/PersistenceCapability.js +++ b/platform/core/src/capabilities/PersistenceCapability.js @@ -19,13 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ -/*jslint es5: true */ - define( function () { - 'use strict'; /** * Defines the `persistence` capability, used to trigger the @@ -64,16 +60,6 @@ define( this.$q = $q; } - // Utility function for creating promise-like objects which - // resolve synchronously when possible - function fastPromise(value) { - return (value || {}).then ? value : { - then: function (callback) { - return fastPromise(callback(value)); - } - }; - } - function getKey(id) { var parts = id.split(":"); return parts.length > 1 ? parts.slice(1).join(":") : id; @@ -83,18 +69,18 @@ define( * Checks if the value returned is falsey, and if so returns a * rejected promise */ - function rejectIfFalsey(value, $q){ - if (!value){ + function rejectIfFalsey(value, $q) { + if (!value) { return $q.reject("Error persisting object"); } else { return value; } } - function formatError(error){ + function formatError(error) { if (error && error.message) { return error.message; - } else if (error && typeof error === "string"){ + } else if (error && typeof error === "string") { return error; } else { return "unknown error"; @@ -105,7 +91,7 @@ define( * Display a notification message if an error has occurred during * persistence. */ - function notifyOnError(error, domainObject, notificationService, $q){ + function notifyOnError(error, domainObject, notificationService, $q) { var errorMessage = "Unable to persist " + domainObject.getModel().name; if (error) { errorMessage += ": " + formatError(error); @@ -132,15 +118,14 @@ define( domainObject = this.domainObject, model = domainObject.getModel(), modified = model.modified, - cacheService = this.cacheService, persistenceService = this.persistenceService, persistenceFn = model.persisted !== undefined ? this.persistenceService.updateObject : this.persistenceService.createObject; // Update persistence timestamp... - domainObject.useCapability("mutation", function (model) { - model.persisted = modified; + domainObject.useCapability("mutation", function (m) { + m.persisted = modified; }, modified); // ...and persist @@ -148,9 +133,9 @@ define( this.getSpace(), getKey(domainObject.getId()), domainObject.getModel() - ]).then(function(result){ + ]).then(function (result) { return rejectIfFalsey(result, self.$q); - }).catch(function(error){ + }).catch(function (error) { return notifyOnError(error, domainObject, self.notificationService, self.$q); }); }; @@ -162,8 +147,7 @@ define( * when the update is complete */ PersistenceCapability.prototype.refresh = function () { - var domainObject = this.domainObject, - model = domainObject.getModel(); + var domainObject = this.domainObject; // Update a domain object's model upon refresh function updateModel(model) { @@ -173,13 +157,10 @@ define( }, modified); } - // Only update if we don't have unsaved changes - return (model.modified === model.persisted) ? - this.persistenceService.readObject( + return this.persistenceService.readObject( this.getSpace(), this.domainObject.getId() - ).then(updateModel) : - fastPromise(false); + ).then(updateModel); }; /** diff --git a/platform/core/src/capabilities/RelationshipCapability.js b/platform/core/src/capabilities/RelationshipCapability.js index 7eb6d01bb9..d09cf0994c 100644 --- a/platform/core/src/capabilities/RelationshipCapability.js +++ b/platform/core/src/capabilities/RelationshipCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Relationship capability. Describes a domain objects relationship diff --git a/platform/core/src/identifiers/Identifier.js b/platform/core/src/identifiers/Identifier.js index e587ee006b..a6259b2bb2 100644 --- a/platform/core/src/identifiers/Identifier.js +++ b/platform/core/src/identifiers/Identifier.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; var SEPARATOR = ":"; diff --git a/platform/core/src/identifiers/IdentifierProvider.js b/platform/core/src/identifiers/IdentifierProvider.js index c6b2a136cb..09c98cfd9d 100644 --- a/platform/core/src/identifiers/IdentifierProvider.js +++ b/platform/core/src/identifiers/IdentifierProvider.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["uuid", "./Identifier"], function (uuid, Identifier) { - 'use strict'; /** * Parses and generates domain object identifiers. diff --git a/platform/core/src/models/CachingModelDecorator.js b/platform/core/src/models/CachingModelDecorator.js index 1ceae1bf88..385dfefbba 100644 --- a/platform/core/src/models/CachingModelDecorator.js +++ b/platform/core/src/models/CachingModelDecorator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The caching model decorator maintains a cache of loaded domain diff --git a/platform/core/src/models/MissingModelDecorator.js b/platform/core/src/models/MissingModelDecorator.js index d3eb8f3159..8b3a136d83 100644 --- a/platform/core/src/models/MissingModelDecorator.js +++ b/platform/core/src/models/MissingModelDecorator.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Adds placeholder domain object models for any models which diff --git a/platform/core/src/models/ModelAggregator.js b/platform/core/src/models/ModelAggregator.js index d5f4060415..d3d8c396e1 100644 --- a/platform/core/src/models/ModelAggregator.js +++ b/platform/core/src/models/ModelAggregator.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining ModelAggregator. Created by vwoeltje on 11/7/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Allow domain object models to be looked up by their identifiers. diff --git a/platform/core/src/models/ModelCacheService.js b/platform/core/src/models/ModelCacheService.js index 4bcee0b93d..0e6a196dbc 100644 --- a/platform/core/src/models/ModelCacheService.js +++ b/platform/core/src/models/ModelCacheService.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([], function () { - 'use strict'; /** * Provides a cache for domain object models which exist in memory, diff --git a/platform/core/src/models/PersistedModelProvider.js b/platform/core/src/models/PersistedModelProvider.js index 3abe57841e..cd6fde75c4 100644 --- a/platform/core/src/models/PersistedModelProvider.js +++ b/platform/core/src/models/PersistedModelProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining PersistedModelProvider. Created by vwoeltje on 11/12/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * A model service which reads domain object models from an external @@ -84,9 +82,9 @@ define( } // Package the result as id->model - function packageResult(parsedIds, models) { + function packageResult(parsedIdsToPackage, models) { var result = {}; - parsedIds.forEach(function (parsedId, index) { + parsedIdsToPackage.forEach(function (parsedId, index) { var id = parsedId.id; if (models[index]) { result[id] = models[index]; @@ -95,11 +93,11 @@ define( return result; } - function loadModels(parsedIds) { - return $q.all(parsedIds.map(loadModel)) + function loadModels(parsedIdsToLoad) { + return $q.all(parsedIdsToLoad.map(loadModel)) .then(function (models) { return packageResult( - parsedIds, + parsedIdsToLoad, models.map(addPersistedTimestamp) ); }); diff --git a/platform/core/src/models/RootModelProvider.js b/platform/core/src/models/RootModelProvider.js index 7c582449d5..83c9636e37 100644 --- a/platform/core/src/models/RootModelProvider.js +++ b/platform/core/src/models/RootModelProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining RootModelProvider. Created by vwoeltje on 11/7/14. @@ -27,7 +26,6 @@ define( ['./StaticModelProvider'], function (StaticModelProvider) { - "use strict"; /** * Provides the root object (id = "ROOT"), which is the top-level @@ -48,7 +46,9 @@ define( */ function RootModelProvider(roots, $q, $log) { // 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 roots.forEach(function (root) { diff --git a/platform/core/src/models/StaticModelProvider.js b/platform/core/src/models/StaticModelProvider.js index ea5846b07a..53051a5b6f 100644 --- a/platform/core/src/models/StaticModelProvider.js +++ b/platform/core/src/models/StaticModelProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining StaticModelProvider. Created by vwoeltje on 11/7/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Loads static models, provided as declared extensions of bundles. diff --git a/platform/core/src/objects/DomainObjectImpl.js b/platform/core/src/objects/DomainObjectImpl.js index 5c2c270a23..14722f97c1 100644 --- a/platform/core/src/objects/DomainObjectImpl.js +++ b/platform/core/src/objects/DomainObjectImpl.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining DomainObject. Created by vwoeltje on 11/7/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * A domain object is an entity of interest to the user. diff --git a/platform/core/src/objects/DomainObjectProvider.js b/platform/core/src/objects/DomainObjectProvider.js index 800d31f5d5..496d29d117 100644 --- a/platform/core/src/objects/DomainObjectProvider.js +++ b/platform/core/src/objects/DomainObjectProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * This bundle implements core components of Open MCT Web's service @@ -29,7 +28,6 @@ define( [], function () { - "use strict"; /** * Provides instances of domain objects, as retrieved by their @@ -63,7 +61,7 @@ define( * @memberof platform/core * @constructor */ - function DomainObjectProvider(modelService, instantiate, $q) { + function DomainObjectProvider(modelService, instantiate) { this.modelService = modelService; this.instantiate = instantiate; } @@ -77,7 +75,7 @@ define( // from this service. function assembleResult(models) { var result = {}; - ids.forEach(function (id, index) { + ids.forEach(function (id) { if (models[id]) { // Create the domain object result[id] = instantiate(models[id], id); diff --git a/platform/core/src/services/Contextualize.js b/platform/core/src/services/Contextualize.js index d231557369..380643f5b3 100644 --- a/platform/core/src/services/Contextualize.js +++ b/platform/core/src/services/Contextualize.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['../capabilities/ContextualDomainObject'], function (ContextualDomainObject) { - "use strict"; /** * Wrap a domain object such that it has a `context` capability diff --git a/platform/core/src/services/Instantiate.js b/platform/core/src/services/Instantiate.js index 2b6032e80e..a6d4b4e96b 100644 --- a/platform/core/src/services/Instantiate.js +++ b/platform/core/src/services/Instantiate.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( ['../objects/DomainObjectImpl'], function (DomainObjectImpl) { - 'use strict'; /** * The `instantiate` service allows new domain object instances to be diff --git a/platform/core/src/services/Now.js b/platform/core/src/services/Now.js index e1a639fe11..839983a594 100644 --- a/platform/core/src/services/Now.js +++ b/platform/core/src/services/Now.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Defines the `now` service, which is a simple wrapper upon diff --git a/platform/core/src/services/Throttle.js b/platform/core/src/services/Throttle.js index 4b1ad32530..959ebd904c 100644 --- a/platform/core/src/services/Throttle.js +++ b/platform/core/src/services/Throttle.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Throttler for function executions, registered as the `throttle` diff --git a/platform/core/src/services/Topic.js b/platform/core/src/services/Topic.js index 99f042cd43..2879ce4406 100644 --- a/platform/core/src/services/Topic.js +++ b/platform/core/src/services/Topic.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; var ERROR_PREFIX = "Error when notifying listener: "; diff --git a/platform/core/src/types/MergeModels.js b/platform/core/src/types/MergeModels.js index b3df6d65ae..a33c6dba40 100644 --- a/platform/core/src/types/MergeModels.js +++ b/platform/core/src/types/MergeModels.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Defines MergedModel, which allows a deep merge of domain object @@ -28,7 +27,6 @@ */ define( function () { - 'use strict'; /** * Utility function for merging domain object models (or any @@ -60,14 +58,14 @@ define( * corresponding keys in the recursive step. * * - * @param a the first object to be merged - * @param b the second object to be merged + * @param modelA the first object to be merged + * @param modelB the second object to be merged * @param merger the merger, as described above - * @returns {*} the result of merging `a` and `b` + * @returns {*} the result of merging `modelA` and `modelB` * @constructor * @memberof platform/core */ - function mergeModels(a, b, merger) { + function mergeModels(modelA, modelB, merger) { var mergeFunction; function mergeArrays(a, b) { @@ -95,11 +93,11 @@ define( } mergeFunction = (merger && Function.isFunction(merger)) ? merger : - (Array.isArray(a) && Array.isArray(b)) ? mergeArrays : - (a instanceof Object && b instanceof Object) ? mergeObjects : + (Array.isArray(modelA) && Array.isArray(modelB)) ? mergeArrays : + (modelA instanceof Object && modelB instanceof Object) ? mergeObjects : mergeOther; - return mergeFunction(a, b); + return mergeFunction(modelA, modelB); } return mergeModels; diff --git a/platform/core/src/types/TypeCapability.js b/platform/core/src/types/TypeCapability.js index 883c8dc7ab..ee0f922b8e 100644 --- a/platform/core/src/types/TypeCapability.js +++ b/platform/core/src/types/TypeCapability.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining TypeCapability. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * The `type` capability makes information about a domain object's diff --git a/platform/core/src/types/TypeImpl.js b/platform/core/src/types/TypeImpl.js index 333f37663f..5e25ecbc93 100644 --- a/platform/core/src/types/TypeImpl.js +++ b/platform/core/src/types/TypeImpl.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TypeProperty'], function (TypeProperty) { - "use strict"; /** * Describes a type of domain object. diff --git a/platform/core/src/types/TypeProperty.js b/platform/core/src/types/TypeProperty.js index 70aaf8fbf8..7b5c85b2e7 100644 --- a/platform/core/src/types/TypeProperty.js +++ b/platform/core/src/types/TypeProperty.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TypePropertyConversion'], function (TypePropertyConversion) { - 'use strict'; /** * Instantiate a property associated with domain objects of a diff --git a/platform/core/src/types/TypePropertyConversion.js b/platform/core/src/types/TypePropertyConversion.js index 6f8344e3d7..e2d1cea984 100644 --- a/platform/core/src/types/TypePropertyConversion.js +++ b/platform/core/src/types/TypePropertyConversion.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( function () { - 'use strict'; var conversions = { @@ -35,8 +33,12 @@ define( } }, identity: { - toModelValue: function (v) { return v; }, - toFormValue: function (v) { return v; } + toModelValue: function (v) { + return v; + }, + toFormValue: function (v) { + return v; + } } }, ARRAY_SUFFIX = '[]'; diff --git a/platform/core/src/types/TypeProvider.js b/platform/core/src/types/TypeProvider.js index d8b6475d58..b30efce0d9 100644 --- a/platform/core/src/types/TypeProvider.js +++ b/platform/core/src/types/TypeProvider.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TypeImpl', './MergeModels'], function (TypeImpl, mergeModels) { - 'use strict'; /** * Provides domain object types that are available/recognized within @@ -161,8 +159,8 @@ define( } function lookupTypeDef(typeKey) { - function buildTypeDef(typeKey) { - var typeDefs = typeDefinitions[typeKey] || [], + function buildTypeDef(typeKeyToBuild) { + var typeDefs = typeDefinitions[typeKeyToBuild] || [], inherits = typeDefs.map(function (typeDef) { return asArray(typeDef.inherits || []); }).reduce(function (a, b) { @@ -177,11 +175,11 @@ define( // Always provide a default name def.model = def.model || {}; def.model.name = def.model.name || - ("Unnamed " + (def.name || "Object")); + ("Unnamed " + (def.name || "Object")); return def; } - + return (self.typeMap[typeKey] = self.typeMap[typeKey] || buildTypeDef(typeKey)); } diff --git a/platform/core/src/views/ViewCapability.js b/platform/core/src/views/ViewCapability.js index 38862cf2fc..c2bfaa6d51 100644 --- a/platform/core/src/views/ViewCapability.js +++ b/platform/core/src/views/ViewCapability.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ViewCapability. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * A `view` capability can be used to retrieve an array of diff --git a/platform/core/src/views/ViewProvider.js b/platform/core/src/views/ViewProvider.js index e2034c3d6b..7af298c7e8 100644 --- a/platform/core/src/views/ViewProvider.js +++ b/platform/core/src/views/ViewProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ViewProvider. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Provides definitions for views that are available for specific @@ -107,15 +105,15 @@ define( // Check if an object has all capabilities designated as `needs` // for a view. Exposing a capability via delegation is taken to // satisfy this filter if `allowDelegation` is true. - function capabilitiesMatch(domainObject, capabilities, allowDelegation) { - var delegation = domainObject.getCapability("delegation"); + function capabilitiesMatch(domainObj, capabilities, allowDelegation) { + var delegation = domainObj.getCapability("delegation"); allowDelegation = allowDelegation && (delegation !== undefined); // Check if an object has (or delegates, if allowed) a // capability. function hasCapability(c) { - return domainObject.hasCapability(c) || + return domainObj.hasCapability(c) || (allowDelegation && delegation.doesDelegateCapability(c)); } @@ -130,13 +128,13 @@ define( // Check if a view and domain object type can be paired; // both can restrict the others they accept. - function viewMatchesType(view, type) { - var views = type && (type.getDefinition() || {}).views, + function viewMatchesType(view, objType) { + var views = objType && (objType.getDefinition() || {}).views, matches = true; // View is restricted to a certain 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 diff --git a/platform/core/test/actions/ActionAggregatorSpec.js b/platform/core/test/actions/ActionAggregatorSpec.js index e665c3cb89..09dddff5af 100644 --- a/platform/core/test/actions/ActionAggregatorSpec.js +++ b/platform/core/test/actions/ActionAggregatorSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * ActionAggregatorSpec. Created by vwoeltje on 11/6/14. @@ -27,14 +26,13 @@ define( ["../../src/actions/ActionAggregator"], function (ActionAggregator) { - "use strict"; describe("Action aggregator", function () { var mockAggregators, aggregator; function createMockActionProvider(actions, i) { - var spy = jasmine.createSpyObj("agg" + i, [ "getActions" ]); + var spy = jasmine.createSpyObj("agg" + i, ["getActions"]); spy.getActions.andReturn(actions); return spy; } @@ -71,4 +69,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/core/test/actions/ActionCapabilitySpec.js b/platform/core/test/actions/ActionCapabilitySpec.js index ab3db012f1..dd83a88082 100644 --- a/platform/core/test/actions/ActionCapabilitySpec.js +++ b/platform/core/test/actions/ActionCapabilitySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * ActionCapabilitySpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/actions/ActionCapability"], function (ActionCapability) { - "use strict"; describe("The action capability", function () { var mockQ, @@ -39,19 +37,19 @@ define( beforeEach(function () { mockAction = jasmine.createSpyObj( "action", - [ "perform", "getMetadata" ] + ["perform", "getMetadata"] ); mockActionService = jasmine.createSpyObj( "actionService", - [ "getActions" ] + ["getActions"] ); mockQ = jasmine.createSpyObj( "$q", - [ "when" ] + ["when"] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ] + ["getId", "getModel", "getCapability", "hasCapability", "useCapability"] ); mockActionService.getActions.andReturn([mockAction, {}]); @@ -78,7 +76,7 @@ define( }); it("promises the result of performed actions", function () { - var mockPromise = jasmine.createSpyObj("promise", [ "then" ]); + var mockPromise = jasmine.createSpyObj("promise", ["then"]); mockQ.when.andReturn(mockPromise); mockAction.perform.andReturn("the action's result"); @@ -97,4 +95,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/actions/ActionProviderSpec.js b/platform/core/test/actions/ActionProviderSpec.js index 14c719f0c2..dce95dd1e5 100644 --- a/platform/core/test/actions/ActionProviderSpec.js +++ b/platform/core/test/actions/ActionProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * ActionProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/actions/ActionProvider"], function (ActionProvider) { - "use strict"; describe("The action provider", function () { var mockLog, @@ -35,29 +33,41 @@ define( actionProvider; function SimpleAction() { - return { perform: function () { return "simple"; } }; + return { perform: function () { + return "simple"; + } }; } function CategorizedAction() { - return { perform: function () { return "categorized"; } }; + return { perform: function () { + return "categorized"; + } }; } CategorizedAction.category = "someCategory"; function KeyedAction() { - return { perform: function () { return "keyed"; } }; + return { perform: function () { + return "keyed"; + } }; } KeyedAction.key = "someKey"; function CategorizedKeyedAction() { - return { perform: function () { return "both"; } }; + return { perform: function () { + return "both"; + } }; } CategorizedKeyedAction.key = "someKey"; CategorizedKeyedAction.category = "someCategory"; function MetadataAction() { return { - perform: function () { return "metadata"; }, - getMetadata: function () { return "custom metadata"; } + perform: function () { + return "metadata"; + }, + getMetadata: function () { + return "custom metadata"; + } }; } MetadataAction.key = "metadata"; @@ -154,7 +164,7 @@ define( } provided = new ActionProvider( - [ SimpleAction, BadAction ], + [SimpleAction, BadAction], mockLog ).getActions(); }); diff --git a/platform/core/test/actions/LoggingActionDecoratorSpec.js b/platform/core/test/actions/LoggingActionDecoratorSpec.js index 3526457495..3e0e9b98e9 100644 --- a/platform/core/test/actions/LoggingActionDecoratorSpec.js +++ b/platform/core/test/actions/LoggingActionDecoratorSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * LoggingActionDecoratorSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/actions/LoggingActionDecorator"], function (LoggingActionDecorator) { - "use strict"; describe("The logging action decorator", function () { var mockLog, @@ -38,15 +36,15 @@ define( beforeEach(function () { mockAction = jasmine.createSpyObj( "action", - [ "perform", "getMetadata" ] + ["perform", "getMetadata"] ); mockActionService = jasmine.createSpyObj( "actionService", - [ "getActions" ] + ["getActions"] ); mockLog = jasmine.createSpyObj( "$log", - [ "error", "warn", "info", "debug" ] + ["error", "warn", "info", "debug"] ); mockActionService.getActions.andReturn([mockAction]); @@ -72,4 +70,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/capabilities/CompositionCapabilitySpec.js b/platform/core/test/capabilities/CompositionCapabilitySpec.js index 98cc1916d2..ca0410123e 100644 --- a/platform/core/test/capabilities/CompositionCapabilitySpec.js +++ b/platform/core/test/capabilities/CompositionCapabilitySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * CompositionCapabilitySpec. Created by vwoeltje on 11/6/14. @@ -30,7 +29,6 @@ define( "../../src/capabilities/ContextualDomainObject" ], function (CompositionCapability, ContextualDomainObject) { - "use strict"; var DOMAIN_OBJECT_METHODS = [ "getId", @@ -66,7 +64,7 @@ define( mockObjectService = jasmine.createSpyObj( "objectService", - [ "getObjects" ] + ["getObjects"] ); mockInjector = { @@ -99,7 +97,7 @@ define( }); it("requests ids found in model's composition from the object service", function () { - var ids = [ "a", "b", "c", "xyz" ]; + var ids = ["a", "b", "c", "xyz"]; mockDomainObject.getModel.andReturn({ composition: ids }); @@ -116,7 +114,9 @@ define( mockObjectService.getObjects.andReturn(mockPromise({x: mockChild})); 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 expect(result[0].getCapability('context')).toBeDefined(); @@ -155,7 +155,7 @@ define( it("does not re-add IDs which are already present", function () { var result, - testModel = { composition: [ 'a' ] }, + testModel = { composition: ['a'] }, mockChild = jasmine.createSpyObj("child", DOMAIN_OBJECT_METHODS); mockDomainObject.getModel.andReturn(testModel); @@ -186,7 +186,7 @@ define( it("can add objects at a specified index", function () { var result, - testModel = { composition: [ 'a', 'b', 'c' ] }, + testModel = { composition: ['a', 'b', 'c'] }, mockChild = jasmine.createSpyObj("child", DOMAIN_OBJECT_METHODS); mockDomainObject.getModel.andReturn(testModel); diff --git a/platform/core/test/capabilities/ContextCapabilitySpec.js b/platform/core/test/capabilities/ContextCapabilitySpec.js index 5ca6adc9e6..08e5ff952b 100644 --- a/platform/core/test/capabilities/ContextCapabilitySpec.js +++ b/platform/core/test/capabilities/ContextCapabilitySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * ContextCapability. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/capabilities/ContextCapability"], function (ContextCapability) { - "use strict"; var DOMAIN_OBJECT_METHODS = [ "getId", @@ -48,7 +46,7 @@ define( mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS); mockParent = jasmine.createSpyObj("parent", DOMAIN_OBJECT_METHODS); mockGrandparent = jasmine.createSpyObj("grandparent", DOMAIN_OBJECT_METHODS); - mockContext = jasmine.createSpyObj("context", [ "getParent", "getRoot", "getPath" ]); + mockContext = jasmine.createSpyObj("context", ["getParent", "getRoot", "getPath"]); mockParent.getCapability.andReturn(mockContext); mockContext.getParent.andReturn(mockGrandparent); @@ -79,4 +77,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/capabilities/ContextualDomainObjectSpec.js b/platform/core/test/capabilities/ContextualDomainObjectSpec.js index f2bf99bceb..00b9e63746 100644 --- a/platform/core/test/capabilities/ContextualDomainObjectSpec.js +++ b/platform/core/test/capabilities/ContextualDomainObjectSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * ContextualDomainObjectSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/capabilities/ContextualDomainObject"], function (ContextualDomainObject) { - "use strict"; var DOMAIN_OBJECT_METHODS = [ @@ -81,4 +79,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/capabilities/CoreCapabilityProviderSpec.js b/platform/core/test/capabilities/CoreCapabilityProviderSpec.js index 26df72c4d7..55ec9ca303 100644 --- a/platform/core/test/capabilities/CoreCapabilityProviderSpec.js +++ b/platform/core/test/capabilities/CoreCapabilityProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * CoreCapabilityProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,22 +26,27 @@ define( ["../../src/capabilities/CoreCapabilityProvider"], function (CoreCapabilityProvider) { - "use strict"; describe("The core capability provider", function () { var mockLog, provider; - function BasicCapability() { return; } + function BasicCapability() { + return; + } BasicCapability.key = "basic"; - function ApplicableCapability() { return; } + function ApplicableCapability() { + return; + } ApplicableCapability.key = "applicable"; ApplicableCapability.appliesTo = function (model) { return !model.isNotApplicable; }; - function KeylessCapability() { return; } + function KeylessCapability() { + return; + } beforeEach(function () { mockLog = jasmine.createSpyObj( diff --git a/platform/core/test/capabilities/DelegationCapabilitySpec.js b/platform/core/test/capabilities/DelegationCapabilitySpec.js index c5267bdfee..b803b64861 100644 --- a/platform/core/test/capabilities/DelegationCapabilitySpec.js +++ b/platform/core/test/capabilities/DelegationCapabilitySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * DelegationCapabilitySpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/capabilities/DelegationCapability"], function (DelegationCapability) { - "use strict"; describe("The delegation capability", function () { var captured, @@ -38,7 +36,11 @@ define( object = {}, delegation; - function capture(k) { return function (v) { captured[k] = v; }; } + function capture(k) { + return function (v) { + captured[k] = v; + }; + } function TestDomainObject(caps, id) { return { getId: function () { @@ -69,12 +71,16 @@ define( beforeEach(function () { captured = {}; typeDef = {}; - typeDef.delegates = [ "foo" ]; - type = { getDefinition: function () { return typeDef; } }; + typeDef.delegates = ["foo"]; + type = { getDefinition: function () { + return typeDef; + } }; children = []; capabilities = { type: type, - composition: { invoke: function () { return mockPromise(children); } } + composition: { invoke: function () { + return mockPromise(children); + } } }; object = new TestDomainObject(capabilities); @@ -97,4 +103,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/core/test/capabilities/InstantiationCapabilitySpec.js b/platform/core/test/capabilities/InstantiationCapabilitySpec.js index d14ebf8292..b65f26f368 100644 --- a/platform/core/test/capabilities/InstantiationCapabilitySpec.js +++ b/platform/core/test/capabilities/InstantiationCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,xdescribe,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/capabilities/InstantiationCapability"], function (InstantiationCapability) { - 'use strict'; describe("The 'instantiation' capability", function () { var mockInjector, @@ -40,15 +38,15 @@ define( mockInstantiate = jasmine.createSpy("instantiate"); mockIdentifierService = jasmine.createSpyObj( 'identifierService', - [ 'parse', 'generate' ] + ['parse', 'generate'] ); mockIdentifier = jasmine.createSpyObj( 'identifier', - [ 'getSpace', 'getKey', 'getDefinedSpace' ] + ['getSpace', 'getKey', 'getDefinedSpace'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getCapability', 'getModel' ] + ['getId', 'getCapability', 'getModel'] ); mockInjector.get.andCallFake(function (key) { @@ -75,16 +73,16 @@ define( }); it("uses the instantiate service to create domain objects", function () { - var mockDomainObject = jasmine.createSpyObj('domainObject', [ + var mockDomainObj = jasmine.createSpyObj('domainObject', [ 'getId', 'getModel', 'getCapability', 'useCapability', 'hasCapability' ]), testModel = { someKey: "some value" }; - mockInstantiate.andReturn(mockDomainObject); + mockInstantiate.andReturn(mockDomainObj); expect(instantiation.instantiate(testModel)) - .toBe(mockDomainObject); + .toBe(mockDomainObj); expect(mockInstantiate) .toHaveBeenCalledWith({ someKey: "some value", diff --git a/platform/core/test/capabilities/MetadataCapabilitySpec.js b/platform/core/test/capabilities/MetadataCapabilitySpec.js index 0a04e1d1ea..c558cb7e1d 100644 --- a/platform/core/test/capabilities/MetadataCapabilitySpec.js +++ b/platform/core/test/capabilities/MetadataCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../../src/capabilities/MetadataCapability'], function (MetadataCapability) { - "use strict"; describe("The metadata capability", function () { var mockDomainObject, diff --git a/platform/core/test/capabilities/MutationCapabilitySpec.js b/platform/core/test/capabilities/MutationCapabilitySpec.js index 434ddfb098..d84a2edec1 100644 --- a/platform/core/test/capabilities/MutationCapabilitySpec.js +++ b/platform/core/test/capabilities/MutationCapabilitySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MutationCapabilitySpec. Created by vwoeltje on 11/6/14. @@ -30,15 +29,18 @@ define( "../../src/services/Topic" ], function (MutationCapability, Topic) { - "use strict"; describe("The mutation capability", function () { var testModel, topic, mockNow, domainObject = { - getId: function () { return "test-id"; }, - getModel: function () { return testModel; } + getId: function () { + return "test-id"; + }, + getModel: function () { + return testModel; + } }, mutation; @@ -62,7 +64,7 @@ define( }); it("allows setting a model", function () { - mutation.invoke(function (m) { + mutation.invoke(function () { return { someKey: "some value" }; }); expect(testModel.number).toBeUndefined(); diff --git a/platform/core/test/capabilities/PersistenceCapabilitySpec.js b/platform/core/test/capabilities/PersistenceCapabilitySpec.js index 7e214db147..ca37936735 100644 --- a/platform/core/test/capabilities/PersistenceCapabilitySpec.js +++ b/platform/core/test/capabilities/PersistenceCapabilitySpec.js @@ -19,8 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ -/*jslint es5: true */ /** * PersistenceCapabilitySpec. Created by vwoeltje on 11/6/14. @@ -28,7 +26,6 @@ define( ["../../src/capabilities/PersistenceCapability"], function (PersistenceCapability) { - "use strict"; describe("The persistence capability", function () { var mockPersistenceService, @@ -49,10 +46,10 @@ define( then: function (callback) { return asPromise(callback(value)); }, - catch: function(callback) { + catch: function (callback) { //Define a default 'happy' catch, that skips over the // catch callback - return doCatch ? asPromise(callback(value)): asPromise(value); + return doCatch ? asPromise(callback(value)) : asPromise(value); } }; } @@ -63,16 +60,16 @@ define( mockPersistenceService = jasmine.createSpyObj( "persistenceService", - [ "updateObject", "readObject", "createObject", "deleteObject" ] + ["updateObject", "readObject", "createObject", "deleteObject"] ); mockIdentifierService = jasmine.createSpyObj( 'identifierService', - [ 'parse', 'generate' ] + ['parse', 'generate'] ); mockIdentifier = jasmine.createSpyObj( 'identifier', - [ 'getSpace', 'getKey', 'getDefinedSpace' ] + ['getSpace', 'getKey', 'getDefinedSpace'] ); mockQ = jasmine.createSpyObj( "$q", @@ -84,12 +81,16 @@ define( ); mockCacheService = jasmine.createSpyObj( "cacheService", - [ "get", "put", "remove", "all" ] + ["get", "put", "remove", "all"] ); mockDomainObject = { - getId: function () { return id; }, - getModel: function () { return model; }, + getId: function () { + return id; + }, + getModel: function () { + return model; + }, useCapability: jasmine.createSpy() }; // Simulate mutation capability @@ -110,7 +111,7 @@ define( ); }); - describe("successful persistence", function() { + describe("successful persistence", function () { beforeEach(function () { mockPersistenceService.updateObject.andReturn(happyPromise); mockPersistenceService.createObject.andReturn(happyPromise); @@ -158,18 +159,6 @@ define( expect(model).toEqual(refreshModel); }); - it("does not overwrite unpersisted changes on refresh", function () { - var refreshModel = {someOtherKey: "some other value"}, - mockCallback = jasmine.createSpy(); - model.modified = 2; - model.persisted = 1; - mockPersistenceService.readObject.andReturn(asPromise(refreshModel)); - persistence.refresh().then(mockCallback); - expect(model).not.toEqual(refreshModel); - // Should have also indicated that no changes were actually made - expect(mockCallback).toHaveBeenCalledWith(false); - }); - it("does not trigger error notification on successful" + " persistence", function () { persistence.persist(); @@ -178,9 +167,9 @@ define( }); }); - describe("unsuccessful persistence", function() { + describe("unsuccessful persistence", function () { var sadPromise = { - then: function(callback){ + then: function (callback) { return asPromise(callback(0), true); } }; diff --git a/platform/core/test/capabilities/RelationshipCapabilitySpec.js b/platform/core/test/capabilities/RelationshipCapabilitySpec.js index 5695878144..4e2b8f9cc8 100644 --- a/platform/core/test/capabilities/RelationshipCapabilitySpec.js +++ b/platform/core/test/capabilities/RelationshipCapabilitySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * CompositionCapabilitySpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/capabilities/RelationshipCapability"], function (RelationshipCapability) { - "use strict"; var DOMAIN_OBJECT_METHODS = [ "getId", @@ -62,7 +60,7 @@ define( mockObjectService = jasmine.createSpyObj( "objectService", - [ "getObjects" ] + ["getObjects"] ); mockInjector = { @@ -87,7 +85,7 @@ define( }); it("requests ids found in model's composition from the object service", function () { - var ids = [ "a", "b", "c", "xyz" ]; + var ids = ["a", "b", "c", "xyz"]; mockDomainObject.getModel.andReturn({ relationships: { xyz: ids } }); @@ -98,7 +96,7 @@ define( it("provides a list of relationship types", function () { mockDomainObject.getModel.andReturn({ relationships: { - abc: [ 'a', 'b' ], + abc: ['a', 'b'], def: "not an array, should be ignored", xyz: [] } }); @@ -106,10 +104,8 @@ define( }); it("avoids redundant requests", function () { - // Lookups can be expensive, so this capability + // Lookups can be expensive, so this capability // should have some self-caching - var response; - mockDomainObject.getModel .andReturn({ relationships: { xyz: ['a'] } }); @@ -125,7 +121,7 @@ define( it("makes new requests on modification", function () { // Lookups can be expensive, so this capability // should have some self-caching - var response, testModel; + var testModel; testModel = { relationships: { xyz: ['a'] } }; @@ -143,4 +139,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/identifiers/IdentifierProviderSpec.js b/platform/core/test/identifiers/IdentifierProviderSpec.js index c424984fef..c4dbb56533 100644 --- a/platform/core/test/identifiers/IdentifierProviderSpec.js +++ b/platform/core/test/identifiers/IdentifierProviderSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/identifiers/IdentifierProvider"], function (IdentifierProvider) { - 'use strict'; describe("IdentifierProvider", function () { var defaultSpace, diff --git a/platform/core/test/identifiers/IdentifierSpec.js b/platform/core/test/identifiers/IdentifierSpec.js index 81433f1072..e54a853712 100644 --- a/platform/core/test/identifiers/IdentifierSpec.js +++ b/platform/core/test/identifiers/IdentifierSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/identifiers/Identifier"], function (Identifier) { - 'use strict'; describe("A parsed domain object identifier", function () { var id, @@ -36,7 +34,7 @@ define( }); describe("when space is encoded", function () { - var idSpace, idKey, spacedId; + var idSpace, idKey; beforeEach(function () { idSpace = "a-specific-space"; diff --git a/platform/core/test/models/CachingModelDecoratorSpec.js b/platform/core/test/models/CachingModelDecoratorSpec.js index d6103dabd9..73a0957b28 100644 --- a/platform/core/test/models/CachingModelDecoratorSpec.js +++ b/platform/core/test/models/CachingModelDecoratorSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( [ @@ -27,7 +26,6 @@ define( "../../src/models/ModelCacheService" ], function (CachingModelDecorator, ModelCacheService) { - "use strict"; describe("The caching model decorator", function () { var mockModelService, @@ -101,7 +99,7 @@ define( }); it("ensures a single object instance, even for multiple concurrent calls", function () { - var promiseA, promiseB, mockCallback = jasmine.createSpy(); + var promiseA, promiseB; promiseA = fakePromise(); promiseB = fakePromise(); @@ -128,7 +126,7 @@ define( }); it("is robust against updating with undefined values", function () { - var promiseA, promiseB, mockCallback = jasmine.createSpy(); + var promiseA, promiseB; promiseA = fakePromise(); promiseB = fakePromise(); diff --git a/platform/core/test/models/MissingModelDecoratorSpec.js b/platform/core/test/models/MissingModelDecoratorSpec.js index da9d4fc54c..20d64f40ae 100644 --- a/platform/core/test/models/MissingModelDecoratorSpec.js +++ b/platform/core/test/models/MissingModelDecoratorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/models/MissingModelDecorator"], function (MissingModelDecorator) { - "use strict"; describe("The missing model decorator", function () { var mockModelService, @@ -42,7 +40,7 @@ define( beforeEach(function () { mockModelService = jasmine.createSpyObj( "modelService", - [ "getModels" ] + ["getModels"] ); testModels = { @@ -63,14 +61,18 @@ define( it("provides models for any IDs which are missing", function () { var models; decorator.getModels(['testId', 'otherId']) - .then(function (m) { models = m; }); + .then(function (m) { + models = m; + }); expect(models.otherId).toBeDefined(); }); it("does not overwrite existing models", function () { var models; decorator.getModels(['testId', 'otherId']) - .then(function (m) { models = m; }); + .then(function (m) { + models = m; + }); expect(models.testId).toEqual({ someKey: "some value" }); }); diff --git a/platform/core/test/models/ModelAggregatorSpec.js b/platform/core/test/models/ModelAggregatorSpec.js index a8dbe96026..2f5f13c053 100644 --- a/platform/core/test/models/ModelAggregatorSpec.js +++ b/platform/core/test/models/ModelAggregatorSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * ModelAggregatorSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/models/ModelAggregator"], function (ModelAggregator) { - "use strict"; describe("The model aggregator", function () { var mockQ, @@ -39,18 +37,20 @@ define( aggregator; beforeEach(function () { - mockQ = jasmine.createSpyObj("$q", [ "all" ]); + mockQ = jasmine.createSpyObj("$q", ["all"]); mockProviders = modelList.map(function (models, i) { var mockProvider = jasmine.createSpyObj( "mockProvider" + i, - [ "getModels" ] + ["getModels"] ); mockProvider.getModels.andReturn(models); return mockProvider; }); mockQ.all.andReturn({ - then: function (c) { return c(modelList); } + then: function (c) { + return c(modelList); + } }); aggregator = new ModelAggregator(mockQ, mockProviders); @@ -74,4 +74,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/models/ModelCacheServiceSpec.js b/platform/core/test/models/ModelCacheServiceSpec.js index f8254779ab..97e84fa918 100644 --- a/platform/core/test/models/ModelCacheServiceSpec.js +++ b/platform/core/test/models/ModelCacheServiceSpec.js @@ -19,17 +19,15 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define(['../../src/models/ModelCacheService'], function (ModelCacheService) { - 'use strict'; describe("ModelCacheService", function () { var testIds, testModels, cacheService; beforeEach(function () { - testIds = [ 'a', 'b', 'c', 'd' ]; + testIds = ['a', 'b', 'c', 'd']; testModels = testIds.reduce(function (models, id) { models[id] = { someKey: "some value for " + id }; return models; diff --git a/platform/core/test/models/PersistedModelProviderSpec.js b/platform/core/test/models/PersistedModelProviderSpec.js index c611a93bb2..c37444a310 100644 --- a/platform/core/test/models/PersistedModelProviderSpec.js +++ b/platform/core/test/models/PersistedModelProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * PersistedModelProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/models/PersistedModelProvider"], function (PersistedModelProvider) { - "use strict"; describe("The persisted model provider", function () { var mockQ, diff --git a/platform/core/test/models/RootModelProviderSpec.js b/platform/core/test/models/RootModelProviderSpec.js index 3de505a6cd..a3b667b963 100644 --- a/platform/core/test/models/RootModelProviderSpec.js +++ b/platform/core/test/models/RootModelProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * RootModelProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/models/RootModelProvider"], function (RootModelProvider) { - "use strict"; describe("The root model provider", function () { var roots = [ @@ -59,7 +57,9 @@ define( }; } - function capture(value) { captured = value; } + function capture(value) { + captured = value; + } beforeEach(function () { diff --git a/platform/core/test/models/StaticModelProviderSpec.js b/platform/core/test/models/StaticModelProviderSpec.js index 7ff727b1d0..c4073c8d55 100644 --- a/platform/core/test/models/StaticModelProviderSpec.js +++ b/platform/core/test/models/StaticModelProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * StaticModelProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/models/StaticModelProvider"], function (StaticModelProvider) { - "use strict"; describe("The static model provider", function () { var models = [ @@ -57,7 +55,9 @@ define( }); it("provides models from extension declarations", function () { - var mockPromise = { then: function () { return; } }; + var mockPromise = { then: function () { + return; + } }; mockQ.when.andReturn(mockPromise); // Verify that we got the promise as the return value @@ -99,4 +99,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/objects/DomainObjectProviderSpec.js b/platform/core/test/objects/DomainObjectProviderSpec.js index fa6ce01b5c..c8450551f4 100644 --- a/platform/core/test/objects/DomainObjectProviderSpec.js +++ b/platform/core/test/objects/DomainObjectProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/ /** * DomainObjectProviderSpec. Created by vwoeltje on 11/6/14. @@ -30,7 +29,6 @@ define( "../../src/objects/DomainObjectImpl" ], function (DomainObjectProvider, DomainObjectImpl) { - "use strict"; describe("The domain object provider", function () { var mockModelService, @@ -48,16 +46,10 @@ define( }; } - function mockAll(mockPromises) { - return mockPromise(mockPromises.map(function (p) { - return mockPromise(p).testValue; - })); - } - beforeEach(function () { mockModelService = jasmine.createSpyObj( "modelService", - [ "getModels" ] + ["getModels"] ); mockInstantiate = jasmine.createSpy("instantiate"); @@ -72,7 +64,7 @@ define( }); it("requests models from the model service", function () { - var ids = [ "a", "b", "c" ]; + var ids = ["a", "b", "c"]; mockModelService.getModels.andReturn(mockPromise({})); provider.getObjects(ids); expect(mockModelService.getModels).toHaveBeenCalledWith(ids); @@ -80,7 +72,7 @@ define( it("instantiates objects with provided models", function () { - var ids = [ "a", "b", "c"], + var ids = ["a", "b", "c"], model = { someKey: "some value"}, result; mockModelService.getModels.andReturn(mockPromise({ a: model })); diff --git a/platform/core/test/objects/DomainObjectSpec.js b/platform/core/test/objects/DomainObjectSpec.js index 13e8968e0d..de5f9a8841 100644 --- a/platform/core/test/objects/DomainObjectSpec.js +++ b/platform/core/test/objects/DomainObjectSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * DomainObjectSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/objects/DomainObjectImpl"], function (DomainObject) { - "use strict"; describe("A domain object", function () { var testId = "test id", @@ -86,4 +84,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/services/ContextualizeSpec.js b/platform/core/test/services/ContextualizeSpec.js index 7acefcc600..e814033f9f 100644 --- a/platform/core/test/services/ContextualizeSpec.js +++ b/platform/core/test/services/ContextualizeSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/services/Contextualize"], function (Contextualize) { - "use strict"; var DOMAIN_OBJECT_METHODS = [ 'getId', @@ -46,7 +44,7 @@ define( mockLog = jasmine.createSpyObj( "$log", - [ "error", "warn", "info", "debug" ] + ["error", "warn", "info", "debug"] ); mockDomainObject = diff --git a/platform/core/test/services/InstantiateSpec.js b/platform/core/test/services/InstantiateSpec.js index fcad45813a..e1993060f3 100644 --- a/platform/core/test/services/InstantiateSpec.js +++ b/platform/core/test/services/InstantiateSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,xdescribe,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/services/Instantiate"], function (Instantiate) { - 'use strict'; describe("The 'instantiate' service", function () { @@ -47,7 +45,7 @@ define( ); mockIdentifierService = jasmine.createSpyObj( 'identifierService', - [ 'parse', 'generate' ] + ['parse', 'generate'] ); mockCapabilityConstructor = jasmine.createSpy('capability'); mockCapabilityInstance = {}; @@ -63,7 +61,7 @@ define( mockCacheService = jasmine.createSpyObj( 'cacheService', - [ 'get', 'put', 'remove', 'all' ] + ['get', 'put', 'remove', 'all'] ); testModel = { someKey: "some value" }; diff --git a/platform/core/test/services/NowSpec.js b/platform/core/test/services/NowSpec.js index bc5eb37ea7..cb122acf78 100644 --- a/platform/core/test/services/NowSpec.js +++ b/platform/core/test/services/NowSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/services/Now"], function (Now) { - "use strict"; describe("The 'now' service", function () { var now = new Now(); @@ -46,4 +44,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/services/ThrottleSpec.js b/platform/core/test/services/ThrottleSpec.js index 3b361f70bb..f473c6a434 100644 --- a/platform/core/test/services/ThrottleSpec.js +++ b/platform/core/test/services/ThrottleSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/services/Throttle"], function (Throttle) { - "use strict"; describe("The 'throttle' service", function () { var throttle, diff --git a/platform/core/test/services/TopicSpec.js b/platform/core/test/services/TopicSpec.js index 22865a2571..d683f36c6c 100644 --- a/platform/core/test/services/TopicSpec.js +++ b/platform/core/test/services/TopicSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/services/Topic"], function (Topic) { - "use strict"; describe("The 'topic' service", function () { var topic, @@ -36,7 +34,7 @@ define( testMessage = { someKey: "some value"}; mockLog = jasmine.createSpyObj( '$log', - [ 'error', 'warn', 'info', 'debug' ] + ['error', 'warn', 'info', 'debug'] ); mockCallback = jasmine.createSpy('callback'); topic = new Topic(mockLog); diff --git a/platform/core/test/types/MergeModelsSpec.js b/platform/core/test/types/MergeModelsSpec.js index 243b1a1c6f..026c263c9a 100644 --- a/platform/core/test/types/MergeModelsSpec.js +++ b/platform/core/test/types/MergeModelsSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,39 +26,38 @@ define( ["../../src/types/MergeModels"], function (mergeModels) { - "use strict"; describe("Model merger", function () { it("merges models", function () { expect(mergeModels( { "a": "property a", - "b": [ 1, 2, 3 ], + "b": [1, 2, 3], "c": { x: 42, - z: [ 0 ] + z: [0] }, "d": "should be ignored" }, { - "b": [ 4 ], + "b": [4], "c": { y: "property y", - z: [ "h" ] + z: ["h"] }, "d": "property d" } )).toEqual({ "a": "property a", - "b": [ 1, 2, 3, 4 ], + "b": [1, 2, 3, 4], "c": { x: 42, y: "property y", - z: [ 0, "h" ] + z: [0, "h"] }, "d": "property d" }); }); }); } -); \ No newline at end of file +); diff --git a/platform/core/test/types/TypeCapabilitySpec.js b/platform/core/test/types/TypeCapabilitySpec.js index 5906f948e4..03a7ac4adb 100644 --- a/platform/core/test/types/TypeCapabilitySpec.js +++ b/platform/core/test/types/TypeCapabilitySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * TypeCapabilitySpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/types/TypeCapability"], function (TypeCapability) { - "use strict"; describe("The type capability", function () { var mockTypeService, @@ -38,11 +36,11 @@ define( beforeEach(function () { mockTypeService = jasmine.createSpyObj( "typeService", - [ "getType" ] + ["getType"] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); mockType = { someKey: "some value" }; @@ -59,4 +57,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/types/TypeImplSpec.js b/platform/core/test/types/TypeImplSpec.js index 0203058934..9f911de157 100644 --- a/platform/core/test/types/TypeImplSpec.js +++ b/platform/core/test/types/TypeImplSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach*/ define( ['../../src/types/TypeImpl'], function (TypeImpl) { - "use strict"; describe("Type definition wrapper", function () { var testTypeDef, @@ -38,7 +36,7 @@ define( glyph: 't', inherits: ['test-parent-1', 'test-parent-2'], features: ['test-feature-1'], - properties: [ {} ], + properties: [{}], model: {someKey: "some value"} }; type = new TypeImpl(testTypeDef); @@ -76,10 +74,14 @@ define( it("supports instance-of checks by type object", function () { expect(type.instanceOf({ - getKey: function () { return 'test-parent-1'; } + getKey: function () { + return 'test-parent-1'; + } })).toBeTruthy(); expect(type.instanceOf({ - getKey: function () { return 'some-other-type'; } + getKey: function () { + return 'some-other-type'; + } })).toBeFalsy(); }); @@ -112,4 +114,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/core/test/types/TypePropertyConversionSpec.js b/platform/core/test/types/TypePropertyConversionSpec.js index 2e7a14e3f6..280134dd86 100644 --- a/platform/core/test/types/TypePropertyConversionSpec.js +++ b/platform/core/test/types/TypePropertyConversionSpec.js @@ -19,18 +19,16 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,xit,expect,beforeEach*/ define( ['../../src/types/TypePropertyConversion'], function (TypePropertyConversion) { - "use strict"; describe("Type property conversion", function () { it("allows non-conversion when parameter is 'identity'", function () { var conversion = new TypePropertyConversion("identity"); - [ 42, "42", { a: 42 } ].forEach(function (v) { + [42, "42", { a: 42 }].forEach(function (v) { expect(conversion.toFormValue(v)).toBe(v); expect(conversion.toModelValue(v)).toBe(v); }); @@ -63,4 +61,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/types/TypePropertySpec.js b/platform/core/test/types/TypePropertySpec.js index e456ff8d5b..c4cdedeb42 100644 --- a/platform/core/test/types/TypePropertySpec.js +++ b/platform/core/test/types/TypePropertySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,xit,expect,beforeEach*/ define( ['../../src/types/TypeProperty'], function (TypeProperty) { - "use strict"; describe("Type property", function () { @@ -59,7 +57,7 @@ define( it("sets properties by path", function () { var definition = { key: "someKey", - property: [ "some", "property" ] + property: ["some", "property"] }, model = {}, property = new TypeProperty(definition); @@ -70,7 +68,7 @@ define( it("gets properties by path", function () { var definition = { key: "someKey", - property: [ "some", "property" ] + property: ["some", "property"] }, model = { some: { property: "some value" } }, property = new TypeProperty(definition); @@ -80,7 +78,7 @@ define( it("stops looking for properties when a path is invalid", function () { var definition = { key: "someKey", - property: [ "some", "property" ] + property: ["some", "property"] }, property = new TypeProperty(definition); expect(property.getValue(undefined)).toBeUndefined(); @@ -99,7 +97,7 @@ define( it("provides empty arrays for values that are array-like", function () { var definition = { property: "someProperty", - items: [ {}, {}, {} ] + items: [{}, {}, {}] }, model = {}, property = new TypeProperty(definition); @@ -110,7 +108,7 @@ define( it("detects and ignores empty arrays on setValue", function () { var definition = { property: "someProperty", - items: [ {}, {}, {} ] + items: [{}, {}, {}] }, model = {}, property = new TypeProperty(definition); @@ -125,4 +123,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/types/TypeProviderSpec.js b/platform/core/test/types/TypeProviderSpec.js index 24f0a77c73..4d2a359e33 100644 --- a/platform/core/test/types/TypeProviderSpec.js +++ b/platform/core/test/types/TypeProviderSpec.js @@ -19,21 +19,14 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach, waitsFor, runs*/ define( ['../../src/types/TypeProvider'], function (TypeProvider) { - "use strict"; describe("Type provider", function () { var captured = {}, - capture = function (name) { - return function (value) { - captured[name] = value; - }; - }, testTypeDefinitions = [ { key: 'basic', @@ -153,4 +146,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/views/ViewCapabilitySpec.js b/platform/core/test/views/ViewCapabilitySpec.js index d71ce1f597..b4e3b64c2a 100644 --- a/platform/core/test/views/ViewCapabilitySpec.js +++ b/platform/core/test/views/ViewCapabilitySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * ViewCapabilitySpec. Created by vwoeltje on 11/6/14. @@ -27,22 +26,21 @@ define( ["../../src/views/ViewCapability"], function (ViewCapability) { - "use strict"; describe("A view capability", function () { var mockViewService, mockDomainObject, - views = [ {key: "someView"} ], + views = [{key: "someView"}], view; beforeEach(function () { mockViewService = jasmine.createSpyObj( "viewService", - [ "getViews" ] + ["getViews"] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); mockViewService.getViews.andReturn(views); view = new ViewCapability(mockViewService, mockDomainObject); @@ -57,4 +55,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/core/test/views/ViewProviderSpec.js b/platform/core/test/views/ViewProviderSpec.js index c04d827980..6d725708da 100644 --- a/platform/core/test/views/ViewProviderSpec.js +++ b/platform/core/test/views/ViewProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * ViewProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/views/ViewProvider"], function (ViewProvider) { - "use strict"; describe("The view provider", function () { var viewA = { @@ -35,11 +33,11 @@ define( }, viewB = { key: "b", - needs: [ "someCapability" ] + needs: ["someCapability"] }, viewC = { key: "c", - needs: [ "someCapability" ], + needs: ["someCapability"], delegation: true }, capabilities = {}, @@ -111,7 +109,7 @@ define( it("restricts typed views to matching types", function () { var testType = "testType", testView = { key: "x", type: testType }, - provider = new ViewProvider([testView], mockLog); + viewProvider = new ViewProvider([testView], mockLog); // Include a "type" capability capabilities.type = jasmine.createSpyObj( @@ -122,22 +120,21 @@ define( // Should be included when types match capabilities.type.instanceOf.andReturn(true); - expect(provider.getViews(mockDomainObject)) + expect(viewProvider.getViews(mockDomainObject)) .toEqual([testView]); expect(capabilities.type.instanceOf) .toHaveBeenCalledWith(testType); // ...but not when they don't capabilities.type.instanceOf.andReturn(false); - expect(provider.getViews(mockDomainObject)) + expect(viewProvider.getViews(mockDomainObject)) .toEqual([]); }); it("enforces view restrictions from types", function () { - var testType = "testType", - testView = { key: "x" }, - provider = new ViewProvider([testView], mockLog); + var testView = { key: "x" }, + viewProvider = new ViewProvider([testView], mockLog); // Include a "type" capability capabilities.type = jasmine.createSpyObj( @@ -149,16 +146,16 @@ define( // Should be included when view keys match capabilities.type.getDefinition .andReturn({ views: [testView.key]}); - expect(provider.getViews(mockDomainObject)) + expect(viewProvider.getViews(mockDomainObject)) .toEqual([testView]); // ...but not when they don't capabilities.type.getDefinition .andReturn({ views: ["somethingElse"]}); - expect(provider.getViews(mockDomainObject)) + expect(viewProvider.getViews(mockDomainObject)) .toEqual([]); }); }); } -); \ No newline at end of file +); diff --git a/platform/entanglement/bundle.js b/platform/entanglement/bundle.js index 76ad847602..b828f2334f 100644 --- a/platform/entanglement/bundle.js +++ b/platform/entanglement/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/actions/MoveAction", @@ -56,7 +55,6 @@ define([ LocationService, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/entanglement", { "name": "Entanglement", diff --git a/platform/entanglement/src/actions/AbstractComposeAction.js b/platform/entanglement/src/actions/AbstractComposeAction.js index 1dfe5c2567..e81ee4361c 100644 --- a/platform/entanglement/src/actions/AbstractComposeAction.js +++ b/platform/entanglement/src/actions/AbstractComposeAction.js @@ -20,10 +20,8 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * Common interface exposed by services which support move, copy, @@ -128,11 +126,11 @@ define( label = this.verb + " To"; - validateLocation = function (newParent) { + validateLocation = function (newParentObj) { var newContext = self.cloneContext(); newContext.selectedObject = object; - newContext.domainObject = newParent; - return composeService.validate(object, newParent) && + newContext.domainObject = newParentObj; + return composeService.validate(object, newParentObj) && self.policyService.allow("action", self, newContext); }; @@ -141,8 +139,8 @@ define( label, validateLocation, currentParent - ).then(function (newParent) { - return composeService.perform(object, newParent); + ).then(function (newParentObj) { + return composeService.perform(object, newParentObj); }); }; diff --git a/platform/entanglement/src/actions/CopyAction.js b/platform/entanglement/src/actions/CopyAction.js index a03b9cae23..2ed9725c41 100644 --- a/platform/entanglement/src/actions/CopyAction.js +++ b/platform/entanglement/src/actions/CopyAction.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( ['./AbstractComposeAction'], function (AbstractComposeAction) { - "use strict"; /** * The CopyAction is available from context menus and allows a user to @@ -71,7 +69,7 @@ define( * @param totalObjects * @param processed */ - CopyAction.prototype.progress = function(phase, totalObjects, processed){ + CopyAction.prototype.progress = function (phase, totalObjects, processed) { /* Copy has two distinct phases. In the first phase a copy plan is made in memory. During this phase of execution, the user is @@ -80,7 +78,7 @@ define( In the second phase, the copying is taking place, and the user is shown non-invasive banner notifications at the bottom of the screen. */ - if (phase.toLowerCase() === 'preparing' && !this.dialog){ + if (phase.toLowerCase() === 'preparing' && !this.dialog) { this.dialog = this.dialogService.showBlockingMessage({ title: "Preparing to copy objects", unknownProgress: true, @@ -107,15 +105,15 @@ define( * the AbstractComposeAction, but extends it to support notification * updates of progress on copy. */ - CopyAction.prototype.perform = function() { + CopyAction.prototype.perform = function () { var self = this; - function success(){ + function success() { self.notification.dismiss(); self.notificationService.info("Copying complete."); } - function error(errorDetails){ + function error(errorDetails) { var errorMessage = { title: "Error copying objects.", severity: "error", @@ -123,7 +121,7 @@ define( minimized: true, // want the notification to be minimized initially (don't show banner) options: [{ label: "OK", - callback: function() { + callback: function () { self.dialogService.dismiss(); } }] @@ -140,7 +138,7 @@ define( self.dialogService.showBlockingMessage(errorMessage); } - function notification(details){ + function notification(details) { self.progress(details.phase, details.totalObjects, details.processed); } diff --git a/platform/entanglement/src/actions/GoToOriginalAction.js b/platform/entanglement/src/actions/GoToOriginalAction.js index 9722915ad6..f68225d3b3 100644 --- a/platform/entanglement/src/actions/GoToOriginalAction.js +++ b/platform/entanglement/src/actions/GoToOriginalAction.js @@ -20,10 +20,8 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * Implements the "Go To Original" action, which follows a link back @@ -52,8 +50,8 @@ define( GoToOriginalAction.appliesTo = function (context) { var domainObject = context.domainObject; - return domainObject && domainObject.hasCapability("location") - && domainObject.getCapability("location").isLink(); + return domainObject && domainObject.hasCapability("location") && + domainObject.getCapability("location").isLink(); }; return GoToOriginalAction; diff --git a/platform/entanglement/src/actions/LinkAction.js b/platform/entanglement/src/actions/LinkAction.js index 212f1e08fe..29b66655e8 100644 --- a/platform/entanglement/src/actions/LinkAction.js +++ b/platform/entanglement/src/actions/LinkAction.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( ['./AbstractComposeAction'], function (AbstractComposeAction) { - "use strict"; /** * The LinkAction is available from context menus and allows a user to diff --git a/platform/entanglement/src/actions/MoveAction.js b/platform/entanglement/src/actions/MoveAction.js index 070dffbe78..8f525e0c60 100644 --- a/platform/entanglement/src/actions/MoveAction.js +++ b/platform/entanglement/src/actions/MoveAction.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( ['./AbstractComposeAction'], function (AbstractComposeAction) { - "use strict"; /** * The MoveAction is available from context menus and allows a user to diff --git a/platform/entanglement/src/actions/SetPrimaryLocationAction.js b/platform/entanglement/src/actions/SetPrimaryLocationAction.js index 25ebd5ccf8..6fbdf89cbc 100644 --- a/platform/entanglement/src/actions/SetPrimaryLocationAction.js +++ b/platform/entanglement/src/actions/SetPrimaryLocationAction.js @@ -20,10 +20,8 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * Implements the "Set Primary Location" action, which sets a @@ -50,8 +48,8 @@ define( SetPrimaryLocationAction.appliesTo = function (context) { var domainObject = context.domainObject; - return domainObject && domainObject.hasCapability("location") - && (domainObject.getModel().location === undefined); + return domainObject && domainObject.hasCapability("location") && + (domainObject.getModel().location === undefined); }; return SetPrimaryLocationAction; diff --git a/platform/entanglement/src/capabilities/LocationCapability.js b/platform/entanglement/src/capabilities/LocationCapability.js index 27e1f74c74..1e4994beed 100644 --- a/platform/entanglement/src/capabilities/LocationCapability.js +++ b/platform/entanglement/src/capabilities/LocationCapability.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * The location capability allows a domain object to know its current diff --git a/platform/entanglement/src/policies/CopyPolicy.js b/platform/entanglement/src/policies/CopyPolicy.js index 09fe424540..dae3066111 100644 --- a/platform/entanglement/src/policies/CopyPolicy.js +++ b/platform/entanglement/src/policies/CopyPolicy.js @@ -20,9 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define([], function () { - 'use strict'; /** * Disallow duplication when the object to be duplicated is not diff --git a/platform/entanglement/src/policies/CrossSpacePolicy.js b/platform/entanglement/src/policies/CrossSpacePolicy.js index c47e653f08..29aab5a484 100644 --- a/platform/entanglement/src/policies/CrossSpacePolicy.js +++ b/platform/entanglement/src/policies/CrossSpacePolicy.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( [], function () { - 'use strict'; var DISALLOWED_ACTIONS = [ "move", @@ -50,8 +48,7 @@ define( function isCrossSpace(context) { var domainObject = context.domainObject, - selectedObject = context.selectedObject, - spaces = [ domainObject, selectedObject ].map(lookupSpace); + selectedObject = context.selectedObject; return selectedObject !== undefined && domainObject !== undefined && lookupSpace(domainObject) !== lookupSpace(selectedObject); diff --git a/platform/entanglement/src/policies/MovePolicy.js b/platform/entanglement/src/policies/MovePolicy.js index 064b6b7192..0c395f9302 100644 --- a/platform/entanglement/src/policies/MovePolicy.js +++ b/platform/entanglement/src/policies/MovePolicy.js @@ -20,9 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define([], function () { - 'use strict'; /** * Disallow moves when either the parent or the child are not diff --git a/platform/entanglement/src/services/CopyService.js b/platform/entanglement/src/services/CopyService.js index 56155f0b77..37745501ac 100644 --- a/platform/entanglement/src/services/CopyService.js +++ b/platform/entanglement/src/services/CopyService.js @@ -20,12 +20,10 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( - [ "./CopyTask" ], + ["./CopyTask"], function (CopyTask) { - "use strict"; /** * CopyService provides an interface for deep copying objects from one @@ -85,11 +83,11 @@ define( // Combines caller-provided filter (if any) with the // baseline behavior of respecting creation policy. - function filterWithPolicy(domainObject) { - return (!filter || filter(domainObject)) && + function filterWithPolicy(domainObj) { + return (!filter || filter(domainObj)) && policyService.allow( "creation", - domainObject.getCapability("type") + domainObj.getCapability("type") ); } diff --git a/platform/entanglement/src/services/CopyTask.js b/platform/entanglement/src/services/CopyTask.js index 4906d84b2e..0fe97d99d5 100644 --- a/platform/entanglement/src/services/CopyTask.js +++ b/platform/entanglement/src/services/CopyTask.js @@ -20,12 +20,10 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( [], function () { - "use strict"; /** * This class encapsulates the process of copying a domain object @@ -39,7 +37,7 @@ define( * @param $q Angular's $q, for promises * @constructor */ - function CopyTask (domainObject, parent, filter, $q){ + function CopyTask(domainObject, parent, filter, $q) { this.domainObject = domainObject; this.parent = parent; this.firstClone = undefined; @@ -91,11 +89,11 @@ define( * result in automatic request batching by the browser. */ function persistObjects(self) { - return self.$q.all(self.clones.map(function(clone){ - return clone.getCapability("persistence").persist().then(function(){ + return self.$q.all(self.clones.map(function (clone) { + return clone.getCapability("persistence").persist().then(function () { self.deferred.notify({phase: "copying", totalObjects: self.clones.length, processed: ++self.persisted}); }); - })).then(function(){ + })).then(function () { return self; }); } @@ -149,16 +147,16 @@ define( * @private * @returns {*} */ - CopyTask.prototype.copyComposees = function(composees, clonedParent, originalParent){ + CopyTask.prototype.copyComposees = function (composees, clonedParent, originalParent) { var self = this, idMap = {}; - return (composees || []).reduce(function(promise, originalComposee){ + return (composees || []).reduce(function (promise, originalComposee) { //If the composee is composed of other // objects, chain a promise.. - return promise.then(function(){ + return promise.then(function () { // ...to recursively copy it (and its children) - return self.copy(originalComposee, originalParent).then(function(clonedComposee){ + return self.copy(originalComposee, originalParent).then(function (clonedComposee) { //Map the original composee's ID to that of its // clone so that we can replace any references to it // in the parent @@ -169,17 +167,18 @@ define( // set, however linked objects will not. return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee); }); - });}, self.$q.when(undefined) - ).then(function(){ - //Replace any references in the cloned parent to - // contained objects that have been composed with the - // Ids of the clones - self.rewriteIdentifiers(clonedParent.getModel(), idMap); + }); + }, self.$q.when(undefined) + ).then(function () { + //Replace any references in the cloned parent to + // contained objects that have been composed with the + // Ids of the clones + self.rewriteIdentifiers(clonedParent.getModel(), idMap); - //Add the clone to the list of clones that will - //be returned by this function - self.clones.push(clonedParent); - return clonedParent; + //Add the clone to the list of clones that will + //be returned by this function + self.clones.push(clonedParent); + return clonedParent; }); }; @@ -194,7 +193,7 @@ define( * duplication, then a duplicate of the object, otherwise the object * itself (to allow linking to non duplicatable objects). */ - CopyTask.prototype.copy = function(originalObject) { + CopyTask.prototype.copy = function (originalObject) { var self = this, clone; @@ -209,7 +208,7 @@ define( clone = this.parent.useCapability("instantiation", cloneObjectModel(originalObject.getModel())); //Iterate through child tree - return this.$q.when(originalObject.useCapability('composition')).then(function(composees){ + return this.$q.when(originalObject.useCapability('composition')).then(function (composees) { self.deferred.notify({phase: "preparing"}); //Duplicate the object's children, and their children, and // so on down to the leaf nodes of the tree. @@ -236,10 +235,10 @@ define( * object being copied. The clones are all full composed with * references to their own children. */ - CopyTask.prototype.buildCopyPlan = function() { + CopyTask.prototype.buildCopyPlan = function () { var self = this; - return this.copy(self.domainObject, self.parent).then(function(domainObjectClone){ + return this.copy(self.domainObject, self.parent).then(function (domainObjectClone) { if (domainObjectClone !== self.domainObject) { domainObjectClone.getModel().location = self.parent.getId(); } @@ -253,7 +252,7 @@ define( * @returns {promise} Which will resolve with a clone of the object * once complete. */ - CopyTask.prototype.perform = function(){ + CopyTask.prototype.perform = function () { this.deferred = this.$q.defer(); this.buildCopyPlan() @@ -266,4 +265,4 @@ define( return CopyTask; } -); \ No newline at end of file +); diff --git a/platform/entanglement/src/services/LinkService.js b/platform/entanglement/src/services/LinkService.js index 5989c3cf06..a8b2da4401 100644 --- a/platform/entanglement/src/services/LinkService.js +++ b/platform/entanglement/src/services/LinkService.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * LinkService provides an interface for linking objects to additional @@ -69,7 +67,9 @@ define( .then(function (objectInNewContext) { return parentObject.getCapability('persistence') .persist() - .then(function () { return objectInNewContext; }); + .then(function () { + return objectInNewContext; + }); }); }; diff --git a/platform/entanglement/src/services/LocatingCreationDecorator.js b/platform/entanglement/src/services/LocatingCreationDecorator.js index 041cc38138..f76990b80d 100644 --- a/platform/entanglement/src/services/LocatingCreationDecorator.js +++ b/platform/entanglement/src/services/LocatingCreationDecorator.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * Adds a `location` property to newly-created domain objects. diff --git a/platform/entanglement/src/services/LocatingObjectDecorator.js b/platform/entanglement/src/services/LocatingObjectDecorator.js index f4be5f1900..a0ed734aff 100644 --- a/platform/entanglement/src/services/LocatingObjectDecorator.js +++ b/platform/entanglement/src/services/LocatingObjectDecorator.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * Ensures that domain objects are loaded with a context capability diff --git a/platform/entanglement/src/services/LocationService.js b/platform/entanglement/src/services/LocationService.js index cb0a632b4e..42925b8235 100644 --- a/platform/entanglement/src/services/LocationService.js +++ b/platform/entanglement/src/services/LocationService.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ /** * This bundle implements actions which control the location of objects @@ -29,7 +28,6 @@ */ define( function () { - "use strict"; /** * The LocationService allows for easily prompting the user for a @@ -79,8 +77,8 @@ define( return dialogService .getUserInput(formStructure, formState) - .then(function (formState) { - return formState.location; + .then(function (userFormState) { + return userFormState.location; }); } }; diff --git a/platform/entanglement/src/services/MoveService.js b/platform/entanglement/src/services/MoveService.js index 608163310f..a1e2d279e7 100644 --- a/platform/entanglement/src/services/MoveService.js +++ b/platform/entanglement/src/services/MoveService.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * MoveService provides an interface for moving objects from one * location to another. It also provides a method for determining if diff --git a/platform/entanglement/test/ControlledPromise.js b/platform/entanglement/test/ControlledPromise.js index 428bb18d10..94e32c7f7e 100644 --- a/platform/entanglement/test/ControlledPromise.js +++ b/platform/entanglement/test/ControlledPromise.js @@ -1,5 +1,25 @@ -/*global define,spyOn */ - +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global spyOn*/ define( function () { @@ -19,8 +39,8 @@ define( * Resolve the promise, passing the supplied value to all resolve * handlers. */ - ControlledPromise.prototype.resolve = function(value) { - this.resolveHandlers.forEach(function(handler) { + ControlledPromise.prototype.resolve = function (value) { + this.resolveHandlers.forEach(function (handler) { handler(value); }); }; @@ -29,8 +49,8 @@ define( * Reject the promise, passing the supplied value to all rejection * handlers. */ - ControlledPromise.prototype.reject = function(value) { - this.rejectHandlers.forEach(function(handler) { + ControlledPromise.prototype.reject = function (value) { + this.rejectHandlers.forEach(function (handler) { handler(value); }); }; @@ -43,11 +63,11 @@ define( var returnPromise = new ControlledPromise(); if (onResolve) { - this.resolveHandlers.push(function(resolveWith) { + this.resolveHandlers.push(function (resolveWith) { var chainResult = onResolve(resolveWith); if (chainResult && chainResult.then) { // chainResult is a promise, resolve when it resolves. - chainResult.then(function(pipedResult) { + chainResult.then(function (pipedResult) { return returnPromise.resolve(pipedResult); }); } else { @@ -57,10 +77,10 @@ define( } if (onReject) { - this.rejectHandlers.push(function(rejectWith) { + this.rejectHandlers.push(function (rejectWith) { var chainResult = onReject(rejectWith); if (chainResult && chainResult.then) { - chainResult.then(function(pipedResult) { + chainResult.then(function (pipedResult) { returnPromise.reject(pipedResult); }); } else { diff --git a/platform/entanglement/test/DomainObjectFactory.js b/platform/entanglement/test/DomainObjectFactory.js index 3f62841e42..f3fbe28e87 100644 --- a/platform/entanglement/test/DomainObjectFactory.js +++ b/platform/entanglement/test/DomainObjectFactory.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define, jasmine, */ - +/*global jasmine*/ define( function () { - "use strict"; /** * @typedef DomainObjectConfig @@ -155,4 +153,4 @@ define( return domainObjectFactory; } -); \ No newline at end of file +); diff --git a/platform/entanglement/test/actions/AbstractComposeActionSpec.js b/platform/entanglement/test/actions/AbstractComposeActionSpec.js index 1e9bb014f3..cfa49cb758 100644 --- a/platform/entanglement/test/actions/AbstractComposeActionSpec.js +++ b/platform/entanglement/test/actions/AbstractComposeActionSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect */ define( [ @@ -29,7 +28,6 @@ define( '../DomainObjectFactory' ], function (AbstractComposeAction, MockCopyService, domainObjectFactory) { - "use strict"; describe("Move/copy/link Actions", function () { @@ -47,7 +45,7 @@ define( beforeEach(function () { policyService = jasmine.createSpyObj( 'policyService', - [ 'allow' ] + ['allow'] ); selectedObjectContextCapability = jasmine.createSpyObj( diff --git a/platform/entanglement/test/actions/CopyActionSpec.js b/platform/entanglement/test/actions/CopyActionSpec.js index 2ec1fde5a7..176b5baef8 100644 --- a/platform/entanglement/test/actions/CopyActionSpec.js +++ b/platform/entanglement/test/actions/CopyActionSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define( [ @@ -29,7 +28,6 @@ define( '../DomainObjectFactory' ], function (CopyAction, MockCopyService, domainObjectFactory) { - "use strict"; describe("Copy Action", function () { @@ -53,7 +51,7 @@ define( beforeEach(function () { policyService = jasmine.createSpyObj( 'policyService', - [ 'allow' ] + ['allow'] ); policyService.allow.andReturn(true); @@ -107,12 +105,12 @@ define( ] ); - abstractComposePromise.then.andCallFake(function(success, error, notify){ + abstractComposePromise.then.andCallFake(function (success, error, notify) { notify(progress); success(); }); - locationServicePromise.then.andCallFake(function(callback){ + locationServicePromise.then.andCallFake(function (callback) { callback(newParent); return abstractComposePromise; }); @@ -193,7 +191,7 @@ define( .toHaveBeenCalledWith(selectedObject, newParent); }); - it("notifies the user of progress", function(){ + it("notifies the user of progress", function () { expect(notificationService.info).toHaveBeenCalled(); }); diff --git a/platform/entanglement/test/actions/GoToOriginalActionSpec.js b/platform/entanglement/test/actions/GoToOriginalActionSpec.js index 40c2f213ce..a05928239c 100644 --- a/platform/entanglement/test/actions/GoToOriginalActionSpec.js +++ b/platform/entanglement/test/actions/GoToOriginalActionSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect */ define( [ @@ -29,7 +28,6 @@ define( '../ControlledPromise' ], function (GoToOriginalAction, domainObjectFactory, ControlledPromise) { - 'use strict'; describe("The 'go to original' action", function () { var testContext, @@ -42,11 +40,11 @@ define( beforeEach(function () { mockLocationCapability = jasmine.createSpyObj( 'location', - [ 'isLink', 'isOriginal', 'getOriginal' ] + ['isLink', 'isOriginal', 'getOriginal'] ); mockOriginalActionCapability = jasmine.createSpyObj( 'action', - [ 'perform', 'getActions' ] + ['perform', 'getActions'] ); originalPromise = new ControlledPromise(); mockLocationCapability.getOriginal.andReturn(originalPromise); diff --git a/platform/entanglement/test/actions/LinkActionSpec.js b/platform/entanglement/test/actions/LinkActionSpec.js index bf3bd05c6b..fa220831fc 100644 --- a/platform/entanglement/test/actions/LinkActionSpec.js +++ b/platform/entanglement/test/actions/LinkActionSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect */ define( [ @@ -29,7 +28,6 @@ define( '../DomainObjectFactory' ], function (LinkAction, MockLinkService, domainObjectFactory) { - "use strict"; describe("Link Action", function () { @@ -47,7 +45,7 @@ define( beforeEach(function () { policyService = jasmine.createSpyObj( 'policyService', - [ 'allow' ] + ['allow'] ); policyService.allow.andReturn(true); diff --git a/platform/entanglement/test/actions/MoveActionSpec.js b/platform/entanglement/test/actions/MoveActionSpec.js index 868a3ce84a..10c509ea54 100644 --- a/platform/entanglement/test/actions/MoveActionSpec.js +++ b/platform/entanglement/test/actions/MoveActionSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect */ define( [ @@ -29,7 +28,6 @@ define( '../DomainObjectFactory' ], function (MoveAction, MockMoveService, domainObjectFactory) { - "use strict"; describe("Move Action", function () { @@ -47,7 +45,7 @@ define( beforeEach(function () { policyService = jasmine.createSpyObj( 'policyService', - [ 'allow' ] + ['allow'] ); policyService.allow.andReturn(true); diff --git a/platform/entanglement/test/actions/SetPrimaryLocationActionSpec.js b/platform/entanglement/test/actions/SetPrimaryLocationActionSpec.js index 76fb3a344b..fb1d8fa6ef 100644 --- a/platform/entanglement/test/actions/SetPrimaryLocationActionSpec.js +++ b/platform/entanglement/test/actions/SetPrimaryLocationActionSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect */ define( [ @@ -28,14 +27,12 @@ define( '../DomainObjectFactory' ], function (SetPrimaryLocation, domainObjectFactory) { - 'use strict'; describe("The 'set primary location' action", function () { var testContext, testModel, testId, - mockLocationCapability, - mockContextCapability; + mockLocationCapability; beforeEach(function () { testId = "some-id"; @@ -43,7 +40,7 @@ define( mockLocationCapability = jasmine.createSpyObj( 'location', - [ 'setPrimaryLocation', 'getContextualLocation' ] + ['setPrimaryLocation', 'getContextualLocation'] ); mockLocationCapability.getContextualLocation.andReturn(testId); diff --git a/platform/entanglement/test/capabilities/LocationCapabilitySpec.js b/platform/entanglement/test/capabilities/LocationCapabilitySpec.js index 442bfe20aa..fb136a7988 100644 --- a/platform/entanglement/test/capabilities/LocationCapabilitySpec.js +++ b/platform/entanglement/test/capabilities/LocationCapabilitySpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine */ define( [ @@ -29,7 +28,6 @@ define( '../ControlledPromise' ], function (LocationCapability, domainObjectFactory, ControlledPromise) { - 'use strict'; describe("LocationCapability", function () { diff --git a/platform/entanglement/test/policies/CopyPolicySpec.js b/platform/entanglement/test/policies/CopyPolicySpec.js index b53f4d22ed..88eeaec8d8 100644 --- a/platform/entanglement/test/policies/CopyPolicySpec.js +++ b/platform/entanglement/test/policies/CopyPolicySpec.js @@ -20,12 +20,10 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define([ '../../src/policies/CopyPolicy', '../DomainObjectFactory' ], function (CopyPolicy, domainObjectFactory) { - 'use strict'; describe("CopyPolicy", function () { var testMetadata, diff --git a/platform/entanglement/test/policies/CrossSpacePolicySpec.js b/platform/entanglement/test/policies/CrossSpacePolicySpec.js index a0b030f04f..ef09a47619 100644 --- a/platform/entanglement/test/policies/CrossSpacePolicySpec.js +++ b/platform/entanglement/test/policies/CrossSpacePolicySpec.js @@ -20,14 +20,12 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define( [ '../../src/policies/CrossSpacePolicy', '../DomainObjectFactory' ], function (CrossSpacePolicy, domainObjectFactory) { - "use strict"; describe("CrossSpacePolicy", function () { var mockAction, @@ -56,7 +54,7 @@ define( // only define those in mocks. mockAction = jasmine.createSpyObj( 'action', - [ 'getMetadata' ] + ['getMetadata'] ); mockAction.getMetadata.andReturn(testActionMetadata); diff --git a/platform/entanglement/test/policies/MovePolicySpec.js b/platform/entanglement/test/policies/MovePolicySpec.js index d55ad3c697..ab19731a60 100644 --- a/platform/entanglement/test/policies/MovePolicySpec.js +++ b/platform/entanglement/test/policies/MovePolicySpec.js @@ -20,12 +20,10 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define([ '../../src/policies/MovePolicy', '../DomainObjectFactory' ], function (MovePolicy, domainObjectFactory) { - 'use strict'; describe("MovePolicy", function () { var testMetadata, diff --git a/platform/entanglement/test/services/CopyServiceSpec.js b/platform/entanglement/test/services/CopyServiceSpec.js index fb5092ba65..b52e7aab6a 100644 --- a/platform/entanglement/test/services/CopyServiceSpec.js +++ b/platform/entanglement/test/services/CopyServiceSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define( [ @@ -28,7 +27,6 @@ define( '../DomainObjectFactory' ], function (CopyService, domainObjectFactory) { - "use strict"; function synchronousPromise(value) { if (value && value.then) { @@ -126,10 +124,8 @@ define( var mockQ, mockDeferred, - creationService, createObjectPromise, copyService, - mockNow, object, newParent, copyResult, @@ -149,12 +145,12 @@ define( instantiationCapability = jasmine.createSpyObj( "instantiation", - [ "invoke" ] + ["invoke"] ); persistenceCapability = jasmine.createSpyObj( "persistenceCapability", - [ "persist", "getSpace" ] + ["persist", "getSpace"] ); persistenceCapability.persist.andReturn(persistObjectPromise); @@ -174,10 +170,12 @@ define( 'mockDeferred', ['notify', 'resolve', 'reject'] ); - mockDeferred.notify.andCallFake(function(notification){}); - mockDeferred.resolve.andCallFake(function(value){resolvedValue = value;}); + mockDeferred.notify.andCallFake(function () {}); + mockDeferred.resolve.andCallFake(function (value) { + resolvedValue = value; + }); mockDeferred.promise = { - then: function(callback){ + then: function (callback) { return synchronousPromise(callback(resolvedValue)); } }; @@ -191,12 +189,14 @@ define( mockQ.all.andCallFake(function (promises) { var result = {}; Object.keys(promises).forEach(function (k) { - promises[k].then(function (v) { result[k] = v; }); + promises[k].then(function (v) { + result[k] = v; + }); }); return synchronousPromise(result); }); mockQ.defer.andReturn(mockDeferred); - + }); describe("on domain object without composition", function () { @@ -242,7 +242,7 @@ define( }); instantiationCapability.invoke.andCallFake( - function(model){ + function (model) { objectCopy.model = model; return objectCopy; } @@ -258,7 +258,7 @@ define( expect(persistenceCapability.persist) .toHaveBeenCalled(); }); - + it("deep clones object model", function () { var newModel = copyFinished.calls[0].args[0].getModel(); expect(newModel).toEqual(object.model); @@ -273,8 +273,7 @@ define( }); describe("on domainObject with composition", function () { - var newObject, - childObject, + var childObject, objectClone, childObjectClone, compositionPromise; @@ -284,7 +283,7 @@ define( objectClones; instantiationCapability.invoke.andCallFake( - function(model){ + function (model) { var cloneToReturn = objectClones[invocationCount++]; cloneToReturn.model = model; return cloneToReturn; @@ -367,8 +366,8 @@ define( copyService = new CopyService(mockQ, policyService); }); - describe("the cloning process", function(){ - beforeEach(function() { + describe("the cloning process", function () { + beforeEach(function () { copyResult = copyService.perform(object, newParent); copyFinished = jasmine.createSpy('copyFinished'); copyResult.then(copyFinished); @@ -384,23 +383,23 @@ define( expect(copyFinished).toHaveBeenCalled(); }); - it ("correctly locates cloned objects", function() { + it ("correctly locates cloned objects", function () { expect(childObjectClone.getModel().location).toEqual(objectClone.getId()); }); }); - describe("when cloning non-creatable objects", function() { + describe("when cloning non-creatable objects", function () { beforeEach(function () { - policyService.allow.andCallFake(function(category){ + policyService.allow.andCallFake(function (category) { //Return false for 'creation' policy - return category !== 'creation'; + return category !== 'creation'; }); copyResult = copyService.perform(object, newParent); copyFinished = jasmine.createSpy('copyFinished'); copyResult.then(copyFinished); }); - it ("creates link instead of clone", function() { + it ("creates link instead of clone", function () { var copiedObject = copyFinished.calls[0].args[0]; expect(copiedObject).toBe(object); expect(compositionCapability.add) @@ -417,7 +416,7 @@ define( } it("does not create new instances of objects " + - "rejected by the filter", function() { + "rejected by the filter", function () { copyService.perform(object, newParent, reject) .then(copyFinished); expect(copyFinished.mostRecentCall.args[0]) @@ -425,7 +424,7 @@ define( }); it("does create new instances of objects " + - "accepted by the filter", function() { + "accepted by the filter", function () { copyService.perform(object, newParent, accept) .then(copyFinished); expect(copyFinished.mostRecentCall.args[0]) @@ -459,17 +458,17 @@ define( }); it("throws an error", function () { - var copyService = + var service = new CopyService(mockQ, policyService); function perform() { - copyService.perform(object, newParent); + service.perform(object, newParent); } - spyOn(copyService, "validate"); - copyService.validate.andReturn(true); + spyOn(service, "validate"); + service.validate.andReturn(true); expect(perform).not.toThrow(); - copyService.validate.andReturn(false); + service.validate.andReturn(false); expect(perform).toThrow(); }); }); diff --git a/platform/entanglement/test/services/CopyTaskSpec.js b/platform/entanglement/test/services/CopyTaskSpec.js index a66fb185ce..9111b08c4c 100644 --- a/platform/entanglement/test/services/CopyTaskSpec.js +++ b/platform/entanglement/test/services/CopyTaskSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define( [ @@ -28,7 +27,6 @@ define( '../DomainObjectFactory' ], function (CopyTask, domainObjectFactory) { - 'use strict'; var ID_A = "some-string-with-vaguely-uuidish-uniqueness", ID_B = "some-other-similarly-unique-string"; @@ -102,11 +100,11 @@ define( cloneIds = {}; testModel = { - composition: [ ID_A, ID_B ], + composition: [ID_A, ID_B], someObj: {}, - someArr: [ ID_A, ID_B ], + someArr: [ID_A, ID_B], objArr: [{"id": ID_A}, {"id": ID_B}], - singleElementArr: [ ID_A ] + singleElementArr: [ID_A] }; testModel.someObj[ID_A] = "some value"; testModel.someObj.someProperty = ID_B; @@ -122,7 +120,7 @@ define( mockQ = jasmine.createSpyObj('$q', ['when', 'defer', 'all']); mockDeferred = jasmine.createSpyObj( 'deferred', - [ 'notify', 'resolve', 'reject' ] + ['notify', 'resolve', 'reject'] ); mockFilter.andReturn(true); @@ -132,7 +130,9 @@ define( mockQ.all.andCallFake(function (promises) { return synchronousPromise(promises.map(function (promise) { var value; - promise.then(function (v) { value = v; }); + promise.then(function (v) { + value = v; + }); return value; })); }); @@ -189,8 +189,7 @@ define( describe("copies object trees with multiple references to the" + " same object", function () { - var model, - mockDomainObjectB, + var mockDomainObjectB, mockComposingObject, composingObjectModel, domainObjectClone, @@ -254,9 +253,7 @@ define( it(" and correctly updates child identifiers in object" + " arrays within models ", function () { var childA_ID = task.clones[0].getId(), - childB_ID = task.clones[1].getId(), - childC_ID = task.clones[3].getId(), - childD_ID = task.clones[4].getId(); + childB_ID = task.clones[1].getId(); expect(domainObjectClone.model.objArr[0].id).not.toBe(ID_A); expect(domainObjectClone.model.objArr[0].id).toBe(childA_ID); diff --git a/platform/entanglement/test/services/LinkServiceSpec.js b/platform/entanglement/test/services/LinkServiceSpec.js index 3d63c2c030..e9e57d2c3e 100644 --- a/platform/entanglement/test/services/LinkServiceSpec.js +++ b/platform/entanglement/test/services/LinkServiceSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define( [ @@ -29,7 +28,6 @@ define( '../ControlledPromise' ], function (LinkService, domainObjectFactory, ControlledPromise) { - "use strict"; describe("LinkService", function () { diff --git a/platform/entanglement/test/services/LocatingCreationDecoratorSpec.js b/platform/entanglement/test/services/LocatingCreationDecoratorSpec.js index aa3cbce68a..97fd960623 100644 --- a/platform/entanglement/test/services/LocatingCreationDecoratorSpec.js +++ b/platform/entanglement/test/services/LocatingCreationDecoratorSpec.js @@ -20,14 +20,12 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect */ define( [ '../../src/services/LocatingCreationDecorator' ], function (LocatingCreationDecorator) { - "use strict"; describe("LocatingCreationDecorator", function () { var mockCreationService, diff --git a/platform/entanglement/test/services/LocatingObjectDecoratorSpec.js b/platform/entanglement/test/services/LocatingObjectDecoratorSpec.js index 5946f982ff..35412510c7 100644 --- a/platform/entanglement/test/services/LocatingObjectDecoratorSpec.js +++ b/platform/entanglement/test/services/LocatingObjectDecoratorSpec.js @@ -20,14 +20,12 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect */ define( [ '../../src/services/LocatingObjectDecorator' ], function (LocatingObjectDecorator) { - "use strict"; describe("LocatingObjectDecorator", function () { var mockContextualize, @@ -78,7 +76,9 @@ define( mockQ.all.andCallFake(function (promises) { var result = {}; Object.keys(promises).forEach(function (k) { - promises[k].then(function (v) { result[k] = v; }); + promises[k].then(function (v) { + result[k] = v; + }); }); return testPromise(result); }); @@ -90,7 +90,7 @@ define( Object.keys(testModels).forEach(function (id) { testObjects[id] = jasmine.createSpyObj( "domainObject-" + id, - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); testObjects[id].getId.andReturn(id); testObjects[id].getModel.andReturn(testModels[id]); diff --git a/platform/entanglement/test/services/LocationServiceSpec.js b/platform/entanglement/test/services/LocationServiceSpec.js index c469392f23..951baa71ac 100644 --- a/platform/entanglement/test/services/LocationServiceSpec.js +++ b/platform/entanglement/test/services/LocationServiceSpec.js @@ -20,14 +20,12 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect */ define( [ '../../src/services/LocationService' ], function (LocationService) { - "use strict"; describe("LocationService", function () { var dialogService, @@ -65,7 +63,9 @@ define( beforeEach(function () { title = "Get a location to do something"; label = "a location"; - validate = function () { return true; }; + validate = function () { + return true; + }; initialLocation = { key: "a key" }; locationResult = locationService.getLocationFromUser( title, diff --git a/platform/entanglement/test/services/MockCopyService.js b/platform/entanglement/test/services/MockCopyService.js index 0e7e3517f3..cf986bec7e 100644 --- a/platform/entanglement/test/services/MockCopyService.js +++ b/platform/entanglement/test/services/MockCopyService.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,jasmine */ - +/*global jasmine*/ define( function () { - "use strict"; /** * MockCopyService provides the same interface as the copyService, diff --git a/platform/entanglement/test/services/MockLinkService.js b/platform/entanglement/test/services/MockLinkService.js index cb4f346082..5345efc86e 100644 --- a/platform/entanglement/test/services/MockLinkService.js +++ b/platform/entanglement/test/services/MockLinkService.js @@ -20,14 +20,12 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,jasmine */ - +/*global jasmine*/ define( [ '../ControlledPromise' ], function (ControlledPromise) { - "use strict"; /** * MockLinkService provides the same interface as the linkService, @@ -65,7 +63,7 @@ define( ] ); - mockLinkService.perform.andCallFake(function (object, newParent) { + mockLinkService.perform.andCallFake(function (object) { var performPromise = new ControlledPromise(); this.perform.mostRecentCall.promise = performPromise; diff --git a/platform/entanglement/test/services/MockMoveService.js b/platform/entanglement/test/services/MockMoveService.js index 52278a49d5..d5a290c03f 100644 --- a/platform/entanglement/test/services/MockMoveService.js +++ b/platform/entanglement/test/services/MockMoveService.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,jasmine */ - +/*global jasmine*/ define( function () { - "use strict"; /** * MockMoveService provides the same interface as the moveService, diff --git a/platform/entanglement/test/services/MoveServiceSpec.js b/platform/entanglement/test/services/MoveServiceSpec.js index 0eb9943dd8..ebea207b42 100644 --- a/platform/entanglement/test/services/MoveServiceSpec.js +++ b/platform/entanglement/test/services/MoveServiceSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define( [ '../../src/services/MoveService', @@ -34,7 +33,6 @@ define( domainObjectFactory, ControlledPromise ) { - "use strict"; describe("MoveService", function () { diff --git a/platform/execution/bundle.js b/platform/execution/bundle.js index 967726fe03..68d2268e21 100644 --- a/platform/execution/bundle.js +++ b/platform/execution/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/WorkerService", @@ -28,7 +27,6 @@ define([ WorkerService, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/execution", { "extensions": { diff --git a/platform/execution/src/WorkerService.js b/platform/execution/src/WorkerService.js index e4c2ec6a66..046c88a446 100644 --- a/platform/execution/src/WorkerService.js +++ b/platform/execution/src/WorkerService.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** @@ -30,7 +29,6 @@ define( [], function () { - "use strict"; /** * Handles the execution of WebWorkers. diff --git a/platform/execution/test/WorkerServiceSpec.js b/platform/execution/test/WorkerServiceSpec.js index e1a287f60d..b79a72dad0 100644 --- a/platform/execution/test/WorkerServiceSpec.js +++ b/platform/execution/test/WorkerServiceSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../src/WorkerService"], function (WorkerService) { - "use strict"; describe("The worker service", function () { var mockWindow, diff --git a/platform/exporters/ExportService.js b/platform/exporters/ExportService.js index 1493e8a8a6..05263eba9f 100644 --- a/platform/exporters/ExportService.js +++ b/platform/exporters/ExportService.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Blob*/ /** * @namespace platform/exporters @@ -62,7 +61,7 @@ define(['csv'], function (CSV) { (Object.keys((rows[0] || {})).sort()), filename = (options && options.filename) || "export.csv", csvText = new CSV(rows, { header: headers }).encode(), - blob = new Blob([ csvText ] , { type: "text/csv" }); + blob = new Blob([csvText], { type: "text/csv" }); this.saveAs(blob, filename); }; diff --git a/platform/exporters/ExportServiceSpec.js b/platform/exporters/ExportServiceSpec.js index 4a634ef880..f70a408274 100644 --- a/platform/exporters/ExportServiceSpec.js +++ b/platform/exporters/ExportServiceSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,Blob,FileReader*/ define( ["./ExportService", "csv"], function (ExportService, CSV) { - 'use strict'; describe("ExportService", function () { var mockSaveAs, @@ -47,7 +45,7 @@ define( mockSaveAs.andCallFake(function (blob) { var reader = new FileReader(); reader.onloadend = function () { - csvContents = new CSV(reader.result).parse(); + csvContents = new CSV(reader.result).parse(); }; reader.readAsText(blob); }); @@ -88,7 +86,7 @@ define( var testHeaders; beforeEach(function () { - testHeaders = [ 'a', 'b' ]; + testHeaders = ['a', 'b']; exportService .exportCSV(testRows, { headers: testHeaders }); waitsFor(finishedReadingCSV); @@ -141,4 +139,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/exporters/bundle.js b/platform/exporters/bundle.js index 42d6b674a1..eb42429496 100644 --- a/platform/exporters/bundle.js +++ b/platform/exporters/bundle.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./ExportService", "saveAs", "legacyRegistry" ], function (ExportService, saveAs, legacyRegistry) { - 'use strict'; legacyRegistry.register("platform/exporters", { extensions: { diff --git a/platform/features/clock/bundle.js b/platform/features/clock/bundle.js index bb0ddf9b0f..dc1f24cea9 100644 --- a/platform/features/clock/bundle.js +++ b/platform/features/clock/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/indicators/ClockIndicator", @@ -44,7 +43,6 @@ define([ timerTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/features/clock", { "name": "Clocks/Timers", diff --git a/platform/features/clock/src/actions/AbstractStartTimerAction.js b/platform/features/clock/src/actions/AbstractStartTimerAction.js index 116a5e51f4..d37962d76f 100644 --- a/platform/features/clock/src/actions/AbstractStartTimerAction.js +++ b/platform/features/clock/src/actions/AbstractStartTimerAction.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Implements the "Start" and "Restart" action for timers. diff --git a/platform/features/clock/src/actions/RestartTimerAction.js b/platform/features/clock/src/actions/RestartTimerAction.js index 0c4e0e93f4..5ddcd002c7 100644 --- a/platform/features/clock/src/actions/RestartTimerAction.js +++ b/platform/features/clock/src/actions/RestartTimerAction.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./AbstractStartTimerAction'], function (AbstractStartTimerAction) { - "use strict"; /** * Implements the "Restart at 0" action. @@ -41,7 +39,7 @@ define( * @param {ActionContext} context the context for this action */ function RestartTimerAction(now, context) { - AbstractStartTimerAction.apply(this, [ now, context ]); + AbstractStartTimerAction.apply(this, [now, context]); } RestartTimerAction.prototype = @@ -49,8 +47,8 @@ define( RestartTimerAction.appliesTo = function (context) { var model = - (context.domainObject && context.domainObject.getModel()) - || {}; + (context.domainObject && context.domainObject.getModel()) || + {}; // We show this variant for timers which already have // a target time. diff --git a/platform/features/clock/src/actions/StartTimerAction.js b/platform/features/clock/src/actions/StartTimerAction.js index f005a9a46e..d683ec190b 100644 --- a/platform/features/clock/src/actions/StartTimerAction.js +++ b/platform/features/clock/src/actions/StartTimerAction.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./AbstractStartTimerAction'], function (AbstractStartTimerAction) { - "use strict"; /** * Implements the "Start" action for timers. @@ -41,7 +39,7 @@ define( * @param {ActionContext} context the context for this action */ function StartTimerAction(now, context) { - AbstractStartTimerAction.apply(this, [ now, context ]); + AbstractStartTimerAction.apply(this, [now, context]); } StartTimerAction.prototype = @@ -49,8 +47,8 @@ define( StartTimerAction.appliesTo = function (context) { var model = - (context.domainObject && context.domainObject.getModel()) - || {}; + (context.domainObject && context.domainObject.getModel()) || + {}; // We show this variant for timers which do not yet have // a target time. diff --git a/platform/features/clock/src/controllers/ClockController.js b/platform/features/clock/src/controllers/ClockController.js index 387c8d44ad..59512243ff 100644 --- a/platform/features/clock/src/controllers/ClockController.js +++ b/platform/features/clock/src/controllers/ClockController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['moment'], function (moment) { - "use strict"; /** * Controller for views of a Clock domain object. diff --git a/platform/features/clock/src/controllers/RefreshingController.js b/platform/features/clock/src/controllers/RefreshingController.js index 30d4d7841e..58483172f6 100644 --- a/platform/features/clock/src/controllers/RefreshingController.js +++ b/platform/features/clock/src/controllers/RefreshingController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Continually refreshes the represented domain object. diff --git a/platform/features/clock/src/controllers/TimerController.js b/platform/features/clock/src/controllers/TimerController.js index 3f596df673..d1d31bfb80 100644 --- a/platform/features/clock/src/controllers/TimerController.js +++ b/platform/features/clock/src/controllers/TimerController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TimerFormatter'], function (TimerFormatter) { - "use strict"; var FORMATTER = new TimerFormatter(); @@ -40,8 +38,7 @@ define( * time (typically wrapping `Date.now`) */ function TimerController($scope, $window, now) { - var timerObject, - formatter, + var formatter, active = true, relativeTimestamp, lastTimestamp, diff --git a/platform/features/clock/src/controllers/TimerFormatter.js b/platform/features/clock/src/controllers/TimerFormatter.js index 7a2b2da44b..9cfa799cc7 100644 --- a/platform/features/clock/src/controllers/TimerFormatter.js +++ b/platform/features/clock/src/controllers/TimerFormatter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,requirejs*/ define( ['moment', 'moment-duration-format'], function (moment) { - "use strict"; var SHORT_FORMAT = "HH:mm:ss", LONG_FORMAT = "d[D] HH:mm:ss"; diff --git a/platform/features/clock/src/indicators/ClockIndicator.js b/platform/features/clock/src/indicators/ClockIndicator.js index a564ddf8d1..731b87e625 100644 --- a/platform/features/clock/src/indicators/ClockIndicator.js +++ b/platform/features/clock/src/indicators/ClockIndicator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['moment'], function (moment) { - "use strict"; /** * Indicator that displays the current UTC time in the status area. diff --git a/platform/features/clock/src/services/TickerService.js b/platform/features/clock/src/services/TickerService.js index 371c9a010e..07e0a5886b 100644 --- a/platform/features/clock/src/services/TickerService.js +++ b/platform/features/clock/src/services/TickerService.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( - ['moment'], - function (moment) { - "use strict"; + [], + function () { /** * Calls functions every second, as close to the actual second diff --git a/platform/features/clock/test/actions/AbstractStartTimerActionSpec.js b/platform/features/clock/test/actions/AbstractStartTimerActionSpec.js index 613bf666da..bc72a00f46 100644 --- a/platform/features/clock/test/actions/AbstractStartTimerActionSpec.js +++ b/platform/features/clock/test/actions/AbstractStartTimerActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/actions/AbstractStartTimerAction"], function (AbstractStartTimerAction) { - "use strict"; describe("A timer's start/restart action", function () { var mockNow, @@ -45,7 +43,7 @@ define( mockNow = jasmine.createSpy('now'); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getCapability', 'useCapability' ] + ['getCapability', 'useCapability'] ); mockPersistence = jasmine.createSpyObj( 'persistence', diff --git a/platform/features/clock/test/actions/RestartTimerActionSpec.js b/platform/features/clock/test/actions/RestartTimerActionSpec.js index df9ea0cba7..1c98037380 100644 --- a/platform/features/clock/test/actions/RestartTimerActionSpec.js +++ b/platform/features/clock/test/actions/RestartTimerActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/actions/RestartTimerAction"], function (RestartTimerAction) { - "use strict"; describe("A timer's restart action", function () { var mockNow, @@ -46,7 +44,7 @@ define( mockNow = jasmine.createSpy('now'); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getCapability', 'useCapability', 'getModel' ] + ['getCapability', 'useCapability', 'getModel'] ); mockPersistence = jasmine.createSpyObj( 'persistence', diff --git a/platform/features/clock/test/actions/StartTimerActionSpec.js b/platform/features/clock/test/actions/StartTimerActionSpec.js index 97aee20e12..67d6438eb2 100644 --- a/platform/features/clock/test/actions/StartTimerActionSpec.js +++ b/platform/features/clock/test/actions/StartTimerActionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/actions/StartTimerAction"], function (StartTimerAction) { - "use strict"; describe("A timer's start action", function () { var mockNow, @@ -46,7 +44,7 @@ define( mockNow = jasmine.createSpy('now'); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getCapability', 'useCapability', 'getModel' ] + ['getCapability', 'useCapability', 'getModel'] ); mockPersistence = jasmine.createSpyObj( 'persistence', diff --git a/platform/features/clock/test/controllers/ClockControllerSpec.js b/platform/features/clock/test/controllers/ClockControllerSpec.js index c815ec8c5a..3ee76596fb 100644 --- a/platform/features/clock/test/controllers/ClockControllerSpec.js +++ b/platform/features/clock/test/controllers/ClockControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/controllers/ClockController"], function (ClockController) { - "use strict"; // Wed, 03 Jun 2015 17:56:14 GMT var TEST_TIMESTAMP = 1433354174000; @@ -33,7 +31,6 @@ define( var mockScope, mockTicker, mockUnticker, - mockDomainObject, controller; beforeEach(function () { diff --git a/platform/features/clock/test/controllers/RefreshingControllerSpec.js b/platform/features/clock/test/controllers/RefreshingControllerSpec.js index 8aee11279f..c343575c55 100644 --- a/platform/features/clock/test/controllers/RefreshingControllerSpec.js +++ b/platform/features/clock/test/controllers/RefreshingControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/controllers/RefreshingController"], function (RefreshingController) { - "use strict"; @@ -47,11 +45,11 @@ define( it("refreshes the represented object on every tick", function () { var mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getCapability' ] + ['getCapability'] ), mockPersistence = jasmine.createSpyObj( 'persistence', - [ 'persist', 'refresh' ] + ['persist', 'refresh'] ); mockDomainObject.getCapability.andCallFake(function (c) { diff --git a/platform/features/clock/test/controllers/TimerControllerSpec.js b/platform/features/clock/test/controllers/TimerControllerSpec.js index d0259a0528..79c64f941d 100644 --- a/platform/features/clock/test/controllers/TimerControllerSpec.js +++ b/platform/features/clock/test/controllers/TimerControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/controllers/TimerController"], function (TimerController) { - "use strict"; // Wed, 03 Jun 2015 17:56:14 GMT var TEST_TIMESTAMP = 1433354174000; @@ -59,7 +57,7 @@ define( ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getCapability', 'useCapability', 'getModel' ] + ['getCapability', 'useCapability', 'getModel'] ); mockActionCapability = jasmine.createSpyObj( 'action', diff --git a/platform/features/clock/test/controllers/TimerFormatterSpec.js b/platform/features/clock/test/controllers/TimerFormatterSpec.js index 558bafceb2..58f91edad7 100644 --- a/platform/features/clock/test/controllers/TimerFormatterSpec.js +++ b/platform/features/clock/test/controllers/TimerFormatterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/controllers/TimerFormatter"], function (TimerFormatter) { - "use strict"; var MS_IN_SEC = 1000, MS_IN_MIN = MS_IN_SEC * 60, @@ -47,10 +45,6 @@ define( ].reduce(sum, 0); } - function twoDigits(n) { - return n < 10 ? ('0' + n) : n; - } - it("formats short-form values (no days)", function () { expect(formatter.short(toDuration(0, 123, 2, 3) + 123)) .toEqual("123:02:03"); diff --git a/platform/features/clock/test/indicators/ClockIndicatorSpec.js b/platform/features/clock/test/indicators/ClockIndicatorSpec.js index fd6ac72a96..dd4b9e9a46 100644 --- a/platform/features/clock/test/indicators/ClockIndicatorSpec.js +++ b/platform/features/clock/test/indicators/ClockIndicatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/indicators/ClockIndicator"], function (ClockIndicator) { - "use strict"; // Wed, 03 Jun 2015 17:56:14 GMT var TEST_TIMESTAMP = 1433354174000, diff --git a/platform/features/clock/test/services/TickerServiceSpec.js b/platform/features/clock/test/services/TickerServiceSpec.js index 9b5370d1d1..8fb9613dca 100644 --- a/platform/features/clock/test/services/TickerServiceSpec.js +++ b/platform/features/clock/test/services/TickerServiceSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/services/TickerService"], function (TickerService) { - "use strict"; var TEST_TIMESTAMP = 1433354174000; diff --git a/platform/features/conductor/bundle.js b/platform/features/conductor/bundle.js index 9987be5c68..ad252fb446 100644 --- a/platform/features/conductor/bundle.js +++ b/platform/features/conductor/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/ConductorRepresenter", @@ -34,7 +33,6 @@ define([ timeConductorTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/features/conductor", { "extensions": { diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index 113b99de94..08a5968800 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; var TEMPLATE = [ "= mockConductor.displayStart()); - inWindow = inWindow && (v <= mockConductor.displayEnd()); - } - return inWindow; - } - beforeEach(function () { mockTelemetryService = jasmine.createSpyObj( 'telemetryService', - [ 'requestTelemetry', 'subscribe' ] + ['requestTelemetry', 'subscribe'] ); mockConductorService = jasmine.createSpyObj( 'conductorService', @@ -61,7 +49,7 @@ define( ); mockSeries = jasmine.createSpyObj( 'series', - [ 'getPointCount', 'getDomainValue', 'getRangeValue' ] + ['getPointCount', 'getDomainValue', 'getRangeValue'] ); mockTelemetryService.requestTelemetry.andReturn(mockPromise); diff --git a/platform/features/conductor/test/TestTimeConductor.js b/platform/features/conductor/test/TestTimeConductor.js index 01fed0c8fd..52ffb773d4 100644 --- a/platform/features/conductor/test/TestTimeConductor.js +++ b/platform/features/conductor/test/TestTimeConductor.js @@ -19,12 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,spyOn*/ +/*global spyOn*/ define( ["../src/TimeConductor"], function (TimeConductor) { - 'use strict'; function TestTimeConductor() { var self = this; diff --git a/platform/features/conductor/test/TimeConductorSpec.js b/platform/features/conductor/test/TimeConductorSpec.js index ee1d2f56b7..dfd4c6e8db 100644 --- a/platform/features/conductor/test/TimeConductorSpec.js +++ b/platform/features/conductor/test/TimeConductorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TimeConductor"], function (TimeConductor) { - "use strict"; describe("TimeConductor", function () { var testStart, diff --git a/platform/features/imagery/bundle.js b/platform/features/imagery/bundle.js index e17534fc4c..50408a47f5 100644 --- a/platform/features/imagery/bundle.js +++ b/platform/features/imagery/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/policies/ImageryViewPolicy", @@ -34,7 +33,6 @@ define([ imageryTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/features/imagery", { "name": "Plot view for telemetry", diff --git a/platform/features/imagery/src/controllers/ImageryController.js b/platform/features/imagery/src/controllers/ImageryController.js index 5439fc414c..ff69de1226 100644 --- a/platform/features/imagery/src/controllers/ImageryController.js +++ b/platform/features/imagery/src/controllers/ImageryController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle implements views of image telemetry. @@ -28,7 +27,6 @@ define( ['moment'], function (moment) { - "use strict"; var DATE_FORMAT = "YYYY-MM-DD", TIME_FORMAT = "HH:mm:ss.SSS"; diff --git a/platform/features/imagery/src/directives/MCTBackgroundImage.js b/platform/features/imagery/src/directives/MCTBackgroundImage.js index 9100dce4b8..ab2eb7b169 100644 --- a/platform/features/imagery/src/directives/MCTBackgroundImage.js +++ b/platform/features/imagery/src/directives/MCTBackgroundImage.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( function () { - "use strict"; /** * Defines the `mct-background-image` directive. @@ -38,7 +36,7 @@ define( * @memberof platform/features/imagery */ function MCTBackgroundImage($document) { - function link(scope, element, attrs) { + function link(scope, element) { // General strategy here: // - Keep count of how many images have been requested; this // counter will be used as an internal identifier or sorts @@ -51,7 +49,7 @@ define( // in which images are actually loaded may be different, so // some strategy like this is necessary to ensure that images // do not display out-of-order. - var div, requested = 0, loaded = 0; + var requested = 0, loaded = 0; function nextImage(url) { var myCounter = requested, diff --git a/platform/features/imagery/src/policies/ImageryViewPolicy.js b/platform/features/imagery/src/policies/ImageryViewPolicy.js index f9f2e9c074..1439ffe279 100644 --- a/platform/features/imagery/src/policies/ImageryViewPolicy.js +++ b/platform/features/imagery/src/policies/ImageryViewPolicy.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( function () { - "use strict"; /** * Policy preventing the Imagery view from being made available for diff --git a/platform/features/imagery/test/controllers/ImageryControllerSpec.js b/platform/features/imagery/test/controllers/ImageryControllerSpec.js index 6ae82b3d86..5319d4cbdb 100644 --- a/platform/features/imagery/test/controllers/ImageryControllerSpec.js +++ b/platform/features/imagery/test/controllers/ImageryControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ["../../src/controllers/ImageryController"], function (ImageryController) { - "use strict"; describe("The Imagery controller", function () { var mockScope, diff --git a/platform/features/imagery/test/directives/MCTBackgroundImageSpec.js b/platform/features/imagery/test/directives/MCTBackgroundImageSpec.js index 2444266619..172708bcdf 100644 --- a/platform/features/imagery/test/directives/MCTBackgroundImageSpec.js +++ b/platform/features/imagery/test/directives/MCTBackgroundImageSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ["../../src/directives/MCTBackgroundImage"], function (MCTBackgroundImage) { - "use strict"; describe("The mct-background-image directive", function () { var mockDocument, @@ -38,7 +36,7 @@ define( jasmine.createSpyObj('document', ['createElement']) ]; mockScope = jasmine.createSpyObj('scope', ['$watch']); - mockElement = jasmine.createSpyObj('element', [ 'css' ]); + mockElement = jasmine.createSpyObj('element', ['css']); testImage = {}; mockDocument[0].createElement.andReturn(testImage); diff --git a/platform/features/imagery/test/policies/ImageryViewPolicySpec.js b/platform/features/imagery/test/policies/ImageryViewPolicySpec.js index 21e64cc324..e4eaddb842 100644 --- a/platform/features/imagery/test/policies/ImageryViewPolicySpec.js +++ b/platform/features/imagery/test/policies/ImageryViewPolicySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ["../../src/policies/ImageryViewPolicy"], function (ImageryViewPolicy) { - "use strict"; describe("Imagery view policy", function () { var testView, @@ -53,24 +51,24 @@ define( }); it("allows the imagery view for domain objects with image telemetry", function () { - testMetadata.ranges = [ { key: "foo", format: "imageUrl" } ]; + testMetadata.ranges = [{ key: "foo", format: "imageUrl" }]; expect(policy.allow(testView, mockDomainObject)).toBeTruthy(); }); it("disallows the imagery view for domain objects without image telemetry", function () { - testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ]; + testMetadata.ranges = [{ key: "foo", format: "somethingElse" }]; expect(policy.allow(testView, mockDomainObject)).toBeFalsy(); }); it("disallows the imagery view for domain objects without telemetry", function () { - testMetadata.ranges = [ { key: "foo", format: "imageUrl" } ]; + testMetadata.ranges = [{ key: "foo", format: "imageUrl" }]; mockDomainObject.getCapability.andReturn(undefined); expect(policy.allow(testView, mockDomainObject)).toBeFalsy(); }); it("allows other views", function () { testView.key = "somethingElse"; - testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ]; + testMetadata.ranges = [{ key: "foo", format: "somethingElse" }]; expect(policy.allow(testView, mockDomainObject)).toBeTruthy(); }); diff --git a/platform/features/layout/bundle.js b/platform/features/layout/bundle.js index 1ca80f99f7..21a0f8f263 100644 --- a/platform/features/layout/bundle.js +++ b/platform/features/layout/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/LayoutController", @@ -48,7 +47,6 @@ define([ imageTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/features/layout", { "name": "Layout components.", @@ -73,9 +71,6 @@ define([ "uses": [ "composition" ], - "gestures": [ - "drop" - ], "toolbar": { "sections": [ { diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index 751a0e70d3..c8b5aebb2e 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./FixedProxy', './elements/ElementProxies', './FixedDragHandle'], function (FixedProxy, ElementProxies, FixedDragHandle) { - "use strict"; - var DEFAULT_DIMENSIONS = [ 2, 1 ], + var DEFAULT_DIMENSIONS = [2, 1], DEFAULT_GRID_SIZE = [64, 16]; /** @@ -38,7 +36,7 @@ define( * @constructor * @param {Scope} $scope the controller's Angular scope */ - function FixedController($scope, $q, dialogService, telemetryHandler, telemetryFormatter, throttle) { + function FixedController($scope, $q, dialogService, telemetryHandler, telemetryFormatter) { var self = this, handle, names = {}, // Cache names by ID @@ -232,7 +230,7 @@ define( } // Handle changes in the object's composition - function updateComposition(ids) { + function updateComposition() { // Populate panel positions // TODO: Ensure defaults here // Resubscribe - objects in view have changed @@ -273,15 +271,13 @@ define( } // Position a panel after a drop event - function handleDrop(e, id, position, editableDomainObject) { + function handleDrop(e, id, position) { // Don't handle this event if it has already been handled // color is set to "" to let the CSS theme determine the default color if (e.defaultPrevented) { return; } - if (editableDomainObject){ - $scope.setEditable(editableDomainObject); - } + e.preventDefault(); // Store the position of this element. addElement({ diff --git a/platform/features/layout/src/FixedDragHandle.js b/platform/features/layout/src/FixedDragHandle.js index afc98eabaf..3b4e14663a 100644 --- a/platform/features/layout/src/FixedDragHandle.js +++ b/platform/features/layout/src/FixedDragHandle.js @@ -19,16 +19,14 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; // Drag handle dimensions - var DRAG_HANDLE_SIZE = [ 6, 6 ]; + var DRAG_HANDLE_SIZE = [6, 6]; /** * Template-displayable drag handle for an element in fixed diff --git a/platform/features/layout/src/FixedProxy.js b/platform/features/layout/src/FixedProxy.js index bb6c2f16c8..2965fac308 100644 --- a/platform/features/layout/src/FixedProxy.js +++ b/platform/features/layout/src/FixedProxy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,window*/ define( ['./elements/ElementFactory'], function (ElementFactory) { - "use strict"; /** * Proxy for configuring a fixed position view via the toolbar. diff --git a/platform/features/layout/src/LayoutCompositionPolicy.js b/platform/features/layout/src/LayoutCompositionPolicy.js index 23d5a4f882..b70d875869 100644 --- a/platform/features/layout/src/LayoutCompositionPolicy.js +++ b/platform/features/layout/src/LayoutCompositionPolicy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Defines composition policy for Display Layout objects. diff --git a/platform/features/layout/src/LayoutController.js b/platform/features/layout/src/LayoutController.js index a4ff03f021..6d60738fc3 100644 --- a/platform/features/layout/src/LayoutController.js +++ b/platform/features/layout/src/LayoutController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle implements object types and associated views for @@ -29,11 +28,10 @@ define( ['./LayoutDrag'], function (LayoutDrag) { - "use strict"; - var DEFAULT_DIMENSIONS = [ 12, 8 ], - DEFAULT_GRID_SIZE = [ 32, 32 ], - MINIMUM_FRAME_SIZE = [ 320, 180 ]; + var DEFAULT_DIMENSIONS = [12, 8], + DEFAULT_GRID_SIZE = [32, 32], + MINIMUM_FRAME_SIZE = [320, 180]; /** * The LayoutController is responsible for supporting the @@ -62,15 +60,11 @@ define( } // Position a panel after a drop event - //An editableDomainObject is provided, as the drop may have - // triggered a transition to edit mode. - function handleDrop(e, id, position, editableDomainObject) { + function handleDrop(e, id, position) { if (e.defaultPrevented) { return; } - if (editableDomainObject){ - $scope.setEditable(editableDomainObject); - } + // Ensure that configuration field is populated $scope.configuration = $scope.configuration || {}; // Make sure there is a "panels" field in the @@ -105,12 +99,12 @@ define( //Keep a track of how many composition callbacks have been made var thisCount = ++callbackCount; - $scope.domainObject.useCapability('composition').then(function(composition){ + $scope.domainObject.useCapability('composition').then(function (composition) { var ids; //Is this callback for the most recent composition // request? If not, discard it. Prevents race condition - if (thisCount === callbackCount){ + if (thisCount === callbackCount) { ids = composition.map(function (object) { return object.getId(); }) || []; diff --git a/platform/features/layout/src/LayoutDrag.js b/platform/features/layout/src/LayoutDrag.js index 0c0ef6b1a7..360e9d9543 100644 --- a/platform/features/layout/src/LayoutDrag.js +++ b/platform/features/layout/src/LayoutDrag.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Handles drag interactions on frames in layouts. This will diff --git a/platform/features/layout/src/elements/AccessorMutator.js b/platform/features/layout/src/elements/AccessorMutator.js index 656c4abbcf..88b59abaee 100644 --- a/platform/features/layout/src/elements/AccessorMutator.js +++ b/platform/features/layout/src/elements/AccessorMutator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Utility function for creating getter-setter functions, diff --git a/platform/features/layout/src/elements/BoxProxy.js b/platform/features/layout/src/elements/BoxProxy.js index a4b6bc4c09..7a4c72bb5a 100644 --- a/platform/features/layout/src/elements/BoxProxy.js +++ b/platform/features/layout/src/elements/BoxProxy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./ElementProxy', './AccessorMutator'], function (ElementProxy, AccessorMutator) { - 'use strict'; /** * Selection proxy for Box elements in a fixed position view. diff --git a/platform/features/layout/src/elements/ElementFactory.js b/platform/features/layout/src/elements/ElementFactory.js index 6dbef2f708..431a33e6b7 100644 --- a/platform/features/layout/src/elements/ElementFactory.js +++ b/platform/features/layout/src/elements/ElementFactory.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; var INITIAL_STATES = { "fixed.image": { diff --git a/platform/features/layout/src/elements/ElementProxies.js b/platform/features/layout/src/elements/ElementProxies.js index 1443363883..6246ebf3da 100644 --- a/platform/features/layout/src/elements/ElementProxies.js +++ b/platform/features/layout/src/elements/ElementProxies.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TelemetryProxy', './ImageProxy', './LineProxy', './BoxProxy', './TextProxy'], function (TelemetryProxy, ImageProxy, LineProxy, BoxProxy, TextProxy) { - "use strict"; return { "fixed.telemetry": TelemetryProxy, diff --git a/platform/features/layout/src/elements/ElementProxy.js b/platform/features/layout/src/elements/ElementProxy.js index 5f3ef17bcb..75ed061085 100644 --- a/platform/features/layout/src/elements/ElementProxy.js +++ b/platform/features/layout/src/elements/ElementProxy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./AccessorMutator', './ResizeHandle'], function (AccessorMutator, ResizeHandle) { - "use strict"; // Index deltas for changes in order var ORDERS = { @@ -56,7 +54,7 @@ define( * @param {Array} elements the full array of elements */ function ElementProxy(element, index, elements) { - this.resizeHandles = [ new ResizeHandle(element, 1, 1) ]; + this.resizeHandles = [new ResizeHandle(element, 1, 1)]; /** * The element as stored in the view configuration. diff --git a/platform/features/layout/src/elements/ImageProxy.js b/platform/features/layout/src/elements/ImageProxy.js index 22ef3ef0c3..de8a6532da 100644 --- a/platform/features/layout/src/elements/ImageProxy.js +++ b/platform/features/layout/src/elements/ImageProxy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./ElementProxy', './AccessorMutator'], function (ElementProxy, AccessorMutator) { - 'use strict'; /** * Selection proxy for Image elements in a fixed position view. diff --git a/platform/features/layout/src/elements/LineHandle.js b/platform/features/layout/src/elements/LineHandle.js index c61d1f3802..4af03de031 100644 --- a/platform/features/layout/src/elements/LineHandle.js +++ b/platform/features/layout/src/elements/LineHandle.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * Handle for changing x/y position of a line's end point. diff --git a/platform/features/layout/src/elements/LineProxy.js b/platform/features/layout/src/elements/LineProxy.js index 44cf282993..a8a20babca 100644 --- a/platform/features/layout/src/elements/LineProxy.js +++ b/platform/features/layout/src/elements/LineProxy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./ElementProxy', './LineHandle'], function (ElementProxy, LineHandle) { - 'use strict'; /** * Selection/diplay proxy for line elements of a fixed position diff --git a/platform/features/layout/src/elements/ResizeHandle.js b/platform/features/layout/src/elements/ResizeHandle.js index 757bb6218e..c4ceb16203 100644 --- a/platform/features/layout/src/elements/ResizeHandle.js +++ b/platform/features/layout/src/elements/ResizeHandle.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * @interface platform/features/layout.ElementHandle diff --git a/platform/features/layout/src/elements/TelemetryProxy.js b/platform/features/layout/src/elements/TelemetryProxy.js index dbb7044c51..5537d3b525 100644 --- a/platform/features/layout/src/elements/TelemetryProxy.js +++ b/platform/features/layout/src/elements/TelemetryProxy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( - ['./TextProxy', './AccessorMutator'], - function (TextProxy, AccessorMutator) { - 'use strict'; + ['./TextProxy'], + function (TextProxy) { // Method names to expose from this proxy var HIDE = 'hideTitle', SHOW = 'showTitle'; diff --git a/platform/features/layout/src/elements/TextProxy.js b/platform/features/layout/src/elements/TextProxy.js index c5b5247c4c..7c4f2dd35a 100644 --- a/platform/features/layout/src/elements/TextProxy.js +++ b/platform/features/layout/src/elements/TextProxy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./BoxProxy', './AccessorMutator'], function (BoxProxy, AccessorMutator) { - 'use strict'; /** * Selection proxy for Text elements in a fixed position view. diff --git a/platform/features/layout/test/FixedControllerSpec.js b/platform/features/layout/test/FixedControllerSpec.js index 7c545e2d3d..ff939a21c9 100644 --- a/platform/features/layout/test/FixedControllerSpec.js +++ b/platform/features/layout/test/FixedControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ["../src/FixedController"], function (FixedController) { - "use strict"; describe("The Fixed Position controller", function () { var mockScope, @@ -66,7 +64,7 @@ define( function makeMockDomainObject(id) { var mockObject = jasmine.createSpyObj( 'domainObject-' + id, - [ 'getId', 'getModel', 'getCapability' ] + ['getId', 'getModel', 'getCapability'] ); mockObject.getId.andReturn(id); mockObject.getModel.andReturn({ name: "Point " + id}); @@ -76,11 +74,11 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( '$scope', - [ "$on", "$watch", "commit" ] + ["$on", "$watch", "commit"] ); mockHandler = jasmine.createSpyObj( 'telemetryHandler', - [ 'handle' ] + ['handle'] ); mockQ = jasmine.createSpyObj('$q', ['when']); mockDialogService = jasmine.createSpyObj( @@ -89,11 +87,11 @@ define( ); mockFormatter = jasmine.createSpyObj( 'telemetryFormatter', - [ 'formatDomainValue', 'formatRangeValue' ] + ['formatDomainValue', 'formatRangeValue'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getModel', 'getCapability' ] + ['getId', 'getModel', 'getCapability'] ); mockHandle = jasmine.createSpyObj( 'subscription', @@ -108,10 +106,10 @@ define( ); mockEvent = jasmine.createSpyObj( 'event', - [ 'preventDefault' ] + ['preventDefault'] ); - testGrid = [ 123, 456 ]; + testGrid = [123, 456]; testModel = { composition: ['a', 'b', 'c'], layoutGrid: testGrid @@ -138,7 +136,7 @@ define( mockScope.configuration = testConfiguration; mockScope.selection = jasmine.createSpyObj( 'selection', - [ 'select', 'get', 'selected', 'deselect', 'proxy' ] + ['select', 'get', 'selected', 'deselect', 'proxy'] ); controller = new FixedController( @@ -420,7 +418,7 @@ define( expect(controller.selected().style).toEqual(oldStyle); // Drag a little - controller.moveHandle().continueDrag([ 1000, 100 ]); + controller.moveHandle().continueDrag([1000, 100]); // Style should have been updated expect(controller.selected().style).not.toEqual(oldStyle); diff --git a/platform/features/layout/test/FixedDragHandleSpec.js b/platform/features/layout/test/FixedDragHandleSpec.js index d54a8d6a00..2cbaca1746 100644 --- a/platform/features/layout/test/FixedDragHandleSpec.js +++ b/platform/features/layout/test/FixedDragHandleSpec.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ['../src/FixedDragHandle'], function (FixedDragHandle) { - "use strict"; - var TEST_GRID_SIZE = [ 13, 33 ]; + var TEST_GRID_SIZE = [13, 33]; describe("A fixed position drag handle", function () { var mockElementHandle, @@ -37,7 +35,7 @@ define( beforeEach(function () { mockElementHandle = jasmine.createSpyObj( 'elementHandle', - [ 'x', 'y' ] + ['x', 'y'] ); mockUpdate = jasmine.createSpy('update'); mockCommit = jasmine.createSpy('commit'); @@ -63,13 +61,13 @@ define( it("allows handles to be dragged", function () { handle.startDrag(); - handle.continueDrag([ 16, 8 ]); + handle.continueDrag([16, 8]); // Should update x/y, snapped to grid expect(mockElementHandle.x).toHaveBeenCalledWith(7); expect(mockElementHandle.y).toHaveBeenCalledWith(8); - handle.continueDrag([ -16, -35 ]); + handle.continueDrag([-16, -35]); // Should have interpreted relative to initial state expect(mockElementHandle.x).toHaveBeenCalledWith(5); @@ -86,4 +84,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/layout/test/FixedProxySpec.js b/platform/features/layout/test/FixedProxySpec.js index 1a95dc0e1d..c4b8ec6de4 100644 --- a/platform/features/layout/test/FixedProxySpec.js +++ b/platform/features/layout/test/FixedProxySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ['../src/FixedProxy'], function (FixedProxy) { - "use strict"; describe("Fixed Position view's selection proxy", function () { var mockCallback, diff --git a/platform/features/layout/test/LayoutCompositionPolicySpec.js b/platform/features/layout/test/LayoutCompositionPolicySpec.js index f8ddec5bc5..0cbb92cd82 100644 --- a/platform/features/layout/test/LayoutCompositionPolicySpec.js +++ b/platform/features/layout/test/LayoutCompositionPolicySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/LayoutCompositionPolicy"], function (LayoutCompositionPolicy) { - "use strict"; describe("Layout's composition policy", function () { var mockCandidate, mockContext, diff --git a/platform/features/layout/test/LayoutControllerSpec.js b/platform/features/layout/test/LayoutControllerSpec.js index 338875823b..06ff8b80f0 100644 --- a/platform/features/layout/test/LayoutControllerSpec.js +++ b/platform/features/layout/test/LayoutControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,spyOn*/ define( ["../src/LayoutController"], function (LayoutController) { - "use strict"; describe("The Layout controller", function () { var mockScope, @@ -36,7 +34,7 @@ define( mockComposition, mockCompositionObjects; - function mockPromise(value){ + function mockPromise(value) { return { then: function (thenFunc) { return mockPromise(thenFunc(value)); @@ -44,12 +42,12 @@ define( }; } - function mockDomainObject(id){ + function mockDomainObject(id) { return { - getId: function() { + getId: function () { return id; }, - useCapability: function() { + useCapability: function () { return mockCompositionCapability; } }; @@ -58,11 +56,11 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "$watch", "$watchCollection", "$on", "commit" ] + ["$watch", "$watchCollection", "$on", "commit"] ); mockEvent = jasmine.createSpyObj( 'event', - [ 'preventDefault' ] + ['preventDefault'] ); testModel = {}; @@ -237,10 +235,10 @@ define( }); it("ensures a minimum frame size", function () { - var styleB, styleC; + var styleB; // Start with a very small frame size - testModel.layoutGrid = [ 1, 1 ]; + testModel.layoutGrid = [1, 1]; // White-boxy; we know which watch is which mockScope.$watch.calls[0].args[1](testModel.layoutGrid); @@ -257,7 +255,7 @@ define( var style; // Start with a very small frame size - testModel.layoutGrid = [ 1, 1 ]; + testModel.layoutGrid = [1, 1]; mockScope.$watch.calls[0].args[1](testModel.layoutGrid); // Notify that a drop occurred diff --git a/platform/features/layout/test/LayoutDragSpec.js b/platform/features/layout/test/LayoutDragSpec.js index 9b58459971..23503bd16d 100644 --- a/platform/features/layout/test/LayoutDragSpec.js +++ b/platform/features/layout/test/LayoutDragSpec.js @@ -19,65 +19,63 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../src/LayoutDrag"], function (LayoutDrag) { - "use strict"; describe("A Layout drag handler", function () { var testPosition = { - position: [ 8, 11 ], - dimensions: [ 3, 2 ] + position: [8, 11], + dimensions: [3, 2] }; it("changes position by a supplied factor, rounding by grid size", function () { var handler = new LayoutDrag( testPosition, - [ 1, 1 ], - [ 0, 0 ], - [ 10, 20 ] + [1, 1], + [0, 0], + [10, 20] ); - expect(handler.getAdjustedPosition([ 37, 84 ])).toEqual({ - position: [ 12, 15 ], - dimensions: [ 3, 2 ] + expect(handler.getAdjustedPosition([37, 84])).toEqual({ + position: [12, 15], + dimensions: [3, 2] }); - expect(handler.getAdjustedPosition([ -37, 84 ])).toEqual({ - position: [ 4, 15 ], - dimensions: [ 3, 2 ] + expect(handler.getAdjustedPosition([-37, 84])).toEqual({ + position: [4, 15], + dimensions: [3, 2] }); }); it("changes dimensions by a supplied factor, rounding by grid size", function () { var handler = new LayoutDrag( testPosition, - [ 0, 0 ], - [ 1, 1 ], - [ 10, 20 ] + [0, 0], + [1, 1], + [10, 20] ); - expect(handler.getAdjustedPosition([ 37, 84 ])).toEqual({ - position: [ 8, 11 ], - dimensions: [ 7, 6 ] + expect(handler.getAdjustedPosition([37, 84])).toEqual({ + position: [8, 11], + dimensions: [7, 6] }); }); it("allows mixing dimension and position factors", function () { var handler = new LayoutDrag( testPosition, - [ 0, 1 ], - [ -1, 0 ], - [ 10, 20 ] + [0, 1], + [-1, 0], + [10, 20] ); - expect(handler.getAdjustedPosition([ 11, 84 ])).toEqual({ - position: [ 8, 15 ], - dimensions: [ 2, 2 ] + expect(handler.getAdjustedPosition([11, 84])).toEqual({ + position: [8, 15], + dimensions: [2, 2] }); }); }); } -); \ No newline at end of file +); diff --git a/platform/features/layout/test/elements/AccessorMutatorSpec.js b/platform/features/layout/test/elements/AccessorMutatorSpec.js index 4dc1873b7a..dfc9e1b282 100644 --- a/platform/features/layout/test/elements/AccessorMutatorSpec.js +++ b/platform/features/layout/test/elements/AccessorMutatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/AccessorMutator'], function (AccessorMutator) { - "use strict"; describe("An accessor-mutator", function () { var testObject, diff --git a/platform/features/layout/test/elements/BoxProxySpec.js b/platform/features/layout/test/elements/BoxProxySpec.js index 00f9087370..620095619a 100644 --- a/platform/features/layout/test/elements/BoxProxySpec.js +++ b/platform/features/layout/test/elements/BoxProxySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/BoxProxy'], function (BoxProxy) { - "use strict"; describe("A fixed position box proxy", function () { var testElement, @@ -39,7 +37,7 @@ define( height: 24, fill: "transparent" }; - testElements = [ {}, {}, testElement, {} ]; + testElements = [{}, {}, testElement, {}]; proxy = new BoxProxy( testElement, testElements.indexOf(testElement), diff --git a/platform/features/layout/test/elements/ElementFactorySpec.js b/platform/features/layout/test/elements/ElementFactorySpec.js index 64cc933903..36c9fa9b7a 100644 --- a/platform/features/layout/test/elements/ElementFactorySpec.js +++ b/platform/features/layout/test/elements/ElementFactorySpec.js @@ -19,15 +19,13 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/ElementFactory'], function (ElementFactory) { - "use strict"; - var DIALOG_ELEMENTS = [ 'image', 'text' ], - NON_DIALOG_ELEMENTS = [ 'box', 'line' ]; + var DIALOG_ELEMENTS = ['image', 'text'], + NON_DIALOG_ELEMENTS = ['box', 'line']; describe("The fixed position element factory", function () { var mockDialogService, @@ -37,11 +35,11 @@ define( beforeEach(function () { mockDialogService = jasmine.createSpyObj( 'dialogService', - [ 'getUserInput' ] + ['getUserInput'] ); mockPromise = jasmine.createSpyObj( 'promise', - [ 'then' ] + ['then'] ); mockDialogService.getUserInput.andReturn(mockPromise); @@ -68,4 +66,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/layout/test/elements/ElementProxiesSpec.js b/platform/features/layout/test/elements/ElementProxiesSpec.js index a7c0778020..076c6c2540 100644 --- a/platform/features/layout/test/elements/ElementProxiesSpec.js +++ b/platform/features/layout/test/elements/ElementProxiesSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/ElementProxies'], function (ElementProxies) { - "use strict"; // Expect these element types to have proxies var ELEMENT_TYPES = [ diff --git a/platform/features/layout/test/elements/ElementProxySpec.js b/platform/features/layout/test/elements/ElementProxySpec.js index ef29f78026..5c7a5e5183 100644 --- a/platform/features/layout/test/elements/ElementProxySpec.js +++ b/platform/features/layout/test/elements/ElementProxySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/ElementProxy'], function (ElementProxy) { - "use strict"; describe("A fixed position element proxy", function () { var testElement, @@ -39,7 +37,7 @@ define( width: 42, height: 24 }; - testElements = [ {}, {}, testElement, {} ]; + testElements = [{}, {}, testElement, {}]; proxy = new ElementProxy( testElement, testElements.indexOf(testElement), diff --git a/platform/features/layout/test/elements/ImageProxySpec.js b/platform/features/layout/test/elements/ImageProxySpec.js index 412587e2d2..2e77cfe543 100644 --- a/platform/features/layout/test/elements/ImageProxySpec.js +++ b/platform/features/layout/test/elements/ImageProxySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/ImageProxy'], function (ImageProxy) { - "use strict"; describe("A fixed position image proxy", function () { var testElement, @@ -39,7 +37,7 @@ define( height: 24, url: "http://www.nasa.gov" }; - testElements = [ {}, {}, testElement, {} ]; + testElements = [{}, {}, testElement, {}]; proxy = new ImageProxy( testElement, testElements.indexOf(testElement), diff --git a/platform/features/layout/test/elements/LineHandleSpec.js b/platform/features/layout/test/elements/LineHandleSpec.js index ed43eb45ae..5f682029d7 100644 --- a/platform/features/layout/test/elements/LineHandleSpec.js +++ b/platform/features/layout/test/elements/LineHandleSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ['../../src/elements/LineHandle'], function (LineHandle) { - "use strict"; describe("A fixed position drag handle", function () { var testElement, @@ -72,4 +70,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/layout/test/elements/LineProxySpec.js b/platform/features/layout/test/elements/LineProxySpec.js index a73133bdc5..14ba0a790e 100644 --- a/platform/features/layout/test/elements/LineProxySpec.js +++ b/platform/features/layout/test/elements/LineProxySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/LineProxy'], function (LineProxy) { - "use strict"; describe("A fixed position line proxy", function () { var vertical, horizontal, diagonal, reversed; @@ -94,4 +92,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/layout/test/elements/ResizeHandleSpec.js b/platform/features/layout/test/elements/ResizeHandleSpec.js index 5b05064756..48ffed0ae3 100644 --- a/platform/features/layout/test/elements/ResizeHandleSpec.js +++ b/platform/features/layout/test/elements/ResizeHandleSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ['../../src/elements/ResizeHandle'], function (ResizeHandle) { - "use strict"; var TEST_MIN_WIDTH = 4, TEST_MIN_HEIGHT = 2; @@ -77,4 +75,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/layout/test/elements/TelemetryProxySpec.js b/platform/features/layout/test/elements/TelemetryProxySpec.js index 396e3e505c..e68c6bf173 100644 --- a/platform/features/layout/test/elements/TelemetryProxySpec.js +++ b/platform/features/layout/test/elements/TelemetryProxySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/TelemetryProxy'], function (TelemetryProxy) { - "use strict"; describe("A fixed position telemetry proxy", function () { var testElement, @@ -40,7 +38,7 @@ define( height: 24, id: "test-id" }; - testElements = [ {}, {}, testElement, {} ]; + testElements = [{}, {}, testElement, {}]; proxy = new TelemetryProxy( testElement, testElements.indexOf(testElement), diff --git a/platform/features/layout/test/elements/TextProxySpec.js b/platform/features/layout/test/elements/TextProxySpec.js index 5b69d28930..eb808d5867 100644 --- a/platform/features/layout/test/elements/TextProxySpec.js +++ b/platform/features/layout/test/elements/TextProxySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ['../../src/elements/TextProxy'], function (TextProxy) { - "use strict"; describe("A fixed position text proxy", function () { var testElement, @@ -39,7 +37,7 @@ define( height: 24, fill: "transparent" }; - testElements = [ {}, {}, testElement, {} ]; + testElements = [{}, {}, testElement, {}]; proxy = new TextProxy( testElement, testElements.indexOf(testElement), diff --git a/platform/features/pages/bundle.js b/platform/features/pages/bundle.js index 1862b4980a..00c1e8729f 100644 --- a/platform/features/pages/bundle.js +++ b/platform/features/pages/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/EmbeddedPageController", @@ -30,7 +29,6 @@ define([ iframeTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/features/pages", { "extensions": { diff --git a/platform/features/pages/src/EmbeddedPageController.js b/platform/features/pages/src/EmbeddedPageController.js index 0ebe5dfa23..8729e653fe 100644 --- a/platform/features/pages/src/EmbeddedPageController.js +++ b/platform/features/pages/src/EmbeddedPageController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle adds the Web Page object type, which can be used to embed @@ -29,7 +28,6 @@ define( [], function () { - "use strict"; /** * Controller for embedded web pages; serves simply as a diff --git a/platform/features/pages/test/EmbeddedPageControllerSpec.js b/platform/features/pages/test/EmbeddedPageControllerSpec.js index 5f9c1948da..fe88c0ddee 100644 --- a/platform/features/pages/test/EmbeddedPageControllerSpec.js +++ b/platform/features/pages/test/EmbeddedPageControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/EmbeddedPageController"], function (EmbeddedPageController) { - "use strict"; describe("The controller for embedded pages", function () { var mockSCE, diff --git a/platform/features/plot/bundle.js b/platform/features/plot/bundle.js index 87f4563d91..d88ed0fdf4 100644 --- a/platform/features/plot/bundle.js +++ b/platform/features/plot/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/MCTChart", @@ -38,7 +37,6 @@ define([ plotOptionsBrowseTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/features/plot", { "name": "Plot view for telemetry", diff --git a/platform/features/plot/src/Canvas2DChart.js b/platform/features/plot/src/Canvas2DChart.js index 5917207920..7ed9e0982b 100644 --- a/platform/features/plot/src/Canvas2DChart.js +++ b/platform/features/plot/src/Canvas2DChart.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Float32Array*/ define( [], function () { - "use strict"; /** * Create a new chart which uses Canvas's 2D API for rendering. @@ -40,8 +38,8 @@ define( this.c2d = canvas.getContext('2d'); this.width = canvas.width; this.height = canvas.height; - this.dimensions = [ this.width, this.height ]; - this.origin = [ 0, 0 ]; + this.dimensions = [this.width, this.height]; + this.origin = [0, 0]; if (!this.c2d) { throw new Error("Canvas 2d API unavailable."); diff --git a/platform/features/plot/src/GLChart.js b/platform/features/plot/src/GLChart.js index 6dc7934fa5..7c4363a1dc 100644 --- a/platform/features/plot/src/GLChart.js +++ b/platform/features/plot/src/GLChart.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Float32Array*/ /** * Module defining GLPlot. Created by vwoeltje on 11/12/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; // WebGL shader sources (for drawing plain colors) var FRAGMENT_SHADER = [ diff --git a/platform/features/plot/src/MCTChart.js b/platform/features/plot/src/MCTChart.js index 05e45a2948..3edb16f607 100644 --- a/platform/features/plot/src/MCTChart.js +++ b/platform/features/plot/src/MCTChart.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining MCTChart. Created by vwoeltje on 11/12/14. @@ -27,7 +26,6 @@ define( ["./GLChart", "./Canvas2DChart"], function (GLChart, Canvas2DChart) { - "use strict"; var TEMPLATE = ""; diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index 4789f4c682..2525657501 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle adds a "Plot" view for numeric telemetry data. @@ -44,7 +43,6 @@ define( PlotModeOptions, SubPlotFactory ) { - "use strict"; var AXIS_DEFAULTS = [ { "name": "Time" }, diff --git a/platform/features/plot/src/PlotOptionsController.js b/platform/features/plot/src/PlotOptionsController.js index 381ee4dea2..4ab0ee2aa7 100644 --- a/platform/features/plot/src/PlotOptionsController.js +++ b/platform/features/plot/src/PlotOptionsController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./PlotOptionsForm'], function (PlotOptionsForm) { - "use strict"; /** * Notes on implementation of plot options @@ -59,7 +57,7 @@ define( Listen for changes to the domain object and update the object's children. */ - this.mutationListener = this.domainObject.getCapability('mutation').listen(function(model) { + this.mutationListener = this.domainObject.getCapability('mutation').listen(function (model) { if (self.hasCompositionChanged(self.composition, model.composition)) { self.updateChildren(); } @@ -72,7 +70,7 @@ define( $scope.xAxisForm = this.plotOptionsForm.xAxisForm; $scope.yAxisForm = this.plotOptionsForm.yAxisForm; - $scope.$on("$destroy", function() { + $scope.$on("$destroy", function () { //Clean up any listeners on destruction of controller self.mutationListener(); }); @@ -84,10 +82,10 @@ define( * Setup a number of watches for changes to form values. On * change, update the model configuration via mutation */ - $scope.$watchCollection('configuration.plot.yAxis', function(newValue, oldValue){ + $scope.$watchCollection('configuration.plot.yAxis', function (newValue, oldValue) { self.updateConfiguration(newValue, oldValue); }); - $scope.$watchCollection('configuration.plot.xAxis', function(newValue, oldValue){ + $scope.$watchCollection('configuration.plot.xAxis', function (newValue, oldValue) { self.updateConfiguration(newValue, oldValue); }); @@ -100,8 +98,8 @@ define( * child objects) * @private */ - PlotOptionsController.prototype.clearSeriesWatches = function() { - this.watches.forEach(function(watch) { + PlotOptionsController.prototype.clearSeriesWatches = function () { + this.watches.forEach(function (watch) { watch(); }); this.watches = []; @@ -111,16 +109,16 @@ define( * Attach watches for each object in the plot's composition * @private */ - PlotOptionsController.prototype.watchSeries = function() { + PlotOptionsController.prototype.watchSeries = function () { var self = this; this.clearSeriesWatches(); - (self.$scope.children || []).forEach(function(child, index){ + (self.$scope.children || []).forEach(function (child, index) { self.watches.push( self.$scope.$watchCollection( 'configuration.plot.series[' + index + ']', - function(newValue, oldValue){ + function (newValue, oldValue) { self.updateConfiguration(newValue, oldValue); } ) @@ -134,13 +132,13 @@ define( * * @private */ - PlotOptionsController.prototype.hasCompositionChanged = function(oldComposition, newComposition){ + PlotOptionsController.prototype.hasCompositionChanged = function (oldComposition, newComposition) { // Framed slightly strangely, but the boolean logic is // easier to follow for the unchanged case. var isUnchanged = oldComposition === newComposition || ( oldComposition.length === newComposition.length && - oldComposition.every( function (currentValue, index) { + oldComposition.every(function (currentValue, index) { return newComposition[index] && currentValue === newComposition[index]; }) ); @@ -165,12 +163,12 @@ define( * plot options model * @private */ - PlotOptionsController.prototype.updateChildren = function() { + PlotOptionsController.prototype.updateChildren = function () { var self = this; - this.domainObject.useCapability('composition').then(function(children){ + this.domainObject.useCapability('composition').then(function (children) { self.$scope.children = children; self.composition = self.domainObject.getModel().composition; - children.forEach(function(child, index){ + children.forEach(function (child, index) { self.configuration.plot.series[index] = self.configuration.plot.series[index] || {'id': child.getId()}; }); @@ -183,9 +181,9 @@ define( * object * @private */ - PlotOptionsController.prototype.updateConfiguration = function() { + PlotOptionsController.prototype.updateConfiguration = function () { var self = this; - this.domainObject.useCapability('mutation', function(model){ + this.domainObject.useCapability('mutation', function (model) { model.configuration = model.configuration || {}; model.configuration.plot = self.configuration.plot; }); diff --git a/platform/features/plot/src/PlotOptionsForm.js b/platform/features/plot/src/PlotOptionsForm.js index 993760ff06..3d8e534811 100644 --- a/platform/features/plot/src/PlotOptionsForm.js +++ b/platform/features/plot/src/PlotOptionsForm.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * A class for encapsulating structure and behaviour of the plot @@ -39,7 +37,7 @@ define( Defined below are the form structures for the plot options. */ this.xAxisForm = { - 'name':'x-axis', + 'name': 'x-axis', 'sections': [{ 'name': 'x-axis', 'rows': [ @@ -48,30 +46,30 @@ define( 'control': 'select', 'key': 'key', 'options': [ - {'name':'SCET', 'value': 'scet'}, - {'name':'SCLK', 'value': 'sclk'}, - {'name':'LST', 'value': 'lst'} + {'name': 'SCET', 'value': 'scet'}, + {'name': 'SCLK', 'value': 'sclk'}, + {'name': 'LST', 'value': 'lst'} ] } ] - }]}; + }]}; this.yAxisForm = { - 'name':'y-axis', - 'sections': [{ - // Will need to be repeated for each y-axis, with a - // distinct name for each. Ideally the name of the axis - // itself. 'name': 'y-axis', - 'rows': [ + 'sections': [{ + // Will need to be repeated for each y-axis, with a + // distinct name for each. Ideally the name of the axis + // itself. + 'name': 'y-axis', + 'rows': [ { 'name': 'Range', 'control': 'select', 'key': 'key', 'options': [ - {'name':'EU', 'value': 'eu'}, - {'name':'DN', 'value': 'dn'}, - {'name':'Status', 'value': 'status'} + {'name': 'EU', 'value': 'eu'}, + {'name': 'DN', 'value': 'dn'}, + {'name': 'Status', 'value': 'status'} ] }, { @@ -97,7 +95,7 @@ define( }] }; this.plotSeriesForm = { - 'name':'Series Options', + 'name': 'Series Options', 'sections': [ { rows: [ @@ -108,7 +106,7 @@ define( }] }, { - 'rows':[ + 'rows': [ { 'name': 'Markers', 'control': 'checkbox', @@ -118,7 +116,7 @@ define( ] }, { - 'rows':[ + 'rows': [ { 'name': 'No Line', 'control': 'radio', diff --git a/platform/features/plot/src/SubPlot.js b/platform/features/plot/src/SubPlot.js index 051f95f2a8..b0a003de38 100644 --- a/platform/features/plot/src/SubPlot.js +++ b/platform/features/plot/src/SubPlot.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [ @@ -27,7 +26,6 @@ define( './elements/PlotTickGenerator' ], function (PlotPosition, PlotTickGenerator) { - "use strict"; var DOMAIN_TICKS = 5, RANGE_TICKS = 7; @@ -69,9 +67,9 @@ define( * implies that there is no range data displayed either * @returns {boolean} true if domain data exists for the current pan/zoom level */ - SubPlot.prototype.hasDomainData = function() { - return this.panZoomStack - && this.panZoomStack.getDimensions()[0] > 0; + SubPlot.prototype.hasDomainData = function () { + return this.panZoomStack && + this.panZoomStack.getDimensions()[0] > 0; }; // Utility function for filtering out empty strings. @@ -111,7 +109,7 @@ define( // associated with conversion to a 32-bit floating point // format (which is needed in the chart area itself, by WebGL.) SubPlot.prototype.toDisplayable = function (position) { - return [ position[0] - this.domainOffset, position[1] ]; + return [position[0] - this.domainOffset, position[1]]; }; // Update the current hover coordinates @@ -147,7 +145,7 @@ define( end: this.toDisplayable( this.mousePositionToDomainRange(this.mousePosition) ), - color: [1, 1, 1, 0.5 ] + color: [1, 1, 1, 0.5] }] : undefined; }; @@ -191,7 +189,7 @@ define( this.panZoomStack ); - delta = [ current[0] - start[0], current[1] - start[1] ]; + delta = [current[0] - start[0], current[1] - start[1]]; nextOrigin = [ this.panStartBounds.origin[0] - delta[0], this.panStartBounds.origin[1] - delta[1] diff --git a/platform/features/plot/src/SubPlotFactory.js b/platform/features/plot/src/SubPlotFactory.js index 6de318f106..093ee879b7 100644 --- a/platform/features/plot/src/SubPlotFactory.js +++ b/platform/features/plot/src/SubPlotFactory.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["./SubPlot"], function (SubPlot) { - "use strict"; /** * Utility factory; wraps the SubPlot constructor and adds diff --git a/platform/features/plot/src/elements/PlotAxis.js b/platform/features/plot/src/elements/PlotAxis.js index e2f7809c64..26b3d80969 100644 --- a/platform/features/plot/src/elements/PlotAxis.js +++ b/platform/features/plot/src/elements/PlotAxis.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * A PlotAxis provides a template-ready set of options diff --git a/platform/features/plot/src/elements/PlotLimitTracker.js b/platform/features/plot/src/elements/PlotLimitTracker.js index 9309c50f32..e87a196d33 100644 --- a/platform/features/plot/src/elements/PlotLimitTracker.js +++ b/platform/features/plot/src/elements/PlotLimitTracker.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Float32Array*/ define( [], function () { - 'use strict'; /** * Tracks the limit state of telemetry objects being plotted. diff --git a/platform/features/plot/src/elements/PlotLine.js b/platform/features/plot/src/elements/PlotLine.js index abb23c8770..7582e1dbf7 100644 --- a/platform/features/plot/src/elements/PlotLine.js +++ b/platform/features/plot/src/elements/PlotLine.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Float32Array*/ define( ['./PlotSeriesWindow'], function (PlotSeriesWindow) { - "use strict"; /** diff --git a/platform/features/plot/src/elements/PlotLineBuffer.js b/platform/features/plot/src/elements/PlotLineBuffer.js index af0bbe553b..5687f854ee 100644 --- a/platform/features/plot/src/elements/PlotLineBuffer.js +++ b/platform/features/plot/src/elements/PlotLineBuffer.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Float32Array*/ define( [], function () { - "use strict"; /** * Contains the buffer used to draw a plot. @@ -37,7 +35,7 @@ define( function PlotLineBuffer(domainOffset, initialSize, maxSize) { this.buffer = new Float32Array(initialSize * 2); this.rangeExtrema = - [ Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY ]; + [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]; this.length = 0; this.domainOffset = domainOffset; this.initialSize = initialSize; diff --git a/platform/features/plot/src/elements/PlotPalette.js b/platform/features/plot/src/elements/PlotPalette.js index f003317fec..cea1aefeae 100644 --- a/platform/features/plot/src/elements/PlotPalette.js +++ b/platform/features/plot/src/elements/PlotPalette.js @@ -19,49 +19,47 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Plot palette. Defines colors for various plot lines. */ define( function () { - 'use strict'; // Prepare different forms of the palette, since we wish to // describe colors in several ways (as RGB 0-255, as // RGB 0.0-1.0, or as stylesheet-appropriate #-prefixed colors). var integerPalette = [ - [ 0x20, 0xB2, 0xAA ], - [ 0x9A, 0xCD, 0x32 ], - [ 0xFF, 0x8C, 0x00 ], - [ 0xD2, 0xB4, 0x8C ], - [ 0x40, 0xE0, 0xD0 ], - [ 0x41, 0x69, 0xFF ], - [ 0xFF, 0xD7, 0x00 ], - [ 0x6A, 0x5A, 0xCD ], - [ 0xEE, 0x82, 0xEE ], - [ 0xCC, 0x99, 0x66 ], - [ 0x99, 0xCC, 0xCC ], - [ 0x66, 0xCC, 0x33 ], - [ 0xFF, 0xCC, 0x00 ], - [ 0xFF, 0x66, 0x33 ], - [ 0xCC, 0x66, 0xFF ], - [ 0xFF, 0x00, 0x66 ], - [ 0xFF, 0xFF, 0x00 ], - [ 0x80, 0x00, 0x80 ], - [ 0x00, 0x86, 0x8B ], - [ 0x00, 0x8A, 0x00 ], - [ 0xFF, 0x00, 0x00 ], - [ 0x00, 0x00, 0xFF ], - [ 0xF5, 0xDE, 0xB3 ], - [ 0xBC, 0x8F, 0x8F ], - [ 0x46, 0x82, 0xB4 ], - [ 0xFF, 0xAF, 0xAF ], - [ 0x43, 0xCD, 0x80 ], - [ 0xCD, 0xC1, 0xC5 ], - [ 0xA0, 0x52, 0x2D ], - [ 0x64, 0x95, 0xED ] + [0x20, 0xB2, 0xAA], + [0x9A, 0xCD, 0x32], + [0xFF, 0x8C, 0x00], + [0xD2, 0xB4, 0x8C], + [0x40, 0xE0, 0xD0], + [0x41, 0x69, 0xFF], + [0xFF, 0xD7, 0x00], + [0x6A, 0x5A, 0xCD], + [0xEE, 0x82, 0xEE], + [0xCC, 0x99, 0x66], + [0x99, 0xCC, 0xCC], + [0x66, 0xCC, 0x33], + [0xFF, 0xCC, 0x00], + [0xFF, 0x66, 0x33], + [0xCC, 0x66, 0xFF], + [0xFF, 0x00, 0x66], + [0xFF, 0xFF, 0x00], + [0x80, 0x00, 0x80], + [0x00, 0x86, 0x8B], + [0x00, 0x8A, 0x00], + [0xFF, 0x00, 0x00], + [0x00, 0x00, 0xFF], + [0xF5, 0xDE, 0xB3], + [0xBC, 0x8F, 0x8F], + [0x46, 0x82, 0xB4], + [0xFF, 0xAF, 0xAF], + [0x43, 0xCD, 0x80], + [0xCD, 0xC1, 0xC5], + [0xA0, 0x52, 0x2D], + [0x64, 0x95, 0xED] ], stringPalette = integerPalette.map(function (arr) { // Convert to # notation for use in styles return '#' + arr.map(function (c) { diff --git a/platform/features/plot/src/elements/PlotPanZoomStack.js b/platform/features/plot/src/elements/PlotPanZoomStack.js index 1afb903056..e1cf7f3bcc 100644 --- a/platform/features/plot/src/elements/PlotPanZoomStack.js +++ b/platform/features/plot/src/elements/PlotPanZoomStack.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The PlotPanZoomStack is responsible for maintaining the diff --git a/platform/features/plot/src/elements/PlotPanZoomStackGroup.js b/platform/features/plot/src/elements/PlotPanZoomStackGroup.js index e1b61a06eb..52565b524a 100644 --- a/platform/features/plot/src/elements/PlotPanZoomStackGroup.js +++ b/platform/features/plot/src/elements/PlotPanZoomStackGroup.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./PlotPanZoomStack'], function (PlotPanZoomStack) { - "use strict"; /** * A plot pan zoom stack group provides a collection of individual @@ -52,8 +50,8 @@ define( // For other stacks, do a push, but repeat // their current range axis bounds. stack.pushPanZoom( - [ origin[0], stack.getOrigin()[1] ], - [ dimensions[0], stack.getDimensions()[1] ] + [origin[0], stack.getOrigin()[1]], + [dimensions[0], stack.getDimensions()[1]] ); } }); diff --git a/platform/features/plot/src/elements/PlotPosition.js b/platform/features/plot/src/elements/PlotPosition.js index d8369faf33..76282c5bbb 100644 --- a/platform/features/plot/src/elements/PlotPosition.js +++ b/platform/features/plot/src/elements/PlotPosition.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * A PlotPosition converts from pixel coordinates to domain-range @@ -62,7 +60,7 @@ define( // Note that range is reversed from the y-axis in pixel space //(positive range points up, positive pixel-y points down) this.position = - [ x / width, (height - y) / height ].map(convert); + [x / width, (height - y) / height].map(convert); } } diff --git a/platform/features/plot/src/elements/PlotPreparer.js b/platform/features/plot/src/elements/PlotPreparer.js index a1ca0cc5b5..5d6b1f001c 100644 --- a/platform/features/plot/src/elements/PlotPreparer.js +++ b/platform/features/plot/src/elements/PlotPreparer.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Float32Array*/ /** * Prepares data to be rendered in a GL Plot. Handles @@ -27,9 +26,10 @@ */ define( function () { - 'use strict'; - function identity(x) { return x; } + function identity(x) { + return x; + } /** * The PlotPreparer is responsible for handling data sets and diff --git a/platform/features/plot/src/elements/PlotSeriesWindow.js b/platform/features/plot/src/elements/PlotSeriesWindow.js index 4bf880a239..adafe78c3a 100644 --- a/platform/features/plot/src/elements/PlotSeriesWindow.js +++ b/platform/features/plot/src/elements/PlotSeriesWindow.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Provides a window on a telemetry data series, to support diff --git a/platform/features/plot/src/elements/PlotTelemetryFormatter.js b/platform/features/plot/src/elements/PlotTelemetryFormatter.js index bc2d4505a8..a3456459f8 100644 --- a/platform/features/plot/src/elements/PlotTelemetryFormatter.js +++ b/platform/features/plot/src/elements/PlotTelemetryFormatter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; var DIGITS = 3; diff --git a/platform/features/plot/src/elements/PlotTickGenerator.js b/platform/features/plot/src/elements/PlotTickGenerator.js index 8fa957fae7..a3503aefba 100644 --- a/platform/features/plot/src/elements/PlotTickGenerator.js +++ b/platform/features/plot/src/elements/PlotTickGenerator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The PlotTickGenerator provides labels for ticks along the diff --git a/platform/features/plot/src/elements/PlotUpdater.js b/platform/features/plot/src/elements/PlotUpdater.js index 53cfd1c4c4..9c4e7a8a92 100644 --- a/platform/features/plot/src/elements/PlotUpdater.js +++ b/platform/features/plot/src/elements/PlotUpdater.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Float32Array*/ define( ['./PlotLine', './PlotLineBuffer'], function (PlotLine, PlotLineBuffer) { - 'use strict'; var MAX_POINTS = 86400, PADDING_RATIO = 0.10, // Padding percentage for top & bottom @@ -73,7 +71,7 @@ define( // Used in the reduce step of updateExtrema function reduceExtrema(a, b) { - return [ Math.min(a[0], b[0]), Math.max(a[1], b[1]) ]; + return [Math.min(a[0], b[0]), Math.max(a[1], b[1])]; } // Convert a domain/range extrema to plot dimensions @@ -175,9 +173,9 @@ define( }).reduce(reduceExtrema); // Calculate best-fit dimensions - this.dimensions = [ this.domainExtrema, this.rangeExtrema ] + this.dimensions = [this.domainExtrema, this.rangeExtrema] .map(dimensionsOf); - this.origin = [ this.domainExtrema, this.rangeExtrema ] + this.origin = [this.domainExtrema, this.rangeExtrema] .map(originOf); // Enforce some minimum visible area diff --git a/platform/features/plot/src/modes/PlotModeOptions.js b/platform/features/plot/src/modes/PlotModeOptions.js index bd03129698..a1056ebfc4 100644 --- a/platform/features/plot/src/modes/PlotModeOptions.js +++ b/platform/features/plot/src/modes/PlotModeOptions.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["./PlotOverlayMode", "./PlotStackMode"], function (PlotOverlayMode, PlotStackMode) { - "use strict"; var STACKED = { key: "stacked", @@ -91,7 +89,7 @@ define( */ function PlotModeOptions(telemetryObjects, subPlotFactory) { this.options = telemetryObjects.length > 1 ? - [ OVERLAID, STACKED ] : [ OVERLAID ]; + [OVERLAID, STACKED] : [OVERLAID]; this.mode = this.options[0]; // Initial selection (overlaid) this.telemetryObjects = telemetryObjects; this.subPlotFactory = subPlotFactory; diff --git a/platform/features/plot/src/modes/PlotOverlayMode.js b/platform/features/plot/src/modes/PlotOverlayMode.js index 809d800ef2..d8e5c906ae 100644 --- a/platform/features/plot/src/modes/PlotOverlayMode.js +++ b/platform/features/plot/src/modes/PlotOverlayMode.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["../SubPlot", "../elements/PlotPalette", "../elements/PlotPanZoomStack"], function (SubPlot, PlotPalette, PlotPanZoomStack) { - "use strict"; /** * Handles plotting in Overlaid mode. In overlaid mode, there @@ -40,7 +38,7 @@ define( telemetryObjects, this.panZoomStack ); - this.subplots = [ this.subplot ]; + this.subplots = [this.subplot]; } PlotOverlayMode.prototype.plotTelemetry = function (updater) { diff --git a/platform/features/plot/src/modes/PlotStackMode.js b/platform/features/plot/src/modes/PlotStackMode.js index b20e9b9e32..e2d48bdade 100644 --- a/platform/features/plot/src/modes/PlotStackMode.js +++ b/platform/features/plot/src/modes/PlotStackMode.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["../SubPlot", "../elements/PlotPalette", "../elements/PlotPanZoomStackGroup"], function (SubPlot, PlotPalette, PlotPanZoomStackGroup) { - "use strict"; /** * Handles plotting in Stacked mode. In stacked mode, there diff --git a/platform/features/plot/src/policies/PlotViewPolicy.js b/platform/features/plot/src/policies/PlotViewPolicy.js index 1a2793aaa7..88f7b409b5 100644 --- a/platform/features/plot/src/policies/PlotViewPolicy.js +++ b/platform/features/plot/src/policies/PlotViewPolicy.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( function () { - "use strict"; /** * Policy preventing the Plot view from being made available for diff --git a/platform/features/plot/test/Canvas2DChartSpec.js b/platform/features/plot/test/Canvas2DChartSpec.js index a4c3b56197..102bdbb127 100644 --- a/platform/features/plot/test/Canvas2DChartSpec.js +++ b/platform/features/plot/test/Canvas2DChartSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/Canvas2DChart"], function (Canvas2DChart) { - "use strict"; describe("A canvas 2d chart", function () { var mockCanvas, @@ -35,7 +33,7 @@ define( chart; beforeEach(function () { - mockCanvas = jasmine.createSpyObj("canvas", [ "getContext" ]); + mockCanvas = jasmine.createSpyObj("canvas", ["getContext"]); mock2d = jasmine.createSpyObj( "2d", [ @@ -74,8 +72,8 @@ define( }); it("allows lines to be drawn", function () { - var testBuffer = [ 0, 1, 3, 8 ], - testColor = [ 0.25, 0.33, 0.66, 1.0 ], + var testBuffer = [0, 1, 3, 8], + testColor = [0.25, 0.33, 0.66, 1.0], testPoints = 2; chart.drawLine(testBuffer, testColor, testPoints); expect(mock2d.beginPath).toHaveBeenCalled(); @@ -86,7 +84,7 @@ define( it("allows squares to be drawn", function () { var testMin = [0, 1], testMax = [10, 10], - testColor = [ 0.25, 0.33, 0.66, 1.0 ]; + testColor = [0.25, 0.33, 0.66, 1.0]; chart.drawSquare(testMin, testMax, testColor); expect(mock2d.fillRect).toHaveBeenCalled(); @@ -94,4 +92,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/GLChartSpec.js b/platform/features/plot/test/GLChartSpec.js index e8a57b4bb8..3501e60191 100644 --- a/platform/features/plot/test/GLChartSpec.js +++ b/platform/features/plot/test/GLChartSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/GLChart"], function (GLChart) { - "use strict"; describe("A WebGL chart", function () { var mockCanvas, @@ -35,7 +33,7 @@ define( glChart; beforeEach(function () { - mockCanvas = jasmine.createSpyObj("canvas", [ "getContext" ]); + mockCanvas = jasmine.createSpyObj("canvas", ["getContext"]); mockGL = jasmine.createSpyObj( "gl", [ @@ -100,8 +98,8 @@ define( }); it("allows lines to be drawn", function () { - var testBuffer = [ 0, 1, 3, 8 ], - testColor = [ 0.25, 0.33, 0.66, 1.0 ], + var testBuffer = [0, 1, 3, 8], + testColor = [0.25, 0.33, 0.66, 1.0], testPoints = 2; glChart.drawLine(testBuffer, testColor, testPoints); expect(mockGL.bufferData).toHaveBeenCalledWith( @@ -118,7 +116,7 @@ define( it("allows squares to be drawn", function () { var testMin = [0, 1], testMax = [10, 10], - testColor = [ 0.25, 0.33, 0.66, 1.0 ]; + testColor = [0.25, 0.33, 0.66, 1.0]; glChart.drawSquare(testMin, testMax, testColor); @@ -142,4 +140,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/MCTChartSpec.js b/platform/features/plot/test/MCTChartSpec.js index 2277b65975..3fdd4924af 100644 --- a/platform/features/plot/test/MCTChartSpec.js +++ b/platform/features/plot/test/MCTChartSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/MCTChart"], function (MCTChart) { - "use strict"; describe("The mct-chart directive", function () { var mockInterval, @@ -57,7 +55,7 @@ define( // mct-chart uses GLChart, so it needs WebGL API mockCanvas = - jasmine.createSpyObj("canvas", [ "getContext", "addEventListener" ]); + jasmine.createSpyObj("canvas", ["getContext", "addEventListener"]); mockGL = jasmine.createSpyObj( "gl", [ @@ -124,7 +122,7 @@ define( it("issues one draw call per line", function () { mctChart.link(mockScope, mockElement); mockScope.$watchCollection.mostRecentCall.args[1]({ - lines: [ {}, {}, {} ] + lines: [{}, {}, {}] }); expect(mockGL.drawArrays.calls.length).toEqual(3); }); diff --git a/platform/features/plot/test/PlotControllerSpec.js b/platform/features/plot/test/PlotControllerSpec.js index f9715d822a..4213041387 100644 --- a/platform/features/plot/test/PlotControllerSpec.js +++ b/platform/features/plot/test/PlotControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,xit,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/PlotController"], function (PlotController) { - "use strict"; describe("The plot controller", function () { var mockScope, @@ -65,15 +63,15 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "$watch", "$on", "$emit" ] + ["$watch", "$on", "$emit"] ); mockFormatter = jasmine.createSpyObj( "formatter", - [ "formatDomainValue", "formatRangeValue" ] + ["formatDomainValue", "formatRangeValue"] ); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); mockHandler = jasmine.createSpyObj( "telemetrySubscriber", @@ -98,7 +96,9 @@ define( ); mockHandler.handle.andReturn(mockHandle); - mockThrottle.andCallFake(function (fn) { return fn; }); + mockThrottle.andCallFake(function (fn) { + return fn; + }); mockHandle.getTelemetryObjects.andReturn([mockDomainObject]); mockHandle.getMetadata.andReturn([{}]); mockHandle.getDomainValue.andReturn(123); diff --git a/platform/features/plot/test/PlotOptionsControllerSpec.js b/platform/features/plot/test/PlotOptionsControllerSpec.js index cac42f72a7..a95aabce7c 100644 --- a/platform/features/plot/test/PlotOptionsControllerSpec.js +++ b/platform/features/plot/test/PlotOptionsControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ['../src/PlotOptionsController'], function (PlotOptionsController) { - "use strict"; describe("The Plot Options controller", function () { var plotOptionsController, @@ -34,7 +32,6 @@ define( mockCompositionCapability, mockComposition, mockUnlisten, - mockFormUnlisten, mockChildOne, mockChildTwo, model, @@ -61,7 +58,7 @@ define( mockComposition = [ mockChildOne ]; - mockCompositionCapability.then.andCallFake(function (callback){ + mockCompositionCapability.then.andCallFake(function (callback) { callback(mockComposition); }); @@ -82,7 +79,7 @@ define( 'useCapability', 'getCapability' ]); - mockDomainObject.useCapability.andCallFake(function(capability){ + mockDomainObject.useCapability.andCallFake(function (capability) { return mockUseCapabilities[capability](); }); mockDomainObject.getCapability.andReturn(mockMutationCapability); @@ -123,7 +120,7 @@ define( it("on changes in form values, updates the object model", function () { var scopeConfiguration = mockScope.configuration, - model = mockDomainObject.getModel(); + objModel = mockDomainObject.getModel(); scopeConfiguration.plot.yAxis.autoScale = true; scopeConfiguration.plot.yAxis.key = 'eu'; @@ -133,10 +130,10 @@ define( mockScope.$watchCollection.calls[0].args[1](); expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function)); - mockDomainObject.useCapability.mostRecentCall.args[1](model); - expect(model.configuration.plot.yAxis.autoScale).toBe(true); - expect(model.configuration.plot.yAxis.key).toBe('eu'); - expect(model.configuration.plot.xAxis.key).toBe('lst'); + mockDomainObject.useCapability.mostRecentCall.args[1](objModel); + expect(objModel.configuration.plot.yAxis.autoScale).toBe(true); + expect(objModel.configuration.plot.yAxis.key).toBe('eu'); + expect(objModel.configuration.plot.xAxis.key).toBe('lst'); }); diff --git a/platform/features/plot/test/PlotOptionsFormSpec.js b/platform/features/plot/test/PlotOptionsFormSpec.js index 49dfc823e9..bb35d532f4 100644 --- a/platform/features/plot/test/PlotOptionsFormSpec.js +++ b/platform/features/plot/test/PlotOptionsFormSpec.js @@ -19,16 +19,13 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ['../src/PlotOptionsForm'], function (PlotOptionsForm) { - "use strict"; describe("The Plot Options form", function () { - var plotOptionsForm, - listener; + var plotOptionsForm; beforeEach(function () { diff --git a/platform/features/plot/test/SubPlotFactorySpec.js b/platform/features/plot/test/SubPlotFactorySpec.js index 1b2a5af703..5e8e3affcc 100644 --- a/platform/features/plot/test/SubPlotFactorySpec.js +++ b/platform/features/plot/test/SubPlotFactorySpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/SubPlotFactory"], function (SubPlotFactory) { - "use strict"; describe("The sub-plot factory", function () { var mockDomainObject, @@ -38,20 +36,20 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); mockPanZoomStack = jasmine.createSpyObj( "panZoomStack", - [ "getPanZoom" ] + ["getPanZoom"] ); mockFormatter = jasmine.createSpyObj( "formatter", - [ "formatDomainValue", "formatRangeValue" ] + ["formatDomainValue", "formatRangeValue"] ); mockPanZoomStack.getPanZoom.andReturn({ - origin: [ 0, 0 ], - dimensions: [ 100, 100 ] + origin: [0, 0], + dimensions: [100, 100] }); factory = new SubPlotFactory(mockFormatter); @@ -65,4 +63,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/SubPlotSpec.js b/platform/features/plot/test/SubPlotSpec.js index f7a7b667e9..8d3fc16f67 100644 --- a/platform/features/plot/test/SubPlotSpec.js +++ b/platform/features/plot/test/SubPlotSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/SubPlot"], function (SubPlot) { - "use strict"; describe("A sub-plot", function () { var mockDomainObject, @@ -42,7 +40,7 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); mockPanZoomStack = jasmine.createSpyObj( "panZoomStack", @@ -59,16 +57,16 @@ define( ); mockFormatter = jasmine.createSpyObj( "formatter", - [ "formatDomainValue", "formatRangeValue" ] + ["formatDomainValue", "formatRangeValue"] ); mockElement = jasmine.createSpyObj( "element", - [ "getBoundingClientRect" ] + ["getBoundingClientRect"] ); - testOrigin = [ 5, 10 ]; - testDimensions = [ 3000, 1000 ]; - testDomainObjects = [ mockDomainObject, mockDomainObject ]; + testOrigin = [5, 10]; + testDimensions = [3000, 1000]; + testDomainObjects = [mockDomainObject, mockDomainObject]; mockPanZoomStack.getOrigin.andReturn(testOrigin); mockPanZoomStack.getDimensions.andReturn(testDimensions); @@ -165,7 +163,7 @@ define( mockPanZoomStack.getDimensions.andReturn([0,0]); expect(subplot.hasDomainData()).toEqual(false); }); - + it("disallows marquee zoom when start and end Marquee is at the same position", function () { expect(mockPanZoomStack.pushPanZoom).not.toHaveBeenCalled(); diff --git a/platform/features/plot/test/elements/PlotAxisSpec.js b/platform/features/plot/test/elements/PlotAxisSpec.js index f06f0c69cc..922d20d1a8 100644 --- a/platform/features/plot/test/elements/PlotAxisSpec.js +++ b/platform/features/plot/test/elements/PlotAxisSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/elements/PlotAxis"], function (PlotAxis) { - "use strict"; describe("A plot axis", function () { var testMetadatas, @@ -90,7 +88,7 @@ define( }); it("reflects changes to applicable metadata", function () { - axis.updateMetadata([ testMetadatas[1] ]); + axis.updateMetadata([testMetadatas[1]]); expect(axis.options).toEqual([ { key: "t0", name: "T0" }, { key: "t2", name: "T2" } diff --git a/platform/features/plot/test/elements/PlotLimitTrackerSpec.js b/platform/features/plot/test/elements/PlotLimitTrackerSpec.js index 1ba428115f..4212f57c49 100644 --- a/platform/features/plot/test/elements/PlotLimitTrackerSpec.js +++ b/platform/features/plot/test/elements/PlotLimitTrackerSpec.js @@ -19,19 +19,16 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/elements/PlotLimitTracker"], function (PlotLimitTracker) { - "use strict"; describe("A plot's limit tracker", function () { var mockHandle, testRange, mockTelemetryObjects, testData, - mockLimitCapabilities, tracker; beforeEach(function () { @@ -44,11 +41,11 @@ define( mockTelemetryObjects = ['a', 'b', 'c'].map(function (id, i) { var mockTelemetryObject = jasmine.createSpyObj( 'object-' + id, - [ 'getId', 'getCapability', 'getModel' ] + ['getId', 'getCapability', 'getModel'] ), mockLimitCapability = jasmine.createSpyObj( 'limit-' + id, - [ 'evaluate' ] + ['evaluate'] ); testData[id] = { id: id, value: i }; mockTelemetryObject.getId.andReturn(id); diff --git a/platform/features/plot/test/elements/PlotLineBufferSpec.js b/platform/features/plot/test/elements/PlotLineBufferSpec.js index 54c0c04c77..405dd4df10 100644 --- a/platform/features/plot/test/elements/PlotLineBufferSpec.js +++ b/platform/features/plot/test/elements/PlotLineBufferSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/elements/PlotLineBuffer"], function (PlotLineBuffer) { - "use strict"; var TEST_INITIAL_SIZE = 10, TEST_MAX_SIZE = 40, @@ -40,8 +38,8 @@ define( buffer; beforeEach(function () { - testDomainValues = [ 1, 3, 7, 9, 14, 15 ]; - testRangeValues = [ 8, 0, 3, 9, 8, 11 ]; + testDomainValues = [1, 3, 7, 9, 14, 15]; + testRangeValues = [8, 0, 3, 9, 8, 11]; mockSeries = jasmine.createSpyObj( "series", ['getPointCount', 'getDomainValue', 'getRangeValue'] @@ -72,7 +70,7 @@ define( // that domain offset was adjusted for. expect( Array.prototype.slice.call(buffer.getBuffer()).slice(0, 12) - ).toEqual([ -41, 8, -39, 0, -35, 3, -33, 9, -28, 8, -27, 11]); + ).toEqual([-41, 8, -39, 0, -35, 3, -33, 9, -28, 8, -27, 11]); expect(buffer.getLength()).toEqual(6); }); @@ -86,8 +84,8 @@ define( }); it("allows insertion in the middle", function () { - var head = [ -41, 8, -39, 0, -35, 3 ], - tail = [ -33, 9, -28, 8, -27, 11]; + var head = [-41, 8, -39, 0, -35, 3], + tail = [-33, 9, -28, 8, -27, 11]; buffer.insert(mockSeries, 3); expect( Array.prototype.slice.call(buffer.getBuffer()).slice(0, 24) @@ -100,7 +98,7 @@ define( expect(buffer.getLength()).toEqual(4); expect( Array.prototype.slice.call(buffer.getBuffer()).slice(0, 8) - ).toEqual([ -35, 3, -33, 9, -28, 8, -27, 11]); + ).toEqual([-35, 3, -33, 9, -28, 8, -27, 11]); }); it("expands buffer when needed to accommodate more data", function () { diff --git a/platform/features/plot/test/elements/PlotLineSpec.js b/platform/features/plot/test/elements/PlotLineSpec.js index aa8b66597a..a6a3ed7800 100644 --- a/platform/features/plot/test/elements/PlotLineSpec.js +++ b/platform/features/plot/test/elements/PlotLineSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/elements/PlotLine"], function (PlotLine) { - "use strict"; describe("A plot line", function () { var mockBuffer, @@ -103,7 +101,7 @@ define( }); it("allows series insertion", function () { - testSeries = [ [ 50, 42 ], [ 100, 200 ], [ 150, 12321 ] ]; + testSeries = [[50, 42], [100, 200], [150, 12321]]; line.addSeries(mockSeries); // Should have managed insertion index choices to get to... expect(testDomainBuffer).toEqual([50, 100, 150]); @@ -111,7 +109,7 @@ define( }); it("splits series insertion when necessary", function () { - testSeries = [ [ 50, 42 ], [ 100, 200 ], [ 150, 12321 ] ]; + testSeries = [[50, 42], [100, 200], [150, 12321]]; line.addPoint(75, 1); line.addSeries(mockSeries); // Should have managed insertion index choices to get to... @@ -132,4 +130,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/elements/PlotPaletteSpec.js b/platform/features/plot/test/elements/PlotPaletteSpec.js index 050303dab9..134cf41e9b 100644 --- a/platform/features/plot/test/elements/PlotPaletteSpec.js +++ b/platform/features/plot/test/elements/PlotPaletteSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/elements/PlotPalette"], function (PlotPalette) { - "use strict"; describe("The plot palette", function () { it("can be used as a constructor", function () { @@ -122,4 +120,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/elements/PlotPanZoomStackGroupSpec.js b/platform/features/plot/test/elements/PlotPanZoomStackGroupSpec.js index 668862f4ff..52a47a8b10 100644 --- a/platform/features/plot/test/elements/PlotPanZoomStackGroupSpec.js +++ b/platform/features/plot/test/elements/PlotPanZoomStackGroupSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/elements/PlotPanZoomStackGroup"], function (PlotPanZoomStackGroup) { - "use strict"; var COUNT = 8; @@ -51,7 +49,7 @@ define( it("synchronizes pan-zoom stack depth", function () { expect(group.getDepth()).toEqual(1); - group.getPanZoomStack(1).pushPanZoom([ 10, 20 ], [ 30, 40 ]); + group.getPanZoomStack(1).pushPanZoom([10, 20], [30, 40]); stacks.forEach(function (stack) { expect(stack.getDepth()).toEqual(2); }); @@ -60,11 +58,11 @@ define( it("synchronizes domain but not range", function () { // Set up different initial states stacks.forEach(function (stack, i) { - stack.pushPanZoom([ i, i ], [ i, i ]); + stack.pushPanZoom([i, i], [i, i]); }); // Push a new pan-zoom state onto one of the stacks - group.getPanZoomStack(1).pushPanZoom([ 99, 99 ], [ 42, 42 ]); + group.getPanZoomStack(1).pushPanZoom([99, 99], [42, 42]); // Should changed domain values for all stacks, but // only changed range values for stack 1 @@ -87,7 +85,7 @@ define( it("clears pan-zoom on request", function () { // Set up different initial states stacks.forEach(function (stack, i) { - stack.pushPanZoom([ i, i ], [ i, i ]); + stack.pushPanZoom([i, i], [i, i]); }); // Verify that we have a greater depth @@ -106,7 +104,7 @@ define( it("pops pan-zoom on request", function () { // Set up different initial states stacks.forEach(function (stack, i) { - stack.pushPanZoom([ i, i ], [ i, i ]); + stack.pushPanZoom([i, i], [i, i]); }); // Verify that we have a greater depth @@ -125,4 +123,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/elements/PlotPanZoomStackSpec.js b/platform/features/plot/test/elements/PlotPanZoomStackSpec.js index b7170140b4..7f2760cdef 100644 --- a/platform/features/plot/test/elements/PlotPanZoomStackSpec.js +++ b/platform/features/plot/test/elements/PlotPanZoomStackSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/elements/PlotPanZoomStack"], function (PlotPanZoomStack) { - "use strict"; describe("A plot pan-zoom stack", function () { var panZoomStack, @@ -48,10 +46,10 @@ define( } beforeEach(function () { - initialOrigin = [ 4, 2 ]; - initialDimensions = [ 600, 400 ]; - otherOrigins = [ [8, 6], [12, 9] ]; - otherDimensions = [ [400, 300], [200, 300] ]; + initialOrigin = [4, 2]; + initialDimensions = [600, 400]; + otherOrigins = [[8, 6], [12, 9]]; + otherDimensions = [[400, 300], [200, 300]]; panZoomStack = new PlotPanZoomStack(initialOrigin, initialDimensions); }); @@ -98,4 +96,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/elements/PlotPositionSpec.js b/platform/features/plot/test/elements/PlotPositionSpec.js index d3571fc943..61f6e2b965 100644 --- a/platform/features/plot/test/elements/PlotPositionSpec.js +++ b/platform/features/plot/test/elements/PlotPositionSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,17 +26,16 @@ define( ["../../src/elements/PlotPosition"], function (PlotPosition) { - "use strict"; describe("A plot position", function () { var mockPanZoom, - testOrigin = [ 10, 20 ], - testDimensions = [ 800, 10 ]; + testOrigin = [10, 20], + testDimensions = [800, 10]; beforeEach(function () { mockPanZoom = jasmine.createSpyObj( "panZoomStack", - [ "getPanZoom" ] + ["getPanZoom"] ); mockPanZoom.getPanZoom.andReturn({ origin: testOrigin, @@ -66,4 +64,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/elements/PlotPreparerSpec.js b/platform/features/plot/test/elements/PlotPreparerSpec.js index 9bb0ecd048..ded5c5454d 100644 --- a/platform/features/plot/test/elements/PlotPreparerSpec.js +++ b/platform/features/plot/test/elements/PlotPreparerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,Float32Array*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/elements/PlotPreparer"], function (PlotPreparer) { - "use strict"; var START = 123456; @@ -36,7 +34,7 @@ define( function makeMockData(scale) { var mockData = jasmine.createSpyObj( "data" + scale, - [ "getPointCount", "getDomainValue", "getRangeValue" ] + ["getPointCount", "getDomainValue", "getRangeValue"] ); mockData.getPointCount.andReturn(1000); mockData.getDomainValue.andCallFake(function (i) { @@ -63,6 +61,8 @@ define( var datas = [makeMockData(1)], preparer = new PlotPreparer(datas, "testDomain", "testRange"); + expect(preparer).toBeDefined(); + expect(datas[0].getDomainValue).toHaveBeenCalledWith( jasmine.any(Number), "testDomain" @@ -90,4 +90,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/elements/PlotSeriesWindowSpec.js b/platform/features/plot/test/elements/PlotSeriesWindowSpec.js index a0d910127c..eaf619751f 100644 --- a/platform/features/plot/test/elements/PlotSeriesWindowSpec.js +++ b/platform/features/plot/test/elements/PlotSeriesWindowSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/elements/PlotSeriesWindow"], function (PlotSeriesWindow) { - "use strict"; describe("A plot's window on a telemetry series", function () { var mockSeries, @@ -33,11 +31,11 @@ define( beforeEach(function () { testSeries = [ - [ 0, 42 ], - [ 10, 1 ], - [ 20, 4 ], - [ 30, 9 ], - [ 40, 3 ] + [0, 42], + [10, 1], + [20, 4], + [30, 9], + [40, 3] ]; mockSeries = jasmine.createSpyObj( @@ -92,4 +90,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/elements/PlotTelemetryFormatterSpec.js b/platform/features/plot/test/elements/PlotTelemetryFormatterSpec.js index eea22ba2ef..7de30e338b 100644 --- a/platform/features/plot/test/elements/PlotTelemetryFormatterSpec.js +++ b/platform/features/plot/test/elements/PlotTelemetryFormatterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/elements/PlotTelemetryFormatter"], function (PlotTelemetryFormatter) { - 'use strict'; describe("The PlotTelemetryFormatter", function () { var mockFormatter, diff --git a/platform/features/plot/test/elements/PlotTickGeneratorSpec.js b/platform/features/plot/test/elements/PlotTickGeneratorSpec.js index 4b480a45cd..b26a6a0051 100644 --- a/platform/features/plot/test/elements/PlotTickGeneratorSpec.js +++ b/platform/features/plot/test/elements/PlotTickGeneratorSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/elements/PlotTickGenerator"], function (PlotTickGenerator) { - "use strict"; describe("A plot tick generator", function () { var mockPanZoomStack, @@ -37,16 +35,16 @@ define( beforeEach(function () { mockPanZoomStack = jasmine.createSpyObj( "panZoomStack", - [ "getPanZoom" ] + ["getPanZoom"] ); mockFormatter = jasmine.createSpyObj( "formatter", - [ "formatDomainValue", "formatRangeValue" ] + ["formatDomainValue", "formatRangeValue"] ); mockPanZoomStack.getPanZoom.andReturn({ - origin: [ 0, 0 ], - dimensions: [ 100, 100 ] + origin: [0, 0], + dimensions: [100, 100] }); generator = @@ -72,4 +70,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/elements/PlotUpdaterSpec.js b/platform/features/plot/test/elements/PlotUpdaterSpec.js index c287dbfdf8..e91da5f19a 100644 --- a/platform/features/plot/test/elements/PlotUpdaterSpec.js +++ b/platform/features/plot/test/elements/PlotUpdaterSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,Float32Array*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/elements/PlotUpdater"], function (PlotUpdater) { - "use strict"; describe("A plot updater", function () { var mockSubscription, @@ -41,19 +39,19 @@ define( function makeMockDomainObject(id) { var mockDomainObject = jasmine.createSpyObj( "object-" + id, - [ "getId", "getCapability", "getModel" ] + ["getId", "getCapability", "getModel"] ); mockDomainObject.getId.andReturn(id); return mockDomainObject; } beforeEach(function () { - var ids = [ 'a', 'b', 'c' ], + var ids = ['a', 'b', 'c'], mockObjects = ids.map(makeMockDomainObject); mockSubscription = jasmine.createSpyObj( "subscription", - [ "getDomainValue", "getRangeValue", "getTelemetryObjects" ] + ["getDomainValue", "getRangeValue", "getTelemetryObjects"] ); mockSeries = jasmine.createSpyObj( 'series', diff --git a/platform/features/plot/test/modes/PlotModeOptionsSpec.js b/platform/features/plot/test/modes/PlotModeOptionsSpec.js index 672a311adb..37c74cdf8f 100644 --- a/platform/features/plot/test/modes/PlotModeOptionsSpec.js +++ b/platform/features/plot/test/modes/PlotModeOptionsSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/modes/PlotModeOptions"], function (PlotModeOptions) { - "use strict"; describe("Plot mode options", function () { var mockDomainObject, @@ -36,11 +34,11 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); mockSubPlotFactory = jasmine.createSpyObj( "subPlotFactory", - [ "createSubPlot" ] + ["createSubPlot"] ); }); @@ -86,4 +84,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/modes/PlotOverlayModeSpec.js b/platform/features/plot/test/modes/PlotOverlayModeSpec.js index 1f9e107047..877820750c 100644 --- a/platform/features/plot/test/modes/PlotOverlayModeSpec.js +++ b/platform/features/plot/test/modes/PlotOverlayModeSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,25 +26,15 @@ define( ["../../src/modes/PlotOverlayMode"], function (PlotOverlayMode) { - "use strict"; describe("Overlaid plot mode", function () { var mockDomainObject, mockSubPlotFactory, - mockSubPlot, mockPrepared, testBuffers, testDrawingObjects, mode; - function mockElement(x, y, w, h) { - return { - getBoundingClientRect: function () { - return { left: x, top: y, width: w, height: h }; - } - }; - } - function createMockSubPlot() { var mockSubPlot = jasmine.createSpyObj( "subPlot", @@ -69,11 +58,11 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); mockSubPlotFactory = jasmine.createSpyObj( "subPlotFactory", - [ "createSubPlot" ] + ["createSubPlot"] ); // Prepared telemetry data mockPrepared = jasmine.createSpyObj( @@ -129,7 +118,7 @@ define( mode.plotTelemetry(mockPrepared); // Should have one sub-plot with three lines - testDrawingObjects.forEach(function (testDrawingObject, i) { + testDrawingObjects.forEach(function (testDrawingObject) { // Either empty list or undefined is fine; // just want to make sure there are no lines. expect(testDrawingObject.lines.length) @@ -180,7 +169,7 @@ define( }); // Step back the same number of zoom changes - mockSubPlotFactory.createSubPlot.calls.forEach(function (c) { + mockSubPlotFactory.createSubPlot.calls.forEach(function () { // Should still be zoomed at start of each iteration expect(mode.isZoomed()).toBeTruthy(); // Step back one of the zoom changes. @@ -192,4 +181,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/modes/PlotStackModeSpec.js b/platform/features/plot/test/modes/PlotStackModeSpec.js index d1381b21ca..65e6962591 100644 --- a/platform/features/plot/test/modes/PlotStackModeSpec.js +++ b/platform/features/plot/test/modes/PlotStackModeSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,25 +26,15 @@ define( ["../../src/modes/PlotStackMode"], function (PlotStackMode) { - "use strict"; describe("Stacked plot mode", function () { var mockDomainObject, mockSubPlotFactory, - mockSubPlot, mockPrepared, testBuffers, testDrawingObjects, mode; - function mockElement(x, y, w, h) { - return { - getBoundingClientRect: function () { - return { left: x, top: y, width: w, height: h }; - } - }; - } - function createMockSubPlot() { var mockSubPlot = jasmine.createSpyObj( "subPlot", @@ -69,16 +58,16 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "getCapability" ] + ["getId", "getModel", "getCapability"] ); mockSubPlotFactory = jasmine.createSpyObj( "subPlotFactory", - [ "createSubPlot" ] + ["createSubPlot"] ); // Prepared telemetry data mockPrepared = jasmine.createSpyObj( "prepared", - [ "getDomainOffset", "getOrigin", "getDimensions", "getLineBuffers" ] + ["getDomainOffset", "getOrigin", "getDimensions", "getLineBuffers"] ); mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot); @@ -174,7 +163,7 @@ define( }); // Step back the same number of zoom changes - mockSubPlotFactory.createSubPlot.calls.forEach(function (c) { + mockSubPlotFactory.createSubPlot.calls.forEach(function () { // Should still be zoomed at start of each iteration expect(mode.isZoomed()).toBeTruthy(); // Step back @@ -187,4 +176,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/plot/test/policies/PlotViewPolicySpec.js b/platform/features/plot/test/policies/PlotViewPolicySpec.js index 27c40221ef..008d4275da 100644 --- a/platform/features/plot/test/policies/PlotViewPolicySpec.js +++ b/platform/features/plot/test/policies/PlotViewPolicySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,xit*/ define( ["../../src/policies/PlotViewPolicy"], function (PlotViewPolicy) { - "use strict"; describe("Plot view policy", function () { var testView, @@ -53,23 +51,23 @@ define( }); it("allows the imagery view for domain objects with numeric telemetry", function () { - testMetadata.ranges = [ { key: "foo", format: "number" } ]; + testMetadata.ranges = [{ key: "foo", format: "number" }]; expect(policy.allow(testView, mockDomainObject)).toBeTruthy(); }); it("allows the imagery view for domain objects with unspecified telemetry", function () { - testMetadata.ranges = [ { key: "foo" } ]; + testMetadata.ranges = [{ key: "foo" }]; expect(policy.allow(testView, mockDomainObject)).toBeTruthy(); }); it("disallows the imagery view for domain objects without image telemetry", function () { - testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ]; + testMetadata.ranges = [{ key: "foo", format: "somethingElse" }]; expect(policy.allow(testView, mockDomainObject)).toBeFalsy(); }); it("allows other views", function () { testView.key = "somethingElse"; - testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ]; + testMetadata.ranges = [{ key: "foo", format: "somethingElse" }]; expect(policy.allow(testView, mockDomainObject)).toBeTruthy(); }); diff --git a/platform/features/static-markup/bundle.js b/platform/features/static-markup/bundle.js index 4ac5a13701..59376ff957 100644 --- a/platform/features/static-markup/bundle.js +++ b/platform/features/static-markup/bundle.js @@ -19,18 +19,16 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ - + "text!./res/markup.html", 'legacyRegistry' ], function ( - + markupTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/features/static-markup", { "extensions": { diff --git a/platform/features/table/bundle.js b/platform/features/table/bundle.js index 77ead67c04..ee907bc963 100644 --- a/platform/features/table/bundle.js +++ b/platform/features/table/bundle.js @@ -19,26 +19,24 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/directives/MCTTable", - "./src/controllers/RTTelemetryTableController", - "./src/controllers/TelemetryTableController", + "./src/controllers/RealtimeTableController", + "./src/controllers/HistoricalTableController", "./src/controllers/TableOptionsController", '../../commonUI/regions/src/Region', '../../commonUI/browse/src/InspectorRegion', "legacyRegistry" ], function ( MCTTable, - RTTelemetryTableController, - TelemetryTableController, + RealtimeTableController, + HistoricalTableController, TableOptionsController, Region, InspectorRegion, legacyRegistry ) { - "use strict"; /** * Two region parts are defined here. One that appears only in browse * mode, and one that appears only in edit mode. For not they both point @@ -109,13 +107,13 @@ define([ ], "controllers": [ { - "key": "TelemetryTableController", - "implementation": TelemetryTableController, + "key": "HistoricalTableController", + "implementation": HistoricalTableController, "depends": ["$scope", "telemetryHandler", "telemetryFormatter"] }, { - "key": "RTTelemetryTableController", - "implementation": RTTelemetryTableController, + "key": "RealtimeTableController", + "implementation": RealtimeTableController, "depends": ["$scope", "telemetryHandler", "telemetryFormatter"] }, { @@ -130,7 +128,7 @@ define([ "name": "Historical Table", "key": "table", "glyph": "\ue604", - "templateUrl": "templates/table.html", + "templateUrl": "templates/historical-table.html", "needs": [ "telemetry" ], @@ -161,6 +159,12 @@ define([ "key": "table-options-edit", "templateUrl": "templates/table-options-edit.html" } + ], + "stylesheets": [ + { + "stylesheetUrl": "css/table.css", + "priority": "mandatory" + } ] } }); diff --git a/platform/features/table/res/sass/table.scss b/platform/features/table/res/sass/table.scss new file mode 100644 index 0000000000..4ab70c09de --- /dev/null +++ b/platform/features/table/res/sass/table.scss @@ -0,0 +1,62 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ + +.sizing-table { + min-width: 100%; + z-index: -1; + visibility: hidden; + position: absolute; + + //Add some padding to allow for decorations such as limits indicator + td { + padding-right: 15px; + padding-left: 10px; + white-space: nowrap; + } +} +.mct-table { + table-layout: fixed; + thead { + display: block; + tr { + display: block; + white-space: nowrap; + th { + display: inline-block; + box-sizing: border-box; + } + } + } + tbody { + tr { + position: absolute; + white-space: nowrap; + display: block; + } + td { + white-space: nowrap; + overflow: hidden; + box-sizing: border-box; + display: inline-block; + } + } +} diff --git a/platform/features/table/res/templates/table.html b/platform/features/table/res/templates/historical-table.html similarity index 71% rename from platform/features/table/res/templates/table.html rename to platform/features/table/res/templates/historical-table.html index c63f6d63fc..9917c41dcc 100644 --- a/platform/features/table/res/templates/table.html +++ b/platform/features/table/res/templates/historical-table.html @@ -1,4 +1,4 @@ -
      +
      - +
      + + + + + + +
      {{header}}
      + {{sizingRow[header].text}} +
      + + }"> - +
      @@ -41,21 +42,15 @@
      {{ visibleRow.contents[header].text }} diff --git a/platform/features/table/res/templates/rt-table.html b/platform/features/table/res/templates/rt-table.html index 326c5b847b..d35015c96c 100644 --- a/platform/features/table/res/templates/rt-table.html +++ b/platform/features/table/res/templates/rt-table.html @@ -1,4 +1,4 @@ -
      +
      0){ + if (this.columns.length > 0) { self.addColumn(new NameColumn(), 0); } } @@ -93,7 +91,7 @@ define( * @returns {*|string} */ TableConfiguration.prototype.getColumnTitle = function (column) { - return column.getTitle(); + return column.getTitle(); }; /** @@ -102,7 +100,7 @@ define( */ TableConfiguration.prototype.getHeaders = function () { var self = this; - return this.columns.map(function (column, i){ + return this.columns.map(function (column, i) { return self.getColumnTitle(column) || 'Column ' + (i + 1); }); }; @@ -117,11 +115,11 @@ define( */ TableConfiguration.prototype.getRowValues = function (telemetryObject, datum) { var self = this; - return this.columns.reduce(function (rowObject, column, i){ + return this.columns.reduce(function (rowObject, column, i) { var columnTitle = self.getColumnTitle(column) || 'Column ' + (i + 1), columnValue = column.getValue(telemetryObject, datum); - if (columnValue !== undefined && columnValue.text === undefined){ + if (columnValue !== undefined && columnValue.text === undefined) { columnValue.text = ''; } // Don't replace something with nothing. @@ -140,8 +138,7 @@ define( * @private */ TableConfiguration.prototype.defaultColumnConfiguration = function () { - return ((this.domainObject.getModel().configuration || {}).table || - {}).columns || {}; + return ((this.domainObject.getModel().configuration || {}).table || {}).columns || {}; }; /** @@ -156,6 +153,16 @@ define( }); }; + function configChanged(config1, config2) { + var config1Keys = Object.keys(config1), + config2Keys = Object.keys(config2); + + return (config1Keys.length !== config2Keys.length) || + config1Keys.some(function (key) { + return config1[key] !== config2[key]; + }); + } + /** * As part of the process of building the table definition, extract * configuration from column definitions. @@ -163,7 +170,7 @@ define( * pairs where the key is the column title, and the value is a * boolean indicating whether the column should be shown. */ - TableConfiguration.prototype.getColumnConfiguration = function () { + TableConfiguration.prototype.buildColumnConfiguration = function () { var configuration = {}, //Use existing persisted config, or default it defaultConfig = this.defaultColumnConfiguration(); @@ -179,6 +186,11 @@ define( defaultConfig[columnTitle]; }); + //Synchronize column configuration with model + if (configChanged(configuration, defaultConfig)) { + this.saveColumnConfiguration(configuration); + } + return configuration; }; diff --git a/platform/features/table/src/controllers/HistoricalTableController.js b/platform/features/table/src/controllers/HistoricalTableController.js new file mode 100644 index 0000000000..69446f58f4 --- /dev/null +++ b/platform/features/table/src/controllers/HistoricalTableController.js @@ -0,0 +1,68 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ + +define( + [ + './TelemetryTableController' + ], + function (TableController) { + + /** + * Extends TelemetryTableController and adds real-time streaming + * support. + * @memberof platform/features/table + * @param $scope + * @param telemetryHandler + * @param telemetryFormatter + * @constructor + */ + function HistoricalTableController($scope, telemetryHandler, telemetryFormatter) { + TableController.call(this, $scope, telemetryHandler, telemetryFormatter); + } + + HistoricalTableController.prototype = Object.create(TableController.prototype); + + /** + * Populates historical data on scope when it becomes available from + * the telemetry API + */ + HistoricalTableController.prototype.addHistoricalData = function () { + var rowData = [], + self = this; + + this.handle.getTelemetryObjects().forEach(function (telemetryObject) { + var series = self.handle.getSeries(telemetryObject) || {}, + pointCount = series.getPointCount ? series.getPointCount() : 0, + i = 0; + + for (; i < pointCount; i++) { + rowData.push(self.table.getRowValues(telemetryObject, + self.handle.makeDatum(telemetryObject, series, i))); + } + }); + + this.$scope.rows = rowData; + }; + + return HistoricalTableController; + } +); diff --git a/platform/features/table/src/controllers/MCTTableController.js b/platform/features/table/src/controllers/MCTTableController.js index ad13647766..e4cfa45b23 100644 --- a/platform/features/table/src/controllers/MCTTableController.js +++ b/platform/features/table/src/controllers/MCTTableController.js @@ -1,9 +1,7 @@ -/*global define*/ define( [], function () { - "use strict"; /** * A controller for the MCTTable directive. Populates scope with @@ -23,23 +21,26 @@ define( this.maxDisplayRows = 50; this.scrollable = element.find('div'); + this.thead = element.find('thead'); + this.tbody = element.find('tbody'); + this.$scope.sizingRow = {}; + this.scrollable.on('scroll', this.onScroll.bind(this)); $scope.visibleRows = []; - $scope.overrideRowPositioning = false; /** * Set default values for optional parameters on a given scope */ - function setDefaults($scope) { - if (typeof $scope.enableFilter === 'undefined') { - $scope.enableFilter = true; - $scope.filters = {}; + function setDefaults(scope) { + if (typeof scope.enableFilter === 'undefined') { + scope.enableFilter = true; + scope.filters = {}; } - if (typeof $scope.enableSort === 'undefined') { - $scope.enableSort = true; - $scope.sortColumn = undefined; - $scope.sortDirection = undefined; + if (typeof scope.enableSort === 'undefined') { + scope.enableSort = true; + scope.sortColumn = undefined; + scope.sortDirection = undefined; } } @@ -58,22 +59,22 @@ define( $scope.sortColumn = undefined; $scope.sortDirection = undefined; } - self.updateRows($scope.rows); + self.setRows($scope.rows); }; /* * Define watches to listen for changes to headers and rows. */ $scope.$watchCollection('filters', function () { - self.updateRows($scope.rows); + self.setRows($scope.rows); }); - $scope.$watch('headers', this.updateHeaders.bind(this)); - $scope.$watch('rows', this.updateRows.bind(this)); + $scope.$watch('headers', this.setHeaders.bind(this)); + $scope.$watch('rows', this.setRows.bind(this)); /* * Listen for rows added individually (eg. for real-time tables) */ - $scope.$on('add:row', this.newRow.bind(this)); + $scope.$on('add:row', this.addRow.bind(this)); $scope.$on('remove:row', this.removeRow.bind(this)); } @@ -88,31 +89,35 @@ define( //Use timeout to defer execution until next digest when any // pending UI changes have completed, eg. a new row in the table. if (this.$scope.autoScroll) { - this.$timeout(function (){ - self.scrollable[0].scrollTop = self.scrollable[0].scrollHeight; + this.$timeout(function () { + self.scrollable[0].scrollTop = self.scrollable[0].scrollHeight; }); } }; /** * Handles a row add event. Rows can be added as needed using the - * `addRow` broadcast event. + * `add:row` broadcast event. * @private */ - MCTTableController.prototype.newRow = function (event, rowIndex) { + MCTTableController.prototype.addRow = function (event, rowIndex) { var row = this.$scope.rows[rowIndex]; - //Add row to the filtered, sorted list of all rows - if (this.filterRows([row]).length > 0) { - this.insertSorted(this.$scope.displayRows, row); - } - this.$timeout(this.setElementSizes.bind(this)) - .then(this.scrollToBottom.bind(this)); + //Does the row pass the current filter? + if (this.filterRows([row]).length === 1) { + //Insert the row into the correct position in the array + this.insertSorted(this.$scope.displayRows, row); + + //Resize the columns , then update the rows visible in the table + this.resize([this.$scope.sizingRow, row]) + .then(this.setVisibleRows.bind(this)) + .then(this.scrollToBottom.bind(this)); + } }; /** - * Handles a row add event. Rows can be added as needed using the - * `addRow` broadcast event. + * Handles a row remove event. Rows can be removed as needed using the + * `remove:row` broadcast event. * @private */ MCTTableController.prototype.removeRow = function (event, rowIndex) { @@ -120,10 +125,10 @@ define( // Do a sequential search here. Only way of finding row is by // object equality, so array is in effect unsorted. indexInDisplayRows = this.$scope.displayRows.indexOf(row); - if (indexInDisplayRows != -1) { - this.$scope.displayRows.splice(indexInDisplayRows, 1); - this.setVisibleRows(); - } + if (indexInDisplayRows !== -1) { + this.$scope.displayRows.splice(indexInDisplayRows, 1); + this.setVisibleRows(); + } }; /** @@ -160,17 +165,8 @@ define( //No need to scroll if (this.$scope.displayRows.length < this.maxDisplayRows) { - //Check whether need to resynchronize visible with display - // rows (if data added) - if (this.$scope.visibleRows.length != - this.$scope.displayRows.length){ - start = 0; - end = this.$scope.displayRows.length; - } else { - //Data is in sync, and no need to calculate scroll, - // so do nothing. - return; - } + start = 0; + end = this.$scope.displayRows.length; } else { //rows has exceeded display maximum, so may be necessary to // scroll @@ -225,8 +221,8 @@ define( * enabled, reset filters. If sorting is enabled, reset * sorting. */ - MCTTableController.prototype.updateHeaders = function (newHeaders) { - if (!newHeaders){ + MCTTableController.prototype.setHeaders = function (newHeaders) { + if (!newHeaders) { return; } @@ -238,10 +234,10 @@ define( // contain the column currently sorted on. if (this.$scope.enableSort && newHeaders.indexOf(this.$scope.sortColumn) === -1) { - this.$scope.sortColumn = undefined; - this.$scope.sortDirection = undefined; + this.$scope.sortColumn = undefined; + this.$scope.sortDirection = undefined; } - this.updateRows(this.$scope.rows); + this.setRows(this.$scope.rows); }; /** @@ -249,13 +245,12 @@ define( * for individual rows. */ MCTTableController.prototype.setElementSizes = function () { - var self = this, - thead = this.element.find('thead'), - tbody = this.element.find('tbody'), + var thead = this.thead, + tbody = this.tbody, firstRow = tbody.find('tr'), column = firstRow.find('td'), headerHeight = thead.prop('offsetHeight'), - rowHeight = 20, + rowHeight = firstRow.prop('offsetHeight'), columnWidth, tableWidth = 0, overallHeight = headerHeight + (rowHeight * @@ -272,15 +267,12 @@ define( this.$scope.headerHeight = headerHeight; this.$scope.rowHeight = rowHeight; this.$scope.totalHeight = overallHeight; - this.setVisibleRows(); if (tableWidth > 0) { this.$scope.totalWidth = tableWidth + 'px'; } else { this.$scope.totalWidth = 'none'; } - - this.$scope.overrideRowPositioning = true; }; /** @@ -291,22 +283,15 @@ define( self = this, sortKey = this.$scope.sortColumn; - function binarySearch(searchArray, searchElement, min, max){ - var sampleAt = Math.floor((max - min) / 2) + min, - valA, - valB; + function binarySearch(searchArray, searchElement, min, max) { + var sampleAt = Math.floor((max - min) / 2) + min; + if (max < min) { return min; // Element is not in array, min gives direction } - valA = isNaN(searchElement[sortKey].text) ? - searchElement[sortKey].text : - parseFloat(searchElement[sortKey].text); - valB = isNaN(searchArray[sampleAt][sortKey].text) ? - searchArray[sampleAt][sortKey].text : - parseFloat(searchArray[sampleAt][sortKey].text); - - switch(self.sortComparator(valA, valB)) { + switch (self.sortComparator(searchElement[sortKey].text, + searchArray[sampleAt][sortKey].text)) { case -1: return binarySearch(searchArray, searchElement, min, sampleAt - 1); @@ -325,9 +310,9 @@ define( //Sort is enabled, perform binary search to find insertion point index = binarySearch(array, element, 0, array.length - 1); } - if (index === -1){ + if (index === -1) { array.unshift(element); - } else if (index === array.length){ + } else if (index === array.length) { array.push(element); } else { array.splice(index, 0, element); @@ -344,8 +329,34 @@ define( */ MCTTableController.prototype.sortComparator = function (a, b) { var result = 0, - sortDirectionMultiplier; + sortDirectionMultiplier, + numberA, + numberB; + /** + * Given a value, if it is a number, or a string representation of a + * number, then return a number representation. Otherwise, return + * the original value. It's a little more robust than using just + * Number() or parseFloat, or isNaN in isolation, all of which are + * fairly inconsistent in their results. + * @param value The value to return as a number. + * @returns {*} The value cast to a Number, or the original value if + * a Number representation is not possible. + */ + function toNumber(value) { + var val = !isNaN(Number(value)) && !isNaN(parseFloat(value)) ? Number(value) : value; + return val; + } + numberA = toNumber(a); + numberB = toNumber(b); + + //If they're both numbers, then compare them as numbers + if (typeof numberA === "number" && typeof numberB === "number") { + a = numberA; + b = numberB; + } + + //If they're both strings, then ignore case if (typeof a === "string" && typeof b === "string") { a = a.toLowerCase(); b = b.toLowerCase(); @@ -382,15 +393,7 @@ define( } return rowsToSort.sort(function (a, b) { - //If the values to compare can be compared as - // numbers, do so. String comparison of number - // values can cause inconsistencies - var valA = isNaN(a[sortKey].text) ? a[sortKey].text : - parseFloat(a[sortKey].text), - valB = isNaN(b[sortKey].text) ? b[sortKey].text : - parseFloat(b[sortKey].text); - - return self.sortComparator(valA, valB); + return self.sortComparator(a[sortKey].text, b[sortKey].text); }); }; @@ -400,74 +403,48 @@ define( * pre-calculate optimal column sizes without having to render * every row. */ - MCTTableController.prototype.findLargestRow = function (rows) { - var largestRow = rows.reduce(function (largestRow, row) { + MCTTableController.prototype.buildLargestRow = function (rows) { + var largestRow = rows.reduce(function (prevLargest, row) { Object.keys(row).forEach(function (key) { - var currentColumn = row[key].text, + var currentColumn, + currentColumnLength, + largestColumn, + largestColumnLength; + if (row[key]) { + currentColumn = (row[key]).text; currentColumnLength = (currentColumn && currentColumn.length) ? currentColumn.length : - currentColumn, - largestColumn = largestRow[key].text, - largestColumnLength = - (largestColumn && largestColumn.length) ? - largestColumn.length : - largestColumn; + currentColumn; + largestColumn = prevLargest[key] ? prevLargest[key].text : ""; + largestColumnLength = largestColumn.length; - if (currentColumnLength > largestColumnLength) { - largestRow[key] = JSON.parse(JSON.stringify(row[key])); + if (currentColumnLength > largestColumnLength) { + prevLargest[key] = JSON.parse(JSON.stringify(row[key])); + } } }); - return largestRow; + return prevLargest; }, JSON.parse(JSON.stringify(rows[0] || {}))); - - largestRow = JSON.parse(JSON.stringify(largestRow)); - - // Pad with characters to accomodate variable-width fonts, - // and remove characters that would allow word-wrapping. - Object.keys(largestRow).forEach(function (key) { - var padCharacters, - i; - - largestRow[key].text = String(largestRow[key].text); - padCharacters = largestRow[key].text.length / 10; - for (i = 0; i < padCharacters; i++) { - largestRow[key].text = largestRow[key].text + 'W'; - } - largestRow[key].text = largestRow[key].text - .replace(/[ \-_]/g, 'W'); - }); return largestRow; }; /** - * Calculates the widest row in the table, pads that row, and adds - * it to the table. Allows the table to size itself, then uses this - * as basis for column dimensions. + * Calculates the widest row in the table, and if necessary, resizes + * the table accordingly + * + * @param rows the rows on which to resize + * @returns {Promise} a promise that will resolve when resizing has + * occurred. * @private */ - MCTTableController.prototype.resize = function (){ - var largestRow = this.findLargestRow(this.$scope.displayRows), - self = this; - this.$scope.visibleRows = [ - { - rowIndex: 0, - offsetY: undefined, - contents: largestRow - } - ]; - - //Wait a timeout to allow digest of previous change to visible - // rows to happen. - this.$timeout(function () { - //Remove temporary padding row used for setting column widths - self.$scope.visibleRows = []; - self.setElementSizes(); - }); + MCTTableController.prototype.resize = function (rows) { + this.$scope.sizingRow = this.buildLargestRow(rows); + return this.$timeout(this.setElementSizes.bind(this)); }; /** - * @priate + * @private */ MCTTableController.prototype.filterAndSort = function (rows) { var displayRows = rows; @@ -478,26 +455,21 @@ define( if (this.$scope.enableSort) { displayRows = this.sortRows(displayRows.slice(0)); } - this.$scope.displayRows = displayRows; + return displayRows; }; /** * Update rows with new data. If filtering is enabled, rows * will be sorted before display. */ - MCTTableController.prototype.updateRows = function (newRows) { - //Reset visible rows because new row data available. - this.$scope.visibleRows = []; - - this.$scope.overrideRowPositioning = false; - + MCTTableController.prototype.setRows = function (newRows) { //Nothing to show because no columns visible - if (!this.$scope.displayHeaders) { + if (!this.$scope.displayHeaders || !newRows) { return; } - this.filterAndSort(newRows || []); - this.resize(); + this.$scope.displayRows = this.filterAndSort(newRows || []); + this.resize(newRows).then(this.setVisibleRows.bind(this)); }; /** @@ -513,13 +485,13 @@ define( /** * Returns true if row matches all filters. */ - function matchRow(filters, row) { - return Object.keys(filters).every(function (key) { + function matchRow(filterMap, row) { + return Object.keys(filterMap).every(function (key) { if (!row[key]) { return false; } var testVal = String(row[key].text).toLowerCase(); - return testVal.indexOf(filters[key]) !== -1; + return testVal.indexOf(filterMap[key]) !== -1; }); } diff --git a/platform/features/table/src/controllers/RTTelemetryTableController.js b/platform/features/table/src/controllers/RealtimeTableController.js similarity index 58% rename from platform/features/table/src/controllers/RTTelemetryTableController.js rename to platform/features/table/src/controllers/RealtimeTableController.js index 8a61d61b5e..d9a3efd559 100644 --- a/platform/features/table/src/controllers/RTTelemetryTableController.js +++ b/platform/features/table/src/controllers/RealtimeTableController.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [ './TelemetryTableController' ], function (TableController) { - "use strict"; /** * Extends TelemetryTableController and adds real-time streaming @@ -37,7 +35,7 @@ define( * @param telemetryFormatter * @constructor */ - function RTTelemetryTableController($scope, telemetryHandler, telemetryFormatter) { + function RealtimeTableController($scope, telemetryHandler, telemetryFormatter) { TableController.call(this, $scope, telemetryHandler, telemetryFormatter); $scope.autoScroll = false; @@ -60,64 +58,41 @@ define( $scope.$watch('domainObject', function (domainObject) { //When a domain object becomes available, check whether the // view should auto-scroll to the bottom. - if (domainObject && hasStringTelemetry(domainObject)){ + if (domainObject && hasStringTelemetry(domainObject)) { $scope.autoScroll = true; } }); } - RTTelemetryTableController.prototype = Object.create(TableController.prototype); + RealtimeTableController.prototype = Object.create(TableController.prototype); /** - Override the subscribe function defined on the parent controller in - order to handle realtime telemetry instead of historical. + * Overrides method on TelemetryTableController providing handling + * for realtime data. */ - RTTelemetryTableController.prototype.subscribe = function () { - var self = this; - self.$scope.rows = undefined; - (this.subscriptions || []).forEach(function (unsubscribe){ - unsubscribe(); - }); + RealtimeTableController.prototype.addRealtimeData = function () { + var self = this, + datum, + row; + this.handle.getTelemetryObjects().forEach(function (telemetryObject) { + datum = self.handle.getDatum(telemetryObject); + if (datum) { + //Populate row values from telemetry datum + row = self.table.getRowValues(telemetryObject, datum); + self.$scope.rows.push(row); - if (this.handle) { - this.handle.unsubscribe(); - } - - function updateData(){ - var datum, - row; - self.handle.getTelemetryObjects().forEach(function (telemetryObject){ - datum = self.handle.getDatum(telemetryObject); - if (datum) { - row = self.table.getRowValues(telemetryObject, datum); - if (!self.$scope.rows){ - self.$scope.rows = [row]; - self.$scope.$digest(); - } else { - self.$scope.rows.push(row); - - if (self.$scope.rows.length > self.maxRows) { - self.$scope.$broadcast('remove:row', 0); - self.$scope.rows.shift(); - } - - self.$scope.$broadcast('add:row', - self.$scope.rows.length - 1); - } + //Inform table that a new row has been added + if (self.$scope.rows.length > self.maxRows) { + self.$scope.$broadcast('remove:row', 0); + self.$scope.rows.shift(); } - }); - } - - this.handle = this.$scope.domainObject && this.telemetryHandler.handle( - this.$scope.domainObject, - updateData, - true // Lossless - ); - - this.setup(); + self.$scope.$broadcast('add:row', + self.$scope.rows.length - 1); + } + }); }; - return RTTelemetryTableController; + return RealtimeTableController; } ); diff --git a/platform/features/table/src/controllers/TableOptionsController.js b/platform/features/table/src/controllers/TableOptionsController.js index c3b479073c..0ca83b088c 100644 --- a/platform/features/table/src/controllers/TableOptionsController.js +++ b/platform/features/table/src/controllers/TableOptionsController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Notes on implementation of plot options @@ -51,42 +49,63 @@ define( this.$scope = $scope; this.domainObject = $scope.domainObject; + this.listeners = []; $scope.columnsForm = {}; - this.domainObject.getCapability('mutation').listen(function (model) { - self.populateForm(model); + function unlisten() { + self.listeners.forEach(function (listener) { + listener(); + }); + } + + $scope.$watch('domainObject', function (domainObject) { + unlisten(); + self.populateForm(domainObject.getModel()); + + self.listeners.push(self.domainObject.getCapability('mutation').listen(function (model) { + self.populateForm(model); + })); }); - $scope.$watchCollection('configuration.table.columns', function (columns){ - if (columns){ + /** + * Maintain a configuration object on scope that stores column + * configuration. On change, synchronize with object model. + */ + $scope.$watchCollection('configuration.table.columns', function (columns) { + if (columns) { self.domainObject.useCapability('mutation', function (model) { - model.configuration.table.columns = columns; + model.configuration.table.columns = columns; }); self.domainObject.getCapability('persistence').persist(); } }); + /** + * Destroy all mutation listeners + */ + $scope.$on('$destroy', unlisten); + } TableOptionsController.prototype.populateForm = function (model) { var columnsDefinition = (((model.configuration || {}).table || {}).columns || {}), rows = []; this.$scope.columnsForm = { - 'name':'Columns', + 'name': 'Columns', 'sections': [{ 'name': 'Columns', 'rows': rows }]}; - Object.keys(columnsDefinition).forEach(function (key){ + Object.keys(columnsDefinition).forEach(function (key) { rows.push({ 'name': key, 'control': 'checkbox', 'key': key }); }); - this.$scope.configuration = JSON.parse(JSON.stringify(model.configuration)); + this.$scope.configuration = JSON.parse(JSON.stringify(model.configuration || {})); }; return TableOptionsController; diff --git a/platform/features/table/src/controllers/TelemetryTableController.js b/platform/features/table/src/controllers/TelemetryTableController.js index e579c5eeb8..3f4e69db12 100644 --- a/platform/features/table/src/controllers/TelemetryTableController.js +++ b/platform/features/table/src/controllers/TelemetryTableController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle adds a table view for displaying telemetry data. @@ -30,7 +29,6 @@ define( '../TableConfiguration' ], function (TableConfiguration) { - "use strict"; /** * The TableController is responsible for getting data onto the page @@ -52,19 +50,15 @@ define( this.$scope = $scope; this.columns = {}; //Range and Domain columns this.handle = undefined; - //this.pending = false; this.telemetryHandler = telemetryHandler; this.table = new TableConfiguration($scope.domainObject, telemetryFormatter); this.changeListeners = []; - $scope.rows = undefined; + $scope.rows = []; // Subscribe to telemetry when a domain object becomes available - this.$scope.$watch('domainObject', function(domainObject){ - if (!domainObject) - return; - + this.$scope.$watch('domainObject', function () { self.subscribe(); self.registerChangeListeners(); }); @@ -73,16 +67,24 @@ define( this.$scope.$on("$destroy", this.destroy.bind(this)); } + /** + * @private + */ + TelemetryTableController.prototype.unregisterChangeListeners = function () { + this.changeListeners.forEach(function (listener) { + return listener && listener(); + }); + this.changeListeners = []; + }; + /** * Defer registration of change listeners until domain object is * available in order to avoid race conditions * @private */ TelemetryTableController.prototype.registerChangeListeners = function () { - this.changeListeners.forEach(function (listener) { - return listener && listener(); - }); - this.changeListeners = []; + this.unregisterChangeListeners(); + // When composition changes, re-subscribe to the various // telemetry subscriptions this.changeListeners.push(this.$scope.$watchCollection( @@ -103,25 +105,37 @@ define( } }; + /** + * Function for handling realtime data when it is available. This + * will be called by the telemetry framework when new data is + * available. + * + * Method should be overridden by specializing class. + */ + TelemetryTableController.prototype.addRealtimeData = function () { + }; + + /** + * Function for handling historical data. Will be called by + * telemetry framework when requested historical data is available. + * Should be overridden by specializing class. + */ + TelemetryTableController.prototype.addHistoricalData = function () { + }; + /** Create a new subscription. This can be overridden by children to change default behaviour (which is to retrieve historical telemetry only). */ TelemetryTableController.prototype.subscribe = function () { - var self = this; - if (this.handle) { this.handle.unsubscribe(); } - //Noop because not supporting realtime data right now - function noop(){ - } - this.handle = this.$scope.domainObject && this.telemetryHandler.handle( this.$scope.domainObject, - noop, + this.addRealtimeData.bind(this), true // Lossless ); @@ -130,28 +144,6 @@ define( this.setup(); }; - /** - * Populates historical data on scope when it becomes available - * @private - */ - TelemetryTableController.prototype.addHistoricalData = function () { - var rowData = [], - self = this; - - this.handle.getTelemetryObjects().forEach(function (telemetryObject){ - var series = self.handle.getSeries(telemetryObject) || {}, - pointCount = series.getPointCount ? series.getPointCount() : 0, - i = 0; - - for (; i < pointCount; i++) { - rowData.push(self.table.getRowValues(telemetryObject, - self.handle.makeDatum(telemetryObject, series, i))); - } - }); - - this.$scope.rows = rowData; - }; - /** * Setup table columns based on domain object metadata */ @@ -162,7 +154,9 @@ define( if (handle) { handle.promiseTelemetryObjects().then(function () { - table.buildColumns(handle.getMetadata()); + self.$scope.headers = []; + self.$scope.rows = []; + table.populateColumns(handle.getMetadata()); self.filterColumns(); @@ -176,26 +170,14 @@ define( } }; - /** - * @private - * @param object The object for which data is available (table may - * be composed of multiple objects) - * @param datum The data received from the telemetry source - */ - TelemetryTableController.prototype.updateRows = function (object, datum) { - this.$scope.rows.push(this.table.getRowValues(object, datum)); - }; - /** * When column configuration changes, update the visible headers * accordingly. * @private */ - TelemetryTableController.prototype.filterColumns = function (columnConfig) { - if (!columnConfig){ - columnConfig = this.table.getColumnConfiguration(); - this.table.saveColumnConfiguration(columnConfig); - } + TelemetryTableController.prototype.filterColumns = function () { + var columnConfig = this.table.buildColumnConfiguration(); + //Populate headers with visible columns (determined by configuration) this.$scope.headers = Object.keys(columnConfig).filter(function (column) { return columnConfig[column]; diff --git a/platform/features/table/src/directives/MCTTable.js b/platform/features/table/src/directives/MCTTable.js index 575e830395..5dd8f9f03f 100644 --- a/platform/features/table/src/directives/MCTTable.js +++ b/platform/features/table/src/directives/MCTTable.js @@ -1,4 +1,24 @@ -/*global define*/ +/***************************************************************************** + * 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. + *****************************************************************************/ define( [ @@ -6,12 +26,55 @@ define( "text!../../res/templates/mct-table.html" ], function (MCTTableController, TableTemplate) { - "use strict"; - /** * Defines a generic 'Table' component. The table can be populated * en-masse by setting the rows attribute, or rows can be added as * needed via a broadcast 'addRow' event. + * + * This directive accepts parameters specifying header and row + * content, as well as some additional options. + * + * Two broadcast events for notifying the table that the rows have + * changed. For performance reasons, the table does not monitor the + * content of `rows` constantly. + * - 'add:row': A $broadcast event that will notify the table that + * a new row has been added to the table. + * eg. + *
      
      +         * $scope.rows.push(newRow);
      +         * $scope.$broadcast('add:row', $scope.rows.length-1);
      +         * 
      + * The code above adds a new row, and alerts the table using the + * add:row event. Sorting and filtering will be applied + * automatically by the table component. + * + * - 'remove:row': A $broadcast event that will notify the table that a + * row should be removed from the table. + * eg. + *
      
      +         * $scope.rows.slice(5, 1);
      +         * $scope.$broadcast('remove:row', 5);
      +         * 
      + * The code above removes a row from the rows array, and then alerts + * the table to its removal. + * + * @memberof platform/features/table + * @param {string[]} headers The column titles to appear at the top + * of the table. Corresponding values are specified in the rows + * using the header title provided here. + * @param {Object[]} rows The row content. Each row is an object + * with key-value pairs where the key corresponds to a header + * specified in the headers parameter. + * @param {boolean} enableFilter If true, values will be searchable + * and results filtered + * @param {boolean} enableSort If true, sorting will be enabled + * allowing sorting by clicking on column headers + * @param {boolean} autoScroll If true, table will automatically + * scroll to the bottom as new data arrives. Auto-scroll can be + * disengaged manually by scrolling away from the bottom of the + * table, and can also be enabled manually by scrolling to the bottom of + * the table rows. + * * @constructor */ function MCTTable($timeout) { @@ -25,7 +88,7 @@ define( enableFilter: "=?", enableSort: "=?", autoScroll: "=?" - }, + } }; } diff --git a/platform/features/table/test/DomainColumnSpec.js b/platform/features/table/test/DomainColumnSpec.js index bb15f9d55e..e707c8dd0b 100644 --- a/platform/features/table/test/DomainColumnSpec.js +++ b/platform/features/table/test/DomainColumnSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,xit*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/DomainColumn"], function (DomainColumn) { - "use strict"; var TEST_DOMAIN_VALUE = "some formatted domain value"; @@ -40,11 +38,11 @@ define( beforeEach(function () { mockDataSet = jasmine.createSpyObj( "data", - [ "getDomainValue" ] + ["getDomainValue"] ); mockFormatter = jasmine.createSpyObj( "formatter", - [ "formatDomainValue", "formatRangeValue" ] + ["formatDomainValue", "formatRangeValue"] ); testMetadata = { key: "testKey", diff --git a/platform/features/table/test/NameColumnSpec.js b/platform/features/table/test/NameColumnSpec.js index 355ebef545..d381758330 100644 --- a/platform/features/table/test/NameColumnSpec.js +++ b/platform/features/table/test/NameColumnSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/NameColumn"], function (NameColumn) { - "use strict"; describe("A name column", function () { var mockDomainObject, @@ -36,7 +34,7 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getModel" ] + ["getModel"] ); mockDomainObject.getModel.andReturn({ name: "Test object name" diff --git a/platform/features/table/test/RangeColumnSpec.js b/platform/features/table/test/RangeColumnSpec.js index b77245bb82..45383fcdf7 100644 --- a/platform/features/table/test/RangeColumnSpec.js +++ b/platform/features/table/test/RangeColumnSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,xit*/ /** * MergeModelsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/RangeColumn"], function (RangeColumn) { - "use strict"; var TEST_RANGE_VALUE = "some formatted range value"; @@ -42,7 +40,7 @@ define( testDatum = { testKey: 123, otherKey: 456 }; mockFormatter = jasmine.createSpyObj( "formatter", - [ "formatDomainValue", "formatRangeValue" ] + ["formatDomainValue", "formatRangeValue"] ); testMetadata = { key: "testKey", @@ -50,7 +48,7 @@ define( }; mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getModel", "getCapability" ] + ["getModel", "getCapability"] ); mockFormatter.formatRangeValue.andReturn(TEST_RANGE_VALUE); diff --git a/platform/features/table/test/TableConfigurationSpec.js b/platform/features/table/test/TableConfigurationSpec.js index 86a18aee5a..2f59fb173f 100644 --- a/platform/features/table/test/TableConfigurationSpec.js +++ b/platform/features/table/test/TableConfigurationSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,xit*/ define( [ @@ -27,7 +26,6 @@ define( "../src/DomainColumn" ], function (Table, DomainColumn) { - "use strict"; describe("A table", function () { var mockDomainObject, @@ -46,10 +44,10 @@ define( 'formatDomainValue', 'formatRangeValue' ]); - mockTelemetryFormatter.formatDomainValue.andCallFake(function(valueIn){ + mockTelemetryFormatter.formatDomainValue.andCallFake(function (valueIn) { return valueIn; }); - mockTelemetryFormatter.formatRangeValue.andCallFake(function(valueIn){ + mockTelemetryFormatter.formatRangeValue.andCallFake(function (valueIn) { return valueIn; }); @@ -89,7 +87,7 @@ define( expect(table.columns[2]).toBe(thirdColumn); }); - describe("Building columns from telemetry metadata", function() { + describe("Building columns from telemetry metadata", function () { var metadata = [{ ranges: [ { @@ -115,21 +113,21 @@ define( ] }]; - beforeEach(function() { - table.buildColumns(metadata); + beforeEach(function () { + table.populateColumns(metadata); }); - it("populates the columns attribute", function() { + it("populates columns", function () { expect(table.columns.length).toBe(5); }); - it("Build columns populates columns with domains to the left", function() { + it("Build columns populates columns with domains to the left", function () { expect(table.columns[1] instanceof DomainColumn).toBeTruthy(); expect(table.columns[2] instanceof DomainColumn).toBeTruthy(); expect(table.columns[3] instanceof DomainColumn).toBeFalsy(); }); - it("Produces headers for each column based on title", function() { + it("Produces headers for each column based on title", function () { var headers, firstColumn = table.columns[0]; @@ -140,16 +138,16 @@ define( }); it("Provides a default configuration with all columns" + - " visible", function() { - var configuration = table.getColumnConfiguration(); + " visible", function () { + var configuration = table.buildColumnConfiguration(); expect(configuration).toBeDefined(); - expect(Object.keys(configuration).every(function(key){ + expect(Object.keys(configuration).every(function (key) { return configuration[key]; })); }); - it("Column configuration exposes persisted configuration", function() { + it("Column configuration exposes persisted configuration", function () { var tableConfig, modelConfig = { table: { @@ -160,7 +158,7 @@ define( }; mockModel.configuration = modelConfig; - tableConfig = table.getColumnConfiguration(); + tableConfig = table.buildColumnConfiguration(); expect(tableConfig).toBeDefined(); expect(tableConfig['Range 1']).toBe(false); @@ -170,7 +168,7 @@ define( var datum, rowValues; - beforeEach(function() { + beforeEach(function () { datum = { 'range1': 'range 1 value', 'range2': 'range 2 value', @@ -180,14 +178,14 @@ define( rowValues = table.getRowValues(mockDomainObject, datum); }); - it("Returns a value for every column", function() { + it("Returns a value for every column", function () { expect(rowValues['Range 1'].text).toBeDefined(); expect(rowValues['Range 1'].text).toEqual('range 1' + ' value'); }); it("Uses the telemetry formatter to appropriately format" + - " telemetry values", function() { + " telemetry values", function () { expect(mockTelemetryFormatter.formatRangeValue).toHaveBeenCalled(); }); }); diff --git a/platform/features/table/test/controllers/TelemetryTableControllerSpec.js b/platform/features/table/test/controllers/HistoricalTableControllerSpec.js similarity index 88% rename from platform/features/table/test/controllers/TelemetryTableControllerSpec.js rename to platform/features/table/test/controllers/HistoricalTableControllerSpec.js index 03f62f11e3..54c213d5a6 100644 --- a/platform/features/table/test/controllers/TelemetryTableControllerSpec.js +++ b/platform/features/table/test/controllers/HistoricalTableControllerSpec.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,xit*/ define( [ - "../../src/controllers/TelemetryTableController" + "../../src/controllers/HistoricalTableController" ], function (TableController) { - "use strict"; describe('The Table Controller', function () { var mockScope, @@ -41,7 +39,7 @@ define( function promise(value) { return { - then: function (callback){ + then: function (callback) { return promise(callback(value)); } }; @@ -55,13 +53,13 @@ define( '$watchCollection' ]); - mockScope.$on.andCallFake(function (expression, callback){ + mockScope.$on.andCallFake(function (expression, callback) { watches[expression] = callback; }); - mockScope.$watch.andCallFake(function (expression, callback){ - watches[expression] = callback; + mockScope.$watch.andCallFake(function (expression, callback) { + watches[expression] = callback; }); - mockScope.$watchCollection.andCallFake(function (expression, callback){ + mockScope.$watchCollection.andCallFake(function (expression, callback) { watches[expression] = callback; }); @@ -73,16 +71,16 @@ define( mockTable = jasmine.createSpyObj('table', [ - 'buildColumns', - 'getColumnConfiguration', + 'populateColumns', + 'buildColumnConfiguration', 'getRowValues', 'saveColumnConfiguration' ] ); mockTable.columns = []; - mockTable.getColumnConfiguration.andReturn(mockConfiguration); + mockTable.buildColumnConfiguration.andReturn(mockConfiguration); - mockDomainObject= jasmine.createSpyObj('domainObject', [ + mockDomainObject = jasmine.createSpyObj('domainObject', [ 'getCapability', 'useCapability', 'getModel' @@ -120,31 +118,28 @@ define( expect(mockTelemetryHandle.request).toHaveBeenCalled(); }); - it('Unsubscribes from telemetry when scope is destroyed',function () { + it('Unsubscribes from telemetry when scope is destroyed', function () { controller.handle = mockTelemetryHandle; watches.$destroy(); expect(mockTelemetryHandle.unsubscribe).toHaveBeenCalled(); }); - describe('the controller makes use of the table', function () { + describe('makes use of the table', function () { it('to create column definitions from telemetry' + ' metadata', function () { controller.setup(); - expect(mockTable.buildColumns).toHaveBeenCalled(); + expect(mockTable.populateColumns).toHaveBeenCalled(); }); it('to create column configuration, which is written to the' + ' object model', function () { - var mockModel = {}; - controller.setup(); - expect(mockTable.getColumnConfiguration).toHaveBeenCalled(); - expect(mockTable.saveColumnConfiguration).toHaveBeenCalled(); + expect(mockTable.buildColumnConfiguration).toHaveBeenCalled(); }); }); - it('updates the rows on scope when historical telemetry is received', function (){ + it('updates the rows on scope when historical telemetry is received', function () { var mockSeries = { getPointCount: function () { return 5; @@ -159,7 +154,7 @@ define( mockRow = {'domain': 'Domain Value', 'range': 'Range' + ' Value'}; - mockTelemetryHandle.makeDatum.andCallFake(function (){ + mockTelemetryHandle.makeDatum.andCallFake(function () { return mockRow; }); mockTable.getRowValues.andReturn(mockRow); @@ -172,7 +167,7 @@ define( expect(controller.$scope.rows[0]).toBe(mockRow); }); - it('filters the visible columns based on configuration', function (){ + it('filters the visible columns based on configuration', function () { controller.filterColumns(); expect(controller.$scope.headers.length).toBe(3); expect(controller.$scope.headers[2]).toEqual('domain1'); @@ -183,9 +178,9 @@ define( expect(controller.$scope.headers[2]).toBeUndefined(); }); - describe('creates event listeners', function (){ + describe('creates event listeners', function () { beforeEach(function () { - spyOn(controller,'subscribe'); + spyOn(controller, 'subscribe'); spyOn(controller, 'filterColumns'); }); diff --git a/platform/features/table/test/controllers/MCTTableControllerSpec.js b/platform/features/table/test/controllers/MCTTableControllerSpec.js index 5e38c7e651..26578ba244 100644 --- a/platform/features/table/test/controllers/MCTTableControllerSpec.js +++ b/platform/features/table/test/controllers/MCTTableControllerSpec.js @@ -19,16 +19,14 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,xit*/ define( [ "../../src/controllers/MCTTableController" ], function (MCTTableController) { - "use strict"; - describe('The MCTTable Controller', function() { + describe('The MCTTable Controller', function () { var controller, mockScope, @@ -38,13 +36,13 @@ define( function promise(value) { return { - then: function (callback){ + then: function (callback) { return promise(callback(value)); } }; } - beforeEach(function() { + beforeEach(function () { watches = {}; mockScope = jasmine.createSpyObj('scope', [ @@ -52,32 +50,40 @@ define( '$on', '$watchCollection' ]); - mockScope.$watchCollection.andCallFake(function(event, callback) { + mockScope.$watchCollection.andCallFake(function (event, callback) { watches[event] = callback; }); mockElement = jasmine.createSpyObj('element', [ 'find', + 'prop', 'on' ]); mockElement.find.andReturn(mockElement); + mockElement.prop.andReturn(0); + mockElement[0] = { + scrollTop: 0, + scrollHeight: 500, + offsetHeight: 1000 + }; mockScope.displayHeaders = true; mockTimeout = jasmine.createSpy('$timeout'); mockTimeout.andReturn(promise(undefined)); controller = new MCTTableController(mockScope, mockTimeout, mockElement); + spyOn(controller, 'setVisibleRows').andCallThrough(); }); - it('Reacts to changes to filters, headers, and rows', function() { + it('Reacts to changes to filters, headers, and rows', function () { expect(mockScope.$watchCollection).toHaveBeenCalledWith('filters', jasmine.any(Function)); expect(mockScope.$watch).toHaveBeenCalledWith('headers', jasmine.any(Function)); expect(mockScope.$watch).toHaveBeenCalledWith('rows', jasmine.any(Function)); }); - describe('rows', function() { + describe('rows', function () { var testRows = []; - beforeEach(function() { + beforeEach(function () { testRows = [ { 'col1': {'text': 'row1 col1 match'}, @@ -98,57 +104,55 @@ define( mockScope.rows = testRows; }); - it('Filters results based on filter input', function() { - var filters = {}, - filteredRows; + it('Filters results based on filter input', function () { + var filters = {}, + filteredRows; - mockScope.filters = filters; + mockScope.filters = filters; - filteredRows = controller.filterRows(testRows); - expect(filteredRows.length).toBe(3); - filters.col1 = 'row1'; - filteredRows = controller.filterRows(testRows); - expect(filteredRows.length).toBe(1); - filters.col1 = 'match'; - filteredRows = controller.filterRows(testRows); - expect(filteredRows.length).toBe(2); + filteredRows = controller.filterRows(testRows); + expect(filteredRows.length).toBe(3); + filters.col1 = 'row1'; + filteredRows = controller.filterRows(testRows); + expect(filteredRows.length).toBe(1); + filters.col1 = 'match'; + filteredRows = controller.filterRows(testRows); + expect(filteredRows.length).toBe(2); }); - it('Sets rows on scope when rows change', function() { - controller.updateRows(testRows); + it('Sets rows on scope when rows change', function () { + controller.setRows(testRows); expect(mockScope.displayRows.length).toBe(3); expect(mockScope.displayRows).toEqual(testRows); }); - it('Supports adding rows individually', function() { - var addRowFunc = mockScope.$on.calls[mockScope.$on.calls.length-2].args[1], + it('Supports adding rows individually', function () { + var addRowFunc = mockScope.$on.calls[mockScope.$on.calls.length - 2].args[1], row4 = { 'col1': {'text': 'row3 col1'}, 'col2': {'text': 'ghi'}, 'col3': {'text': 'row3 col3'} }; - controller.updateRows(testRows); + controller.setRows(testRows); expect(mockScope.displayRows.length).toBe(3); testRows.push(row4); addRowFunc(undefined, 3); expect(mockScope.displayRows.length).toBe(4); }); - it('Supports removing rows individually', function() { - var removeRowFunc = mockScope.$on.calls[mockScope.$on.calls.length-1].args[1]; - controller.updateRows(testRows); + it('Supports removing rows individually', function () { + var removeRowFunc = mockScope.$on.calls[mockScope.$on.calls.length - 1].args[1]; + controller.setRows(testRows); expect(mockScope.displayRows.length).toBe(3); - spyOn(controller, 'setVisibleRows'); - //controller.setVisibleRows.andReturn(undefined); removeRowFunc(undefined, 2); expect(mockScope.displayRows.length).toBe(2); expect(controller.setVisibleRows).toHaveBeenCalled(); }); - describe('sorting', function() { + describe('sorting', function () { var sortedRows; - it('Sorts rows ascending', function() { + it('Sorts rows ascending', function () { mockScope.sortColumn = 'col1'; mockScope.sortDirection = 'asc'; @@ -160,7 +164,7 @@ define( }); - it('Sorts rows descending', function() { + it('Sorts rows descending', function () { mockScope.sortColumn = 'col1'; mockScope.sortDirection = 'desc'; @@ -169,7 +173,7 @@ define( expect(sortedRows[1].col1.text).toEqual('row2 col1 match'); expect(sortedRows[2].col1.text).toEqual('row1 col1 match'); }); - it('Sorts rows descending based on selected sort column', function() { + it('Sorts rows descending based on selected sort column', function () { mockScope.sortColumn = 'col2'; mockScope.sortDirection = 'desc'; @@ -179,12 +183,69 @@ define( expect(sortedRows[2].col2.text).toEqual('abc'); }); - describe('Adding new rows', function() { + // https://github.com/nasa/openmct/issues/910 + it('updates visible rows in scope', function () { + var oldRows; + mockScope.rows = testRows; + controller.setRows(testRows); + oldRows = mockScope.visibleRows; + mockScope.toggleSort('col2'); + expect(mockScope.visibleRows).not.toEqual(oldRows); + }); + + it('correctly sorts rows of differing types', function () { + mockScope.sortColumn = 'col2'; + mockScope.sortDirection = 'desc'; + + testRows.push({ + 'col1': {'text': 'row4 col1'}, + 'col2': {'text': '123'}, + 'col3': {'text': 'row4 col3'} + }); + testRows.push({ + 'col1': {'text': 'row5 col1'}, + 'col2': {'text': '456'}, + 'col3': {'text': 'row5 col3'} + }); + testRows.push({ + 'col1': {'text': 'row5 col1'}, + 'col2': {'text': ''}, + 'col3': {'text': 'row5 col3'} + }); + + sortedRows = controller.sortRows(testRows); + expect(sortedRows[0].col2.text).toEqual('ghi'); + expect(sortedRows[1].col2.text).toEqual('def'); + expect(sortedRows[2].col2.text).toEqual('abc'); + + expect(sortedRows[sortedRows.length - 3].col2.text).toEqual('456'); + expect(sortedRows[sortedRows.length - 2].col2.text).toEqual('123'); + expect(sortedRows[sortedRows.length - 1].col2.text).toEqual(''); + }); + + describe('The sort comparator', function () { + it('Correctly sorts different data types', function () { + var val1 = "", + val2 = "1", + val3 = "2016-04-05 18:41:30.713Z", + val4 = "1.1", + val5 = "8.945520958175627e-13"; + mockScope.sortDirection = "asc"; + + expect(controller.sortComparator(val1, val2)).toEqual(-1); + expect(controller.sortComparator(val3, val1)).toEqual(1); + expect(controller.sortComparator(val3, val2)).toEqual(1); + expect(controller.sortComparator(val4, val2)).toEqual(1); + expect(controller.sortComparator(val2, val5)).toEqual(1); + }); + }); + + describe('Adding new rows', function () { var row4, row5, row6; - beforeEach(function() { + beforeEach(function () { row4 = { 'col1': {'text': 'row5 col1'}, 'col2': {'text': 'xyz'}, @@ -203,33 +264,33 @@ define( }); it('Adds new rows at the correct sort position when' + - ' sorted ', function() { + ' sorted ', function () { mockScope.sortColumn = 'col2'; mockScope.sortDirection = 'desc'; mockScope.displayRows = controller.sortRows(testRows.slice(0)); mockScope.rows.push(row4); - controller.newRow(undefined, mockScope.rows.length-1); + controller.addRow(undefined, mockScope.rows.length - 1); expect(mockScope.displayRows[0].col2.text).toEqual('xyz'); mockScope.rows.push(row5); - controller.newRow(undefined, mockScope.rows.length-1); + controller.addRow(undefined, mockScope.rows.length - 1); expect(mockScope.displayRows[4].col2.text).toEqual('aaa'); mockScope.rows.push(row6); - controller.newRow(undefined, mockScope.rows.length-1); + controller.addRow(undefined, mockScope.rows.length - 1); expect(mockScope.displayRows[2].col2.text).toEqual('ggg'); //Add a duplicate row mockScope.rows.push(row6); - controller.newRow(undefined, mockScope.rows.length-1); + controller.addRow(undefined, mockScope.rows.length - 1); expect(mockScope.displayRows[2].col2.text).toEqual('ggg'); expect(mockScope.displayRows[3].col2.text).toEqual('ggg'); }); it('Adds new rows at the correct sort position when' + - ' sorted and filtered', function() { + ' sorted and filtered', function () { mockScope.sortColumn = 'col2'; mockScope.sortDirection = 'desc'; mockScope.filters = {'col2': 'a'};//Include only @@ -239,18 +300,18 @@ define( mockScope.displayRows = controller.filterRows(testRows); mockScope.rows.push(row5); - controller.newRow(undefined, mockScope.rows.length-1); + controller.addRow(undefined, mockScope.rows.length - 1); expect(mockScope.displayRows.length).toBe(2); expect(mockScope.displayRows[1].col2.text).toEqual('aaa'); mockScope.rows.push(row6); - controller.newRow(undefined, mockScope.rows.length-1); + controller.addRow(undefined, mockScope.rows.length - 1); expect(mockScope.displayRows.length).toBe(2); //Row was not added because does not match filter }); it('Adds new rows at the correct sort position when' + - ' not sorted ', function() { + ' not sorted ', function () { mockScope.sortColumn = undefined; mockScope.sortDirection = undefined; mockScope.filters = {}; @@ -258,14 +319,33 @@ define( mockScope.displayRows = testRows.slice(0); mockScope.rows.push(row5); - controller.newRow(undefined, mockScope.rows.length-1); + controller.addRow(undefined, mockScope.rows.length - 1); expect(mockScope.displayRows[3].col2.text).toEqual('aaa'); mockScope.rows.push(row6); - controller.newRow(undefined, mockScope.rows.length-1); + controller.addRow(undefined, mockScope.rows.length - 1); expect(mockScope.displayRows[4].col2.text).toEqual('ggg'); }); + it('Resizes columns if length of any columns in new' + + ' row exceeds corresponding existing column', function () { + var row7 = { + 'col1': {'text': 'row6 col1'}, + 'col2': {'text': 'some longer string'}, + 'col3': {'text': 'row6 col3'} + }; + + mockScope.sortColumn = undefined; + mockScope.sortDirection = undefined; + mockScope.filters = {}; + + mockScope.displayRows = testRows.slice(0); + + mockScope.rows.push(row7); + controller.addRow(undefined, mockScope.rows.length - 1); + expect(controller.$scope.sizingRow.col2).toEqual({text: 'some longer string'}); + }); + }); }); diff --git a/platform/features/table/test/controllers/RTTelemetryTableControllerSpec.js b/platform/features/table/test/controllers/RealtimeTableControllerSpec.js similarity index 88% rename from platform/features/table/test/controllers/RTTelemetryTableControllerSpec.js rename to platform/features/table/test/controllers/RealtimeTableControllerSpec.js index 59911d1771..ada85baa3c 100644 --- a/platform/features/table/test/controllers/RTTelemetryTableControllerSpec.js +++ b/platform/features/table/test/controllers/RealtimeTableControllerSpec.js @@ -19,14 +19,12 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,xit*/ define( [ - "../../src/controllers/RTTelemetryTableController" + "../../src/controllers/RealtimeTableController" ], function (TableController) { - "use strict"; describe('The real-time table controller', function () { var mockScope, @@ -42,7 +40,7 @@ define( function promise(value) { return { - then: function (callback){ + then: function (callback) { return promise(callback(value)); } }; @@ -59,13 +57,13 @@ define( '$digest', '$broadcast' ]); - mockScope.$on.andCallFake(function (expression, callback){ + mockScope.$on.andCallFake(function (expression, callback) { watches[expression] = callback; }); - mockScope.$watch.andCallFake(function (expression, callback){ - watches[expression] = callback; + mockScope.$watch.andCallFake(function (expression, callback) { + watches[expression] = callback; }); - mockScope.$watchCollection.andCallFake(function (expression, callback){ + mockScope.$watchCollection.andCallFake(function (expression, callback) { watches[expression] = callback; }); @@ -77,17 +75,17 @@ define( mockTable = jasmine.createSpyObj('table', [ - 'buildColumns', - 'getColumnConfiguration', + 'populateColumns', + 'buildColumnConfiguration', 'getRowValues', 'saveColumnConfiguration' ] ); mockTable.columns = []; - mockTable.getColumnConfiguration.andReturn(mockConfiguration); + mockTable.buildColumnConfiguration.andReturn(mockConfiguration); mockTable.getRowValues.andReturn(mockTableRow); - mockDomainObject= jasmine.createSpyObj('domainObject', [ + mockDomainObject = jasmine.createSpyObj('domainObject', [ 'getCapability', 'useCapability', 'getModel' @@ -95,7 +93,7 @@ define( mockDomainObject.getModel.andReturn({}); mockDomainObject.getCapability.andReturn( { - getMetadata: function (){ + getMetadata: function () { return {ranges: [{format: 'string'}]}; } }); @@ -107,13 +105,16 @@ define( 'unsubscribe', 'getDatum', 'promiseTelemetryObjects', - 'getTelemetryObjects' + 'getTelemetryObjects', + 'request' ]); + // Arbitrary array with non-zero length, contents are not // used by mocks mockTelemetryHandle.getTelemetryObjects.andReturn([{}]); mockTelemetryHandle.promiseTelemetryObjects.andReturn(promise(undefined)); mockTelemetryHandle.getDatum.andReturn({}); + mockTelemetryHandle.request.andReturn(promise(undefined)); mockTelemetryHandler = jasmine.createSpyObj('telemetryHandler', [ 'handle' @@ -131,7 +132,7 @@ define( }); describe('receives new telemetry', function () { - beforeEach(function() { + beforeEach(function () { controller.subscribe(); mockScope.rows = []; }); @@ -150,7 +151,7 @@ define( } mockTelemetryHandler.handle.mostRecentCall.args[1](); expect(mockScope.rows.length).toBe(controller.maxRows); - expect(mockScope.rows[mockScope.rows.length-1]).toBe(mockTableRow); + expect(mockScope.rows[mockScope.rows.length - 1]).toBe(mockTableRow); expect(mockScope.rows[0].row).toBe(1); }); }); diff --git a/platform/features/table/test/controllers/TableOptionsControllerSpec.js b/platform/features/table/test/controllers/TableOptionsControllerSpec.js index 9de96b5f52..9ea1967b36 100644 --- a/platform/features/table/test/controllers/TableOptionsControllerSpec.js +++ b/platform/features/table/test/controllers/TableOptionsControllerSpec.js @@ -19,59 +19,67 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,xit*/ define( [ "../../src/controllers/TableOptionsController" ], function (TableOptionsController) { - "use strict"; - describe('The Table Options Controller', function() { + describe('The Table Options Controller', function () { var mockDomainObject, mockCapability, controller, mockScope; - function promise(value) { - return { - then: function (callback){ - return promise(callback(value)); - } - }; - } - - beforeEach(function() { + beforeEach(function () { mockCapability = jasmine.createSpyObj('mutationCapability', [ 'listen' ]); mockDomainObject = jasmine.createSpyObj('domainObject', [ - 'getCapability' + 'getCapability', + 'getModel' ]); mockDomainObject.getCapability.andReturn(mockCapability); + mockDomainObject.getModel.andReturn({}); + mockScope = jasmine.createSpyObj('scope', [ - '$watchCollection' + '$watchCollection', + '$watch', + '$on' ]); mockScope.domainObject = mockDomainObject; controller = new TableOptionsController(mockScope); }); - it('Registers a listener for mutation events on the object', function() { + it('Listens for changing domain object', function () { + expect(mockScope.$watch).toHaveBeenCalledWith('domainObject', jasmine.any(Function)); + }); + + it('On destruction of controller, destroys listeners', function () { + var unlistenFunc = jasmine.createSpy("unlisten"); + controller.listeners.push(unlistenFunc); + expect(mockScope.$on).toHaveBeenCalledWith('$destroy', jasmine.any(Function)); + mockScope.$on.mostRecentCall.args[1](); + expect(unlistenFunc).toHaveBeenCalled(); + }); + + it('Registers a listener for mutation events on the object', function () { + mockScope.$watch.mostRecentCall.args[1](mockDomainObject); expect(mockCapability.listen).toHaveBeenCalled(); }); it('Listens for changes to object composition and updates' + - ' options accordingly', function() { + ' options accordingly', function () { expect(mockScope.$watchCollection).toHaveBeenCalledWith('configuration.table.columns', jasmine.any(Function)); }); describe('Populates scope with a form definition based on provided' + - ' column configuration', function() { + ' column configuration', function () { var mockModel; - beforeEach(function() { + beforeEach(function () { mockModel = { configuration: { table: { @@ -79,7 +87,7 @@ define( 'column1': true, 'column2': true, 'column3': false, - 'column4': true, + 'column4': true } } } @@ -87,19 +95,19 @@ define( controller.populateForm(mockModel); }); - it('creates form on scope', function() { + it('creates form on scope', function () { expect(mockScope.columnsForm).toBeDefined(); expect(mockScope.columnsForm.sections[0]).toBeDefined(); expect(mockScope.columnsForm.sections[0].rows).toBeDefined(); expect(mockScope.columnsForm.sections[0].rows.length).toBe(4); }); - it('presents columns as checkboxes', function() { - expect(mockScope.columnsForm.sections[0].rows.every(function(row){ + it('presents columns as checkboxes', function () { + expect(mockScope.columnsForm.sections[0].rows.every(function (row) { return row.control === 'checkbox'; })).toBe(true); }); }); }); - }); \ No newline at end of file + }); diff --git a/platform/features/timeline/bundle.js b/platform/features/timeline/bundle.js index 27420fd032..e44b27c589 100644 --- a/platform/features/timeline/bundle.js +++ b/platform/features/timeline/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/actions/ExportTimelineAsCSVAction", @@ -80,7 +79,6 @@ define([ datetimeTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/features/timeline", { "name": "Timelines", diff --git a/platform/features/timeline/res/sass/_timelines.scss b/platform/features/timeline/res/sass/_timelines.scss index 0348839263..251008a64c 100644 --- a/platform/features/timeline/res/sass/_timelines.scss +++ b/platform/features/timeline/res/sass/_timelines.scss @@ -158,9 +158,13 @@ top: 20px; bottom: 5px; .l-labels-holder { @include absPosDefault(); + @include justify-content(space-between); left: $m; - .tick-label.tick-label-y { - text-align: left; + .t-resource-graph-tick-label { + font-size: 0.9em; + &.tick-label-y { + text-align: left; + } } } } diff --git a/platform/features/timeline/res/templates/resource-graph-labels.html b/platform/features/timeline/res/templates/resource-graph-labels.html index 192188f554..038c2073eb 100644 --- a/platform/features/timeline/res/templates/resource-graph-labels.html +++ b/platform/features/timeline/res/templates/resource-graph-labels.html @@ -23,14 +23,14 @@ {{parameters.title}}
      -
      -
      +
      +
      {{parameters.high}}
      -
      +
      {{parameters.middle}}
      -
      +
      {{parameters.low}}
      diff --git a/platform/features/timeline/res/templates/tabular-swimlane-cols-tree.html b/platform/features/timeline/res/templates/tabular-swimlane-cols-tree.html index e5ca69e15c..22c4a84229 100644 --- a/platform/features/timeline/res/templates/tabular-swimlane-cols-tree.html +++ b/platform/features/timeline/res/templates/tabular-swimlane-cols-tree.html @@ -29,7 +29,7 @@ }">
      diff --git a/platform/features/timeline/src/TimelineConstants.js b/platform/features/timeline/src/TimelineConstants.js index 3b7de588a4..74fd7392b4 100644 --- a/platform/features/timeline/src/TimelineConstants.js +++ b/platform/features/timeline/src/TimelineConstants.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Defines constant values for use in timeline view. @@ -29,4 +28,4 @@ define({ HANDLE_WIDTH: 32, // Pixel tolerance for snapping behavior SNAP_WIDTH: 16 -}); \ No newline at end of file +}); diff --git a/platform/features/timeline/src/TimelineFormatter.js b/platform/features/timeline/src/TimelineFormatter.js index f9980546b3..447361decb 100644 --- a/platform/features/timeline/src/TimelineFormatter.js +++ b/platform/features/timeline/src/TimelineFormatter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; // Conversion factors from time units to milliseconds var SECONDS = 1000, @@ -75,4 +73,4 @@ define( return TimelineFormatter; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/actions/CompositionColumn.js b/platform/features/timeline/src/actions/CompositionColumn.js index b7208c3e92..f9bede9983 100644 --- a/platform/features/timeline/src/actions/CompositionColumn.js +++ b/platform/features/timeline/src/actions/CompositionColumn.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([], function () { - "use strict"; /** * A column containing references to other objects contained diff --git a/platform/features/timeline/src/actions/ExportTimelineAsCSVAction.js b/platform/features/timeline/src/actions/ExportTimelineAsCSVAction.js index e50b9369db..57ac17c8a0 100644 --- a/platform/features/timeline/src/actions/ExportTimelineAsCSVAction.js +++ b/platform/features/timeline/src/actions/ExportTimelineAsCSVAction.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define(["./ExportTimelineAsCSVTask"], function (ExportTimelineAsCSVTask) { - 'use strict'; /** * Implements the "Export Timeline as CSV" action. diff --git a/platform/features/timeline/src/actions/ExportTimelineAsCSVTask.js b/platform/features/timeline/src/actions/ExportTimelineAsCSVTask.js index 5979347d3c..1e9be7d97a 100644 --- a/platform/features/timeline/src/actions/ExportTimelineAsCSVTask.js +++ b/platform/features/timeline/src/actions/ExportTimelineAsCSVTask.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ExportTimelineAsCSVTask. Created by vwoeltje on 2/8/16. @@ -28,7 +27,6 @@ define([ "./TimelineTraverser", "./TimelineColumnizer" ], function (TimelineTraverser, TimelineColumnizer) { - "use strict"; /** * Runs (and coordinates) the preparation and export of CSV data diff --git a/platform/features/timeline/src/actions/IdColumn.js b/platform/features/timeline/src/actions/IdColumn.js index 56ddfe385f..38c8b9264e 100644 --- a/platform/features/timeline/src/actions/IdColumn.js +++ b/platform/features/timeline/src/actions/IdColumn.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([], function () { - "use strict"; /** * A column showing domain object identifiers. diff --git a/platform/features/timeline/src/actions/MetadataColumn.js b/platform/features/timeline/src/actions/MetadataColumn.js index c94237a917..7676552879 100644 --- a/platform/features/timeline/src/actions/MetadataColumn.js +++ b/platform/features/timeline/src/actions/MetadataColumn.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([], function () { - "use strict"; /** * A column reflecting properties from domain object metadata. diff --git a/platform/features/timeline/src/actions/ModeColumn.js b/platform/features/timeline/src/actions/ModeColumn.js index 4ae61b30d3..fe2063566d 100644 --- a/platform/features/timeline/src/actions/ModeColumn.js +++ b/platform/features/timeline/src/actions/ModeColumn.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([], function () { - "use strict"; /** * A column showing relationships to activity modes. diff --git a/platform/features/timeline/src/actions/TimelineColumnizer.js b/platform/features/timeline/src/actions/TimelineColumnizer.js index 035496edc6..5468add401 100644 --- a/platform/features/timeline/src/actions/TimelineColumnizer.js +++ b/platform/features/timeline/src/actions/TimelineColumnizer.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define([ "./IdColumn", @@ -34,7 +33,6 @@ define([ MetadataColumn, TimespanColumn ) { - 'use strict'; /** * A description of how to populate a given column within a diff --git a/platform/features/timeline/src/actions/TimelineTraverser.js b/platform/features/timeline/src/actions/TimelineTraverser.js index f6857658fb..089f51cb35 100644 --- a/platform/features/timeline/src/actions/TimelineTraverser.js +++ b/platform/features/timeline/src/actions/TimelineTraverser.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define([], function () { - "use strict"; /** * Builds a list of domain objects which should be included @@ -82,4 +80,4 @@ define([], function () { return TimelineTraverser; -}); \ No newline at end of file +}); diff --git a/platform/features/timeline/src/actions/TimespanColumn.js b/platform/features/timeline/src/actions/TimespanColumn.js index 6d0c4e05a9..a701724ee1 100644 --- a/platform/features/timeline/src/actions/TimespanColumn.js +++ b/platform/features/timeline/src/actions/TimespanColumn.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define(['../TimelineFormatter'], function (TimelineFormatter) { - "use strict"; var FORMATTER = new TimelineFormatter(); diff --git a/platform/features/timeline/src/capabilities/ActivityTimespan.js b/platform/features/timeline/src/capabilities/ActivityTimespan.js index 7bf8ac06b1..61e120d688 100644 --- a/platform/features/timeline/src/capabilities/ActivityTimespan.js +++ b/platform/features/timeline/src/capabilities/ActivityTimespan.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * Describes the time span of an activity object. @@ -54,25 +52,25 @@ define( // Set the start time associated with this object function setStart(value) { var end = getEnd(); - mutation.mutate(function (model) { - model.start.timestamp = Math.max(value, 0); + mutation.mutate(function (m) { + m.start.timestamp = Math.max(value, 0); // Update duration to keep end time - model.duration.timestamp = Math.max(end - value, 0); + m.duration.timestamp = Math.max(end - value, 0); }, model.modified); } // Set the duration associated with this object function setDuration(value) { - mutation.mutate(function (model) { - model.duration.timestamp = Math.max(value, 0); + mutation.mutate(function (m) { + m.duration.timestamp = Math.max(value, 0); }, model.modified); } // Set the end time associated with this object function setEnd(value) { var start = getStart(); - mutation.mutate(function (model) { - model.duration.timestamp = Math.max(value - start, 0); + mutation.mutate(function (m) { + m.duration.timestamp = Math.max(value - start, 0); }, model.modified); } @@ -118,4 +116,4 @@ define( return ActivityTimespan; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/capabilities/ActivityTimespanCapability.js b/platform/features/timeline/src/capabilities/ActivityTimespanCapability.js index c5852fa4d1..8d0f2fe211 100644 --- a/platform/features/timeline/src/capabilities/ActivityTimespanCapability.js +++ b/platform/features/timeline/src/capabilities/ActivityTimespanCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./ActivityTimespan'], function (ActivityTimespan) { - 'use strict'; /** * Implements the `timespan` capability for Activity objects. diff --git a/platform/features/timeline/src/capabilities/ActivityUtilization.js b/platform/features/timeline/src/capabilities/ActivityUtilization.js index 5db644833d..6e7895d34d 100644 --- a/platform/features/timeline/src/capabilities/ActivityUtilization.js +++ b/platform/features/timeline/src/capabilities/ActivityUtilization.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Provides data to populate resource graphs associated @@ -37,10 +35,10 @@ define( getPointCount: function () { return 0; }, - getDomainValue: function (index) { + getDomainValue: function () { return 0; }, - getRangeValue: function (index) { + getRangeValue: function () { return 0; } }; @@ -49,4 +47,4 @@ define( return ActivityUtilization; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/capabilities/CostCapability.js b/platform/features/timeline/src/capabilities/CostCapability.js index c977b5751f..4dae542093 100644 --- a/platform/features/timeline/src/capabilities/CostCapability.js +++ b/platform/features/timeline/src/capabilities/CostCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Exposes costs associated with a subsystem mode. diff --git a/platform/features/timeline/src/capabilities/CumulativeGraph.js b/platform/features/timeline/src/capabilities/CumulativeGraph.js index 62d799d0b0..92d1cfa503 100644 --- a/platform/features/timeline/src/capabilities/CumulativeGraph.js +++ b/platform/features/timeline/src/capabilities/CumulativeGraph.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Provide points for a cumulative resource summary graph, using @@ -55,22 +53,21 @@ define( // Initialize the data values function initializeValues() { - var values = [], + var vals = [], slope = 0, - previous = 0, i; // Add a point (or points, if needed) reaching to the provided // domain and/or range value function addPoint(domain, range) { - var previous = values[values.length - 1], + var previous = vals[vals.length - 1], delta = domain - previous.domain, // time delta change = delta * slope * rate, // change next = previous.range + change; // Crop to minimum boundary... if (next < minimum) { - values.push({ + vals.push({ domain: intercept( previous.domain, previous.range, @@ -84,7 +81,7 @@ define( // ...and maximum boundary if (next > maximum) { - values.push({ + vals.push({ domain: intercept( previous.domain, previous.range, @@ -98,19 +95,19 @@ define( // Add the new data value if (delta > 0) { - values.push({ domain: domain, range: next }); + vals.push({ domain: domain, range: next }); } slope = range; } - values.push({ domain: 0, range: initial }); + vals.push({ domain: 0, range: initial }); for (i = 0; i < graph.getPointCount(); i += 1) { addPoint(graph.getDomainValue(i), graph.getRangeValue(i)); } - return values; + return vals; } function convertToPercent(point) { @@ -152,4 +149,4 @@ define( return CumulativeGraph; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/capabilities/GraphCapability.js b/platform/features/timeline/src/capabilities/GraphCapability.js index b701b69e9e..867450345e 100644 --- a/platform/features/timeline/src/capabilities/GraphCapability.js +++ b/platform/features/timeline/src/capabilities/GraphCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./ResourceGraph', './CumulativeGraph'], function (ResourceGraph, CumulativeGraph) { - 'use strict'; /** * Implements the `graph` capability for Timeline and diff --git a/platform/features/timeline/src/capabilities/ResourceGraph.js b/platform/features/timeline/src/capabilities/ResourceGraph.js index 70dba5af64..93ced78f09 100644 --- a/platform/features/timeline/src/capabilities/ResourceGraph.js +++ b/platform/features/timeline/src/capabilities/ResourceGraph.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; // Utility function to copy an array, sorted by a specific field function sort(array, field) { @@ -74,13 +72,13 @@ define( // If there are sequences of points with the same timestamp, // allow only the first and last. - function filterPoint(value, index, values) { + function filterPoint(value, index, vals) { // Allow the first or last point as a base case; aside from // that, allow only points that have different timestamps // from their predecessor or successor. - return (index === 0) || (index === values.length - 1) || - (value.domain !== values[index - 1].domain) || - (value.domain !== values[index + 1].domain); + return (index === 0) || (index === vals.length - 1) || + (value.domain !== vals[index - 1].domain) || + (value.domain !== vals[index + 1].domain); } // Add a step up or down (Step 3c above) @@ -146,4 +144,4 @@ define( return ResourceGraph; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/capabilities/TimelineTimespan.js b/platform/features/timeline/src/capabilities/TimelineTimespan.js index 48b5c5609f..de747764ef 100644 --- a/platform/features/timeline/src/capabilities/TimelineTimespan.js +++ b/platform/features/timeline/src/capabilities/TimelineTimespan.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * Describes the time span of a timeline object. @@ -59,18 +57,18 @@ define( // Set the start time associated with this object function setStart(value) { - mutation.mutate(function (model) { - model.start.timestamp = Math.max(value, 0); + mutation.mutate(function (m) { + m.start.timestamp = Math.max(value, 0); }, model.modified); } // Set the duration associated with this object - function setDuration(value) { + function setDuration() { // No-op; duration is implicit } // Set the end time associated with this object - function setEnd(value) { + function setEnd() { // No-op; end time is implicit } @@ -123,4 +121,4 @@ define( return TimelineTimespan; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/capabilities/TimelineTimespanCapability.js b/platform/features/timeline/src/capabilities/TimelineTimespanCapability.js index 4700f8ccea..f1374b3e13 100644 --- a/platform/features/timeline/src/capabilities/TimelineTimespanCapability.js +++ b/platform/features/timeline/src/capabilities/TimelineTimespanCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TimelineTimespan'], function (TimelineTimespan) { - 'use strict'; /** * Implements the `timespan` capability for Timeline objects. diff --git a/platform/features/timeline/src/capabilities/TimelineUtilization.js b/platform/features/timeline/src/capabilities/TimelineUtilization.js index bb90c67142..a4fc885734 100644 --- a/platform/features/timeline/src/capabilities/TimelineUtilization.js +++ b/platform/features/timeline/src/capabilities/TimelineUtilization.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Provides data to populate resource graphs associated @@ -49,4 +47,4 @@ define( return TimelineUtilization; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/capabilities/UtilizationCapability.js b/platform/features/timeline/src/capabilities/UtilizationCapability.js index 33a7e4f793..55976f3ab5 100644 --- a/platform/features/timeline/src/capabilities/UtilizationCapability.js +++ b/platform/features/timeline/src/capabilities/UtilizationCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Provide the resource utilization over time for a timeline @@ -122,13 +120,13 @@ define( } // Look up a specific object's resource utilization - function lookupUtilization(domainObject) { - return domainObject.useCapability('utilization'); + function lookupUtilization(object) { + return object.useCapability('utilization'); } // Look up a specific object's resource utilization keys - function lookupUtilizationResources(domainObject) { - var utilization = domainObject.getCapability('utilization'); + function lookupUtilizationResources(object) { + var utilization = object.getCapability('utilization'); return utilization && utilization.resources(); } diff --git a/platform/features/timeline/src/controllers/ActivityModeValuesController.js b/platform/features/timeline/src/controllers/ActivityModeValuesController.js index 2545c8b370..5ea75ad774 100644 --- a/platform/features/timeline/src/controllers/ActivityModeValuesController.js +++ b/platform/features/timeline/src/controllers/ActivityModeValuesController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Controller which support the Values view of Activity Modes. diff --git a/platform/features/timeline/src/controllers/TimelineController.js b/platform/features/timeline/src/controllers/TimelineController.js index a31fffa1c7..796807c76a 100644 --- a/platform/features/timeline/src/controllers/TimelineController.js +++ b/platform/features/timeline/src/controllers/TimelineController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [ @@ -32,7 +31,6 @@ define( TimelineGraphPopulator, TimelineDragPopulator ) { - 'use strict'; /** * Controller for the Timeline view. @@ -98,7 +96,7 @@ define( }); } } - + // Recalculate swimlane state on changes $scope.$watch("domainObject", swimlanePopulator.populate); diff --git a/platform/features/timeline/src/controllers/TimelineDateTimeController.js b/platform/features/timeline/src/controllers/TimelineDateTimeController.js index f986b3fe7e..01ec6cebe3 100644 --- a/platform/features/timeline/src/controllers/TimelineDateTimeController.js +++ b/platform/features/timeline/src/controllers/TimelineDateTimeController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,moment*/ define( [], function () { - "use strict"; /** * Controller for the `datetime` form control. @@ -90,4 +88,4 @@ define( return DateTimeController; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/TimelineGanttController.js b/platform/features/timeline/src/controllers/TimelineGanttController.js index 163e8dca8a..a435ac49ad 100644 --- a/platform/features/timeline/src/controllers/TimelineGanttController.js +++ b/platform/features/timeline/src/controllers/TimelineGanttController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Control for Gantt bars in a timeline view. @@ -85,4 +83,4 @@ define( return TimelineGanttController; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/TimelineGraphController.js b/platform/features/timeline/src/controllers/TimelineGraphController.js index 1b45efad5c..5710e1a1c5 100644 --- a/platform/features/timeline/src/controllers/TimelineGraphController.js +++ b/platform/features/timeline/src/controllers/TimelineGraphController.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * Controller for the graph area of a timeline view. @@ -94,4 +92,4 @@ define( return TimelineGraphController; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/TimelineTableController.js b/platform/features/timeline/src/controllers/TimelineTableController.js index 986a44222f..2e71654577 100644 --- a/platform/features/timeline/src/controllers/TimelineTableController.js +++ b/platform/features/timeline/src/controllers/TimelineTableController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["../TimelineFormatter"], function (TimelineFormatter) { - "use strict"; var FORMATTER = new TimelineFormatter(); diff --git a/platform/features/timeline/src/controllers/TimelineTickController.js b/platform/features/timeline/src/controllers/TimelineTickController.js index 62b6095fc0..611828241a 100644 --- a/platform/features/timeline/src/controllers/TimelineTickController.js +++ b/platform/features/timeline/src/controllers/TimelineTickController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["../TimelineFormatter"], function (TimelineFormatter) { - "use strict"; var FORMATTER = new TimelineFormatter(); @@ -115,4 +113,4 @@ define( return TimelineTickController; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/TimelineZoomController.js b/platform/features/timeline/src/controllers/TimelineZoomController.js index 13fb600923..4c8acd0061 100644 --- a/platform/features/timeline/src/controllers/TimelineZoomController.js +++ b/platform/features/timeline/src/controllers/TimelineZoomController.js @@ -19,14 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( - ['../TimelineFormatter'], - function (TimelineFormatter) { - "use strict"; - - - var FORMATTER = new TimelineFormatter(); + [], + function () { /** * Controls the pan-zoom state of a timeline view. @@ -34,7 +29,7 @@ define( */ function TimelineZoomController($scope, ZOOM_CONFIGURATION) { // Prefer to start with the middle index - var zoomLevels = ZOOM_CONFIGURATION.levels || [ 1000 ], + var zoomLevels = ZOOM_CONFIGURATION.levels || [1000], zoomIndex = Math.floor(zoomLevels.length / 2), tickWidth = ZOOM_CONFIGURATION.width || 200, duration = 86400000; // Default duration in view @@ -62,7 +57,8 @@ define( function storeZoom() { var isEditMode = $scope.commit && $scope.domainObject && - $scope.domainObject.hasCapability('editor'); + $scope.domainObject.hasCapability('editor') && + $scope.domainObject.getCapability('editor').inEditContext(); if (isEditMode) { $scope.configuration = $scope.configuration || {}; $scope.configuration.zoomLevel = zoomIndex; @@ -115,7 +111,6 @@ define( * @returns {number} duration, in milliseconds */ duration: function (value) { - var prior = duration; if (arguments.length > 0) { duration = roundDuration(value); } diff --git a/platform/features/timeline/src/controllers/drag/TimelineDragHandleFactory.js b/platform/features/timeline/src/controllers/drag/TimelineDragHandleFactory.js index 6f1dc56d7c..2ef1e139fa 100644 --- a/platform/features/timeline/src/controllers/drag/TimelineDragHandleFactory.js +++ b/platform/features/timeline/src/controllers/drag/TimelineDragHandleFactory.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TimelineStartHandle', './TimelineEndHandle', './TimelineMoveHandle'], function (TimelineStartHandle, TimelineEndHandle, TimelineMoveHandle) { - "use strict"; var DEFAULT_HANDLES = [ diff --git a/platform/features/timeline/src/controllers/drag/TimelineDragHandler.js b/platform/features/timeline/src/controllers/drag/TimelineDragHandler.js index ff1147bbae..c1605a21e9 100644 --- a/platform/features/timeline/src/controllers/drag/TimelineDragHandler.js +++ b/platform/features/timeline/src/controllers/drag/TimelineDragHandler.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Handles business logic (mutation of objects, retrieval of start/end @@ -49,19 +47,19 @@ define( } // Get the timespan associated with this domain object - function populateCapabilityMaps(domainObject) { - var id = domainObject.getId(), - timespanPromise = domainObject.useCapability('timespan'); + function populateCapabilityMaps(object) { + var id = object.getId(), + timespanPromise = object.useCapability('timespan'); if (timespanPromise) { timespanPromise.then(function (timespan) { // Cache that timespan timespans[id] = timespan; // And its mutation capability - mutations[id] = domainObject.getCapability('mutation'); + mutations[id] = object.getCapability('mutation'); // Also cache the persistence capability for later - persists[id] = domainObject.getCapability('persistence'); + persists[id] = object.getCapability('persistence'); // And the composition, for bulk moves - compositions[id] = domainObject.getModel().composition || []; + compositions[id] = object.getModel().composition || []; }); } } @@ -201,8 +199,8 @@ define( minStart; // Update start & end, in that order - function updateStartEnd(id) { - var timespan = timespans[id], start, end; + function updateStartEnd(spanId) { + var timespan = timespans[spanId], start, end; if (timespan) { // Get start/end so we don't get fooled by our // own adjustments @@ -212,7 +210,7 @@ define( timespan.setStart(start + delta); timespan.setEnd(end + delta); // Mark as dirty for subsequent persistence - dirty[toId(id)] = true; + dirty[toId(spanId)] = true; } } @@ -230,12 +228,12 @@ define( } // Find the minimum start time - minStart = Object.keys(ids).map(function (id) { + minStart = Object.keys(ids).map(function (spanId) { // Get the start time; default to +Inf if not // found, since this will not survive a min // test if any real timespans are present - return timespans[id] ? - timespans[id].getStart() : + return timespans[spanId] ? + timespans[spanId].getStart() : Number.POSITIVE_INFINITY; }).reduce(function (a, b) { // Reduce with a minimum test @@ -255,4 +253,4 @@ define( return TimelineDragHandler; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/drag/TimelineDragPopulator.js b/platform/features/timeline/src/controllers/drag/TimelineDragPopulator.js index e21080b003..67f26d0144 100644 --- a/platform/features/timeline/src/controllers/drag/TimelineDragPopulator.js +++ b/platform/features/timeline/src/controllers/drag/TimelineDragPopulator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TimelineDragHandler', './TimelineSnapHandler', './TimelineDragHandleFactory'], function (TimelineDragHandler, TimelineSnapHandler, TimelineDragHandleFactory) { - "use strict"; /** * Provides drag handles for the active selection in a timeline view. @@ -94,4 +92,4 @@ define( return TimelineDragPopulator; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/drag/TimelineEndHandle.js b/platform/features/timeline/src/controllers/drag/TimelineEndHandle.js index 060e690fa9..facbedc889 100644 --- a/platform/features/timeline/src/controllers/drag/TimelineEndHandle.js +++ b/platform/features/timeline/src/controllers/drag/TimelineEndHandle.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['../../TimelineConstants'], function (Constants) { - "use strict"; /** * Handle for changing the end time of a timeline or @@ -95,4 +93,4 @@ define( return TimelineEndHandle; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/drag/TimelineMoveHandle.js b/platform/features/timeline/src/controllers/drag/TimelineMoveHandle.js index f2f2d082f0..f6b9868656 100644 --- a/platform/features/timeline/src/controllers/drag/TimelineMoveHandle.js +++ b/platform/features/timeline/src/controllers/drag/TimelineMoveHandle.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['../../TimelineConstants'], function (Constants) { - "use strict"; /** * Handle for moving (by drag) a timeline or @@ -119,13 +117,10 @@ define( style: function (zoom) { return { - left: zoom.toPixels(dragHandler.start(id)) + - Constants.HANDLE_WIDTH + - 'px', - width: zoom.toPixels(dragHandler.duration(id)) - - Constants.HANDLE_WIDTH * 2 - + 'px' - //cursor: initialStart === undefined ? 'grab' : 'grabbing' + left: (zoom.toPixels(dragHandler.start(id)) + + Constants.HANDLE_WIDTH) + 'px', + width: (zoom.toPixels(dragHandler.duration(id)) - + Constants.HANDLE_WIDTH * 2) + 'px' }; } }; @@ -133,4 +128,4 @@ define( return TimelineMoveHandle; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/drag/TimelineSnapHandler.js b/platform/features/timeline/src/controllers/drag/TimelineSnapHandler.js index 5d2085f795..cc60e0d8f4 100644 --- a/platform/features/timeline/src/controllers/drag/TimelineSnapHandler.js +++ b/platform/features/timeline/src/controllers/drag/TimelineSnapHandler.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Snaps timestamps to match other timestamps within a @@ -44,7 +42,9 @@ define( candidates; // Filter an id for inclustion - function include(id) { return id !== exclude; } + function include(id) { + return id !== exclude; + } // Evaluate a candidate timestamp as a snap-to location function evaluate(candidate) { @@ -103,4 +103,4 @@ define( return TimelineSnapHandler; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/drag/TimelineStartHandle.js b/platform/features/timeline/src/controllers/drag/TimelineStartHandle.js index 65d132e9d4..ce7907eeed 100644 --- a/platform/features/timeline/src/controllers/drag/TimelineStartHandle.js +++ b/platform/features/timeline/src/controllers/drag/TimelineStartHandle.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['../../TimelineConstants'], function (Constants) { - "use strict"; /** * Handle for changing the start time of a timeline or @@ -95,4 +93,4 @@ define( return TimelineStartHandle; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/graph/TimelineGraph.js b/platform/features/timeline/src/controllers/graph/TimelineGraph.js index 7268020263..5cb5ccd491 100644 --- a/platform/features/timeline/src/controllers/graph/TimelineGraph.js +++ b/platform/features/timeline/src/controllers/graph/TimelineGraph.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * Provides data to populate a graph in a timeline view. @@ -47,8 +45,6 @@ define( min = 0, // current maximum max = 0, - // current displayed time span - duration = 1000, // line colors to display colors = Object.keys(domainObjects); @@ -172,8 +168,8 @@ define( setBounds: function (offset, duration) { // We don't update in-place, because we need the change // to trigger a watch in mct-chart. - drawingObject.origin = [ offset, drawingObject.origin[1] ]; - drawingObject.dimensions = [ duration, drawingObject.dimensions[1] ]; + drawingObject.origin = [offset, drawingObject.origin[1]]; + drawingObject.dimensions = [duration, drawingObject.dimensions[1]]; }, /** * Redraw lines in this graph. @@ -190,4 +186,4 @@ define( return TimelineGraph; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/graph/TimelineGraphPopulator.js b/platform/features/timeline/src/controllers/graph/TimelineGraphPopulator.js index 019f128525..2488d57030 100644 --- a/platform/features/timeline/src/controllers/graph/TimelineGraphPopulator.js +++ b/platform/features/timeline/src/controllers/graph/TimelineGraphPopulator.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TimelineGraph', './TimelineGraphRenderer'], function (TimelineGraph, TimelineGraphRenderer) { - 'use strict'; /** * Responsible for determining which resource graphs @@ -77,11 +75,14 @@ define( // Look up resources for a domain object function lookupResources(swimlane) { - var graphs = swimlane.domainObject.useCapability('graph'); + var graphPromise = + swimlane.domainObject.useCapability('graph'); function getKeys(obj) { return Object.keys(obj); } - return $q.when(graphs ? (graphs.then(getKeys)) : []); + return $q.when( + graphPromise ? (graphPromise.then(getKeys)) : [] + ); } // Add all graph assignments appropriate for this swimlane @@ -154,4 +155,4 @@ define( return TimelineGraphPopulator; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/graph/TimelineGraphRenderer.js b/platform/features/timeline/src/controllers/graph/TimelineGraphRenderer.js index 72add2f315..bd0546ab03 100644 --- a/platform/features/timeline/src/controllers/graph/TimelineGraphRenderer.js +++ b/platform/features/timeline/src/controllers/graph/TimelineGraphRenderer.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Float32Array*/ define( [], function () { - 'use strict'; /** * Responsible for preparing data for display by @@ -80,4 +78,4 @@ define( return TimelineGraphRenderer; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineColorAssigner.js b/platform/features/timeline/src/controllers/swimlane/TimelineColorAssigner.js index b3335ec236..26d4fd7a9f 100644 --- a/platform/features/timeline/src/controllers/swimlane/TimelineColorAssigner.js +++ b/platform/features/timeline/src/controllers/swimlane/TimelineColorAssigner.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; var COLOR_OPTIONS = [ "#20b2aa", @@ -119,4 +117,4 @@ define( return TimelineColorAssigner; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineProxy.js b/platform/features/timeline/src/controllers/swimlane/TimelineProxy.js index 7f74f59de0..7fa4dc2e9b 100644 --- a/platform/features/timeline/src/controllers/swimlane/TimelineProxy.js +++ b/platform/features/timeline/src/controllers/swimlane/TimelineProxy.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Selection proxy for the Timeline view. Implements @@ -36,8 +34,8 @@ define( var actionMap = {}; // Populate available Create actions for this domain object - function populateActionMap(domainObject) { - var actionCapability = domainObject.getCapability('action'), + function populateActionMap(object) { + var actionCapability = object.getCapability('action'), actions = actionCapability ? actionCapability.getActions('add') : []; actions.forEach(function (action) { @@ -76,4 +74,4 @@ define( return TimelineProxy; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlane.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlane.js index 23f2c49a2e..1938145d6e 100644 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlane.js +++ b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlane.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Describes a swimlane in a timeline view. This will be @@ -49,9 +47,7 @@ define( depth = parent ? (parent.depth + 1) : 0, timespan, path = (!parent || !parent.parent) ? "" : parent.path + - //(parent.path.length > 0 ? " / " : "") + - parent.domainObject.getModel().name + - " > "; + parent.domainObject.getModel().name + " > "; // Look up timespan for this object domainObject.useCapability('timespan').then(function (t) { @@ -174,4 +170,4 @@ define( return TimelineSwimlane; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js index 522197a873..898ca119ee 100644 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js +++ b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TimelineSwimlaneDropHandler'], function (TimelineSwimlaneDropHandler) { - "use strict"; var ACTIVITY_RELATIONSHIP = "modes"; @@ -47,9 +45,9 @@ define( if (arguments.length > 0 && Array.isArray(value)) { if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) { // Update the relationships - mutator.mutate(function (model) { - model.relationships = model.relationships || {}; - model.relationships[ACTIVITY_RELATIONSHIP] = value; + mutator.mutate(function (m) { + m.relationships = m.relationships || {}; + m.relationships[ACTIVITY_RELATIONSHIP] = value; }).then(persister.persist); } } @@ -63,8 +61,8 @@ define( if (arguments.length > 0 && (typeof value === 'string') && value !== model.link) { // Update the link - mutator.mutate(function (model) { - model.link = value; + mutator.mutate(function (m) { + m.link = value; }).then(persister.persist); } return model.link; diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js index 619232539f..71648995f0 100644 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js +++ b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Handles drop (from drag-and-drop) initiated changes to a swimlane. @@ -41,9 +39,10 @@ define( }; } - // Check if we are in edit mode + // Check if we are in edit mode (also check parents) function inEditMode() { - return swimlane.domainObject.hasCapability("editor"); + return swimlane.domainObject.hasCapability('editor') && + swimlane.domainObject.getCapability('editor').inEditContext(); } // Boolean and (for reduce below) @@ -52,7 +51,7 @@ define( } // Check if pathA entirely contains pathB - function pathContains(swimlane, id) { + function pathContains(swimlaneToCheck, id) { // Check if id at a specific index matches (for map below) function matches(pathId) { return pathId === id; @@ -60,18 +59,18 @@ define( // Path A contains Path B if it is longer, and all of // B's ids match the ids in A. - return swimlane.idPath.map(matches).reduce(or, false); + return swimlaneToCheck.idPath.map(matches).reduce(or, false); } // Check if a swimlane contains a child with the specified id - function contains(swimlane, id) { + function contains(swimlaneToCheck, id) { // Check if a child swimlane has a matching domain object id function matches(child) { return child.domainObject.getId() === id; } // Find any one child id that matches this id - return swimlane.children.map(matches).reduce(or, false); + return swimlaneToCheck.children.map(matches).reduce(or, false); } // Initiate mutation of a domain object diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js index 0875c87d5a..ccc6148997 100644 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js +++ b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [ @@ -34,7 +33,6 @@ define( TimelineColorAssigner, TimelineProxy ) { - 'use strict'; /** * Populates and maintains a list of swimlanes for a given @@ -63,8 +61,8 @@ define( swimlane; // For the recursive step - function populate(childSubgraph, index) { - populateSwimlanes(childSubgraph, swimlane, index); + function populate(childSubgraph, nextIndex) { + populateSwimlanes(childSubgraph, swimlane, nextIndex); } // Make sure we have a valid object instance... @@ -196,4 +194,4 @@ define( return TimelineSwimlanePopulator; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/src/directives/MCTSwimlaneDrag.js b/platform/features/timeline/src/directives/MCTSwimlaneDrag.js index 8825cced8e..2276cacc78 100644 --- a/platform/features/timeline/src/directives/MCTSwimlaneDrag.js +++ b/platform/features/timeline/src/directives/MCTSwimlaneDrag.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./SwimlaneDragConstants'], function (SwimlaneDragConstants) { - "use strict"; /** * Defines the `mct-swimlane-drag` directive. When a drag is initiated diff --git a/platform/features/timeline/src/directives/MCTSwimlaneDrop.js b/platform/features/timeline/src/directives/MCTSwimlaneDrop.js index 704444c41c..708bce85ee 100644 --- a/platform/features/timeline/src/directives/MCTSwimlaneDrop.js +++ b/platform/features/timeline/src/directives/MCTSwimlaneDrop.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./SwimlaneDragConstants'], function (SwimlaneDragConstants) { - "use strict"; /** * Defines the `mct-swimlane-drop` directive. When a drop occurs @@ -42,7 +40,6 @@ define( height = element[0].offsetHeight, rect = element[0].getBoundingClientRect(), offset = event.pageY - rect.top, - dataTransfer = event.dataTransfer, id = dndService.getData( SwimlaneDragConstants.MCT_DRAG_TYPE ), diff --git a/platform/features/timeline/src/directives/SwimlaneDragConstants.js b/platform/features/timeline/src/directives/SwimlaneDragConstants.js index 33ce4d79ea..f9b769bb5f 100644 --- a/platform/features/timeline/src/directives/SwimlaneDragConstants.js +++ b/platform/features/timeline/src/directives/SwimlaneDragConstants.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define({ /** diff --git a/platform/features/timeline/src/services/ObjectLoader.js b/platform/features/timeline/src/services/ObjectLoader.js index ce15c721df..ec4d7b15c8 100644 --- a/platform/features/timeline/src/services/ObjectLoader.js +++ b/platform/features/timeline/src/services/ObjectLoader.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * The ObjectLoader is a utility service for loading subgraphs @@ -43,13 +41,13 @@ define( filter; // Check object existence (for criterion-less filtering) - function exists(domainObject) { - return !!domainObject; + function exists(object) { + return !!object; } // Check for capability matching criterion - function hasCapability(domainObject) { - return domainObject && domainObject.hasCapability(criterion); + function hasCapability(object) { + return object && object.hasCapability(criterion); } // For the recursive step... @@ -63,8 +61,8 @@ define( } // Avoid infinite recursion - function notVisiting(domainObject) { - return !visiting[domainObject.getId()]; + function notVisiting(object) { + return !visiting[object.getId()]; } // Put the composition of this domain object into the result @@ -132,4 +130,4 @@ define( return ObjectLoader; } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/TimelineConstantsSpec.js b/platform/features/timeline/test/TimelineConstantsSpec.js index 3a0bb0866d..e299243cd2 100644 --- a/platform/features/timeline/test/TimelineConstantsSpec.js +++ b/platform/features/timeline/test/TimelineConstantsSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../src/TimelineConstants'], function (TimelineConstants) { - "use strict"; describe("The set of Timeline constants", function () { it("specifies a handle width", function () { expect(TimelineConstants.HANDLE_WIDTH) diff --git a/platform/features/timeline/test/TimelineFormatterSpec.js b/platform/features/timeline/test/TimelineFormatterSpec.js index 456e408514..d883fa5c3f 100644 --- a/platform/features/timeline/test/TimelineFormatterSpec.js +++ b/platform/features/timeline/test/TimelineFormatterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../src/TimelineFormatter'], function (TimelineFormatter) { - 'use strict'; var SECOND = 1000, MINUTE = SECOND * 60, @@ -59,4 +57,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/actions/CompositionColumnSpec.js b/platform/features/timeline/test/actions/CompositionColumnSpec.js index 99e23d5597..8cf566a080 100644 --- a/platform/features/timeline/test/actions/CompositionColumnSpec.js +++ b/platform/features/timeline/test/actions/CompositionColumnSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/actions/CompositionColumn'], @@ -45,10 +44,10 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getModel', 'getCapability' ] + ['getId', 'getModel', 'getCapability'] ); testModel = { - composition: [ 'a', 'b', 'c', 'd', 'e', 'f' ] + composition: ['a', 'b', 'c', 'd', 'e', 'f'] }; mockDomainObject.getModel.andReturn(testModel); }); @@ -59,7 +58,7 @@ define( }); it("returns nothing when composition is exceeded", function () { - testModel.composition = [ 'foo' ]; + testModel.composition = ['foo']; expect(column.value(mockDomainObject)).toEqual(""); }); @@ -71,4 +70,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/actions/ExportTimelineAsCSVActionSpec.js b/platform/features/timeline/test/actions/ExportTimelineAsCSVActionSpec.js index 3d5cd8b01c..e0f09c3ae6 100644 --- a/platform/features/timeline/test/actions/ExportTimelineAsCSVActionSpec.js +++ b/platform/features/timeline/test/actions/ExportTimelineAsCSVActionSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/actions/ExportTimelineAsCSVAction'], @@ -37,20 +36,20 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getModel', 'getCapability', 'hasCapability' ] + ['getId', 'getModel', 'getCapability', 'hasCapability'] ); - mockType = jasmine.createSpyObj('type', [ 'instanceOf' ]); + mockType = jasmine.createSpyObj('type', ['instanceOf']); mockExportService = jasmine.createSpyObj( 'exportService', - [ 'exportCSV' ] + ['exportCSV'] ); mockNotificationService = jasmine.createSpyObj( 'notificationService', - [ 'notify', 'error' ] + ['notify', 'error'] ); mockNotification = jasmine.createSpyObj( 'notification', - [ 'dismiss' ] + ['dismiss'] ); mockNotificationService.notify.andReturn(mockNotification); @@ -150,4 +149,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/actions/ExportTimelineAsCSVTaskSpec.js b/platform/features/timeline/test/actions/ExportTimelineAsCSVTaskSpec.js index 7979104ee5..0330e86397 100644 --- a/platform/features/timeline/test/actions/ExportTimelineAsCSVTaskSpec.js +++ b/platform/features/timeline/test/actions/ExportTimelineAsCSVTaskSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/actions/ExportTimelineAsCSVTask'], function (ExportTimelineAsCSVTask) { - 'use strict'; // Note that most responsibility is delegated to helper // classes, so testing here is minimal. @@ -36,7 +34,7 @@ define( beforeEach(function () { mockExportService = jasmine.createSpyObj( 'exportService', - [ 'exportCSV' ] + ['exportCSV'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', diff --git a/platform/features/timeline/test/actions/IdColumnSpec.js b/platform/features/timeline/test/actions/IdColumnSpec.js index a12b6145a9..f44d255255 100644 --- a/platform/features/timeline/test/actions/IdColumnSpec.js +++ b/platform/features/timeline/test/actions/IdColumnSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/actions/IdColumn'], @@ -43,7 +42,7 @@ define( testId = "foo"; mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getModel', 'getCapability' ] + ['getId', 'getModel', 'getCapability'] ); mockDomainObject.getId.andReturn(testId); }); @@ -56,4 +55,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/actions/MetadataColumnSpec.js b/platform/features/timeline/test/actions/MetadataColumnSpec.js index ba38fc83c0..da98df5040 100644 --- a/platform/features/timeline/test/actions/MetadataColumnSpec.js +++ b/platform/features/timeline/test/actions/MetadataColumnSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/actions/MetadataColumn'], @@ -45,7 +44,7 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getModel', 'getCapability', 'useCapability' ] + ['getId', 'getModel', 'getCapability', 'useCapability'] ); testMetadata = [ { name: "Something else", value: 123 }, @@ -73,4 +72,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/actions/ModeColumnSpec.js b/platform/features/timeline/test/actions/ModeColumnSpec.js index ab15d696c2..446e3b1030 100644 --- a/platform/features/timeline/test/actions/ModeColumnSpec.js +++ b/platform/features/timeline/test/actions/ModeColumnSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/actions/ModeColumn'], @@ -45,11 +44,11 @@ define( beforeEach(function () { mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getModel', 'getCapability' ] + ['getId', 'getModel', 'getCapability'] ); testModel = { relationships: { - modes: [ 'a', 'b', 'c', 'd', 'e', 'f' ] + modes: ['a', 'b', 'c', 'd', 'e', 'f'] } }; mockDomainObject.getModel.andReturn(testModel); @@ -61,7 +60,7 @@ define( }); it("returns nothing when relationships are exceeded", function () { - testModel.relationships.modes = [ 'foo' ]; + testModel.relationships.modes = ['foo']; expect(column.value(mockDomainObject)).toEqual(""); }); @@ -73,4 +72,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/actions/TimelineColumnizerSpec.js b/platform/features/timeline/test/actions/TimelineColumnizerSpec.js index 9eacf4f3b3..d29bb14278 100644 --- a/platform/features/timeline/test/actions/TimelineColumnizerSpec.js +++ b/platform/features/timeline/test/actions/TimelineColumnizerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/actions/TimelineColumnizer'], @@ -51,7 +50,7 @@ define( beforeEach(function () { var mockTimespan = jasmine.createSpyObj( 'timespan', - [ 'getStart', 'getEnd' ] + ['getStart', 'getEnd'] ); testMetadata = [ @@ -60,8 +59,8 @@ define( ]; mockDomainObjects = [ - { composition: [ 'a', 'b', 'c' ] }, - { relationships: { modes: [ 'x', 'y' ] } }, + { composition: ['a', 'b', 'c'] }, + { relationships: { modes: ['x', 'y'] } }, { } ].map(makeMockDomainObject); diff --git a/platform/features/timeline/test/actions/TimelineTraverserSpec.js b/platform/features/timeline/test/actions/TimelineTraverserSpec.js index 6962373ff9..e6000c6c62 100644 --- a/platform/features/timeline/test/actions/TimelineTraverserSpec.js +++ b/platform/features/timeline/test/actions/TimelineTraverserSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define([ "../../src/actions/TimelineTraverser" ], function (TimelineTraverser) { - 'use strict'; describe("TimelineTraverser", function () { var testModels, @@ -57,8 +55,8 @@ define([ if (!!model.composition) { mockDomainObject.useCapability.andCallFake(function (c) { return c === 'composition' && - Promise.resolve(model.composition.map(function (id) { - return mockDomainObjects[id]; + Promise.resolve(model.composition.map(function (cid) { + return mockDomainObjects[cid]; })); }); } @@ -70,8 +68,8 @@ define([ ); mockRelationships.getRelatedObjects.andCallFake(function (k) { var ids = model.relationships[k] || []; - return Promise.resolve(ids.map(function (id) { - return mockDomainObjects[id]; + return Promise.resolve(ids.map(function (objId) { + return mockDomainObjects[objId]; })); }); mockDomainObject.getCapability.andCallFake(function (c) { @@ -84,9 +82,9 @@ define([ beforeEach(function () { testModels = { - a: { composition: [ 'b', 'c' ]}, - b: { composition: [ 'c' ] }, - c: { relationships: { modes: [ 'd' ] } }, + a: { composition: ['b', 'c']}, + b: { composition: ['c'] }, + c: { relationships: { modes: ['d'] } }, d: {}, unreachable: {} }; @@ -134,4 +132,4 @@ define([ }); }); -}); \ No newline at end of file +}); diff --git a/platform/features/timeline/test/actions/TimespanColumnSpec.js b/platform/features/timeline/test/actions/TimespanColumnSpec.js index f4970b778e..efe8df8bff 100644 --- a/platform/features/timeline/test/actions/TimespanColumnSpec.js +++ b/platform/features/timeline/test/actions/TimespanColumnSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/actions/TimespanColumn', '../../src/TimelineFormatter'], @@ -37,11 +36,11 @@ define( }; mockTimespan = jasmine.createSpyObj( 'timespan', - [ 'getStart', 'getEnd' ] + ['getStart', 'getEnd'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'useCapability', 'hasCapability' ] + ['useCapability', 'hasCapability'] ); mockTimespan.getStart.andReturn(testTimes.start); mockTimespan.getEnd.andReturn(testTimes.end); @@ -53,7 +52,7 @@ define( }); }); - [ "start", "end" ].forEach(function (bound) { + ["start", "end"].forEach(function (bound) { describe("when referring to " + bound + " times", function () { var name = bound.charAt(0).toUpperCase() + bound.slice(1); @@ -91,4 +90,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/capabilities/ActivityTimespanCapabilitySpec.js b/platform/features/timeline/test/capabilities/ActivityTimespanCapabilitySpec.js index a3feb78c15..dcd2170bb6 100644 --- a/platform/features/timeline/test/capabilities/ActivityTimespanCapabilitySpec.js +++ b/platform/features/timeline/test/capabilities/ActivityTimespanCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/ActivityTimespanCapability'], function (ActivityTimespanCapability) { - 'use strict'; describe("An Activity's timespan capability", function () { var mockQ, @@ -43,7 +41,7 @@ define( mockQ = jasmine.createSpyObj('$q', ['when']); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getModel', 'getCapability' ] + ['getModel', 'getCapability'] ); mockQ.when.andCallFake(asPromise); diff --git a/platform/features/timeline/test/capabilities/ActivityTimespanSpec.js b/platform/features/timeline/test/capabilities/ActivityTimespanSpec.js index 2254fb29dd..837f0fd726 100644 --- a/platform/features/timeline/test/capabilities/ActivityTimespanSpec.js +++ b/platform/features/timeline/test/capabilities/ActivityTimespanSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/ActivityTimespan'], function (ActivityTimespan) { - 'use strict'; describe("An Activity's timespan", function () { var testModel, @@ -98,4 +96,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/capabilities/ActivityUtilizationSpec.js b/platform/features/timeline/test/capabilities/ActivityUtilizationSpec.js index ec453b9953..74ab27fb50 100644 --- a/platform/features/timeline/test/capabilities/ActivityUtilizationSpec.js +++ b/platform/features/timeline/test/capabilities/ActivityUtilizationSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/ActivityUtilization'], function (ActivityUtilization) { - 'use strict'; describe("An Activity's resource utilization", function () { @@ -38,4 +36,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/capabilities/CostCapabilitySpec.js b/platform/features/timeline/test/capabilities/CostCapabilitySpec.js index ca1db9c74f..3134d1ea58 100644 --- a/platform/features/timeline/test/capabilities/CostCapabilitySpec.js +++ b/platform/features/timeline/test/capabilities/CostCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/CostCapability'], function (CostCapability) { - 'use strict'; describe("A subsystem mode's cost capability", function () { var testModel, @@ -33,7 +31,7 @@ define( beforeEach(function () { var mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getModel', 'getId' ] + ['getModel', 'getId'] ); testModel = { diff --git a/platform/features/timeline/test/capabilities/CumulativeGraphSpec.js b/platform/features/timeline/test/capabilities/CumulativeGraphSpec.js index 3f19161414..0dacf2436c 100644 --- a/platform/features/timeline/test/capabilities/CumulativeGraphSpec.js +++ b/platform/features/timeline/test/capabilities/CumulativeGraphSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/CumulativeGraph'], function (CumulativeGraph) { - 'use strict'; describe("A cumulative resource graph", function () { var mockGraph, @@ -32,11 +30,11 @@ define( graph; beforeEach(function () { - points = [ 0, 10, -10, -100, 20, 100, 0 ]; + points = [0, 10, -10, -100, 20, 100, 0]; mockGraph = jasmine.createSpyObj( 'graph', - [ 'getPointCount', 'getDomainValue', 'getRangeValue' ] + ['getPointCount', 'getDomainValue', 'getRangeValue'] ); mockGraph.getPointCount.andReturn(points.length * 2); @@ -85,4 +83,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/capabilities/GraphCapabilitySpec.js b/platform/features/timeline/test/capabilities/GraphCapabilitySpec.js index fc880cbd94..bffbe21bad 100644 --- a/platform/features/timeline/test/capabilities/GraphCapabilitySpec.js +++ b/platform/features/timeline/test/capabilities/GraphCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/GraphCapability'], function (GraphCapability) { - 'use strict'; describe("A Timeline's graph capability", function () { var mockQ, @@ -44,7 +42,7 @@ define( mockQ = jasmine.createSpyObj('$q', ['when']); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getModel', 'useCapability' ] + ['getId', 'getModel', 'useCapability'] ); testModel = { diff --git a/platform/features/timeline/test/capabilities/ResourceGraphSpec.js b/platform/features/timeline/test/capabilities/ResourceGraphSpec.js index 16744704ad..ed4acbc0fc 100644 --- a/platform/features/timeline/test/capabilities/ResourceGraphSpec.js +++ b/platform/features/timeline/test/capabilities/ResourceGraphSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/ResourceGraph'], function (ResourceGraph) { - 'use strict'; describe("A resource graph capability", function () { @@ -45,14 +43,14 @@ define( expect(graph.getPointCount()).toEqual(16); // Should get two values at every time stamp, for step-like appearance - [ 5, 15, 40, 50, 100, 120, 150, 180].forEach(function (v, i) { + [5, 15, 40, 50, 100, 120, 150, 180].forEach(function (v, i) { expect(graph.getDomainValue(i * 2)).toEqual(v); expect(graph.getDomainValue(i * 2 + 1)).toEqual(v); }); // Should also repeat values at subsequent indexes, but offset differently, // for horizontal spans between steps - [ 0, 42, 72, 42, 20, -22, 0, -10].forEach(function (v, i) { + [0, 42, 72, 42, 20, -22, 0, -10].forEach(function (v, i) { expect(graph.getRangeValue(i * 2)).toEqual(v); // Offset backwards; wrap around end of the series expect(graph.getRangeValue((16 + i * 2 - 1) % 16)).toEqual(v); @@ -74,4 +72,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/capabilities/TimelineTimespanCapabilitySpec.js b/platform/features/timeline/test/capabilities/TimelineTimespanCapabilitySpec.js index 2de3186889..27b8bb2436 100644 --- a/platform/features/timeline/test/capabilities/TimelineTimespanCapabilitySpec.js +++ b/platform/features/timeline/test/capabilities/TimelineTimespanCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/TimelineTimespanCapability'], function (TimelineTimespanCapability) { - 'use strict'; describe("A Timeline's timespan capability", function () { var mockQ, @@ -47,30 +45,34 @@ define( mockQ = jasmine.createSpyObj('$q', ['when', 'all']); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getModel', 'getCapability', 'useCapability' ] + ['getModel', 'getCapability', 'useCapability'] ); mockChildA = jasmine.createSpyObj( 'childA', - [ 'getModel', 'useCapability', 'hasCapability' ] + ['getModel', 'useCapability', 'hasCapability'] ); mockChildB = jasmine.createSpyObj( 'childA', - [ 'getModel', 'useCapability', 'hasCapability' ] + ['getModel', 'useCapability', 'hasCapability'] ); mockTimespanA = jasmine.createSpyObj( 'timespanA', - [ 'getEnd' ] + ['getEnd'] ); mockTimespanB = jasmine.createSpyObj( 'timespanB', - [ 'getEnd' ] + ['getEnd'] ); mockQ.when.andCallFake(asPromise); mockQ.all.andCallFake(function (values) { var result = []; - function addResult(v) { result.push(v); } - function promiseResult(v) { asPromise(v).then(addResult); } + function addResult(v) { + result.push(v); + } + function promiseResult(v) { + asPromise(v).then(addResult); + } values.forEach(promiseResult); return asPromise(result); }); @@ -85,7 +87,7 @@ define( }); mockDomainObject.useCapability.andCallFake(function (c) { if (c === 'composition') { - return asPromise([ mockChildA, mockChildB ]); + return asPromise([mockChildA, mockChildB]); } }); mockChildA.hasCapability.andReturn(true); diff --git a/platform/features/timeline/test/capabilities/TimelineTimespanSpec.js b/platform/features/timeline/test/capabilities/TimelineTimespanSpec.js index 41c46c53a7..2d33035913 100644 --- a/platform/features/timeline/test/capabilities/TimelineTimespanSpec.js +++ b/platform/features/timeline/test/capabilities/TimelineTimespanSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/TimelineTimespan'], function (TimelineTimespan) { - 'use strict'; describe("A Timeline's timespan", function () { var testModel, @@ -53,7 +51,7 @@ define( mutationModel = JSON.parse(JSON.stringify(testModel)); mockMutation = jasmine.createSpyObj("mutation", ["mutate"]); - mockTimespans = [ 44000, 65000, 1100 ].map(makeMockTimespan); + mockTimespans = [44000, 65000, 1100].map(makeMockTimespan); mockMutation.mutate.andCallFake(function (mutator) { mutator(mutationModel); @@ -109,4 +107,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/capabilities/TimelineUtilizationSpec.js b/platform/features/timeline/test/capabilities/TimelineUtilizationSpec.js index 4282e1ab8d..0fd44795b4 100644 --- a/platform/features/timeline/test/capabilities/TimelineUtilizationSpec.js +++ b/platform/features/timeline/test/capabilities/TimelineUtilizationSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/TimelineUtilization'], function (TimelineUtilization) { - 'use strict'; describe("A Timeline's resource utilization", function () { @@ -38,4 +36,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/capabilities/UtilizationCapabilitySpec.js b/platform/features/timeline/test/capabilities/UtilizationCapabilitySpec.js index eda895bb60..0c37f3edae 100644 --- a/platform/features/timeline/test/capabilities/UtilizationCapabilitySpec.js +++ b/platform/features/timeline/test/capabilities/UtilizationCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/capabilities/UtilizationCapability'], function (UtilizationCapability) { - 'use strict'; describe("A Timeline's utilization capability", function () { var mockQ, @@ -71,8 +69,8 @@ define( resources: function () { return Object.keys(costs).sort(); }, - cost: function (c) { - return costs[c]; + cost: function (k) { + return costs[k]; } }); }, @@ -86,15 +84,15 @@ define( mockQ = jasmine.createSpyObj('$q', ['when', 'all']); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getModel', 'getCapability', 'useCapability' ] + ['getId', 'getModel', 'getCapability', 'useCapability'] ); mockRelationship = jasmine.createSpyObj( 'relationship', - [ 'getRelatedObjects' ] + ['getRelatedObjects'] ); mockComposition = jasmine.createSpyObj( 'composition', - [ 'invoke' ] + ['invoke'] ); mockCallback = jasmine.createSpy('callback'); diff --git a/platform/features/timeline/test/controllers/ActivityModeValuesControllerSpec.js b/platform/features/timeline/test/controllers/ActivityModeValuesControllerSpec.js index b731c414ac..d6eb96d81b 100644 --- a/platform/features/timeline/test/controllers/ActivityModeValuesControllerSpec.js +++ b/platform/features/timeline/test/controllers/ActivityModeValuesControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/controllers/ActivityModeValuesController'], function (ActivityModeValuesController) { - 'use strict'; describe("An Activity Mode's Values view controller", function () { var testResources, @@ -50,4 +48,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/TimelineControllerSpec.js b/platform/features/timeline/test/controllers/TimelineControllerSpec.js index 0f20165ae8..9e777b0d8e 100644 --- a/platform/features/timeline/test/controllers/TimelineControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/controllers/TimelineController'], function (TimelineController) { - 'use strict'; var DOMAIN_OBJECT_METHODS = [ 'getModel', @@ -101,7 +99,7 @@ define( mockScope = jasmine.createSpyObj( "$scope", - [ '$watch', '$on' ] + ['$watch', '$on'] ); mockLoader = jasmine.createSpyObj('objectLoader', ['load']); mockDomainObject = mockA; @@ -247,4 +245,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/TimelineDateTimeControllerSpec.js b/platform/features/timeline/test/controllers/TimelineDateTimeControllerSpec.js index d39b47caf5..d5e75dff6f 100644 --- a/platform/features/timeline/test/controllers/TimelineDateTimeControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineDateTimeControllerSpec.js @@ -20,12 +20,10 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ["../../src/controllers/TimelineDateTimeController"], function (TimelineDateTimeController) { - "use strict"; describe("The date-time controller for timeline creation", function () { var mockScope, diff --git a/platform/features/timeline/test/controllers/TimelineGanttControllerSpec.js b/platform/features/timeline/test/controllers/TimelineGanttControllerSpec.js index c573d02ed5..c7f16077fa 100644 --- a/platform/features/timeline/test/controllers/TimelineGanttControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineGanttControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/controllers/TimelineGanttController'], function (TimelineGanttController) { - "use strict"; var TEST_MAX_OFFSCREEN = 50; @@ -63,7 +61,9 @@ define( mockTimespan.getDuration.andReturn(50); mockTimespan.getEnd.andReturn(150); - mockToPixels.andCallFake(function (t) { return t * 10; }); + mockToPixels.andCallFake(function (t) { + return t * 10; + }); controller = new TimelineGanttController(TEST_MAX_OFFSCREEN); }); @@ -98,4 +98,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/TimelineGraphControllerSpec.js b/platform/features/timeline/test/controllers/TimelineGraphControllerSpec.js index 9d74832cdb..51e9de94a4 100644 --- a/platform/features/timeline/test/controllers/TimelineGraphControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineGraphControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/controllers/TimelineGraphController'], function (TimelineGraphController) { - 'use strict'; describe("The Timeline graph controller", function () { var mockScope, @@ -34,7 +32,7 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( '$scope', - [ '$watchCollection' ] + ['$watchCollection'] ); testResources = [ { key: 'abc', name: "Some name" }, @@ -60,7 +58,7 @@ define( // Supply new parameters mockScope.$watchCollection.mostRecentCall.args[1]({ - graphs: [ mockGraphA, mockGraphB ], + graphs: [mockGraphA, mockGraphB], origin: 9, duration: 144 }); diff --git a/platform/features/timeline/test/controllers/TimelineTableControllerSpec.js b/platform/features/timeline/test/controllers/TimelineTableControllerSpec.js index f97390bdb4..bb66becf27 100644 --- a/platform/features/timeline/test/controllers/TimelineTableControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineTableControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( [ @@ -27,7 +26,6 @@ define( '../../src/TimelineFormatter' ], function (TimelineTableController, TimelineFormatter) { - "use strict"; describe("The timeline table controller", function () { var formatter, controller; @@ -40,7 +38,7 @@ define( // This controller's job is just to expose the formatter // in scope, so simply verify that the two agree. it("formats durations", function () { - [ 0, 100, 4123, 93600, 748801230012].forEach(function (n) { + [0, 100, 4123, 93600, 748801230012].forEach(function (n) { expect(controller.niceTime(n)) .toEqual(formatter.format(n)); }); diff --git a/platform/features/timeline/test/controllers/TimelineTickControllerSpec.js b/platform/features/timeline/test/controllers/TimelineTickControllerSpec.js index ca3063a0d9..ddb53204a5 100644 --- a/platform/features/timeline/test/controllers/TimelineTickControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineTickControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/controllers/TimelineTickController', '../../src/TimelineFormatter'], function (TimelineTickController, TimelineFormatter) { - 'use strict'; var BILLION = 1000000000, FORMATTER = new TimelineFormatter(); @@ -85,4 +83,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/TimelineZoomControllerSpec.js b/platform/features/timeline/test/controllers/TimelineZoomControllerSpec.js index 1c86d75599..1365fca7d6 100644 --- a/platform/features/timeline/test/controllers/TimelineZoomControllerSpec.js +++ b/platform/features/timeline/test/controllers/TimelineZoomControllerSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/controllers/TimelineZoomController'], function (TimelineZoomController) { - 'use strict'; describe("The timeline zoom state controller", function () { var testConfiguration, @@ -84,11 +82,20 @@ define( it("persists zoom changes in Edit mode", function () { mockScope.domainObject = jasmine.createSpyObj( 'domainObject', - ['hasCapability'] + ['hasCapability', 'getCapability'] ); mockScope.domainObject.hasCapability.andCallFake(function (c) { return c === 'editor'; }); + mockScope.domainObject.getCapability.andCallFake(function (c) { + if (c === 'editor') { + return { + inEditContext: function () { + return true; + } + }; + } + }); controller.zoom(1); expect(mockScope.commit).toHaveBeenCalled(); expect(mockScope.configuration.zoomLevel) diff --git a/platform/features/timeline/test/controllers/drag/TimelineDragHandleFactorySpec.js b/platform/features/timeline/test/controllers/drag/TimelineDragHandleFactorySpec.js index 8528b3c68d..1ef3fe6733 100644 --- a/platform/features/timeline/test/controllers/drag/TimelineDragHandleFactorySpec.js +++ b/platform/features/timeline/test/controllers/drag/TimelineDragHandleFactorySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/drag/TimelineDragHandleFactory'], function (TimelineDragHandleFactory) { - 'use strict'; describe("A Timeline drag handle factory", function () { var mockDragHandler, @@ -37,19 +35,19 @@ define( beforeEach(function () { mockDragHandler = jasmine.createSpyObj( 'dragHandler', - [ 'start' ] + ['start'] ); mockSnapHandler = jasmine.createSpyObj( 'snapHandler', - [ 'snap' ] + ['snap'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getCapability', 'getId' ] + ['getCapability', 'getId'] ); mockType = jasmine.createSpyObj( 'type', - [ 'instanceOf' ] + ['instanceOf'] ); mockDomainObject.getId.andReturn('test-id'); diff --git a/platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js b/platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js index b6ddd364c0..1e62983437 100644 --- a/platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js +++ b/platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/drag/TimelineDragHandler'], function (TimelineDragHandler) { - 'use strict'; describe("A Timeline drag handler", function () { var mockLoader, @@ -58,22 +56,22 @@ define( } function makeMockDomainObject(id, composition) { - var mockDomainObject = jasmine.createSpyObj( + var mockDomainObj = jasmine.createSpyObj( 'domainObject-' + id, ['getId', 'getModel', 'getCapability', 'useCapability'] ); - mockDomainObject.getId.andReturn(id); - mockDomainObject.getModel.andReturn({ composition: composition }); - mockDomainObject.useCapability.andReturn(asPromise(mockTimespans[id])); - mockDomainObject.getCapability.andCallFake(function (c) { + mockDomainObj.getId.andReturn(id); + mockDomainObj.getModel.andReturn({ composition: composition }); + mockDomainObj.useCapability.andReturn(asPromise(mockTimespans[id])); + mockDomainObj.getCapability.andCallFake(function (c) { return { persistence: mockPersists[id], mutation: mockMutations[id] }[c]; }); - return mockDomainObject; + return mockDomainObj; } beforeEach(function () { @@ -83,15 +81,15 @@ define( ['a', 'b', 'c', 'd', 'e', 'f'].forEach(function (id, index) { mockTimespans[id] = jasmine.createSpyObj( 'timespan-' + id, - [ 'getStart', 'getEnd', 'getDuration', 'setStart', 'setEnd', 'setDuration' ] + ['getStart', 'getEnd', 'getDuration', 'setStart', 'setEnd', 'setDuration'] ); mockPersists[id] = jasmine.createSpyObj( 'persistence-' + id, - [ 'persist' ] + ['persist'] ); mockMutations[id] = jasmine.createSpyObj( 'mutation-' + id, - [ 'mutate' ] + ['mutate'] ); mockTimespans[id].getStart.andReturn(index * 1000); mockTimespans[id].getDuration.andReturn(4000 + index); @@ -227,4 +225,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/drag/TimelineDragPopulatorSpec.js b/platform/features/timeline/test/controllers/drag/TimelineDragPopulatorSpec.js index 1a120a8fbb..bfb2176e18 100644 --- a/platform/features/timeline/test/controllers/drag/TimelineDragPopulatorSpec.js +++ b/platform/features/timeline/test/controllers/drag/TimelineDragPopulatorSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/drag/TimelineDragPopulator'], function (TimelineDragPopulator) { - "use strict"; describe("The timeline drag populator", function () { var mockObjectLoader, @@ -71,4 +69,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/drag/TimelineEndHandleSpec.js b/platform/features/timeline/test/controllers/drag/TimelineEndHandleSpec.js index 85c06f22cb..aa87903c48 100644 --- a/platform/features/timeline/test/controllers/drag/TimelineEndHandleSpec.js +++ b/platform/features/timeline/test/controllers/drag/TimelineEndHandleSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/drag/TimelineEndHandle', '../../../src/TimelineConstants'], function (TimelineEndHandle, TimelineConstants) { - 'use strict'; describe("A Timeline end drag handle", function () { var mockDragHandler, @@ -35,15 +33,15 @@ define( beforeEach(function () { mockDragHandler = jasmine.createSpyObj( 'dragHandler', - [ 'end', 'persist' ] + ['end', 'persist'] ); mockSnapHandler = jasmine.createSpyObj( 'snapHandler', - [ 'snap' ] + ['snap'] ); mockZoomController = jasmine.createSpyObj( 'zoom', - [ 'toMillis', 'toPixels' ] + ['toMillis', 'toPixels'] ); mockDragHandler.end.andReturn(12321); @@ -114,4 +112,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/drag/TimelineMoveHandleSpec.js b/platform/features/timeline/test/controllers/drag/TimelineMoveHandleSpec.js index 2f49bfb8bf..fbce2d8212 100644 --- a/platform/features/timeline/test/controllers/drag/TimelineMoveHandleSpec.js +++ b/platform/features/timeline/test/controllers/drag/TimelineMoveHandleSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/drag/TimelineMoveHandle', '../../../src/TimelineConstants'], function (TimelineMoveHandle, TimelineConstants) { - 'use strict'; describe("A Timeline move drag handle", function () { var mockDragHandler, @@ -35,15 +33,15 @@ define( beforeEach(function () { mockDragHandler = jasmine.createSpyObj( 'dragHandler', - [ 'start', 'duration', 'end', 'move', 'persist' ] + ['start', 'duration', 'end', 'move', 'persist'] ); mockSnapHandler = jasmine.createSpyObj( 'snapHandler', - [ 'snap' ] + ['snap'] ); mockZoomController = jasmine.createSpyObj( 'zoom', - [ 'toMillis', 'toPixels' ] + ['toMillis', 'toPixels'] ); mockDragHandler.start.andReturn(12321); @@ -181,4 +179,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/drag/TimelineSnapHandlerSpec.js b/platform/features/timeline/test/controllers/drag/TimelineSnapHandlerSpec.js index 780bd7c999..36fb30188b 100644 --- a/platform/features/timeline/test/controllers/drag/TimelineSnapHandlerSpec.js +++ b/platform/features/timeline/test/controllers/drag/TimelineSnapHandlerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/drag/TimelineSnapHandler'], function (TimelineSnapHandler) { - 'use strict'; describe("A Timeline snap handler", function () { var mockDragHandler, @@ -36,7 +34,7 @@ define( mockDragHandler = jasmine.createSpyObj( 'dragHandler', - [ 'start', 'end', 'ids' ] + ['start', 'end', 'ids'] ); mockDragHandler.ids.andReturn(['a', 'b', 'c', 'd']); @@ -78,4 +76,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/drag/TimelineStartHandleSpec.js b/platform/features/timeline/test/controllers/drag/TimelineStartHandleSpec.js index b036bf93f9..de7d3cb643 100644 --- a/platform/features/timeline/test/controllers/drag/TimelineStartHandleSpec.js +++ b/platform/features/timeline/test/controllers/drag/TimelineStartHandleSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/drag/TimelineStartHandle', '../../../src/TimelineConstants'], function (TimelineStartHandle, TimelineConstants) { - 'use strict'; describe("A Timeline start drag handle", function () { var mockDragHandler, @@ -35,15 +33,15 @@ define( beforeEach(function () { mockDragHandler = jasmine.createSpyObj( 'dragHandler', - [ 'start', 'persist' ] + ['start', 'persist'] ); mockSnapHandler = jasmine.createSpyObj( 'snapHandler', - [ 'snap' ] + ['snap'] ); mockZoomController = jasmine.createSpyObj( 'zoom', - [ 'toMillis', 'toPixels' ] + ['toMillis', 'toPixels'] ); mockDragHandler.start.andReturn(12321); @@ -113,4 +111,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/graph/TimelineGraphPopulatorSpec.js b/platform/features/timeline/test/controllers/graph/TimelineGraphPopulatorSpec.js index 2fd042dc47..69a5148b59 100644 --- a/platform/features/timeline/test/controllers/graph/TimelineGraphPopulatorSpec.js +++ b/platform/features/timeline/test/controllers/graph/TimelineGraphPopulatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/graph/TimelineGraphPopulator'], function (TimelineGraphPopulator) { - 'use strict'; describe("A Timeline's resource graph populator", function () { var mockSwimlanes, @@ -50,9 +48,9 @@ define( beforeEach(function () { testResources = { - a: [ 'xyz', 'abc' ], - b: [ 'xyz' ], - c: [ 'xyz', 'abc', 'def', 'ghi' ] + a: ['xyz', 'abc'], + b: ['xyz'], + c: ['xyz', 'abc', 'def', 'ghi'] }; mockQ = jasmine.createSpyObj('$q', ['when', 'all']); @@ -60,16 +58,16 @@ define( mockSwimlanes = ['a', 'b', 'c'].map(function (k) { var mockSwimlane = jasmine.createSpyObj( 'swimlane-' + k, - [ 'graph', 'color' ] + ['graph', 'color'] ), mockGraph = jasmine.createSpyObj( 'graph-' + k, - [ 'getPointCount', 'getDomainValue', 'getRangeValue' ] + ['getPointCount', 'getDomainValue', 'getRangeValue'] ); mockSwimlane.graph.andReturn(true); mockSwimlane.domainObject = jasmine.createSpyObj( 'domainObject-' + k, - [ 'getCapability', 'hasCapability', 'useCapability', 'getId' ] + ['getCapability', 'hasCapability', 'useCapability', 'getId'] ); mockSwimlane.color.andReturn('#' + k); // Provide just enough information about graphs to support @@ -150,4 +148,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/graph/TimelineGraphRendererSpec.js b/platform/features/timeline/test/controllers/graph/TimelineGraphRendererSpec.js index bbaa721bb5..74e9e18e79 100644 --- a/platform/features/timeline/test/controllers/graph/TimelineGraphRendererSpec.js +++ b/platform/features/timeline/test/controllers/graph/TimelineGraphRendererSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/graph/TimelineGraphRenderer'], function (TimelineGraphRenderer) { - 'use strict'; describe("A Timeline's graph renderer", function () { var renderer; @@ -74,4 +72,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/graph/TimelineGraphSpec.js b/platform/features/timeline/test/controllers/graph/TimelineGraphSpec.js index 5240fc1152..305da86334 100644 --- a/platform/features/timeline/test/controllers/graph/TimelineGraphSpec.js +++ b/platform/features/timeline/test/controllers/graph/TimelineGraphSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/graph/TimelineGraph'], function (TimelineGraph) { - 'use strict'; describe("A Timeline's resource graph", function () { var mockDomainObjects, @@ -44,9 +42,9 @@ define( beforeEach(function () { testColors = { - a: [ 0, 1, 0 ], - b: [ 1, 0, 1 ], - c: [ 1, 0, 0 ] + a: [0, 1, 0], + b: [1, 0, 1], + c: [1, 0, 0] }; mockGraphs = []; @@ -55,11 +53,11 @@ define( ['a', 'b', 'c'].forEach(function (k, i) { var mockGraph = jasmine.createSpyObj( 'utilization-' + k, - [ 'getPointCount', 'getDomainValue', 'getRangeValue' ] + ['getPointCount', 'getDomainValue', 'getRangeValue'] ); mockDomainObjects[k] = jasmine.createSpyObj( 'domainObject-' + k, - [ 'getCapability', 'useCapability' ] + ['getCapability', 'useCapability'] ); mockDomainObjects[k].useCapability.andReturn(asPromise({ testResource: mockGraph @@ -74,7 +72,7 @@ define( mockRenderer = jasmine.createSpyObj( 'renderer', - [ 'render', 'decode' ] + ['render', 'decode'] ); mockRenderer.render.andCallFake(function (utilization) { @@ -169,4 +167,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineColorAssignerSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineColorAssignerSpec.js index beb3886f2d..5848c25deb 100644 --- a/platform/features/timeline/test/controllers/swimlane/TimelineColorAssignerSpec.js +++ b/platform/features/timeline/test/controllers/swimlane/TimelineColorAssignerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/swimlane/TimelineColorAssigner'], function (TimelineColorAssigner) { - 'use strict'; describe("The Timeline legend color assigner", function () { var testConfiguration, @@ -51,10 +49,14 @@ define( var colors = {}, i, ids = []; // Add item to set - function set(c) { colors[c] = true; } + function set(c) { + colors[c] = true; + } // Generate ids - for (i = 0; i < 30; i += 1) { ids.push("id" + i); } + for (i = 0; i < 30; i += 1) { + ids.push("id" + i); + } // Assign colors to each id, then retrieve colors, // storing into the set diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineProxySpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineProxySpec.js index 7d137fa6e4..7490d61346 100644 --- a/platform/features/timeline/test/controllers/swimlane/TimelineProxySpec.js +++ b/platform/features/timeline/test/controllers/swimlane/TimelineProxySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/swimlane/TimelineProxy'], function (TimelineProxy) { - 'use strict'; describe("The Timeline's selection proxy", function () { var mockDomainObject, @@ -40,16 +38,16 @@ define( ); mockSelection = jasmine.createSpyObj( 'selection', - [ 'get' ] + ['get'] ); mockActionCapability = jasmine.createSpyObj( 'action', - [ 'getActions' ] + ['getActions'] ); mockActions = ['a', 'b', 'c'].map(function (type) { var mockAction = jasmine.createSpyObj( 'action-' + type, - [ 'perform', 'getMetadata' ] + ['perform', 'getMetadata'] ); mockAction.getMetadata.andReturn({ type: type }); return mockAction; diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDecoratorSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDecoratorSpec.js index c76920f2a0..56fb532f27 100644 --- a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDecoratorSpec.js +++ b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDecoratorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/swimlane/TimelineSwimlaneDecorator'], function (TimelineSwimlaneDecorator) { - 'use strict'; describe("A Timeline swimlane decorator", function () { var mockSwimlane, @@ -45,7 +43,7 @@ define( mockSwimlane.domainObject = jasmine.createSpyObj( 'domainObject', - [ 'getCapability', 'getModel' ] + ['getCapability', 'getModel'] ); mockCapabilities.mutation = jasmine.createSpyObj( @@ -160,11 +158,11 @@ define( it("fires the 'remove' action when remove is called", function () { var mockChild = jasmine.createSpyObj( 'childObject', - [ 'getCapability', 'getModel' ] + ['getCapability', 'getModel'] ), mockAction = jasmine.createSpyObj( 'action', - [ 'perform' ] + ['perform'] ); mockChild.getCapability.andCallFake(function (c) { diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js index 14bff75a16..ebb01159c9 100644 --- a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js +++ b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js @@ -19,17 +19,16 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/swimlane/TimelineSwimlaneDropHandler'], function (TimelineSwimlaneDropHandler) { - "use strict"; describe("A timeline's swimlane drop handler", function () { var mockSwimlane, mockOtherObject, mockActionCapability, + mockEditorCapability, mockPersistence, mockContext, mockAction, @@ -38,30 +37,32 @@ define( beforeEach(function () { var mockPromise = jasmine.createSpyObj('promise', ['then']); + mockEditorCapability = jasmine.createSpyObj('editorCapability', ['inEditContext']); + mockSwimlane = jasmine.createSpyObj( "swimlane", - [ "highlight", "highlightBottom" ] + ["highlight", "highlightBottom"] ); // domainObject, idPath, children, expanded mockSwimlane.domainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "useCapability", "hasCapability" ] + ["getId", "getCapability", "useCapability", "hasCapability"] ); - mockSwimlane.idPath = [ 'a', 'b' ]; - mockSwimlane.children = [ {} ]; + mockSwimlane.idPath = ['a', 'b']; + mockSwimlane.children = [{}]; mockSwimlane.expanded = true; mockSwimlane.parent = {}; mockSwimlane.parent.idPath = ['a']; mockSwimlane.parent.domainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "useCapability", "hasCapability" ] + ["getId", "getCapability", "useCapability", "hasCapability"] ); - mockSwimlane.parent.children = [ mockSwimlane ]; + mockSwimlane.parent.children = [mockSwimlane]; mockSwimlane.children[0].domainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "useCapability", "hasCapability" ] + ["getId", "getCapability", "useCapability", "hasCapability"] ); mockAction = jasmine.createSpyObj('action', ['perform']); @@ -72,11 +73,11 @@ define( mockOtherObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "useCapability", "hasCapability" ] + ["getId", "getCapability", "useCapability", "hasCapability"] ); mockActionCapability = jasmine.createSpyObj("action", ["perform", "getActions"]); mockPersistence = jasmine.createSpyObj("persistence", ["persist"]); - mockContext = jasmine.createSpyObj('context', [ 'getParent' ]); + mockContext = jasmine.createSpyObj('context', ['getParent']); mockActionCapability.getActions.andReturn([mockAction]); mockSwimlane.parent.domainObject.getId.andReturn('a'); @@ -88,19 +89,22 @@ define( mockSwimlane.domainObject.getCapability.andCallFake(function (c) { return { action: mockActionCapability, - persistence: mockPersistence + persistence: mockPersistence, + editor: mockEditorCapability }[c]; }); mockSwimlane.parent.domainObject.getCapability.andCallFake(function (c) { return { action: mockActionCapability, - persistence: mockPersistence + persistence: mockPersistence, + editor: mockEditorCapability }[c]; }); mockOtherObject.getCapability.andCallFake(function (c) { return { action: mockActionCapability, - context: mockContext + context: mockContext, + editor: mockEditorCapability }[c]; }); mockContext.getParent.andReturn(mockOtherObject); @@ -111,13 +115,14 @@ define( }); it("disallows drop outside of edit mode", function () { + mockEditorCapability.inEditContext.andReturn(true); // Verify precondition expect(handler.allowDropIn('d', mockSwimlane.domainObject)) .toBeTruthy(); expect(handler.allowDropAfter('d', mockSwimlane.domainObject)) .toBeTruthy(); // Act as if we're not in edit mode - mockSwimlane.domainObject.hasCapability.andReturn(false); + mockEditorCapability.inEditContext.andReturn(false); // Now, they should be disallowed expect(handler.allowDropIn('d', mockSwimlane.domainObject)) .toBeFalsy(); @@ -147,7 +152,7 @@ define( }); it("inserts into when highlighted", function () { - var testModel = { composition: [ 'c' ] }; + var testModel = { composition: ['c'] }; mockSwimlane.highlight.andReturn(true); handler.drop('d', mockOtherObject); // Should have mutated @@ -162,7 +167,7 @@ define( }); it("inserts after as a peer when highlighted at the bottom", function () { - var testModel = { composition: [ 'x', 'b', 'y' ] }; + var testModel = { composition: ['x', 'b', 'y'] }; mockSwimlane.highlightBottom.andReturn(true); mockSwimlane.expanded = false; handler.drop('d', mockOtherObject); @@ -172,11 +177,11 @@ define( // Run the mutator mockSwimlane.parent.domainObject.useCapability.mostRecentCall .args[1](testModel); - expect(testModel.composition).toEqual([ 'x', 'b', 'd', 'y']); + expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']); }); it("inserts into when highlighted at the bottom and expanded", function () { - var testModel = { composition: [ 'c' ] }; + var testModel = { composition: ['c'] }; mockSwimlane.highlightBottom.andReturn(true); mockSwimlane.expanded = true; handler.drop('d', mockOtherObject); @@ -186,11 +191,11 @@ define( // Run the mutator mockSwimlane.domainObject.useCapability.mostRecentCall .args[1](testModel); - expect(testModel.composition).toEqual([ 'd', 'c' ]); + expect(testModel.composition).toEqual(['d', 'c']); }); it("inserts after as a peer when highlighted at the bottom and childless", function () { - var testModel = { composition: [ 'x', 'b', 'y' ] }; + var testModel = { composition: ['x', 'b', 'y'] }; mockSwimlane.highlightBottom.andReturn(true); mockSwimlane.expanded = true; mockSwimlane.children = []; @@ -201,11 +206,11 @@ define( // Run the mutator mockSwimlane.parent.domainObject.useCapability.mostRecentCall .args[1](testModel); - expect(testModel.composition).toEqual([ 'x', 'b', 'd', 'y']); + expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']); }); it("allows reordering within a parent", function () { - var testModel = { composition: [ 'x', 'b', 'y', 'd' ] }; + var testModel = { composition: ['x', 'b', 'y', 'd'] }; mockSwimlane.highlightBottom.andReturn(true); mockSwimlane.expanded = true; @@ -222,7 +227,7 @@ define( runs(function () { mockSwimlane.parent.domainObject.useCapability.mostRecentCall .args[1](testModel); - expect(testModel.composition).toEqual([ 'x', 'b', 'd', 'y']); + expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']); }); }); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlanePopulatorSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlanePopulatorSpec.js index 895ae34a79..f9358a514e 100644 --- a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlanePopulatorSpec.js +++ b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlanePopulatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/swimlane/TimelineSwimlanePopulator'], function (TimelineSwimlanePopulator) { - 'use strict'; describe("A Timeline swimlane populator", function () { var mockLoader, @@ -44,16 +42,16 @@ define( } function makeMockDomainObject(id, composition) { - var mockDomainObject = jasmine.createSpyObj( + var mockDomainObj = jasmine.createSpyObj( 'domainObject-' + id, ['getId', 'getModel', 'getCapability', 'useCapability'] ); - mockDomainObject.getId.andReturn(id); - mockDomainObject.getModel.andReturn({ composition: composition }); - mockDomainObject.useCapability.andReturn(asPromise(false)); + mockDomainObj.getId.andReturn(id); + mockDomainObj.getModel.andReturn({ composition: composition }); + mockDomainObj.useCapability.andReturn(asPromise(false)); - return mockDomainObject; + return mockDomainObj; } function subgraph(domainObject, objects) { @@ -162,4 +160,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneSpec.js index 7100e82c35..615b6f7501 100644 --- a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneSpec.js +++ b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../../src/controllers/swimlane/TimelineSwimlane'], function (TimelineSwimlane) { - 'use strict'; describe("A Timeline swimlane", function () { var parent, @@ -38,7 +36,9 @@ define( testConfiguration; function asPromise(v) { - return { then: function (cb) { cb(v); } }; + return { then: function (cb) { + cb(v); + } }; } beforeEach(function () { @@ -220,4 +220,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/features/timeline/test/directives/MCTSwimlaneDragSpec.js b/platform/features/timeline/test/directives/MCTSwimlaneDragSpec.js index 48991b83ae..e7667d238b 100644 --- a/platform/features/timeline/test/directives/MCTSwimlaneDragSpec.js +++ b/platform/features/timeline/test/directives/MCTSwimlaneDragSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/directives/MCTSwimlaneDrag', '../../src/directives/SwimlaneDragConstants'], function (MCTSwimlaneDrag, SwimlaneDragConstants) { - "use strict"; describe("The mct-swimlane-drag directive", function () { var mockDndService, diff --git a/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js b/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js index aea4da18df..4f7b914db3 100644 --- a/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js +++ b/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/directives/MCTSwimlaneDrop'], function (MCTSwimlaneDrop) { - "use strict"; var TEST_HEIGHT = 100, TEST_TOP = 600; @@ -35,7 +33,6 @@ define( mockElement, testAttrs, mockSwimlane, - mockRealElement, testEvent, handlers, directive; @@ -60,11 +57,11 @@ define( testAttrs = { mctSwimlaneDrop: "mockSwimlane" }; mockSwimlane = jasmine.createSpyObj( "swimlane", - [ "allowDropIn", "allowDropAfter", "drop", "highlight", "highlightBottom" ] + ["allowDropIn", "allowDropAfter", "drop", "highlight", "highlightBottom"] ); mockElement[0] = jasmine.createSpyObj( "realElement", - [ "getBoundingClientRect" ] + ["getBoundingClientRect"] ); mockElement[0].offsetHeight = TEST_HEIGHT; mockElement[0].getBoundingClientRect.andReturn({ top: TEST_TOP }); diff --git a/platform/features/timeline/test/directives/SwimlaneDragConstantsSpec.js b/platform/features/timeline/test/directives/SwimlaneDragConstantsSpec.js index 42122647dc..6b135f3cd0 100644 --- a/platform/features/timeline/test/directives/SwimlaneDragConstantsSpec.js +++ b/platform/features/timeline/test/directives/SwimlaneDragConstantsSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/directives/SwimlaneDragConstants'], function (SwimlaneDragConstants) { - "use strict"; describe("Timeline swimlane drag constants", function () { it("define a custom type for swimlane drag-drop", function () { diff --git a/platform/features/timeline/test/services/ObjectLoaderSpec.js b/platform/features/timeline/test/services/ObjectLoaderSpec.js index 57f646e08f..8828d92a06 100644 --- a/platform/features/timeline/test/services/ObjectLoaderSpec.js +++ b/platform/features/timeline/test/services/ObjectLoaderSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,window,afterEach*/ define( ['../../src/services/ObjectLoader'], function (ObjectLoader) { - "use strict"; describe("The domain object loader", function () { var mockQ, @@ -56,7 +54,7 @@ define( function addDomainObject(id, children, capabilities) { var mockDomainObject = jasmine.createSpyObj( 'object-' + id, - [ 'useCapability', 'hasCapability', 'getId' ] + ['useCapability', 'hasCapability', 'getId'] ); mockDomainObject.getId.andReturn(id); @@ -74,7 +72,7 @@ define( } beforeEach(function () { - mockQ = jasmine.createSpyObj('$q', [ 'when', 'all' ]); + mockQ = jasmine.createSpyObj('$q', ['when', 'all']); mockCallback = jasmine.createSpy('callback'); mockDomainObjects = {}; testCompositions = {}; @@ -84,8 +82,12 @@ define( mockQ.when.andCallFake(asPromise); mockQ.all.andCallFake(function (values) { var result = []; - function addResult(v) { result.push(v); } - function promiseResult(v) { asPromise(v).then(addResult); } + function addResult(v) { + result.push(v); + } + function promiseResult(v) { + asPromise(v).then(addResult); + } values.forEach(promiseResult); return asPromise(result); }); @@ -154,4 +156,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/forms/bundle.js b/platform/forms/bundle.js index 76cd4c20b8..6760f339b7 100644 --- a/platform/forms/bundle.js +++ b/platform/forms/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/MCTForm", @@ -60,7 +59,6 @@ define([ radioTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/forms", { "name": "MCT Forms", diff --git a/platform/forms/src/MCTControl.js b/platform/forms/src/MCTControl.js index 09192a09ee..762e7f280b 100644 --- a/platform/forms/src/MCTControl.js +++ b/platform/forms/src/MCTControl.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The mct-control will dynamically include the control diff --git a/platform/forms/src/MCTForm.js b/platform/forms/src/MCTForm.js index 70c18cbf2f..13c859f0e6 100644 --- a/platform/forms/src/MCTForm.js +++ b/platform/forms/src/MCTForm.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * This bundle implements directives for displaying and handling forms for @@ -29,7 +28,6 @@ define( ["./controllers/FormController", "text!../res/templates/form.html"], function (FormController, formTemplate) { - "use strict"; /** * The mct-form directive allows generation of displayable @@ -60,7 +58,7 @@ define( template: formTemplate, // Use FormController to populate/respond to changes in scope - controller: [ '$scope', FormController ], + controller: ['$scope', FormController], // Initial an isolate scope scope: { diff --git a/platform/forms/src/MCTToolbar.js b/platform/forms/src/MCTToolbar.js index 42c93c4842..34c1cf15c1 100644 --- a/platform/forms/src/MCTToolbar.js +++ b/platform/forms/src/MCTToolbar.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining MCTForm. Created by vwoeltje on 11/10/14. @@ -27,7 +26,6 @@ define( ["./MCTForm", "text!../res/templates/toolbar.html"], function (MCTForm, toolbarTemplate) { - "use strict"; /** * The mct-toolbar directive allows generation of displayable diff --git a/platform/forms/src/controllers/ColorController.js b/platform/forms/src/controllers/ColorController.js index 62640364df..f91397be82 100644 --- a/platform/forms/src/controllers/ColorController.js +++ b/platform/forms/src/controllers/ColorController.js @@ -19,24 +19,22 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; var BASE_COLORS = [ - [ 136, 32, 32 ], - [ 224, 64, 64 ], - [ 240, 160, 72 ], - [ 255, 248, 96 ], - [ 128, 240, 72 ], - [ 128, 248, 248 ], - [ 88, 144, 224 ], - [ 0, 72, 240 ], - [ 136, 80, 240 ], - [ 224, 96, 248 ] + [136, 32, 32], + [224, 64, 64], + [240, 160, 72], + [255, 248, 96], + [128, 240, 72], + [128, 248, 248], + [88, 144, 224], + [0, 72, 240], + [136, 80, 240], + [224, 96, 248] ], GRADIENTS = [0.75, 0.50, 0.25, -0.25, -0.50, -0.75], GROUPS = []; @@ -57,7 +55,7 @@ define( } function initializeGroups() { - var i, group; + var group; // Ten grayscale colors group = []; diff --git a/platform/forms/src/controllers/CompositeController.js b/platform/forms/src/controllers/CompositeController.js index 506fbb6f4e..812da3996e 100644 --- a/platform/forms/src/controllers/CompositeController.js +++ b/platform/forms/src/controllers/CompositeController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The CompositeController supports the "composite" control type, diff --git a/platform/forms/src/controllers/DateTimeController.js b/platform/forms/src/controllers/DateTimeController.js index 21d6c4d304..840f94f8f6 100644 --- a/platform/forms/src/controllers/DateTimeController.js +++ b/platform/forms/src/controllers/DateTimeController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,moment*/ define( ["moment"], function (moment) { - "use strict"; var DATE_FORMAT = "YYYY-MM-DD"; diff --git a/platform/forms/src/controllers/DialogButtonController.js b/platform/forms/src/controllers/DialogButtonController.js index 2c440dead1..f6431221a4 100644 --- a/platform/forms/src/controllers/DialogButtonController.js +++ b/platform/forms/src/controllers/DialogButtonController.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * Controller for the `dialog-button` control type. Provides @@ -73,7 +71,7 @@ define( // Prepare the form; a single row buttonForm = { name: structure.title, - sections: [ { rows: [ row ] } ] + sections: [{ rows: [row] }] }; } diff --git a/platform/forms/src/controllers/FormController.js b/platform/forms/src/controllers/FormController.js index 04b8379304..c2082fdc37 100644 --- a/platform/forms/src/controllers/FormController.js +++ b/platform/forms/src/controllers/FormController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; // Default ng-pattern; any non whitespace var NON_WHITESPACE = /\S/; diff --git a/platform/forms/test/MCTControlSpec.js b/platform/forms/test/MCTControlSpec.js index 4f4b2cbd6f..a588381ddc 100644 --- a/platform/forms/test/MCTControlSpec.js +++ b/platform/forms/test/MCTControlSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/MCTControl"], function (MCTControl) { - "use strict"; describe("The mct-control directive", function () { var testControls, @@ -47,7 +45,7 @@ define( } ]; - mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]); + mockScope = jasmine.createSpyObj("$scope", ["$watch"]); mockLinker = jasmine.createSpyObj("templateLinker", ["link"]); mockChangeTemplate = jasmine.createSpy('changeTemplate'); mockLinker.link.andReturn(mockChangeTemplate); @@ -85,4 +83,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/forms/test/MCTFormSpec.js b/platform/forms/test/MCTFormSpec.js index 37f4b4f6c2..d2f5fc5c09 100644 --- a/platform/forms/test/MCTFormSpec.js +++ b/platform/forms/test/MCTFormSpec.js @@ -19,25 +19,22 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/MCTForm"], function (MCTForm) { - "use strict"; describe("The mct-form directive", function () { var mockScope, mctForm; function installController() { - var controllerProperty = mctForm.controller, - Controller = mctForm.controller[1]; + var Controller = mctForm.controller[1]; return new Controller(mockScope); } beforeEach(function () { - mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]); + mockScope = jasmine.createSpyObj("$scope", ["$watch"]); mockScope.$parent = {}; mctForm = new MCTForm(); }); @@ -114,4 +111,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/forms/test/MCTToolbarSpec.js b/platform/forms/test/MCTToolbarSpec.js index 00869d9606..61f0dae01c 100644 --- a/platform/forms/test/MCTToolbarSpec.js +++ b/platform/forms/test/MCTToolbarSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/MCTToolbar"], function (MCTToolbar) { - "use strict"; describe("The mct-toolbar directive", function () { var mockScope, @@ -36,7 +34,7 @@ define( } beforeEach(function () { - mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]); + mockScope = jasmine.createSpyObj("$scope", ["$watch"]); mockScope.$parent = {}; mctToolbar = new MCTToolbar(); }); @@ -113,4 +111,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/forms/test/controllers/ColorControllerSpec.js b/platform/forms/test/controllers/ColorControllerSpec.js index 8f075b9cf8..3f8bce3e05 100644 --- a/platform/forms/test/controllers/ColorControllerSpec.js +++ b/platform/forms/test/controllers/ColorControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/ColorController"], function (ColorController) { - "use strict"; var COLOR_REGEX = /^#[0-9a-fA-F]{6}$/; @@ -69,4 +67,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/forms/test/controllers/CompositeControllerSpec.js b/platform/forms/test/controllers/CompositeControllerSpec.js index 096c70b87f..bec1d3a96e 100644 --- a/platform/forms/test/controllers/CompositeControllerSpec.js +++ b/platform/forms/test/controllers/CompositeControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/CompositeController"], function (CompositeController) { - "use strict"; describe("The composite controller", function () { var controller; @@ -54,4 +52,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/forms/test/controllers/DateTimeControllerSpec.js b/platform/forms/test/controllers/DateTimeControllerSpec.js index 54370ea90b..079cd0b80f 100644 --- a/platform/forms/test/controllers/DateTimeControllerSpec.js +++ b/platform/forms/test/controllers/DateTimeControllerSpec.js @@ -19,19 +19,17 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/DateTimeController"], function (DateTimeController) { - "use strict"; describe("The date-time controller", function () { var mockScope, controller; beforeEach(function () { - mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]); + mockScope = jasmine.createSpyObj("$scope", ["$watch"]); controller = new DateTimeController(mockScope); }); diff --git a/platform/forms/test/controllers/DialogButtonControllerSpec.js b/platform/forms/test/controllers/DialogButtonControllerSpec.js index facc01cf35..1aecb5d941 100644 --- a/platform/forms/test/controllers/DialogButtonControllerSpec.js +++ b/platform/forms/test/controllers/DialogButtonControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/DialogButtonController"], function (DialogButtonController) { - "use strict"; describe("A dialog button controller", function () { var mockScope, @@ -36,15 +34,15 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( '$scope', - [ '$watch' ] + ['$watch'] ); mockDialogService = jasmine.createSpyObj( 'dialogService', - [ 'getUserInput' ] + ['getUserInput'] ); mockPromise = jasmine.createSpyObj( 'promise', - [ 'then' ] + ['then'] ); testStructure = { name: "A Test", @@ -134,4 +132,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/forms/test/controllers/FormControllerSpec.js b/platform/forms/test/controllers/FormControllerSpec.js index 4a4495ace7..06f3ea93bd 100644 --- a/platform/forms/test/controllers/FormControllerSpec.js +++ b/platform/forms/test/controllers/FormControllerSpec.js @@ -19,19 +19,17 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/controllers/FormController"], function (FormController) { - "use strict"; describe("The form controller", function () { var mockScope, controller; beforeEach(function () { - mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]); + mockScope = jasmine.createSpyObj("$scope", ["$watch"]); mockScope.$parent = {}; controller = new FormController(mockScope); }); @@ -87,4 +85,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/bundle.js b/platform/framework/bundle.js index 96e8802550..89c44feade 100644 --- a/platform/framework/bundle.js +++ b/platform/framework/bundle.js @@ -19,16 +19,14 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ - + 'legacyRegistry' ], function ( - + legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/framework", { "name": "Open MCT Web Framework Component", diff --git a/platform/framework/src/Constants.js b/platform/framework/src/Constants.js index 3d9fb949b0..aa6b22d1a8 100644 --- a/platform/framework/src/Constants.js +++ b/platform/framework/src/Constants.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Constants used by the framework layer. diff --git a/platform/framework/src/FrameworkInitializer.js b/platform/framework/src/FrameworkInitializer.js index add6846e9f..3c563006bf 100644 --- a/platform/framework/src/FrameworkInitializer.js +++ b/platform/framework/src/FrameworkInitializer.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining FrameworkInitializer. Created by vwoeltje on 11/3/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Responsible for managing the four stages of framework diff --git a/platform/framework/src/FrameworkLayer.js b/platform/framework/src/FrameworkLayer.js index 4cffd465cc..d1888085f0 100644 --- a/platform/framework/src/FrameworkLayer.js +++ b/platform/framework/src/FrameworkLayer.js @@ -19,7 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define, window, requirejs*/ + +/*global window,requirejs*/ define([ 'require', @@ -50,7 +51,6 @@ define([ ExtensionSorter, ApplicationBootstrapper ) { - 'use strict'; function FrameworkLayer($http, $log) { this.$http = $http; @@ -102,4 +102,4 @@ define([ }; return FrameworkLayer; -}); \ No newline at end of file +}); diff --git a/platform/framework/src/LogLevel.js b/platform/framework/src/LogLevel.js index fbf69e8dcd..31c129cd89 100644 --- a/platform/framework/src/LogLevel.js +++ b/platform/framework/src/LogLevel.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; // Log levels; note that these must be in order of // most-important-first for LogLevel to function correctly diff --git a/platform/framework/src/Main.js b/platform/framework/src/Main.js index 44f6c8d7a5..c468e4dbea 100644 --- a/platform/framework/src/Main.js +++ b/platform/framework/src/Main.js @@ -19,7 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define, window, requirejs*/ + +/*global window,requirejs*/ /** * Implements the framework layer, which handles the loading of bundles @@ -40,7 +41,6 @@ define( FrameworkLayer, angular ) { - "use strict"; function Main() { } diff --git a/platform/framework/src/bootstrap/ApplicationBootstrapper.js b/platform/framework/src/bootstrap/ApplicationBootstrapper.js index 490017885a..1b2276631e 100644 --- a/platform/framework/src/bootstrap/ApplicationBootstrapper.js +++ b/platform/framework/src/bootstrap/ApplicationBootstrapper.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining Bootstrapper. Created by vwoeltje on 11/4/14. @@ -29,7 +28,6 @@ define( [], function () { - "use strict"; /** * The application bootstrapper is responsible for issuing the diff --git a/platform/framework/src/load/Bundle.js b/platform/framework/src/load/Bundle.js index a53d2761fd..3f05e23ae3 100644 --- a/platform/framework/src/load/Bundle.js +++ b/platform/framework/src/load/Bundle.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['../Constants', './Extension'], function (Constants, Extension) { - "use strict"; /** @@ -108,8 +106,8 @@ define( */ Bundle.prototype.getSourcePath = function (sourceFile) { var subpath = sourceFile ? - [ this.definition.sources, sourceFile ] : - [ this.definition.sources ]; + [this.definition.sources, sourceFile] : + [this.definition.sources]; return this.resolvePath(subpath); }; @@ -126,8 +124,8 @@ define( */ Bundle.prototype.getResourcePath = function (resourceFile) { var subpath = resourceFile ? - [ this.definition.resources, resourceFile ] : - [ this.definition.resources ]; + [this.definition.resources, resourceFile] : + [this.definition.resources]; return this.resolvePath(subpath); }; @@ -144,8 +142,8 @@ define( */ Bundle.prototype.getLibraryPath = function (libraryFile) { var subpath = libraryFile ? - [ this.definition.libraries, libraryFile ] : - [ this.definition.libraries ]; + [this.definition.libraries, libraryFile] : + [this.definition.libraries]; return this.resolvePath(subpath); }; diff --git a/platform/framework/src/load/BundleLoader.js b/platform/framework/src/load/BundleLoader.js index 9389207ea8..e8cbe5252e 100644 --- a/platform/framework/src/load/BundleLoader.js +++ b/platform/framework/src/load/BundleLoader.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining BundleLoader.js. Created by vwoeltje on 10/31/14. @@ -27,7 +26,6 @@ define( ['../Constants', './Bundle'], function (Constants, Bundle) { - "use strict"; var INVALID_ARGUMENT_MESSAGE = "Malformed loadBundles argument; " + "expected string or array", @@ -75,7 +73,9 @@ define( // loadBundleDefinition, so at this point they are safe // to discard. function filterBundles(array) { - return array.filter(function (x) { return x !== undefined; }); + return array.filter(function (x) { + return x !== undefined; + }); } // Load a definition for a bundle diff --git a/platform/framework/src/load/Extension.js b/platform/framework/src/load/Extension.js index 7b07f879dc..51a3dfdced 100644 --- a/platform/framework/src/load/Extension.js +++ b/platform/framework/src/load/Extension.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * An extension's plain JSON definition. diff --git a/platform/framework/src/register/CustomRegistrars.js b/platform/framework/src/register/CustomRegistrars.js index e47825e991..95ce291ad1 100644 --- a/platform/framework/src/register/CustomRegistrars.js +++ b/platform/framework/src/register/CustomRegistrars.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining CustomRegistrars. Created by vwoeltje on 11/3/14. @@ -27,7 +26,7 @@ define( ['../Constants', './ServiceCompositor'], function (Constants, ServiceCompositor) { - "use strict"; + /*jshint validthis:true */ /** * Handles registration of a few specific extension types that are diff --git a/platform/framework/src/register/ExtensionRegistrar.js b/platform/framework/src/register/ExtensionRegistrar.js index 352d3b9f3f..7b5ef7e096 100644 --- a/platform/framework/src/register/ExtensionRegistrar.js +++ b/platform/framework/src/register/ExtensionRegistrar.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ExtensionRegistrar. Created by vwoeltje on 11/3/14. @@ -27,7 +26,6 @@ define( ['../Constants', './PartialConstructor'], function (Constants, PartialConstructor) { - "use strict"; /** * Responsible for registering extensions with Angular. @@ -94,7 +92,9 @@ define( // Always return a static value; used to represent plain // metadata as a single dependency in Angular. function staticFunction(value) { - return function () { return value; }; + return function () { + return value; + }; } // Utility function; create the second argument for Angular's @@ -164,15 +164,15 @@ define( // Examine a group of resolved dependencies to determine // which extension categories still need to be satisfied. - function findEmptyExtensionDependencies(extensionGroup) { + function findEmptyExtensionDependencies(extGroup) { var needed = {}, - categories = Object.keys(extensionGroup), + categories = Object.keys(extGroup), allExtensions = []; // Build up an array of all extensions categories.forEach(function (category) { allExtensions = - allExtensions.concat(extensionGroup[category]); + allExtensions.concat(extGroup[category]); }); // Track all extension dependencies exposed therefrom @@ -197,10 +197,9 @@ define( // Register any extension categories that are depended-upon but // have not been declared anywhere; such dependencies are then // satisfied by an empty array, instead of not at all. - function registerEmptyDependencies(extensionGroup) { - findEmptyExtensionDependencies( - extensionGroup - ).forEach(function (name) { + function registerEmptyDependencies(extGroup) { + findEmptyExtensionDependencies(extGroup) + .forEach(function (name) { $log.info("Registering empty extension category " + name); app.factory(name, [staticFunction([])]); }); diff --git a/platform/framework/src/register/ExtensionSorter.js b/platform/framework/src/register/ExtensionSorter.js index 9bc902da9e..eb3a936dfa 100644 --- a/platform/framework/src/register/ExtensionSorter.js +++ b/platform/framework/src/register/ExtensionSorter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["../Constants"], function (Constants) { - "use strict"; /** * Responsible for applying priority order to extensions in a diff --git a/platform/framework/src/register/PartialConstructor.js b/platform/framework/src/register/PartialConstructor.js index 46598f6402..4ab0e0b4d2 100644 --- a/platform/framework/src/register/PartialConstructor.js +++ b/platform/framework/src/register/PartialConstructor.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining PartialConstructor. Created by vwoeltje on 11/3/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * A partial constructor is used to instantiate objects in two diff --git a/platform/framework/src/register/ServiceCompositor.js b/platform/framework/src/register/ServiceCompositor.js index 349e0c92e4..3167bfe332 100644 --- a/platform/framework/src/register/ServiceCompositor.js +++ b/platform/framework/src/register/ServiceCompositor.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ServiceCompositor. Created by vwoeltje on 11/5/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Handles service compositing; that is, building up services diff --git a/platform/framework/src/resolve/BundleResolver.js b/platform/framework/src/resolve/BundleResolver.js index 4360764aee..00344d278f 100644 --- a/platform/framework/src/resolve/BundleResolver.js +++ b/platform/framework/src/resolve/BundleResolver.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining BundleResolver. Created by vwoeltje on 11/4/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Responsible for the extension resolution phase of framework diff --git a/platform/framework/src/resolve/ExtensionResolver.js b/platform/framework/src/resolve/ExtensionResolver.js index 567a399213..1abcd91a91 100644 --- a/platform/framework/src/resolve/ExtensionResolver.js +++ b/platform/framework/src/resolve/ExtensionResolver.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ExtensionResolver. Created by vwoeltje on 11/3/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * An ExtensionResolver is responsible for loading any implementation @@ -60,11 +58,11 @@ define( var loader = this.loader, $log = this.$log; - function loadImplementation(extension) { - var implPromise = extension.hasImplementationValue() ? - Promise.resolve(extension.getImplementationValue()) : - loader.load(extension.getImplementationPath()), - definition = extension.getDefinition(); + function loadImplementation(ext) { + var implPromise = ext.hasImplementationValue() ? + Promise.resolve(ext.getImplementationValue()) : + loader.load(ext.getImplementationPath()), + definition = ext.getDefinition(); // Wrap a constructor function (to avoid modifying the original) function constructorFor(impl) { @@ -96,7 +94,7 @@ define( result.definition = definition; // Log that this load was successful - $log.info("Resolved " + extension.getLogName()); + $log.info("Resolved " + ext.getLogName()); return result; } @@ -107,7 +105,7 @@ define( // Build up a log message from parts var message = [ "Could not load implementation for extension ", - extension.getLogName(), + ext.getLogName(), " due to ", err.message ].join(""); @@ -115,16 +113,16 @@ define( // Log that the extension was not loaded $log.warn(message); - return extension.getDefinition(); + return ext.getDefinition(); } - if (!extension.hasImplementationValue()) { + if (!ext.hasImplementationValue()) { // Log that loading has begun $log.info([ "Loading implementation ", - extension.getImplementationPath(), + ext.getImplementationPath(), " for extension ", - extension.getLogName() + ext.getLogName() ].join("")); } diff --git a/platform/framework/src/resolve/ImplementationLoader.js b/platform/framework/src/resolve/ImplementationLoader.js index c9f1ae8bc9..72efe0c263 100644 --- a/platform/framework/src/resolve/ImplementationLoader.js +++ b/platform/framework/src/resolve/ImplementationLoader.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ImplementationLoader. Created by vwoeltje on 11/3/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Responsible for loading extension implementations diff --git a/platform/framework/src/resolve/RequireConfigurator.js b/platform/framework/src/resolve/RequireConfigurator.js index f55ac559c1..eb3b18c46d 100644 --- a/platform/framework/src/resolve/RequireConfigurator.js +++ b/platform/framework/src/resolve/RequireConfigurator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Handles configuration of RequireJS to expose libraries diff --git a/platform/framework/test/FrameworkInitializerSpec.js b/platform/framework/test/FrameworkInitializerSpec.js index 775fed4dda..f91c7dbc93 100644 --- a/platform/framework/test/FrameworkInitializerSpec.js +++ b/platform/framework/test/FrameworkInitializerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,runs*/ /** * FrameworkInitializerSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/FrameworkInitializer"], function (FrameworkInitializer) { - "use strict"; describe("The framework initializer", function () { var initializer; @@ -52,13 +50,17 @@ define( it("calls injected stages in order", function () { var result; - initializer.runApplication([]).then(function (v) { result = v; }); + initializer.runApplication([]).then(function (v) { + result = v; + }); waitsFor( - function () { return result !== undefined; }, - "promise resolution", - 250 - ); + function () { + return result !== undefined; + }, + "promise resolution", + 250 + ); runs(function () { expect(result).toEqual( @@ -69,4 +71,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/LogLevelSpec.js b/platform/framework/test/LogLevelSpec.js index 224db5186e..00a49077c5 100644 --- a/platform/framework/test/LogLevelSpec.js +++ b/platform/framework/test/LogLevelSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ['../src/LogLevel'], function (LogLevel) { - "use strict"; var LOG_METHODS = [ 'error', @@ -97,4 +95,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/bootstrap/ApplicationBootstrapperSpec.js b/platform/framework/test/bootstrap/ApplicationBootstrapperSpec.js index d8e87aeb27..b4a64d62b8 100644 --- a/platform/framework/test/bootstrap/ApplicationBootstrapperSpec.js +++ b/platform/framework/test/bootstrap/ApplicationBootstrapperSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach*/ /** * ApplicationBootstrapperSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/bootstrap/ApplicationBootstrapper"], function (ApplicationBootstrapper) { - "use strict"; describe("The application bootstrapper", function () { // Test support variables @@ -106,4 +104,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/load/BundleLoaderSpec.js b/platform/framework/test/load/BundleLoaderSpec.js index 3c6eb69bb6..914f139ea2 100644 --- a/platform/framework/test/load/BundleLoaderSpec.js +++ b/platform/framework/test/load/BundleLoaderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,runs,jasmine*/ /** * BundleLoaderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/load/BundleLoader"], function (BundleLoader) { - "use strict"; describe("The bundle loader", function () { var loader, @@ -46,7 +44,7 @@ define( beforeEach(function () { testBundles = { - "bundles.json": [ "bundle/a", "bundle/b"], + "bundles.json": ["bundle/a", "bundle/b"], "bundle/a/bundle.json": {"someValue": 6}, "bundle/b/bundle.json": {"someValue": 7} }; @@ -56,7 +54,7 @@ define( mockLog = jasmine.createSpyObj("$log", ["error", "warn", "info", "debug"]); mockRegistry = jasmine.createSpyObj( 'legacyRegistry', - [ 'list', 'contains', 'get' ] + ['list', 'contains', 'get'] ); mockRegistry.list.andReturn([]); mockRegistry.contains.andReturn(false); @@ -147,4 +145,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/load/BundleSpec.js b/platform/framework/test/load/BundleSpec.js index 5c9142ad79..ced5e91069 100644 --- a/platform/framework/test/load/BundleSpec.js +++ b/platform/framework/test/load/BundleSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach*/ /** * BundleSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/load/Bundle", "../../src/Constants"], function (Bundle, Constants) { // Verify against constants, too - "use strict"; describe("A bundle", function () { var PATH = "some/path", @@ -80,17 +78,17 @@ define( it("reports all extensions that have been declared", function () { var bundle = new Bundle(PATH, { - extensions: { things: [ {}, {}, {} ] } + extensions: { things: [{}, {}, {}] } }); expect(bundle.getExtensions("things").length).toEqual(3); }); it("reports an empty list for extensions that have not been declared", function () { var bundle = new Bundle(PATH, { - extensions: { things: [ {}, {}, {} ] } + extensions: { things: [{}, {}, {}] } }); expect(bundle.getExtensions("stuffs").length).toEqual(0); }); }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/load/ExtensionSpec.js b/platform/framework/test/load/ExtensionSpec.js index bc8a51fae3..989864bb78 100644 --- a/platform/framework/test/load/ExtensionSpec.js +++ b/platform/framework/test/load/ExtensionSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach*/ /** * ExtensionSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/load/Extension", "../../src/load/Bundle"], function (Extension, Bundle) { - "use strict"; describe("An extension", function () { var bundle; @@ -106,4 +104,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/register/CustomRegistrarsSpec.js b/platform/framework/test/register/CustomRegistrarsSpec.js index 5083e63f88..31fe0c8a52 100644 --- a/platform/framework/test/register/CustomRegistrarsSpec.js +++ b/platform/framework/test/register/CustomRegistrarsSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,jasmine,waitsFor*/ /** * CustomRegistrarsSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/register/CustomRegistrars"], function (CustomRegistrars) { - "use strict"; describe("Custom registrars", function () { var mockLog, diff --git a/platform/framework/test/register/ExtensionRegistrarSpec.js b/platform/framework/test/register/ExtensionRegistrarSpec.js index 07a282e23c..be8d0fa5df 100644 --- a/platform/framework/test/register/ExtensionRegistrarSpec.js +++ b/platform/framework/test/register/ExtensionRegistrarSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,jasmine*/ /** * ExtensionRegistrarSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/register/ExtensionRegistrar"], function (ExtensionRegistrar) { - "use strict"; describe("The extension registrar", function () { var mockApp, @@ -42,7 +40,9 @@ define( mockSorter = jasmine.createSpyObj("sorter", ["sort"]); customRegistrars = {}; - mockSorter.sort.andCallFake(function (v) { return v; }); + mockSorter.sort.andCallFake(function (v) { + return v; + }); registrar = new ExtensionRegistrar( mockApp, @@ -53,7 +53,7 @@ define( }); it("registers extensions using the factory", function () { - registrar.registerExtensions({ things: [ {} ] }); + registrar.registerExtensions({ things: [{}] }); expect(mockApp.factory).toHaveBeenCalled(); }); @@ -62,7 +62,7 @@ define( mockApp.factory.andCallFake(function (name, value) { callbacks[name] = value[value.length - 1]; }); - registrar.registerExtensions({ things: [ {} ] }); + registrar.registerExtensions({ things: [{}] }); expect(callbacks["things[]"]).toBeDefined(); // Verify dependency echo behavior @@ -70,9 +70,9 @@ define( }); it("warns if multiple registrations are made for the same category of extension", function () { - registrar.registerExtensions({ things: [ {} ] }); + registrar.registerExtensions({ things: [{}] }); expect(mockLog.warn).not.toHaveBeenCalled(); - registrar.registerExtensions({ things: [ {} ] }); + registrar.registerExtensions({ things: [{}] }); expect(mockLog.warn).toHaveBeenCalled(); }); @@ -83,14 +83,14 @@ define( }); // Nobody has registered tests[], but it looks like an extension dependency, // so register it as an empty array. - registrar.registerExtensions({ things: [ { depends: [ "tests[]", "other" ] } ] }); + registrar.registerExtensions({ things: [{ depends: ["tests[]", "other"] }] }); expect(lengths["tests[]"]).toEqual(1); expect(lengths.other).toBeUndefined(); }); it("invokes custom registrars (not app.factory) when available", function () { customRegistrars.things = jasmine.createSpy("things"); - registrar.registerExtensions({ things: [ {} ] }); + registrar.registerExtensions({ things: [{}] }); expect(mockApp.factory).not.toHaveBeenCalled(); expect(customRegistrars.things).toHaveBeenCalled(); }); @@ -100,13 +100,15 @@ define( var a = { a: 'a' }, b = { b: 'b' }, c = { c: 'c' }; // Fake sorting; just reverse the array - mockSorter.sort.andCallFake(function (v) { return v.reverse(); }); + mockSorter.sort.andCallFake(function (v) { + return v.reverse(); + }); // Register the extensions - registrar.registerExtensions({ things: [ a, b, c ] }); + registrar.registerExtensions({ things: [a, b, c] }); // Verify registration interactions occurred in reverse-order - [ c, b, a ].forEach(function (extension, index) { + [c, b, a].forEach(function (extension, index) { expect(mockApp.factory.calls[index].args[1][0]()) .toEqual(extension); }); @@ -114,4 +116,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/register/ExtensionSorterSpec.js b/platform/framework/test/register/ExtensionSorterSpec.js index 2511bb01a4..a652daf4c9 100644 --- a/platform/framework/test/register/ExtensionSorterSpec.js +++ b/platform/framework/test/register/ExtensionSorterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,jasmine,waitsFor*/ define( ["../../src/register/ExtensionSorter"], function (ExtensionSorter) { - "use strict"; describe("The extension sorter", function () { var mockLog, diff --git a/platform/framework/test/register/PartialConstructorSpec.js b/platform/framework/test/register/PartialConstructorSpec.js index 8df3c6c462..6aea16adf7 100644 --- a/platform/framework/test/register/PartialConstructorSpec.js +++ b/platform/framework/test/register/PartialConstructorSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach*/ /** * PartialConstructorSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/register/PartialConstructor"], function (PartialConstructor) { - "use strict"; describe("A partial constructor", function () { var result, @@ -95,4 +93,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/register/ServiceCompositorSpec.js b/platform/framework/test/register/ServiceCompositorSpec.js index 16e2b9c015..0c10b87afe 100644 --- a/platform/framework/test/register/ServiceCompositorSpec.js +++ b/platform/framework/test/register/ServiceCompositorSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,jasmine*/ /** * ServiceCompositorSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/register/ServiceCompositor"], function (ServiceCompositor) { - "use strict"; describe("The service compositor", function () { var registered, @@ -39,8 +37,8 @@ define( beforeEach(function () { registered = {}; - mockApp = jasmine.createSpyObj("app", [ "service" ]); - mockLog = jasmine.createSpyObj("$log", [ "error", "warn", "info", "debug" ]); + mockApp = jasmine.createSpyObj("app", ["service"]); + mockLog = jasmine.createSpyObj("$log", ["error", "warn", "info", "debug"]); mockApp.service.andCallFake(function (name, value) { var factory = value[value.length - 1]; @@ -68,11 +66,21 @@ define( it("allows composite services to be registered", function () { // Prepare components that look like resolved extensions var components, name; - function MyDecorator() { return {}; } - function MyOtherDecorator() { return {}; } - function MyProvider() { return {}; } - function MyOtherProvider() { return {}; } - function MyAggregator() { return {}; } + function MyDecorator() { + return {}; + } + function MyOtherDecorator() { + return {}; + } + function MyProvider() { + return {}; + } + function MyOtherProvider() { + return {}; + } + function MyAggregator() { + return {}; + } components = [ MyDecorator, @@ -87,11 +95,13 @@ define( MyProvider.type = "provider"; MyOtherProvider.type = "provider"; MyAggregator.type = "aggregator"; - components.forEach(function (c) { c.provides = "testService"; }); + components.forEach(function (c) { + c.provides = "testService"; + }); // Add some test dependencies, to check prepending - MyOtherDecorator.depends = [ "someOtherService" ]; - MyAggregator.depends = [ "tests[]" ]; + MyOtherDecorator.depends = ["someOtherService"]; + MyAggregator.depends = ["tests[]"]; // Register! compositor.registerCompositeServices(components); @@ -119,16 +129,24 @@ define( it("allows registered composite services to be instantiated", function () { // Prepare components that look like resolved extensions var components, name; - function MyProvider() { return {}; } - function MyOtherProvider() { return {}; } - function MyAggregator() { return {}; } + function MyProvider() { + return {}; + } + function MyOtherProvider() { + return {}; + } + function MyAggregator() { + return {}; + } - components = [ MyProvider, MyAggregator, MyOtherProvider ]; + components = [MyProvider, MyAggregator, MyOtherProvider]; MyProvider.type = "provider"; MyOtherProvider.type = "provider"; MyAggregator.type = "aggregator"; - components.forEach(function (c) { c.provides = "testService"; }); + components.forEach(function (c) { + c.provides = "testService"; + }); // Register! compositor.registerCompositeServices(components); @@ -151,11 +169,17 @@ define( it("warns and skips components with no service type", function () { // Prepare components that look like resolved extensions var components; - function MyProvider() { return {}; } - function MyDecorator() { return {}; } - function MyAggregator() { return {}; } + function MyProvider() { + return {}; + } + function MyDecorator() { + return {}; + } + function MyAggregator() { + return {}; + } - components = [ MyProvider, MyAggregator, MyDecorator ]; + components = [MyProvider, MyAggregator, MyDecorator]; MyProvider.type = "provider"; MyDecorator.type = "decorator"; @@ -177,9 +201,11 @@ define( it("warns about and skips aggregators with zero providers", function () { // Prepare components that look like resolved extensions var components; - function MyAggregator() { return {}; } + function MyAggregator() { + return {}; + } - components = [ MyAggregator ]; + components = [MyAggregator]; MyAggregator.type = "aggregator"; MyAggregator.provides = "testService"; @@ -197,9 +223,11 @@ define( it("warns about and skips decorators with nothing to decorate", function () { // Prepare components that look like resolved extensions var components; - function MyDecorator() { return {}; } + function MyDecorator() { + return {}; + } - components = [ MyDecorator ]; + components = [MyDecorator]; MyDecorator.type = "decorator"; MyDecorator.provides = "testService"; @@ -216,4 +244,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/resolve/BundleResolverSpec.js b/platform/framework/test/resolve/BundleResolverSpec.js index 500ff14de6..70c12f327e 100644 --- a/platform/framework/test/resolve/BundleResolverSpec.js +++ b/platform/framework/test/resolve/BundleResolverSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,runs*/ /** * BundleResolverSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/resolve/BundleResolver", "../../src/load/Bundle"], function (BundleResolver, Bundle) { - "use strict"; describe("The bundle resolver", function () { var mockExtensionResolver, @@ -62,16 +60,20 @@ define( var result; resolver.resolveBundles([ - new Bundle("x", { extensions: { tests: [ {}, {}, {} ] } }), - new Bundle("y", { extensions: { tests: [ {}, {} ], others: [ {}, {} ] } }), - new Bundle("z", { extensions: { others: [ {} ] } }) - ]).then(function (v) { result = v; }); + new Bundle("x", { extensions: { tests: [{}, {}, {}] } }), + new Bundle("y", { extensions: { tests: [{}, {}], others: [{}, {}] } }), + new Bundle("z", { extensions: { others: [{}] } }) + ]).then(function (v) { + result = v; + }); waitsFor( - function () { return result !== undefined; }, - "promise resolution", - 250 - ); + function () { + return result !== undefined; + }, + "promise resolution", + 250 + ); // Should get back the result from the resolver, and // should be binned by extension category. @@ -83,9 +85,9 @@ define( it("configures require before loading implementations", function () { var bundles = [ - new Bundle("x", { extensions: { tests: [ {}, {}, {} ] } }), - new Bundle("y", { extensions: { tests: [ {}, {} ], others: [ {}, {} ] } }), - new Bundle("z", { extensions: { others: [ {} ] } }) + new Bundle("x", { extensions: { tests: [{}, {}, {}] } }), + new Bundle("y", { extensions: { tests: [{}, {}], others: [{}, {}] } }), + new Bundle("z", { extensions: { others: [{}] } }) ]; resolver.resolveBundles(bundles); @@ -95,4 +97,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/resolve/ExtensionResolverSpec.js b/platform/framework/test/resolve/ExtensionResolverSpec.js index de1c29fc45..f635ba7972 100644 --- a/platform/framework/test/resolve/ExtensionResolverSpec.js +++ b/platform/framework/test/resolve/ExtensionResolverSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,jasmine,waitsFor,runs*/ /** * ExtensionResolverSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/resolve/ExtensionResolver", "../../src/load/Bundle"], function (ExtensionResolver, Bundle) { - "use strict"; describe("", function () { var mockLoader, @@ -35,7 +33,9 @@ define( resolver; // Test implementation, to load from the mock loader - function Constructor() { return { someKey: "some value" }; } + function Constructor() { + return { someKey: "some value" }; + } Constructor.someProperty = "some static value"; beforeEach(function () { @@ -54,18 +54,22 @@ define( it("requests implementations from the implementation loader", function () { var bundle = new Bundle("w", { sources: "x", - extensions: { tests: [ { implementation: "y/z.js" } ] } + extensions: { tests: [{ implementation: "y/z.js" }] } }), extension = bundle.getExtensions("tests")[0], result; - resolver.resolve(extension).then(function (v) { result = v; }); + resolver.resolve(extension).then(function (v) { + result = v; + }); waitsFor( - function () { return result !== undefined; }, - "promise resolution", - 250 - ); + function () { + return result !== undefined; + }, + "promise resolution", + 250 + ); runs(function () { // Verify that the right file was requested @@ -81,22 +85,26 @@ define( it("issues a warning and defaults to plain definition if load fails", function () { var bundle = new Bundle("w", { sources: "x", - extensions: { tests: [ { + extensions: { tests: [{ someOtherKey: "some other value", implementation: "y/z.js" - } ] } + }] } }), extension = bundle.getExtensions("tests")[0], result; mockLoader.load.andReturn(Promise.reject(new Error("test error"))); - resolver.resolve(extension).then(function (v) { result = v; }); + resolver.resolve(extension).then(function (v) { + result = v; + }); waitsFor( - function () { return result !== undefined; }, - "promise resolution", - 250 - ); + function () { + return result !== undefined; + }, + "promise resolution", + 250 + ); runs(function () { // Should have gotten a warning @@ -111,18 +119,22 @@ define( it("ensures implementation properties are exposed", function () { var bundle = new Bundle("w", { sources: "x", - extensions: { tests: [ { implementation: "y/z.js" } ] } + extensions: { tests: [{ implementation: "y/z.js" }] } }), extension = bundle.getExtensions("tests")[0], result; - resolver.resolve(extension).then(function (v) { result = v; }); + resolver.resolve(extension).then(function (v) { + result = v; + }); waitsFor( - function () { return result !== undefined; }, - "promise resolution", - 250 - ); + function () { + return result !== undefined; + }, + "promise resolution", + 250 + ); runs(function () { // Verify that the right file was requested @@ -138,4 +150,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/resolve/ImplementationLoaderSpec.js b/platform/framework/test/resolve/ImplementationLoaderSpec.js index aaa32d6c84..56201dfc9d 100644 --- a/platform/framework/test/resolve/ImplementationLoaderSpec.js +++ b/platform/framework/test/resolve/ImplementationLoaderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,runs*/ /** * ImplementationLoaderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../../src/resolve/ImplementationLoader"], function (ImplementationLoader) { - "use strict"; describe("The implementation loader", function () { var required, @@ -55,17 +53,21 @@ define( var result; // Load and get the result - loader.load("xyz.js").then(function (v) { result = v; }); + loader.load("xyz.js").then(function (v) { + result = v; + }); expect(result).toBeUndefined(); required.fulfill("test result"); waitsFor( - function () { return result !== undefined; }, - "promise resolution", - 250 - ); + function () { + return result !== undefined; + }, + "promise resolution", + 250 + ); runs(function () { expect(result).toEqual("test result"); @@ -78,19 +80,25 @@ define( // Load and get the result loader.load("xyz.js").then( - function (v) { result = v; }, - function (v) { rejection = v; } - ); + function (v) { + result = v; + }, + function (v) { + rejection = v; + } + ); expect(result).toBeUndefined(); required.reject("test result"); waitsFor( - function () { return rejection !== undefined; }, - "promise resolution", - 250 - ); + function () { + return rejection !== undefined; + }, + "promise resolution", + 250 + ); runs(function () { expect(result).toBeUndefined(); @@ -100,4 +108,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/framework/test/resolve/RequireConfiguratorSpec.js b/platform/framework/test/resolve/RequireConfiguratorSpec.js index a270e303c7..6a50044a3b 100644 --- a/platform/framework/test/resolve/RequireConfiguratorSpec.js +++ b/platform/framework/test/resolve/RequireConfiguratorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,runs*/ define( ["../../src/resolve/RequireConfigurator", "../../src/load/Bundle"], function (RequireConfigurator, Bundle) { - "use strict"; describe("The RequireJS configurator", function () { var mockRequire, @@ -33,7 +31,7 @@ define( beforeEach(function () { mockRequire = jasmine.createSpyObj( "requirejs", - [ "config" ] + ["config"] ); configurator = new RequireConfigurator(mockRequire); }); @@ -81,4 +79,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/identity/bundle.js b/platform/identity/bundle.js index 280019293c..2a6183d064 100644 --- a/platform/identity/bundle.js +++ b/platform/identity/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/IdentityAggregator", @@ -34,7 +33,6 @@ define([ IdentityIndicator, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/identity", { "extensions": { diff --git a/platform/identity/src/IdentityAggregator.js b/platform/identity/src/IdentityAggregator.js index c1d9481223..3e75ee0c8b 100644 --- a/platform/identity/src/IdentityAggregator.js +++ b/platform/identity/src/IdentityAggregator.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Defines interfaces and common infrastructure for establishing @@ -28,7 +27,6 @@ */ define( function () { - "use strict"; /** * Provides information about the currently logged-in diff --git a/platform/identity/src/IdentityCreationDecorator.js b/platform/identity/src/IdentityCreationDecorator.js index 0581b2ae8f..8f62258171 100644 --- a/platform/identity/src/IdentityCreationDecorator.js +++ b/platform/identity/src/IdentityCreationDecorator.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define */ define( function () { - "use strict"; /** * Adds a `creator` property to newly-created domain objects. diff --git a/platform/identity/src/IdentityIndicator.js b/platform/identity/src/IdentityIndicator.js index bee8648f26..ae553b60cd 100644 --- a/platform/identity/src/IdentityIndicator.js +++ b/platform/identity/src/IdentityIndicator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Indicator showing the currently logged-in user. diff --git a/platform/identity/src/IdentityProvider.js b/platform/identity/src/IdentityProvider.js index 8b6bd8f329..839c8c6671 100644 --- a/platform/identity/src/IdentityProvider.js +++ b/platform/identity/src/IdentityProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Defines interfaces and common infrastructure for establishing @@ -28,7 +27,6 @@ */ define( function () { - "use strict"; /** * Default implementation of an identity service. Provides an diff --git a/platform/identity/test/IdentityAggregatorSpec.js b/platform/identity/test/IdentityAggregatorSpec.js index 07d41c0ce8..3f34cce2e0 100644 --- a/platform/identity/test/IdentityAggregatorSpec.js +++ b/platform/identity/test/IdentityAggregatorSpec.js @@ -19,18 +19,15 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,runs,jasmine*/ define( ["../src/IdentityAggregator"], function (IdentityAggregator) { - "use strict"; describe("The identity aggregator", function () { var mockProviders, mockQ, resolves, - mockPromise, mockCallback, testUsers, aggregator; @@ -57,7 +54,7 @@ define( mockProviders = ['a', 'b', 'c'].map(function (id) { var mockProvider = jasmine.createSpyObj( 'provider-' + id, - [ 'getUser' ] + ['getUser'] ); mockProvider.getUser.andReturn(new Promise(function (r) { @@ -118,7 +115,7 @@ define( }); it("returns undefined when no providers expose users", function () { - testUsers = [ undefined, undefined, undefined ]; + testUsers = [undefined, undefined, undefined]; aggregator.getUser().then(mockCallback); diff --git a/platform/identity/test/IdentityCreationDecoratorSpec.js b/platform/identity/test/IdentityCreationDecoratorSpec.js index 91021a7a8f..761e78cf77 100644 --- a/platform/identity/test/IdentityCreationDecoratorSpec.js +++ b/platform/identity/test/IdentityCreationDecoratorSpec.js @@ -20,14 +20,12 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,Promise,waitsFor,runs */ define( [ '../src/IdentityCreationDecorator' ], function (IdentityCreationDecorator) { - "use strict"; describe("IdentityCreationDecorator", function () { var mockIdentityService, diff --git a/platform/identity/test/IdentityIndicatorSpec.js b/platform/identity/test/IdentityIndicatorSpec.js index 335ca69669..66c2b790b9 100644 --- a/platform/identity/test/IdentityIndicatorSpec.js +++ b/platform/identity/test/IdentityIndicatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/IdentityIndicator"], function (IdentityIndicator) { - "use strict"; describe("The identity indicator", function () { var mockPromise, diff --git a/platform/identity/test/IdentityProviderSpec.js b/platform/identity/test/IdentityProviderSpec.js index 61852c42ff..5a4c82d9c8 100644 --- a/platform/identity/test/IdentityProviderSpec.js +++ b/platform/identity/test/IdentityProviderSpec.js @@ -20,14 +20,12 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,Promise,waitsFor,runs */ define( [ '../src/IdentityProvider' ], function (IdentityProvider) { - "use strict"; describe("IdentityProvider", function () { var mockQ, mockCallback, provider; diff --git a/platform/persistence/aggregator/bundle.js b/platform/persistence/aggregator/bundle.js index c53fecd427..7286010949 100644 --- a/platform/persistence/aggregator/bundle.js +++ b/platform/persistence/aggregator/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/PersistenceAggregator", @@ -28,7 +27,6 @@ define([ PersistenceAggregator, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/persistence/aggregator", { "extensions": { diff --git a/platform/persistence/aggregator/src/PersistenceAggregator.js b/platform/persistence/aggregator/src/PersistenceAggregator.js index 6ca463ecdf..bc988099a7 100644 --- a/platform/persistence/aggregator/src/PersistenceAggregator.js +++ b/platform/persistence/aggregator/src/PersistenceAggregator.js @@ -20,12 +20,10 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,window*/ define( [], function () { - 'use strict'; // Return values to use when a persistence space is unknown, // and there is no appropriate provider to route to. @@ -63,7 +61,9 @@ define( } this.providerMapPromise = $q.all(providers.map(addToMap)) - .then(function () { return providerMap; }); + .then(function () { + return providerMap; + }); } PersistenceAggregator.prototype.listSpaces = function () { diff --git a/platform/persistence/aggregator/test/PersistenceAggregatorSpec.js b/platform/persistence/aggregator/test/PersistenceAggregatorSpec.js index 5e2b5c5fa8..f7db0530ad 100644 --- a/platform/persistence/aggregator/test/PersistenceAggregatorSpec.js +++ b/platform/persistence/aggregator/test/PersistenceAggregatorSpec.js @@ -20,11 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,beforeEach,it,jasmine,expect,spyOn */ define( ['../src/PersistenceAggregator'], function (PersistenceAggregator) { - 'use strict'; var PERSISTENCE_SERVICE_METHODS = [ 'listSpaces', @@ -72,7 +70,9 @@ define( mockQ.all.andCallFake(function (fakePromises) { var result = []; fakePromises.forEach(function (p) { - p.then(function (v) { result.push(v); }); + p.then(function (v) { + result.push(v); + }); }); return fakePromise(result); }); diff --git a/platform/persistence/couch/bundle.js b/platform/persistence/couch/bundle.js index 1045fe2bed..fac58a9bee 100644 --- a/platform/persistence/couch/bundle.js +++ b/platform/persistence/couch/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/CouchPersistenceProvider", @@ -30,7 +29,6 @@ define([ CouchIndicator, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/persistence/couch", { "name": "Couch Persistence", diff --git a/platform/persistence/couch/src/CouchDocument.js b/platform/persistence/couch/src/CouchDocument.js index d61641f041..b1537d1f7a 100644 --- a/platform/persistence/couch/src/CouchDocument.js +++ b/platform/persistence/couch/src/CouchDocument.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * A CouchDocument describes domain object model in a format diff --git a/platform/persistence/couch/src/CouchIndicator.js b/platform/persistence/couch/src/CouchIndicator.js index 684f2e58c5..223a12b7c4 100644 --- a/platform/persistence/couch/src/CouchIndicator.js +++ b/platform/persistence/couch/src/CouchIndicator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; // Set of connection states; changing among these states will be // reflected in the indicator's appearance. @@ -76,7 +74,7 @@ define( // Callback if the HTTP request to Couch fails - function handleError(err) { + function handleError() { self.state = DISCONNECTED; } diff --git a/platform/persistence/couch/src/CouchPersistenceProvider.js b/platform/persistence/couch/src/CouchPersistenceProvider.js index c50cc86386..583d62e379 100644 --- a/platform/persistence/couch/src/CouchPersistenceProvider.js +++ b/platform/persistence/couch/src/CouchPersistenceProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle implements a persistence service which uses CouchDB to @@ -29,7 +28,6 @@ define( ["./CouchDocument"], function (CouchDocument) { - 'use strict'; // JSLint doesn't like dangling _'s, but CouchDB uses these, so // hide this behind variables. @@ -49,46 +47,42 @@ define( * @param {string} path the path to the CouchDB instance */ function CouchPersistenceProvider($http, $q, space, path) { - this.spaces = [ space ]; + this.spaces = [space]; this.revs = {}; this.$q = $q; this.$http = $http; this.path = path; } - function bind(fn, thisArg) { - return function () { - return fn.apply(thisArg, arguments); - }; - } - // Pull out a list of document IDs from CouchDB's // _all_docs response function getIdsFromAllDocs(allDocs) { - return allDocs.rows.map(function (r) { return r.id; }); + return allDocs.rows.map(function (r) { + return r.id; + }); } // Check the response to a create/update/delete request; // track the rev if it's valid, otherwise return false to // indicate that the request failed. - function checkResponse(response) { + CouchPersistenceProvider.prototype.checkResponse = function (response) { if (response && response.ok) { this.revs[response.id] = response.rev; return response.ok; } else { return false; } - } + }; // Get a domain object model out of CouchDB's response - function getModel(response) { + CouchPersistenceProvider.prototype.getModel = function (response) { if (response && response.model) { this.revs[response[ID]] = response[REV]; return response.model; } else { return undefined; } - } + }; // Issue a request using $http; get back the plain JS object // from the expected JSON response @@ -118,30 +112,30 @@ define( return this.$q.when(this.spaces); }; - CouchPersistenceProvider.prototype.listObjects = function (space) { - return this.get("_all_docs").then(bind(getIdsFromAllDocs, this)); + CouchPersistenceProvider.prototype.listObjects = function () { + return this.get("_all_docs").then(getIdsFromAllDocs.bind(this)); }; CouchPersistenceProvider.prototype.createObject = function (space, key, value) { return this.put(key, new CouchDocument(key, value)) - .then(bind(checkResponse, this)); + .then(this.checkResponse.bind(this)); }; CouchPersistenceProvider.prototype.readObject = function (space, key) { - return this.get(key).then(bind(getModel, this)); + return this.get(key).then(this.getModel.bind(this)); }; CouchPersistenceProvider.prototype.updateObject = function (space, key, value) { var rev = this.revs[key]; return this.put(key, new CouchDocument(key, value, rev)) - .then(bind(checkResponse, this)); + .then(this.checkResponse.bind(this)); }; CouchPersistenceProvider.prototype.deleteObject = function (space, key, value) { var rev = this.revs[key]; return this.put(key, new CouchDocument(key, value, rev, true)) - .then(bind(checkResponse, this)); + .then(this.checkResponse.bind(this)); }; return CouchPersistenceProvider; diff --git a/platform/persistence/couch/test/CouchDocumentSpec.js b/platform/persistence/couch/test/CouchDocumentSpec.js index 17cd8f9361..90f9de41ec 100644 --- a/platform/persistence/couch/test/CouchDocumentSpec.js +++ b/platform/persistence/couch/test/CouchDocumentSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * DomainObjectProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/CouchDocument"], function (CouchDocument) { - "use strict"; // JSLint doesn't like dangling _'s, but CouchDB uses these, so // hide this behind variables. @@ -62,4 +60,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/persistence/couch/test/CouchIndicatorSpec.js b/platform/persistence/couch/test/CouchIndicatorSpec.js index d24baf6ab1..5d056a42cf 100644 --- a/platform/persistence/couch/test/CouchIndicatorSpec.js +++ b/platform/persistence/couch/test/CouchIndicatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/CouchIndicator"], function (CouchIndicator) { - "use strict"; describe("The CouchDB status indicator", function () { var mockHttp, @@ -35,9 +33,9 @@ define( indicator; beforeEach(function () { - mockHttp = jasmine.createSpyObj("$http", [ "get" ]); + mockHttp = jasmine.createSpyObj("$http", ["get"]); mockInterval = jasmine.createSpy("$interval"); - mockPromise = jasmine.createSpyObj("promise", [ "then" ]); + mockPromise = jasmine.createSpyObj("promise", ["then"]); testPath = "/test/path"; testInterval = 12321; // Some number @@ -129,4 +127,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/persistence/couch/test/CouchPersistenceProviderSpec.js b/platform/persistence/couch/test/CouchPersistenceProviderSpec.js index c803f4a258..36c1a04317 100644 --- a/platform/persistence/couch/test/CouchPersistenceProviderSpec.js +++ b/platform/persistence/couch/test/CouchPersistenceProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * DomainObjectProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/CouchPersistenceProvider"], function (CouchPersistenceProvider) { - "use strict"; describe("The couch persistence provider", function () { var mockHttp, @@ -73,7 +71,7 @@ define( // return values match what is expected. it("lists all available documents", function () { mockHttp.andReturn(mockPromise({ - data: { rows: [ { id: "a" }, { id: "b" }, { id: "c" } ] } + data: { rows: [{ id: "a" }, { id: "b" }, { id: "c" }] } })); provider.listObjects().then(capture); expect(mockHttp).toHaveBeenCalledWith({ @@ -189,4 +187,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/persistence/elastic/bundle.js b/platform/persistence/elastic/bundle.js index a830caacbe..c7687301e4 100644 --- a/platform/persistence/elastic/bundle.js +++ b/platform/persistence/elastic/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/ElasticPersistenceProvider", @@ -32,7 +31,6 @@ define([ ElasticIndicator, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/persistence/elastic", { "name": "ElasticSearch Persistence", diff --git a/platform/persistence/elastic/src/ElasticIndicator.js b/platform/persistence/elastic/src/ElasticIndicator.js index 767c37c8cb..b55878f0b9 100644 --- a/platform/persistence/elastic/src/ElasticIndicator.js +++ b/platform/persistence/elastic/src/ElasticIndicator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; // Set of connection states; changing among these states will be // reflected in the indicator's appearance. diff --git a/platform/persistence/elastic/src/ElasticPersistenceProvider.js b/platform/persistence/elastic/src/ElasticPersistenceProvider.js index c7d21ae81d..2fe826bb49 100644 --- a/platform/persistence/elastic/src/ElasticPersistenceProvider.js +++ b/platform/persistence/elastic/src/ElasticPersistenceProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle implements a persistence service which uses ElasticSearch to @@ -29,7 +28,6 @@ define( [], function () { - 'use strict'; // JSLint doesn't like underscore-prefixed properties, // so hide them here. @@ -52,7 +50,7 @@ define( * @param {stirng} path the path to domain objects within ElasticSearch */ function ElasticPersistenceProvider($http, $q, space, root, path) { - this.spaces = [ space ]; + this.spaces = [space]; this.revs = {}; this.$http = $http; this.$q = $q; @@ -60,12 +58,6 @@ define( this.path = path; } - function bind(fn, thisArg) { - return function () { - return fn.apply(thisArg, arguments); - }; - } - // Issue a request using $http; get back the plain JS object // from the expected JSON response ElasticPersistenceProvider.prototype.request = function (subpath, method, value, params) { @@ -100,8 +92,8 @@ define( if ((response || {}).status === CONFLICT) { error.key = "revision"; // Load the updated model, then reject the promise - return this.get(key).then(function (response) { - error.model = response[SRC]; + return this.get(key).then(function (res) { + error.model = res[SRC]; return $q.reject(error); }); } @@ -110,14 +102,14 @@ define( }; // Get a domain object model out of ElasticSearch's response - function getModel(response) { + ElasticPersistenceProvider.prototype.getModel = function (response) { if (response && response[SRC]) { this.revs[response[ID]] = response[REV]; return response[SRC]; } else { return undefined; } - } + }; // Check the response to a create/update/delete request; // track the rev if it's valid, otherwise return false to @@ -143,23 +135,24 @@ define( ElasticPersistenceProvider.prototype.createObject = function (space, key, value) { - return this.put(key, value).then(bind(this.checkResponse, this)); + return this.put(key, value).then(this.checkResponse.bind(this)); }; ElasticPersistenceProvider.prototype.readObject = function (space, key) { - return this.get(key).then(bind(getModel, this)); + return this.get(key).then(this.getModel.bind(this)); }; ElasticPersistenceProvider.prototype.updateObject = function (space, key, value) { + var self = this; function checkUpdate(response) { - return this.checkResponse(response, key); + return self.checkResponse(response, key); } return this.put(key, value, { version: this.revs[key] }) - .then(bind(checkUpdate, this)); + .then(checkUpdate); }; - ElasticPersistenceProvider.prototype.deleteObject = function (space, key, value) { - return this.del(key).then(bind(this.checkResponse, this)); + ElasticPersistenceProvider.prototype.deleteObject = function (space, key) { + return this.del(key).then(this.checkResponse.bind(this)); }; return ElasticPersistenceProvider; diff --git a/platform/persistence/elastic/src/ElasticSearchProvider.js b/platform/persistence/elastic/src/ElasticSearchProvider.js index 84290d999a..30ef2cd62a 100644 --- a/platform/persistence/elastic/src/ElasticSearchProvider.js +++ b/platform/persistence/elastic/src/ElasticSearchProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining ElasticSearchProvider. Created by shale on 07/16/2015. @@ -29,7 +28,6 @@ define([ ], function ( ) { - "use strict"; var ID_PROPERTY = '_id', SOURCE_PROPERTY = '_source', @@ -75,7 +73,7 @@ define([ }) .then(function success(succesResponse) { return provider.parseResponse(succesResponse); - }, function error(errorResponse) { + }, function error() { // Gracefully fail. return { hits: [], diff --git a/platform/persistence/elastic/test/ElasticIndicatorSpec.js b/platform/persistence/elastic/test/ElasticIndicatorSpec.js index 63aa49f0ac..9f675c5f00 100644 --- a/platform/persistence/elastic/test/ElasticIndicatorSpec.js +++ b/platform/persistence/elastic/test/ElasticIndicatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/ElasticIndicator"], function (ElasticIndicator) { - "use strict"; describe("The ElasticSearch status indicator", function () { var mockHttp, @@ -35,9 +33,9 @@ define( indicator; beforeEach(function () { - mockHttp = jasmine.createSpyObj("$http", [ "get" ]); + mockHttp = jasmine.createSpyObj("$http", ["get"]); mockInterval = jasmine.createSpy("$interval"); - mockPromise = jasmine.createSpyObj("promise", [ "then" ]); + mockPromise = jasmine.createSpyObj("promise", ["then"]); testPath = "/test/path"; testInterval = 12321; // Some number @@ -109,4 +107,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/persistence/elastic/test/ElasticPersistenceProviderSpec.js b/platform/persistence/elastic/test/ElasticPersistenceProviderSpec.js index e99a09ebba..0961e63d74 100644 --- a/platform/persistence/elastic/test/ElasticPersistenceProviderSpec.js +++ b/platform/persistence/elastic/test/ElasticPersistenceProviderSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/ElasticPersistenceProvider"], function (ElasticPersistenceProvider) { - "use strict"; describe("The ElasticSearch persistence provider", function () { var mockHttp, @@ -213,4 +211,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/persistence/elastic/test/ElasticSearchProviderSpec.js b/platform/persistence/elastic/test/ElasticSearchProviderSpec.js index f8337e0862..da79ac7b25 100644 --- a/platform/persistence/elastic/test/ElasticSearchProviderSpec.js +++ b/platform/persistence/elastic/test/ElasticSearchProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,spyOn,Promise,waitsFor*/ /** * SearchSpec. Created by shale on 07/31/2015. @@ -29,7 +28,6 @@ define([ ], function ( ElasticSearchProvider ) { - 'use strict'; describe('ElasticSearchProvider', function () { var $http, diff --git a/platform/persistence/local/bundle.js b/platform/persistence/local/bundle.js index 93f9895407..e09e19e4b7 100644 --- a/platform/persistence/local/bundle.js +++ b/platform/persistence/local/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/LocalStoragePersistenceProvider", @@ -30,7 +29,6 @@ define([ LocalStorageIndicator, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/persistence/local", { "extensions": { @@ -40,6 +38,7 @@ define([ "type": "provider", "implementation": LocalStoragePersistenceProvider, "depends": [ + "$window", "$q", "PERSISTENCE_SPACE" ] diff --git a/platform/persistence/local/src/LocalStorageIndicator.js b/platform/persistence/local/src/LocalStorageIndicator.js index df6f868ead..37ab457098 100644 --- a/platform/persistence/local/src/LocalStorageIndicator.js +++ b/platform/persistence/local/src/LocalStorageIndicator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,window*/ define( [], function () { - "use strict"; var LOCAL_STORAGE_WARNING = [ "Using browser local storage for persistence.", diff --git a/platform/persistence/local/src/LocalStoragePersistenceProvider.js b/platform/persistence/local/src/LocalStoragePersistenceProvider.js index 0f87b46a45..9f6b594a71 100644 --- a/platform/persistence/local/src/LocalStoragePersistenceProvider.js +++ b/platform/persistence/local/src/LocalStoragePersistenceProvider.js @@ -20,12 +20,9 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,window*/ - define( [], function () { - 'use strict'; /** * The LocalStoragePersistenceProvider reads and writes JSON documents @@ -38,11 +35,11 @@ define( * @param $interval Angular's $interval service * @param {string} space the name of the persistence space being served */ - function LocalStoragePersistenceProvider($q, space) { + function LocalStoragePersistenceProvider($window, $q, space) { this.$q = $q; this.space = space; this.spaces = space ? [space] : []; - this.localStorage = window.localStorage; + this.localStorage = $window.localStorage; } /** @@ -82,7 +79,7 @@ define( return this.$q.when(spaceObj[key]); }; - LocalStoragePersistenceProvider.prototype.deleteObject = function (space, key, value) { + LocalStoragePersistenceProvider.prototype.deleteObject = function (space, key) { var spaceObj = this.getValue(space); delete spaceObj[key]; this.setValue(space, spaceObj); diff --git a/platform/persistence/local/test/LocalStorageIndicatorSpec.js b/platform/persistence/local/test/LocalStorageIndicatorSpec.js index 0e71ebceba..566275f0b6 100644 --- a/platform/persistence/local/test/LocalStorageIndicatorSpec.js +++ b/platform/persistence/local/test/LocalStorageIndicatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/LocalStorageIndicator"], function (LocalStorageIndicator) { - "use strict"; describe("The local storage status indicator", function () { var indicator; diff --git a/platform/persistence/local/test/LocalStoragePersistenceProviderSpec.js b/platform/persistence/local/test/LocalStoragePersistenceProviderSpec.js index 5d42117164..50869cf9a0 100644 --- a/platform/persistence/local/test/LocalStoragePersistenceProviderSpec.js +++ b/platform/persistence/local/test/LocalStoragePersistenceProviderSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,afterEach,waitsFor,jasmine*/ define( ["../src/LocalStoragePersistenceProvider"], function (LocalStoragePersistenceProvider) { - "use strict"; describe("The local storage persistence provider", function () { var mockQ, @@ -51,14 +49,10 @@ define( mockQ.when.andCallFake(mockPromise); provider = new LocalStoragePersistenceProvider( + { localStorage: testLocalStorage }, mockQ, - testSpace, - testLocalStorage + testSpace ); - - // White-boxy: Can't effectively mock window.localStorage, - // so override the provider's local reference to it. - provider.localStorage = testLocalStorage; }); it("reports available spaces", function () { diff --git a/platform/persistence/queue/bundle.js b/platform/persistence/queue/bundle.js index 00df156b0a..0312382c6e 100644 --- a/platform/persistence/queue/bundle.js +++ b/platform/persistence/queue/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/QueuingPersistenceCapabilityDecorator", @@ -34,7 +33,6 @@ define([ persistenceFailureDialogTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/persistence/queue", { "extensions": { diff --git a/platform/persistence/queue/src/PersistenceFailureConstants.js b/platform/persistence/queue/src/PersistenceFailureConstants.js index 8eab3d9f4c..9300c2e0ca 100644 --- a/platform/persistence/queue/src/PersistenceFailureConstants.js +++ b/platform/persistence/queue/src/PersistenceFailureConstants.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define({ REVISION_ERROR_KEY: "revision", diff --git a/platform/persistence/queue/src/PersistenceFailureController.js b/platform/persistence/queue/src/PersistenceFailureController.js index 8586854857..7506d535cf 100644 --- a/platform/persistence/queue/src/PersistenceFailureController.js +++ b/platform/persistence/queue/src/PersistenceFailureController.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['moment', './PersistenceFailureConstants'], function (moment, Constants) { - "use strict"; /** * Controller to support the template to be shown in the diff --git a/platform/persistence/queue/src/PersistenceFailureDialog.js b/platform/persistence/queue/src/PersistenceFailureDialog.js index 7b048e7519..9ded808644 100644 --- a/platform/persistence/queue/src/PersistenceFailureDialog.js +++ b/platform/persistence/queue/src/PersistenceFailureDialog.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./PersistenceFailureConstants'], function (PersistenceFailureConstants) { - "use strict"; var OVERWRITE_CANCEL_OPTIONS = [ { @@ -36,7 +34,7 @@ define( key: "cancel" } ], - OK_OPTIONS = [ { name: "OK", key: "ok" } ]; + OK_OPTIONS = [{ name: "OK", key: "ok" }]; /** * Populates a `dialogModel` to pass to `dialogService.getUserChoise` diff --git a/platform/persistence/queue/src/PersistenceFailureHandler.js b/platform/persistence/queue/src/PersistenceFailureHandler.js index 8920ee5543..447519633c 100644 --- a/platform/persistence/queue/src/PersistenceFailureHandler.js +++ b/platform/persistence/queue/src/PersistenceFailureHandler.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./PersistenceFailureDialog', './PersistenceFailureConstants'], function (PersistenceFailureDialog, PersistenceFailureConstants) { - "use strict"; /** * Handle failures to persist domain object models. @@ -70,7 +68,7 @@ define( } // Retry persistence (overwrite) for this set of failed attempts - function retry(failures) { + function retry(failuresToRetry) { var models = {}; // Cache a copy of the model @@ -86,23 +84,25 @@ define( var model = models[failure.id]; return failure.domainObject.useCapability( "mutation", - function () { return model; }, - model.modified - ); + function () { + return model; + }, + model.modified + ); } // Cache the object models we might want to save - failures.forEach(cacheModel); + failuresToRetry.forEach(cacheModel); // Strategy here: // * Cache all of the models we might want to save (above) // * Refresh all domain objects (so they are latest versions) // * Re-insert the cached domain object models // * Invoke persistence again - return $q.all(failures.map(refresh)).then(function () { - return $q.all(failures.map(remutate)); + return $q.all(failuresToRetry.map(refresh)).then(function () { + return $q.all(failuresToRetry.map(remutate)); }).then(function () { - return $q.all(failures.map(persist)); + return $q.all(failuresToRetry.map(persist)); }); } @@ -114,8 +114,8 @@ define( } // Discard changes associated with a failed save - function discardAll(failures) { - return $q.all(failures.map(discard)); + function discardAll(failuresToDiscard) { + return $q.all(failuresToDiscard.map(discard)); } // Handle user input (did they choose to overwrite?) diff --git a/platform/persistence/queue/src/PersistenceQueue.js b/platform/persistence/queue/src/PersistenceQueue.js index e704dafe71..6b43eca0c5 100644 --- a/platform/persistence/queue/src/PersistenceQueue.js +++ b/platform/persistence/queue/src/PersistenceQueue.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [ @@ -32,7 +31,6 @@ define( PersistenceQueueHandler, PersistenceFailureHandler ) { - "use strict"; /** diff --git a/platform/persistence/queue/src/PersistenceQueueHandler.js b/platform/persistence/queue/src/PersistenceQueueHandler.js index 4d630ce208..511685b350 100644 --- a/platform/persistence/queue/src/PersistenceQueueHandler.js +++ b/platform/persistence/queue/src/PersistenceQueueHandler.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Handles actual persistence invocations for queeud persistence @@ -59,20 +57,20 @@ define( failureHandler = this.failureHandler; // Handle a group of persistence invocations - function persistGroup(ids, persistences, domainObjects, queue) { + function persistGroup(groupIds, persistenceCaps, domainObjs, pQueue) { var failures = []; // Try to persist a specific domain object function tryPersist(id) { // Look up its persistence capability from the provided // id->persistence object. - var persistence = persistences[id], - domainObject = domainObjects[id]; + var persistence = persistenceCaps[id], + domainObject = domainObjs[id]; // Put a domain object back in the queue // (e.g. after Overwrite) function requeue() { - return queue.put(domainObject, persistence); + return pQueue.put(domainObject, persistence); } // Handle success @@ -105,7 +103,7 @@ define( } // Try to persist everything, then handle any failures - return $q.all(ids.map(tryPersist)).then(handleFailure); + return $q.all(groupIds.map(tryPersist)).then(handleFailure); } return persistGroup(ids, persistences, domainObjects, queue); diff --git a/platform/persistence/queue/src/PersistenceQueueImpl.js b/platform/persistence/queue/src/PersistenceQueueImpl.js index fa68ca864c..f177800afe 100644 --- a/platform/persistence/queue/src/PersistenceQueueImpl.js +++ b/platform/persistence/queue/src/PersistenceQueueImpl.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The PersistenceQueue is used by the QueuingPersistenceCapability @@ -68,8 +66,8 @@ define( // Check if the queue's size has stopped increasing) function quiescent() { - return Object.keys(self.persistences).length - === self.lastObservedSize; + return Object.keys(self.persistences).length === + self.lastObservedSize; } // Persist all queued objects diff --git a/platform/persistence/queue/src/QueuingPersistenceCapability.js b/platform/persistence/queue/src/QueuingPersistenceCapability.js index 8fe006504a..816f8d92d9 100644 --- a/platform/persistence/queue/src/QueuingPersistenceCapability.js +++ b/platform/persistence/queue/src/QueuingPersistenceCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The QueuingPersistenceCapability places `persist` calls in a queue diff --git a/platform/persistence/queue/src/QueuingPersistenceCapabilityDecorator.js b/platform/persistence/queue/src/QueuingPersistenceCapabilityDecorator.js index a86fe60515..a76711fa2a 100644 --- a/platform/persistence/queue/src/QueuingPersistenceCapabilityDecorator.js +++ b/platform/persistence/queue/src/QueuingPersistenceCapabilityDecorator.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * This bundle decorates the persistence service to handle persistence @@ -30,7 +29,6 @@ define( ['./QueuingPersistenceCapability'], function (QueuingPersistenceCapability) { - "use strict"; /** * Capability decorator. Adds queueing support to persistence diff --git a/platform/persistence/queue/test/PersistenceFailureConstantsSpec.js b/platform/persistence/queue/test/PersistenceFailureConstantsSpec.js index c8c2649a66..4eec1ea5e7 100644 --- a/platform/persistence/queue/test/PersistenceFailureConstantsSpec.js +++ b/platform/persistence/queue/test/PersistenceFailureConstantsSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PersistenceFailureConstants"], function (PersistenceFailureConstants) { - "use strict"; describe("Persistence failure constants", function () { it("defines an overwrite key", function () { @@ -34,4 +32,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/persistence/queue/test/PersistenceFailureControllerSpec.js b/platform/persistence/queue/test/PersistenceFailureControllerSpec.js index e870672ff8..d8053daebb 100644 --- a/platform/persistence/queue/test/PersistenceFailureControllerSpec.js +++ b/platform/persistence/queue/test/PersistenceFailureControllerSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PersistenceFailureController"], function (PersistenceFailureController) { - "use strict"; describe("The persistence failure controller", function () { var controller; @@ -45,4 +43,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/persistence/queue/test/PersistenceFailureDialogSpec.js b/platform/persistence/queue/test/PersistenceFailureDialogSpec.js index fd9918ea99..ab66997748 100644 --- a/platform/persistence/queue/test/PersistenceFailureDialogSpec.js +++ b/platform/persistence/queue/test/PersistenceFailureDialogSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PersistenceFailureDialog", "../src/PersistenceFailureConstants"], function (PersistenceFailureDialog, Constants) { - "use strict"; describe("The persistence failure dialog", function () { var testFailures, @@ -56,4 +54,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/persistence/queue/test/PersistenceFailureHandlerSpec.js b/platform/persistence/queue/test/PersistenceFailureHandlerSpec.js index ec4e2d4abe..4157476fb9 100644 --- a/platform/persistence/queue/test/PersistenceFailureHandlerSpec.js +++ b/platform/persistence/queue/test/PersistenceFailureHandlerSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PersistenceFailureHandler", "../src/PersistenceFailureConstants"], function (PersistenceFailureHandler, Constants) { - "use strict"; describe("The persistence failure handler", function () { var mockQ, @@ -106,7 +104,7 @@ define( // User chooses overwrite mockPromise.then.mostRecentCall.args[0](false); // Should refresh, but not remutate, and requeue all objects - mockFailures.forEach(function (mockFailure, i) { + mockFailures.forEach(function (mockFailure) { expect(mockFailure.persistence.refresh).toHaveBeenCalled(); expect(mockFailure.requeue).not.toHaveBeenCalled(); expect(mockFailure.domainObject.useCapability).not.toHaveBeenCalled(); @@ -115,4 +113,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/persistence/queue/test/PersistenceQueueHandlerSpec.js b/platform/persistence/queue/test/PersistenceQueueHandlerSpec.js index 0b46e2b9c7..e85fb7f34c 100644 --- a/platform/persistence/queue/test/PersistenceQueueHandlerSpec.js +++ b/platform/persistence/queue/test/PersistenceQueueHandlerSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PersistenceQueueHandler"], function (PersistenceQueueHandler) { - "use strict"; var TEST_ERROR = { someKey: "some value" }; @@ -49,7 +47,7 @@ define( function makeMockPersistence(id) { var mockPersistence = jasmine.createSpyObj( 'persistence-' + id, - [ 'persist', 'refresh' ] + ['persist', 'refresh'] ); mockPersistence.persist.andReturn(asPromise(true)); return mockPersistence; @@ -58,7 +56,7 @@ define( function makeMockDomainObject(id) { var mockDomainObject = jasmine.createSpyObj( 'domainObject-' + id, - [ 'getId' ] + ['getId'] ); mockDomainObject.getId.andReturn(id); return mockDomainObject; @@ -134,4 +132,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/persistence/queue/test/PersistenceQueueImplSpec.js b/platform/persistence/queue/test/PersistenceQueueImplSpec.js index 836c14cbb2..6281f2d5ac 100644 --- a/platform/persistence/queue/test/PersistenceQueueImplSpec.js +++ b/platform/persistence/queue/test/PersistenceQueueImplSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PersistenceQueueImpl"], function (PersistenceQueueImpl) { - "use strict"; var TEST_DELAY = 42; @@ -40,7 +38,7 @@ define( function makeMockDomainObject(id) { var mockDomainObject = jasmine.createSpyObj( 'domainObject-' + id, - [ 'getId' ] + ['getId'] ); mockDomainObject.getId.andReturn(id); return mockDomainObject; @@ -49,7 +47,7 @@ define( function makeMockPersistence(id) { var mockPersistence = jasmine.createSpyObj( 'persistence-' + id, - [ 'persist' ] + ['persist'] ); return mockPersistence; } @@ -151,4 +149,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/persistence/queue/test/PersistenceQueueSpec.js b/platform/persistence/queue/test/PersistenceQueueSpec.js index dd8e987cbd..fae0009835 100644 --- a/platform/persistence/queue/test/PersistenceQueueSpec.js +++ b/platform/persistence/queue/test/PersistenceQueueSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PersistenceQueue"], function (PersistenceQueue) { - "use strict"; describe("The persistence queue", function () { var mockQ, @@ -53,4 +51,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/persistence/queue/test/QueuingPersistenceCapabilityDecoratorSpec.js b/platform/persistence/queue/test/QueuingPersistenceCapabilityDecoratorSpec.js index 1f8298710c..2e1a04d611 100644 --- a/platform/persistence/queue/test/QueuingPersistenceCapabilityDecoratorSpec.js +++ b/platform/persistence/queue/test/QueuingPersistenceCapabilityDecoratorSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/QueuingPersistenceCapabilityDecorator"], function (QueuingPersistenceCapabilityDecorator) { - "use strict"; describe("A queuing persistence capability decorator", function () { var mockQueue, @@ -81,4 +79,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/persistence/queue/test/QueuingPersistenceCapabilitySpec.js b/platform/persistence/queue/test/QueuingPersistenceCapabilitySpec.js index a2053e367b..e542fe2100 100644 --- a/platform/persistence/queue/test/QueuingPersistenceCapabilitySpec.js +++ b/platform/persistence/queue/test/QueuingPersistenceCapabilitySpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/QueuingPersistenceCapability"], function (QueuingPersistenceCapability) { - "use strict"; describe("A queuing persistence capability", function () { var mockQueue, @@ -64,4 +62,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/policy/bundle.js b/platform/policy/bundle.js index a5dfa31f65..9b58255df6 100644 --- a/platform/policy/bundle.js +++ b/platform/policy/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/PolicyActionDecorator", @@ -32,7 +31,6 @@ define([ PolicyProvider, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/policy", { "name": "Policy Service", diff --git a/platform/policy/src/PolicyActionDecorator.js b/platform/policy/src/PolicyActionDecorator.js index 96dbd9498e..a8cec1442c 100644 --- a/platform/policy/src/PolicyActionDecorator.js +++ b/platform/policy/src/PolicyActionDecorator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Filters out actions based on policy. @@ -42,7 +40,7 @@ define( PolicyActionDecorator.prototype.getActions = function (context) { var policyService = this.policyService; - + // Check if an action is allowed by policy. function allow(action) { return policyService.allow('action', action, context); diff --git a/platform/policy/src/PolicyProvider.js b/platform/policy/src/PolicyProvider.js index 38858cadcc..fac4588c4b 100644 --- a/platform/policy/src/PolicyProvider.js +++ b/platform/policy/src/PolicyProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle implements the policy service. @@ -28,7 +27,6 @@ define( [], function () { - "use strict"; /** * A policy is a participant in decision-making policies. Policies diff --git a/platform/policy/src/PolicyViewDecorator.js b/platform/policy/src/PolicyViewDecorator.js index c9ac54b173..a8306cb589 100644 --- a/platform/policy/src/PolicyViewDecorator.js +++ b/platform/policy/src/PolicyViewDecorator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Filters out views based on policy. diff --git a/platform/policy/test/PolicyActionDecoratorSpec.js b/platform/policy/test/PolicyActionDecoratorSpec.js index 136898570d..ed7cc8af7d 100644 --- a/platform/policy/test/PolicyActionDecoratorSpec.js +++ b/platform/policy/test/PolicyActionDecoratorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PolicyActionDecorator"], function (PolicyActionDecorator) { - "use strict"; describe("The policy action decorator", function () { var mockPolicyService, @@ -88,13 +86,13 @@ define( it("filters out policy-disallowed actions", function () { // Disallow the second action - mockPolicyService.allow.andCallFake(function (cat, candidate, ctxt) { + mockPolicyService.allow.andCallFake(function (cat, candidate) { return candidate.someKey !== 'b'; }); expect(decorator.getActions(testContext)) - .toEqual([ testActions[0], testActions[2] ]); + .toEqual([testActions[0], testActions[2]]); }); }); } -); \ No newline at end of file +); diff --git a/platform/policy/test/PolicyProviderSpec.js b/platform/policy/test/PolicyProviderSpec.js index 040648f06c..ac827cb0f6 100644 --- a/platform/policy/test/PolicyProviderSpec.js +++ b/platform/policy/test/PolicyProviderSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PolicyProvider"], function (PolicyProvider) { - "use strict"; describe("The policy provider", function () { var testPolicies, @@ -45,7 +43,9 @@ define( ]; mockPolicies = testPolicies.map(function (p) { var mockPolicy = jasmine.createSpyObj("policy", ['allow']); - mockPolicy.allow.andCallFake(function () { return p.result; }); + mockPolicy.allow.andCallFake(function () { + return p.result; + }); return mockPolicy; }); mockPolicyConstructors = testPolicies.map(function (p, i) { @@ -103,4 +103,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/policy/test/PolicyViewDecoratorSpec.js b/platform/policy/test/PolicyViewDecoratorSpec.js index 346099666a..f7f698cb22 100644 --- a/platform/policy/test/PolicyViewDecoratorSpec.js +++ b/platform/policy/test/PolicyViewDecoratorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/PolicyViewDecorator"], function (PolicyViewDecorator) { - "use strict"; describe("The policy view decorator", function () { var mockPolicyService, @@ -92,13 +90,13 @@ define( it("filters out policy-disallowed views", function () { // Disallow the second action - mockPolicyService.allow.andCallFake(function (cat, candidate, ctxt) { + mockPolicyService.allow.andCallFake(function (cat, candidate) { return candidate.someKey !== 'b'; }); expect(decorator.getViews(mockDomainObject)) - .toEqual([ testViews[0], testViews[2] ]); + .toEqual([testViews[0], testViews[2]]); }); }); } -); \ No newline at end of file +); diff --git a/platform/representation/bundle.js b/platform/representation/bundle.js index c257e972f0..01484ccb78 100644 --- a/platform/representation/bundle.js +++ b/platform/representation/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/MCTInclude", @@ -48,7 +47,6 @@ define([ TemplatePrefetcher, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/representation", { "extensions": { @@ -88,10 +86,7 @@ define([ "implementation": DropGesture, "depends": [ "dndService", - "$q", - "navigationService", - "instantiate", - "typeService" + "$q" ] }, { diff --git a/platform/representation/src/MCTInclude.js b/platform/representation/src/MCTInclude.js index 748a57f479..2f7dbc7d62 100644 --- a/platform/representation/src/MCTInclude.js +++ b/platform/representation/src/MCTInclude.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining MCTInclude. Created by vwoeltje on 11/7/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Defines the mct-include directive. This acts like the diff --git a/platform/representation/src/MCTRepresentation.js b/platform/representation/src/MCTRepresentation.js index 54b0743e0c..953ed7cf5a 100644 --- a/platform/representation/src/MCTRepresentation.js +++ b/platform/representation/src/MCTRepresentation.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * This bundle implements the directives for representing domain objects @@ -29,7 +28,6 @@ define( [], function () { - "use strict"; /** * Defines the mct-representation directive. This may be used to @@ -55,8 +53,7 @@ define( * @param {ViewDefinition[]} views an array of view extensions */ function MCTRepresentation(representations, views, representers, $q, templateLinker, $log) { - var representationMap = {}, - gestureMap = {}; + var representationMap = {}; // Assemble all representations and views // The distinction between views and representations is @@ -84,16 +81,16 @@ define( } } - function link($scope, element, attrs, ctrl, transclude) { + function link($scope, element, attrs) { var activeRepresenters = representers.map(function (Representer) { return new Representer($scope, element, attrs); }), toClear = [], // Properties to clear out of scope on change counter = 0, couldRepresent = false, - couldEdit = false, lastIdPath = [], lastKey, + statusListener, changeTemplate = templateLinker.link($scope, element); // Populate scope with any capabilities indicated by the @@ -139,14 +136,13 @@ define( }); } - function unchanged(canRepresent, canEdit, idPath, key) { + function unchanged(canRepresent, idPath, key) { return (canRepresent === couldRepresent) && (key === lastKey) && (idPath.length === lastIdPath.length) && idPath.every(function (id, i) { return id === lastIdPath[i]; - }) && - (canEdit === couldEdit); + }); } function getIdPath(domainObject) { @@ -170,11 +166,10 @@ define( representation = lookup($scope.key, domainObject), uses = ((representation || {}).uses || []), canRepresent = !!(representation && domainObject), - canEdit = !!(domainObject && domainObject.hasCapability('editor')), idPath = getIdPath(domainObject), key = $scope.key; - if (unchanged(canRepresent, canEdit, idPath, key)) { + if (unchanged(canRepresent, idPath, key)) { return; } @@ -182,10 +177,6 @@ define( // representation to store local variables into. $scope.representation = {}; - // Change templates (passing in undefined to clear - // if we don't have enough info to show a template.) - changeTemplate(canRepresent ? representation : undefined); - // Any existing representers are no longer valid; release them. destroyRepresenters(); @@ -203,7 +194,6 @@ define( // To allow simplified change detection next time around couldRepresent = canRepresent; lastIdPath = idPath; - couldEdit = canEdit; lastKey = key; // Populate scope with fields associated with the current @@ -232,6 +222,10 @@ define( // next change object/key pair changes toClear = uses.concat(['model']); } + + // Change templates (passing in undefined to clear + // if we don't have enough info to show a template.) + changeTemplate(canRepresent ? representation : undefined); } // Update the representation when the key changes (e.g. if a @@ -250,6 +244,11 @@ define( // Make sure any resources allocated by representers also get // released. $scope.$on("$destroy", destroyRepresenters); + $scope.$on("$destroy", function () { + if (statusListener) { + statusListener(); + } + }); // Do one initial refresh, so that we don't need another // digest iteration just to populate the scope. Failure to diff --git a/platform/representation/src/TemplateLinker.js b/platform/representation/src/TemplateLinker.js index 27bf317afb..e248ebd1de 100644 --- a/platform/representation/src/TemplateLinker.js +++ b/platform/representation/src/TemplateLinker.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( [], function () { - "use strict"; /** * The `templateLinker` service is intended for internal use by @@ -156,12 +154,12 @@ define( activeTemplateUrl = templateUrl; } - function changeTemplate(ext) { - ext = ext || {}; - if (ext.templateUrl) { - changeTemplateUrl(self.getPath(ext)); - } else if (ext.template) { - showTemplate(ext.template); + function changeTemplate(templateExt) { + templateExt = templateExt || {}; + if (templateExt.templateUrl) { + changeTemplateUrl(self.getPath(templateExt)); + } else if (templateExt.template) { + showTemplate(templateExt.template); } else { removeElement(); } diff --git a/platform/representation/src/TemplatePrefetcher.js b/platform/representation/src/TemplatePrefetcher.js index 7d20bc1031..25fd223610 100644 --- a/platform/representation/src/TemplatePrefetcher.js +++ b/platform/representation/src/TemplatePrefetcher.js @@ -19,11 +19,9 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ define( function () { - 'use strict'; /** * Loads all templates when the application is started. @@ -33,7 +31,7 @@ define( * @param {...Array.<{templateUrl: string}>} extensions arrays * of template or template-like extensions */ - function TemplatePrefetcher(templateLinker, extensions) { + function TemplatePrefetcher(templateLinker) { Array.prototype.slice.apply(arguments, [1]) .reduce(function (a, b) { return a.concat(b); diff --git a/platform/representation/src/actions/ContextMenuAction.js b/platform/representation/src/actions/ContextMenuAction.js index 82e11713f9..11acd0ed51 100644 --- a/platform/representation/src/actions/ContextMenuAction.js +++ b/platform/representation/src/actions/ContextMenuAction.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining ContextMenuAction. Created by shale on 06/30/2015. @@ -27,7 +26,6 @@ define( ["../gestures/GestureConstants"], function (GestureConstants) { - "use strict"; var MENU_TEMPLATE = " 0; - } - function dragOver(e) { - //Refresh domain object on each dragOver to catch external - // updates to the model - //Don't use EditableDomainObject for folders, allow immediate persistence - if (domainObject.hasCapability('editor') || - domainObject.getModel().type==='folder') { - editableDomainObject = domainObject; - } else { - editableDomainObject = new EditableDomainObject(domainObject, $q); - } - - actionCapability = editableDomainObject.getCapability('action'); - var event = (e || {}).originalEvent || e, selectedObject = dndService.getData( GestureConstants.MCT_EXTENDED_DRAG_TYPE @@ -116,21 +91,17 @@ define( function drop(e) { var event = (e || {}).originalEvent || e, - id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE), - domainObjectType = editableDomainObject.getModel().type; + id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE); // Handle the drop; add the dropped identifier to the // destination domain object's composition, and persist // the change. if (id) { e.preventDefault(); - $q.when(action && action.perform()).then(function (result) { - //Don't go into edit mode for folders - if (domainObjectType!=='folder') { - editableDomainObject.getCapability('action').perform('edit'); - } + $q.when(action && action.perform()).then(function () { broadcastDrop(id, event); }); + } } diff --git a/platform/representation/src/gestures/GestureConstants.js b/platform/representation/src/gestures/GestureConstants.js index f43487424a..45b998d630 100644 --- a/platform/representation/src/gestures/GestureConstants.js +++ b/platform/representation/src/gestures/GestureConstants.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Constants used by domain object gestures. @@ -45,7 +44,7 @@ define({ * positioning. * @memberof platform/representation.GestureConstants */ - MCT_MENU_DIMENSIONS: [ 170, 200 ], + MCT_MENU_DIMENSIONS: [170, 200], /** * Identifier for drop events. * @memberof platform/representation.GestureConstants diff --git a/platform/representation/src/gestures/GestureProvider.js b/platform/representation/src/gestures/GestureProvider.js index 30b463505d..7f3d049ddb 100644 --- a/platform/representation/src/gestures/GestureProvider.js +++ b/platform/representation/src/gestures/GestureProvider.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise*/ /** * Module defining GestureProvider. Created by vwoeltje on 11/22/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Handles the attachment of gestures (responses to DOM events, diff --git a/platform/representation/src/gestures/GestureRepresenter.js b/platform/representation/src/gestures/GestureRepresenter.js index 9353722ae8..69f9d2e833 100644 --- a/platform/representation/src/gestures/GestureRepresenter.js +++ b/platform/representation/src/gestures/GestureRepresenter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * The GestureRepresenter is responsible for installing predefined diff --git a/platform/representation/src/services/DndService.js b/platform/representation/src/services/DndService.js index b8c4ae7bfe..3df251db58 100644 --- a/platform/representation/src/services/DndService.js +++ b/platform/representation/src/services/DndService.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Drag-and-drop service. diff --git a/platform/representation/test/MCTIncludeSpec.js b/platform/representation/test/MCTIncludeSpec.js index dc1a139968..169d801241 100644 --- a/platform/representation/test/MCTIncludeSpec.js +++ b/platform/representation/test/MCTIncludeSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTIncudeSpec. Created by vwoeltje on 11/6/14. @@ -27,7 +26,6 @@ define( ["../src/MCTInclude"], function (MCTInclude) { - "use strict"; describe("The mct-include directive", function () { var testTemplates, diff --git a/platform/representation/test/MCTRepresentationSpec.js b/platform/representation/test/MCTRepresentationSpec.js index b764f89cb1..98da386c91 100644 --- a/platform/representation/test/MCTRepresentationSpec.js +++ b/platform/representation/test/MCTRepresentationSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -27,17 +26,17 @@ define( ["../src/MCTRepresentation"], function (MCTRepresentation) { - "use strict"; - var JQLITE_FUNCTIONS = [ "on", "off", "attr", "removeAttr" ], - LOG_FUNCTIONS = [ "error", "warn", "info", "debug"], - DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability"]; + var JQLITE_FUNCTIONS = ["on", "off", "attr", "removeAttr"], + LOG_FUNCTIONS = ["error", "warn", "info", "debug"], + DOMAIN_OBJECT_METHODS = ["getId", "getModel", "getCapability", "hasCapability", "useCapability"]; describe("The mct-representation directive", function () { var testRepresentations, testViews, testUrls, mockRepresenters, + mockStatusCapability, mockQ, mockLinker, mockLog, @@ -77,7 +76,7 @@ define( key: "def", bundle: { path: "d", resources: "e" }, templateUrl: "f/template.html", - uses: [ "testCapability", "otherTestCapability" ] + uses: ["testCapability", "otherTestCapability"] } ]; @@ -86,7 +85,7 @@ define( key: "uvw", bundle: { path: "u", resources: "v" }, templateUrl: "w/template.html", - gestures: [ "testGesture", "otherTestGesture" ] + gestures: ["testGesture", "otherTestGesture"] }, { key: "xyz", @@ -106,7 +105,7 @@ define( var constructor = jasmine.createSpy("Representer" + name), representer = jasmine.createSpyObj( "representer" + name, - [ "represent", "destroy" ] + ["represent", "destroy"] ); constructor.andReturn(representer); return constructor; @@ -120,7 +119,9 @@ define( mockChangeTemplate = jasmine.createSpy('changeTemplate'); mockLog = jasmine.createSpyObj("$log", LOG_FUNCTIONS); - mockScope = jasmine.createSpyObj("scope", [ "$watch", "$on" ]); + mockStatusCapability = jasmine.createSpyObj("statusCapability", ["listen"]); + + mockScope = jasmine.createSpyObj("scope", ["$watch", "$on"]); mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS); mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS); @@ -130,6 +131,10 @@ define( return testUrls[ext.key]; }); + mockDomainObject.getCapability.andCallFake(function (c) { + return c === 'status' && mockStatusCapability; + }); + mctRepresentation = new MCTRepresentation( testRepresentations, testViews, @@ -189,6 +194,21 @@ define( .toHaveBeenCalledWith(testViews[1]); }); + it("exposes configuration before changing templates", function () { + var observedConfiguration; + + mockChangeTemplate.andCallFake(function () { + observedConfiguration = mockScope.configuration; + }); + + mockScope.key = "xyz"; + mockScope.domainObject = mockDomainObject; + fireWatch('key', mockScope.key); + fireWatch('domainObject', mockDomainObject); + + expect(observedConfiguration).toBeDefined(); + }); + it("does not load templates until there is an object", function () { mockScope.key = "xyz"; @@ -231,7 +251,7 @@ define( expect(mockLog.warn).toHaveBeenCalled(); }); - it("clears out obsolete peroperties from scope", function () { + it("clears out obsolete properties from scope", function () { mockScope.key = "def"; mockScope.domainObject = mockDomainObject; mockDomainObject.useCapability.andReturn("some value"); @@ -309,6 +329,7 @@ define( mockScope.$watch.calls[0].args[1](); expect(mockChangeTemplate.calls.length).toEqual(callCount); }); + }); diff --git a/platform/representation/test/TemplateLinkerSpec.js b/platform/representation/test/TemplateLinkerSpec.js index 2db92a42d7..c91e82e6a7 100644 --- a/platform/representation/test/TemplateLinkerSpec.js +++ b/platform/representation/test/TemplateLinkerSpec.js @@ -19,16 +19,14 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TemplateLinker"], function (TemplateLinker) { - 'use strict'; - var JQLITE_METHODS = [ 'replaceWith', 'empty', 'html', 'contents' ], - SCOPE_METHODS = [ '$on', '$new', '$destroy' ]; + var JQLITE_METHODS = ['replaceWith', 'empty', 'html', 'contents'], + SCOPE_METHODS = ['$on', '$new', '$destroy']; describe("TemplateLinker", function () { var mockTemplateRequest, diff --git a/platform/representation/test/TemplatePrefetcherSpec.js b/platform/representation/test/TemplatePrefetcherSpec.js index 269f6cc0da..99eda9efa7 100644 --- a/platform/representation/test/TemplatePrefetcherSpec.js +++ b/platform/representation/test/TemplatePrefetcherSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TemplatePrefetcher"], function (TemplatePrefetcher) { - 'use strict'; describe("TemplatePrefetcher", function () { var mockTemplateLinker, @@ -38,7 +36,7 @@ define( mockTemplateLinker = jasmine.createSpyObj( 'templateLinker', - [ 'getPath', 'load' ] + ['getPath', 'load'] ); mockTemplateLinker.getPath.andCallFake(function (ext) { diff --git a/platform/representation/test/actions/ContextMenuActionSpec.js b/platform/representation/test/actions/ContextMenuActionSpec.js index ba24076fbb..4efb48d76b 100644 --- a/platform/representation/test/actions/ContextMenuActionSpec.js +++ b/platform/representation/test/actions/ContextMenuActionSpec.js @@ -19,20 +19,17 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ /** * Module defining ContextMenuActionSpec. Created by shale on 07/02/2015. */ define( - ["../../src/actions/ContextMenuAction", "../../src/gestures/GestureConstants"], - function (ContextMenuAction, GestureConstants) { - "use strict"; + ["../../src/actions/ContextMenuAction"], + function (ContextMenuAction) { - var JQLITE_FUNCTIONS = [ "on", "off", "find", "append", "remove" ], - DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ], - MENU_DIMENSIONS = GestureConstants.MCT_MENU_DIMENSIONS; + var JQLITE_FUNCTIONS = ["on", "off", "find", "append", "remove"], + DOMAIN_OBJECT_METHODS = ["getId", "getModel", "getCapability", "hasCapability", "useCapability"]; describe("The 'context menu' action", function () { @@ -96,7 +93,7 @@ define( action.perform(); expect(mockPopupService.display).toHaveBeenCalledWith( mockMenu, - [ mockEvent.pageX, mockEvent.pageY ], + [mockEvent.pageX, mockEvent.pageY], jasmine.any(Object) ); }); @@ -107,7 +104,7 @@ define( }); it("adds classes to menus based on position", function () { - var booleans = [ false, true ]; + var booleans = [false, true]; booleans.forEach(function (goLeft) { booleans.forEach(function (goUp) { diff --git a/platform/representation/test/gestures/ContextMenuGestureSpec.js b/platform/representation/test/gestures/ContextMenuGestureSpec.js index 0e78729ef9..20e15bcbbb 100644 --- a/platform/representation/test/gestures/ContextMenuGestureSpec.js +++ b/platform/representation/test/gestures/ContextMenuGestureSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** @@ -28,10 +27,9 @@ define( ["../../src/gestures/ContextMenuGesture"], function (ContextMenuGesture) { - "use strict"; - var JQLITE_FUNCTIONS = [ "on", "off", "find", "append", "remove" ], - DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability"]; + var JQLITE_FUNCTIONS = ["on", "off", "find", "append", "remove"], + DOMAIN_OBJECT_METHODS = ["getId", "getModel", "getCapability", "hasCapability", "useCapability"]; describe("The 'context menu' gesture", function () { @@ -57,15 +55,15 @@ define( mockEvent = jasmine.createSpyObj("event", ["preventDefault"]); mockContextMenuAction = jasmine.createSpyObj( "action", - [ "perform", "getActions" ] + ["perform", "getActions"] ); - + mockActionContext = {domainObject: mockDomainObject, event: mockEvent}; mockDomainObject.getCapability.andReturn(mockContextMenuAction); mockContextMenuAction.perform.andReturn(jasmine.any(Function)); mockAgentService.isMobile.andReturn(false); - - + + gesture = new ContextMenuGesture(mockTimeout, mockAgentService, mockElement, mockDomainObject); // Capture the contextmenu callback @@ -92,7 +90,7 @@ define( mockDomainObject.calls ); }); - + it("attaches a callback for context menu events on mobile", function () { // Mock touch event and set to mobile device mockTouchEvent = jasmine.createSpyObj("event", ["preventDefault", "touches"]); @@ -100,21 +98,21 @@ define( mockTouch.length = 1; mockTouchEvent.touches.andReturn(mockTouch); mockAgentService.isMobile.andReturn(true); - + // Then create new (mobile) gesture gesture = new ContextMenuGesture(mockTimeout, mockAgentService, mockElement, mockDomainObject); - + // Set calls for the touchstart and touchend gestures fireTouchStartGesture = mockElement.on.calls[1].args[1]; fireTouchEndGesture = mockElement.on.mostRecentCall.args[1]; - + // Fire touchstart and expect touch start to begin fireTouchStartGesture(mockTouchEvent); expect(mockElement.on).toHaveBeenCalledWith( "touchstart", jasmine.any(Function) ); - + // Expect timeout to begin and then fireTouchEnd expect(mockTimeout).toHaveBeenCalled(); mockTimeout.mostRecentCall.args[0](); @@ -122,4 +120,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/representation/test/gestures/DragGestureSpec.js b/platform/representation/test/gestures/DragGestureSpec.js index b179605e99..6ae71754fa 100644 --- a/platform/representation/test/gestures/DragGestureSpec.js +++ b/platform/representation/test/gestures/DragGestureSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * DragGestureSpec. Created by vwoeltje on 11/6/14. @@ -27,12 +26,11 @@ define( ["../../src/gestures/DragGesture", "../../src/gestures/GestureConstants"], function (DragGesture, GestureConstants) { - "use strict"; - var JQLITE_FUNCTIONS = [ "on", "off", "attr", "removeAttr" ], - LOG_FUNCTIONS = [ "error", "warn", "info", "debug"], - DND_FUNCTIONS = [ "setData", "getData", "removeData" ], - DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability"], + var JQLITE_FUNCTIONS = ["on", "off", "attr", "removeAttr"], + LOG_FUNCTIONS = ["error", "warn", "info", "debug"], + DND_FUNCTIONS = ["setData", "getData", "removeData"], + DOMAIN_OBJECT_METHODS = ["getId", "getModel", "getCapability", "hasCapability", "useCapability"], TEST_ID = "test-id"; @@ -137,4 +135,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/representation/test/gestures/DropGestureSpec.js b/platform/representation/test/gestures/DropGestureSpec.js index 52327792ab..79ed9d1139 100644 --- a/platform/representation/test/gestures/DropGestureSpec.js +++ b/platform/representation/test/gestures/DropGestureSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine,xit,xdescribe*/ /** * DropGestureSpec. Created by vwoeltje on 11/6/14. @@ -27,12 +26,11 @@ define( ["../../src/gestures/DropGesture"], function (DropGesture) { - "use strict"; // Methods to mock - var JQLITE_FUNCTIONS = [ "on", "off", "attr", "removeAttr", "scope" ], - DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability"], + var JQLITE_FUNCTIONS = ["on", "off", "attr", "removeAttr", "scope"], + DOMAIN_OBJECT_METHODS = ["getId", "getModel", "getCapability", "hasCapability", "useCapability"], TEST_ID = "test-id", DROP_ID = "drop-id"; @@ -71,9 +69,9 @@ define( mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS); mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS); mockDraggedObject = jasmine.createSpyObj("draggedObject", DOMAIN_OBJECT_METHODS); - mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]); + mockPersistence = jasmine.createSpyObj("persistence", ["persist"]); mockEvent = jasmine.createSpyObj("event", ["preventDefault"]); - mockEvent.dataTransfer = jasmine.createSpyObj("dataTransfer", [ "getData" ]); + mockEvent.dataTransfer = jasmine.createSpyObj("dataTransfer", ["getData"]); mockScope = jasmine.createSpyObj("$scope", ["$broadcast"]); mockUnwrappedElement = jasmine.createSpyObj("unwrapped", ["getBoundingClientRect"]); mockAction = jasmine.createSpyObj('action', ['getActions']); @@ -132,11 +130,11 @@ define( expect(mockEvent.preventDefault).toHaveBeenCalled(); expect(mockEvent.dataTransfer.dropEffect).toBeDefined(); }); - + it("invokes compose on drop in edit mode", function () { // Set the mockDomainObject to have the editor capability mockDomainObject.hasCapability.andReturn(true); - + callbacks.dragover(mockEvent); expect(mockAction.getActions).toHaveBeenCalledWith({ key: 'compose', @@ -145,14 +143,14 @@ define( callbacks.drop(mockEvent); expect(mockCompose.perform).toHaveBeenCalled(); }); - - + + it("does not invoke compose on drop in browse mode for non-folders", function () { // Set the mockDomainObject to not have the editor capability mockDomainObject.hasCapability.andReturn(false); // Set the mockDomainObject to not have a type of folder mockDomainObject.getModel.andReturn({type: 'notAFolder'}); - + callbacks.dragover(mockEvent); expect(mockAction.getActions).toHaveBeenCalledWith({ key: 'compose', @@ -161,8 +159,8 @@ define( callbacks.drop(mockEvent); expect(mockCompose.perform).not.toHaveBeenCalled(); }); - - + + it("invokes compose on drop in browse mode for folders", function () { // Set the mockDomainObject to not have the editor capability mockDomainObject.hasCapability.andReturn(false); @@ -177,11 +175,11 @@ define( callbacks.drop(mockEvent); expect(mockCompose.perform).toHaveBeenCalled(); }); - + it("broadcasts drop position (in edit mode)", function () { // Set the mockDomainObject to have the editor capability mockDomainObject.hasCapability.andReturn(true); - + testRect.left = 42; testRect.top = 36; mockEvent.pageX = 52; diff --git a/platform/representation/test/gestures/GestureProviderSpec.js b/platform/representation/test/gestures/GestureProviderSpec.js index 9ef5c35157..f4e29b66d9 100644 --- a/platform/representation/test/gestures/GestureProviderSpec.js +++ b/platform/representation/test/gestures/GestureProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ /** * GestureProviderSpec. Created by vwoeltje on 11/6/14. @@ -27,11 +26,10 @@ define( ["../../src/gestures/GestureProvider"], function (GestureProvider) { - "use strict"; - var JQLITE_FUNCTIONS = [ "on", "off", "attr", "removeAttr" ], + var JQLITE_FUNCTIONS = ["on", "off", "attr", "removeAttr"], GESTURE_KEYS = ["a", "b", "c", "d", "e"], - DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability"]; + DOMAIN_OBJECT_METHODS = ["getId", "getModel", "getCapability", "hasCapability", "useCapability"]; describe("The gesture provider", function () { var mockGestures, @@ -88,4 +86,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/representation/test/gestures/GestureRepresenterSpec.js b/platform/representation/test/gestures/GestureRepresenterSpec.js index 3d08e2bc5f..24ce81e0d0 100644 --- a/platform/representation/test/gestures/GestureRepresenterSpec.js +++ b/platform/representation/test/gestures/GestureRepresenterSpec.js @@ -19,28 +19,25 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ define( ["../../src/gestures/GestureRepresenter"], function (GestureRepresenter) { - "use strict"; describe("A gesture representer", function () { var mockGestureService, mockGestureHandle, - mockScope, mockElement, representer; beforeEach(function () { mockGestureService = jasmine.createSpyObj( "gestureService", - [ "attachGestures" ] + ["attachGestures"] ); mockGestureHandle = jasmine.createSpyObj( "gestureHandle", - [ "destroy" ] + ["destroy"] ); mockElement = { someKey: "some value" }; @@ -65,7 +62,7 @@ define( expect(mockGestureService.attachGestures).toHaveBeenCalledWith( mockElement, domainObject, - [ "a", "b", "c" ] + ["a", "b", "c"] ); // Should not have been destroyed yet... @@ -80,4 +77,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/representation/test/services/DndServiceSpec.js b/platform/representation/test/services/DndServiceSpec.js index a4b26d5dd4..ecadcc0f69 100644 --- a/platform/representation/test/services/DndServiceSpec.js +++ b/platform/representation/test/services/DndServiceSpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../../src/services/DndService"], function (DndService) { - "use strict"; describe("The drag-and-drop service", function () { var service; @@ -37,7 +35,9 @@ define( it("allows setting of arbitrary objects", function () { var foo = { - bar: function () { return 42; } + bar: function () { + return 42; + } }; service.setData('xyz', foo); @@ -63,4 +63,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/search/bundle.js b/platform/search/bundle.js index 7a0a9f4b9e..14e9a2c093 100644 --- a/platform/search/bundle.js +++ b/platform/search/bundle.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/controllers/SearchController", "./src/controllers/SearchMenuController", - "./src/controllers/ClickAwayController", "./src/services/GenericSearchProvider", "./src/services/SearchAggregator", "text!./res/templates/search-item.html", @@ -34,7 +32,6 @@ define([ ], function ( SearchController, SearchMenuController, - ClickAwayController, GenericSearchProvider, SearchAggregator, searchItemTemplate, @@ -42,7 +39,6 @@ define([ searchMenuTemplate, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/search", { "name": "Search", @@ -73,14 +69,6 @@ define([ "$scope", "types[]" ] - }, - { - "key": "ClickAwayController", - "implementation": ClickAwayController, - "depends": [ - "$scope", - "$document" - ] } ], "representations": [ diff --git a/platform/search/src/controllers/ClickAwayController.js b/platform/search/src/controllers/ClickAwayController.js deleted file mode 100644 index 9b92e89cc0..0000000000 --- a/platform/search/src/controllers/ClickAwayController.js +++ /dev/null @@ -1,105 +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. - *****************************************************************************/ -/*global define,Promise*/ - -/* - * Copied from the ClickAwayController in platform/commonUI/general - */ - -define( - [], - function () { - "use strict"; - - /** - * A ClickAwayController is used to toggle things (such as context - * menus) where clicking elsewhere in the document while the toggle - * is in an active state is intended to dismiss the toggle. - * - * @constructor - * @param $scope the scope in which this controller is active - * @param $document the document element, injected by Angular - */ - function ClickAwayController($scope, $document) { - var state = false, - clickaway; - - // Track state, but also attach and detach a listener for - // mouseup events on the document. - function deactivate() { - state = false; - $document.off("mouseup", clickaway); - } - - function activate() { - state = true; - $document.on("mouseup", clickaway); - } - - function changeState() { - if (state) { - deactivate(); - } else { - activate(); - } - } - - // Callback used by the document listener. Deactivates; - // note also $scope.$apply is invoked to indicate that - // the state of this controller has changed. - clickaway = function () { - deactivate(); - $scope.$apply(); - return false; - }; - - return { - /** - * Get the current state of the toggle. - * @return {boolean} true if active - */ - isActive: function () { - return state; - }, - /** - * Set a new state for the toggle. - * @return {boolean} true to activate - */ - setState: function (newState) { - if (state !== newState) { - changeState(); - } - }, - /** - * Toggle the current state; activate if it is inactive, - * deactivate if it is active. - */ - toggle: function () { - changeState(); - } - }; - - } - - return ClickAwayController; - } -); \ No newline at end of file diff --git a/platform/search/src/controllers/SearchController.js b/platform/search/src/controllers/SearchController.js index 629e495331..2edb7f1cf9 100644 --- a/platform/search/src/controllers/SearchController.js +++ b/platform/search/src/controllers/SearchController.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining SearchController. Created by shale on 07/15/2015. */ define(function () { - "use strict"; /** * Controller for search in Tree View. diff --git a/platform/search/src/controllers/SearchMenuController.js b/platform/search/src/controllers/SearchMenuController.js index e0d8c342e5..c46fb0657c 100644 --- a/platform/search/src/controllers/SearchMenuController.js +++ b/platform/search/src/controllers/SearchMenuController.js @@ -19,38 +19,36 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining SearchMenuController. Created by shale on 08/17/2015. */ define(function () { - "use strict"; - + function SearchMenuController($scope, types) { - - // Model variables are: - // ngModel.filter, the function filter defined in SearchController + + // Model variables are: + // ngModel.filter, the function filter defined in SearchController // ngModel.types, an array of type objects - // ngModel.checked, a dictionary of which type filter options are checked - // ngModel.checkAll, a boolean of whether all of the types in ngModel.checked are checked + // ngModel.checked, a dictionary of which type filter options are checked + // ngModel.checkAll, a boolean of whether all of the types in ngModel.checked are checked // ngModel.filtersString, a string list of what filters on the results are active $scope.ngModel.types = []; $scope.ngModel.checked = {}; $scope.ngModel.checkAll = true; $scope.ngModel.filtersString = ''; - + // On initialization, fill the model's types with type keys types.forEach(function (type) { // We only want some types, the ones that are probably human readable - // Manually remove 'root', but not 'unknown' + // Manually remove 'root', but not 'unknown' if (type.key && type.name && type.key !== 'root') { $scope.ngModel.types.push(type); $scope.ngModel.checked[type.key] = false; } }); - - + + // For documentation, see updateOptions below function updateOptions() { var type, @@ -64,7 +62,7 @@ define(function () { } } } - + // Update the current filters string $scope.ngModel.filtersString = ''; if (!$scope.ngModel.checkAll) { @@ -79,7 +77,7 @@ define(function () { } } } - // If there's still nothing in the filters string, there are no + // If there's still nothing in the filters string, there are no // filters selected if ($scope.ngModel.filtersString === '') { $scope.ngModel.filtersString = 'NONE'; @@ -89,16 +87,14 @@ define(function () { // Re-filter results $scope.ngModel.filter(); } - + // For documentation, see checkAll below function checkAll() { - var type; - // Reset all the other options to original/default position - for (type in $scope.ngModel.checked) { + Object.keys($scope.ngModel.checked).forEach(function (type) { $scope.ngModel.checked[type] = false; - } - + }); + // Change the filters string depending on checkAll status if ($scope.ngModel.checkAll) { // This setting will make the filters display hidden @@ -106,23 +102,23 @@ define(function () { } else { $scope.ngModel.filtersString = 'NONE'; } - + // Re-filter results $scope.ngModel.filter(); } - + return { /** - * Updates the status of the checked options. Updates the filtersString + * Updates the status of the checked options. Updates the filtersString * with which options are checked. Re-filters the search results after. - * Not intended to be called by checkAll when it is toggled. + * Not intended to be called by checkAll when it is toggled. */ updateOptions: updateOptions, - + /** - * Handles the search and filter options for when checkAll has been - * toggled. This is a special case, compared to the other search - * menu options, so is intended to be called instead of updateOptions. + * Handles the search and filter options for when checkAll has been + * toggled. This is a special case, compared to the other search + * menu options, so is intended to be called instead of updateOptions. */ checkAll: checkAll }; diff --git a/platform/search/src/services/GenericSearchProvider.js b/platform/search/src/services/GenericSearchProvider.js index cc93655f45..b610bb022d 100644 --- a/platform/search/src/services/GenericSearchProvider.js +++ b/platform/search/src/services/GenericSearchProvider.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,setTimeout*/ +/*global setTimeout*/ /** * Module defining GenericSearchProvider. Created by shale on 07/16/2015. @@ -29,7 +29,6 @@ define([ ], function ( ) { - "use strict"; /** * A search service which searches through domain objects in @@ -121,8 +120,8 @@ define([ provider = this; mutationTopic.listen(function (mutatedObject) { - var status = mutatedObject.getCapability('status'); - if (!status || !status.get('editing')) { + var editor = mutatedObject.getCapability('editor'); + if (!editor || !editor.inEditContext()) { provider.index( mutatedObject.getId(), mutatedObject.getModel() @@ -179,8 +178,8 @@ define([ }); if (Array.isArray(model.composition)) { - model.composition.forEach(function (id) { - provider.scheduleForIndexing(id); + model.composition.forEach(function (idToIndex) { + provider.scheduleForIndexing(idToIndex); }); } }; diff --git a/platform/search/src/services/GenericSearchWorker.js b/platform/search/src/services/GenericSearchWorker.js index 928f66cab8..3b6962e55a 100644 --- a/platform/search/src/services/GenericSearchWorker.js +++ b/platform/search/src/services/GenericSearchWorker.js @@ -19,13 +19,13 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ + /*global self*/ /** * Module defining GenericSearchWorker. Created by shale on 07/21/2015. */ (function () { - "use strict"; // An array of objects composed of domain object IDs and models // {id: domainObject's ID, model: domainObject's model} @@ -118,7 +118,7 @@ match.matchCount += 100; } else if (match.item.vector.lowerCaseName === query.inputLowerCase) { - match.matchCount += 50; + match.matchCount += 50; } return match; }) diff --git a/platform/search/src/services/SearchAggregator.js b/platform/search/src/services/SearchAggregator.js index 00988f81a8..f782b2c876 100644 --- a/platform/search/src/services/SearchAggregator.js +++ b/platform/search/src/services/SearchAggregator.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining SearchAggregator. Created by shale on 07/16/2015. @@ -29,7 +28,6 @@ define([ ], function ( ) { - "use strict"; /** * Aggregates multiple search providers as a singular search provider. diff --git a/platform/search/test/controllers/ClickAwayControllerSpec.js b/platform/search/test/controllers/ClickAwayControllerSpec.js deleted file mode 100644 index 96e7b6c13f..0000000000 --- a/platform/search/test/controllers/ClickAwayControllerSpec.js +++ /dev/null @@ -1,94 +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. - *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ - -define( - ["../../src/controllers/ClickAwayController"], - function (ClickAwayController) { - "use strict"; - - describe("The click-away controller", function () { - var mockScope, - mockDocument, - controller; - - beforeEach(function () { - mockScope = jasmine.createSpyObj( - "$scope", - [ "$apply" ] - ); - mockDocument = jasmine.createSpyObj( - "$document", - [ "on", "off" ] - ); - controller = new ClickAwayController(mockScope, mockDocument); - }); - - it("is initially inactive", function () { - expect(controller.isActive()).toBe(false); - }); - - it("does not listen to the document before being toggled", function () { - expect(mockDocument.on).not.toHaveBeenCalled(); - }); - - it("tracks enabled/disabled state when toggled", function () { - controller.toggle(); - expect(controller.isActive()).toBe(true); - controller.toggle(); - expect(controller.isActive()).toBe(false); - controller.toggle(); - expect(controller.isActive()).toBe(true); - controller.toggle(); - expect(controller.isActive()).toBe(false); - }); - - it("allows active state to be explictly specified", function () { - controller.setState(true); - expect(controller.isActive()).toBe(true); - controller.setState(true); - expect(controller.isActive()).toBe(true); - controller.setState(false); - expect(controller.isActive()).toBe(false); - controller.setState(false); - expect(controller.isActive()).toBe(false); - }); - - it("registers a mouse listener when activated", function () { - controller.setState(true); - expect(mockDocument.on).toHaveBeenCalled(); - }); - - it("deactivates and detaches listener on document click", function () { - var callback; - controller.setState(true); - callback = mockDocument.on.mostRecentCall.args[1]; - callback(); - expect(controller.isActive()).toEqual(false); - expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback); - }); - - - - }); - } -); \ No newline at end of file diff --git a/platform/search/test/controllers/SearchControllerSpec.js b/platform/search/test/controllers/SearchControllerSpec.js index a755594d58..7f9095ebe3 100644 --- a/platform/search/test/controllers/SearchControllerSpec.js +++ b/platform/search/test/controllers/SearchControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ /** * SearchSpec. Created by shale on 07/31/2015. @@ -29,7 +28,6 @@ define([ ], function ( SearchController ) { - 'use strict'; describe('The search controller', function () { var mockScope, @@ -53,7 +51,7 @@ define([ beforeEach(function () { mockScope = jasmine.createSpyObj( '$scope', - [ '$watch' ] + ['$watch'] ); mockScope.ngModel = {}; mockScope.ngModel.input = 'test input'; @@ -63,11 +61,11 @@ define([ mockSearchService = jasmine.createSpyObj( 'searchService', - [ 'query' ] + ['query'] ); mockPromise = jasmine.createSpyObj( 'promise', - [ 'then' ] + ['then'] ); mockSearchService.query.andReturn(mockPromise); @@ -75,11 +73,11 @@ define([ mockSearchResult = jasmine.createSpyObj( 'searchResult', - [ '' ] + [''] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getModel' ] + ['getModel'] ); mockSearchResult.object = mockDomainObject; mockDomainObject.getModel.andReturn({name: 'Mock Object', type: 'mock.type'}); diff --git a/platform/search/test/controllers/SearchMenuControllerSpec.js b/platform/search/test/controllers/SearchMenuControllerSpec.js index 9e31f461c5..dda5f491bd 100644 --- a/platform/search/test/controllers/SearchMenuControllerSpec.js +++ b/platform/search/test/controllers/SearchMenuControllerSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ /** * SearchSpec. Created by shale on 08/17/2015. @@ -27,25 +26,23 @@ define( ["../../src/controllers/SearchMenuController"], function (SearchMenuController) { - "use strict"; describe("The search menu controller", function () { var mockScope, - mockPromise, mockTypes, controller; - + beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "" ] + [""] ); - + mockTypes = [ {key: 'mock.type.1', name: 'Mock Type 1', glyph: 'a'}, {key: 'mock.type.2', name: 'Mock Type 2', glyph: 'b'} ]; - + mockScope.ngModel = {}; mockScope.ngModel.checked = {}; mockScope.ngModel.checked['mock.type.1'] = false; @@ -53,81 +50,75 @@ define( mockScope.ngModel.checkAll = true; mockScope.ngModel.filter = jasmine.createSpy('$scope.ngModel.filter'); mockScope.ngModel.filtersString = ''; - + controller = new SearchMenuController(mockScope, mockTypes); }); - + it("gets types on initiliztion", function () { expect(mockScope.ngModel.types).toBeDefined(); }); - + it("refilters results when options are updated", function () { controller.updateOptions(); expect(mockScope.ngModel.filter).toHaveBeenCalled(); - + controller.checkAll(); expect(mockScope.ngModel.filter).toHaveBeenCalled(); }); - + it("updates the filters string when options are updated", function () { controller.updateOptions(); expect(mockScope.ngModel.filtersString).toEqual(''); - + mockScope.ngModel.checked['mock.type.1'] = true; - + controller.updateOptions(); expect(mockScope.ngModel.filtersString).not.toEqual(''); }); - + it("changing checkAll status updates the filter string", function () { controller.checkAll(); expect(mockScope.ngModel.filtersString).toEqual(''); - + mockScope.ngModel.checkAll = false; - + controller.checkAll(); expect(mockScope.ngModel.filtersString).toEqual('NONE'); }); - + it("checking checkAll option resets other options", function () { - var type; - mockScope.ngModel.checked['mock.type.1'] = true; mockScope.ngModel.checked['mock.type.2'] = true; - + controller.checkAll(); - - for (type in mockScope.ngModel.checked) { + + Object.keys(mockScope.ngModel.checked).forEach(function (type) { expect(mockScope.ngModel.checked[type]).toBeFalsy(); - } + }); }); - + it("tells the user when no options are checked", function () { - var type; - - for (type in mockScope.ngModel.checked) { + Object.keys(mockScope.ngModel.checked).forEach(function (type) { mockScope.ngModel.checked[type] = false; - } + }); mockScope.ngModel.checkAll = false; - + controller.updateOptions(); - + expect(mockScope.ngModel.filtersString).toEqual('NONE'); }); - + it("tells the user when options are checked", function () { - var type; - mockScope.ngModel.checkAll = false; - for (type in mockScope.ngModel.checked) { + Object.keys(mockScope.ngModel.checked).forEach(function (type) { mockScope.ngModel.checked[type] = true; - } - + }); + controller.updateOptions(); - + expect(mockScope.ngModel.filtersString).not.toEqual('NONE'); expect(mockScope.ngModel.filtersString).not.toEqual(''); }); }); } -); \ No newline at end of file +); diff --git a/platform/search/test/services/GenericSearchProviderSpec.js b/platform/search/test/services/GenericSearchProviderSpec.js index 97f12966b1..5df794819c 100644 --- a/platform/search/test/services/GenericSearchProviderSpec.js +++ b/platform/search/test/services/GenericSearchProviderSpec.js @@ -19,8 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,Promise,spyOn,waitsFor, - runs*/ /** * SearchSpec. Created by shale on 07/31/2015. @@ -30,7 +28,6 @@ define([ ], function ( GenericSearchProvider ) { - "use strict"; describe('GenericSearchProvider', function () { var $q, @@ -336,7 +333,7 @@ define([ }] }); - expect(provider.pendingQueries[143]).not.toBeDefined(); + expect(provider.pendingQueries[143]).not.toBeDefined(); }); diff --git a/platform/search/test/services/GenericSearchWorkerSpec.js b/platform/search/test/services/GenericSearchWorkerSpec.js index 20afb4c781..952d2a4d58 100644 --- a/platform/search/test/services/GenericSearchWorkerSpec.js +++ b/platform/search/test/services/GenericSearchWorkerSpec.js @@ -19,8 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,runs,waitsFor,beforeEach,jasmine,Worker, - require,afterEach*/ + +/*global require*/ /** * SearchSpec. Created by shale on 07/31/2015. @@ -30,7 +30,6 @@ define([ ], function ( ) { - 'use strict'; describe('GenericSearchWorker', function () { // If this test fails, make sure this path is correct diff --git a/platform/search/test/services/SearchAggregatorSpec.js b/platform/search/test/services/SearchAggregatorSpec.js index f8bee0dcc0..d274d068f2 100644 --- a/platform/search/test/services/SearchAggregatorSpec.js +++ b/platform/search/test/services/SearchAggregatorSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine,Promise,waitsFor,spyOn*/ /** * SearchSpec. Created by shale on 07/31/2015. @@ -27,7 +26,6 @@ define([ "../../src/services/SearchAggregator" ], function (SearchAggregator) { - "use strict"; describe("SearchAggregator", function () { var $q, diff --git a/platform/status/bundle.js b/platform/status/bundle.js index a1f8041067..8c42be1a26 100644 --- a/platform/status/bundle.js +++ b/platform/status/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/StatusRepresenter", @@ -32,7 +31,6 @@ define([ StatusService, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/status", { "extensions": { diff --git a/platform/status/src/StatusCapability.js b/platform/status/src/StatusCapability.js index 6b0221d188..ec91d7aef6 100644 --- a/platform/status/src/StatusCapability.js +++ b/platform/status/src/StatusCapability.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - 'use strict'; /** * The `status` capability can be used to attach information diff --git a/platform/status/src/StatusConstants.js b/platform/status/src/StatusConstants.js index 75b1bca2e1..832e41c0bb 100644 --- a/platform/status/src/StatusConstants.js +++ b/platform/status/src/StatusConstants.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define({ CSS_CLASS_PREFIX: 's-status-', TOPIC_PREFIX: 'status:' diff --git a/platform/status/src/StatusRepresenter.js b/platform/status/src/StatusRepresenter.js index 550fec3e6d..edb49229e3 100644 --- a/platform/status/src/StatusRepresenter.js +++ b/platform/status/src/StatusRepresenter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./StatusConstants'], function (StatusConstants) { - 'use strict'; var STATUS_CLASS_PREFIX = StatusConstants.CSS_CLASS_PREFIX; diff --git a/platform/status/src/StatusService.js b/platform/status/src/StatusService.js index d75e935429..a6d4477f7c 100644 --- a/platform/status/src/StatusService.js +++ b/platform/status/src/StatusService.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./StatusConstants'], function (StatusConstants) { - 'use strict'; var STATUS_PREFIX = StatusConstants.TOPIC_PREFIX; diff --git a/platform/status/test/StatusCapabilitySpec.js b/platform/status/test/StatusCapabilitySpec.js index 1bd3326c4e..7da9ce259e 100644 --- a/platform/status/test/StatusCapabilitySpec.js +++ b/platform/status/test/StatusCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/StatusCapability"], function (StatusCapability) { - "use strict"; describe("The status capability", function () { var mockStatusService, @@ -36,15 +34,15 @@ define( beforeEach(function () { testId = "some-id"; - testStatusFlags = [ 'a', 'b', 'c' ]; + testStatusFlags = ['a', 'b', 'c']; mockStatusService = jasmine.createSpyObj( 'statusService', - [ 'listen', 'setStatus', 'listStatuses' ] + ['listen', 'setStatus', 'listStatuses'] ); mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getId', 'getCapability', 'getModel' ] + ['getId', 'getCapability', 'getModel'] ); mockUnlisten = jasmine.createSpy('unlisten'); diff --git a/platform/status/test/StatusRepresenterSpec.js b/platform/status/test/StatusRepresenterSpec.js index 1d305ea983..b9c048e511 100644 --- a/platform/status/test/StatusRepresenterSpec.js +++ b/platform/status/test/StatusRepresenterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/StatusRepresenter", "../src/StatusConstants"], function (StatusRepresenter, StatusConstants) { - "use strict"; describe("The status representer", function () { var mockScope, @@ -52,7 +50,7 @@ define( } beforeEach(function () { - testStatusFlags = [ 'x', 'y', 'z' ]; + testStatusFlags = ['x', 'y', 'z']; mockScope = {}; mockElement = jasmine.createSpyObj('element', [ @@ -62,11 +60,11 @@ define( testRepresentation = { key: "someKey" }; mockDomainObject = jasmine.createSpyObj( 'domainObject', - [ 'getModel', 'getId', 'getCapability' ] + ['getModel', 'getId', 'getCapability'] ); mockStatusCapability = jasmine.createSpyObj( 'status', - [ 'list', 'get', 'set', 'listen' ] + ['list', 'get', 'set', 'listen'] ); mockUnlisten = jasmine.createSpy(); diff --git a/platform/status/test/StatusServiceSpec.js b/platform/status/test/StatusServiceSpec.js index c064af6bc8..e530fd53d8 100644 --- a/platform/status/test/StatusServiceSpec.js +++ b/platform/status/test/StatusServiceSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/StatusService"], function (StatusService) { - "use strict"; describe("The status service", function () { var mockTopic, @@ -42,7 +40,7 @@ define( mockTopic = jasmine.createSpy('topic'); mockTopicInstance = jasmine.createSpyObj( 'topicInstance', - [ 'notify', 'listen' ] + ['notify', 'listen'] ); mockUnlisten = jasmine.createSpy('unlisten'); mockCallback = jasmine.createSpy('callback'); @@ -77,7 +75,7 @@ define( it("notifies listeners of changes", function () { statusService.setStatus(testId, testStatus, true); expect(mockTopicInstance.notify) - .toHaveBeenCalledWith([ testStatus ]); + .toHaveBeenCalledWith([testStatus]); statusService.setStatus(testId, testStatus, false); expect(mockTopicInstance.notify) .toHaveBeenCalledWith([ ]); diff --git a/platform/telemetry/bundle.js b/platform/telemetry/bundle.js index 6a901ab687..40b4d5c583 100644 --- a/platform/telemetry/bundle.js +++ b/platform/telemetry/bundle.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define([ "./src/TelemetryAggregator", @@ -38,7 +37,6 @@ define([ TelemetryHandler, legacyRegistry ) { - "use strict"; legacyRegistry.register("platform/telemetry", { "name": "Data bundle", diff --git a/platform/telemetry/src/TelemetryAggregator.js b/platform/telemetry/src/TelemetryAggregator.js index 86257befb7..175064df94 100644 --- a/platform/telemetry/src/TelemetryAggregator.js +++ b/platform/telemetry/src/TelemetryAggregator.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * This bundle provides infrastructure and utility services for handling @@ -29,7 +28,6 @@ define( [], function () { - "use strict"; /** * Describes a request for telemetry data. Note that responses diff --git a/platform/telemetry/src/TelemetryCapability.js b/platform/telemetry/src/TelemetryCapability.js index d89b3cd3bf..02b74806e8 100644 --- a/platform/telemetry/src/TelemetryCapability.js +++ b/platform/telemetry/src/TelemetryCapability.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining TelemetryCapability. Created by vwoeltje on 11/12/14. @@ -27,9 +26,10 @@ define( [], function () { - "use strict"; - var ZERO = function () { return 0; }, + var ZERO = function () { + return 0; + }, EMPTY_SERIES = { getPointCount: ZERO, getDomainValue: ZERO, diff --git a/platform/telemetry/src/TelemetryController.js b/platform/telemetry/src/TelemetryController.js index 83279252d5..73f474d11e 100644 --- a/platform/telemetry/src/TelemetryController.js +++ b/platform/telemetry/src/TelemetryController.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ /** * Module defining TelemetryController. Created by vwoeltje on 11/12/14. @@ -27,7 +26,6 @@ define( [], function () { - "use strict"; /** * Serves as a reusable controller for views (or parts of views) @@ -178,7 +176,7 @@ define( "telemetry" )).then(function (result) { var head = domainObject.hasCapability("telemetry") ? - [ domainObject ] : [], + [domainObject] : [], tail = result || []; return head.concat(tail); }); diff --git a/platform/telemetry/src/TelemetryDelegator.js b/platform/telemetry/src/TelemetryDelegator.js index 37fd1bedbf..594b98397d 100644 --- a/platform/telemetry/src/TelemetryDelegator.js +++ b/platform/telemetry/src/TelemetryDelegator.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Used to handle telemetry delegation associated with a @@ -47,7 +45,7 @@ define( */ TelemetryDelegator.prototype.promiseTelemetryObjects = function (domainObject) { var $q = this.$q; - + // If object has been cleared, there are no relevant // telemetry-providing domain objects. if (!domainObject) { @@ -61,7 +59,7 @@ define( "telemetry" )).then(function (result) { var head = domainObject.hasCapability("telemetry") ? - [ domainObject ] : [], + [domainObject] : [], tail = result || []; return head.concat(tail); }); diff --git a/platform/telemetry/src/TelemetryFormatter.js b/platform/telemetry/src/TelemetryFormatter.js index 3a68a38728..b0dd94b3db 100644 --- a/platform/telemetry/src/TelemetryFormatter.js +++ b/platform/telemetry/src/TelemetryFormatter.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,moment*/ define( [], function () { - "use strict"; /** * The TelemetryFormatter is responsible for formatting (as text diff --git a/platform/telemetry/src/TelemetryHandle.js b/platform/telemetry/src/TelemetryHandle.js index 11fd05bb90..e93a6d3e3d 100644 --- a/platform/telemetry/src/TelemetryHandle.js +++ b/platform/telemetry/src/TelemetryHandle.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * A telemetry handle acts as a helper in issuing requests for diff --git a/platform/telemetry/src/TelemetryHandler.js b/platform/telemetry/src/TelemetryHandler.js index cd0df98724..0f5d665c0c 100644 --- a/platform/telemetry/src/TelemetryHandler.js +++ b/platform/telemetry/src/TelemetryHandler.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TelemetryHandle'], function (TelemetryHandle) { - "use strict"; /** diff --git a/platform/telemetry/src/TelemetryQueue.js b/platform/telemetry/src/TelemetryQueue.js index d51c42a98f..dadb34d3df 100644 --- a/platform/telemetry/src/TelemetryQueue.js +++ b/platform/telemetry/src/TelemetryQueue.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Supports TelemetrySubscription. Provides a simple data structure @@ -39,22 +37,22 @@ define( function TelemetryQueue() { // General approach here: // * Maintain a queue as an array of objects containing key-value - // pairs. Putting values into the queue will assign to the - // earliest-available queue position for the associated key + // pairs. Putting values into the queue will assign to the + // earliest-available queue position for the associated key // (appending to the array if necessary.) // * Maintain a set of counts for each key, such that determining // the next available queue position is easy; O(1) insertion. - // * When retrieving objects, pop off the queue and decrement + // * When retrieving objects, pop off the queue and decrement // counts. This provides O(n+k) or O(k) retrieval for a queue // of length n with k unique keys; this depends on whether // the browser's implementation of Array.prototype.shift is // O(n) or O(1). - + // Graphically (indexes at top, keys along side, values as *'s), // if we have a queue that looks like: // 0 1 2 3 4 // a * * * * * - // b * * + // b * * // c * * * // // And we put a new value for b, we expect: @@ -95,11 +93,11 @@ define( // Look up an object in the queue that does not have a value // assigned to this key (or, add a new one) - function getFreeObject(key) { - var index = counts[key] || 0, object; + function getFreeObject(k) { + var index = counts[k] || 0, object; // Track the largest free position for this key - counts[key] = index + 1; + counts[k] = index + 1; // If it's before the end of the queue, add it there if (index < queue.length) { diff --git a/platform/telemetry/src/TelemetrySubscriber.js b/platform/telemetry/src/TelemetrySubscriber.js index c6e7ec0bf1..98f52bc2f7 100644 --- a/platform/telemetry/src/TelemetrySubscriber.js +++ b/platform/telemetry/src/TelemetrySubscriber.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ["./TelemetrySubscription"], function (TelemetrySubscription) { - "use strict"; /** * The TelemetrySubscriber is a service which allows diff --git a/platform/telemetry/src/TelemetrySubscription.js b/platform/telemetry/src/TelemetrySubscription.js index 3de00e4c37..7cf524b184 100644 --- a/platform/telemetry/src/TelemetrySubscription.js +++ b/platform/telemetry/src/TelemetrySubscription.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( ['./TelemetryQueue', './TelemetryTable', './TelemetryDelegator'], function (TelemetryQueue, TelemetryTable, TelemetryDelegator) { - "use strict"; /** * A pool of telemetry values. @@ -86,8 +84,8 @@ define( // Look up domain objects which have telemetry capabilities. // This will either be the object in view, or object that // this object delegates its telemetry capability to. - function promiseRelevantObjects(domainObject) { - return delegator.promiseTelemetryObjects(domainObject); + function promiseRelevantObjects(domainObj) { + return delegator.promiseTelemetryObjects(domainObj); } function updateValuesFromPool() { @@ -116,16 +114,16 @@ define( // Look up metadata associated with an object's telemetry - function lookupMetadata(domainObject) { + function lookupMetadata(domainObj) { var telemetryCapability = - domainObject.getCapability("telemetry"); + domainObj.getCapability("telemetry"); return telemetryCapability && telemetryCapability.getMetadata(); } // Update the latest telemetry data for a specific // domain object. This will notify listeners. - function update(domainObject, series) { + function update(domainObj, series) { var count = series && series.getPointCount(); // Only schedule notification if there isn't already @@ -138,21 +136,21 @@ define( // Update the latest-value table if (count > 0) { - pool.put(domainObject.getId(), { + pool.put(domainObj.getId(), { domain: series.getDomainValue(count - 1), range: series.getRangeValue(count - 1), - datum: self.makeDatum(domainObject, series, count - 1) + datum: self.makeDatum(domainObj, series, count - 1) }); } } // Prepare a subscription to a specific telemetry-providing // domain object. - function subscribe(domainObject) { + function subscribe(domainObj) { var telemetryCapability = - domainObject.getCapability("telemetry"); + domainObj.getCapability("telemetry"); return telemetryCapability.subscribe(function (telemetry) { - update(domainObject, telemetry); + update(domainObj, telemetry); }); } diff --git a/platform/telemetry/src/TelemetryTable.js b/platform/telemetry/src/TelemetryTable.js index 2cfcf8823d..e56bed0c49 100644 --- a/platform/telemetry/src/TelemetryTable.js +++ b/platform/telemetry/src/TelemetryTable.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define( [], function () { - "use strict"; /** * Supports TelemetrySubscription. Provides a simple data structure diff --git a/platform/telemetry/test/TelemetryAggregatorSpec.js b/platform/telemetry/test/TelemetryAggregatorSpec.js index 55d3b35860..39ac5a9c9a 100644 --- a/platform/telemetry/test/TelemetryAggregatorSpec.js +++ b/platform/telemetry/test/TelemetryAggregatorSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryAggregator"], function (TelemetryAggregator) { - "use strict"; describe("The telemetry aggregator", function () { var mockQ, @@ -40,10 +38,10 @@ define( }; } - function mockProvider(key, index) { + function makeMockProvider(key, index) { var provider = jasmine.createSpyObj( "provider" + index, - [ "requestTelemetry", "subscribe" ] + ["requestTelemetry", "subscribe"] ), unsubscribe = jasmine.createSpy("unsubscribe" + index); provider.requestTelemetry.andReturn({ someKey: key }); @@ -55,11 +53,11 @@ define( } beforeEach(function () { - mockQ = jasmine.createSpyObj("$q", [ "all" ]); + mockQ = jasmine.createSpyObj("$q", ["all"]); mockQ.all.andReturn(mockPromise([])); mockUnsubscribes = []; - mockProviders = [ "a", "b", "c" ].map(mockProvider); + mockProviders = ["a", "b", "c"].map(makeMockProvider); aggregator = new TelemetryAggregator(mockQ, mockProviders); }); @@ -123,4 +121,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/telemetry/test/TelemetryCapabilitySpec.js b/platform/telemetry/test/TelemetryCapabilitySpec.js index d19048b20d..e5b57cb365 100644 --- a/platform/telemetry/test/TelemetryCapabilitySpec.js +++ b/platform/telemetry/test/TelemetryCapabilitySpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryCapability"], function (TelemetryCapability) { - "use strict"; describe("The telemetry capability", function () { var mockInjector, @@ -51,11 +49,11 @@ define( mockLog = jasmine.createSpyObj("$log", ["warn", "info", "debug"]); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getId", "getCapability", "getModel" ] + ["getId", "getCapability", "getModel"] ); mockTelemetryService = jasmine.createSpyObj( "telemetryService", - [ "requestTelemetry", "subscribe" ] + ["requestTelemetry", "subscribe"] ); mockReject = jasmine.createSpyObj("reject", ["then"]); mockUnsubscribe = jasmine.createSpy("unsubscribe"); @@ -121,7 +119,9 @@ define( it("provides an empty series when telemetry is missing", function () { var series; mockTelemetryService.requestTelemetry.andReturn(mockPromise({})); - telemetry.requestData({}).then(function (s) { series = s; }); + telemetry.requestData({}).then(function (s) { + series = s; + }); expect(series.getPointCount()).toEqual(0); }); @@ -149,7 +149,9 @@ define( it("warns if no telemetry service can be injected", function () { - mockInjector.get.andCallFake(function () { throw ""; }); + mockInjector.get.andCallFake(function () { + throw ""; + }); // Verify precondition expect(mockLog.warn).not.toHaveBeenCalled(); diff --git a/platform/telemetry/test/TelemetryControllerSpec.js b/platform/telemetry/test/TelemetryControllerSpec.js index d3a95e87d2..b5dd7ea847 100644 --- a/platform/telemetry/test/TelemetryControllerSpec.js +++ b/platform/telemetry/test/TelemetryControllerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryController"], function (TelemetryController) { - "use strict"; describe("The telemetry controller", function () { var mockScope, @@ -47,9 +45,9 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "$on", "$broadcast", "$watch" ] + ["$on", "$broadcast", "$watch"] ); - mockQ = jasmine.createSpyObj("$q", [ "all", "when" ]); + mockQ = jasmine.createSpyObj("$q", ["all", "when"]); mockTimeout = jasmine.createSpy("$timeout"); mockLog = jasmine.createSpyObj("$log", ["warn", "info", "debug"]); @@ -66,7 +64,7 @@ define( mockTelemetry = jasmine.createSpyObj( "telemetry", - [ "requestData", "subscribe", "getMetadata" ] + ["requestData", "subscribe", "getMetadata"] ); mockUnsubscribe = jasmine.createSpy("unsubscribe"); @@ -241,4 +239,4 @@ define( }); }); } -); \ No newline at end of file +); diff --git a/platform/telemetry/test/TelemetryDelegatorSpec.js b/platform/telemetry/test/TelemetryDelegatorSpec.js index 9a2053990b..0841020449 100644 --- a/platform/telemetry/test/TelemetryDelegatorSpec.js +++ b/platform/telemetry/test/TelemetryDelegatorSpec.js @@ -19,15 +19,17 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryDelegator"], function (TelemetryDelegator) { - "use strict"; describe("The telemetry delegator", function () { + var delegator; + beforeEach(function () { + delegator = new TelemetryDelegator(); + }); }); } ); diff --git a/platform/telemetry/test/TelemetryFormatterSpec.js b/platform/telemetry/test/TelemetryFormatterSpec.js index 65cd363aa6..cf3794d19b 100644 --- a/platform/telemetry/test/TelemetryFormatterSpec.js +++ b/platform/telemetry/test/TelemetryFormatterSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryFormatter"], function (TelemetryFormatter) { - "use strict"; describe("The telemetry formatter", function () { var mockFormatService, diff --git a/platform/telemetry/test/TelemetryHandleSpec.js b/platform/telemetry/test/TelemetryHandleSpec.js index f342572045..aedf734807 100644 --- a/platform/telemetry/test/TelemetryHandleSpec.js +++ b/platform/telemetry/test/TelemetryHandleSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryHandle"], function (TelemetryHandle) { - "use strict"; describe("A telemetry handle", function () { var mockQ, @@ -73,7 +71,9 @@ define( mockQ.all.andCallFake(function (values) { return values.map(function (v) { var r; - asPromise(v).then(function (value) { r = value; }); + asPromise(v).then(function (value) { + r = value; + }); return r; }); }); diff --git a/platform/telemetry/test/TelemetryHandlerSpec.js b/platform/telemetry/test/TelemetryHandlerSpec.js index a909781329..d6786db931 100644 --- a/platform/telemetry/test/TelemetryHandlerSpec.js +++ b/platform/telemetry/test/TelemetryHandlerSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryHandler"], function (TelemetryHandler) { - "use strict"; describe("The telemetry handler", function () { // TelemetryHandler just provides a factory diff --git a/platform/telemetry/test/TelemetryQueueSpec.js b/platform/telemetry/test/TelemetryQueueSpec.js index 7fc46d9474..af4f866048 100644 --- a/platform/telemetry/test/TelemetryQueueSpec.js +++ b/platform/telemetry/test/TelemetryQueueSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryQueue"], function (TelemetryQueue) { - "use strict"; describe("The telemetry queue", function () { var queue; @@ -73,4 +71,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/telemetry/test/TelemetrySubscriberSpec.js b/platform/telemetry/test/TelemetrySubscriberSpec.js index d0eb972b04..f79cb608fc 100644 --- a/platform/telemetry/test/TelemetrySubscriberSpec.js +++ b/platform/telemetry/test/TelemetrySubscriberSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetrySubscriber"], function (TelemetrySubscriber) { - "use strict"; describe("The telemetry subscriber", function () { // TelemetrySubscriber just provides a factory @@ -42,7 +40,7 @@ define( mockTimeout = jasmine.createSpy("$timeout"); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getCapability", "useCapability", "hasCapability" ] + ["getCapability", "useCapability", "hasCapability"] ); mockCallback = jasmine.createSpy("callback"); mockPromise = jasmine.createSpyObj("promise", ["then"]); @@ -72,4 +70,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/telemetry/test/TelemetrySubscriptionSpec.js b/platform/telemetry/test/TelemetrySubscriptionSpec.js index e179a76bff..c3e4b23be2 100644 --- a/platform/telemetry/test/TelemetrySubscriptionSpec.js +++ b/platform/telemetry/test/TelemetrySubscriptionSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetrySubscription"], function (TelemetrySubscription) { - "use strict"; describe("A telemetry subscription", function () { var mockQ, @@ -54,7 +52,7 @@ define( mockTimeout = jasmine.createSpy("$timeout"); mockDomainObject = jasmine.createSpyObj( "domainObject", - [ "getCapability", "useCapability", "hasCapability", "getId" ] + ["getCapability", "useCapability", "hasCapability", "getId"] ); mockCallback = jasmine.createSpy("callback"); mockTelemetry = jasmine.createSpyObj( @@ -69,7 +67,7 @@ define( mockUnlisten = jasmine.createSpy("unlisten"); mockSeries = jasmine.createSpyObj( "series", - [ "getPointCount", "getDomainValue", "getRangeValue" ] + ["getPointCount", "getDomainValue", "getRangeValue"] ); mockQ.when.andCallFake(mockPromise); @@ -225,7 +223,7 @@ define( subscription.promiseTelemetryObjects().then(mockCallback2); expect(mockCallback2) - .toHaveBeenCalledWith([ mockDomainObject ]); + .toHaveBeenCalledWith([mockDomainObject]); }); it("reinitializes on mutation", function () { @@ -254,8 +252,8 @@ define( mockSeries.getDomainValue.andCallFake(lookup); mockSeries.getRangeValue.andCallFake(lookup); - testMetadata.domains = [ { key: 'a' }, { key: 'b'} ]; - testMetadata.ranges = [ { key: 'c' }, { key: 'd'} ]; + testMetadata.domains = [{ key: 'a' }, { key: 'b'}]; + testMetadata.ranges = [{ key: 'c' }, { key: 'd'}]; mockTelemetry.subscribe.mostRecentCall.args[0](mockSeries); mockTimeout.mostRecentCall.args[0](); diff --git a/platform/telemetry/test/TelemetryTableSpec.js b/platform/telemetry/test/TelemetryTableSpec.js index a42730dc8c..c787a5ec93 100644 --- a/platform/telemetry/test/TelemetryTableSpec.js +++ b/platform/telemetry/test/TelemetryTableSpec.js @@ -19,12 +19,10 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( ["../src/TelemetryTable"], function (TelemetryTable) { - "use strict"; describe("The telemetry table", function () { var queue; @@ -71,4 +69,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/edit/test/objects/EditableDomainObjectSpec.js b/scripts/migrate-for-jshint.js similarity index 61% rename from platform/commonUI/edit/test/objects/EditableDomainObjectSpec.js rename to scripts/migrate-for-jshint.js index f0f241be96..77a7c14569 100644 --- a/platform/commonUI/edit/test/objects/EditableDomainObjectSpec.js +++ b/scripts/migrate-for-jshint.js @@ -19,15 +19,31 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,describe,it,expect,beforeEach,jasmine*/ -define( - ["../../src/objects/EditableDomainObject"], - function (EditableDomainObject) { - "use strict"; +// Converts all templateUrl references in bundle.js files to +// plain template references, loading said templates with the +// RequireJS text plugin. - describe("Editable domain object", function () { +var glob = require('glob'), + fs = require('fs'); - }); +function migrate(file) { + var sourceCode = fs.readFileSync(file, 'utf8'), + lines = sourceCode.split('\n') + .filter(function (line) { + return !(/^\W*['"]use strict['"];\W*$/.test(line)); + }) + .filter(function (line) { + return line.indexOf("/*global") !== 0; + }); + fs.writeFileSync(file, lines.join('\n')); +} + +glob('@(src|platform)/**/*.js', {}, function (err, files) { + if (err) { + console.log(err); + return; } -); \ No newline at end of file + + files.forEach(migrate); +}); diff --git a/src/BundleRegistry.js b/src/BundleRegistry.js index a65a9b8f3c..f55d3fcd4c 100644 --- a/src/BundleRegistry.js +++ b/src/BundleRegistry.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define*/ define(function () { - 'use strict'; function BundleRegistry() { this.bundles = {}; @@ -49,4 +47,4 @@ define(function () { }; return BundleRegistry; -}); \ No newline at end of file +}); diff --git a/src/BundleRegistrySpec.js b/src/BundleRegistrySpec.js index 04a48d440a..208e9d4fcc 100644 --- a/src/BundleRegistrySpec.js +++ b/src/BundleRegistrySpec.js @@ -19,10 +19,8 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,runs,jasmine*/ define(['./BundleRegistry'], function (BundleRegistry) { - 'use strict'; describe("BundleRegistry", function () { var testPath, @@ -87,4 +85,4 @@ define(['./BundleRegistry'], function (BundleRegistry) { }); -}); \ No newline at end of file +}); diff --git a/src/legacyRegistry.js b/src/legacyRegistry.js index f7a8d13b06..25bf1b40fe 100644 --- a/src/legacyRegistry.js +++ b/src/legacyRegistry.js @@ -19,9 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define, window, requirejs*/ define(['src/BundleRegistry'], function (BundleRegistry) { - 'use strict'; return new BundleRegistry(); -}); \ No newline at end of file +}); diff --git a/src/legacyRegistrySpec.js b/src/legacyRegistrySpec.js index a4b37ea68a..d79bbeb521 100644 --- a/src/legacyRegistrySpec.js +++ b/src/legacyRegistrySpec.js @@ -19,13 +19,11 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global define,Promise,describe,it,expect,beforeEach,waitsFor,runs,jasmine*/ define([ './legacyRegistry', './BundleRegistry' ], function (legacyRegistry, BundleRegistry) { - 'use strict'; describe("legacyRegistry", function () { it("is a BundleRegistry", function () { diff --git a/test-main.js b/test-main.js index 6e4729f050..90da6dabb9 100644 --- a/test-main.js +++ b/test-main.js @@ -67,6 +67,9 @@ requirejs.config({ "moment-duration-format": { "deps": [ "moment" ] }, + "screenfull": { + "exports": "screenfull" + }, "zepto": { "exports": "Zepto" }