Rearrange form fields in default edit story template.
Change photo JSON blob to be an array ref, not a hash ref. Code for saving new photo data.
This commit is contained in:
parent
420a70531b
commit
3d5f5b04c1
4 changed files with 46 additions and 18 deletions
Binary file not shown.
|
|
@ -145,7 +145,7 @@ sub definition {
|
||||||
},
|
},
|
||||||
photo => {
|
photo => {
|
||||||
fieldType => 'text',
|
fieldType => 'text',
|
||||||
defaultValue => '{}',
|
defaultValue => '[]',
|
||||||
},
|
},
|
||||||
storageId => {
|
storageId => {
|
||||||
fieldType => 'hidden',
|
fieldType => 'hidden',
|
||||||
|
|
@ -249,7 +249,6 @@ sub getAutoCommitWorkflowId {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $archive = $self->getArchive;
|
my $archive = $self->getArchive;
|
||||||
if ($archive->hasBeenCommitted) {
|
if ($archive->hasBeenCommitted) {
|
||||||
$self->session->log->warn($archive->get('approvalWorkflowId'));
|
|
||||||
return $archive->get('approvalWorkflowId')
|
return $archive->get('approvalWorkflowId')
|
||||||
|| $self->session->setting->get('defaultVersionTagWorkflow');
|
|| $self->session->setting->get('defaultVersionTagWorkflow');
|
||||||
}
|
}
|
||||||
|
|
@ -490,6 +489,7 @@ sub processPropertiesFromFormPost {
|
||||||
if ($newStorage) {
|
if ($newStorage) {
|
||||||
push @{ $photoData }, {
|
push @{ $photoData }, {
|
||||||
caption => $form->process('newImgCaption', 'text'),
|
caption => $form->process('newImgCaption', 'text'),
|
||||||
|
alt => $form->process('newImgAlt', 'text'),
|
||||||
title => $form->process('newImgTitle', 'text'),
|
title => $form->process('newImgTitle', 'text'),
|
||||||
byLine => $form->process('newImgByline', 'text'),
|
byLine => $form->process('newImgByline', 'text'),
|
||||||
url => $form->process('newImgUrl', 'url'),
|
url => $form->process('newImgUrl', 'url'),
|
||||||
|
|
@ -538,9 +538,7 @@ sub purgeRevision {
|
||||||
|
|
||||||
=head2 setPhotoData ( $perlStructure )
|
=head2 setPhotoData ( $perlStructure )
|
||||||
|
|
||||||
Returns the storage location for this Story. If it does not exist,
|
Sets the photo data from the JSON stored in the object.
|
||||||
then it creates it via setStorageLocation. Subsequent lookups return
|
|
||||||
an internally cached Storage object to save time.
|
|
||||||
|
|
||||||
=head3 $perlStructure
|
=head3 $perlStructure
|
||||||
|
|
||||||
|
|
@ -577,7 +575,7 @@ want in there so there's no valid content checking.
|
||||||
|
|
||||||
sub setPhotoData {
|
sub setPhotoData {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $photoData = shift || {};
|
my $photoData = shift || [];
|
||||||
my $photo = to_json($photoData);
|
my $photo = to_json($photoData);
|
||||||
$self->update({photo => $photo});
|
$self->update({photo => $photo});
|
||||||
delete $self->{_photoData};
|
delete $self->{_photoData};
|
||||||
|
|
|
||||||
|
|
@ -344,6 +344,36 @@ our $I18N = {
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'photo caption' => {
|
||||||
|
message => q|Photo Caption|,
|
||||||
|
context => q|Label in the edit story form. Short for Photograph Caption.|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
'photo byline' => {
|
||||||
|
message => q|Photo By Line|,
|
||||||
|
context => q|Label in the edit story form. The person who took, or owns this photo.|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
'photo alt' => {
|
||||||
|
message => q|Photo Alternate Text|,
|
||||||
|
context => q|Label in the edit story form. Text for the ALT attribute of an IMG tag.|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
'photo title' => {
|
||||||
|
message => q|Photo Alternate Title|,
|
||||||
|
context => q|Label in the edit story form. Text for the TITLE attribute of an IMG tag.|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
'photo url' => {
|
||||||
|
message => q|Photo URL|,
|
||||||
|
context => q|Label in the edit story form. A link from the photo to more information about it, or referring to it.|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ $story = $archive->addChild({
|
||||||
|
|
||||||
isa_ok($story, 'WebGUI::Asset::Story', 'Created a Story asset');
|
isa_ok($story, 'WebGUI::Asset::Story', 'Created a Story asset');
|
||||||
is($story->get('storageId'), '', 'by default, there is no storageId');
|
is($story->get('storageId'), '', 'by default, there is no storageId');
|
||||||
is($story->get('photo'), '{}', 'by default, photos is an empty JSON hash');
|
is($story->get('photo'), '[]', 'by default, photos is an empty JSON array');
|
||||||
is($story->get('isHidden'), 1, 'by default, stories are hidden');
|
is($story->get('isHidden'), 1, 'by default, stories are hidden');
|
||||||
$story->update({isHidden => 0});
|
$story->update({isHidden => 0});
|
||||||
is($story->get('isHidden'), 1, 'stories cannot be set to not be hidden');
|
is($story->get('isHidden'), 1, 'stories cannot be set to not be hidden');
|
||||||
|
|
@ -111,36 +111,36 @@ is($story->getArchive->getId, $archive->getId, 'getArchive gets the parent archi
|
||||||
|
|
||||||
my $photoData = $story->getPhotoData();
|
my $photoData = $story->getPhotoData();
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$photoData, {},
|
$photoData, [],
|
||||||
'getPhotoData: returns an empty hash with no JSON data'
|
'getPhotoData: returns an empty array ref with no JSON data'
|
||||||
);
|
);
|
||||||
|
|
||||||
$story->setPhotoData({
|
$story->setPhotoData([
|
||||||
filename1 => {
|
{
|
||||||
byLine => 'Andrew Dufresne',
|
byLine => 'Andrew Dufresne',
|
||||||
caption => 'Shawshank Prison',
|
caption => 'Shawshank Prison',
|
||||||
},
|
},
|
||||||
});
|
]);
|
||||||
|
|
||||||
is($story->get('photo'), q|{"filename1":{"caption":"Shawshank Prison","byLine":"Andrew Dufresne"}}|, 'setPhotoData: set JSON in the photo property');
|
is($story->get('photo'), q|[{"caption":"Shawshank Prison","byLine":"Andrew Dufresne"}]|, 'setPhotoData: set JSON in the photo property');
|
||||||
|
|
||||||
$photoData = $story->getPhotoData();
|
$photoData = $story->getPhotoData();
|
||||||
$photoData->{filename1}->{caption}="My cell";
|
$photoData->[0]->{caption}="My cell";
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$story->getPhotoData,
|
$story->getPhotoData,
|
||||||
{
|
[
|
||||||
filename1 => {
|
{
|
||||||
byLine => 'Andrew Dufresne',
|
byLine => 'Andrew Dufresne',
|
||||||
caption => 'Shawshank Prison',
|
caption => 'Shawshank Prison',
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
'getPhotoData does not return an unsafe reference'
|
'getPhotoData does not return an unsafe reference'
|
||||||
);
|
);
|
||||||
|
|
||||||
$story->setPhotoData();
|
$story->setPhotoData();
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$story->getPhotoData, {},
|
$story->getPhotoData, [],
|
||||||
'setPhotoData: wipes the stored data if nothing is passed'
|
'setPhotoData: wipes the stored data if nothing is passed'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue