mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 22:50:49 +00:00
Modified edit policy to hide edit button when in edit mode
This commit is contained in:
parent
acb7d4b807
commit
833ef82e67
@ -51,6 +51,19 @@ define(
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the domain object is currently being edited. If
|
||||||
|
* so, the edit action is not applicable.
|
||||||
|
* @param context
|
||||||
|
* @returns {*|boolean}
|
||||||
|
*/
|
||||||
|
function isEditing(context) {
|
||||||
|
var domainObject = (context || {}).domainObject;
|
||||||
|
return domainObject
|
||||||
|
&& domainObject.hasCapability('status')
|
||||||
|
&& domainObject.getCapability('status').get('editing');
|
||||||
|
}
|
||||||
|
|
||||||
EditActionPolicy.prototype.allow = function (action, context) {
|
EditActionPolicy.prototype.allow = function (action, context) {
|
||||||
var key = action.getMetadata().key,
|
var key = action.getMetadata().key,
|
||||||
category = (context || {}).category;
|
category = (context || {}).category;
|
||||||
@ -59,11 +72,12 @@ define(
|
|||||||
if (category === 'view-control') {
|
if (category === 'view-control') {
|
||||||
// Restrict 'edit' to cases where there are editable
|
// Restrict 'edit' to cases where there are editable
|
||||||
// views (similarly, restrict 'properties' to when
|
// views (similarly, restrict 'properties' to when
|
||||||
// the converse is true)
|
// the converse is true), and where the domain object is not
|
||||||
|
// already being edited.
|
||||||
if (key === 'edit') {
|
if (key === 'edit') {
|
||||||
return countEditableViews(context) > 0;
|
return countEditableViews(context) > 0 && !isEditing(context);
|
||||||
} else if (key === 'properties') {
|
} else if (key === 'properties') {
|
||||||
return countEditableViews(context) < 1;
|
return countEditableViews(context) < 1 && !isEditing(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +134,7 @@ define(
|
|||||||
function drop(e) {
|
function drop(e) {
|
||||||
var event = (e || {}).originalEvent || e,
|
var event = (e || {}).originalEvent || e,
|
||||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
||||||
domainObjectType = editableDomainObject.getModel().type,
|
domainObjectType = editableDomainObject.getModel().type;
|
||||||
virtualPanel;
|
|
||||||
|
|
||||||
// If currently in edit mode allow drag and drop gestures to the
|
// If currently in edit mode allow drag and drop gestures to the
|
||||||
// domain object. An exception to this is folders which have drop
|
// domain object. An exception to this is folders which have drop
|
||||||
@ -147,10 +146,10 @@ define(
|
|||||||
// the change.
|
// the change.
|
||||||
if (id) {
|
if (id) {
|
||||||
if (shouldCreateVirtualPanel(domainObject)){
|
if (shouldCreateVirtualPanel(domainObject)){
|
||||||
navigationService.setNavigation(createVirtualPanel(domainObject, id));
|
editableDomainObject = createVirtualPanel(domainObject, id)
|
||||||
|
navigationService.setNavigation(editableDomainObject);
|
||||||
broadcastDrop(id, event);
|
broadcastDrop(id, event);
|
||||||
} else {
|
} else {
|
||||||
editableDomainObject.getCapability('status').set('editing', true);
|
|
||||||
$q.when(action && action.perform()).then(function (result) {
|
$q.when(action && action.perform()).then(function (result) {
|
||||||
//Don't go into edit mode for folders
|
//Don't go into edit mode for folders
|
||||||
if (domainObjectType!=='folder') {
|
if (domainObjectType!=='folder') {
|
||||||
@ -159,6 +158,7 @@ define(
|
|||||||
broadcastDrop(id, event);
|
broadcastDrop(id, event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
editableDomainObject.getCapability('status').set('editing', true);
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
// TODO: Alert user if drag and drop is not allowed
|
// TODO: Alert user if drag and drop is not allowed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user