Эх сурвалжийг харах

[search] Add link of saved definitions in the URL

Enrico Berti 10 жил өмнө
parent
commit
6b1fd7f

+ 5 - 1
apps/search/src/search/static/search/js/search.ko.js

@@ -599,6 +599,9 @@ var Collection = function (vm, collection) {
 
     qdefinition.hasChanged = ko.observable(false);
     vm.selectedQDefinition(qdefinition);
+    if (window.location.hash.indexOf("collection") == -1){
+      window.location.hash = "q=" + qdef.uuid();
+    }
     vm.search();
     $(document).trigger("loadedQDefinition");
   }
@@ -633,7 +636,8 @@ var Collection = function (vm, collection) {
 
   self.getQDefinition = function (qDefID) {
     for (var i = 0; i < self.qdefinitions().length; i++) {
-      if (self.qdefinitions()[i].id() == qDefID) {
+      var qdef = ko.mapping.fromJSON(self.qdefinitions()[i].data());
+      if (qdef.uuid() == qDefID) {
         return self.qdefinitions()[i];
       }
     }