diff --git a/src/plugins/notebook/components/Notebook.vue b/src/plugins/notebook/components/Notebook.vue index 7ce16e14fa..026706025a 100644 --- a/src/plugins/notebook/components/Notebook.vue +++ b/src/plugins/notebook/components/Notebook.vue @@ -97,7 +97,8 @@ :selected-page="getSelectedPage()" :selected-section="getSelectedSection()" :read-only="false" - @updateEntries="updateEntries" + @deleteEntry="deleteEntry" + @updateEntry="updateEntry" /> @@ -111,7 +112,7 @@ import Search from '@/ui/components/search.vue'; import SearchResults from './SearchResults.vue'; import Sidebar from './Sidebar.vue'; import { clearDefaultNotebook, getDefaultNotebook, setDefaultNotebook, setDefaultNotebookSection, setDefaultNotebookPage } from '../utils/notebook-storage'; -import { addNotebookEntry, createNewEmbed, getNotebookEntries, mutateObject } from '../utils/notebook-entries'; +import { addNotebookEntry, createNewEmbed, getEntryPosById, getNotebookEntries, mutateObject } from '../utils/notebook-entries'; import objectUtils from 'objectUtils'; import { throttle } from 'lodash'; @@ -244,6 +245,37 @@ export default { section }; }, + deleteEntry(entryId) { + const self = this; + const entryPos = getEntryPosById(entryId, this.internalDomainObject, this.selectedSection, this.selectedPage); + if (entryPos === -1) { + this.openmct.notifications.alert('Warning: unable to delete entry'); + console.error(`unable to delete entry ${entryId} from section ${this.selectedSection}, page ${this.selectedPage}`); + + return; + } + + const dialog = this.openmct.overlays.dialog({ + iconClass: 'alert', + message: 'This action will permanently delete this entry. Do you wish to continue?', + buttons: [ + { + label: "Ok", + emphasis: true, + callback: () => { + const entries = getNotebookEntries(self.internalDomainObject, self.selectedSection, self.selectedPage); + entries.splice(entryPos, 1); + self.updateEntries(entries); + dialog.dismiss(); + } + }, + { + label: "Cancel", + callback: () => dialog.dismiss() + } + ] + }); + }, dragOver(event) { event.preventDefault(); event.dataTransfer.dropEffect = "copy"; @@ -540,6 +572,13 @@ export default { setDefaultNotebookSection(section); }, + updateEntry(entry) { + const entries = getNotebookEntries(this.internalDomainObject, this.selectedSection, this.selectedPage); + const entryPos = getEntryPosById(entry.id, this.internalDomainObject, this.selectedSection, this.selectedPage); + entries[entryPos] = entry; + + this.updateEntries(entries); + }, updateEntries(entries) { const configuration = this.internalDomainObject.configuration; const notebookEntries = configuration.entries || {}; diff --git a/src/plugins/notebook/components/NotebookEntry.vue b/src/plugins/notebook/components/NotebookEntry.vue index 289ad6cc4a..445aa41b8e 100644 --- a/src/plugins/notebook/components/NotebookEntry.vue +++ b/src/plugins/notebook/components/NotebookEntry.vue @@ -12,11 +12,15 @@