migrate DataForm www_editTab to FormBuilder
This commit is contained in:
parent
c9db7b0d7f
commit
0591c69594
2 changed files with 56 additions and 11 deletions
|
|
@ -1782,28 +1782,28 @@ sub www_editTab {
|
|||
$tab = $self->getTabConfig($tabId);
|
||||
}
|
||||
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
$f->hidden(
|
||||
my $f = WebGUI::FormBuilder->new($self->session,action=>$self->getUrl);
|
||||
$f->addField( "hidden",
|
||||
-name => "tabId",
|
||||
-value => $tabId,
|
||||
);
|
||||
$f->hidden(
|
||||
$f->addField( "hidden",
|
||||
-name => "func",
|
||||
-value => "editTabSave"
|
||||
);
|
||||
$f->text(
|
||||
$f->addField( "text",
|
||||
-name=>"label",
|
||||
-label=>$i18n->get(101),
|
||||
-value=>$tab->{label}
|
||||
);
|
||||
$f->textarea(
|
||||
$f->addField( "textarea",
|
||||
-name=>"subtext",
|
||||
-label=>$i18n->get(79),
|
||||
-value=>$tab->{subtext},
|
||||
-subtext=>""
|
||||
);
|
||||
if ($tabId eq "new") {
|
||||
$f->whatNext(
|
||||
$f->addField( "whatNext",
|
||||
options=>{
|
||||
editTab=>$i18n->get(103),
|
||||
""=>$i18n->get(745)
|
||||
|
|
@ -1811,10 +1811,9 @@ sub www_editTab {
|
|||
-value=>"editTab"
|
||||
);
|
||||
}
|
||||
$f->submit;
|
||||
my $ac = $self->getAdminConsole;
|
||||
return $ac->render($f->print,$i18n->get('103')) if $tabId eq "new";
|
||||
return $ac->render($f->print,$i18n->get('102'));
|
||||
$f->addField( "submit", name => "submit" );
|
||||
return '<h1>' . $i18n->get('103') . '</h1>' . $f->toHtml if $tabId eq "new";
|
||||
return '<h1>' . $i18n->get('102') . '</h1>' . $f->toHtml;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ $dform->createField('gotCaptcha', { type => 'Captcha', name => 'humanCheck', });
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 11; # Increment this number for each test you create
|
||||
plan tests => 18; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# _createForm
|
||||
|
|
@ -141,5 +141,51 @@ cmp_deeply(
|
|||
);
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_editTab
|
||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
$mech->get_ok('/');
|
||||
$mech->session->user({ userId => 3 });
|
||||
|
||||
# Create a new tab
|
||||
$mech->get_ok( $df->getUrl( 'func=editTab' ) );
|
||||
$mech->submit_form_ok( {
|
||||
fields => {
|
||||
label => 'Request Info',
|
||||
subtext => "We won't be reading it, but fill it out anyway or get fired.",
|
||||
},
|
||||
}, "add a new tab" );
|
||||
|
||||
$df = WebGUI::Asset->newById( $mech->session, $df->getId );
|
||||
# Figure out the ID
|
||||
my $tabId = ( keys %{$df->getTabConfig} )[0];
|
||||
cmp_deeply(
|
||||
$df->getTabConfig( $tabId ),
|
||||
superhashof( {
|
||||
label => 'Request Info',
|
||||
subtext => "We won't be reading it, but fill it out anyway or get fired.",
|
||||
} ),
|
||||
"tab exists with correct config",
|
||||
);
|
||||
|
||||
# Edit that tab
|
||||
sleep 1; # stupid addRevision
|
||||
$mech->get_ok( $df->getUrl( 'func=editTab;tabId=' . $tabId ) );
|
||||
$mech->submit_form_ok( {
|
||||
fields => {
|
||||
label => 'Begging Info',
|
||||
subtext => "Adding puppydog eyes may help your case, slightly",
|
||||
},
|
||||
}, "edit the tab" );
|
||||
|
||||
$df = WebGUI::Asset->newPending( $mech->session, $df->getId );
|
||||
cmp_deeply(
|
||||
$df->getTabConfig( $tabId ),
|
||||
superhashof( {
|
||||
label => 'Begging Info',
|
||||
subtext => "Adding puppydog eyes may help your case, slightly",
|
||||
} ),
|
||||
"tab config updated",
|
||||
);
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue