From a27b3737f19834bcbd7d771549ff2a39f9f5a4d5 Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Mon, 25 Mar 2019 18:26:39 -0700 Subject: [PATCH] Fixes testathon 3/21 (#2328) * fix error in location.vue because of drawing objects in selection * add conditional to check if view is editable before forcing edit after create * show original location only in inspector, add original location for drawing objects * fix document title * set document title in browse.js * sort items in create menu * sort children in tree by name * remove ordering from tree items * add loading spinner * fix minor bug --- platform/commonUI/browse/bundle.js | 10 --- .../browse/src/windowing/WindowTitler.js | 51 ------------ .../browse/test/windowing/WindowTitlerSpec.js | 78 ------------------- .../edit/src/creation/CreateAction.js | 10 ++- src/ui/inspector/Location.vue | 30 ++++--- src/ui/layout/CreateButton.vue | 15 +++- src/ui/layout/mct-tree.vue | 16 +++- src/ui/layout/tree-item.vue | 16 +++- src/ui/router/Browse.js | 7 +- 9 files changed, 75 insertions(+), 158 deletions(-) delete mode 100644 platform/commonUI/browse/src/windowing/WindowTitler.js delete mode 100644 platform/commonUI/browse/test/windowing/WindowTitlerSpec.js diff --git a/platform/commonUI/browse/bundle.js b/platform/commonUI/browse/bundle.js index 21347cf5c5..0f64e5fd55 100644 --- a/platform/commonUI/browse/bundle.js +++ b/platform/commonUI/browse/bundle.js @@ -31,7 +31,6 @@ define([ "./src/navigation/NavigateAction", "./src/navigation/OrphanNavigationHandler", "./src/windowing/NewTabAction", - "./src/windowing/WindowTitler", "./res/templates/browse.html", "./res/templates/browse-object.html", "./res/templates/browse/object-header.html", @@ -52,7 +51,6 @@ define([ NavigateAction, OrphanNavigationHandler, NewTabAction, - WindowTitler, browseTemplate, browseObjectTemplate, objectHeaderTemplate, @@ -226,14 +224,6 @@ define([ } ], "runs": [ - { - "implementation": WindowTitler, - "depends": [ - "navigationService", - "$rootScope", - "$document" - ] - }, { "implementation": OrphanNavigationHandler, "depends": [ diff --git a/platform/commonUI/browse/src/windowing/WindowTitler.js b/platform/commonUI/browse/src/windowing/WindowTitler.js deleted file mode 100644 index e3545268b9..0000000000 --- a/platform/commonUI/browse/src/windowing/WindowTitler.js +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT is licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * Open MCT includes source code licensed under additional open source - * licenses. See the Open Source Licenses file (LICENSES.md) included with - * this source code distribution or the Licensing information page available - * at runtime from the About dialog for additional information. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Updates the title of the current window to reflect the name - * of the currently navigated-to domain object. - * @memberof platform/commonUI/browse - * @constructor - */ - function WindowTitler(navigationService, $rootScope, $document) { - // Look up name of the navigated domain object... - function getNavigatedObjectName() { - var navigatedObject = navigationService.getNavigation(); - return navigatedObject && navigatedObject.getModel().name; - } - - // Set the window title... - function setTitle(name) { - $document[0].title = name; - } - - // Watch the former, and invoke the latter - $rootScope.$watch(getNavigatedObjectName, setTitle); - } - - return WindowTitler; - } -); diff --git a/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js b/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js deleted file mode 100644 index fdad395f43..0000000000 --- a/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT is licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * Open MCT includes source code licensed under additional open source - * licenses. See the Open Source Licenses file (LICENSES.md) included with - * this source code distribution or the Licensing information page available - * at runtime from the About dialog for additional information. - *****************************************************************************/ - -/** - * WindowTitlerSpec. Created by vwoeltje on 11/6/14. - */ -define( - ["../../src/windowing/WindowTitler"], - function (WindowTitler) { - - describe("The window titler", function () { - var mockNavigationService, - mockRootScope, - mockDocument, - mockDomainObject, - titler; // eslint-disable-line - - beforeEach(function () { - mockNavigationService = jasmine.createSpyObj( - 'navigationService', - ['getNavigation'] - ); - mockRootScope = jasmine.createSpyObj( - '$rootScope', - ['$watch'] - ); - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getModel'] - ); - mockDocument = [{}]; - - mockDomainObject.getModel.and.returnValue({ name: 'Test name' }); - mockNavigationService.getNavigation.and.returnValue(mockDomainObject); - - titler = new WindowTitler( - mockNavigationService, - mockRootScope, - mockDocument - ); - }); - - it("listens for changes to the name of the navigated object", function () { - expect(mockRootScope.$watch).toHaveBeenCalledWith( - jasmine.any(Function), - jasmine.any(Function) - ); - expect(mockRootScope.$watch.calls.mostRecent().args[0]()) - .toEqual('Test name'); - }); - - it("sets the title to the name of the navigated object", function () { - mockRootScope.$watch.calls.mostRecent().args[1]("Some name"); - expect(mockDocument[0].title).toEqual("Some name"); - }); - - }); - } -); diff --git a/platform/commonUI/edit/src/creation/CreateAction.js b/platform/commonUI/edit/src/creation/CreateAction.js index 9b4bf0f995..9282acf899 100644 --- a/platform/commonUI/edit/src/creation/CreateAction.js +++ b/platform/commonUI/edit/src/creation/CreateAction.js @@ -71,6 +71,12 @@ define( openmct.editor.cancel(); } + function isFirstViewEditable(domainObject) { + let firstView = openmct.objectViews.get(domainObject)[0]; + + return firstView && firstView.canEdit && firstView.canEdit(domainObject); + } + function navigateAndEdit(object) { let objectPath = object.getCapability('context').getPath(), url = '#/browse/' + objectPath @@ -82,7 +88,9 @@ define( window.location.href = url; - openmct.editor.edit(); + if (isFirstViewEditable(object.useCapability('adapter'))) { + openmct.editor.edit(); + } } newModel.type = this.type.getKey(); diff --git a/src/ui/inspector/Location.vue b/src/ui/inspector/Location.vue index e2072a2628..adc7b6aad0 100644 --- a/src/ui/inspector/Location.vue +++ b/src/ui/inspector/Location.vue @@ -1,9 +1,8 @@