mirror of
https://github.com/nasa/openmct.git
synced 2025-06-20 08:03:49 +00:00
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
This commit is contained in:
committed by
Andrew Henry
parent
78dccf1e0a
commit
a27b3737f1
@ -31,7 +31,6 @@ define([
|
|||||||
"./src/navigation/NavigateAction",
|
"./src/navigation/NavigateAction",
|
||||||
"./src/navigation/OrphanNavigationHandler",
|
"./src/navigation/OrphanNavigationHandler",
|
||||||
"./src/windowing/NewTabAction",
|
"./src/windowing/NewTabAction",
|
||||||
"./src/windowing/WindowTitler",
|
|
||||||
"./res/templates/browse.html",
|
"./res/templates/browse.html",
|
||||||
"./res/templates/browse-object.html",
|
"./res/templates/browse-object.html",
|
||||||
"./res/templates/browse/object-header.html",
|
"./res/templates/browse/object-header.html",
|
||||||
@ -52,7 +51,6 @@ define([
|
|||||||
NavigateAction,
|
NavigateAction,
|
||||||
OrphanNavigationHandler,
|
OrphanNavigationHandler,
|
||||||
NewTabAction,
|
NewTabAction,
|
||||||
WindowTitler,
|
|
||||||
browseTemplate,
|
browseTemplate,
|
||||||
browseObjectTemplate,
|
browseObjectTemplate,
|
||||||
objectHeaderTemplate,
|
objectHeaderTemplate,
|
||||||
@ -226,14 +224,6 @@ define([
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"runs": [
|
"runs": [
|
||||||
{
|
|
||||||
"implementation": WindowTitler,
|
|
||||||
"depends": [
|
|
||||||
"navigationService",
|
|
||||||
"$rootScope",
|
|
||||||
"$document"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"implementation": OrphanNavigationHandler,
|
"implementation": OrphanNavigationHandler,
|
||||||
"depends": [
|
"depends": [
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
);
|
|
@ -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");
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
@ -71,6 +71,12 @@ define(
|
|||||||
openmct.editor.cancel();
|
openmct.editor.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isFirstViewEditable(domainObject) {
|
||||||
|
let firstView = openmct.objectViews.get(domainObject)[0];
|
||||||
|
|
||||||
|
return firstView && firstView.canEdit && firstView.canEdit(domainObject);
|
||||||
|
}
|
||||||
|
|
||||||
function navigateAndEdit(object) {
|
function navigateAndEdit(object) {
|
||||||
let objectPath = object.getCapability('context').getPath(),
|
let objectPath = object.getCapability('context').getPath(),
|
||||||
url = '#/browse/' + objectPath
|
url = '#/browse/' + objectPath
|
||||||
@ -82,7 +88,9 @@ define(
|
|||||||
|
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
|
|
||||||
openmct.editor.edit();
|
if (isFirstViewEditable(object.useCapability('adapter'))) {
|
||||||
|
openmct.editor.edit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newModel.type = this.type.getKey();
|
newModel.type = this.type.getKey();
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="c-properties c-properties--location">
|
<div class="c-properties c-properties--location">
|
||||||
<div class="c-properties__header" title="The location of this linked object.">Location</div>
|
<div class="c-properties__header" title="The location of this linked object.">Original Location</div>
|
||||||
<ul class="c-properties__section">
|
<ul class="c-properties__section">
|
||||||
<li class="c-properties__row" v-if="originalPath.length">
|
<li class="c-properties__row" v-if="originalPath.length">
|
||||||
<div class="c-properties__label">Original</div>
|
|
||||||
<ul class="c-properties__value">
|
<ul class="c-properties__value">
|
||||||
<li v-for="pathObject in orderedOriginalPath"
|
<li v-for="pathObject in orderedOriginalPath"
|
||||||
:key="pathObject.key">
|
:key="pathObject.key">
|
||||||
@ -43,8 +42,14 @@ export default {
|
|||||||
this.openmct.selection.off('change', this.updateSelection);
|
this.openmct.selection.off('change', this.updateSelection);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setOriginalPath(path) {
|
setOriginalPath(path, skipSlice) {
|
||||||
this.originalPath = path.slice(1,-1).map((domainObject, index, pathArray) => {
|
let originalPath = path;
|
||||||
|
|
||||||
|
if (!skipSlice) {
|
||||||
|
originalPath = path.slice(1,-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.originalPath = originalPath.map((domainObject, index, pathArray) => {
|
||||||
let key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
let key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
return {
|
return {
|
||||||
domainObject,
|
domainObject,
|
||||||
@ -53,10 +58,17 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
clearData() {
|
||||||
|
this.domainObject = {};
|
||||||
|
this.originalPath = [];
|
||||||
|
this.keyString = '';
|
||||||
|
},
|
||||||
updateSelection(selection) {
|
updateSelection(selection) {
|
||||||
if (selection.length === 0) {
|
if (!selection.length) {
|
||||||
this.domainObject = {};
|
this.clearData();
|
||||||
this.originalLocation = [];
|
return;
|
||||||
|
} else if (!selection[0].context.item && selection[1] && selection[1].context.item) {
|
||||||
|
this.setOriginalPath([selection[1].context.item], true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +76,7 @@ export default {
|
|||||||
|
|
||||||
let keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
let keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||||
|
|
||||||
if (this.keyString !== keyString) {
|
if (keyString && this.keyString !== keyString) {
|
||||||
this.keyString = keyString;
|
this.keyString = keyString;
|
||||||
this.originalPath = [];
|
this.originalPath = [];
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
v-if="opened">
|
v-if="opened">
|
||||||
<div class="c-super-menu__menu">
|
<div class="c-super-menu__menu">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(item, index) in items"
|
<li v-for="(item, index) in sortedItems"
|
||||||
:key="index"
|
:key="index"
|
||||||
:class="item.class"
|
:class="item.class"
|
||||||
:title="item.title"
|
:title="item.title"
|
||||||
@ -145,6 +145,19 @@
|
|||||||
selectedMenuItem: {},
|
selectedMenuItem: {},
|
||||||
opened: false
|
opened: false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
sortedItems () {
|
||||||
|
return this.items.sort((a,b) => {
|
||||||
|
if (a.name < b.name) {
|
||||||
|
return -1;
|
||||||
|
} else if (a.name > b.name) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -7,6 +7,13 @@
|
|||||||
@clear="searchTree">
|
@clear="searchTree">
|
||||||
</search>
|
</search>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- loading -->
|
||||||
|
<span v-if="isLoading"
|
||||||
|
class="loading">
|
||||||
|
</span>
|
||||||
|
<!-- end loading -->
|
||||||
|
|
||||||
<div class="c-tree-and-search__no-results" v-if="treeItems.length === 0">
|
<div class="c-tree-and-search__no-results" v-if="treeItems.length === 0">
|
||||||
No results found
|
No results found
|
||||||
</div>
|
</div>
|
||||||
@ -168,7 +175,8 @@
|
|||||||
return {
|
return {
|
||||||
searchValue: '',
|
searchValue: '',
|
||||||
allTreeItems: [],
|
allTreeItems: [],
|
||||||
filteredTreeItems: []
|
filteredTreeItems: [],
|
||||||
|
isLoading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -182,9 +190,13 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getAllChildren() {
|
getAllChildren() {
|
||||||
|
this.isLoading = true;
|
||||||
this.openmct.objects.get('ROOT')
|
this.openmct.objects.get('ROOT')
|
||||||
.then(root => this.openmct.composition.get(root).load())
|
.then(root => {
|
||||||
|
return this.openmct.composition.get(root).load()
|
||||||
|
})
|
||||||
.then(children => {
|
.then(children => {
|
||||||
|
this.isLoading = false;
|
||||||
this.allTreeItems = children.map(c => {
|
this.allTreeItems = children.map(c => {
|
||||||
return {
|
return {
|
||||||
id: this.openmct.objects.makeKeyString(c.identifier),
|
id: this.openmct.objects.makeKeyString(c.identifier),
|
||||||
|
@ -11,10 +11,17 @@
|
|||||||
</object-label>
|
</object-label>
|
||||||
</div>
|
</div>
|
||||||
<ul v-if="expanded" class="c-tree">
|
<ul v-if="expanded" class="c-tree">
|
||||||
|
|
||||||
|
<!-- loading -->
|
||||||
|
<span
|
||||||
|
class="loading"
|
||||||
|
v-if="isLoading && !loaded">
|
||||||
|
</span>
|
||||||
|
<!-- end loading -->
|
||||||
|
|
||||||
<tree-item v-for="child in children"
|
<tree-item v-for="child in children"
|
||||||
:key="child.id"
|
:key="child.id"
|
||||||
:node="child"
|
:node="child">
|
||||||
>
|
|
||||||
</tree-item>
|
</tree-item>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@ -50,7 +57,7 @@
|
|||||||
}
|
}
|
||||||
let parentKeyString = this.openmct.objects.makeKeyString(parent.identifier);
|
let parentKeyString = this.openmct.objects.makeKeyString(parent.identifier);
|
||||||
return parentKeyString !== this.node.object.location;
|
return parentKeyString !== this.node.object.location;
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// TODO: should update on mutation.
|
// TODO: should update on mutation.
|
||||||
@ -88,7 +95,8 @@
|
|||||||
this.composition = this.openmct.composition.get(this.domainObject);
|
this.composition = this.openmct.composition.get(this.domainObject);
|
||||||
this.composition.on('add', this.addChild);
|
this.composition.on('add', this.addChild);
|
||||||
this.composition.on('remove', this.removeChild);
|
this.composition.on('remove', this.removeChild);
|
||||||
this.composition.load().then(this.finishLoading());
|
this.composition.load().then(this.finishLoading);
|
||||||
|
this.isLoading = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -49,13 +49,16 @@ define([
|
|||||||
|
|
||||||
openmct.layout.$refs.browseBar.domainObject = navigatedObject;
|
openmct.layout.$refs.browseBar.domainObject = navigatedObject;
|
||||||
browseObject = navigatedObject;
|
browseObject = navigatedObject;
|
||||||
|
|
||||||
if (!navigatedObject) {
|
if (!navigatedObject) {
|
||||||
openmct.layout.$refs.browseObject.clear();
|
openmct.layout.$refs.browseObject.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let currentProvider = openmct
|
let currentProvider = openmct
|
||||||
.objectViews
|
.objectViews
|
||||||
.getByProviderKey(currentViewKey)
|
.getByProviderKey(currentViewKey);
|
||||||
|
|
||||||
|
document.title = browseObject.name; //change document title to current object in main view
|
||||||
|
|
||||||
if (currentProvider && currentProvider.canView(navigatedObject)) {
|
if (currentProvider && currentProvider.canView(navigatedObject)) {
|
||||||
viewObject(navigatedObject, currentProvider);
|
viewObject(navigatedObject, currentProvider);
|
||||||
|
Reference in New Issue
Block a user