StoryTopic 'Alphabetically' sort order
This commit is contained in:
parent
33592f9dbb
commit
e033192328
6 changed files with 110 additions and 9 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
- fixed #11742: linktag FilePump macro not xhtml valid
|
- fixed #11742: linktag FilePump macro not xhtml valid
|
||||||
- fixed #11744: Default DataForm list template does not contain pagination
|
- fixed #11744: Default DataForm list template does not contain pagination
|
||||||
- fixed #11683: URL with UTF8 (for äÄöÖüÜß)
|
- fixed #11683: URL with UTF8 (for äÄöÖüÜß)
|
||||||
|
- added option for sort order of Alphabetically on title to StoryArchive, StoryTopic and Keyword
|
||||||
|
|
||||||
7.9.9
|
7.9.9
|
||||||
- fixed #11693: Shopping cart does not show for visitor user
|
- fixed #11693: Shopping cart does not show for visitor user
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ my $session = start(); # this line required
|
||||||
# upgrade functions go here
|
# upgrade functions go here
|
||||||
addSpamStopWordsToConfig($session);
|
addSpamStopWordsToConfig($session);
|
||||||
alterStoryArchiveTable($session);
|
alterStoryArchiveTable($session);
|
||||||
|
alterStoryTopicTable($session);
|
||||||
|
|
||||||
finish($session); # this line required
|
finish($session); # this line required
|
||||||
|
|
||||||
|
|
@ -74,6 +75,24 @@ sub alterStoryArchiveTable {
|
||||||
print "DONE!\n" unless $quiet;
|
print "DONE!\n" unless $quiet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Describe what our function does
|
||||||
|
sub alterStoryTopicTable {
|
||||||
|
my $session = shift;
|
||||||
|
print "\tAdd story sort order column to the StoryTopic table... " unless $quiet;
|
||||||
|
|
||||||
|
my $sth = $session->db->read('DESCRIBE `StoryTopic`');
|
||||||
|
while (my ($col) = $sth->array) {
|
||||||
|
if ($col eq 'storySortOrder') {
|
||||||
|
print "Skipped.\n" unless $quiet;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$session->db->write("ALTER TABLE StoryTopic ADD COLUMN storySortOrder CHAR(22)");
|
||||||
|
$session->db->write("UPDATE StoryTopic SET storySortOrder = 'Chronologically' WHERE storySortOrder IS NULL");
|
||||||
|
print "DONE!\n" unless $quiet;
|
||||||
|
}
|
||||||
|
|
||||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ sub definition {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
my $definition = shift;
|
my $definition = shift;
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset_StoryTopic');
|
my $i18n = WebGUI::International->new($session, 'Asset_StoryTopic');
|
||||||
|
my $other_i18n = WebGUI::International->new($session, 'Asset_StoryArchive');
|
||||||
my %properties;
|
my %properties;
|
||||||
tie %properties, 'Tie::IxHash';
|
tie %properties, 'Tie::IxHash';
|
||||||
%properties = (
|
%properties = (
|
||||||
|
|
@ -72,6 +73,17 @@ sub definition {
|
||||||
namespace => 'Story',
|
namespace => 'Story',
|
||||||
defaultValue => 'TbDcVLbbznPi0I0rxQf2CQ',
|
defaultValue => 'TbDcVLbbznPi0I0rxQf2CQ',
|
||||||
},
|
},
|
||||||
|
storySortOrder => {
|
||||||
|
fieldType => "selectBox",
|
||||||
|
tab => 'display',
|
||||||
|
defaultValue => 'Chronologically',
|
||||||
|
options => {
|
||||||
|
Alphabetically => $other_i18n->get('alphabetically'),
|
||||||
|
Chronologically => $other_i18n->get('chronologically')
|
||||||
|
},
|
||||||
|
label => $other_i18n->get('sortAlphabeticallyChronologically'),
|
||||||
|
hoverHelp => $other_i18n->get('sortAlphabeticallyChronologically description'),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
push(@{$definition}, {
|
push(@{$definition}, {
|
||||||
assetName=>$i18n->get('assetName'),
|
assetName=>$i18n->get('assetName'),
|
||||||
|
|
@ -174,10 +186,11 @@ sub viewTemplateVariables {
|
||||||
my $wordList = WebGUI::Keyword::string2list($self->get('keywords'));
|
my $wordList = WebGUI::Keyword::string2list($self->get('keywords'));
|
||||||
my $key = WebGUI::Keyword->new($session);
|
my $key = WebGUI::Keyword->new($session);
|
||||||
my $p = $key->getMatchingAssets({
|
my $p = $key->getMatchingAssets({
|
||||||
keywords => $wordList,
|
sortOrder => $self->get('storySortOrder') || 'Chronologically',
|
||||||
isa => 'WebGUI::Asset::Story',
|
keywords => $wordList,
|
||||||
usePaginator => 1,
|
isa => 'WebGUI::Asset::Story',
|
||||||
rowsPerPage => $numberOfStories,
|
usePaginator => 1,
|
||||||
|
rowsPerPage => $numberOfStories,
|
||||||
});
|
});
|
||||||
my $storyIds = $p->getPageData();
|
my $storyIds = $p->getPageData();
|
||||||
$var->{story_loop} = [];
|
$var->{story_loop} = [];
|
||||||
|
|
|
||||||
|
|
@ -367,9 +367,18 @@ sub getMatchingAssets {
|
||||||
push @clauses, 'keyword in ('.join(',', @placeholders).')';
|
push @clauses, 'keyword in ('.join(',', @placeholders).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $sortOrder = $options->{sortOrder} || 'Chronologically';
|
||||||
|
|
||||||
|
my $orderBy = $sortOrder eq 'Alphabetically' ? ' order by upper(title), lineage' : ' order by creationDate desc, lineage';
|
||||||
|
|
||||||
# write the query
|
# write the query
|
||||||
my $query = 'select distinct assetKeyword.assetId from assetKeyword left join asset using (assetId)
|
my $query = q{
|
||||||
where '.join(' and ', @clauses).' order by creationDate desc, lineage';
|
select distinct assetKeyword.assetId
|
||||||
|
from assetKeyword
|
||||||
|
left join asset using (assetId)
|
||||||
|
left join assetData using (assetId)
|
||||||
|
where } .
|
||||||
|
join(' and ', @clauses) . $orderBy;
|
||||||
|
|
||||||
# perform the search
|
# perform the search
|
||||||
if ($options->{usePaginator}) {
|
if ($options->{usePaginator}) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
plan tests => 18;
|
plan tests => 19;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
|
@ -316,3 +316,44 @@ cmp_deeply(
|
||||||
],
|
],
|
||||||
'rssFeedItems'
|
'rssFeedItems'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# Sort Order
|
||||||
|
################################################################
|
||||||
|
|
||||||
|
$pastStory->update( { title => "aaaay was history but isn't any more" } );
|
||||||
|
$pastStory->requestAutoCommit;
|
||||||
|
|
||||||
|
$topic->update({ storiesPer => 4, storiesShort => 4, }); # storiesPer is used when _standAlone is true, storiesShort otherwise
|
||||||
|
$topic->{_standAlone} = 0;
|
||||||
|
$topic->update( { storySortOrder => 'Alphabetically' } );
|
||||||
|
|
||||||
|
$templateVars = $topic->viewTemplateVariables();
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$templateVars->{story_loop},
|
||||||
|
[
|
||||||
|
{
|
||||||
|
title => "aaaay was history but isn't any more",
|
||||||
|
url => ignore(),
|
||||||
|
creationDate => $yesterday,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title => 'andy',
|
||||||
|
url => ignore(),
|
||||||
|
creationDate => $now,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title => 'bogs',
|
||||||
|
url => ignore(),
|
||||||
|
creationDate => $now,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title => 'brooks',
|
||||||
|
url => ignore(),
|
||||||
|
creationDate => $now,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'viewTemplateVars has right number and contents in the story_loop in sort order Alphabetically mode'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
|
||||||
22
t/Keyword.t
22
t/Keyword.t
|
|
@ -17,7 +17,7 @@ use WebGUI::Keyword;
|
||||||
use WebGUI::Asset;
|
use WebGUI::Asset;
|
||||||
# load your modules here
|
# load your modules here
|
||||||
|
|
||||||
use Test::More tests => 15; # increment this value for each test you create
|
use Test::More tests => 16; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
|
@ -76,10 +76,28 @@ my $assetIds = $keyword->getMatchingAssets({ keyword => 'webgui', });
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$assetIds,
|
$assetIds,
|
||||||
[$snippet->getId, $home->getId, ],
|
[ $snippet->getId, $home->getId, ],
|
||||||
'getMatchingAssets, by keyword, assetIds in order by creationDate, descending'
|
'getMatchingAssets, by keyword, assetIds in order by creationDate, descending'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# sorted by title, alphabetically
|
||||||
|
|
||||||
|
my $aa_story = $home->addChild({ className => 'WebGUI::Asset::Story', title => "aaaa", keywords => 'webgui' });
|
||||||
|
WebGUI::Test->addToCleanup($aa_story);
|
||||||
|
|
||||||
|
$assetIds = $keyword->getMatchingAssets({ keyword => 'webgui', sortOrder => 'Alphabetically', });
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$assetIds,
|
||||||
|
[ $aa_story->getId, $home->getId, $snippet->getId, ], # 'aaa', 'Home', 'keyword snippet'
|
||||||
|
'getMatchingAssets, by keyword, assetIds in order by title'
|
||||||
|
);
|
||||||
|
|
||||||
|
$aa_story->trash();
|
||||||
|
$aa_story->purge();
|
||||||
|
|
||||||
|
# trashed assets
|
||||||
|
|
||||||
$snippet->trash();
|
$snippet->trash();
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue