migrate Product www_addRelated to FormBuilder
This commit is contained in:
parent
a30d9acc25
commit
078397b015
2 changed files with 49 additions and 16 deletions
|
|
@ -959,10 +959,10 @@ Provides a form for the user to pick Products related to this one.
|
|||
sub www_addRelated {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless ($self->canEdit);
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
$f->hidden(
|
||||
-name => 'func',
|
||||
-value => 'addRelatedSave',
|
||||
my $f = WebGUI::FormBuilder->new($self->session,action=>$self->getUrl);
|
||||
$f->addField( "hidden",
|
||||
name => 'func',
|
||||
value => 'addRelatedSave',
|
||||
);
|
||||
##Relateds are other Products. Give the user a list of Related products that
|
||||
##are not already used, nor itself.
|
||||
|
|
@ -988,19 +988,19 @@ sub www_addRelated {
|
|||
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session,'Asset_Product');
|
||||
$f->selectBox(
|
||||
-name => 'relatedAssetId',
|
||||
-options => $related,
|
||||
-label => $i18n->get(20),
|
||||
-hoverHelp => $i18n->get('20 description'),
|
||||
$f->addField( "selectBox",
|
||||
name => 'relatedAssetId',
|
||||
options => $related,
|
||||
label => $i18n->get(20),
|
||||
hoverHelp => $i18n->get('20 description'),
|
||||
);
|
||||
$f->yesNo(
|
||||
-name => 'proceed',
|
||||
-label => $i18n->get(21),
|
||||
-hoverHelp => $i18n->get('21 description'),
|
||||
$f->addField( "yesNo",
|
||||
name => 'proceed',
|
||||
label => $i18n->get(21),
|
||||
hoverHelp => $i18n->get('21 description'),
|
||||
);
|
||||
$f->submit;
|
||||
return $self->getAdminConsole->render($f->print,'product related add/edit');
|
||||
$f->addField( "submit", name => "submit" );
|
||||
return $f->toHtml;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 25; # Increment this number for each test you create
|
||||
plan tests => 31; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -209,3 +209,36 @@ cmp_deeply(
|
|||
[ { accessoryAssetId => $imagedProduct->getId }, { accessoryAssetId => $viewProduct->getId } ],
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# addRelated
|
||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
$mech->get_ok( '/' );
|
||||
$mech->session->user({ userId => 3 });
|
||||
$mech->get_ok( $product->getUrl( 'func=addRelated' ) );
|
||||
|
||||
$mech->submit_form_ok({
|
||||
fields => {
|
||||
relatedAssetId => $imagedProduct->getId,
|
||||
proceed => 1,
|
||||
},
|
||||
}, 'add imagedProduct as a related and add another');
|
||||
|
||||
$product = $product->cloneFromDb;
|
||||
cmp_deeply(
|
||||
$product->getAllCollateral( 'relatedJSON' ),
|
||||
[ { relatedAssetId => $imagedProduct->getId } ],
|
||||
);
|
||||
|
||||
$mech->submit_form_ok({
|
||||
fields => {
|
||||
relatedAssetId => $viewProduct->getId,
|
||||
proceed => 0,
|
||||
},
|
||||
}, 'add viewProduct and go back' );
|
||||
|
||||
$product = $product->cloneFromDb;
|
||||
cmp_deeply(
|
||||
$product->getAllCollateral( 'relatedJSON' ),
|
||||
[ { relatedAssetId => $imagedProduct->getId }, { relatedAssetId => $viewProduct->getId } ],
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue