renamed www_view to www_manage, and added more JS
This commit is contained in:
parent
ff61a8e50a
commit
1453900e01
1 changed files with 33 additions and 11 deletions
|
|
@ -376,14 +376,14 @@ sub www_getTaxesAsJson {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_view ( )
|
=head2 www_manage ( )
|
||||||
|
|
||||||
User interface to manage taxes. Provides a list of current taxes, and forms for adding
|
User interface to manage taxes. Provides a list of current taxes, and forms for adding
|
||||||
new tax info, exporting and importing sets of taxes, and deleting individual tax data.
|
new tax info, exporting and importing sets of taxes, and deleting individual tax data.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_view {
|
sub www_manage {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
my $admin = WebGUI::Shop::Admin->new($session);
|
my $admin = WebGUI::Shop::Admin->new($session);
|
||||||
|
|
@ -423,20 +423,22 @@ EODIV
|
||||||
##Build datasource with URL.
|
##Build datasource with URL.
|
||||||
$output .= sprintf <<'EODSURL', $url->page('shop=tax;method=getTaxesAsJson');
|
$output .= sprintf <<'EODSURL', $url->page('shop=tax;method=getTaxesAsJson');
|
||||||
var mySource = new DataSource('%s');
|
var mySource = new DataSource('%s');
|
||||||
EODSURL
|
|
||||||
$output .= <<STOP;
|
|
||||||
mySource.responseType = DataSource.TYPE_JSON;
|
mySource.responseType = DataSource.TYPE_JSON;
|
||||||
mySource.responseSchema = {
|
mySource.responseSchema = {
|
||||||
resultsList : 'records',
|
resultsList : 'records',
|
||||||
totalRecords: 'totalRecords',
|
totalRecords: 'totalRecords',
|
||||||
fields : [ 'taxId', 'country', 'state', 'city', 'code', 'taxRate']
|
fields : [ 'taxId', 'country', 'state', 'city', 'code', 'taxRate']
|
||||||
};
|
};
|
||||||
|
EODSURL
|
||||||
|
$output .= <<STOP;
|
||||||
|
##Tell YUI how to get back to the site
|
||||||
var buildQueryString = function (state,dt) {
|
var buildQueryString = function (state,dt) {
|
||||||
return ";startIndex=" + state.pagination.recordOffset +
|
return ";startIndex=" + state.pagination.recordOffset +
|
||||||
";keywords=" + Dom.get('keywordsField').value +
|
";keywords=" + Dom.get('keywordsField').value +
|
||||||
";results=" + state.pagination.rowsPerPage;
|
";results=" + state.pagination.rowsPerPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
##Build and configure a paginator
|
||||||
var myPaginator = new Paginator({
|
var myPaginator = new Paginator({
|
||||||
containers : ['paging'],
|
containers : ['paging'],
|
||||||
pageLinks : 5,
|
pageLinks : 5,
|
||||||
|
|
@ -444,17 +446,37 @@ EODSURL
|
||||||
rowsPerPageOptions : [10,25,50,100],
|
rowsPerPageOptions : [10,25,50,100],
|
||||||
template : "<strong>{CurrentPageReport}</strong> {PreviousPageLink} {PageLinks} {NextPageLink} {RowsPerPageDropdown}"
|
template : "<strong>{CurrentPageReport}</strong> {PreviousPageLink} {PageLinks} {NextPageLink} {RowsPerPageDropdown}"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
##Configure the table to use the paginator.
|
||||||
|
var myTableConfig = {
|
||||||
|
initialRequest : ';startIndex=0',
|
||||||
|
generateRequest : buildQueryString,
|
||||||
|
paginationEventHandler : DataTable.handleDataSourcePagination,
|
||||||
|
paginator : myPaginator
|
||||||
|
};
|
||||||
STOP
|
STOP
|
||||||
|
|
||||||
##Build column headers.
|
|
||||||
$output .= sprintf <<'EOCHJS', $i18n->get('country'), $i18n->get('state'), $i18n->get('city'), $i18n->get('code');
|
$output .= sprintf <<'EOCHJS', $i18n->get('country'), $i18n->get('state'), $i18n->get('city'), $i18n->get('code');
|
||||||
var taxColumnDefs = [
|
##Build column headers.
|
||||||
{key:"country", label:"%s"},
|
var taxColumnDefs = [
|
||||||
{key:"state", label:"%s"},
|
{key:"country", label:"%s"},
|
||||||
{key:"city", label:"%s"},
|
{key:"state", label:"%s"},
|
||||||
{key:"code", label:"%s"}
|
{key:"city", label:"%s"},
|
||||||
];
|
{key:"code", label:"%s"}
|
||||||
|
];
|
||||||
EOCHJS
|
EOCHJS
|
||||||
|
$output .= <<STOP;
|
||||||
|
##Now, finally, the table
|
||||||
|
var myTable = new DataTable('dt', myColumnDefs, mySource, myTableConfig);
|
||||||
|
|
||||||
|
##Setup the form to submit an AJAX request back to the site.
|
||||||
|
Dom.get('keywordSearchForm').onsubmit = function () {
|
||||||
|
mySource.sendRequest(';keywords=' + Dom.get('keywordsField').value + ';startIndex=0',
|
||||||
|
myTable.onDataReturnInitializeTable, myTable);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
STOP
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue