mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 07:08:12 +00:00
[Edit] Utilize model cache
Utilize model cache, permitting object models in edit mode to be reused across multiple distinct instances with unique contexts (unique contexts are necessary to avoid ambiguity in the Remove action, WTD-473). To avoid infinite digest cycles as a consequence of this, refactor context/composition capability wrappers such that the former is idempotent (since idempotence is no longer ensured by the EditableDomainObjectCache) to avoid infinite digest errors in Edit mode.
This commit is contained in:
@ -53,9 +53,8 @@ define(
|
||||
|
||||
// Constructor for EditableDomainObject, which adheres
|
||||
// to the same shared cache.
|
||||
function EditableDomainObjectImpl(domainObject) {
|
||||
var model = JSON.parse(JSON.stringify(domainObject.getModel())),
|
||||
editableObject = Object.create(domainObject);
|
||||
function EditableDomainObjectImpl(domainObject, model) {
|
||||
var editableObject = Object.create(domainObject);
|
||||
|
||||
// Only provide the cloned model.
|
||||
editableObject.getModel = function () { return model; };
|
||||
|
@ -15,7 +15,8 @@
|
||||
* @module editor/object/editable-domain-object-cache
|
||||
*/
|
||||
define(
|
||||
function () {
|
||||
["./EditableModelCache"],
|
||||
function (EditableModelCache) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@ -32,7 +33,7 @@ define(
|
||||
* @memberof module:editor/object/editable-domain-object-cache
|
||||
*/
|
||||
function EditableDomainObjectCache(EditableDomainObject) {
|
||||
var cache = {},
|
||||
var cache = new EditableModelCache(),
|
||||
dirty = {};
|
||||
|
||||
return {
|
||||
@ -44,9 +45,10 @@ define(
|
||||
* @returns {DomainObject} the domain object in an editable form
|
||||
*/
|
||||
getEditableObject: function (domainObject) {
|
||||
var id = domainObject.getId();
|
||||
return (cache[id] =
|
||||
cache[id] || new EditableDomainObject(domainObject));
|
||||
return new EditableDomainObject(
|
||||
domainObject,
|
||||
cache.getCachedModel(domainObject)
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Mark an editable domain object (presumably already cached)
|
||||
|
Reference in New Issue
Block a user