fixed some problems with the new asset manager. restored functionality to search with the hope of making the asset data table an API we can use in all the places we display tables of assets

This commit is contained in:
Doug Bell 2008-06-12 08:58:51 +00:00
parent f786ad7ce4
commit 36bea30cd6
6 changed files with 229 additions and 148 deletions

View file

@ -107,3 +107,58 @@ tr.highlight td {
.functionPane a {
vertical-align: bottom;
}
/** Asset Search table
NOTE: These will be removed when the search uses the Asset Data Table API **/
.assetSearch {
clear: both;
width: 100%;
}
.assetSearch th {
border: solid #666;
border-width: 0 1px 2px 0;
background-color: #eee;
}
.assetSearch th, .assetSearch td {
padding: 0 0.8em;
}
#assetSearch th, #assetSearch td, .assetManager {
font-size: 0.8em;
}
.assetSearch .center, .assetSearch th {
text-align: center;
}
.assetSearch .right {
text-align: right;
}
.assetSearch a:link, .assetSearch a:visited, .assetSearch a:active, .assetSearch a:hover {
font-size: 8pt;
}
.assetSearch tr.alt td {
background-color: #ddd;
}
.assetSearch tr.highlight td {
background-color: #CCF;
}
/** Page stats **/
#pageStats {
float: right;
text-align: right;
}
#pageLinks {
float: right;
text-align: right;
}

View file

@ -59,6 +59,12 @@ WebGUI.AssetManager.formatActions
more.appendChild( document.createTextNode( 'More' ) );
more.href = '#';
// Delete the old menu
if ( document.getElementById( 'moreMenu' + oRecord.getData( 'assetId' ) ) ) {
var oldMenu = document.getElementById( 'moreMenu' + oRecord.getData( 'assetId' ) );
oldMenu.parentNode.removeChild( oldMenu );
}
// Build a more menu
var rawItems = WebGUI.AssetManager.MoreMenuItems;
var menuItems = [];
@ -67,22 +73,20 @@ WebGUI.AssetManager.formatActions
? rawItems[i].url.replace( "<url>", oRecord.getData( 'url' ) )
: oRecord.getData( 'url' ) + rawItems[i].url
;
menuItems.push( '<li><a href="' + itemUrl + '">' + rawItems[i].label + "</a></li>" );
menuItems.push( { "url" : itemUrl, "text" : rawItems[i].label } );
}
var options = {
"zindex" : 100,
"zindex" : 1000,
"clicktohide" : true,
"constraintoviewport" : true,
"position" : "dynamic",
"xy" : [ more.clientLeft, more.clientTop ],
"context" : [ more, "tl", "bl" ],
"itemdata" : menuItems
};
var menu = new YAHOO.widget.Menu( "moreMenu" + oRecord.getData( 'assetId' ), options );
menu.render( document.getElementById( 'assetManager' ) );
YAHOO.util.Event.addListener( more, "click", menu.show, null, menu );
YAHOO.util.Event.onDOMReady( function () { menu.render( document.getElementById( 'assetManager' ) ) } );
YAHOO.util.Event.addListener( more, "click", function () { menu.show(); menu.focus(); }, null, menu );
};
/*---------------------------------------------------------------------------
@ -178,16 +182,93 @@ WebGUI.AssetManager.formatTitle
Initialize the www_manage page
*/
WebGUI.AssetManager.initManager
= function () {
= function (o) {
var assetPaginator = new YAHOO.widget.Paginator({
containers : ['pagination'],
pageLinks : 7,
rowsPerPage : 15,
template : "<strong>{CurrentPageReport}</strong> {PreviousPageLink} {PageLinks} {NextPageLink}"
});
};
/*---------------------------------------------------------------------------
WebGUI.AssetManager.initSearch ( )
Initialize the www_search page
*/
WebGUI.AssetManager.initSearch
= function () {
// Custom function to handle pagination requests
var handlePagination = function (state,dt) {
var sortedBy = dt.get('sortedBy');
// Define the new state
var newState = {
startIndex: state.recordOffset,
sorting: {
key: sortedBy.key,
dir: ((sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC) ? "desc" : "asc")
},
pagination : { // Pagination values
recordOffset: state.recordOffset, // Default to first page when sorting
rowsPerPage: dt.get("paginator").getRowsPerPage() // Keep current setting
}
};
// Create callback object for the request
var oCallback = {
success: dt.onDataReturnSetRows,
failure: dt.onDataReturnSetRows,
scope: dt,
argument: newState // Pass in new state as data payload for callback function to use
};
// Send the request
dt.getDataSource().sendRequest(WebGUI.AssetManager.BuildQueryString(newState), oCallback);
};
// Initialize the data table
WebGUI.AssetManager.DataTable
= new YAHOO.widget.DataTable( 'dataTableContainer',
WebGUI.AssetManager.ColumnDefs,
WebGUI.AssetManager.DataSource,
{
initialRequest : ';recordOffset=0',
generateRequest : WebGUI.AssetManager.BuildQueryString,
paginationEventHandler : handlePagination,
paginator : assetPaginator,
sortedBy : WebGUI.AssetManager.DefaultSortedBy
}
);
// Override function for custom server-side sorting
WebGUI.AssetManager.DataTable.sortColumn = function(oColumn) {
// Default ascending
var sDir = "asc";
// If already sorted, sort in opposite direction
if(oColumn.key === this.get("sortedBy").key) {
sDir = (this.get("sortedBy").dir === YAHOO.widget.DataTable.CLASS_ASC) ?
"desc" : "asc";
}
// Define the new state
var newState = {
startIndex: 0,
sorting: { // Sort values
key: oColumn.key,
dir: (sDir === "desc") ? YAHOO.widget.DataTable.CLASS_DESC : YAHOO.widget.DataTable.CLASS_ASC
},
pagination : { // Pagination values
recordOffset: 0, // Default to first page when sorting
rowsPerPage: this.get("paginator").getRowsPerPage() // Keep current setting
}
};
// Create callback object for the request
var oCallback = {
success: this.onDataReturnSetRows,
failure: this.onDataReturnSetRows,
scope: this,
argument: newState // Pass in new state as data payload for callback function to use
};
// Send the request
this.getDataSource().sendRequest(WebGUI.AssetManager.BuildQueryString(newState), oCallback);
};
};
@ -224,37 +305,6 @@ WebGUI.AssetManager.selectRow
}
};
/*---------------------------------------------------------------------------
WebGUI.AssetManager.showMoreMenu ( event, url )
Show the more menu located inside element.
*/
WebGUI.AssetManager.showMoreMenu
= function ( event, url ) {
var rawItems = WebGUI.AssetManager.MoreMenuItems;
var menuItems = [];
for ( var i = 0; i < rawItems.length; i++ ) {
var itemUrl = rawItems[i].url.match( /<url>/ )
? rawItems[i].url.replace( "<url>", url )
: url + rawItems[i].url
;
menuItems.push( '<li><a href="' + itemUrl + '">' + rawItems[i].label + "</a></li>" );
}
var options = {
"zindex" : 1000,
"clicktohide" : true,
"constraintoviewport" : true,
"xy" : [ event.clientX, event.clientY ],
"itemdata" : menuItems
};
var menu = new YAHOO.widget.Menu( "moreMenu", options );
menu.render( document.getElementById( 'assetManager' ) );
menu.show();
menu.focus();
};
/*---------------------------------------------------------------------------
WebGUI.AssetManager.toggleHighlightForRow ( checkbox )
Toggle the highlight for the row based on the state of the checkbox