Merge remote-tracking branch 'github/master' into mobile

Merge in latest from master into mobile branch
to reconcile conflicts

Conflicts:
	platform/commonUI/edit/src/actions/RemoveAction.js
This commit is contained in:
Victor Woeltjen
2015-09-10 14:56:20 -07:00
13 changed files with 12952 additions and 6271 deletions

View File

@@ -31,7 +31,7 @@
{
"key": "LocatorController",
"implementation": "creation/LocatorController",
"depends": [ "$scope" ]
"depends": [ "$scope", "$timeout" ]
},
{
"key": "MenuArrowController",

View File

@@ -33,7 +33,7 @@ define(
* @memberof platform/commonUI/browse
* @constructor
*/
function LocatorController($scope) {
function LocatorController($scope, $timeout) {
// Populate values needed by the locator control. These are:
// * rootObject: The top-level object, since we want to show
// the full tree
@@ -41,9 +41,19 @@ define(
// used for bi-directional object selection.
function setLocatingObject(domainObject, priorObject) {
var context = domainObject &&
domainObject.getCapability("context");
domainObject.getCapability("context"),
contextRoot = context && context.getRoot();
if (contextRoot && contextRoot !== $scope.rootObject) {
$scope.rootObject = undefined;
// Update the displayed tree on a timeout to avoid
// an infinite digest exception.
$timeout(function () {
$scope.rootObject =
(context && context.getRoot()) || $scope.rootObject;
}, 0);
}
$scope.rootObject = (context && context.getRoot()) || $scope.rootObject;
$scope.treeModel.selectedObject = domainObject;
$scope.ngModel[$scope.field] = domainObject;
@@ -52,10 +62,7 @@ define(
$scope.structure &&
$scope.structure.validate) {
if (!$scope.structure.validate(domainObject)) {
setLocatingObject(
$scope.structure.validate(priorObject) ?
priorObject : undefined
);
setLocatingObject(priorObject, undefined);
return;
}
}

View File

@@ -31,6 +31,7 @@ define(
describe("The locator controller", function () {
var mockScope,
mockTimeout,
mockDomainObject,
mockRootObject,
mockContext,
@@ -41,6 +42,7 @@ define(
"$scope",
[ "$watch" ]
);
mockTimeout = jasmine.createSpy("$timeout");
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getCapability" ]
@@ -60,7 +62,7 @@ define(
mockScope.ngModel = {};
mockScope.field = "someField";
controller = new LocatorController(mockScope);
controller = new LocatorController(mockScope, mockTimeout);
});
it("adds a treeModel to scope", function () {
@@ -80,6 +82,7 @@ define(
// Need to pass on selection changes as updates to
// the control's value
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModel.someField).toEqual(mockDomainObject);
expect(mockScope.rootObject).toEqual(mockRootObject);
@@ -95,6 +98,7 @@ define(
// Pass selection change
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.structure.validate).toHaveBeenCalled();
// Change should have been rejected
@@ -108,14 +112,16 @@ define(
);
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModelController.$setValidity)
.toHaveBeenCalledWith(jasmine.any(String), true);
mockScope.$watch.mostRecentCall.args[1](undefined);
mockTimeout.mostRecentCall.args[0]();
expect(mockScope.ngModelController.$setValidity)
.toHaveBeenCalledWith(jasmine.any(String), false);
});
});
}
);
);

View File

@@ -81,7 +81,7 @@ define(
var persistence = domainObject.getCapability('persistence');
return persistence && persistence.persist();
}
/*
* Checks current object and ascendants of current
* object with object being removed, if the current
@@ -90,11 +90,11 @@ define(
*/
function checkObjectNavigation(object, parentObject) {
// Traverse object starts at current location
var traverseObject = (navigationService).getNavigation();
var traverseObject = (navigationService).getNavigation(),
context;
// Stop when object is not defined (above ROOT)
while (traverseObject && traverseObject.getCapability('context')) {
// If object currently traversed to is object being removed
// navigate to parent of current object and then exit loop
if (traverseObject.getId() === object.getId()) {
@@ -103,7 +103,8 @@ define(
}
// Traverses to parent of current object, moving
// up the ascendant path
traverseObject = traverseObject.getCapability('context').getParent();
context = traverseObject.getCapability('context');
traverseObject = context && context.getParent();
}
}
@@ -115,11 +116,11 @@ define(
function removeFromContext(object) {
var contextCapability = object.getCapability('context'),
parent = contextCapability.getParent();
// If currently within path of removed object(s),
// navigates to existing object up tree
checkObjectNavigation(object, parent);
return $q.when(
parent.useCapability('mutation', doMutate)
).then(function () {

View File

@@ -57,7 +57,8 @@ define(
// Also make sure we dismiss bubble if representation is destroyed
// before the mouse actually leaves it
this.scopeOff = element.scope().$on('$destroy', this.hideBubbleCallback);
this.scopeOff =
element.scope().$on('$destroy', this.hideBubbleCallback);
this.element = element;
this.$timeout = $timeout;
@@ -102,14 +103,7 @@ define(
InfoGesture.prototype.showBubble = function (event) {
var self = this;
this.trackPosition(event);
// Also need to track position during hover
this.element.on('mousemove', this.trackPositionCallback);
// Show the bubble, after a suitable delay (if mouse has
// left before this time is up, this will be canceled.)
this.pendingBubble = this.$timeout(function () {
function displayBubble() {
self.dismissBubble = self.infoService.display(
"info-table",
self.domainObject.getModel().name,
@@ -118,7 +112,23 @@ define(
);
self.element.off('mousemove', self.trackPositionCallback);
self.pendingBubble = undefined;
}, this.delay);
}
this.trackPosition(event);
// Do nothing if we're already scheduled to show a bubble.
// This may happen due to redundant event firings caused
// by https://github.com/angular/angular.js/issues/12795
if (this.pendingBubble) {
return;
}
// Also need to track position during hover
this.element.on('mousemove', this.trackPositionCallback);
// Show the bubble, after a suitable delay (if mouse has
// left before this time is up, this will be canceled.)
this.pendingBubble = this.$timeout(displayBubble, this.delay);
this.element.on('mouseleave', this.hideBubbleCallback);
};

View File

@@ -100,7 +100,9 @@ define(
body.append(bubble);
// Return a function to dismiss the bubble
return function () { bubble.remove(); };
return function () {
bubble.remove();
};
};
return InfoService;