Instantiate legacy objects inline

This commit is contained in:
Andrew Henry 2018-11-23 15:31:38 -08:00
parent eeab6e9bde
commit 9ae4e66c91
2 changed files with 16 additions and 3 deletions

View File

@ -41,6 +41,7 @@ define([
'./styles-new/core.scss',
'./styles-new/notebook.scss',
'./ui/components/layout/Layout.vue',
'../platform/core/src/objects/DomainObjectImpl',
'../platform/core/src/capabilities/ContextualDomainObject',
'vue'
], function (
@ -64,6 +65,7 @@ define([
coreStyles,
NotebookStyles,
Layout,
DomainObjectImpl,
ContextualDomainObject,
Vue
) {
@ -251,6 +253,8 @@ define([
* @private
*/
MCT.prototype.legacyObject = function (domainObject) {
let capabilityService = this.$injector.get('capabilityService');
if (Array.isArray(domainObject)) {
// an array of domain objects. [object, ...ancestors] representing
// a single object with a given chain of ancestors. We instantiate
@ -259,7 +263,7 @@ define([
.map((o) => {
let keyString = objectUtils.makeKeyString(o.identifier);
let oldModel = objectUtils.toOldFormat(o);
return this.$injector.get('instantiate')(oldModel, keyString);
return instantiate(oldModel, keyString);
})
.reverse()
.reduce((parent, child) => {
@ -269,7 +273,13 @@ define([
} else {
let keyString = objectUtils.makeKeyString(domainObject.identifier);
let oldModel = objectUtils.toOldFormat(domainObject);
return this.$injector.get('instantiate')(oldModel, keyString);
return instantiate(oldModel, keyString);
}
function instantiate(model, keyString) {
var capabilities = capabilityService.getCapabilities(model, keyString);
model.id = keyString;
return new DomainObjectImpl(keyString, model, capabilities);
}
};

View File

@ -70,7 +70,7 @@ class ContextMenuRegistry {
this._activeContextMenu = this._createContextMenuForObject(objectPath, applicableActions);
this._activeContextMenu.$mount();
document.body.appendChild(this._activeContextMenu.$el);
let position = this._calculatePopupPosition(event, this._activeContextMenu.$el);
this._activeContextMenu.$el.style.left = `${position.x}px`;
this._activeContextMenu.$el.style.top = `${position.y}px`;
@ -78,6 +78,9 @@ class ContextMenuRegistry {
document.addEventListener('click', this._hideActiveContextMenu);
}
/**
* @private
*/
_calculatePopupPosition(event, menuElement) {
let x = event.clientX;
let y = event.clientY;