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

[search] Pagination should use numbers and not strings

Romain Rigaux 11 жил өмнө
parent
commit
0731f6b

+ 4 - 0
apps/search/src/search/models.py

@@ -284,12 +284,16 @@ class Collection(models.Model):
       props['collection']['name'] = self.name
     if self.label:
       props['collection']['label'] = self.label
+    if self.enabled is not None:
+      props['collection']['enabled'] = self.enabled
     # fields updated
     # idField
     
     # tmp for dev    
     if 'rows' not in props['collection']['template']:
       props['collection']['template']['rows'] = 10
+    if 'enabled' not in props['collection']:
+      props['collection']['enabled'] = True
       
     return json.dumps(props)
 

+ 2 - 2
apps/search/src/search/templates/search2.mako

@@ -531,7 +531,7 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
   <a href="javascript: void(0)" title="${ _('Previous') }">
     <span data-bind="text: name, click: $root.collection.toggleSortColumnGridLayout"></span>
     <i class="fa fa-arrow-left" data-bind="
-        visible: $data.response.start >= $root.collection.template.rows(),
+        visible: $data.response.start * 1.0 >= $root.collection.template.rows() * 1.0,
         click: function() { $root.query.paginate('prev') }">
     </i>
   </a>  
@@ -551,7 +551,7 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
   <a href="javascript: void(0)" title="${ _('Next') }">
     <span data-bind="text: name, click: $root.collection.toggleSortColumnGridLayout"></span>
     <i class="fa fa-arrow-right" data-bind="
-        visible: ($root.collection.template.rows() + $data.response.start) < $data.response.numFound,
+        visible: ($root.collection.template.rows() * 1.0 + $data.response.start * 1.0) < $data.response.numFound,
         click: function() { $root.query.paginate('next') }">
     </i>
   </a>  

+ 2 - 2
apps/search/static/js/search.ko.js

@@ -327,9 +327,9 @@ var Query = function (vm, query) {
   
   self.paginate = function (direction) {
 	if (direction == 'next') {
-	  self.start(self.start() + vm.collection.template.rows());
+	  self.start(self.start() + vm.collection.template.rows() * 1.0);
 	} else {
-	  self.start(self.start() - vm.collection.template.rows());
+	  self.start(self.start() - vm.collection.template.rows() * 1.0);
 	}
 	vm.search();
   };