From 07992f0b2adb362698ba9ffe64b43a91e3333896 Mon Sep 17 00:00:00 2001 From: johnriedel <65196434+johnriedel@users.noreply.github.com> Date: Wed, 22 Jul 2020 16:17:35 -0600 Subject: [PATCH] [Tabs View] add ability to remove tabs from tabs view interface (#3147) (#3148) * add ability to remove tabs from tabs view interface (#3147) * an "X" on each tab is visible in edit mode * replaced custom removeDialog with openmct.overlays.dialog * Minor mods to markup and CSS - Changed tab from button to div to allow a cleaner approach to the nested close button; - Changed close "icon-x" span to a button and added `c-click-icon` style tag; - Tweaked class naming to simplify and align with a more functional/ descriptive approach; * use ES6 arrow func to avoid self=this Co-authored-by: Deep Tailor Co-authored-by: charlesh88 --- src/plugins/tabs/components/tabs.scss | 13 +++++++ src/plugins/tabs/components/tabs.vue | 55 ++++++++++++++++++++------- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/plugins/tabs/components/tabs.scss b/src/plugins/tabs/components/tabs.scss index efc7b0ade9..c3ce0f38c3 100644 --- a/src/plugins/tabs/components/tabs.scss +++ b/src/plugins/tabs/components/tabs.scss @@ -17,6 +17,19 @@ margin-right: $interiorMarginSm; opacity: 0.7; } + + &__label { + flex: 1 1 auto; + } + + &__close-btn { + flex: 0 0 auto; + pointer-events: all; + } + + > * + * { + margin-left: $interiorMargin; + } } &__object-holder { diff --git a/src/plugins/tabs/components/tabs.vue b/src/plugins/tabs/components/tabs.vue index 294ba41470..0cfaa2c4b9 100644 --- a/src/plugins/tabs/components/tabs.vue +++ b/src/plugins/tabs/components/tabs.vue @@ -19,7 +19,7 @@ > Drag objects here to add them to this view. - + {{ tab.domainObject.name }} + +
import ObjectView from '../../../ui/components/ObjectView.vue'; +import RemoveAction from '../../remove/RemoveAction.js'; import { getSearchParam, setSearchParam, @@ -123,6 +117,7 @@ export default { this.unsubscribe = this.openmct.objects.observe(this.internalDomainObject, '*', this.updateInternalDomainObject); + this.RemoveAction = new RemoveAction(this.openmct); document.addEventListener('dragstart', this.dragstart); document.addEventListener('dragend', this.dragend); }, @@ -153,6 +148,38 @@ export default { this.currentTab = tab; }, + showRemoveDialog(index) { + if(!this.tabsList[index]) { + return; + } + + let activeTab = this.tabsList[index]; + let childDomainObject = activeTab.domainObject + + let prompt = this.openmct.overlays.dialog({ + iconClass: 'alert', + message: `This action will remove this tab from the Tabs Layout. Do you want to continue?`, + buttons: [ + { + label: 'Ok', + emphasis: 'true', + callback: () => { + this.removeFromComposition(childDomainObject); + prompt.dismiss(); + } + }, + { + label: 'Cancel', + callback: () => { + prompt.dismiss(); + } + } + ] + }); + }, + removeFromComposition(childDomainObject) { + this.composition.remove(childDomainObject); + }, addItem(domainObject) { let type = this.openmct.types.get(domainObject.type) || unknownObjectType, tabItem = {