Allow the default Search root to be overridden by a form variable. Adds RFE #11460.
This commit is contained in:
parent
35492ca11f
commit
8f951013b9
3 changed files with 80 additions and 1 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
- fixed #11453: fileUpload.pl does not handle files with spaces, overwriting
|
- fixed #11453: fileUpload.pl does not handle files with spaces, overwriting
|
||||||
- fixed #11458: Use packed template removes wanted whitespace
|
- fixed #11458: Use packed template removes wanted whitespace
|
||||||
- fixed #11459: "default template" warning after upgrade to 7.8.14
|
- fixed #11459: "default template" warning after upgrade to 7.8.14
|
||||||
|
- added #11460: Override the search root asset. (United Knowledge)
|
||||||
|
|
||||||
7.8.13
|
7.8.13
|
||||||
- fixed #11418: confusing typ-o in gotcha
|
- fixed #11418: confusing typ-o in gotcha
|
||||||
|
|
|
||||||
|
|
@ -181,13 +181,17 @@ sub view {
|
||||||
value=>$keywords
|
value=>$keywords
|
||||||
});
|
});
|
||||||
$var{'no_results' } = $i18n->get("no results");
|
$var{'no_results' } = $i18n->get("no results");
|
||||||
|
my $searchRoot = $self->getValue('searchRoot');
|
||||||
|
if (my $searchOverride = $form->get('searchroot', 'asset')) {
|
||||||
|
$searchRoot = $searchOverride;
|
||||||
|
}
|
||||||
|
|
||||||
if ($form->get("doit")) {
|
if ($form->get("doit")) {
|
||||||
my $search = WebGUI::Search->new($session);
|
my $search = WebGUI::Search->new($session);
|
||||||
my %rules = (
|
my %rules = (
|
||||||
keywords =>$keywords,
|
keywords =>$keywords,
|
||||||
lineage =>[
|
lineage =>[
|
||||||
WebGUI::Asset->newByDynamicClass($session,$self->getValue("searchRoot"))->get("lineage")
|
WebGUI::Asset->newByDynamicClass($session, $searchRoot)->get("lineage"),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
my @classes = split("\n",$self->get("classLimiter"));
|
my @classes = split("\n",$self->get("classLimiter"));
|
||||||
|
|
|
||||||
74
t/Asset/Wobject/Search/searchroot.t
Normal file
74
t/Asset/Wobject/Search/searchroot.t
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# Please read the legal notices (docs/legal.txt) and the license
|
||||||
|
# (docs/license.txt) that came with this distribution before using
|
||||||
|
# this software.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# http://www.plainblack.com info@plainblack.com
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
use FindBin;
|
||||||
|
use strict;
|
||||||
|
use JSON qw/from_json/;
|
||||||
|
use lib "$FindBin::Bin/../../../lib";
|
||||||
|
|
||||||
|
##The goal of this test is to test the creation of Search Wobjects.
|
||||||
|
|
||||||
|
use WebGUI::Test;
|
||||||
|
use WebGUI::Session;
|
||||||
|
use Test::More tests => 2; # increment this value for each test you create
|
||||||
|
use Test::Deep;
|
||||||
|
use WebGUI::Asset::Wobject::Search;
|
||||||
|
|
||||||
|
my $session = WebGUI::Test->session;
|
||||||
|
$session->user({userId => 3});
|
||||||
|
|
||||||
|
# Do our work in the import node
|
||||||
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
||||||
|
|
||||||
|
my $default = WebGUI::Asset->getDefault($session);
|
||||||
|
my $importArticle = $node->addChild({
|
||||||
|
className => 'WebGUI::Asset::Wobject::Article',
|
||||||
|
description => 'rockhound',
|
||||||
|
});
|
||||||
|
my $defaultArticle = $default->addChild({
|
||||||
|
className => 'WebGUI::Asset::Wobject::Article',
|
||||||
|
description => 'rockhound',
|
||||||
|
});
|
||||||
|
my $template = $node->addChild({
|
||||||
|
className => 'WebGUI::Asset::Template',
|
||||||
|
template => qq{[<tmpl_loop result_set>"<tmpl_var assetId>"<tmpl_unless __LAST__>,</tmpl_unless></tmpl_loop>]},
|
||||||
|
});
|
||||||
|
my $search = $default->addChild({
|
||||||
|
className => 'WebGUI::Asset::Wobject::Search',
|
||||||
|
searchRoot => $default->getId,
|
||||||
|
templateId => $template->getId,
|
||||||
|
});
|
||||||
|
my $tag2 = WebGUI::VersionTag->getWorking($session);
|
||||||
|
$tag2->commit;
|
||||||
|
|
||||||
|
$search->prepareView();
|
||||||
|
$session->request->setup_body({doit => 1, keywords => 'rockhound'});
|
||||||
|
my $json = $search->view();
|
||||||
|
my $assetIds = from_json($json);
|
||||||
|
cmp_deeply(
|
||||||
|
$assetIds,
|
||||||
|
[ $defaultArticle->getId ],
|
||||||
|
'search with no override returns asset from default asset'
|
||||||
|
);
|
||||||
|
|
||||||
|
$session->request->setup_body({doit => 1, keywords => 'rockhound', searchroot => $node->getId,});
|
||||||
|
$json = $search->view();
|
||||||
|
$assetIds = from_json($json);
|
||||||
|
cmp_deeply(
|
||||||
|
$assetIds,
|
||||||
|
[ $importArticle->getId ],
|
||||||
|
'search with override returns asset from import node'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$session->request->setup_body({});
|
||||||
|
$tag2->rollback;
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue