From 4b7287e51e42acaac2adff9b4e55416c67ae3470 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 8 Dec 2015 14:51:25 -0800 Subject: [PATCH] Fixed JSLint errors --- .../commonUI/browse/src/BrowseController.js | 36 +++++++++--------- .../browse/src/BrowseObjectController.js | 6 +-- .../commonUI/edit/src/actions/SaveAction.js | 37 ++++++++----------- .../edit/src/capabilities/EditorCapability.js | 2 +- .../src/controllers/ElementsController.js | 5 ++- .../src/gestures/ContextMenuGesture.js | 2 +- .../src/gestures/DropGesture.js | 8 ++-- 7 files changed, 46 insertions(+), 50 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 5c23e2ba67..f2d7fbcd7b 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -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); diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js index f188557a0f..983aa158c3 100644 --- a/platform/commonUI/browse/src/BrowseObjectController.js +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -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](); + }; } diff --git a/platform/commonUI/edit/src/actions/SaveAction.js b/platform/commonUI/edit/src/actions/SaveAction.js index dff0e58748..3cda01129c 100644 --- a/platform/commonUI/edit/src/actions/SaveAction.js +++ b/platform/commonUI/edit/src/actions/SaveAction.js @@ -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())); diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index 62ae9fadc1..81d3486021 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -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()); }; diff --git a/platform/commonUI/edit/src/controllers/ElementsController.js b/platform/commonUI/edit/src/controllers/ElementsController.js index fb57387d79..c62e999fa2 100644 --- a/platform/commonUI/edit/src/controllers/ElementsController.js +++ b/platform/commonUI/edit/src/controllers/ElementsController.js @@ -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; } diff --git a/platform/representation/src/gestures/ContextMenuGesture.js b/platform/representation/src/gestures/ContextMenuGesture.js index f425a93a83..199b28e460 100644 --- a/platform/representation/src/gestures/ContextMenuGesture.js +++ b/platform/representation/src/gestures/ContextMenuGesture.js @@ -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 diff --git a/platform/representation/src/gestures/DropGesture.js b/platform/representation/src/gestures/DropGesture.js index d225f27f38..7d20578652 100644 --- a/platform/representation/src/gestures/DropGesture.js +++ b/platform/representation/src/gestures/DropGesture.js @@ -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 {