andreabadesso / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

Add setting that makes Listfacet combine its selection as AND instead of OR. #406

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
There are several requests on the mailing list for a list facet that returns 
those items that have all of the chosen options in the list facet instead of 
any one of the chosen options as is the case with the present implementation 
(trunk revision 2140). I tried to implement this and the result is in the 
attached file "andListfacet.js".

If this file is loaded after the exhibit code is loaded, it adds an extra 
setting with the name "combineMode" to listfacets. The default of this setting 
is "or" which keeps the current behavior. If combineMode is set to "and" the 
facet is to behave in the requested manner. So code within your exhibit html 
file typically looks like:
<div ex:role="facet" ex:expression=".property" ex:combineMode="and"></div>

Please give this code a try, and report positive and negative results here on 
the issue tracker, because it has not seen much testing.

Original issue reported on code.google.com by m.d.na...@hetnet.nl on 24 Oct 2010 at 9:56

Attachments:

GoogleCodeExporter commented 9 years ago
hi Michiel,  this is a great addition - i've needed this for a long time.  i 
just tried it, and it seems to work just fine.
thank you!

Original comment by kumar.ch...@gmail.com on 25 Oct 2010 at 10:05

GoogleCodeExporter commented 9 years ago
Hey Michiel,

I tried out your patch and it works well. The only problem I see is that the 
counts and available items within a single list-facet are not updated to 
reflect the fact that the facet intersects versus unions. For my use-case, it's 
useful to see the number of items that would result by selecting an additional 
restriction in the list facet. 

The counts are updated when the Exhibit.ListFacet.update is called. It's called 
with the set of items that are available to the facet -- if this list-facet is 
the only one with restrictions, it updates it with the all the available items. 
If it is not the only one, then it is updated with the intersection of all 
available items from the other facets. The logic for all this is in 
Exhibit.Collection._updateFacets.

To fix the counts for the intersect case, on a ListFacet.update(), I just 
called restrict() on the set of items given before calculating the counts if 
the list-facet is in intersection mode. This makes the counts limited only to 
values arising from items in the intersection of the currently chosen 
restrictions.

The attached patch to andListfacet.js accomplishes this. It's a straight copy 
of Exhibit.ListFacet.prototype._computeFacet from SVN r2153, except lines 3-7 
of the method are the restrict() call I describe above. It works well for me.

Thanks,
RJ Ryan

Original comment by russelljryan on 22 Dec 2010 at 10:36

Attachments:

GoogleCodeExporter commented 9 years ago
Just a note to say I find this change (Michiel with Russell's additions) really 
helpful for my particular project (a database of thousands of academic journal 
articles, with various keywords acting as the facets.)  Thanks to you both for 
your contributions.

Original comment by pleon...@gmail.com on 5 Feb 2011 at 8:21

GoogleCodeExporter commented 9 years ago

Original comment by ryan...@csail.mit.edu on 23 Jun 2011 at 9:47