From a9ff59d7b2ff91cd736f7dbfa9ec73d444f75a92 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Wed, 21 Apr 2010 11:20:22 -0500 Subject: [PATCH] started asset helpers --- lib/WebGUI/Admin.pm | 17 +++++++++++++---- lib/WebGUI/Asset.pm | 28 ++++++++++++++++++++++++++++ www/extras/admin/admin.js | 20 +++++++++++++++----- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/lib/WebGUI/Admin.pm b/lib/WebGUI/Admin.pm index 0da88726b..1484da1fd 100644 --- a/lib/WebGUI/Admin.pm +++ b/lib/WebGUI/Admin.pm @@ -210,6 +210,7 @@ sub www_getTreeData { assetSize => $asset->assetSize, lockedBy => ($asset->isLockedBy ? $asset->lockedBy->username : ''), actions => $asset->canEdit && $asset->canEditIfLocked, + helpers => $asset->getHelpers, ); $fields{ className } = {}; @@ -225,6 +226,15 @@ sub www_getTreeData { $assetInfo->{ totalAssets } = $p->getRowCount; $assetInfo->{ sort } = $session->form->get( 'orderByColumn' ); $assetInfo->{ dir } = lc $session->form->get( 'orderByDirection' ); + $assetInfo->{ currentAsset } = { title => $asset->getTitle, helpers => $asset->getHelpers }; + + $assetInfo->{ crumbtrail } = []; + for my $asset ( @{ $asset->getLineage( ['ancestors'], { returnObjects => 1 } ) } ) { + push @{ $assetInfo->{crumbtrail} }, { + title => $asset->getTitle, + url => $asset->getUrl + }; + } $session->http->setMimeType( 'application/json' ); @@ -357,10 +367,9 @@ __DATA__
-
-
-
-
+
+
+
diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 7fefbd645..3d9ae1fad 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1172,6 +1172,34 @@ sub getExtraHeadTags { ; } +#---------------------------------------------------------------------------- + +=head2 getHelpers ( ) + +Get the AssetHelpers for this asset. + +=cut + +sub getHelpers { + my ( $self ) = @_; + + my $default = [ + { + class => 'WebGUI::AssetHelper::EditBranch', + label => 'Edit Branch', + }, + { + url => $self->getUrl( 'func=edit' ), + label => 'Edit', + }, + { + url => $self->getUrl( 'func=view' ), + label => 'View', + }, + ]; + + return $default; +} #------------------------------------------------------------------- diff --git a/www/extras/admin/admin.js b/www/extras/admin/admin.js index fe66f64c6..71928eef7 100644 --- a/www/extras/admin/admin.js +++ b/www/extras/admin/admin.js @@ -723,18 +723,18 @@ WebGUI.Admin.Tree.prototype.formatTitle = function ( elCell, oRecord, oColumn, orderNumber ) { elCell.innerHTML = '' + ( oRecord.getData( 'childCount' ) > 0 ? "+" : " " ) - + ' ' + + ' ' + oRecord.getData( 'title' ) - + '' + + '' ; }; WebGUI.Admin.Tree.prototype.goto = function ( assetUrl ) { var callback = { - success : this.dataTable.onDataReturnInitializeTable, - failure : this.dataTable.onDataReturnInitializeTable, - scope : this.dataTable, + success : this.onDataReturnInitializeTable, + failure : this.onDataReturnInitializeTable, + scope : this, argument: this.dataTable.getState() }; @@ -748,6 +748,16 @@ WebGUI.Admin.Tree.prototype.goto ); }; +/** + * onDataReturnInitializeTable ( sRequest, oResponse, oPayload ) + * Initialize the table with a new response from the server + */ +WebGUI.Admin.Tree.prototype.onDataReturnInitializeTable += function ( sRequest, oResponse, oPayload ) { + this.dataTable.onDataReturnInitializeTable.call( this.dataTable, sRequest, oResponse, oPayload ); + +}; + /** * removeHighlightFromRow ( child ) * Remove the highlight from a row by removing the "highlight" class.