[Toolbar] hide toolbar when in browse mode (#2278)

* Hide toolbar when not editing and the selected object has no toolbar.

* Remove unused code
This commit is contained in:
Pegah Sarram 2019-01-28 15:52:03 -08:00 committed by Deep Tailor
parent baa5d10009
commit 1dc1cc6c24
3 changed files with 25 additions and 13 deletions

View File

@ -588,20 +588,9 @@ export default {
}
},
mounted() {
let context = {
item: this.domainObject,
addContainer: this.addContainer,
deleteContainer: this.deleteContainer,
deleteFrame: this.deleteFrame,
type: 'flexible-layout'
}
this.unsubscribeSelection = this.openmct.selection.selectable(this.$el, context, true);
this.unobserve = this.openmct.objects.observe(this.domainObject, '*', this.updateDomainObject);
},
beforeDestroy() {
this.unsubscribeSelection();
this.unobserve();
}
}

View File

@ -52,9 +52,18 @@ define([
layoutObject: domainObject
},
el: element,
template: '<flexible-layout-component></flexible-layout-component>'
template: '<flexible-layout-component ref="flexibleLayout"></flexible-layout-component>'
});
},
getSelectionContext: function () {
return {
item: domainObject,
addContainer: component.$refs.flexibleLayout.addContainer,
deleteContainer: component.$refs.flexibleLayout.deleteContainer,
deleteFrame: component.$refs.flexibleLayout.deleteFrame,
type: 'flexible-layout'
};
},
destroy: function (element) {
component.$destroy();
component = undefined;

View File

@ -31,7 +31,7 @@
<browse-bar class="l-shell__main-view-browse-bar"
ref="browseBar">
</browse-bar>
<toolbar class="l-shell__toolbar"></toolbar>
<toolbar v-if="toolbar" class="l-shell__toolbar"></toolbar>
<object-view class="l-shell__main-container"
ref="browseObject">
</object-view>
@ -312,6 +312,20 @@
isEditing: false
}
},
computed: {
toolbar() {
let selection = this.openmct.selection.get();
let structure = undefined;
if (!selection[0]) {
structure = [];
} else {
structure = this.openmct.toolbars.get(selection);
}
return this.isEditing && structure.length > 0;
}
},
methods: {
fullScreenToggle() {