Provide for limiting the number of classOrder elements to a specific number. Skips...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 27 Sep 2010 15:23:10 +0000 (15:23 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 27 Sep 2010 15:23:10 +0000 (15:23 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18025 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/widget/FacetSidebar.js

index 9256ce4..25c2175 100644 (file)
@@ -66,6 +66,7 @@ if(!dojo._hasResource["openils.widget.FacetSidebar"]) {
             facetCacheKey : '',
             searchBox : '',
             classOrder : null, // Array of cmc.name values, OR array of objects with name and facetOrder properties
+            displayItemLimit : 999, // Number of distinctly described entries (classes or facets), that have values, to display from classOrder
             searchSubmit : '',
             facetLimit : 10,
             maxValuesPerFacet : 100,
@@ -116,6 +117,7 @@ if(!dojo._hasResource["openils.widget.FacetSidebar"]) {
                     );
                 }
 
+                var displayedItems = 0;
                 var me = this;
                 dojo.forEach(
                     classes,
@@ -126,7 +128,12 @@ if(!dojo._hasResource["openils.widget.FacetSidebar"]) {
                                 var maybe_facet = dojo.filter(
                                     openils.widget.Searcher._cache.arr.cmf,
                                     function (y) {
-                                        if (y.field_class == x.name && y.name == fname && facetData[y.id]) return 1;
+                                        if (y.field_class == x.name && y.name == fname && facetData[y.id]) {
+                                            if (displayedItems < me.displayItemLimit) {
+                                                displayedItems++;
+                                                return 1;
+                                            }
+                                        }
                                         return 0;
                                     }
                                 )[0];
@@ -136,7 +143,12 @@ if(!dojo._hasResource["openils.widget.FacetSidebar"]) {
                             possible_facets = dojo.filter(
                                 openils.widget.Searcher._cache.arr.cmf,
                                 function (y) {
-                                    if (y.field_class == x.name && facetData[y.id]) return 1;
+                                    if (y.field_class == x.name && facetData[y.id]) {
+                                        if (displayedItems < me.displayItemLimit) {
+                                            displayedItems++;
+                                            return 1;
+                                        }
+                                    }
                                     return 0;
                                 }
                             );