Merge branch 'master' into jscs-rebase-142

Conflicts:
	platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js
	platform/representation/src/MCTRepresentation.js
This commit is contained in:
Victor Woeltjen
2016-05-20 13:07:58 -07:00
11 changed files with 122 additions and 102 deletions

View File

@ -88,7 +88,6 @@ define(
toClear = [], // Properties to clear out of scope on change
counter = 0,
couldRepresent = false,
couldEdit = false,
lastIdPath = [],
lastKey,
statusListener,
@ -137,14 +136,13 @@ define(
});
}
function unchanged(canRepresent, canEdit, idPath, key) {
function unchanged(canRepresent, idPath, key) {
return (canRepresent === couldRepresent) &&
(key === lastKey) &&
(idPath.length === lastIdPath.length) &&
idPath.every(function (id, i) {
return id === lastIdPath[i];
}) &&
(canEdit === couldEdit);
});
}
function getIdPath(domainObject) {
@ -168,11 +166,10 @@ define(
representation = lookup($scope.key, domainObject),
uses = ((representation || {}).uses || []),
canRepresent = !!(representation && domainObject),
canEdit = !!(domainObject && domainObject.hasCapability('editor') && domainObject.getCapability('editor').inEditContext()),
idPath = getIdPath(domainObject),
key = $scope.key;
if (unchanged(canRepresent, canEdit, idPath, key)) {
if (unchanged(canRepresent, idPath, key)) {
return;
}
@ -201,7 +198,6 @@ define(
// To allow simplified change detection next time around
couldRepresent = canRepresent;
lastIdPath = idPath;
couldEdit = canEdit;
lastKey = key;
// Populate scope with fields associated with the current
@ -239,26 +235,7 @@ define(
// Also update when the represented domain object changes
// (to a different object)
$scope.$watch("domainObject", refresh);
function listenForStatusChange(object) {
if (statusListener) {
statusListener();
}
statusListener = object.getCapability("status").listen(refresh);
}
/**
* Add a listener to the object for status changes.
*/
$scope.$watch("domainObject", function (domainObject, oldDomainObject) {
if (domainObject !== oldDomainObject) {
listenForStatusChange(domainObject);
}
});
if ($scope.domainObject) {
listenForStatusChange($scope.domainObject);
}
// Finally, also update when there is a new version of that
// same domain object; these changes should be tracked in the
// model's "modified" field, by the mutation capability.

View File

@ -54,9 +54,6 @@ define(
// ...and broadcast the event. This allows specific
// views to have post-drop behavior which depends on
// drop position.
// Also broadcast the editableDomainObject to
// avoid race condition against non-editable
// version in EditRepresenter
scope.$broadcast(
GestureConstants.MCT_DROP_EVENT,
id,
@ -93,21 +90,13 @@ define(
function drop(e) {
var event = (e || {}).originalEvent || e,
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
domainObjectType = domainObject.getModel().type;
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE);
// Handle the drop; add the dropped identifier to the
// destination domain object's composition, and persist
// the change.
if (id) {
e.preventDefault();
//Use scope.apply, drop event is outside digest cycle
scope.$apply(function () {
if (domainObjectType !== 'folder') {
domainObject.getCapability('action').perform('edit');
}
});
$q.when(action && action.perform()).then(function () {
broadcastDrop(id, event);
});