rfe #12159: Asset Manager sort preferences
This commit is contained in:
parent
328826e3f7
commit
1ff1ffe423
5 changed files with 106 additions and 22 deletions
|
|
@ -12,6 +12,7 @@
|
||||||
- fixed #12119: Locale setting for paypal
|
- fixed #12119: Locale setting for paypal
|
||||||
- fixed #12156: Asset Manager performance
|
- fixed #12156: Asset Manager performance
|
||||||
- fixed #12158: Shop credit cannot be used to pay for Shipping on PayPal
|
- fixed #12158: Shop credit cannot be used to pay for Shipping on PayPal
|
||||||
|
- rfe #12159: Asset Manager sort preferences
|
||||||
|
|
||||||
7.10.17
|
7.10.17
|
||||||
- fixed: Forced to use a PayDriver even with a balance of 0 in the cart.
|
- fixed: Forced to use a PayDriver even with a balance of 0 in the cart.
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,59 @@ my $quiet; # this line required
|
||||||
my $session = start(); # this line required
|
my $session = start(); # this line required
|
||||||
|
|
||||||
# upgrade functions go here
|
# upgrade functions go here
|
||||||
|
addAssetManagerSortPreferences($session);
|
||||||
|
|
||||||
finish($session); # this line required
|
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
|
# Describe what our function does
|
||||||
#sub exampleFunction {
|
#sub exampleFunction {
|
||||||
|
|
|
||||||
|
|
@ -100,15 +100,26 @@ filled with asset IDs.
|
||||||
|
|
||||||
sub getManagerPaginator {
|
sub getManagerPaginator {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
|
my $user = $session->user;
|
||||||
my $asset = getCurrentAsset( $session );
|
my $asset = getCurrentAsset( $session );
|
||||||
|
my %update;
|
||||||
|
|
||||||
my $orderByColumn = $session->form->get( 'orderByColumn' )
|
my $orderByColumn = $session->form->get( 'orderByColumn' );
|
||||||
|| "lineage"
|
if ($orderByColumn) {
|
||||||
;
|
$update{assetManagerSortColumn} = $orderByColumn;
|
||||||
my $orderByDirection = lc $session->form->get( 'orderByDirection' ) eq "desc"
|
}
|
||||||
? "DESC"
|
else {
|
||||||
: "ASC"
|
$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 $recordOffset = $session->form->get( 'recordOffset' ) || 1;
|
||||||
my $rowsPerPage = $session->form->get( 'rowsPerPage' ) || 100;
|
my $rowsPerPage = $session->form->get( 'rowsPerPage' ) || 100;
|
||||||
|
|
@ -119,7 +130,11 @@ sub getManagerPaginator {
|
||||||
my $orderBy = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection;
|
my $orderBy = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection;
|
||||||
$p->setDataByArrayRef( $asset->getLineage( ['children'], { orderByClause => $orderBy } ) );
|
$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 $session = shift;
|
||||||
my $i18n = WebGUI::International->new( $session, "Asset" );
|
my $i18n = WebGUI::International->new( $session, "Asset" );
|
||||||
my $assetInfo = { assets => [] };
|
my $assetInfo = { assets => [] };
|
||||||
my $p = getManagerPaginator( $session );
|
my $pageInfo = getManagerPaginator( $session );
|
||||||
|
my $p = $pageInfo->{paginator};
|
||||||
|
|
||||||
for my $assetId ( @{ $p->getPageData } ) {
|
for my $assetId ( @{ $p->getPageData } ) {
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
||||||
|
|
@ -319,8 +335,8 @@ sub www_ajaxGetManagerPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
$assetInfo->{ totalAssets } = $p->getRowCount;
|
$assetInfo->{ totalAssets } = $p->getRowCount;
|
||||||
$assetInfo->{ sort } = $session->form->get( 'orderByColumn' );
|
$assetInfo->{ sort } = $pageInfo->{sortColumn};
|
||||||
$assetInfo->{ dir } = lc $session->form->get( 'orderByDirection' );
|
$assetInfo->{ dir } = $pageInfo->{sortDirection};
|
||||||
|
|
||||||
$session->http->setMimeType( 'application/json' );
|
$session->http->setMimeType( 'application/json' );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,24 @@ our $I18N = {
|
||||||
message => q{required },
|
message => q{required },
|
||||||
lastUpdated => 1225724810,
|
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;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -203,14 +203,6 @@ WebGUI.AssetManager.onMoreClick = function (e, a) {
|
||||||
menu.focus();
|
menu.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
WebGUI.AssetManager.DefaultSortedBy ( )
|
|
||||||
*/
|
|
||||||
WebGUI.AssetManager.DefaultSortedBy = {
|
|
||||||
"key" : "lineage",
|
|
||||||
"dir" : YAHOO.widget.DataTable.CLASS_ASC
|
|
||||||
};
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
WebGUI.AssetManager.BuildQueryString ( )
|
WebGUI.AssetManager.BuildQueryString ( )
|
||||||
*/
|
*/
|
||||||
|
|
@ -314,7 +306,9 @@ WebGUI.AssetManager.initDataTable = function (o) {
|
||||||
{ key: 'childCount' }
|
{ key: 'childCount' }
|
||||||
],
|
],
|
||||||
metaFields: {
|
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',
|
initialRequest : 'recordOffset=0',
|
||||||
dynamicData : true,
|
dynamicData : true,
|
||||||
paginator : assetPaginator,
|
paginator : assetPaginator,
|
||||||
sortedBy : WebGUI.AssetManager.DefaultSortedBy,
|
|
||||||
generateRequest : WebGUI.AssetManager.BuildQueryString
|
generateRequest : WebGUI.AssetManager.BuildQueryString
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
WebGUI.AssetManager.DataTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
|
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;
|
return oPayload;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue