Add sortable YUI data table to bounce score overview.
This commit is contained in:
parent
595e340515
commit
0d1b0fe7ac
1 changed files with 59 additions and 3 deletions
|
|
@ -86,21 +86,77 @@ EOSQL
|
|||
|
||||
my $sth = $db->read( $sql, [ $windowSize, $windowSize - 1 ] );
|
||||
|
||||
my $output = '<table><tr><th>'
|
||||
my $output = '<div class="yui-skin-sam"><div id="tableWrapper"><table id="bounceScoreTable"><thead><tr><th>'
|
||||
. join( '</th><th>',
|
||||
$i18n->get('email'),
|
||||
$i18n->get('bounce score'),
|
||||
$i18n->get('bounce reason'),
|
||||
$i18n->get('bounce message')
|
||||
)
|
||||
. '</th></tr>';
|
||||
. '</th></tr></thead><tbody>';
|
||||
while ( my $values = $sth->arrayRef ) {
|
||||
$output .= '<tr><td>'. join( '</td><td>', @$values ) . '</td></tr>';
|
||||
}
|
||||
$output .= '</table>';
|
||||
$output .= '</tbody></table></div></div>';
|
||||
|
||||
$self->addBounceScoreTableJS;
|
||||
|
||||
return WebGUI::Mailing::Admin->new( $session )->getAdminConsole->render( $output, $i18n->get( 'bounce scores' ) );
|
||||
}
|
||||
|
||||
sub addBounceScoreTableJS {
|
||||
my $self = shift;
|
||||
my ($style, $url) = $self->session->quick( qw{ style url } );
|
||||
my $i18n = WebGUI::International->new( $self->session, 'MailingManager' );
|
||||
|
||||
my $emailLabel = $i18n->get('email');
|
||||
my $scoreLabel = $i18n->get('bounce score');
|
||||
my $reasonLabel = $i18n->get('bounce reason');
|
||||
my $messageLabel= $i18n->get('bounce message');
|
||||
|
||||
my $js = <<EOJS;
|
||||
<script type="text/javascript">
|
||||
//<!--
|
||||
YAHOO.util.Event.onDOMReady( function () {
|
||||
var columnDefs = [
|
||||
{ key : "email", label : "$emailLabel", sortable : true },
|
||||
{ key : "bounceScore", label : "$scoreLabel", sortable : true },
|
||||
{ key : "bounceReason", label : "$reasonLabel", sortable : true },
|
||||
{ key : "bounceMessage", label : "$messageLabel", sortable : true }
|
||||
];
|
||||
|
||||
var ds = new YAHOO.util.DataSource( YAHOO.util.Dom.get('bounceScoreTable') );
|
||||
ds.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
|
||||
ds.responseSchema = {
|
||||
fields: [
|
||||
{ key : 'email' },
|
||||
{ key : 'bounceScore', parser : 'number' },
|
||||
{ key : 'bounceReason' },
|
||||
{ key : 'bounceMessage' }
|
||||
]
|
||||
};
|
||||
|
||||
var dt = new YAHOO.widget.DataTable( 'tableWrapper', columnDefs, ds, {
|
||||
sortedBy : {
|
||||
key : 'bounceScore',
|
||||
dir : 'desc'
|
||||
}
|
||||
} );
|
||||
} );
|
||||
//-->
|
||||
</script>
|
||||
EOJS
|
||||
|
||||
$style->setLink( $url->extras('yui/build/datatable/assets/skins/sam/datatable.css'), { type => 'text/css', rel => 'stylesheet' } );
|
||||
$style->setScript( $url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'), { type => 'text/javascript' } );
|
||||
$style->setScript( $url->extras('yui/build/element/element-min.js'), { type => 'text/javascript' } );
|
||||
$style->setScript( $url->extras('yui/build/datasource/datasource-min.js'), { type => 'text/javascript' } );
|
||||
$style->setScript( $url->extras('yui/build/datatable/datatable-min.js'), { type => 'text/javascript' } );
|
||||
$style->setRawHeadTags( $js );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue