migrate Survey graph to formbuilder
This commit is contained in:
parent
db8b507b94
commit
1fb51f2e75
2 changed files with 24 additions and 10 deletions
|
|
@ -694,22 +694,20 @@ sub www_graph {
|
|||
|
||||
my $i18n = WebGUI::International->new($session, "Asset_Survey");
|
||||
|
||||
my $ac = $self->getAdminConsole;
|
||||
|
||||
eval { require GraphViz };
|
||||
if ($@) {
|
||||
return $ac->render('Survey Visualization requires the GraphViz module', $i18n->get('survey visualization'));
|
||||
return '<h1>' . $i18n->get('survey visualization') . '</h1>Survey Visualization requires the GraphViz module';
|
||||
}
|
||||
|
||||
my $format = $self->session->form->param('format');
|
||||
my $layout = $self->session->form->param('layout');
|
||||
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
my $f = WebGUI::FormBuilder->new($session, action => $self->getUrl);
|
||||
$f->addField( "hidden",
|
||||
name=>'func',
|
||||
value=>'graph'
|
||||
);
|
||||
$f->selectBox(
|
||||
$f->addField( "selectBox",
|
||||
name => 'format',
|
||||
label => $i18n->get('visualization format'),
|
||||
hoverHelp => $i18n->get('visualization format help'),
|
||||
|
|
@ -717,7 +715,7 @@ sub www_graph {
|
|||
defaultValue => [$format],
|
||||
sortByValue => 1,
|
||||
);
|
||||
$f->selectBox(
|
||||
$f->addField( "selectBox",
|
||||
name => 'layout',
|
||||
label => $i18n->get('visualization layout algorithm'),
|
||||
hoverHelp => $i18n->get('visualization layout algorithm help'),
|
||||
|
|
@ -725,7 +723,7 @@ sub www_graph {
|
|||
defaultValue => [$layout],
|
||||
sortByValue => 1,
|
||||
);
|
||||
$f->submit(
|
||||
$f->addField( "submit",
|
||||
defaultValue => $i18n->get('generate'),
|
||||
);
|
||||
|
||||
|
|
@ -735,7 +733,7 @@ sub www_graph {
|
|||
$output .= "<p>" . $i18n->get('visualization success') . qq{ <a href="$url">survey.$format</a></p>};
|
||||
}
|
||||
}
|
||||
return $ac->render($f->print . $output, $i18n->get('survey visualization'));
|
||||
return '<h1>' . $i18n->get('survey visualization') . '</h1>' . $f->toHtml . $output;
|
||||
}
|
||||
|
||||
=head2 hasResponses
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use Test::More;
|
|||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Test::Mechanize;
|
||||
use WebGUI::Session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -16,7 +17,7 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 47;
|
||||
plan tests => 51;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -261,6 +262,21 @@ like($storage->getFileContentsAsScalar($filename), qr{
|
|||
stop$ # ..and end with stop
|
||||
}xs, 'Generated graph looks roughly okay');
|
||||
|
||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
$mech->get_ok( '/' );
|
||||
$mech->session->user({ userId => 3 });
|
||||
$mech->get_ok( $survey->getUrl( 'func=graph' ) );
|
||||
$mech->submit_form_ok({
|
||||
fields => {
|
||||
format => "plain",
|
||||
layout => "dot",
|
||||
},
|
||||
},
|
||||
"generate a graph",
|
||||
);
|
||||
# Can only test for the uploads, mech doesn't have uploads handler
|
||||
$mech->content_contains( 'uploads/temp', 'uploads link exists' );
|
||||
|
||||
}
|
||||
|
||||
####################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue