Merge branch 'master' of https://github.com/nasa/openmct into fix-telemetryview-styles

This commit is contained in:
Joshi 2020-04-01 15:52:55 -07:00
commit d3fe2a6811
2 changed files with 44 additions and 29 deletions

View File

@ -80,10 +80,10 @@
</span> </span>
</div> </div>
<div v-if="selectedSection && selectedPage" <div v-if="selectedSection && selectedPage"
ref="notebookEntries"
class="c-notebook__entries" class="c-notebook__entries"
> >
<NotebookEntry v-for="entry in filteredAndSortedEntries" <NotebookEntry v-for="entry in filteredAndSortedEntries"
ref="notebookEntry"
:key="entry.id" :key="entry.id"
:entry="entry" :entry="entry"
:domain-object="internalDomainObject" :domain-object="internalDomainObject"
@ -122,6 +122,7 @@ export default {
defaultPageId: getDefaultNotebook() ? getDefaultNotebook().page.id : '', defaultPageId: getDefaultNotebook() ? getDefaultNotebook().page.id : '',
defaultSectionId: getDefaultNotebook() ? getDefaultNotebook().section.id : '', defaultSectionId: getDefaultNotebook() ? getDefaultNotebook().section.id : '',
defaultSort: this.domainObject.configuration.defaultSort, defaultSort: this.domainObject.configuration.defaultSort,
focusEntryId: null,
internalDomainObject: this.domainObject, internalDomainObject: this.domainObject,
search: '', search: '',
showTime: 0, showTime: 0,
@ -174,6 +175,11 @@ export default {
this.unlisten(); this.unlisten();
} }
}, },
updated: function () {
this.$nextTick(function () {
this.focusOnEntryId();
})
},
methods: { methods: {
addDefaultClass() { addDefaultClass() {
const classList = this.internalDomainObject.classList || []; const classList = this.internalDomainObject.classList || [];
@ -210,6 +216,20 @@ export default {
this.updateSection({ sections }); this.updateSection({ sections });
this.throttledSearchItem(''); this.throttledSearchItem('');
}, },
createNotebookStorageObject() {
const notebookMeta = {
name: this.internalDomainObject.name,
identifier: this.internalDomainObject.identifier
};
const page = this.getSelectedPage();
const section = this.getSelectedSection();
return {
notebookMeta,
section,
page
}
},
dragOver(event) { dragOver(event) {
event.preventDefault(); event.preventDefault();
event.dataTransfer.dropEffect = "copy"; event.dataTransfer.dropEffect = "copy";
@ -245,6 +265,20 @@ export default {
const embed = createNewEmbed(snapshotMeta); const embed = createNewEmbed(snapshotMeta);
this.newEntry(embed); this.newEntry(embed);
}, },
focusOnEntryId() {
if (!this.focusEntryId) {
return;
}
const element = this.$refs.notebookEntries.querySelector(`#${this.focusEntryId}`);
if (!element) {
return;
}
element.focus();
this.focusEntryId = null;
},
formatSidebar() { formatSidebar() {
/* /*
Determine if the sidebar should slide over content, or compress it Determine if the sidebar should slide over content, or compress it
@ -359,20 +393,12 @@ export default {
this.updateSection({ sections }); this.updateSection({ sections });
}, },
newEntry(embed = null) { newEntry(embed = null) {
const selectedSection = this.getSelectedSection();
const selectedPage = this.getSelectedPage();
this.search = ''; this.search = '';
const notebookStorage = this.createNotebookStorageObject();
this.updateDefaultNotebook(selectedSection, selectedPage); this.updateDefaultNotebook(notebookStorage);
const notebookStorage = getDefaultNotebook();
const id = addNotebookEntry(this.openmct, this.internalDomainObject, notebookStorage, embed); const id = addNotebookEntry(this.openmct, this.internalDomainObject, notebookStorage, embed);
this.focusEntryId = id;
this.$nextTick(() => { this.search = '';
const element = this.$el.querySelector(`#${id}`);
element.focus();
});
return id;
}, },
orientationChange() { orientationChange() {
this.formatSidebar(); this.formatSidebar();
@ -402,13 +428,13 @@ export default {
toggleNav() { toggleNav() {
this.showNav = !this.showNav; this.showNav = !this.showNav;
}, },
async updateDefaultNotebook(selectedSection, selectedPage) { async updateDefaultNotebook(notebookStorage) {
const defaultNotebookObject = await this.getDefaultNotebookObject(); const defaultNotebookObject = await this.getDefaultNotebookObject();
this.removeDefaultClass(defaultNotebookObject); this.removeDefaultClass(defaultNotebookObject);
setDefaultNotebook(this.internalDomainObject, selectedSection, selectedPage); setDefaultNotebook(notebookStorage);
this.addDefaultClass(); this.addDefaultClass();
this.defaultSectionId = selectedSection.id; this.defaultSectionId = notebookStorage.section.id;
this.defaultPageId = selectedPage.id; this.defaultPageId = notebookStorage.page.id;
}, },
updateDefaultNotebookPage(pages, id) { updateDefaultNotebookPage(pages, id) {
if (!id) { if (!id) {

View File

@ -10,18 +10,7 @@ export function getDefaultNotebook() {
return JSON.parse(notebookStorage); return JSON.parse(notebookStorage);
} }
export function setDefaultNotebook(domainObject, section, page) { export function setDefaultNotebook(notebookStorage) {
const notebookMeta = {
name: domainObject.name,
identifier: domainObject.identifier
};
const notebookStorage = {
notebookMeta,
section,
page
}
window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, JSON.stringify(notebookStorage)); window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, JSON.stringify(notebookStorage));
} }