begin edit form

This commit is contained in:
Doug Bell 2010-04-23 13:42:57 -05:00
parent 794c85c65a
commit cbb5c7a11a
2 changed files with 69 additions and 34 deletions

View file

@ -209,7 +209,7 @@ sub www_getTreeData {
childCount => $asset->getChildCount, childCount => $asset->getChildCount,
assetSize => $asset->assetSize, assetSize => $asset->assetSize,
lockedBy => ($asset->isLockedBy ? $asset->lockedBy->username : ''), lockedBy => ($asset->isLockedBy ? $asset->lockedBy->username : ''),
actions => $asset->canEdit && $asset->canEditIfLocked, canEdit => $asset->canEdit && $asset->canEditIfLocked,
helpers => $asset->getHelpers, helpers => $asset->getHelpers,
); );

View file

@ -79,10 +79,37 @@ WebGUI.Admin.prototype.afterShowViewTab
}; };
/** /**
* go( url ) * appendToUrl( url, params )
* Open the view tab and go to the given URL. * Add URL components to a URL;
* Should not be used for assets, use gotoAsset() instead
*/ */
appendToUrl
= function ( url, params ) {
var components = [ url ];
if (url.match(/\?/)) {
components.push(";");
}
else {
components.push("?");
}
components.push(params);
return components.join('');
};
/**
* editAsset( url )
* Show the edit form for the asset at the given URL
*/
WebGUI.Admin.prototype.editAsset
= function ( url ) {
// Open the edit form
window.frames["view"].location.href = appendToUrl( url, "func=edit" );
// Mark undirty, as we'll clean it ourselves
this.viewDirty = 0;
// Show the view tab
this.tabBar.selectTab( 0 );
};
/** /**
* gotoAsset( url ) * gotoAsset( url )
@ -101,6 +128,30 @@ WebGUI.Admin.prototype.gotoAsset
} }
}; };
/**
* makeEditAsset( url )
* Create a callback to edit an asset. Use when attaching to event listeners
*/
WebGUI.Admin.prototype.makeEditAsset
= function (url) {
var self = this;
return function() {
self.editAsset( url );
};
};
/**
* makeGotoAsset( url )
* Create a callback to view an asset. Use when attaching to event listeners
*/
WebGUI.Admin.prototype.makeGotoAsset
= function ( url ) {
var self = this;
return function() {
self.gotoAsset( url );
};
};
/** /**
* navigate( assetDef ) * navigate( assetDef )
* We've navigated to a new asset. Called by the view iframe when a new * We've navigated to a new asset. Called by the view iframe when a new
@ -445,7 +496,7 @@ WebGUI.Admin.Tree
fields: [ fields: [
{ key: 'assetId' }, { key: 'assetId' },
{ key: 'lineage' }, { key: 'lineage' },
{ key: 'actions' }, { key: 'canEdit' },
{ key: 'title' }, { key: 'title' },
{ key: 'className' }, { key: 'className' },
{ key: 'revisionDate' }, { key: 'revisionDate' },
@ -498,23 +549,6 @@ WebGUI.Admin.Tree
}; };
/**
* appendToUrl( url, params )
* Add URL components to a URL;
*/
appendToUrl
= function ( url, params ) {
var components = [ url ];
if (url.match(/\?/)) {
components.push(";");
}
else {
components.push("?");
}
components.push(params);
return components.join('');
};
/** /**
* addHighlightToRow ( child ) * addHighlightToRow ( child )
* Highlight the row containing this element by adding to it the "highlight" * Highlight the row containing this element by adding to it the "highlight"
@ -610,16 +644,17 @@ WebGUI.Admin.Tree.prototype.findRow
*/ */
WebGUI.Admin.Tree.prototype.formatActions WebGUI.Admin.Tree.prototype.formatActions
= function ( elCell, oRecord, oColumn, orderNumber ) { = function ( elCell, oRecord, oColumn, orderNumber ) {
if ( oRecord.getData( 'actions' ) ) { if ( oRecord.getData( 'canEdit' ) ) {
elCell.innerHTML var edit = document.createElement("span");
= '<a href="' + appendToUrl(oRecord.getData( 'url' ), 'func=edit;proceed=manageAssets') + '">' edit.className = "clickable";
+ window.admin.i18n.get('Asset', 'edit') + '</a>' YAHOO.util.Event.addListener( edit, "click", function(){
+ ' | ' window.admin.editAsset( oRecord.getData('url') );
; }, window.admin, true );
} edit.appendChild( document.createTextNode( window.admin.i18n.get('Asset', 'edit') ) );
else { elCell.appendChild( edit );
elCell.innerHTML = ""; elCell.appendChild( document.createTextNode( " | " ) );
} }
return; // TODO return; // TODO
var more = document.createElement( 'a' ); var more = document.createElement( 'a' );
elCell.appendChild( more ); elCell.appendChild( more );
@ -632,7 +667,7 @@ WebGUI.Admin.Tree.prototype.formatActions
oldMenu.parentNode.removeChild( oldMenu ); oldMenu.parentNode.removeChild( oldMenu );
} }
var options = this.buildMoreMenu(oRecord.getData( 'url' ), more, oRecord.getData( 'actions' )); var options = this.buildMoreMenu(oRecord.getData( 'url' ), more, oRecord.getData( 'canEdit' ));
var menu = new YAHOO.widget.Menu( "moreMenu" + oRecord.getData( 'assetId' ), options ); var menu = new YAHOO.widget.Menu( "moreMenu" + oRecord.getData( 'assetId' ), options );
YAHOO.util.Event.onDOMReady( function () { menu.render( document.getElementById( 'assetManager' ) ); } ); YAHOO.util.Event.onDOMReady( function () { menu.render( document.getElementById( 'assetManager' ) ); } );
@ -783,7 +818,7 @@ WebGUI.Admin.Tree.prototype.onDataReturnInitializeTable
var item = crumb[i]; var item = crumb[i];
var elItem = document.createElement( "span" ); var elItem = document.createElement( "span" );
elItem.className = "clickable"; elItem.className = "clickable";
YAHOO.util.Event.addListener( elItem, "click", function(){ window.admin.gotoAsset( item.url ) }, this, true ); YAHOO.util.Event.addListener( elItem, "click", window.admin.makeGotoAsset(item.url) );
elItem.appendChild( document.createTextNode( item.title ) ); elItem.appendChild( document.createTextNode( item.title ) );
elCrumb.appendChild( elItem ); elCrumb.appendChild( elItem );
@ -879,7 +914,7 @@ WebGUI.Admin.Tree.prototype.toggleHighlightForRow
*/ */
WebGUI.Admin.Tree.prototype.toggleRow = function ( child ) { WebGUI.Admin.Tree.prototype.toggleRow = function ( child ) {
var row = this.findRow( child ); var row = this.findRow( child );
// Find the checkbox // Find the checkbox
var inputs = row.getElementsByTagName( "input" ); var inputs = row.getElementsByTagName( "input" );
for ( var i = 0; i < inputs.length; i++ ) { for ( var i = 0; i < inputs.length; i++ ) {