mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 23:53:49 +00:00
[New Edit Mode] Code style fixes
JSLint error
This commit is contained in:
@ -75,7 +75,9 @@ define(
|
|||||||
// urlService.urlForLocation used to adjust current
|
// urlService.urlForLocation used to adjust current
|
||||||
// path to new, addressed, path based on
|
// path to new, addressed, path based on
|
||||||
// domainObject
|
// domainObject
|
||||||
$location.path(urlService.urlForLocation("browse", domainObject.hasCapability('editor') ? domainObject.getOriginalObject() : domainObject));
|
$location.path(urlService.urlForLocation("browse",
|
||||||
|
domainObject.hasCapability('editor') ?
|
||||||
|
domainObject.getOriginalObject() : domainObject));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,10 @@
|
|||||||
/*global define,Promise*/
|
/*global define,Promise*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['../../../representation/src/gestures/GestureConstants',
|
[
|
||||||
'../../edit/src/objects/EditableDomainObject'],
|
'../../../representation/src/gestures/GestureConstants',
|
||||||
|
'../../edit/src/objects/EditableDomainObject'
|
||||||
|
],
|
||||||
function (GestureConstants, EditableDomainObject) {
|
function (GestureConstants, EditableDomainObject) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -50,17 +52,15 @@ define(
|
|||||||
((domainObject && domainObject.useCapability('view')) || [])
|
((domainObject && domainObject.useCapability('view')) || [])
|
||||||
.forEach(selectViewIfMatching);
|
.forEach(selectViewIfMatching);
|
||||||
}
|
}
|
||||||
//$scope.editMode = domainObject.hasCapability('editor') ?
|
|
||||||
// true : false;
|
|
||||||
navigatedObject = domainObject;
|
navigatedObject = domainObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateQueryParam(viewKey) {
|
function updateQueryParam(viewKey) {
|
||||||
var unlisten,
|
var unlisten,
|
||||||
priorRoute = $route.current,
|
priorRoute = $route.current,
|
||||||
editMode = $scope.domainObject && $scope.domainObject.hasCapability('editor');
|
isEditMode = $scope.domainObject && $scope.domainObject.hasCapability('editor');
|
||||||
|
|
||||||
if (viewKey && !editMode) {
|
if (viewKey && !isEditMode) {
|
||||||
$location.search('view', viewKey);
|
$location.search('view', viewKey);
|
||||||
unlisten = $scope.$on('$locationChangeSuccess', function () {
|
unlisten = $scope.$on('$locationChangeSuccess', function () {
|
||||||
// Checks path to make sure /browse/ is at front
|
// Checks path to make sure /browse/ is at front
|
||||||
|
@ -25,9 +25,11 @@
|
|||||||
* Module defining CreateAction. Created by vwoeltje on 11/10/14.
|
* Module defining CreateAction. Created by vwoeltje on 11/10/14.
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
['./CreateWizard',
|
[
|
||||||
|
'./CreateWizard',
|
||||||
'uuid',
|
'uuid',
|
||||||
'../../../edit/src/objects/EditableDomainObject'],
|
'../../../edit/src/objects/EditableDomainObject'
|
||||||
|
],
|
||||||
function (CreateWizard, uuid, EditableDomainObject) {
|
function (CreateWizard, uuid, EditableDomainObject) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
@ -98,9 +98,15 @@ define(
|
|||||||
|
|
||||||
editableObject.getCapability("status").set("editing", false);
|
editableObject.getCapability("status").set("editing", false);
|
||||||
|
|
||||||
return nonrecursive ?
|
if (nonrecursive) {
|
||||||
resolvePromise(doMutate()).then(doPersist).then(function(){self.cancel();}) :
|
return resolvePromise(doMutate())
|
||||||
resolvePromise(cache.saveAll());
|
.then(doPersist)
|
||||||
|
.then(function(){
|
||||||
|
self.cancel();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return resolvePromise(cache.saveAll());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,7 +108,6 @@ define(
|
|||||||
this.key = (representation || {}).key;
|
this.key = (representation || {}).key;
|
||||||
// Track the represented object
|
// Track the represented object
|
||||||
this.domainObject = representedObject;
|
this.domainObject = representedObject;
|
||||||
this.scope.editMode = representedObject.hasCapability("editor");
|
|
||||||
|
|
||||||
// Ensure existing watches are released
|
// Ensure existing watches are released
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
@ -58,27 +58,33 @@ define(
|
|||||||
return domainObject.getCapability('status').get('editing');
|
return domainObject.getCapability('status').get('editing');
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasEditableParent(domainObject){
|
function hasEditableAncestor(domainObject){
|
||||||
return domainObject.hasCapability('context') &&
|
return domainObject.hasCapability('context') &&
|
||||||
domainObject.getCapability('context').getPath().reduce(
|
domainObject
|
||||||
function(previous, domainObject){
|
.getCapability('context')
|
||||||
return domainObject.getCapability('status').get('editing') || previous;
|
.getPath()
|
||||||
}, false);
|
.some(function isEditable (ancestor){
|
||||||
|
return ancestor.getCapability('status').get('editing');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform an action. This will find and perform the
|
* Retrieve the actions applicable to the domain object in the given
|
||||||
* first matching action available for the specified
|
* context.
|
||||||
* context or key.
|
|
||||||
*
|
*
|
||||||
* @param {ActionContext|string} context the context in which
|
* @param {ActionContext|string} context the context in which
|
||||||
* to perform the action; this is passed along to
|
* to assess the applicability of the available actions; this is
|
||||||
* the action service to match against available
|
* passed along to the action service to match against available
|
||||||
* actions. The "domainObject" field will automatically
|
* actions. The "domainObject" field will automatically
|
||||||
* be populated with the domain object that exposed
|
* be populated with the domain object that exposed
|
||||||
* this capability. If given as a string, this will
|
* this capability. If given as a string, this will
|
||||||
* be taken as the "key" field to match against
|
* be taken as the "key" field to match against
|
||||||
* specific actions.
|
* specific actions.
|
||||||
|
*
|
||||||
|
* Additionally, this function will limit the actions
|
||||||
|
* available for an object in Edit Mode
|
||||||
|
* @returns {Array<Action>} The actions applicable to this domain
|
||||||
|
* object in the given context
|
||||||
* @memberof platform/core.ActionCapability#
|
* @memberof platform/core.ActionCapability#
|
||||||
*/
|
*/
|
||||||
ActionCapability.prototype.getActions = function (context) {
|
ActionCapability.prototype.getActions = function (context) {
|
||||||
@ -93,7 +99,7 @@ define(
|
|||||||
actionContext.domainObject = this.domainObject;
|
actionContext.domainObject = this.domainObject;
|
||||||
|
|
||||||
actions = this.actionService.getActions(actionContext) || [];
|
actions = this.actionService.getActions(actionContext) || [];
|
||||||
if (isEditable(this.domainObject) || hasEditableParent(this.domainObject)){
|
if (isEditable(this.domainObject) || hasEditableAncestor(this.domainObject)){
|
||||||
return actions.filter(function(action){
|
return actions.filter(function(action){
|
||||||
return DISALLOWED_ACTIONS.indexOf(action.getMetadata().key) === -1;
|
return DISALLOWED_ACTIONS.indexOf(action.getMetadata().key) === -1;
|
||||||
});
|
});
|
||||||
|
@ -45,7 +45,7 @@ define(
|
|||||||
function DropGesture(dndService, $q, navigationService, objectService, instantiate, typeService, element, domainObject) {
|
function DropGesture(dndService, $q, navigationService, objectService, instantiate, typeService, element, domainObject) {
|
||||||
var actionCapability = domainObject.getCapability('action'),
|
var actionCapability = domainObject.getCapability('action'),
|
||||||
editableDomainObject,
|
editableDomainObject,
|
||||||
scope = element && element.scope && element.scope(),
|
scope = element.scope && element.scope(),
|
||||||
action; // Action for the drop, when it occurs
|
action; // Action for the drop, when it occurs
|
||||||
|
|
||||||
function broadcastDrop(id, event) {
|
function broadcastDrop(id, event) {
|
||||||
@ -83,7 +83,8 @@ define(
|
|||||||
|
|
||||||
function shouldCreateVirtualPanel(domainObject){
|
function shouldCreateVirtualPanel(domainObject){
|
||||||
return domainObject.useCapability('view').filter(function (view){
|
return domainObject.useCapability('view').filter(function (view){
|
||||||
return (view.key==='plot' || view.key==='scrolling') && domainObject.getModel().type!== 'telemetry.panel';
|
return (view.key === 'plot' || view.key === 'scrolling')
|
||||||
|
&& domainObject.getModel().type !== 'telemetry.panel';
|
||||||
}).length > 0;
|
}).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +92,13 @@ define(
|
|||||||
//Refresh domain object on each dragOver to catch external
|
//Refresh domain object on each dragOver to catch external
|
||||||
// updates to the model
|
// updates to the model
|
||||||
//Don't use EditableDomainObject for folders, allow immediate persistence
|
//Don't use EditableDomainObject for folders, allow immediate persistence
|
||||||
editableDomainObject = domainObject.hasCapability('editor') || domainObject.getModel().type==='folder' ? domainObject : new EditableDomainObject(domainObject, $q);
|
if (domainObject.hasCapability('editor') ||
|
||||||
|
domainObject.getModel().type==='folder') {
|
||||||
|
editableDomainObject = domainObject;
|
||||||
|
} else {
|
||||||
|
editableDomainObject = new EditableDomainObject(domainObject, $q);
|
||||||
|
}
|
||||||
|
|
||||||
actionCapability = editableDomainObject.getCapability('action');
|
actionCapability = editableDomainObject.getCapability('action');
|
||||||
|
|
||||||
var event = (e || {}).originalEvent || e,
|
var event = (e || {}).originalEvent || e,
|
||||||
@ -136,12 +143,11 @@ define(
|
|||||||
newPanel.getCapability('composition').add(id);
|
newPanel.getCapability('composition').add(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
newPanel.getCapability('location').setPrimaryLocation(base.getCapability('location').getContextualLocation());
|
newPanel.getCapability('location')
|
||||||
|
.setPrimaryLocation(base.getCapability('location')
|
||||||
|
.getContextualLocation());
|
||||||
|
|
||||||
//var virtualPanel = new EditableDomainObject(newPanel, $q);
|
|
||||||
//virtualPanel.setOriginalObject(base);
|
|
||||||
newPanel.setOriginalObject(base);
|
newPanel.setOriginalObject(base);
|
||||||
//return virtualPanel;
|
|
||||||
return newPanel;
|
return newPanel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user