浏览代码

Merge branch '67-deactivate-label-menu-item-if-there-is-no-label-feature' into 'master'

Resolve "deactivate label menu item if there is no label feature"

Closes #67

See merge request troebs/pycs!62
Eric Tröbs 4 年之前
父节点
当前提交
db1e4c98ac
共有 1 个文件被更改,包括 14 次插入7 次删除
  1. 14 7
      webui/src/components/window/side-navigation-bar.vue

+ 14 - 7
webui/src/components/window/side-navigation-bar.vue

@@ -29,7 +29,7 @@
       </div>
       </div>
 
 
       <div class="item"
       <div class="item"
-           :class="{active: window.content === 'labels', inactive: !currentProject}"
+           :class="{active: window.content === 'labels', inactive: !currentProject || !labelsEnabled}"
            @click="ifProjectIsOpened(show, 'labels')">
            @click="ifProjectIsOpened(show, 'labels')">
         <img src="@/assets/icons/tag.svg">
         <img src="@/assets/icons/tag.svg">
         <span>Labels</span>
         <span>Labels</span>
@@ -70,29 +70,36 @@ export default {
   name: "side-navigation-bar",
   name: "side-navigation-bar",
   props: ['window', 'socket', 'status', 'currentProject'],
   props: ['window', 'socket', 'status', 'currentProject'],
   computed: {
   computed: {
-    collapsed: function() {
+    collapsed: function () {
       if (!this.status)
       if (!this.status)
         return false;
         return false;
 
 
       return this.status.settings.frontend.collapse;
       return this.status.settings.frontend.collapse;
     },
     },
-    mediaAvailable: function() {
+    mediaAvailable: function () {
       return this.currentProject && 'data' in this.currentProject && Object.keys(this.currentProject.data).length > 0;
       return this.currentProject && 'data' in this.currentProject && Object.keys(this.currentProject.data).length > 0;
+    },
+    labelsEnabled: function () {
+      return this.currentProject
+          && (
+              this.currentProject.model.supports.includes('labeled-images')
+              || this.currentProject.model.supports.includes('labeled-bounding-boxes')
+          );
     }
     }
   },
   },
   methods: {
   methods: {
-    closeSelf: function() {
+    closeSelf: function () {
       this.$emit('close', null);
       this.$emit('close', null);
     },
     },
-    ifProjectIsOpened: function(fun, ...args) {
+    ifProjectIsOpened: function (fun, ...args) {
       if (this.currentProject)
       if (this.currentProject)
         fun.bind(fun)(...args);
         fun.bind(fun)(...args);
     },
     },
-    show: function(value) {
+    show: function (value) {
       this.window.content = value;
       this.window.content = value;
       this.closeSelf();
       this.closeSelf();
     },
     },
-    collapse: function() {
+    collapse: function () {
       this.socket.post('/settings', {
       this.socket.post('/settings', {
         frontend: {
         frontend: {
           collapse: !this.collapsed
           collapse: !this.collapsed