From 65098c67cc106c21d903f1cbcf8b2f0fc1292c63 Mon Sep 17 00:00:00 2001
From: isaherbauts <isabelle.herbauts@univie.ac.at>
Date: Tue, 25 Feb 2020 14:45:45 +0100
Subject: [PATCH] sorting deselect

---
 .../PhExtServiceTreeview.vue                  | 30 +++++++++++++++++--
 src/utils/json-ld.js                          | 11 -------
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/src/components/input/pharma-input-fields/PhExtServiceTreeview.vue b/src/components/input/pharma-input-fields/PhExtServiceTreeview.vue
index c1dcba6..4fec854 100644
--- a/src/components/input/pharma-input-fields/PhExtServiceTreeview.vue
+++ b/src/components/input/pharma-input-fields/PhExtServiceTreeview.vue
@@ -14,6 +14,8 @@
         <v-flex xs6>
           <v-layout row wrap fill-height>
             <v-flex xs6>
+              <v-btn @click="alert($refs.treeview.items)">view</v-btn>
+              <v-btn @click="myget($refs.treeview.items)">find</v-btn>
               <v-btn @click="$refs.treeview.updateAll(true)">Open next level</v-btn>
               <v-btn @click="$refs.treeview.updateAll(false)">Close all</v-btn>
             </v-flex>
@@ -44,6 +46,7 @@
                       ></v-checkbox>
                     </div>
                   </template>
+
                   <template v-slot:prepend="{ item}">
                     <span v-if="!item.children"></span>
                   </template>
@@ -62,9 +65,9 @@
               :key="i"
               label
               close
-              @input="selectedItems=[]"
+              @input="selectedItems.splice(i,1);deselect(data, $refs.treeview)"
             >
-              <span>{{ data.text }}</span>
+              <span>{{ data.text }}{{data.selected}}</span>
             </v-chip>
           </v-card-text>
         </v-flex>
@@ -182,6 +185,15 @@ export default {
     }
   },
   methods: {
+    myget: function(tree) {
+      console.log("in myget", tree);
+      var lol = _.findIndex(tree, ["text", "Modeling"]);
+      console.log("in myget", lol);
+    },
+
+    alert: function(a) {
+      console.log("alert", a);
+    },
     select: function(item) {
       if (item.selected) {
         //push it to selected items but first check if it's there first
@@ -199,6 +211,20 @@ export default {
         }
       }
     },
+    deselect: function(item, tree) {
+      //push it to selected items but first check if it's there first
+      console.log("in deselect", item, tree.items);
+
+      if (this.selectedItems.indexOf(item) > -1) {
+        //item has been selected;
+        var index = this.selectedItems.indexOf(item);
+        console.log("in deselect2", this.selectedItems);
+        this.selectedItems.splice(index, 1);
+        console.log("in deselect3", this.selectedItems);
+      } else {
+        //console.log("item ", item);
+      }
+    },
     init: function(e) {
       //console.log("in console", e);
       e = [];
diff --git a/src/utils/json-ld.js b/src/utils/json-ld.js
index 9d885ef..fe3238b 100644
--- a/src/utils/json-ld.js
+++ b/src/utils/json-ld.js
@@ -1937,17 +1937,6 @@ export default {
                     delete f.value[k]["@hierarchicalAncestors"];
                   }
 
-                  /* if (f.value[k]["@type"]) {
-                    //this is to keep track of voc (which field)
-                    //console.log("type here", f.value[k]["@type"], f);
-                    if (f.component === "selection") {
-                      //console.log("selection");
-                    } else {
-                      //we do this only for the ones where component in not "selection",
-                      f.value[k]["@type"] = f.subjectType;
-                    }
-                  }*/
-                  //overwrite the "skos:Concept" of @type returned by the extnsion service to keep track of field structure
                   console.log("lala", f.value[k]["@type"], f.type);
                   f.value[k]["@type"] = f.type;
                   console.log("lala2", f.value[k]["@type"]);
-- 
GitLab