From d5e3e7c42e2984b143f0e52e1f30767a3ba0a87c Mon Sep 17 00:00:00 2001
From: Thuc Tran <thuc.tran@silabs.com>
Date: Wed, 7 Oct 2020 12:56:04 -0400
Subject: [PATCH] ZAPP-323 Hide attributes for sides that are not enabled

---
 src/components/ZclAttributeManager.vue        | 31 ++++++++++--
 .../ZclAttributeReportingManager.vue          | 49 ++++++++++++++-----
 2 files changed, 62 insertions(+), 18 deletions(-)

diff --git a/src/components/ZclAttributeManager.vue b/src/components/ZclAttributeManager.vue
index 3bcfe17a..d2949b14 100644
--- a/src/components/ZclAttributeManager.vue
+++ b/src/components/ZclAttributeManager.vue
@@ -20,10 +20,10 @@ limitations under the License.
   add action to edit button
 -->
 <template>
-  <div v-show="attributeData.length > 0">
+  <div v-show="relevantAttributeData.length > 0">
     <q-table
       class="my-sticky-header-table"
-      :data.sync="attributeData"
+      :data.sync="relevantAttributeData"
       :columns="columns"
       row-key="<b>name</b>"
       dense
@@ -435,9 +435,13 @@ export default {
   },
 
   computed: {
-    attributeData: {
+    relevantAttributeData: {
       get() {
-        return this.$store.state.zap.attributes
+        return this.$store.state.zap.attributes.filter((a) => {
+          let relevantList =
+            a.side === 'client' ? this.selectionClient : this.selectionServer
+          return relevantList.includes(this.selectedClusterId)
+        })
       },
     },
     selection: {
@@ -477,7 +481,7 @@ export default {
     },
     requiredAttributes: {
       get() {
-        return this.attributeData
+        return this.relevantAttributeData
           .filter(
             (attribute) =>
               !attribute.isOptional ||
@@ -496,6 +500,23 @@ export default {
         return this.$store.state.zap.clustersView.selected[0] || {}
       },
     },
+    selectedClusterId: {
+      get() {
+        return this.selectedCluster.id
+      },
+    },
+    selectionClient: {
+      get() {
+        return this.$store.state.zap.clustersView.selectedClients
+      },
+      set(val) {},
+    },
+    selectionServer: {
+      get() {
+        return this.$store.state.zap.clustersView.selectedServers
+      },
+      set(val) {},
+    },
     editableAttributes: {
       get() {
         return this.$store.state.zap.attributeView.editableAttributes
diff --git a/src/components/ZclAttributeReportingManager.vue b/src/components/ZclAttributeReportingManager.vue
index 0650afc4..30ef0c70 100644
--- a/src/components/ZclAttributeReportingManager.vue
+++ b/src/components/ZclAttributeReportingManager.vue
@@ -311,20 +311,26 @@ export default {
   computed: {
     attributeData: {
       get() {
-        return this.$store.state.zap.attributes.filter((attribute) => {
-          if (
-            this.$store.state.zap.attributeView.selectedAttributes.includes(
-              this.hashAttributeIdClusterId(
-                attribute.id,
-                this.selectedCluster.id
+        return this.$store.state.zap.attributes
+          .filter((attribute) => {
+            if (
+              this.$store.state.zap.attributeView.selectedAttributes.includes(
+                this.hashAttributeIdClusterId(
+                  attribute.id,
+                  this.selectedCluster.id
+                )
               )
-            )
-          ) {
-            return true
-          } else {
-            return false
-          }
-        })
+            ) {
+              return true
+            } else {
+              return false
+            }
+          })
+          .filter((a) => {
+            let relevantList =
+              a.side === 'client' ? this.selectionClient : this.selectionServer
+            return relevantList.includes(this.selectedClusterId)
+          })
       },
     },
     selectionDefault: {
@@ -367,6 +373,23 @@ export default {
         return this.$store.state.zap.clustersView.selected[0] || {}
       },
     },
+    selectedClusterId: {
+      get() {
+        return this.selectedCluster.id
+      },
+    },
+    selectionClient: {
+      get() {
+        return this.$store.state.zap.clustersView.selectedClients
+      },
+      set(val) {},
+    },
+    selectionServer: {
+      get() {
+        return this.$store.state.zap.clustersView.selectedServers
+      },
+      set(val) {},
+    },
     editableAttributes: {
       get() {
         return this.$store.state.zap.attributeView.editableAttributes
-- 
GitLab