Fix a bug where the cached data structure was not deleted.
Add template variables for showing the uploaded photos. Add tests for the template variables. Add a form field to delete the photo with all data.
This commit is contained in:
parent
e5cdfdfae8
commit
c8da6cfe26
4 changed files with 158 additions and 2 deletions
|
|
@ -398,6 +398,10 @@ sub getEditForm {
|
|||
name => 'imgUrl'.$photoIndex,
|
||||
value => $photo->{url},
|
||||
}),
|
||||
imgDeleteForm => WebGUI::Form::yesNo($session, {
|
||||
name => 'deletePhoto'.$photoIndex,
|
||||
value => 0,
|
||||
}),
|
||||
};
|
||||
}
|
||||
push @{ $var->{ photo_form_loop } }, {
|
||||
|
|
@ -617,6 +621,7 @@ sub setPhotoData {
|
|||
my $photo = to_json($photoData);
|
||||
##Update the db.
|
||||
$self->update({photo => $photo});
|
||||
delete $self->{_photoData};
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -751,6 +756,22 @@ sub viewTemplateVariables {
|
|||
$var->{updatedTimeEpoch} = $self->get('revisionDate');
|
||||
|
||||
$var->{crumb_loop} = $self->getCrumbTrail();
|
||||
$var->{photo_loop} = [];
|
||||
PHOTO: foreach my $photo (@{ $self->getPhotoData}) {
|
||||
next PHOTO unless $photo->{storageId};
|
||||
my $storage = WebGUI::Storage->get($session, $photo->{storageId});
|
||||
my $file = $storage->getFiles->[0];
|
||||
next PHOTO unless $file;
|
||||
my $imageUrl = $storage->getUrl($file);
|
||||
push @{ $var->{photo_loop} }, {
|
||||
imageUrl => $imageUrl,
|
||||
imageCaption => $photo->{caption},
|
||||
imageByline => $photo->{byLine},
|
||||
imageAlt => $photo->{alt},
|
||||
imageTitle => $photo->{title},
|
||||
imageLink => $photo->{url},
|
||||
}
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue