diff --git a/package.json b/package.json index 011d9417b0..46440d9bad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openmct", - "version": "2.0.2-SNAPSHOT", + "version": "2.0.2", "description": "The Open MCT core platform", "devDependencies": { "@babel/eslint-parser": "7.16.3", diff --git a/src/plugins/notebook/components/Notebook.vue b/src/plugins/notebook/components/Notebook.vue index fb40ca38ab..f045832a9a 100644 --- a/src/plugins/notebook/components/Notebook.vue +++ b/src/plugins/notebook/components/Notebook.vue @@ -35,6 +35,8 @@ ref="searchResults" :domain-object="domainObject" :results="searchResults" + @cancelEdit="cancelTransaction" + @editingEntry="startTransaction" @changeSectionPage="changeSelectedSection" @updateEntries="updateEntries" /> @@ -140,6 +142,8 @@ :selected-page="selectedPage" :selected-section="selectedSection" :read-only="false" + @cancelEdit="cancelTransaction" + @editingEntry="startTransaction" @deleteEntry="deleteEntry" @updateEntry="updateEntry" /> @@ -710,6 +714,8 @@ export default { notebookEntries[this.selectedSection.id][this.selectedPage.id] = entries; mutateObject(this.openmct, this.domainObject, 'configuration.entries', notebookEntries); + + this.saveTransaction(); }, getPageIdFromUrl() { return this.openmct.router.getParams().pageId; @@ -746,6 +752,39 @@ export default { this.selectPage(pageId); this.syncUrlWithPageAndSection(); + }, + activeTransaction() { + return this.openmct.objects.getActiveTransaction(); + }, + startTransaction() { + if (!this.openmct.editor.isEditing()) { + this.openmct.objects.startTransaction(); + } + }, + saveTransaction() { + const transaction = this.activeTransaction(); + + if (!transaction || this.openmct.editor.isEditing()) { + return; + } + + return transaction.commit() + .catch(error => { + throw error; + }).finally(() => { + this.openmct.objects.endTransaction(); + }); + }, + cancelTransaction() { + if (!this.openmct.editor.isEditing()) { + const transaction = this.activeTransaction(); + transaction.cancel() + .catch(error => { + throw error; + }).finally(() => { + this.openmct.objects.endTransaction(); + }); + } } } }; diff --git a/src/plugins/notebook/components/NotebookEntry.vue b/src/plugins/notebook/components/NotebookEntry.vue index 112f80e5c1..9261063a02 100644 --- a/src/plugins/notebook/components/NotebookEntry.vue +++ b/src/plugins/notebook/components/NotebookEntry.vue @@ -55,6 +55,7 @@ class="c-ne__text c-ne__input" tabindex="0" contenteditable + @focus="editingEntry()" @blur="updateEntryValue($event)" @keydown.enter.exact.prevent @keyup.enter.exact.prevent="forceBlur($event)" @@ -284,11 +285,16 @@ export default { this.$emit('updateEntry', this.entry); }, + editingEntry() { + this.$emit('editingEntry'); + }, updateEntryValue($event) { const value = $event.target.innerText; if (value !== this.entry.text && value.match(/\S/)) { this.entry.text = value; this.$emit('updateEntry', this.entry); + } else { + this.$emit('cancelEdit'); } } } diff --git a/src/plugins/notebook/components/SearchResults.vue b/src/plugins/notebook/components/SearchResults.vue index e3f4909810..e44b8ce914 100644 --- a/src/plugins/notebook/components/SearchResults.vue +++ b/src/plugins/notebook/components/SearchResults.vue @@ -33,6 +33,8 @@ :read-only="true" :selected-page="result.page" :selected-section="result.section" + @editingEntry="editingEntry" + @cancelEdit="cancelEdit" @changeSectionPage="changeSectionPage" @updateEntries="updateEntries" /> @@ -63,6 +65,12 @@ export default { } }, methods: { + editingEntry() { + this.$emit('editingEntry'); + }, + cancelEdit() { + this.$emit('cancelEdit'); + }, changeSectionPage(data) { this.$emit('changeSectionPage', data); }, diff --git a/src/plugins/viewLargeAction/viewLargeAction.js b/src/plugins/viewLargeAction/viewLargeAction.js index e951a4ad54..9d5891fff1 100644 --- a/src/plugins/viewLargeAction/viewLargeAction.js +++ b/src/plugins/viewLargeAction/viewLargeAction.js @@ -38,41 +38,41 @@ export default class ViewLargeAction { } invoke(objectPath, view) { - const parentElement = view.parentElement; - let childElement = parentElement && parentElement.firstChild; + performance.mark('viewlarge.start'); + const childElement = view?.parentElement?.firstChild; if (!childElement) { const message = "ViewLargeAction: missing element"; this.openmct.notifications.error(message); throw new Error(message); } - this._expand(objectPath, childElement); + this._expand(objectPath, view); } - appliesTo(objectPath, view = {}) { - const parentElement = view.parentElement; - const element = parentElement && parentElement.firstChild; - const viewLargeAction = element && !element.classList.contains('js-main-container') + appliesTo(objectPath, view) { + const childElement = view?.parentElement?.firstChild; + + return childElement && !childElement.classList.contains('js-main-container') && !this.openmct.router.isNavigatedObject(objectPath); - - return viewLargeAction; } - _expand(objectPath, childElement) { - const parentElement = childElement.parentElement; + _expand(objectPath, view) { + const element = this._getPreview(objectPath, view); this.overlay = this.openmct.overlays.overlay({ - element: this._getPreview(objectPath), + element, size: 'large', autoHide: false, - onDestroy() { - parentElement.append(childElement); + onDestroy: () => { + this.preview.$destroy(); + this.preview = undefined; + delete this.preview; } }); } - _getPreview(objectPath) { - const preview = new Vue({ + _getPreview(objectPath, view) { + this.preview = new Vue({ components: { Preview }, @@ -80,9 +80,14 @@ export default class ViewLargeAction { openmct: this.openmct, objectPath }, - template: '' + data() { + return { + view + }; + }, + template: '' }); - return preview.$mount().$el; + return this.preview.$mount().$el; } } diff --git a/src/ui/preview/Preview.vue b/src/ui/preview/Preview.vue index 7167a1faaa..5fd90b1a14 100644 --- a/src/ui/preview/Preview.vue +++ b/src/ui/preview/Preview.vue @@ -22,10 +22,10 @@