Draw a fieldset around each Photo and its metadata.

Change the delete label so that it is clear that you are deleting the image and the metadata.
Redo the image upload form so that it is clear that uploading a new image to a photo with
an existing image replaces the existing with the new one.
This commit is contained in:
Colin Kuskie 2009-08-13 21:30:49 +00:00
parent d14d468415
commit e886474284
5 changed files with 55 additions and 54 deletions

View file

@ -426,9 +426,18 @@ sub getEditForm {
my $photoData = $self->getPhotoData;
my $numberOfPhotos = scalar @{ $photoData };
foreach my $photoIndex (1..$numberOfPhotos) {
my $photo = $photoData->[$photoIndex-1];
my $photo = $photoData->[$photoIndex-1];
my $storage = WebGUI::Storage->get($session, $photo->{storageId});
my $filename = $storage->getFiles->[0];
push @{ $var->{ photo_form_loop } }, {
imgUploadForm => $self->getPhotoUploadForm($photoIndex, $photo->{storageId}),
hasPhoto => $filename ? 1 : 0,
imgThumb => $filename ? $storage->getThumbnailUrl($filename) : '',
imgUrl => $filename ? $storage->getUrl($filename) : '',
imgFilename => $filename ? $filename : '',
newUploadForm => WebGUI::Form::file($session, {
name => 'newPhoto' . $photoIndex,
maxAttachments => 1,
}),
imgCaptionForm => WebGUI::Form::text($session, {
name => 'imgCaption'.$photoIndex,
value => $photo->{caption},
@ -456,7 +465,7 @@ sub getEditForm {
};
}
push @{ $var->{ photo_form_loop } }, {
imgUploadForm => WebGUI::Form::image($session, {
newUploadForm => WebGUI::Form::image($session, {
name => 'newPhoto',
maxAttachments => 1,
}),
@ -507,48 +516,6 @@ sub getPhotoData {
#-------------------------------------------------------------------
=head2 getPhotoUploadForm ( $index, $storageId )
Render a simple file form control that displays the current image if it is
uploaded.
=head3 $index
The index of a piece of Photo collateral. An upload form for that index
will be generated.
=head3 $storageId
The storage location for that piece of Photo collateral, to display an
existing image if it exists.
=cut
sub getPhotoUploadForm {
my $self = shift;
my $session = $self->session;
my $index = shift;
my $storageId = shift;
my $html = '';
my $storage = WebGUI::Storage->get($session, $storageId);
my $filename = $storage->getFiles->[0];
if ($filename) {
$html .= WebGUI::Form::readOnly($session, {
value => '<p style="display:inline;vertical-align:middle;"><a href="'.$storage->getUrl($filename).'"><img src="'.$storage->getThumbnailUrl($filename).'" alt="'.$filename.'" style="border-style:none;vertical-align:middle;" /> '.$filename.'</a></p>',
})
}
$html .= WebGUI::Form::file($session, {
name => 'newPhoto' . $index,
maxAttachments => 1,
});
return $html;
}
#-------------------------------------------------------------------
=head2 getRssData ( )
Returns RSS data for this Story. The date of the RSS item is the lastModified

View file

@ -32,13 +32,17 @@ our $HELP = {
{ name => 'cancelButton', },
{ name => 'photo_form_loop',
variables => [
{ name => 'imgUploadForm', },
{ name => 'hasPhoto', },
{ name => 'imgThumb', },
{ name => 'imgUrl', },
{ name => 'imgFilename', },
{ name => 'newUploadForm', },
{ name => 'imgCaptionForm', },
{ name => 'imgBylineForm', },
{ name => 'imgAltForm', },
{ name => 'imgTitleForm', },
{ name => 'imgUrlForm', },
{ name => 'imgDeleteForm', },
{ name => 'imgBylineForm', },
{ name => 'imgAltForm', },
{ name => 'imgTitleForm', },
{ name => 'imgUrlForm', },
{ name => 'imgDeleteForm', },
],
},
],

View file

@ -292,7 +292,7 @@ our $I18N = {
lastUpdated => 0,
},
'imgUploadForm' => {
'newUploadForm' => {
message => q|A form field to upload an image.|,
context => q|Template variable for edit form.|,
lastUpdated => 0,
@ -365,9 +365,9 @@ our $I18N = {
},
'photo delete' => {
message => q|Delete Photo|,
message => q|Delete Photo and Metadata|,
context => q|Label in the edit story form. Request that the photo be deleted, and all information with it.|,
lastUpdated => 0,
lastUpdated => 1250195747,
},
'photo_loop' => {
@ -418,6 +418,30 @@ our $I18N = {
lastUpdated => 0,
},
'hasPhoto' => {
message => q|This template variable will be true if the a photo in the photo_loop has an image in it.|,
context => q|Template variable|,
lastUpdated => 0,
},
'imgThumb' => {
message => q|The URL to the thumbnail of the image, if this photo has an image.|,
context => q|Template variable|,
lastUpdated => 0,
},
'imgUrl' => {
message => q|The URL to the image, if this photo has an image.|,
context => q|Template variable|,
lastUpdated => 0,
},
'imgFilename' => {
message => q|The URL to the image, if this photo has an image.|,
context => q|Template variable|,
lastUpdated => 0,
},
'singlePhoto' => {
message => q|This template variable will be true if the Story has just 1 photo uploaded to it.|,
context => q|Template variable|,
@ -441,6 +465,11 @@ our $I18N = {
lastUpdated => 0,
},
'Replace image with new image' => {
message => q|Replace image with new image|,
lastUpdated => 0,
},
};
1;