Fix deleteFileUrl for image*, warranty, brochure and other file collateral in the product.
This commit is contained in:
parent
3b70d64b82
commit
b6e56566c1
2 changed files with 18 additions and 8 deletions
|
|
@ -61,15 +61,19 @@ property image1 => (
|
||||||
default => undef,
|
default => undef,
|
||||||
maxAttachments => 1,
|
maxAttachments => 1,
|
||||||
label => ['7', 'Asset_Product'],
|
label => ['7', 'Asset_Product'],
|
||||||
#deleteFileUrl => $session->url->page("func=deleteFileConfirm;file=image1;filename="),
|
deleteFileUrl => \&_product_delete_file_url,
|
||||||
persist => 1,
|
persist => 1,
|
||||||
);
|
);
|
||||||
|
sub _product_delete_file_url {
|
||||||
|
my ($self, $property) = @_;
|
||||||
|
return $self->session->url->page(sprintf "func=deleteFileConfirm;file=%s;filename=", $property->name);
|
||||||
|
}
|
||||||
property image2 => (
|
property image2 => (
|
||||||
tab => "properties",
|
tab => "properties",
|
||||||
fieldType => "image",
|
fieldType => "image",
|
||||||
maxAttachments => 1,
|
maxAttachments => 1,
|
||||||
label => ['8', 'Asset_Product'],
|
label => ['8', 'Asset_Product'],
|
||||||
#deleteFileUrl => $session->url->page("func=deleteFileConfirm;file=image2;filename="),
|
deleteFileUrl => \&_product_delete_file_url,
|
||||||
default => undef,
|
default => undef,
|
||||||
persist => 1,
|
persist => 1,
|
||||||
);
|
);
|
||||||
|
|
@ -78,7 +82,7 @@ property image3 => (
|
||||||
fieldType => "image",
|
fieldType => "image",
|
||||||
maxAttachments => 1,
|
maxAttachments => 1,
|
||||||
label => ['9', 'Asset_Product'],
|
label => ['9', 'Asset_Product'],
|
||||||
#deleteFileUrl => $session->url->page("func=deleteFileConfirm;file=image3;filename="),
|
deleteFileUrl => \&_product_delete_file_url,
|
||||||
default => undef,
|
default => undef,
|
||||||
persist => 1,
|
persist => 1,
|
||||||
);
|
);
|
||||||
|
|
@ -87,7 +91,7 @@ property brochure => (
|
||||||
fieldType => "file",
|
fieldType => "file",
|
||||||
maxAttachments => 1,
|
maxAttachments => 1,
|
||||||
label => ['13', 'Asset_Product'],
|
label => ['13', 'Asset_Product'],
|
||||||
#deleteFileUrl => $session->url->page("func=deleteFileConfirm;file=brochure;filename="),
|
deleteFileUrl => \&_product_delete_file_url,
|
||||||
default => undef,
|
default => undef,
|
||||||
persist => 1,
|
persist => 1,
|
||||||
);
|
);
|
||||||
|
|
@ -96,7 +100,7 @@ property manual => (
|
||||||
fieldType => "file",
|
fieldType => "file",
|
||||||
maxAttachments => 1,
|
maxAttachments => 1,
|
||||||
label => ['14', 'Asset_Product'],
|
label => ['14', 'Asset_Product'],
|
||||||
#deleteFileUrl => $session->url->page("func=deleteFileConfirm;file=manual;filename="),
|
deleteFileUrl => \&_product_delete_file_url,
|
||||||
default => undef,
|
default => undef,
|
||||||
persist => 1,
|
persist => 1,
|
||||||
);
|
);
|
||||||
|
|
@ -112,7 +116,7 @@ property warranty => (
|
||||||
fieldType => "file",
|
fieldType => "file",
|
||||||
maxAttachments => 1,
|
maxAttachments => 1,
|
||||||
label => ['15', 'Asset_Product'],
|
label => ['15', 'Asset_Product'],
|
||||||
#deleteFileUrl => $session->url->page("func=deleteFileConfirm;file=warranty;filename="),
|
deleteFileUrl => \&_product_delete_file_url,
|
||||||
default => undef,
|
default => undef,
|
||||||
persist => 1,
|
persist => 1,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
plan tests => 13; # Increment this number for each test you create
|
plan tests => 19; # Increment this number for each test you create
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
|
@ -50,6 +50,12 @@ my $product = $node->addChild({
|
||||||
|
|
||||||
is($product->getThumbnailUrl(), '', 'Product with no image1 property returns the empty string');
|
is($product->getThumbnailUrl(), '', 'Product with no image1 property returns the empty string');
|
||||||
|
|
||||||
|
note "Checking automatically generated deleteFileUrl links";
|
||||||
|
foreach my $file_property (qw/image1 image2 image3 brochure manual warranty/) {
|
||||||
|
my $form_properties = $product->getFormProperties($file_property);
|
||||||
|
like $form_properties->{deleteFileUrl}, qr/file=$file_property/, '...' . $file_property;
|
||||||
|
}
|
||||||
|
|
||||||
my $image = WebGUI::Storage->create($session);
|
my $image = WebGUI::Storage->create($session);
|
||||||
WebGUI::Test->storagesToDelete($image);
|
WebGUI::Test->storagesToDelete($image);
|
||||||
$image->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg'));
|
$image->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg'));
|
||||||
|
|
@ -164,7 +170,7 @@ $tag2->commit;
|
||||||
WebGUI::Test->tagsToRollback($tag2);
|
WebGUI::Test->tagsToRollback($tag2);
|
||||||
|
|
||||||
##Fetch a copy from the db, just like a page fetch
|
##Fetch a copy from the db, just like a page fetch
|
||||||
$viewProduct = WebGUI::Asset->new($session, $viewProduct->getId, 'WebGUI::Asset::Sku::Product');
|
$viewProduct = WebGUI::Asset->newById($session, $viewProduct->getId);
|
||||||
|
|
||||||
$viewProduct->prepareView();
|
$viewProduct->prepareView();
|
||||||
my $json = $viewProduct->view();
|
my $json = $viewProduct->view();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue