mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
ALF-3613 ALF-3659 Share search screen refactor:
- added back site specific search, based on new design from Linton - sort field menu - sort for basic properties and TYPE now work (still need to fix up pseudo cm:content props) - optimizations to reduce number of remote calls a page makes to resolve Site Title from siteid git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20920 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<webscript>
|
<webscript>
|
||||||
<shortname>search</shortname>
|
<shortname>search</shortname>
|
||||||
<description>Site Search Component Data Webscript</description>
|
<description>Site Search Component Data Webscript</description>
|
||||||
<url>/slingshot/search?term={term?}&tag={tag?}&site={site?}&container={container?}</url>
|
<url>/slingshot/search?term={term?}&tag={tag?}&site={site?}&container={container?}&sort={sort?}</url>
|
||||||
<format default="json">argument</format>
|
<format default="json">argument</format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction allow="readonly">required</transaction>
|
<transaction allow="readonly">required</transaction>
|
||||||
|
@@ -5,9 +5,10 @@ function main()
|
|||||||
var containerId = (args.container !== undefined) ? args.container : null;
|
var containerId = (args.container !== undefined) ? args.container : null;
|
||||||
var term = (args.term !== undefined) ? args.term : null;
|
var term = (args.term !== undefined) ? args.term : null;
|
||||||
var tag = (args.tag !== undefined) ? args.tag : null;
|
var tag = (args.tag !== undefined) ? args.tag : null;
|
||||||
|
var sort = (args.sort !== undefined) ? args.sort : null;
|
||||||
var maxResults = (args.maxResults !== undefined) ? parseInt(args.maxResults, 10) : DEFAULT_MAX_RESULTS;
|
var maxResults = (args.maxResults !== undefined) ? parseInt(args.maxResults, 10) : DEFAULT_MAX_RESULTS;
|
||||||
|
|
||||||
model.data = getSearchResults(term, tag, maxResults, siteId, containerId);
|
model.data = getSearchResults(term, tag, maxResults, siteId, containerId, sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
@@ -500,7 +500,7 @@ function processResults(nodes, maxResults)
|
|||||||
* "or" is the default operator, AND and NOT are also supported - as is any other valid fts-alfresco
|
* "or" is the default operator, AND and NOT are also supported - as is any other valid fts-alfresco
|
||||||
* elements such as "quoted terms" and (bracket terms) and also propname:propvalue syntax.
|
* elements such as "quoted terms" and (bracket terms) and also propname:propvalue syntax.
|
||||||
*/
|
*/
|
||||||
function getSearchResults(term, tag, maxResults, siteId, containerId)
|
function getSearchResults(term, tag, maxResults, siteId, containerId, sort)
|
||||||
{
|
{
|
||||||
var nodes;
|
var nodes;
|
||||||
|
|
||||||
@@ -538,6 +538,45 @@ function getSearchResults(term, tag, maxResults, siteId, containerId)
|
|||||||
ftsQuery = "PATH:\"" + path + "/*\" AND (" + ftsQuery + ") ";
|
ftsQuery = "PATH:\"" + path + "/*\" AND (" + ftsQuery + ") ";
|
||||||
ftsQuery += "AND -TYPE:\"{http://www.alfresco.org/model/content/1.0}thumbnail\"";
|
ftsQuery += "AND -TYPE:\"{http://www.alfresco.org/model/content/1.0}thumbnail\"";
|
||||||
|
|
||||||
|
// sort field
|
||||||
|
/* sort
|
||||||
|
* {
|
||||||
|
* column: string, mandatory, sort column in appropriate format for the language
|
||||||
|
* ascending: boolean optional, defaults to false
|
||||||
|
* }*/
|
||||||
|
var sortColumns = [];
|
||||||
|
if (sort != null && sort.length != 0)
|
||||||
|
{
|
||||||
|
var asc = true;
|
||||||
|
var separator = sort.indexOf("|");
|
||||||
|
if (separator != -1)
|
||||||
|
{
|
||||||
|
sort = sort.substring(0, separator);
|
||||||
|
asc = (sort.substring(separator + 1) == "true");
|
||||||
|
}
|
||||||
|
var column;
|
||||||
|
if (sort.charAt(0) == '.')
|
||||||
|
{
|
||||||
|
// handle pseudo cm:content fields
|
||||||
|
column = "@{http://www.alfresco.org/model/content/1.0}content" + sort;
|
||||||
|
}
|
||||||
|
else if (sort.indexOf(":") != -1)
|
||||||
|
{
|
||||||
|
// handle attribute field sort
|
||||||
|
column = "@" + utils.longQName(sort);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// other sort types e.g. TYPE
|
||||||
|
column = sort;
|
||||||
|
}
|
||||||
|
sortColumns.push(
|
||||||
|
{
|
||||||
|
column: column,
|
||||||
|
ascending: asc
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// perform fts-alfresco language query
|
// perform fts-alfresco language query
|
||||||
var queryDef = {
|
var queryDef = {
|
||||||
query: ftsQuery,
|
query: ftsQuery,
|
||||||
@@ -545,7 +584,8 @@ function getSearchResults(term, tag, maxResults, siteId, containerId)
|
|||||||
page: {maxItems: maxResults},
|
page: {maxItems: maxResults},
|
||||||
templates: QUERY_TEMPLATES,
|
templates: QUERY_TEMPLATES,
|
||||||
defaultField: "keywords",
|
defaultField: "keywords",
|
||||||
onerror: "no-results"
|
onerror: "no-results",
|
||||||
|
sort: sortColumns
|
||||||
};
|
};
|
||||||
nodes = search.query(queryDef);
|
nodes = search.query(queryDef);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user