From 433dd87e51f53cb4adfd83e213d7265a84f69fd3 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 12 May 2016 16:07:39 -0700 Subject: [PATCH] Resolved merge conflicts --- .../edit/src/capabilities/EditorCapability.js | 20 +++++++++++++++++-- .../edit/src/policies/EditableLinkPolicy.js | 7 ++++--- .../edit/src/policies/EditableMovePolicy.js | 4 ++-- .../edit/src/policies/EditableViewPolicy.js | 2 +- .../regions/src/InspectorController.js | 18 +++++++++++++++-- .../swimlane/TimelineSwimlaneDropHandler.js | 7 ++----- .../representation/src/MCTRepresentation.js | 19 +++++++++++++++--- .../src/gestures/DropGesture.js | 1 - 8 files changed, 59 insertions(+), 19 deletions(-) diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index 8f40508069..54d041aff0 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -39,6 +39,20 @@ define( this.domainObject.getCapability('status').set('editing', true); }; + function isEditing (domainObject) { + return domainObject.getCapability('status').get('editing') || + domainObject.hasCapability('context') && isEditing(domainObject.getCapability('context').getParent()); + } + + /** + * Determines whether this object, or any of its ancestors are + * currently being edited. + * @returns boolean + */ + EditorCapability.prototype.isEditing = function () { + return isEditing(this.domainObject); + }; + EditorCapability.prototype.save = function () { var domainObject = this.domainObject; return this.transactionService.commit().then(function() { @@ -60,8 +74,10 @@ define( return this.dirtyModelCache.isDirty(this.domainObject); }; - //TODO: add 'appliesTo'. EditorCapability should not be available - // for objects that should not be edited + EditorCapability.prototype.appliesTo = function(context) { + var domainObject = context.domainObject; + return domainObject && domainObject.getType().hasFeature("creation"); + } return EditorCapability; } diff --git a/platform/commonUI/edit/src/policies/EditableLinkPolicy.js b/platform/commonUI/edit/src/policies/EditableLinkPolicy.js index c311266cf8..1200496d35 100644 --- a/platform/commonUI/edit/src/policies/EditableLinkPolicy.js +++ b/platform/commonUI/edit/src/policies/EditableLinkPolicy.js @@ -35,11 +35,12 @@ define([], function () { } EditableLinkPolicy.prototype.allow = function (action, context) { - var key = action.getMetadata().key; + var key = action.getMetadata().key, + object; if (key === 'link') { - return !((context.selectedObject || context.domainObject) - .hasCapability('editor')); + object = context.selectedObject || context.domainObject; + return !(object.hasCapability("editor") && object.getCapability("editor").isEditing()); } // Like all policies, allow by default. diff --git a/platform/commonUI/edit/src/policies/EditableMovePolicy.js b/platform/commonUI/edit/src/policies/EditableMovePolicy.js index e89113ea60..cc95114206 100644 --- a/platform/commonUI/edit/src/policies/EditableMovePolicy.js +++ b/platform/commonUI/edit/src/policies/EditableMovePolicy.js @@ -37,8 +37,8 @@ define([], function () { selectedObject = context.selectedObject, key = action.getMetadata().key; - if (key === 'move' && domainObject.hasCapability('editor')) { - return !!selectedObject && selectedObject.hasCapability('editor'); + if (key === 'move' && domainObject.hasCapability('editor') && domainObject.getCapability('editor').isEditing()) { + return !!selectedObject && selectedObject.hasCapability('editor') && selectedObject.getCapability('editor').isEditing(); } // Like all policies, allow by default. diff --git a/platform/commonUI/edit/src/policies/EditableViewPolicy.js b/platform/commonUI/edit/src/policies/EditableViewPolicy.js index 7c9742e2d3..b4ba951bd0 100644 --- a/platform/commonUI/edit/src/policies/EditableViewPolicy.js +++ b/platform/commonUI/edit/src/policies/EditableViewPolicy.js @@ -37,7 +37,7 @@ define( // If a view is flagged as non-editable, only allow it // while we're not in Edit mode. if ((view || {}).editable === false) { - return !domainObject.hasCapability('editor'); + return !(domainObject.hasCapability('editor') && domainObject.getCapability('editor').isEditing()); } // Like all policies, allow by default. diff --git a/platform/commonUI/regions/src/InspectorController.js b/platform/commonUI/regions/src/InspectorController.js index c97b055462..3c0df1e839 100644 --- a/platform/commonUI/regions/src/InspectorController.js +++ b/platform/commonUI/regions/src/InspectorController.js @@ -32,7 +32,8 @@ define( */ function InspectorController($scope, policyService) { var domainObject = $scope.domainObject, - typeCapability = domainObject.getCapability('type'); + typeCapability = domainObject.getCapability('type'), + listener; /** * Filters region parts to only those allowed by region policies @@ -46,7 +47,20 @@ define( }); } - $scope.regions = filterRegions(typeCapability.getDefinition().inspector || new InspectorRegion()); + function setRegions() { + $scope.regions = filterRegions(typeCapability.getDefinition().inspector || new InspectorRegion()); + } + + //Listen for changes to object status that might necessitate + // recalculation of screen regions. + //listener = + // domainObject.getCapability("status").listen(setRegions); + + setRegions(); + + $scope.$on("$destroy", function() { + listener(); + }) } return InspectorController; diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js index 7195d91895..f5d46fbaf7 100644 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js +++ b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js @@ -41,11 +41,8 @@ define( // Check if we are in edit mode (also check parents) function inEditMode(swimlane) { - if (!swimlane.domainObject.getCapability("status").get("editing") && swimlane.parent) { - return inEditMode(swimlane.parent); - } else { - return swimlane.domainObject.getCapability("status").get("editing"); - } + return swimlane.domainObject.hasCapability('editor') && + swimlane.domainObject.getCapability('editor').isEditing(); } // Boolean and (for reduce below) diff --git a/platform/representation/src/MCTRepresentation.js b/platform/representation/src/MCTRepresentation.js index b0c0518d24..264614e5a2 100644 --- a/platform/representation/src/MCTRepresentation.js +++ b/platform/representation/src/MCTRepresentation.js @@ -53,7 +53,8 @@ define( * @param {ViewDefinition[]} views an array of view extensions */ function MCTRepresentation(representations, views, representers, $q, templateLinker, $log) { - var representationMap = {}; + var representationMap = {}, + domainObjectListener; // Assemble all representations and views // The distinction between views and representations is @@ -167,7 +168,7 @@ define( representation = lookup($scope.key, domainObject), uses = ((representation || {}).uses || []), canRepresent = !!(representation && domainObject), - canEdit = !!(domainObject && domainObject.hasCapability('editor')), + canEdit = !!(domainObject && domainObject.hasCapability('editor') && domainObject.getCapability('editor').isEditing()), idPath = getIdPath(domainObject), key = $scope.key; @@ -175,6 +176,8 @@ define( return; } + console.log("changed"); + // Create an empty object named "representation", for this // representation to store local variables into. $scope.representation = {}; @@ -237,7 +240,17 @@ define( // Also update when the represented domain object changes // (to a different object) - $scope.$watch("domainObject", refresh); + //$scope.$watch("domainObject", refresh); + + $scope.$watch("domainObject", function (domainObject) { + if (domainObjectListener) { + domainObjectListener(); + } + if (domainObject) { + domainObjectListener = domainObject.getCapability('status').listen(refresh); + } + refresh(); + }); // Finally, also update when there is a new version of that // same domain object; these changes should be tracked in the diff --git a/platform/representation/src/gestures/DropGesture.js b/platform/representation/src/gestures/DropGesture.js index c25899b9db..e323e9d4a2 100644 --- a/platform/representation/src/gestures/DropGesture.js +++ b/platform/representation/src/gestures/DropGesture.js @@ -103,7 +103,6 @@ define( // the change. if (id) { e.preventDefault(); - if (domainObjectType!=='folder') { domainObject.getCapability('action').perform('edit'); }