Updated check for edit mode on create

This commit is contained in:
Henry 2015-12-09 20:37:15 -08:00
parent 1e7964855a
commit 708aa7dcba

View File

@ -67,6 +67,19 @@ define(
this.$q = $q; this.$q = $q;
} }
// Get a count of views which are not flagged as non-editable.
function countEditableViews(domainObject) {
var views = domainObject && domainObject.useCapability('view'),
count = 0;
// A view is editable unless explicitly flagged as not
(views || []).forEach(function (view) {
count += (view.editable !== false) ? 1 : 0;
});
return count;
}
/** /**
* Create a new object of the given type. * Create a new object of the given type.
* This will prompt for user input first. * This will prompt for user input first.
@ -85,7 +98,7 @@ define(
model.location = parentObject.getId(); model.location = parentObject.getId();
}); });
if (newObject.hasCapability('composition') && this.type.getKey()!=='folder') { if (countEditableViews(editableObject) > 0) {
this.navigationService.setNavigation(editableObject); this.navigationService.setNavigation(editableObject);
} else { } else {
return editableObject.getCapability('action').perform('save'); return editableObject.getCapability('action').perform('save');