Merge pull request #710 from nasa/open673

[Templates] Load templates using RequireJS text plugin
This commit is contained in:
Andrew Henry 2016-02-29 18:45:46 +00:00
commit 7daaecbf8f
39 changed files with 503 additions and 194 deletions

View File

@ -910,7 +910,24 @@ A capability's implementation may also expose a static method `appliesTo(model)`
which should return a boolean value, and will be used by the platform to filter which should return a boolean value, and will be used by the platform to filter
down capabilities to those which should be exposed by specific domain objects, down capabilities to those which should be exposed by specific domain objects,
based on their domain object models. based on their domain object models.
## Containers Category
Containers provide options for the `mct-container` directive.
The definition for an extension in the `containers` category should include:
* `key`: An identifier for the container.
* `template`: An Angular template for the container, including an
`ng-transclude` where contained content should go.
* `attributes`: An array of attribute names. The values associated with
these attributes will be exposed in the template's scope under the
name provided by the `alias` property.
* `alias`: The property name in scope under which attributes will be
exposed. Optional; defaults to "container".
Note that `templateUrl` is not supported for `containers`.
## Controls Category ## Controls Category
Controls provide options for the `mct-control` directive. Controls provide options for the `mct-control` directive.

View File

@ -39,6 +39,7 @@ module.exports = function(config) {
{pattern: 'example/**/*.js', included: false}, {pattern: 'example/**/*.js', included: false},
{pattern: 'platform/**/*.js', included: false}, {pattern: 'platform/**/*.js', included: false},
{pattern: 'warp/**/*.js', included: false}, {pattern: 'warp/**/*.js', included: false},
{pattern: 'platform/**/*.html', included: false},
'test-main.js' 'test-main.js'
], ],

View File

