mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 13:48:12 +00:00
* [Notebook] Clicking new entry does not work as expected #3423 Co-authored-by: Joshi <simplyrender@gmail.com>
This commit is contained in:
@ -111,11 +111,9 @@ import Search from '@/ui/components/search.vue';
|
|||||||
import SearchResults from './SearchResults.vue';
|
import SearchResults from './SearchResults.vue';
|
||||||
import Sidebar from './Sidebar.vue';
|
import Sidebar from './Sidebar.vue';
|
||||||
import { clearDefaultNotebook, getDefaultNotebook, setDefaultNotebook, setDefaultNotebookSection, setDefaultNotebookPage } from '../utils/notebook-storage';
|
import { clearDefaultNotebook, getDefaultNotebook, setDefaultNotebook, setDefaultNotebookSection, setDefaultNotebookPage } from '../utils/notebook-storage';
|
||||||
import { addNotebookEntry, createNewEmbed, getNotebookEntries } from '../utils/notebook-entries';
|
import { DEFAULT_CLASS, addNotebookEntry, createNewEmbed, getNotebookEntries } from '../utils/notebook-entries';
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
|
|
||||||
const DEFAULT_CLASS = 'is-notebook-default';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct', 'domainObject', 'snapshotContainer'],
|
inject: ['openmct', 'domainObject', 'snapshotContainer'],
|
||||||
components: {
|
components: {
|
||||||
@ -197,15 +195,6 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addDefaultClass() {
|
|
||||||
const classList = this.internalDomainObject.classList || [];
|
|
||||||
if (classList.includes(DEFAULT_CLASS)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
classList.push(DEFAULT_CLASS);
|
|
||||||
this.mutateObject('classList', classList);
|
|
||||||
},
|
|
||||||
changeSelectedSection({ sectionId, pageId }) {
|
changeSelectedSection({ sectionId, pageId }) {
|
||||||
const sections = this.sections.map(s => {
|
const sections = this.sections.map(s => {
|
||||||
s.isSelected = false;
|
s.isSelected = false;
|
||||||
@ -442,11 +431,18 @@ export default {
|
|||||||
},
|
},
|
||||||
async updateDefaultNotebook(notebookStorage) {
|
async updateDefaultNotebook(notebookStorage) {
|
||||||
const defaultNotebookObject = await this.getDefaultNotebookObject();
|
const defaultNotebookObject = await this.getDefaultNotebookObject();
|
||||||
this.removeDefaultClass(defaultNotebookObject);
|
if (defaultNotebookObject.identifier.key !== notebookStorage.notebookMeta.identifier.key) {
|
||||||
setDefaultNotebook(this.openmct, notebookStorage);
|
this.removeDefaultClass(defaultNotebookObject);
|
||||||
this.addDefaultClass();
|
setDefaultNotebook(this.openmct, notebookStorage);
|
||||||
this.defaultSectionId = notebookStorage.section.id;
|
}
|
||||||
this.defaultPageId = notebookStorage.page.id;
|
|
||||||
|
if (this.defaultSectionId.length === 0 || this.defaultSectionId !== notebookStorage.section.id) {
|
||||||
|
this.defaultSectionId = notebookStorage.section.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.defaultPageId.length === 0 || this.defaultPageId !== notebookStorage.page.id) {
|
||||||
|
this.defaultPageId = notebookStorage.page.id;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updateDefaultNotebookPage(pages, id) {
|
updateDefaultNotebookPage(pages, id) {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import objectLink from '../../../ui/mixins/object-link';
|
import objectLink from '../../../ui/mixins/object-link';
|
||||||
|
|
||||||
|
export const DEFAULT_CLASS = 'is-notebook-default';
|
||||||
const TIME_BOUNDS = {
|
const TIME_BOUNDS = {
|
||||||
START_BOUND: 'tc.startBound',
|
START_BOUND: 'tc.startBound',
|
||||||
END_BOUND: 'tc.endBound',
|
END_BOUND: 'tc.endBound',
|
||||||
@ -128,6 +129,7 @@ export function addNotebookEntry(openmct, domainObject, notebookStorage, embed =
|
|||||||
embeds
|
embeds
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addDefaultClass(domainObject);
|
||||||
openmct.objects.mutate(domainObject, 'configuration.entries', entries);
|
openmct.objects.mutate(domainObject, 'configuration.entries', entries);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
@ -193,5 +195,15 @@ export function deleteNotebookEntries(openmct, domainObject, selectedSection, se
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete entries[selectedSection.id][selectedPage.id];
|
delete entries[selectedSection.id][selectedPage.id];
|
||||||
|
|
||||||
openmct.objects.mutate(domainObject, 'configuration.entries', entries);
|
openmct.objects.mutate(domainObject, 'configuration.entries', entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addDefaultClass(domainObject) {
|
||||||
|
const classList = domainObject.classList || [];
|
||||||
|
if (classList.includes(DEFAULT_CLASS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
classList.push(DEFAULT_CLASS);
|
||||||
|
}
|
||||||
|
@ -60,7 +60,6 @@ export function setDefaultNotebookSection(section) {
|
|||||||
|
|
||||||
notebookStorage.section = section;
|
notebookStorage.section = section;
|
||||||
saveDefaultNotebook(notebookStorage);
|
saveDefaultNotebook(notebookStorage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setDefaultNotebookPage(page) {
|
export function setDefaultNotebookPage(page) {
|
||||||
|
Reference in New Issue
Block a user