[New Edit Mode] #636 Modified EditAndCompose action to rely on a slightly refactored EditActionPolicy to remove folder specific logic

This commit is contained in:
Henry
2016-05-20 10:23:05 -07:00
parent 54a0de4a08
commit 601bc03ba2
3 changed files with 28 additions and 17 deletions

View File

@@ -37,7 +37,8 @@ define(
}
EditAndComposeAction.prototype.perform = function () {
var self = this;
var self = this,
editAction = this.domainObject.getCapability('action').getActions("edit")[0];
// Persist changes to the domain object
function doPersist() {
@@ -54,8 +55,8 @@ define(
.then(doPersist);
}
if (this.domainObject.getCapability('type').getKey() !== 'folder') {
this.domainObject.getCapability('action').perform('edit');
if (editAction) {
editAction.perform();
}
return this.selectedObject && doLink();

View File

@@ -81,17 +81,14 @@ define(
var key = action.getMetadata().key,
category = (context || {}).category;
// Only worry about actions in the view-control category
if (category === 'view-control') {
// Restrict 'edit' to cases where there are editable
// views (similarly, restrict 'properties' to when
// the converse is true), and where the domain object is not
// already being edited.
if (key === 'edit') {
return this.countEditableViews(context) > 0 && !isEditing(context);
} else if (key === 'properties') {
return this.countEditableViews(context) < 1 && !isEditing(context);
}
// Restrict 'edit' to cases where there are editable
// views (similarly, restrict 'properties' to when
// the converse is true), and where the domain object is not
// already being edited.
if (key === 'edit') {
return this.countEditableViews(context) > 0 && !isEditing(context);
} else if (key === 'properties' && category === 'view-control') {
return this.countEditableViews(context) < 1 && !isEditing(context);
}
// Like all policies, allow by default.