@ -26,12 +26,26 @@ define([
"./src/LogoController", "./src/LogoController",
"./src/AboutController", "./src/AboutController",
"./src/LicenseController", "./src/LicenseController",
"text!./res/templates/app-logo.html",
"text!./res/templates/about-logo.html",
"text!./res/templates/overlay-about.html",
"text!./res/templates/license-apache.html",
"text!./res/templates/license-mit.html",
"text!./res/templates/licenses.html",
"text!./res/templates/licenses-export-md.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
aboutDialogTemplate, aboutDialogTemplate,
LogoController, LogoController,
AboutController, AboutController,
LicenseController, LicenseController,
appLogoTemplate,
aboutLogoTemplate,
overlayAboutTemplate,
licenseApacheTemplate,
licenseMitTemplate,
licensesTemplate,
licensesExportMdTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -43,12 +57,12 @@ define([
{ {
"key": "app-logo", "key": "app-logo",
"priority": "optional", "priority": "optional",
"templateUrl": "templates/app-logo.html" "template": appLogoTemplate
}, },
{ {
"key": "about-logo", "key": "about-logo",
"priority": "preferred", "priority": "preferred",
"templateUrl": "templates/about-logo.html" "template": aboutLogoTemplate
}, },
{ {
"key": "about-dialog", "key": "about-dialog",
@ -56,15 +70,15 @@ define([
}, },
{ {
"key": "overlay-about", "key": "overlay-about",
"templateUrl": "templates/overlay-about.html" "template": overlayAboutTemplate
}, },
{ {
"key": "license-apache", "key": "license-apache",
"templateUrl": "templates/license-apache.html" "template": licenseApacheTemplate
}, },
{ {
"key": "license-mit", "key": "license-mit",
"templateUrl": "templates/license-mit.html" "template": licenseMitTemplate
} }
], ],
"controllers": [ "controllers": [
@ -156,11 +170,11 @@ define([
"routes": [ "routes": [
{ {
"when": "/licenses", "when": "/licenses",
"templateUrl": "templates/licenses.html" "template": licensesTemplate
}, },
{ {
"when": "/licenses-md", "when": "/licenses-md",
"templateUrl": "templates/licenses-export-md.html" "template": licensesExportMdTemplate
} }
] ]
} }

View File

@ -37,6 +37,16 @@ define([
"./src/creation/AddActionProvider", "./src/creation/AddActionProvider",
"./src/creation/CreationService", "./src/creation/CreationService",
"./src/windowing/WindowTitler", "./src/windowing/WindowTitler",
"text!./res/templates/browse.html",
"text!./res/templates/create/locator.html",
"text!./res/templates/browse-object.html",
"text!./res/templates/create/create-button.html",
"text!./res/templates/create/create-menu.html",
"text!./res/templates/items/grid-item.html",
"text!./res/templates/browse/object-header.html",
"text!./res/templates/menu-arrow.html",
"text!./res/templates/back-arrow.html",
"text!./res/templates/items/items.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
BrowseController, BrowseController,
@ -54,6 +64,16 @@ define([
AddActionProvider, AddActionProvider,
CreationService, CreationService,
WindowTitler, WindowTitler,
browseTemplate,
locatorTemplate,
browseObjectTemplate,
createButtonTemplate,
createMenuTemplate,
gridItemTemplate,
objectHeaderTemplate,
menuArrowTemplate,
backArrowTemplate,
itemsTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -63,12 +83,12 @@ define([
"routes": [ "routes": [
{ {
"when": "/browse/:ids*", "when": "/browse/:ids*",
"templateUrl": "templates/browse.html", "template": browseTemplate,
"reloadOnSearch": false "reloadOnSearch": false
}, },
{ {
"when": "", "when": "",
"templateUrl": "templates/browse.html", "template": browseTemplate,
"reloadOnSearch": false "reloadOnSearch": false
} }
], ],
@ -134,13 +154,13 @@ define([
"controls": [ "controls": [
{ {
"key": "locator", "key": "locator",
"templateUrl": "templates/create/locator.html" "template": locatorTemplate
} }
], ],
"representations": [ "representations": [
{ {
"key": "browse-object", "key": "browse-object",
"templateUrl": "templates/browse-object.html", "template": browseObjectTemplate,
"gestures": [ "gestures": [
"drop" "drop"
], ],
@ -150,18 +170,18 @@ define([
}, },
{ {
"key": "create-button", "key": "create-button",
"templateUrl": "templates/create/create-button.html" "template": createButtonTemplate
}, },
{ {
"key": "create-menu", "key": "create-menu",
"templateUrl": "templates/create/create-menu.html", "template": createMenuTemplate,
"uses": [ "uses": [
"action" "action"
] ]
}, },
{ {
"key": "grid-item", "key": "grid-item",
"templateUrl": "templates/items/grid-item.html", "template": gridItemTemplate,
"uses": [ "uses": [
"type", "type",
"action", "action",
@ -174,14 +194,14 @@ define([
}, },
{ {
"key": "object-header", "key": "object-header",
"templateUrl": "templates/browse/object-header.html", "template": objectHeaderTemplate,
"uses": [ "uses": [
"type" "type"
] ]
}, },
{ {
"key": "menu-arrow", "key": "menu-arrow",
"templateUrl": "templates/menu-arrow.html", "template": menuArrowTemplate,
"uses": [ "uses": [
"action" "action"
], ],
@ -194,7 +214,7 @@ define([
"uses": [ "uses": [
"context" "context"
], ],
"templateUrl": "templates/back-arrow.html" "template": backArrowTemplate
} }
], ],
"services": [ "services": [
@ -250,7 +270,7 @@ define([
"name": "Items", "name": "Items",
"glyph": "9", "glyph": "9",
"description": "Grid of available items", "description": "Grid of available items",
"templateUrl": "templates/items/items.html", "template": itemsTemplate,
"uses": [ "uses": [
"composition" "composition"
], ],

View File

@ -24,10 +24,24 @@
define([ define([
"./src/DialogService", "./src/DialogService",
"./src/OverlayService", "./src/OverlayService",
"text!./res/templates/overlay-dialog.html",
"text!./res/templates/overlay-options.html",
"text!./res/templates/dialog.html",
"text!./res/templates/overlay-blocking-message.html",
"text!./res/templates/message.html",
"text!./res/templates/overlay-message-list.html",
"text!./res/templates/overlay.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
DialogService, DialogService,
OverlayService, OverlayService,
overlayDialogTemplate,
overlayOptionsTemplate,
dialogTemplate,
overlayBlockingMessageTemplate,
messageTemplate,
overlayMessageListTemplate,
overlayTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -57,33 +71,33 @@ define([
"templates": [ "templates": [
{ {
"key": "overlay-dialog", "key": "overlay-dialog",
"templateUrl": "templates/overlay-dialog.html" "template": overlayDialogTemplate
}, },
{ {
"key": "overlay-options", "key": "overlay-options",
"templateUrl": "templates/overlay-options.html" "template": overlayOptionsTemplate
}, },
{ {
"key": "form-dialog", "key": "form-dialog",
"templateUrl": "templates/dialog.html" "template": dialogTemplate
}, },
{ {
"key": "overlay-blocking-message", "key": "overlay-blocking-message",
"templateUrl": "templates/overlay-blocking-message.html" "template": overlayBlockingMessageTemplate
}, },
{ {
"key": "message", "key": "message",
"templateUrl": "templates/message.html" "template": messageTemplate
}, },
{ {
"key": "overlay-message-list", "key": "overlay-message-list",
"templateUrl": "templates/overlay-message-list.html" "template": overlayMessageListTemplate
} }
], ],
"containers": [ "containers": [
{ {
"key": "overlay", "key": "overlay",
"templateUrl": "templates/overlay.html" "template": overlayTemplate
} }
] ]
} }

View File

@ -36,6 +36,12 @@ define([
"./src/policies/EditActionPolicy", "./src/policies/EditActionPolicy",
"./src/representers/EditRepresenter", "./src/representers/EditRepresenter",
"./src/representers/EditToolbarRepresenter", "./src/representers/EditToolbarRepresenter",
"text!./res/templates/edit.html",
"text!./res/templates/library.html",
"text!./res/templates/edit-object.html",
"text!./res/templates/edit-action-buttons.html",
"text!./res/templates/elements.html",
"text!./res/templates/topbar-edit.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
EditController, EditController,
@ -52,6 +58,12 @@ define([
EditActionPolicy, EditActionPolicy,
EditRepresenter, EditRepresenter,
EditToolbarRepresenter, EditToolbarRepresenter,
editTemplate,
libraryTemplate,
editObjectTemplate,
editActionButtonsTemplate,
elementsTemplate,
topbarEditTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -61,7 +73,7 @@ define([
"routes": [ "routes": [
{ {
"when": "/edit", "when": "/edit",
"templateUrl": "templates/edit.html" "template": editTemplate
} }
], ],
"controllers": [ "controllers": [
@ -185,27 +197,27 @@ define([
"templates": [ "templates": [
{ {
"key": "edit-library", "key": "edit-library",
"templateUrl": "templates/library.html" "template": libraryTemplate
} }
], ],
"representations": [ "representations": [
{ {
"key": "edit-object", "key": "edit-object",
"templateUrl": "templates/edit-object.html", "template": editObjectTemplate,
"uses": [ "uses": [
"view" "view"
] ]
}, },
{ {
"key": "edit-action-buttons", "key": "edit-action-buttons",
"templateUrl": "templates/edit-action-buttons.html", "template": editActionButtonsTemplate,
"uses": [ "uses": [
"action" "action"
] ]
}, },
{ {
"key": "edit-elements", "key": "edit-elements",
"templateUrl": "templates/elements.html", "template": elementsTemplate,
"uses": [ "uses": [
"composition" "composition"
], ],
@ -215,7 +227,7 @@ define([
}, },
{ {
"key": "topbar-edit", "key": "topbar-edit",
"templateUrl": "templates/topbar-edit.html" "template": topbarEditTemplate
} }
], ],
"representers": [ "representers": [

View File

@ -49,6 +49,25 @@ define([
"./src/directives/MCTScroll", "./src/directives/MCTScroll",
"./src/directives/MCTSplitPane", "./src/directives/MCTSplitPane",
"./src/directives/MCTSplitter", "./src/directives/MCTSplitter",
"text!./res/templates/bottombar.html",
"text!./res/templates/controls/action-button.html",
"text!./res/templates/controls/input-filter.html",
"text!./res/templates/indicator.html",
"text!./res/templates/message-banner.html",
"text!./res/templates/progress-bar.html",
"text!./res/templates/controls/time-controller.html",
"text!./res/templates/containers/accordion.html",
"text!./res/templates/subtree.html",
"text!./res/templates/tree.html",
"text!./res/templates/tree-node.html",
"text!./res/templates/label.html",
"text!./res/templates/controls/action-group.html",
"text!./res/templates/menu/context-menu.html",
"text!./res/templates/controls/switcher.html",
"text!./res/templates/object-inspector.html",
"text!./res/templates/controls/selector.html",
"text!./res/templates/controls/datetime-picker.html",
"text!./res/templates/controls/datetime-field.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
UrlService, UrlService,
@ -78,6 +97,25 @@ define([
MCTScroll, MCTScroll,
MCTSplitPane, MCTSplitPane,
MCTSplitter, MCTSplitter,
bottombarTemplate,
actionButtonTemplate,
inputFilterTemplate,
indicatorTemplate,
messageBannerTemplate,
progressBarTemplate,
timeControllerTemplate,
accordionTemplate,
subtreeTemplate,
treeTemplate,
treeNodeTemplate,
labelTemplate,
actionGroupTemplate,
contextMenuTemplate,
switcherTemplate,
objectInspectorTemplate,
selectorTemplate,
datetimePickerTemplate,
datetimeFieldTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -146,31 +184,31 @@ define([
"templates": [ "templates": [
{ {
"key": "bottombar", "key": "bottombar",
"templateUrl": "templates/bottombar.html" "template": bottombarTemplate
}, },
{ {
"key": "action-button", "key": "action-button",
"templateUrl": "templates/controls/action-button.html" "template": actionButtonTemplate
}, },
{ {
"key": "input-filter", "key": "input-filter",
"templateUrl": "templates/controls/input-filter.html" "template": inputFilterTemplate
}, },
{ {
"key": "indicator", "key": "indicator",
"templateUrl": "templates/indicator.html" "template": indicatorTemplate
}, },
{ {
"key": "message-banner", "key": "message-banner",
"templateUrl": "templates/message-banner.html" "template": messageBannerTemplate
}, },
{ {
"key": "progress-bar", "key": "progress-bar",
"templateUrl": "templates/progress-bar.html" "template": progressBarTemplate
}, },
{ {
"key": "time-controller", "key": "time-controller",
"templateUrl": "templates/controls/time-controller.html" "template": timeControllerTemplate
} }
], ],
"controllers": [ "controllers": [
@ -379,7 +417,7 @@ define([
"containers": [ "containers": [
{ {
"key": "accordion", "key": "accordion",
"templateUrl": "templates/containers/accordion.html", "template": accordionTemplate,
"attributes": [ "attributes": [
"label" "label"
] ]
@ -388,7 +426,7 @@ define([
"representations": [ "representations": [
{ {
"key": "tree", "key": "tree",
"templateUrl": "templates/subtree.html", "template": subtreeTemplate,
"uses": [ "uses": [
"composition" "composition"
], ],
@ -397,25 +435,25 @@ define([
}, },
{ {
"key": "tree", "key": "tree",
"templateUrl": "templates/tree.html" "template": treeTemplate
}, },
{ {
"key": "subtree", "key": "subtree",
"templateUrl": "templates/subtree.html", "template": subtreeTemplate,
"uses": [ "uses": [
"composition" "composition"
] ]
}, },
{ {
"key": "tree-node", "key": "tree-node",
"templateUrl": "templates/tree-node.html", "template": treeNodeTemplate,
"uses": [ "uses": [
"action" "action"
] ]
}, },
{ {
"key": "label", "key": "label",
"templateUrl": "templates/label.html", "template": labelTemplate,
"uses": [ "uses": [
"type", "type",
"location" "location"
@ -428,7 +466,7 @@ define([
}, },
{ {
"key": "node", "key": "node",
"templateUrl": "templates/label.html", "template": labelTemplate,
"uses": [ "uses": [
"type" "type"
], ],
@ -439,42 +477,42 @@ define([
}, },
{ {
"key": "action-group", "key": "action-group",
"templateUrl": "templates/controls/action-group.html", "template": actionGroupTemplate,
"uses": [ "uses": [
"action" "action"
] ]
}, },
{ {
"key": "context-menu", "key": "context-menu",
"templateUrl": "templates/menu/context-menu.html", "template": contextMenuTemplate,
"uses": [ "uses": [
"action" "action"
] ]
}, },
{ {
"key": "switcher", "key": "switcher",
"templateUrl": "templates/controls/switcher.html", "template": switcherTemplate,
"uses": [ "uses": [
"view" "view"
] ]
}, },
{ {
"key": "object-inspector", "key": "object-inspector",
"templateUrl": "templates/object-inspector.html" "template": objectInspectorTemplate
} }
], ],
"controls": [ "controls": [
{ {
"key": "selector", "key": "selector",
"templateUrl": "templates/controls/selector.html" "template": selectorTemplate
}, },
{ {
"key": "datetime-picker", "key": "datetime-picker",
"templateUrl": "templates/controls/datetime-picker.html" "template": datetimePickerTemplate
}, },
{ {
"key": "datetime-field", "key": "datetime-field",
"templateUrl": "templates/controls/datetime-field.html" "template": datetimeFieldTemplate
} }
], ],
"licenses": [ "licenses": [

View File

@ -47,13 +47,7 @@ define(
// Initialize container map from extensions // Initialize container map from extensions
containers.forEach(function (container) { containers.forEach(function (container) {
var key = container.key; containerMap[container.key] = container;
containerMap[key] = Object.create(container);
containerMap[key].templateUrl = [
container.bundle.path,
container.bundle.resources,
container.templateUrl
].join("/");
}); });
return { return {
@ -85,13 +79,11 @@ define(
scope[alias] = copiedAttributes; scope[alias] = copiedAttributes;
}, },
// Get the template URL for this container, based template: function (element, attrs) {
// on its attributes. var key = attrs.key,
templateUrl: function (element, attrs) { container = containerMap[key];
var key = attrs.key; return container ? container.template : "";
return containerMap[key].templateUrl;
} }
}; };
} }

View File

@ -30,12 +30,12 @@ define(
var testContainers = [ var testContainers = [
{ {
bundle: { path: "a", resources: "b" }, bundle: { path: "a", resources: "b" },
templateUrl: "c/template.html", template: "<div>foo</div>",
key: "abc" key: "abc"
}, },
{ {
bundle: { path: "x", resources: "y" }, bundle: { path: "x", resources: "y" },
templateUrl: "z/template.html", template: "<span>bar</span>",
key: "xyz", key: "xyz",
attributes: [ "someAttr", "someOtherAttr" ] attributes: [ "someAttr", "someOtherAttr" ]
} }
@ -55,15 +55,15 @@ define(
}); });
it("chooses a template based on key", function () { it("chooses a template based on key", function () {
expect(mctContainer.templateUrl( expect(mctContainer.template(
undefined, undefined,
{ key: "abc" } { key: "abc" }
)).toEqual("a/b/c/template.html"); )).toEqual(testContainers[0].template);
expect(mctContainer.templateUrl( expect(mctContainer.template(
undefined, undefined,
{ key: "xyz" } { key: "xyz" }
)).toEqual("x/y/z/template.html"); )).toEqual(testContainers[1].template);
}); });
it("copies attributes needed by the container", function () { it("copies attributes needed by the container", function () {

View File

@ -25,11 +25,19 @@ define([
"./src/gestures/InfoGesture", "./src/gestures/InfoGesture",
"./src/gestures/InfoButtonGesture", "./src/gestures/InfoButtonGesture",
"./src/services/InfoService", "./src/services/InfoService",
"text!./res/info-table.html",
"text!./res/info-bubble.html",
"text!./res/bubble.html",
"text!./res/templates/info-button.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
InfoGesture, InfoGesture,
InfoButtonGesture, InfoButtonGesture,
InfoService, InfoService,
infoTableTemplate,
infoBubbleTemplate,
bubbleTemplate,
infoButtonTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -39,17 +47,17 @@ define([
"templates": [ "templates": [
{ {
"key": "info-table", "key": "info-table",
"templateUrl": "info-table.html" "template": infoTableTemplate
}, },
{ {
"key": "info-bubble", "key": "info-bubble",
"templateUrl": "info-bubble.html" "template": infoBubbleTemplate
} }
], ],
"containers": [ "containers": [
{ {
"key": "bubble", "key": "bubble",
"templateUrl": "bubble.html", "template": bubbleTemplate,
"attributes": [ "attributes": [
"bubbleTitle", "bubbleTitle",
"bubbleLayout" "bubbleLayout"
@ -99,7 +107,7 @@ define([
"representations": [ "representations": [
{ {
"key": "info-button", "key": "info-button",
"templateUrl": "templates/info-button.html", "template": infoButtonTemplate,
"gestures": [ "gestures": [
"infobutton" "infobutton"
] ]

View File

@ -25,11 +25,13 @@ define([
"./src/NotificationIndicatorController", "./src/NotificationIndicatorController",
"./src/NotificationIndicator", "./src/NotificationIndicator",
"./src/NotificationService", "./src/NotificationService",
"text!./res/notification-indicator.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
NotificationIndicatorController, NotificationIndicatorController,
NotificationIndicator, NotificationIndicator,
NotificationService, NotificationService,
notificationIndicatorTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -53,7 +55,7 @@ define([
"templates": [ "templates": [
{ {
"key": "notificationIndicatorTemplate", "key": "notificationIndicatorTemplate",
"templateUrl": "notification-indicator.html" "template": notificationIndicatorTemplate
} }
], ],
"controllers": [ "controllers": [

View File

@ -29,6 +29,8 @@ define([
"./src/controllers/RefreshingController", "./src/controllers/RefreshingController",
"./src/actions/StartTimerAction", "./src/actions/StartTimerAction",
"./src/actions/RestartTimerAction", "./src/actions/RestartTimerAction",
"text!./res/templates/clock.html",
"text!./res/templates/timer.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
ClockIndicator, ClockIndicator,
@ -38,6 +40,8 @@ define([
RefreshingController, RefreshingController,
StartTimerAction, StartTimerAction,
RestartTimerAction, RestartTimerAction,
clockTemplate,
timerTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -116,13 +120,13 @@ define([
"key": "clock", "key": "clock",
"type": "clock", "type": "clock",
"editable": false, "editable": false,
"templateUrl": "templates/clock.html" "template": clockTemplate
}, },
{ {
"key": "timer", "key": "timer",
"type": "timer", "type": "timer",
"editable": false, "editable": false,
"templateUrl": "templates/timer.html" "template": timerTemplate
} }
], ],
"actions": [ "actions": [

View File

@ -25,11 +25,13 @@ define([
"./src/ConductorRepresenter", "./src/ConductorRepresenter",
"./src/ConductorTelemetryDecorator", "./src/ConductorTelemetryDecorator",
"./src/ConductorService", "./src/ConductorService",
"text!./res/templates/time-conductor.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
ConductorRepresenter, ConductorRepresenter,
ConductorTelemetryDecorator, ConductorTelemetryDecorator,
ConductorService, ConductorService,
timeConductorTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -70,7 +72,7 @@ define([
"templates": [ "templates": [
{ {
"key": "time-conductor", "key": "time-conductor",
"templateUrl": "templates/time-conductor.html" "template": timeConductorTemplate
} }
], ],
"constants": [ "constants": [

View File

@ -25,11 +25,13 @@ define([
"./src/EventListController", "./src/EventListController",
"./src/directives/MCTDataTable", "./src/directives/MCTDataTable",
"./src/policies/MessagesViewPolicy", "./src/policies/MessagesViewPolicy",
"text!./res/templates/messages.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
EventListController, EventListController,
MCTDataTable, MCTDataTable,
MessagesViewPolicy, MessagesViewPolicy,
messagesTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -44,7 +46,7 @@ define([
"name": "Messages", "name": "Messages",
"glyph": "5", "glyph": "5",
"description": "Scrolling list of messages.", "description": "Scrolling list of messages.",
"templateUrl": "templates/messages.html", "template": messagesTemplate,
"needs": [ "needs": [
"telemetry" "telemetry"
], ],

View File

@ -25,14 +25,14 @@
* Module defining MCTDataTable. Created by shale on 06/22/2015. * Module defining MCTDataTable. Created by shale on 06/22/2015.
*/ */
define( define(
[], ['text!../../res/templates/mct-data-table.html'],
function () { function (dataTableTemplate) {
"use strict"; "use strict";
function MCTDataTable($window) { function MCTDataTable($window) {
return { return {
restrict: "E", restrict: "E",
templateUrl: "platform/features/events/res/templates/mct-data-table.html", template: dataTableTemplate,
scope: { scope: {
headers: "=", headers: "=",
rows: "=", rows: "=",

View File

@ -25,11 +25,13 @@ define([
"./src/policies/ImageryViewPolicy", "./src/policies/ImageryViewPolicy",
"./src/controllers/ImageryController", "./src/controllers/ImageryController",
"./src/directives/MCTBackgroundImage", "./src/directives/MCTBackgroundImage",
"text!./res/templates/imagery.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
ImageryViewPolicy, ImageryViewPolicy,
ImageryController, ImageryController,
MCTBackgroundImage, MCTBackgroundImage,
imageryTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -42,7 +44,7 @@ define([
"name": "Imagery", "name": "Imagery",
"key": "imagery", "key": "imagery",
"glyph": "ã", "glyph": "ã",
"templateUrl": "templates/imagery.html", "template": imageryTemplate,
"priority": "preferred", "priority": "preferred",
"needs": [ "needs": [
"telemetry" "telemetry"

View File

@ -25,11 +25,27 @@ define([
"./src/LayoutController", "./src/LayoutController",
"./src/FixedController", "./src/FixedController",
"./src/LayoutCompositionPolicy", "./src/LayoutCompositionPolicy",
"text!./res/templates/layout.html",
"text!./res/templates/fixed.html",
"text!./res/templates/frame.html",
"text!./res/templates/elements/telemetry.html",
"text!./res/templates/elements/box.html",
"text!./res/templates/elements/line.html",
"text!./res/templates/elements/text.html",
"text!./res/templates/elements/image.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
LayoutController, LayoutController,
FixedController, FixedController,
LayoutCompositionPolicy, LayoutCompositionPolicy,
layoutTemplate,
fixedTemplate,
frameTemplate,
telemetryTemplate,
boxTemplate,
lineTemplate,
textTemplate,
imageTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -44,7 +60,7 @@ define([
"name": "Display Layout", "name": "Display Layout",
"glyph": "L", "glyph": "L",
"type": "layout", "type": "layout",
"templateUrl": "templates/layout.html", "template": layoutTemplate,
"editable": true, "editable": true,
"uses": [] "uses": []
}, },
@ -53,7 +69,7 @@ define([
"name": "Fixed Position", "name": "Fixed Position",
"glyph": "3", "glyph": "3",
"type": "telemetry.panel", "type": "telemetry.panel",
"templateUrl": "templates/fixed.html", "template": fixedTemplate,
"uses": [ "uses": [
"composition" "composition"
], ],
@ -191,7 +207,7 @@ define([
"representations": [ "representations": [
{ {
"key": "frame", "key": "frame",
"templateUrl": "templates/frame.html" "template": frameTemplate
} }
], ],
"controllers": [ "controllers": [
@ -218,23 +234,23 @@ define([
"templates": [ "templates": [
{ {
"key": "fixed.telemetry", "key": "fixed.telemetry",
"templateUrl": "templates/elements/telemetry.html" "template": telemetryTemplate
}, },
{ {
"key": "fixed.box", "key": "fixed.box",
"templateUrl": "templates/elements/box.html" "template": boxTemplate
}, },
{ {
"key": "fixed.line", "key": "fixed.line",
"templateUrl": "templates/elements/line.html" "template": lineTemplate
}, },
{ {
"key": "fixed.text", "key": "fixed.text",
"templateUrl": "templates/elements/text.html" "template": textTemplate
}, },
{ {
"key": "fixed.image", "key": "fixed.image",
"templateUrl": "templates/elements/image.html" "template": imageTemplate
} }
], ],
"policies": [ "policies": [

View File

@ -303,12 +303,16 @@ define(
this.generateDragHandles = generateDragHandles; this.generateDragHandles = generateDragHandles;
// Track current selection state // Track current selection state
this.selection = $scope.selection; $scope.$watch("selection", function (selection) {
this.selection = selection;
// Expose the view's selection proxy // Expose the view's selection proxy
if (this.selection) { if (this.selection) {
this.selection.proxy(new FixedProxy(addElement, $q, dialogService)); this.selection.proxy(
} new FixedProxy(addElement, $q, dialogService)
);
}
}.bind(this));
// Refresh list of elements whenever model changes // Refresh list of elements whenever model changes
$scope.$watch("model.modified", refreshElements); $scope.$watch("model.modified", refreshElements);

View File

@ -148,6 +148,8 @@ define(
mockHandler, mockHandler,
mockFormatter mockFormatter
); );
findWatch("selection")(mockScope.selection);
}); });
it("subscribes when a domain object is available", function () { it("subscribes when a domain object is available", function () {

View File

@ -23,9 +23,11 @@
define([ define([
"./src/EmbeddedPageController", "./src/EmbeddedPageController",
"text!./res/iframe.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
EmbeddedPageController, EmbeddedPageController,
iframeTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -54,7 +56,7 @@ define([
], ],
"views": [ "views": [
{ {
"templateUrl": "iframe.html", "template": iframeTemplate,
"name": "Page", "name": "Page",
"type": "example.page", "type": "example.page",
"key": "example.page", "key": "example.page",

View File

@ -25,11 +25,13 @@ define([
"./src/MCTChart", "./src/MCTChart",
"./src/PlotController", "./src/PlotController",
"./src/policies/PlotViewPolicy", "./src/policies/PlotViewPolicy",
"text!./res/templates/plot.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
MCTChart, MCTChart,
PlotController, PlotController,
PlotViewPolicy, PlotViewPolicy,
plotTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -42,7 +44,7 @@ define([
"name": "Plot", "name": "Plot",
"key": "plot", "key": "plot",
"glyph": "6", "glyph": "6",
"templateUrl": "templates/plot.html", "template": plotTemplate,
"needs": [ "needs": [
"telemetry" "telemetry"
], ],

View File

@ -25,11 +25,13 @@ define([
"./src/RTEventListController", "./src/RTEventListController",
"./src/directives/MCTRTDataTable", "./src/directives/MCTRTDataTable",
"./src/policies/RTMessagesViewPolicy", "./src/policies/RTMessagesViewPolicy",
"text!./res/templates/rtmessages.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
RTEventListController, RTEventListController,
MCTRTDataTable, MCTRTDataTable,
RTMessagesViewPolicy, RTMessagesViewPolicy,
rtmessagesTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -44,7 +46,7 @@ define([
"name": "RT Messages", "name": "RT Messages",
"glyph": "5", "glyph": "5",
"description": "Scrolling list of real time messages.", "description": "Scrolling list of real time messages.",
"templateUrl": "templates/rtmessages.html", "template": rtmessagesTemplate,
"needs": [ "needs": [
"telemetry" "telemetry"
], ],

View File

@ -25,14 +25,14 @@
* Module defining MCTRTDataTable. Created by shale on 06/25/2015. * Module defining MCTRTDataTable. Created by shale on 06/25/2015.
*/ */
define( define(
[], ['text!../../res/templates/mct-rt-data-table.html'],
function () { function (dataTableTemplate) {
"use strict"; "use strict";
function MCTRTDataTable($window) { function MCTRTDataTable($window) {
return { return {
restrict: "E", restrict: "E",
templateUrl: "platform/features/rtevents/res/templates/mct-rt-data-table.html", template: dataTableTemplate,
scope: { scope: {
headers: "=", headers: "=",
rows: "=", rows: "=",

View File

@ -23,9 +23,11 @@
define([ define([
"./src/RTScrollingListController", "./src/RTScrollingListController",
"text!./res/templates/rtscrolling.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
RTScrollingListController, RTScrollingListController,
rtscrollingTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -40,7 +42,7 @@ define([
"name": "Scrolling", "name": "Scrolling",
"glyph": "5", "glyph": "5",
"description": "Scrolling list of data values.", "description": "Scrolling list of data values.",
"templateUrl": "templates/rtscrolling.html", "template": rtscrollingTemplate,
"needs": [ "needs": [
"telemetry" "telemetry"
], ],

View File

@ -23,9 +23,11 @@
define([ define([
"./src/ScrollingListController", "./src/ScrollingListController",
"text!./res/templates/scrolling.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
ScrollingListController, ScrollingListController,
scrollingTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -40,7 +42,7 @@ define([
"name": "Scrolling", "name": "Scrolling",
"glyph": "5", "glyph": "5",
"description": "Scrolling list of data values.", "description": "Scrolling list of data values.",
"templateUrl": "templates/scrolling.html", "template": scrollingTemplate,
"needs": [ "needs": [
"telemetry" "telemetry"
], ],

View File

@ -23,9 +23,11 @@
define([ define([
"text!./res/markup.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
markupTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -45,7 +47,7 @@ define([
], ],
"views": [ "views": [
{ {
"templateUrl": "markup.html", "template": markupTemplate,
"name": "Static Markup", "name": "Static Markup",
"type": "static.markup", "type": "static.markup",
"key": "static.markup" "key": "static.markup"

View File

@ -38,6 +38,16 @@ define([
"./src/directives/MCTSwimlaneDrop", "./src/directives/MCTSwimlaneDrop",
"./src/directives/MCTSwimlaneDrag", "./src/directives/MCTSwimlaneDrag",
"./src/services/ObjectLoader", "./src/services/ObjectLoader",
"text!./res/templates/values.html",
"text!./res/templates/timeline.html",
"text!./res/templates/activity-gantt.html",
"text!./res/templates/tabular-swimlane-cols-tree.html",
"text!./res/templates/tabular-swimlane-cols-data.html",
"text!./res/templates/resource-graphs.html",
"text!./res/templates/resource-graph-labels.html",
"text!./res/templates/legend-item.html",
"text!./res/templates/ticks.html",
"text!./res/templates/controls/datetime.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
TimelineController, TimelineController,
@ -56,6 +66,16 @@ define([
MCTSwimlaneDrop, MCTSwimlaneDrop,
MCTSwimlaneDrag, MCTSwimlaneDrag,
ObjectLoader, ObjectLoader,
valuesTemplate,
timelineTemplate,
activityGanttTemplate,
tabularSwimlaneColsTreeTemplate,
tabularSwimlaneColsDataTemplate,
resourceGraphsTemplate,
resourceGraphLabelsTemplate,
legendItemTemplate,
ticksTemplate,
datetimeTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -226,7 +246,7 @@ define([
"key": "values", "key": "values",
"name": "Values", "name": "Values",
"glyph": "A", "glyph": "A",
"templateUrl": "templates/values.html", "template": valuesTemplate,
"type": "mode", "type": "mode",
"uses": [ "uses": [
"cost" "cost"
@ -239,7 +259,7 @@ define([
"glyph": "S", "glyph": "S",
"type": "timeline", "type": "timeline",
"description": "A timeline view of Timelines and Activities.", "description": "A timeline view of Timelines and Activities.",
"templateUrl": "templates/timeline.html", "template": timelineTemplate,
"editable": true, "editable": true,
"toolbar": { "toolbar": {
"sections": [ "sections": [
@ -335,7 +355,7 @@ define([
"representations": [ "representations": [
{ {
"key": "gantt", "key": "gantt",
"templateUrl": "templates/activity-gantt.html", "template": activityGanttTemplate,
"uses": [ "uses": [
"timespan", "timespan",
"type" "type"
@ -346,42 +366,42 @@ define([
{ {
"key": "timeline-tabular-swimlane-cols-tree", "key": "timeline-tabular-swimlane-cols-tree",
"priority": "mandatory", "priority": "mandatory",
"templateUrl": "templates/tabular-swimlane-cols-tree.html" "template": tabularSwimlaneColsTreeTemplate
}, },
{ {
"key": "timeline-tabular-swimlane-cols-data", "key": "timeline-tabular-swimlane-cols-data",
"priority": "mandatory", "priority": "mandatory",
"templateUrl": "templates/tabular-swimlane-cols-data.html" "template": tabularSwimlaneColsDataTemplate
}, },
{ {
"key": "timeline-resource-graphs", "key": "timeline-resource-graphs",
"priority": "mandatory", "priority": "mandatory",
"templateUrl": "templates/resource-graphs.html" "template": resourceGraphsTemplate
}, },
{ {
"key": "timeline-resource-graph-labels", "key": "timeline-resource-graph-labels",
"priority": "mandatory", "priority": "mandatory",
"templateUrl": "templates/resource-graph-labels.html" "template": resourceGraphLabelsTemplate
}, },
{ {
"key": "timeline-legend-item", "key": "timeline-legend-item",
"priority": "mandatory", "priority": "mandatory",
"templateUrl": "templates/legend-item.html" "template": legendItemTemplate
}, },
{ {
"key": "timeline-ticks", "key": "timeline-ticks",
"priority": "mandatory", "priority": "mandatory",
"templateUrl": "templates/ticks.html" "template": ticksTemplate
} }
], ],
"controls": [ "controls": [
{ {
"key": "timeline-datetime", "key": "timeline-datetime",
"templateUrl": "templates/controls/datetime.html" "template": datetimeTemplate
}, },
{ {
"key": "duration", "key": "duration",
"templateUrl": "templates/controls/datetime.html" "template": datetimeTemplate
} }
], ],
"controllers": [ "controllers": [

View File

@ -22,10 +22,10 @@
<div class="t-timeline-gantt l-timeline-gantt s-timeline-gantt" <div class="t-timeline-gantt l-timeline-gantt s-timeline-gantt"
title="{{model.name}}" title="{{model.name}}"
ng-controller="TimelineGanttController as gantt" ng-controller="TimelineGanttController as gantt"
ng-style="{ ng-style="timespan ? {
left: gantt.left(timespan, parameters.scroll, parameters.toPixels) + 'px', left: gantt.left(timespan, parameters.scroll, parameters.toPixels) + 'px',
width: gantt.width(timespan, parameters.scroll, parameters.toPixels) + 'px' width: gantt.width(timespan, parameters.scroll, parameters.toPixels) + 'px'
}"> } : {}">
<div class="bar"> <div class="bar">
<span class="s-activity-type ui-symbol"> <span class="s-activity-type ui-symbol">

View File

@ -98,7 +98,7 @@ define(
}); });
} }
} }
// Recalculate swimlane state on changes // Recalculate swimlane state on changes
$scope.$watch("domainObject", swimlanePopulator.populate); $scope.$watch("domainObject", swimlanePopulator.populate);
@ -108,6 +108,9 @@ define(
// Carry over changes in swimlane set to changes in graphs // Carry over changes in swimlane set to changes in graphs
$scope.$watch(graphMask, repopulateGraphs); $scope.$watch(graphMask, repopulateGraphs);
// Pass selection object into swimlane populator
$scope.$watch("selection", swimlanePopulator.selection);
// Convey current selection to drag handle populator // Convey current selection to drag handle populator
$scope.$watch("selection.get()", dragPopulator.select); $scope.$watch("selection.get()", dragPopulator.select);

View File

@ -46,7 +46,8 @@ define(
start = Number.POSITIVE_INFINITY, start = Number.POSITIVE_INFINITY,
end = Number.NEGATIVE_INFINITY, end = Number.NEGATIVE_INFINITY,
colors = (configuration.colors || {}), colors = (configuration.colors || {}),
assigner = new TimelineColorAssigner(colors); assigner = new TimelineColorAssigner(colors),
lastDomainObject;
// Track extremes of start/end times // Track extremes of start/end times
function trackStartEnd(timespan) { function trackStartEnd(timespan) {
@ -144,12 +145,25 @@ define(
domainObject && new TimelineProxy(domainObject, selection) domainObject && new TimelineProxy(domainObject, selection)
); );
} }
lastDomainObject = domainObject;
}
function setSelectionObject(s) {
selection = s;
recalculateSwimlanes(lastDomainObject);
} }
// Ensure colors are exposed in configuration // Ensure colors are exposed in configuration
configuration.colors = colors; configuration.colors = colors;
return { return {
/**
* Set the selection object associated with this timeline view.
* @param {Object} selection the selection object
*/
selection: setSelectionObject,
/** /**
* Update list of swimlanes to match those reachable from this * Update list of swimlanes to match those reachable from this
* object. * object.

View File

@ -150,6 +150,15 @@ define(
expect(mockSelection.proxy).toHaveBeenCalled(); expect(mockSelection.proxy).toHaveBeenCalled();
}); });
it("allows selection object to be changed", function () {
var mockNewSelectionObject = jasmine.createSpyObj(
'new-selection',
['get', 'select', 'proxy']
);
populator.selection(mockNewSelectionObject);
expect(mockNewSelectionObject.proxy)
.toHaveBeenCalled();
});
}); });
} }

View File

@ -29,6 +29,15 @@ define([
"./src/controllers/CompositeController", "./src/controllers/CompositeController",
"./src/controllers/ColorController", "./src/controllers/ColorController",
"./src/controllers/DialogButtonController", "./src/controllers/DialogButtonController",
"text!./res/templates/controls/checkbox.html",
"text!./res/templates/controls/datetime.html",
"text!./res/templates/controls/select.html",
"text!./res/templates/controls/textfield.html",
"text!./res/templates/controls/button.html",
"text!./res/templates/controls/color.html",
"text!./res/templates/controls/composite.html",
"text!./res/templates/controls/menu-button.html",
"text!./res/templates/controls/dialog.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
MCTForm, MCTForm,
@ -38,6 +47,15 @@ define([
CompositeController, CompositeController,
ColorController, ColorController,
DialogButtonController, DialogButtonController,
checkboxTemplate,
datetimeTemplate,
selectTemplate,
textfieldTemplate,
buttonTemplate,
colorTemplate,
compositeTemplate,
menuButtonTemplate,
dialogTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -59,6 +77,7 @@ define([
"key": "mctControl", "key": "mctControl",
"implementation": MCTControl, "implementation": MCTControl,
"depends": [ "depends": [
"templateLinker",
"controls[]" "controls[]"
] ]
} }
@ -66,39 +85,39 @@ define([
"controls": [ "controls": [
{ {
"key": "checkbox", "key": "checkbox",
"templateUrl": "templates/controls/checkbox.html" "template": checkboxTemplate
}, },
{ {
"key": "datetime", "key": "datetime",
"templateUrl": "templates/controls/datetime.html" "template": datetimeTemplate
}, },
{ {
"key": "select", "key": "select",
"templateUrl": "templates/controls/select.html" "template": selectTemplate
}, },
{ {
"key": "textfield", "key": "textfield",
"templateUrl": "templates/controls/textfield.html" "template": textfieldTemplate
}, },
{ {
"key": "button", "key": "button",
"templateUrl": "templates/controls/button.html" "template": buttonTemplate
}, },
{ {
"key": "color", "key": "color",
"templateUrl": "templates/controls/color.html" "template": colorTemplate
}, },
{ {
"key": "composite", "key": "composite",
"templateUrl": "templates/controls/composite.html" "template": compositeTemplate
}, },
{ {
"key": "menu-button", "key": "menu-button",
"templateUrl": "templates/controls/menu-button.html" "template": menuButtonTemplate
}, },
{ {
"key": "dialog-button", "key": "dialog-button",
"templateUrl": "templates/controls/dialog.html" "template": dialogTemplate
} }
], ],
"controllers": [ "controllers": [

View File

@ -36,23 +36,18 @@ define(
* @constructor * @constructor
* @memberof platform/forms * @memberof platform/forms
*/ */
function MCTControl(controls) { function MCTControl(templateLinker, controls) {
var controlMap = {}; var controlMap = {};
// Prepopulate controlMap for easy look up by key // Prepopulate controlMap for easy look up by key
controls.forEach(function (control) { controls.forEach(function (control) {
var path = [ controlMap[control.key] = control;
control.bundle.path,
control.bundle.resources,
control.templateUrl
].join("/");
controlMap[control.key] = path;
}); });
function link(scope, element, attrs, ngModelController) { function link(scope, element, attrs, ngModelController) {
var changeTemplate = templateLinker.link(scope, element);
scope.$watch("key", function (key) { scope.$watch("key", function (key) {
// Pass the template URL to ng-include via scope. changeTemplate(controlMap[key]);
scope.inclusion = controlMap[key];
}); });
scope.ngModelController = ngModelController; scope.ngModelController = ngModelController;
} }
@ -61,10 +56,6 @@ define(
// Only show at the element level // Only show at the element level
restrict: "E", restrict: "E",
// Use ng-include as a template; "inclusion" will be the real
// template path
template: '<ng-include src="inclusion"></ng-include>',
// ngOptions is terminal, so we need to be higher priority // ngOptions is terminal, so we need to be higher priority
priority: 1000, priority: 1000,

View File

@ -27,8 +27,8 @@
* @namespace platform/forms * @namespace platform/forms
*/ */
define( define(
["./controllers/FormController"], ["./controllers/FormController", "text!../res/templates/form.html"],
function (FormController) { function (FormController, formTemplate) {
"use strict"; "use strict";
/** /**
@ -52,18 +52,12 @@ define(
* @constructor * @constructor
*/ */
function MCTForm() { function MCTForm() {
var templatePath = [
"platform/forms", //MCTForm.bundle.path,
"res", //MCTForm.bundle.resources,
"templates/form.html"
].join("/");
return { return {
// Only show at the element level // Only show at the element level
restrict: "E", restrict: "E",
// Load the forms template // Load the forms template
templateUrl: templatePath, template: formTemplate,
// Use FormController to populate/respond to changes in scope // Use FormController to populate/respond to changes in scope
controller: [ '$scope', FormController ], controller: [ '$scope', FormController ],

View File

@ -25,8 +25,8 @@
* Module defining MCTForm. Created by vwoeltje on 11/10/14. * Module defining MCTForm. Created by vwoeltje on 11/10/14.
*/ */
define( define(
["./controllers/FormController"], ["./MCTForm", "text!../res/templates/toolbar.html"],
function (FormController) { function (MCTForm, toolbarTemplate) {
"use strict"; "use strict";
/** /**
@ -49,38 +49,14 @@ define(
* @memberof platform/forms * @memberof platform/forms
* @constructor * @constructor
*/ */
function MCTForm() { function MCTToolbar() {
var templatePath = [ // Use Directive Definition Object from mct-form,
"platform/forms", //MCTForm.bundle.path, // but use the toolbar's template instead.
"res", //MCTForm.bundle.resources, var ddo = new MCTForm();
"templates/toolbar.html" ddo.template = toolbarTemplate;
].join("/"); return ddo;
return {
// Only show at the element level
restrict: "E",
// Load the forms template
templateUrl: templatePath,
// Use FormController to populate/respond to changes in scope
controller: [ '$scope', FormController ],
// Initial an isolate scope
scope: {
// The model: Where form input will actually go
ngModel: "=",
// Form structure; what sections/rows to show
structure: "=",
// Name under which to publish the form
name: "@"
}
};
} }
return MCTForm; return MCTToolbar;
} }
); );

View File

@ -29,6 +29,8 @@ define(
describe("The mct-control directive", function () { describe("The mct-control directive", function () {
var testControls, var testControls,
mockScope, mockScope,
mockLinker,
mockChangeTemplate,
mctControl; mctControl;
beforeEach(function () { beforeEach(function () {
@ -46,8 +48,11 @@ define(
]; ];
mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]); mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]);
mockLinker = jasmine.createSpyObj("templateLinker", ["link"]);
mockChangeTemplate = jasmine.createSpy('changeTemplate');
mockLinker.link.andReturn(mockChangeTemplate);
mctControl = new MCTControl(testControls); mctControl = new MCTControl(mockLinker, testControls);
}); });
it("is restricted to the element level", function () { it("is restricted to the element level", function () {
@ -66,14 +71,16 @@ define(
it("changes its template dynamically", function () { it("changes its template dynamically", function () {
mctControl.link(mockScope); mctControl.link(mockScope);
expect(mockChangeTemplate)
.not.toHaveBeenCalledWith(testControls[1]);
mockScope.key = "xyz"; mockScope.key = "xyz";
mockScope.$watch.mostRecentCall.args[1]("xyz"); mockScope.$watch.mostRecentCall.args[1]("xyz");
// Should have communicated the template path to // Should have communicated the template path to
// ng-include via the "inclusion" field in scope // ng-include via the "inclusion" field in scope
expect(mockScope.inclusion).toEqual( expect(mockChangeTemplate)
"x/y/z/template.html" .toHaveBeenCalledWith(testControls[1]);
);
}); });
}); });

View File

@ -25,11 +25,13 @@ define([
"./src/QueuingPersistenceCapabilityDecorator", "./src/QueuingPersistenceCapabilityDecorator",
"./src/PersistenceQueue", "./src/PersistenceQueue",
"./src/PersistenceFailureController", "./src/PersistenceFailureController",
"text!./res/templates/persistence-failure-dialog.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
QueuingPersistenceCapabilityDecorator, QueuingPersistenceCapabilityDecorator,
PersistenceQueue, PersistenceQueue,
PersistenceFailureController, PersistenceFailureController,
persistenceFailureDialogTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -67,7 +69,7 @@ define([
"templates": [ "templates": [
{ {
"key": "persistence-failure-dialog", "key": "persistence-failure-dialog",
"templateUrl": "templates/persistence-failure-dialog.html" "template": persistenceFailureDialogTemplate
} }
], ],
"controllers": [ "controllers": [

View File

@ -27,6 +27,9 @@ define([
"./src/controllers/ClickAwayController", "./src/controllers/ClickAwayController",
"./src/services/GenericSearchProvider", "./src/services/GenericSearchProvider",
"./src/services/SearchAggregator", "./src/services/SearchAggregator",
"text!./res/templates/search-item.html",
"text!./res/templates/search.html",
"text!./res/templates/search-menu.html",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
SearchController, SearchController,
@ -34,6 +37,9 @@ define([
ClickAwayController, ClickAwayController,
GenericSearchProvider, GenericSearchProvider,
SearchAggregator, SearchAggregator,
searchItemTemplate,
searchTemplate,
searchMenuTemplate,
legacyRegistry legacyRegistry
) { ) {
"use strict"; "use strict";
@ -80,17 +86,17 @@ define([
"representations": [ "representations": [
{ {
"key": "search-item", "key": "search-item",
"templateUrl": "templates/search-item.html" "template": searchItemTemplate
} }
], ],
"templates": [ "templates": [
{ {
"key": "search", "key": "search",
"templateUrl": "templates/search.html" "template": searchTemplate
}, },
{ {
"key": "search-menu", "key": "search-menu",
"templateUrl": "templates/search-menu.html" "template": searchMenuTemplate
} }
], ],
"components": [ "components": [

View File

@ -0,0 +1,106 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
// Converts all templateUrl references in bundle.js files to
// plain template references, loading said templates with the
// RequireJS text plugin.
var glob = require('glob'),
fs = require('fs'),
path = require('path'),
_ = require('lodash');
function toTemplateName(templateUrl) {
var parts = templateUrl.split('/');
return _.camelCase(parts[parts.length - 1].replace(".html", "")) +
"Template";
}
function getTemplateUrl(sourceLine) {
return _.trim(sourceLine.split(":")[1], "\", ");
}
function hasTemplateUrl(sourceLine) {
return sourceLine.indexOf("templateUrl") !== -1;
}
function findTemplateURLs(sourceCode) {
return sourceCode.split('\n')
.map(_.trim)
.filter(hasTemplateUrl)
.map(getTemplateUrl);
}
function injectRequireArgument(sourceCode, templateUrls) {
var lines = sourceCode.split('\n'),
index;
templateUrls = _.uniq(templateUrls);
// Add arguments for source paths...
index = lines.map(_.trim).indexOf("'legacyRegistry'");
lines = lines.slice(0, index).concat(templateUrls.map(function (url) {
return " \"text!./res/" + url + "\",";
}).concat(lines.slice(index)));
/// ...and for arguments
index = lines.map(_.trim).indexOf("legacyRegistry");
lines = lines.slice(0, index).concat(templateUrls.map(function (url) {
return " " + toTemplateName(url) + ",";
}).concat(lines.slice(index)));
return lines.join('\n');
}
function rewriteUrl(sourceLine) {
return [
sourceLine.substring(0, sourceLine.indexOf(sourceLine.trim())),
"\"template\": " + toTemplateName(getTemplateUrl(sourceLine)),
_.endsWith(sourceLine, ",") ? "," : ""
].join('');
}
function rewriteLine(sourceLine) {
return hasTemplateUrl(sourceLine) ?
rewriteUrl(sourceLine.replace("templateUrl", "template")) :
sourceLine;
}
function rewriteTemplateUrls(sourceCode) {
return sourceCode.split('\n').map(rewriteLine).join('\n');
}
function migrate(file) {
var sourceCode = fs.readFileSync(file, 'utf8');
fs.writeFileSync(file, rewriteTemplateUrls(
injectRequireArgument(sourceCode, findTemplateURLs(sourceCode))
), 'utf8');
}
glob('platform/**/bundle.js', {}, function (err, files) {
if (err) {
console.log(err);
return;
}
files.forEach(migrate);
});