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

@ -78,6 +78,9 @@ class ContextMenuRegistry {
document.addEventListener('click', this._hideActiveContextMenu); document.addEventListener('click', this._hideActiveContextMenu);
} }
/**
* @private
*/
_calculatePopupPosition(event, menuElement) { _calculatePopupPosition(event, menuElement) {
let x = event.clientX; let x = event.clientX;
let y = event.clientY; let y = event.clientY;