SVC15: Contribution: Alfresco Share Adv Search Enhancement: Allow advanced search on category to include sub-categories in query by checking a checkbox as in Alfresco Explorer (ALF-7157)

A new "showSubCategoriesOption" has been added to the "category.ftl" form control, that when set to true (as shown in the example config snippet below) will display a checkbox allowing the user to request all sub categories be searched as well as the selected ones.

   <field id="cm:categories">
      <control>
         <control-param name="compactMode">true</control-param>
         <control-param name="showSubCategoriesOption">true</control-param>
      </control>
   </field>

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29710 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2011-08-12 10:30:56 +00:00
parent 0b4ddc439e
commit b946119ac8

View File

@@ -697,6 +697,7 @@ function getSearchResults(params)
// extract form data and generate search query
var first = true;
var useSubCats = false;
for (var p in formJson)
{
// retrieve value and check there is someting to search for
@@ -745,6 +746,52 @@ function getSearchResults(params)
formQuery += (first ? '' : ' AND ') + escapeQName(propName) + ':"' + from + '".."' + to + '"';
}
}
else if (propName.indexOf("cm:categories") != -1)
{
// determines if the checkbox use sub categories was clicked
if (propName.indexOf("usesubcats") == -1)
{
if (formJson["prop_cm_categories_usesubcats"] == "true")
{
useSubCats = true;
}
}
else
{
// ignore the 'usesubcats' property
continue;
}
// build list of category terms to search for
var firstCat = true;
var catQuery = "";
var cats = propValue.split(',');
for (var i = 0; i < cats.length; i++)
{
var cat = cats[i];
var catNode = search.findNode(cat);
if (catNode)
{
catQuery += (firstCat ? '' : ' OR ') + "PATH:\"" + catNode.qnamePath + (useSubCats ? "//*\"" : "/member\"" );
firstCat = false;
}
else if (logger.isWarnLoggingEnabled())
{
logger.warn("Search : category noderef " + cat + " not found");
}
}
if (catQuery.length !== 0)
{
// surround category terms with brackets if appropriate
formQuery += (first ? '' : ' AND ') + "(" + catQuery + ")";
}
else
{
// ignore categories, continue loop so we don't set the 'first' flag
continue;
}
}
else
{
formQuery += (first ? '' : ' AND ') + escapeQName(propName) + ':"' + propValue + '"';
@@ -838,6 +885,9 @@ function getSearchResults(params)
});
}
if (logger.isWarnLoggingEnabled())
logger.warn("Search query: " + ftsQuery);
// perform fts-alfresco language query
var queryDef = {
query: ftsQuery,