Merge branch 'open-master' into open1035

Merge in latest changes into topic branch for WTD-1035,
dialog warning before navigating out of Edit mode.
This commit is contained in:
Victor Woeltjen
2015-03-31 14:32:55 -07:00
45 changed files with 791 additions and 418 deletions

View File

@@ -23,13 +23,32 @@ define(
) {
// This is a "lookup" style capability (it looks up other
// domain objects), and it should be idempotent
return new EditableLookupCapability(
contextCapability,
editableObject,
domainObject,
cache,
true // Idempotent
);
var capability = new EditableLookupCapability(
contextCapability,
editableObject,
domainObject,
cache,
true // Idempotent
),
// Track the real root object for the Elements pane
trueRoot = capability.getRoot();
// Provide access to the real root, for the Elements pane.
capability.getTrueRoot = function () {
return trueRoot;
};
// Hide ancestry after the root of this subgraph
if (cache.isRoot(domainObject)) {
capability.getRoot = function () {
return editableObject;
};
capability.getPath = function () {
return [editableObject];
};
}
return capability;
};
}
);

View File

@@ -16,7 +16,7 @@ define(
function updateRoot(domainObject) {
var context = domainObject &&
domainObject.getCapability('context'),
newRoot = context && context.getRoot(),
newRoot = context && context.getTrueRoot(),
oldId = root && root.getId(),
newId = newRoot && newRoot.getId();

View File

@@ -34,7 +34,8 @@ define(
*/
function EditableDomainObjectCache(EditableDomainObject) {
var cache = new EditableModelCache(),
dirty = {};
dirty = {},
root;
return {
/**
@@ -45,11 +46,24 @@ define(
* @returns {DomainObject} the domain object in an editable form
*/
getEditableObject: function (domainObject) {
// Track the top-level domain object; this will have
// some special behavior for its context capability.
root = root || domainObject;
// Provide an editable form of the object
return new EditableDomainObject(
domainObject,
cache.getCachedModel(domainObject)
);
},
/**
* Check if a domain object is (effectively) the top-level
* object in this editable subgraph.
* @returns {boolean} true if it is the root
*/
isRoot: function (domainObject) {
return domainObject === root;
},
/**
* Mark an editable domain object (presumably already cached)
* as having received modifications during editing; it should be