[API] Override template to allow toolbar injection

This commit is contained in:
Victor Woeltjen 2016-06-17 12:16:46 -07:00
parent c289a27305
commit 1f96e84542
2 changed files with 68 additions and 16 deletions

View File

@ -2,12 +2,14 @@ define([
'EventEmitter',
'legacyRegistry',
'uuid',
'./api/api'
'./api/api',
'text!./adapter/templates/edit-object-replacement.html'
], function (
EventEmitter,
legacyRegistry,
uuid,
api
api,
editObjectTemplate
) {
function MCT() {
EventEmitter.call(this);
@ -21,15 +23,20 @@ define([
});
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) {
var viewKey = region + uuid();
var adaptedViewKey = "adapted-view-" + viewKey;
this.legacyBundle.extensions.views =
this.legacyBundle.extensions.views || [];
this.legacyBundle.extensions.views.push({
this.legacyExtension('views', {
name: "A view",
key: adaptedViewKey,
editable: true,
template: '<mct-view key="\'' +
viewKey +
'\'" ' +
@ -37,9 +44,7 @@ define([
'</mct-view>'
});
this.legacyBundle.extensions.policies =
this.legacyBundle.extensions.policies || [];
this.legacyBundle.extensions.policies.push({
this.legacyExtension('policies', {
category: "view",
implementation: function Policy() {
this.allow = function (view, domainObject) {
@ -51,10 +56,9 @@ define([
}
});
this.legacyBundle.extensions.newViews =
this.legacyBundle.extensions.newViews || [];
this.legacyBundle.extensions.newViews.push({
this.legacyExtension('newViews', {
factory: factory,
region: region,
key: viewKey
});
};
@ -62,11 +66,15 @@ define([
MCT.prototype.type = function (key, type) {
var legacyDef = type.toLegacyDefinition();
legacyDef.key = key;
this.legacyBundle.extensions.types =
this.legacyBundle.extensions.types || [];
this.legacyBundle.extensions.types.push(legacyDef);
type.key = key;
this.legacyExtension('types', legacyDef);
this.legacyExtension('representations', {
key: "edit-object",
priority: "preferred",
template: editObjectTemplate,
type: key
});
};
MCT.prototype.start = function () {
@ -75,7 +83,8 @@ define([
};
MCT.prototype.regions = {
main: "MAIN"
main: "MAIN",
toolbar: "TOOLBAR"
};
MCT.prototype.verbs = {

View 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>