topStory template variables should be available in standAlone and not standAlone modes. Added template variables for delete and edit icons for the top story. Updated the tests, template and template variable help. Fixes bug #11851.

This commit is contained in:
Colin Kuskie 2010-09-09 11:56:50 -07:00
parent b63fe8e184
commit 5608a43916
6 changed files with 36 additions and 19 deletions

View file

@ -1,4 +1,5 @@
7.10.1
- fixed #11851: Story Topic: top story variables should be available all the time
7.10.0
- fixed #11812: Checking www_ajaxSave's response in the cart js, urlencoding post parameters

View file

@ -15,3 +15,15 @@ templates, you will need to apply these changes manually to your copies.
}
Gallery.DDSorting.url = '<tmpl_var url escape="js">';
* Story Topic Template
Since topStory template variables are available all the time, manually add the topStory into the list of
stories when the topic is no viewed standalone. Also note the new template variables for the the delete
and edit icons for the top story.
<ul>
<tmpl_unless standAlone>
<li><tmpl_var topStoryDeleteIcon><tmpl_var topStoryEditIcon> <a href="<tmpl_var topStoryUrl>"><tmpl_var topStoryTitle></a></li>
</tmpl_unless>
<tmpl_loop story_loop>

View file

@ -220,15 +220,17 @@ sub viewTemplateVariables {
push @{$var->{story_loop}}, $storyVars;
}
if ($self->{_standAlone} and @$storyIds) {
if (@{ $storyIds }) {
my $topStoryData = $storyIds->[0];
shift @{ $var->{story_loop} };
my $topStoryVars = shift @{ $var->{story_loop} };
##Note, this could have saved from the loop above, but this looks more clean and encapsulated to me.
my $topStory = WebGUI::Asset->new($session, $topStoryData->{assetId}, $topStoryData->{className}, $topStoryData->{revisionDate});
$var->{topStoryTitle} = $topStory->getTitle;
$var->{topStorySubtitle} = $topStory->get('subtitle');
$var->{topStoryUrl} = $session->url->append($self->getUrl, 'func=viewStory;assetId='.$topStoryData->{assetId}),
$var->{topStoryCreationDate} = $topStory->get('creationDate');
$var->{topStoryEditIcon} = $topStoryVars->{editIcon};
$var->{topStoryDeleteIcon} = $topStoryVars->{deleteIcon};
##TODO: Photo variables
my $photoData = $topStory->getPhotoData;
PHOTO: foreach my $photo (@{ $photoData }) {

View file

@ -29,6 +29,10 @@ our $HELP = {
{ name => 'editIcon' },
],
},
{ name => 'topStoryDeleteIcon',
description => 'deleteIcon', },
{ name => 'topStoryEditIcon'
description => 'editIcon', },
{ name => 'topStoryTitle' },
{ name => 'topStorySubtitle' },
{ name => 'topStoryUrl' },

View file

@ -107,11 +107,6 @@ cmp_deeply(
cmp_deeply(
$templateVars->{story_loop},
[
{
title => 'bogs',
url => $session->url->append($topic->getUrl, 'func=viewStory;assetId='.$storyHandler->{'bogs'}->getId),
creationDate => $now,
},
{
title => 'red',
url => $session->url->append($topic->getUrl, 'func=viewStory;assetId='.$storyHandler->{'red'}->getId),
@ -127,11 +122,11 @@ cmp_deeply(
);
ok(
! exists $templateVars->{topStoryTitle}
&& ! exists $templateVars->{topStoryUrl}
&& ! exists $templateVars->{topStoryCreationDate}
&& ! exists $templateVars->{topStorySubtitle},
'topStory variables not present unless in standalone mode'
exists $templateVars->{topStoryTitle}
&& exists $templateVars->{topStoryUrl}
&& exists $templateVars->{topStoryCreationDate}
&& exists $templateVars->{topStorySubtitle},
'topStory variables present in standalone mode'
);
ok(! $templateVars->{standAlone}, 'viewTemplateVars: not in standalone mode');
@ -230,8 +225,9 @@ $topic->update({
$topic->{_standAlone} = 0;
$templateVars = $topic->viewTemplateVariables;
$templateVars = $topic->viewTemplateVariables;
my @topicInmates = map { $_->{title} } @{ $templateVars->{story_loop} };
unshift @topicInmates, $templateVars->{topStoryTitle};
cmp_deeply(
\@topicInmates,
[@inmates, 'Yesterday is history'], #extra for pastStory
@ -246,11 +242,6 @@ $templateVars = $topic->viewTemplateVariables;
cmp_deeply(
$templateVars->{story_loop},
[
{
title => 'bogs',
url => $storyHandler->{'bogs'}->getUrl,
creationDate => $now,
},
{
title => 'red',
url => $storyHandler->{'red'}->getUrl,
@ -331,7 +322,14 @@ $topic->update( { storySortOrder => 'Alphabetically' } );
$templateVars = $topic->viewTemplateVariables();
cmp_deeply(
$templateVars->{story_loop},
[
{
title => $templateVars->{topStoryTitle},
url => $templateVars->{topStoryUrl},
creationDate => $templateVars->{topStoryCreationDate},
},
@{ $templateVars->{story_loop} },
],
[
{
title => "aaaay was history but isn't any more",