Merge remote-tracking branch 'github/master' into open95b
Conflicts: platform/commonUI/edit/src/actions/RemoveAction.js
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
{
|
||||
"key": "LocatorController",
|
||||
"implementation": "creation/LocatorController",
|
||||
"depends": [ "$scope" ]
|
||||
"depends": [ "$scope", "$timeout" ]
|
||||
},
|
||||
{
|
||||
"key": "MenuArrowController",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
while (traverseObject) {
|
||||
// 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 () {
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
{
|
||||
"key": "mctSplitPane",
|
||||
"implementation": "directives/MCTSplitPane.js",
|
||||
"depends": [ "$parse", "$log" ]
|
||||
"depends": [ "$parse", "$log", "$interval" ]
|
||||
},
|
||||
{
|
||||
"key": "mctSplitter",
|
||||
|
||||
@@ -28,6 +28,7 @@ define(
|
||||
|
||||
// Pixel width to allocate for the splitter itself
|
||||
var DEFAULT_ANCHOR = 'left',
|
||||
POLLING_INTERVAL = 15, // milliseconds
|
||||
CHILDREN_WARNING_MESSAGE = [
|
||||
"Invalid mct-split-pane contents.",
|
||||
"This element should contain exactly three",
|
||||
@@ -94,7 +95,7 @@ define(
|
||||
* @memberof platform/commonUI/general
|
||||
* @constructor
|
||||
*/
|
||||
function MCTSplitPane($parse, $log) {
|
||||
function MCTSplitPane($parse, $log, $interval) {
|
||||
var anchors = {
|
||||
left: true,
|
||||
right: true,
|
||||
@@ -105,6 +106,7 @@ define(
|
||||
function controller($scope, $element, $attrs) {
|
||||
var anchorKey = $attrs.anchor || DEFAULT_ANCHOR,
|
||||
anchor,
|
||||
activeInterval,
|
||||
positionParsed = $parse($attrs.position),
|
||||
position; // Start undefined, until explicitly set
|
||||
|
||||
@@ -162,14 +164,14 @@ define(
|
||||
// Getter-setter for the pixel offset of the splitter,
|
||||
// relative to the current edge.
|
||||
function getSetPosition(value) {
|
||||
var min, max;
|
||||
var min, max, prior = position;
|
||||
if (typeof value === 'number') {
|
||||
position = value;
|
||||
enforceExtrema();
|
||||
updateElementPositions();
|
||||
|
||||
// Pass change up so this state can be shared
|
||||
if (positionParsed.assign) {
|
||||
if (positionParsed.assign && position !== prior) {
|
||||
positionParsed.assign($scope, position);
|
||||
}
|
||||
}
|
||||
@@ -193,6 +195,16 @@ define(
|
||||
$element.children().eq(anchor.reversed ? 2 : 0)[0]
|
||||
));
|
||||
|
||||
// And poll for position changes enforced by styles
|
||||
activeInterval = $interval(function () {
|
||||
getSetPosition(getSetPosition());
|
||||
}, POLLING_INTERVAL, false);
|
||||
|
||||
// ...and stop polling when we're destroyed.
|
||||
$scope.$on('$destroy', function () {
|
||||
$interval.cancel(activeInterval);
|
||||
});
|
||||
|
||||
// Interface exposed by controller, for mct-splitter to user
|
||||
return {
|
||||
position: getSetPosition,
|
||||
|
||||
@@ -48,10 +48,6 @@ define(
|
||||
|
||||
element.addClass("splitter");
|
||||
|
||||
// Now that we have the above class, the splitter width
|
||||
// will have changed, so trigger a positioning update.
|
||||
mctSplitPane.position(mctSplitPane.position());
|
||||
|
||||
scope.splitter = {
|
||||
// Begin moving this splitter
|
||||
startMove: function () {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user