mirror of
https://github.com/nasa/openmct.git
synced 2025-06-21 00:23:01 +00:00
[API] Override template to allow toolbar injection
This commit is contained in:
41
src/MCT.js
41
src/MCT.js
@ -2,12 +2,14 @@ define([
|
|||||||
'EventEmitter',
|
'EventEmitter',
|
||||||
'legacyRegistry',
|
'legacyRegistry',
|
||||||
'uuid',
|
'uuid',
|
||||||
'./api/api'
|
'./api/api',
|
||||||
|
'text!./adapter/templates/edit-object-replacement.html'
|
||||||
], function (
|
], function (
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
legacyRegistry,
|
legacyRegistry,
|
||||||
uuid,
|
uuid,
|
||||||
api
|
api,
|
||||||
|
editObjectTemplate
|
||||||
) {
|
) {
|
||||||
function MCT() {
|
function MCT() {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
@ -21,15 +23,20 @@ define([
|
|||||||
});
|
});
|
||||||
MCT.prototype.MCT = MCT;
|
MCT.prototype.MCT = MCT;
|
||||||
|
|
||||||
|
MCT.prototype.legacyExtension = function (category, extension) {
|
||||||
|
this.legacyBundle.extensions[category] =
|
||||||
|
this.legacyBundle.extensions[category] || [];
|
||||||
|
this.legacyBundle.extensions[category].push(extension);
|
||||||
|
};
|
||||||
|
|
||||||
MCT.prototype.view = function (region, factory) {
|
MCT.prototype.view = function (region, factory) {
|
||||||
var viewKey = region + uuid();
|
var viewKey = region + uuid();
|
||||||
var adaptedViewKey = "adapted-view-" + viewKey;
|
var adaptedViewKey = "adapted-view-" + viewKey;
|
||||||
|
|
||||||
this.legacyBundle.extensions.views =
|
this.legacyExtension('views', {
|
||||||
this.legacyBundle.extensions.views || [];
|
|
||||||
this.legacyBundle.extensions.views.push({
|
|
||||||
name: "A view",
|
name: "A view",
|
||||||
key: adaptedViewKey,
|
key: adaptedViewKey,
|
||||||
|
editable: true,
|
||||||
template: '<mct-view key="\'' +
|
template: '<mct-view key="\'' +
|
||||||
viewKey +
|
viewKey +
|
||||||
'\'" ' +
|
'\'" ' +
|
||||||
@ -37,9 +44,7 @@ define([
|
|||||||
'</mct-view>'
|
'</mct-view>'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.legacyBundle.extensions.policies =
|
this.legacyExtension('policies', {
|
||||||
this.legacyBundle.extensions.policies || [];
|
|
||||||
this.legacyBundle.extensions.policies.push({
|
|
||||||
category: "view",
|
category: "view",
|
||||||
implementation: function Policy() {
|
implementation: function Policy() {
|
||||||
this.allow = function (view, domainObject) {
|
this.allow = function (view, domainObject) {
|
||||||
@ -51,10 +56,9 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.legacyBundle.extensions.newViews =
|
this.legacyExtension('newViews', {
|
||||||
this.legacyBundle.extensions.newViews || [];
|
|
||||||
this.legacyBundle.extensions.newViews.push({
|
|
||||||
factory: factory,
|
factory: factory,
|
||||||
|
region: region,
|
||||||
key: viewKey
|
key: viewKey
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -62,11 +66,15 @@ define([
|
|||||||
MCT.prototype.type = function (key, type) {
|
MCT.prototype.type = function (key, type) {
|
||||||
var legacyDef = type.toLegacyDefinition();
|
var legacyDef = type.toLegacyDefinition();
|
||||||
legacyDef.key = key;
|
legacyDef.key = key;
|
||||||
this.legacyBundle.extensions.types =
|
|
||||||
this.legacyBundle.extensions.types || [];
|
|
||||||
this.legacyBundle.extensions.types.push(legacyDef);
|
|
||||||
|
|
||||||
type.key = key;
|
type.key = key;
|
||||||
|
|
||||||
|
this.legacyExtension('types', legacyDef);
|
||||||
|
this.legacyExtension('representations', {
|
||||||
|
key: "edit-object",
|
||||||
|
priority: "preferred",
|
||||||
|
template: editObjectTemplate,
|
||||||
|
type: key
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
MCT.prototype.start = function () {
|
MCT.prototype.start = function () {
|
||||||
@ -75,7 +83,8 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
MCT.prototype.regions = {
|
MCT.prototype.regions = {
|
||||||
main: "MAIN"
|
main: "MAIN",
|
||||||
|
toolbar: "TOOLBAR"
|
||||||
};
|
};
|
||||||
|
|
||||||
MCT.prototype.verbs = {
|
MCT.prototype.verbs = {
|
||||||
|
43
src/adapter/templates/edit-object-replacement.html
Normal file
43
src/adapter/templates/edit-object-replacement.html
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<div class="abs l-flex-col" ng-controller="EditObjectController as EditObjectController">
|
||||||
|
<div mct-before-unload="EditObjectController.getUnloadWarning()"
|
||||||
|
class="holder flex-elem l-flex-row object-browse-bar ">
|
||||||
|
<div class="items-select left flex-elem l-flex-row grows">
|
||||||
|
<mct-representation key="'back-arrow'"
|
||||||
|
mct-object="domainObject"
|
||||||
|
class="flex-elem l-back"></mct-representation>
|
||||||
|
<mct-representation key="'object-header'"
|
||||||
|
mct-object="domainObject"
|
||||||
|
class="l-flex-row flex-elem grows object-header">
|
||||||
|
</mct-representation>
|
||||||
|
</div>
|
||||||
|
<div class="btn-bar right l-flex-row flex-elem flex-justify-end flex-fixed">
|
||||||
|
<mct-representation key="'switcher'"
|
||||||
|
mct-object="domainObject"
|
||||||
|
ng-model="representation">
|
||||||
|
</mct-representation>
|
||||||
|
<!-- Temporarily, on mobile, the action buttons are hidden-->
|
||||||
|
<mct-representation key="'action-group'"
|
||||||
|
mct-object="domainObject"
|
||||||
|
parameters="{ category: 'view-control' }"
|
||||||
|
class="mobile-hide">
|
||||||
|
</mct-representation>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="holder l-flex-col flex-elem grows l-object-wrapper">
|
||||||
|
<div class="holder l-flex-col flex-elem grows l-object-wrapper-inner">
|
||||||
|
<!-- Toolbar and Save/Cancel buttons -->
|
||||||
|
<div class="l-edit-controls flex-elem l-flex-row flex-align-end">
|
||||||
|
<span>This is where a toolbar will go.</span>
|
||||||
|
<mct-representation key="'edit-action-buttons'"
|
||||||
|
mct-object="domainObject"
|
||||||
|
class='flex-elem conclude-editing'>
|
||||||
|
</mct-representation>
|
||||||
|
</div>
|
||||||
|
<mct-representation key="representation.selected.key"
|
||||||
|
mct-object="representation.selected.key && domainObject"
|
||||||
|
class="abs flex-elem grows object-holder-main scroll"
|
||||||
|
toolbar="toolbar">
|
||||||
|
</mct-representation>
|
||||||
|
</div><!--/ l-object-wrapper-inner -->
|
||||||
|
</div>
|
||||||
|
</div>
|
Reference in New Issue
Block a user