[open-ils-commits] r18008 - branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Sep 26 11:33:08 EDT 2010
Author: miker
Date: 2010-09-26 11:33:05 -0400 (Sun, 26 Sep 2010)
New Revision: 18008
Modified:
branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/FacetSidebar.js
Log:
Backport r18007 from trunk: allow more complex facet ordering
Modified: branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/FacetSidebar.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/FacetSidebar.js 2010-09-26 15:31:41 UTC (rev 18007)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/FacetSidebar.js 2010-09-26 15:33:05 UTC (rev 18008)
@@ -14,6 +14,40 @@
* ---------------------------------------------------------------------------
*/
+/* Example markup:
+
+<div id='facetSidebarContainer' class='hide_me'>
+
+ <div class="side_bar_item" style="margin-top: 10px; font-weight: bold;">
+ <span>&navigate.facetRefine;</span>
+ </div>
+
+ <div
+ dojoType='openils.widget.FacetSidebar'
+ searchBox='facet_box'
+ searchSubmit='search_submit'
+ facetLimit='5'
+ maxValuesPerFacet='10'
+ classOrder='[{"name":"author","facetOrder":["personal","corporate"]},{"name":"subject","facetOrder":["topic"]},"series",{"name":"subject","facetOrder":["name","geographic"]}]'
+ >
+ <script type='dojo/method' event='populate'><![CDATA[
+ var f_sidebar = this;
+ attachEvt("result", "allRecordsReceived", function () {
+ if(!resultFacetKey) return;
+ if (f_sidebar.facetCacheKey) return; // already rendered it
+
+ dojo.removeClass('facetSidebarContainer','hide_me');
+
+ f_sidebar.facetCacheKey = resultFacetKey;
+ f_sidebar.render();
+ });
+ ]]></script>
+ </div>
+</div>
+
+ */
+
+
if(!dojo._hasResource["openils.widget.FacetSidebar"]) {
dojo._hasResource["openils.widget.FacetSidebar"] = true;
@@ -31,7 +65,7 @@
facetData : {},
facetCacheKey : '',
searchBox : '',
- classOrder : null,
+ classOrder : null, // Array of cmc.name values, OR array of objects with name and facetOrder properties
searchSubmit : '',
facetLimit : 10,
maxValuesPerFacet : 100,
@@ -75,7 +109,10 @@
classes = [];
dojo.forEach(
this.classOrder,
- function(x) { classes.push({name:x}); }
+ function(x) {
+ if (dojo.isObject(x)) classes.push(x);
+ else classes.push({name:x});
+ }
);
}
@@ -83,13 +120,26 @@
dojo.forEach(
classes,
function (x) {
- var possible_facets = dojo.filter(
- openils.widget.Searcher._cache.arr.cmf,
- function (y) {
- if (y.field_class == x.name && facetData[y.id]) return 1;
- return 0;
- }
- );
+ var possible_facets = [];
+ if (x.facetOrder) {
+ dojo.forEach(x.facetOrder, function(fname) {
+ possible_facets.push(dojo.filter(
+ openils.widget.Searcher._cache.arr.cmf,
+ function (y) {
+ if (y.field_class == x.name && y.name == fname) return 1;
+ return 0;
+ }
+ )[0]);
+ });
+ } else {
+ possible_facets = dojo.filter(
+ openils.widget.Searcher._cache.arr.cmf,
+ function (y) {
+ if (y.field_class == x.name && facetData[y.id]) return 1;
+ return 0;
+ }
+ );
+ }
if (possible_facets.length > 0) me.addClass( x.name, possible_facets );
}
);
More information about the open-ils-commits
mailing list