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:
@@ -2,12 +2,13 @@
|
||||
mct-object="domainObject"
|
||||
ng-model="representation">
|
||||
</mct-representation>
|
||||
<div class="holder edit-area outline abs">
|
||||
<div class="holder edit-area outline abs"
|
||||
ng-controller="SplitPaneController as vSplitter">
|
||||
<mct-toolbar name="mctToolbar"
|
||||
structure="toolbar.structure"
|
||||
ng-model="toolbar.state">
|
||||
</mct-toolbar>
|
||||
<div class='split-layout vertical contents abs work-area' ng-controller="SplitPaneController as vSplitter">
|
||||
<div class='split-layout vertical contents abs work-area'>
|
||||
<div
|
||||
class='abs pane left edit-main'
|
||||
ng-style="{ right: (vSplitter.state()+5) + 'px'}"
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -19,18 +19,22 @@ define(
|
||||
// methods for domain objects, so give it an
|
||||
// arbitrary interface to wrap.
|
||||
mockContext =
|
||||
jasmine.createSpyObj("context", [ "getDomainObject" ]);
|
||||
jasmine.createSpyObj("context", [ "getDomainObject", "getRoot" ]);
|
||||
mockTestObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
[ "getId", "getModel", "getCapability" ]
|
||||
);
|
||||
mockFactory =
|
||||
jasmine.createSpyObj("factory", ["getEditableObject"]);
|
||||
mockFactory = jasmine.createSpyObj(
|
||||
"factory",
|
||||
["getEditableObject", "isRoot"]
|
||||
);
|
||||
|
||||
someValue = { x: 42 };
|
||||
|
||||
mockContext.getRoot.andReturn(mockTestObject);
|
||||
mockContext.getDomainObject.andReturn(mockTestObject);
|
||||
mockFactory.getEditableObject.andReturn(someValue);
|
||||
mockFactory.isRoot.andReturn(true);
|
||||
|
||||
capability = new EditableContextCapability(
|
||||
mockContext,
|
||||
@@ -47,6 +51,18 @@ define(
|
||||
expect(mockContext.getDomainObject.calls.length).toEqual(1);
|
||||
});
|
||||
|
||||
it("hides the root object", function () {
|
||||
expect(capability.getRoot()).toEqual(mockEditableObject);
|
||||
expect(capability.getPath()).toEqual([mockEditableObject]);
|
||||
});
|
||||
|
||||
it("exposes the root object through a different method", function () {
|
||||
// Should still go through the factory...
|
||||
expect(capability.getTrueRoot()).toEqual(someValue);
|
||||
// ...with value of the unwrapped capability's getRoot
|
||||
expect(mockFactory.getEditableObject)
|
||||
.toHaveBeenCalledWith(mockTestObject);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -19,14 +19,14 @@ define(
|
||||
);
|
||||
mockContext = jasmine.createSpyObj(
|
||||
'context',
|
||||
[ 'getRoot' ]
|
||||
[ 'getTrueRoot' ]
|
||||
);
|
||||
|
||||
mockDomainObject.getId.andReturn('test-id');
|
||||
mockDomainObject.getCapability.andReturn(mockContext);
|
||||
|
||||
// Return a new instance of the root object each time
|
||||
mockContext.getRoot.andCallFake(function () {
|
||||
mockContext.getTrueRoot.andCallFake(function () {
|
||||
var mockRoot = jasmine.createSpyObj('root', ['getId']);
|
||||
mockRoot.getId.andReturn('root-id');
|
||||
return mockRoot;
|
||||
@@ -75,7 +75,7 @@ define(
|
||||
firstRoot = controller.getRoot();
|
||||
|
||||
// Change the exposed root
|
||||
mockContext.getRoot.andCallFake(function () {
|
||||
mockContext.getTrueRoot.andCallFake(function () {
|
||||
var mockRoot = jasmine.createSpyObj('root', ['getId']);
|
||||
mockRoot.getId.andReturn('other-root-id');
|
||||
return mockRoot;
|
||||
|
||||
@@ -99,6 +99,17 @@ define(
|
||||
expect(captured.saved).toEqual(1);
|
||||
});
|
||||
|
||||
it("tracks the root object of the Edit mode subgraph", function () {
|
||||
// Root object is the first object exposed to the cache
|
||||
var domainObjects = ['a', 'b', 'c'].map(TestObject);
|
||||
domainObjects.forEach(function (obj) {
|
||||
cache.getEditableObject(obj);
|
||||
});
|
||||
expect(cache.isRoot(domainObjects[0])).toBeTruthy();
|
||||
expect(cache.isRoot(domainObjects[1])).toBeFalsy();
|
||||
expect(cache.isRoot(domainObjects[2])).toBeFalsy();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user