Fixed JSLint errors

This commit is contained in:
Henry 2015-12-08 14:51:25 -08:00
parent 4fbf547bfc
commit 4b7287e51e
7 changed files with 46 additions and 50 deletions

View File

@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise*/
/*global define,Promise, confirm*/
/**
* This bundle implements Browse mode.
@ -52,6 +52,13 @@ define(
($route.current.params.ids || DEFAULT_PATH).split("/")
);
function isDirty(){
var editorCapability = $scope.navigatedObject &&
$scope.navigatedObject.getCapability("editor"),
hasChanges = editorCapability && editorCapability.dirty();
return hasChanges;
}
function updateRoute(domainObject) {
var priorRoute = $route.current,
// Act as if params HADN'T changed to avoid page reload
@ -72,6 +79,15 @@ define(
}
// Callback for updating the in-scope reference to the object
// that is currently navigated-to.
function setNavigation(domainObject) {
$scope.navigatedObject = domainObject;
$scope.treeModel.selectedObject = domainObject;
navigationService.setNavigation(domainObject);
updateRoute(domainObject);
}
function setSelectedObject(domainObject) {
if (domainObject !== $scope.navigatedObject && isDirty() && !confirm(CONFIRM_MSG)) {
$scope.treeModel.selectedObject = $scope.navigatedObject;
@ -83,15 +99,6 @@ define(
}
}
// Callback for updating the in-scope reference to the object
// that is currently navigated-to.
function setNavigation(domainObject) {
$scope.navigatedObject = domainObject;
$scope.treeModel.selectedObject = domainObject;
navigationService.setNavigation(domainObject);
updateRoute(domainObject);
}
function navigateTo(domainObject) {
// Check if an object has been navigated-to already...
@ -159,18 +166,11 @@ define(
selectedObject: navigationService.getNavigation()
};
function isDirty(){
var editorCapability = $scope.navigatedObject &&
$scope.navigatedObject.getCapability("editor"),
hasChanges = editorCapability && editorCapability.dirty();
return hasChanges;
}
$scope.beforeUnloadWarning = function() {
return isDirty() ?
"Unsaved changes will be lost if you leave this page." :
undefined;
}
};
// Listen for changes in navigation state.
navigationService.addListener(setNavigation);

View File

@ -78,11 +78,11 @@ define(
$scope.cancelEditing = function() {
navigationService.setNavigation($scope.domainObject.getDomainObject());
}
};
$scope.doAction = function (action){
$scope[action] && $scope[action]();
}
return $scope[action] && $scope[action]();
};
}

View File

@ -40,7 +40,7 @@ define(
this.$location = $location;
this.injectObjectService = function(){
this.objectService = $injector.get("objectService");
}
};
this.urlService = urlService;
this.navigationService = navigationService;
this.policyService = policyService;
@ -55,7 +55,7 @@ define(
this.injectObjectService();
}
return this.objectService;
}
};
/**
* Save changes and conclude editing.
@ -71,12 +71,14 @@ define(
self = this;
function resolveWith(object){
return function() {return object};
return function() {
return object;
};
}
function doWizardSave(parent) {
var context = domainObject.getCapability("context");
var wizard = new CreateWizard(domainObject.useCapability('type'), parent, self.policyService, domainObject.getModel());
var context = domainObject.getCapability("context"),
wizard = new CreateWizard(domainObject.useCapability('type'), parent, self.policyService, domainObject.getModel());
function mergeObjects(fromObject, toObject){
Object.keys(fromObject).forEach(function(key) {
@ -114,7 +116,7 @@ define(
return self.$q.all(composees.map(function (composee) {
return object.getCapability('composition').add(composee);
})).then(resolveWith(object));
}
};
}
/**
@ -126,35 +128,26 @@ define(
function composeNewObject(object){
if (self.$q.when(object.hasCapability('composition') && domainObject.hasCapability('composition'))) {
return getAllComposees(domainObject)
.then(addComposeesToObject(object))
.then(addComposeesToObject(object));
}
}
return self.dialogService
.getUserInput(wizard.getFormStructure(), wizard.getInitialFormValue())
.then(buildObjectFromInput, doNothing)
//.then(composeNewObject)
//.then(object.getCapability("persistence"));
.then(buildObjectFromInput, doNothing);
}
function persistObject(object){
return (object.hasCapability('editor') && object.getCapability('editor').save(true) || object.getCapability('persistence').persist())
.then(resolveWith(object));
/*
if (object.hasCapability('editor')){
return object.getCapability('editor').save(true)
return ((object.hasCapability('editor') && object.getCapability('editor').save(true)) ||
object.getCapability('persistence').persist())
.then(resolveWith(object));
} else {
return object.useCapability(persistence);
}*/
}
function fetchObject(objectId){
return self.getObjectService().getObjects([objectId]).then(function(objects){
return objects[objectId];
})
});
}
function getParent(object){
@ -182,7 +175,9 @@ define(
// on user selection
.then(locateObjectInParent)
.then(persistObject)
.then(function(){return fetchObject(domainObject.getId());})
.then(function(){
return fetchObject(domainObject.getId());
});
} else {
return domainObject.getCapability("editor").save()
.then(resolveWith(domainObject.getOriginalObject()));

View File

@ -99,7 +99,7 @@ define(
editableObject.getCapability("status").set("editing", false);
return nonrecursive ?
resolvePromise(doMutate()).then(doPersist).then(function(){self.cancel()}) :
resolvePromise(doMutate()).then(doPersist).then(function(){self.cancel();}) :
resolvePromise(cache.saveAll());
};

View File

@ -33,10 +33,11 @@ define(
*/
function ElementsController($scope) {
function filterBy(text){
if (typeof text === 'undefined')
if (typeof text === 'undefined') {
return $scope.searchText;
else
} else {
$scope.searchText = text;
}
}
$scope.filterBy = filterBy;
}

View File

@ -44,7 +44,7 @@ define(
function ContextMenuGesture($timeout, $parse, agentService, navigationService, element, domainObject) {
var isPressing,
longTouchTime = 500,
parameters = element && element.attr('parameters') && $parse(element.attr('parameters'))()
parameters = element && element.attr('parameters') && $parse(element.attr('parameters'))();
function suppressMenu(){
return parameters

View File

@ -72,7 +72,7 @@ define(
function shouldCreateVirtualPanel(domainObject){
return domainObject.useCapability('view').filter(function (view){
return view.key==='plot' && domainObject.getModel().type!== 'telemetry.panel'
return view.key==='plot' && domainObject.getModel().type!== 'telemetry.panel';
}).length > 0;
}
@ -112,13 +112,13 @@ define(
type = typeService.getType(typeKey),
model = type.getInitialModel(),
id = uuid(),
newPanel = undefined;
newPanel;
model.type = typeKey;
newPanel = new EditableDomainObject(instantiate(model, id), $q);
[base.getId(), overlayId].forEach(function(id){
newPanel.getCapability('composition').add(id)
newPanel.getCapability('composition').add(id);
});
newPanel.getCapability('location').setPrimaryLocation(base.getCapability('location').getContextualLocation());
@ -146,7 +146,7 @@ define(
// the change.
if (id) {
if (shouldCreateVirtualPanel(domainObject)){
editableDomainObject = createVirtualPanel(domainObject, id)
editableDomainObject = createVirtualPanel(domainObject, id);
navigationService.setNavigation(editableDomainObject);
broadcastDrop(id, event);
} else {