rfe #12159: Asset Manager sort preferences

This commit is contained in:
Paul Driver 2011-06-13 13:22:16 -05:00
parent 328826e3f7
commit 1ff1ffe423
5 changed files with 106 additions and 22 deletions

View file

@ -12,6 +12,7 @@
- fixed #12119: Locale setting for paypal
- fixed #12156: Asset Manager performance
- fixed #12158: Shop credit cannot be used to pay for Shipping on PayPal
- rfe #12159: Asset Manager sort preferences
7.10.17
- fixed: Forced to use a PayDriver even with a balance of 0 in the cart.

View file

@ -31,10 +31,59 @@ my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
addAssetManagerSortPreferences($session);
finish($session); # this line required
#----------------------------------------------------------------------------
sub addAssetManagerSortPreferences {
my $cn = 'assetManagerSortColumn';
my $on = 'assetManagerSortDirection';
unless (WebGUI::ProfileField->new($session, $cn)) {
print 'Adding Asset Manager Sort Column profile field...'
unless $quiet;
WebGUI::ProfileField->create($session, $cn => {
label =>
"WebGUI::International::get('$cn label', 'Account_Profile')",
protected => 1,
fieldType => 'selectBox',
dataDefault => 'lineage',
possibleValues => <<'VALUES',
{
lineage => WebGUI::International::get('rank', 'Asset'),
title => WebGUI::International::get(99, 'Asset'),
className => WebGUI::International::get('type', 'Asset'),
revisionDate => WebGUI::International::get('revision date', 'Asset'),
assetSize => WebGUI::International::get('size', 'Asset'),
lockedBy => WebGUI::International::get('locked', 'Asset'),
}
VALUES
}, 4);
print "Done!\n" unless $quiet;
}
unless (WebGUI::ProfileField->new($session, $on)) {
print 'Adding Asset Manager Sort Direction profile field...'
unless $quiet;
WebGUI::ProfileField->create($session, $on => {
label =>
"WebGUI::International::get('$on label', 'Account_Profile')",
protected => 1,
fieldType => 'selectBox',
dataDefault => 'asc',
possibleValues => <<'VALUES',
{
asc => WebGUI::International::get('ascending', 'Account_Profile'),
desc => WebGUI::International::get('descending', 'Account_Profile'),
}
VALUES
}, 4);
print "Done!\n" unless $quiet;
}
}
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {

View file

@ -100,15 +100,26 @@ filled with asset IDs.
sub getManagerPaginator {
my $session = shift;
my $user = $session->user;
my $asset = getCurrentAsset( $session );
my %update;
my $orderByColumn = $session->form->get( 'orderByColumn' )
|| "lineage"
;
my $orderByDirection = lc $session->form->get( 'orderByDirection' ) eq "desc"
? "DESC"
: "ASC"
;
my $orderByColumn = $session->form->get( 'orderByColumn' );
if ($orderByColumn) {
$update{assetManagerSortColumn} = $orderByColumn;
}
else {
$orderByColumn = $user->get( 'assetManagerSortColumn' ) || 'lineage';
}
my $orderByDirection = lc $session->form->get( 'orderByDirection' );
if ($orderByDirection) {
$update{assetManagerSortDirection} = $orderByDirection;
}
else {
$orderByDirection = $user->get( 'assetManagerSortDirection' );
}
$orderByDirection = $orderByDirection eq 'desc' ? 'DESC' : 'ASC';
$user->update( \%update ) if ( keys %update );
my $recordOffset = $session->form->get( 'recordOffset' ) || 1;
my $rowsPerPage = $session->form->get( 'rowsPerPage' ) || 100;
@ -119,7 +130,11 @@ sub getManagerPaginator {
my $orderBy = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection;
$p->setDataByArrayRef( $asset->getLineage( ['children'], { orderByClause => $orderBy } ) );
return $p;
return {
paginator => $p,
sortColumn => $orderByColumn,
sortDirection => lc $orderByDirection,
};
}
#----------------------------------------------------------------------------
@ -288,7 +303,8 @@ sub www_ajaxGetManagerPage {
my $session = shift;
my $i18n = WebGUI::International->new( $session, "Asset" );
my $assetInfo = { assets => [] };
my $p = getManagerPaginator( $session );
my $pageInfo = getManagerPaginator( $session );
my $p = $pageInfo->{paginator};
for my $assetId ( @{ $p->getPageData } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
@ -319,8 +335,8 @@ sub www_ajaxGetManagerPage {
}
$assetInfo->{ totalAssets } = $p->getRowCount;
$assetInfo->{ sort } = $session->form->get( 'orderByColumn' );
$assetInfo->{ dir } = lc $session->form->get( 'orderByDirection' );
$assetInfo->{ sort } = $pageInfo->{sortColumn};
$assetInfo->{ dir } = $pageInfo->{sortDirection};
$session->http->setMimeType( 'application/json' );

View file

@ -169,6 +169,24 @@ our $I18N = {
message => q{required },
lastUpdated => 1225724810,
},
'assetManagerSortDirection label' => {
message => 'Asset Manager Sort Direction',
lastUpdated => 1307982524,
},
'assetManagerSortColumn label' => {
message => 'Asset Manager Sort Column',
lastUpdated => 1307982524,
},
'ascending' => {
message => 'Ascending',
lastUpdated => 1307982524,
context => 'Ascending sort order (lowest to highest)',
},
'descending' => {
message => 'Descending',
lastUpdated => 1307982524,
context => 'Descending sort order (highest to lowest)',
},
};
1;

View file

@ -203,14 +203,6 @@ WebGUI.AssetManager.onMoreClick = function (e, a) {
menu.focus();
};
/*---------------------------------------------------------------------------
WebGUI.AssetManager.DefaultSortedBy ( )
*/
WebGUI.AssetManager.DefaultSortedBy = {
"key" : "lineage",
"dir" : YAHOO.widget.DataTable.CLASS_ASC
};
/*---------------------------------------------------------------------------
WebGUI.AssetManager.BuildQueryString ( )
*/
@ -314,7 +306,9 @@ WebGUI.AssetManager.initDataTable = function (o) {
{ key: 'childCount' }
],
metaFields: {
totalRecords: "totalAssets" // Access to value in the server response
totalRecords : 'totalAssets',
sortColumn : 'sort',
sortDirection : 'dir'
}
};
@ -329,13 +323,19 @@ WebGUI.AssetManager.initDataTable = function (o) {
initialRequest : 'recordOffset=0',
dynamicData : true,
paginator : assetPaginator,
sortedBy : WebGUI.AssetManager.DefaultSortedBy,
generateRequest : WebGUI.AssetManager.BuildQueryString
}
);
WebGUI.AssetManager.DataTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
oPayload.totalRecords = oResponse.meta.totalRecords;
var m = oResponse.meta;
oPayload.totalRecords = m.totalRecords;
this.set('sortedBy', {
key: m.sortColumn,
dir: m.sortDirection === 'desc' ?
YAHOO.widget.DataTable.CLASS_DESC :
YAHOO.widget.DataTable.CLASS_ASC
});
return oPayload;
};