Add i18n for Tax, for the UI.

Begin to flesh out the DataTable JS for www_view.  Add a method to slurp all the
tax data out of the db at once.
Add a test for the slurp method, and stop using the private sub that used to
do it in the tests.
This commit is contained in:
Colin Kuskie 2008-03-10 04:25:36 +00:00
parent 1bbf5a3c7c
commit f40bed7ef3
3 changed files with 112 additions and 20 deletions

View file

@ -141,7 +141,7 @@ sub calculate {
=head2 canEdit ( [ $user ] )
Determine whether or not the current user can perform commerce functions
Determine whether or not a user can perform commerce functions
=head3 $user
@ -212,6 +212,21 @@ sub exportTaxData {
#-------------------------------------------------------------------
=head2 getAllItems ( )
Returns an arrayref of hashrefs, where each hashref is the data for one row of
tax data. taxId is dropped from the dataset.
=cut
sub getAllItems {
my $self = shift;
my $taxes = $self->session->db->buildArrayRefOfHashRefs('select country,state,city,code,taxRate from tax order by country, state');
return $taxes;
}
#-------------------------------------------------------------------
=head2 getItems ( )
Returns a WebGUI::SQL::Result object for accessing all of the data in the tax table. This
@ -221,7 +236,7 @@ is a convenience method for listing and/or exporting tax data.
sub getItems {
my $self = shift;
my $result = $self->session->db->read('select * from tax');
my $result = $self->session->db->read('select * from tax order by country, state');
return $result;
}
@ -353,6 +368,28 @@ sub www_view {
my $self = shift;
return $self->session->privileges->insufficient
unless $self->canEdit;
my $session = $self->session;
##YUI specific datatable CSS
$session->setLink($session->url->extras('yui/build/datatable/assets/skins/sam/datatable.css'), {type => 'text/CSS'});
##YUI basics
$session->style->setScript($session->url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'), {type => 'text/javascript'});
$session->style->setScript($session->url->extras('yui/build/element/element-beta-min.js'), {type => 'text/javascript'});
$session->style->setScript($session->url->extras('yui/build/datasource/datasource-beta-min.js'), {type => 'text/javascript'});
##YUI Datatable
$session->style->setScript($session->url->extras('yui/build/datatable/datatable-beta-min.js'), {type => 'text/javascript'});
##YUI JSON handler
$session->style->setScript($session->url->extras('yui/build/json/json-min.js'), {type => 'text/javascript'});
##Build column headers. TODO: I18N
my $i18n=WebGUI::International->new($session, 'Tax');
$session->style->setRawHeadTags(sprintf <<'EOCHJS', $i18n->get('country'), $i18n->get('state'), $i18n->get('city'), $i18n->get('code'));
var taxColumnDefs = [
{key:"country", label:"%s"},
{key:"state", label:"%s"},
{key:"city", label:"%s"},
{key:"code", label:"%s"}
];
EOCHJS
$session->style->setRawHeadTags();
return '';
}

View file

@ -0,0 +1,32 @@
package WebGUI::i18n::English::Tax;
use strict;
our $I18N = {
'country' => {
message => q|Country|,
lastUpdated => 1205120607,
context => q|The name of a country, such as Portugal or Canada.|,
},
'state' => {
message => q|State|,
lastUpdated => 1205120615,
context => q|A political subdivision of a country, such as California.|,
},
'city' => {
message => q|City|,
lastUpdated => 1205120661,
},
'code' => {
message => q|Code|,
lastUpdated => 1205120660,
context => q|A postal code, or zip code.|,
},
};
1;