diff --git a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm index 9d05f0cbc..f4535b78b 100644 --- a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm +++ b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm @@ -935,6 +935,16 @@ sub www_edit { $session->errorHandler->error("Couldn't demote asset '$assetId' because we couldn't instantiate it."); } } + elsif ( $form->get("delete") ) { + my $assetId = $form->get("delete"); + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); + if ( $asset ) { + $asset->purge; + } + else { + $session->errorHandler->error( "Couldn't delete asset '$assetId' because we couldn't instanciate it."); + } + } # Generate the form if ($form->get("func") eq "add") { @@ -972,6 +982,7 @@ sub www_edit { = WebGUI::Form::submit( $session, { name => "cancel", value => $i18n->get("cancel"), + extras => 'onclick="history.go(-1)"', }); } $var->{ form_start } @@ -1016,21 +1027,31 @@ sub www_edit { # Raw HTML here to provide proper value for the image $file->{ form_promote } - = qq{} ; $file->{ form_demote } - = qq{} ; + my $deleteConfirm = $i18n->get( 'template delete message' ); + $file->{ form_delete } + = qq!} + ; + $file->{ form_synopsis } - = WebGUI::Form::text( $session, { + = WebGUI::Form::HTMLArea( $session, { name => "fileSynopsis_$file->{assetId}", value => $form->get( "fileSynopsis_$file->{assetId}" ) || $file->{ synopsis }, + richEditId => $self->getParent->get( 'richEditIdFile' ), + height => 150, + width => 400, }); } diff --git a/lib/WebGUI/Content/AssetManager.pm b/lib/WebGUI/Content/AssetManager.pm index 4b060cde8..d0bac6814 100644 --- a/lib/WebGUI/Content/AssetManager.pm +++ b/lib/WebGUI/Content/AssetManager.pm @@ -162,6 +162,8 @@ sub getMoreMenu { ### The More menu my @more_fields = (); + # FIXME: Add a show callback with the record as first argument. If it + # returns true, the URL will be shown. # These links are shown based on UI level if ( $userUiLevel >= $toolbarUiLevel->{ "changeUrl" } ) { push @more_fields, { @@ -391,7 +393,7 @@ sub www_manage { YAHOO.util.Event.onDOMReady( WebGUI.AssetManager.initManager ); ENDHTML - my $output = '
' . getHeader( $session ); + my $output = '
' . getHeader( $session ); ### Crumbtrail my $crumb_markup = '
  • %s >
  • '; @@ -413,7 +415,7 @@ ENDHTML $output .= ''; ### The page of assets - $output .= q{
    } + $output .= q{
    } . q{
    } . q{} . q{} @@ -514,8 +516,6 @@ ENDHTML ; $output .= <<'ENDJS'; -// Initialize the datatable and datasource -YAHOO.util.Event.onDOMReady(function () { // Start the data source WebGUI.AssetManager.DataSource = new YAHOO.util.DataSource( '?op=assetManager;method=ajaxGetManagerPage' ); @@ -540,14 +540,8 @@ YAHOO.util.Event.onDOMReady(function () { ] }; - var assetPaginator = new YAHOO.widget.Paginator({ - containers : ['pagination'], - pageLinks : 7, - rowsPerPage : 15, - template : "{CurrentPageReport} {PreviousPageLink} {PageLinks} {NextPageLink}" - }); - - function buildQueryString( state, dt ) { + WebGUI.AssetManager.BuildQueryString + = function ( state, dt ) { var query = ";recordOffset=" + state.pagination.recordOffset + ';orderByDirection=' + ((state.sorting.dir === YAHOO.widget.DataTable.CLASS_DESC) ? "DESC" : "ASC") + ';rowsPerPage=' + state.pagination.rowsPerPage @@ -556,35 +550,6 @@ YAHOO.util.Event.onDOMReady(function () { return query; }; - // 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(buildQueryString(newState), oCallback); - }; - ENDJS $output .= q( @@ -602,55 +567,8 @@ ENDJS ); $output .= <<'ENDJS'; - WebGUI.AssetManager.DataTable - = new YAHOO.widget.DataTable( 'dataTableContainer', - WebGUI.AssetManager.ColumnDefs, - WebGUI.AssetManager.DataSource, - { - initialRequest : ';recordOffset=0', - generateRequest : buildQueryString, - paginationEventHandler : handlePagination, - paginator : assetPaginator, - sortedBy : { key : "lineage", dir : YAHOO.widget.DataTable.CLASS_ASC } - } - ); - // 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(buildQueryString(newState), oCallback); - }; -} ); + YAHOO.util.Event.onDOMReady( WebGUI.AssetManager.initManager ); ENDJS @@ -669,7 +587,7 @@ sub www_search { my $session = shift; my $ac = WebGUI::AdminConsole->new( $session, "assets" ); my $i18n = WebGUI::International->new( $session, "Asset" ); - my $output = '
    ' . getHeader( $session ); + my $output = '
    ' . getHeader( $session ); $session->style->setLink( $session->url->extras( 'yui-webgui/build/assetManager/assetManager.css' ), { rel => "stylesheet", type => 'text/css' } ); $session->style->setScript( $session->url->extras( 'yui/build/yahoo-dom-event/yahoo-dom-event.js' ) ); @@ -749,11 +667,11 @@ ENDHTML $output .= q{}; } - $output .= q{} + $output .= q{
    } . q{} . q{} . q{} # Checkbox column - . q{} # Edit / More + . q{} # Edit . q{} # Title . q{} # Type . q{} # Revision Date @@ -767,7 +685,7 @@ ENDHTML # The markup for a single asset my $row_markup = q{} . q{} - . q{} + . q{} . q{} . q{} . q{} @@ -780,7 +698,7 @@ ENDHTML my @row_fields = qw( alt assetId - editLink moreMenu + editLink title iconUrl type revisionDate @@ -795,7 +713,7 @@ ENDHTML # Populate the required fields to fill in my %fields = ( - alt => ( $count % 3 == 0 ? 'class="alt"' : '' ), + alt => ( $count % 2 == 0 ? 'class="alt"' : '' ), assetId => $asset->getId, url => $asset->getUrl, title => $asset->get( "title" ), @@ -832,14 +750,11 @@ ENDHTML # The edit link if ( !$asset->lockedBy || $asset->canEditIfLocked ) { $fields{ editLink } - = sprintf '' . $i18n->get( "edit" ) . ' |', + = sprintf '' . $i18n->get( "edit" ) . '', $asset->getUrl( 'func=edit' ) ; } - # The More menu - $fields{ moreMenu } = getMoreMenu( $session, $i18n->get( "menu label" ) ); - $output .= sprintf $row_markup, @fields{ @row_fields }; } diff --git a/lib/WebGUI/Help/Asset_GalleryAlbum.pm b/lib/WebGUI/Help/Asset_GalleryAlbum.pm index 3eb2e23c4..76c56424e 100644 --- a/lib/WebGUI/Help/Asset_GalleryAlbum.pm +++ b/lib/WebGUI/Help/Asset_GalleryAlbum.pm @@ -295,6 +295,22 @@ our $HELP = { name => 'isAlbumThumbnail', description => 'helpvar isAlbumThumbnail', }, + { + name => 'form_promote', + description => 'helpvar form_promote', + }, + { + name => 'form_demote', + description => 'helpvar form_demote', + }, + { + name => 'form_synopsis', + description => 'helpvar form_synopsis', + }, + { + name => 'form_delete', + description => 'helpvar form_delete', + }, ], }, ], diff --git a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm index d078e4777..93c10f9a2 100644 --- a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm +++ b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm @@ -490,6 +490,30 @@ our $I18N = { context => q{Description of template variable}, }, + 'helpvar form_promote' => { + message => q{A button to promote the image in the ranking. Use these to move images in the order.}, + lastUpdated => 0, + context => q{Description of template variable}, + }, + + 'helpvar form_demote' => { + message => q{A button to demote the image in the ranking. Use these to move images in the order.}, + lastUpdated => 0, + context => q{Description of template variable}, + }, + + 'helpvar form_delete' => { + message => q{A button to delete the image.}, + lastUpdated => 0, + context => q{Description of template variable}, + }, + + 'helpvar form_synopsis' => { + message => q{An HTML Area for the image thumbnail.}, + lastUpdated => 0, + context => q{Description of template variable}, + }, + }; 1; diff --git a/www/extras/yui-webgui/build/assetManager/assetManager.css b/www/extras/yui-webgui/build/assetManager/assetManager.css index db7aa8aae..7e83ba588 100644 --- a/www/extras/yui-webgui/build/assetManager/assetManager.css +++ b/www/extras/yui-webgui/build/assetManager/assetManager.css @@ -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; +} + + diff --git a/www/extras/yui-webgui/build/assetManager/assetManager.js b/www/extras/yui-webgui/build/assetManager/assetManager.js index 5f373ec39..399bf795a 100644 --- a/www/extras/yui-webgui/build/assetManager/assetManager.js +++ b/www/extras/yui-webgui/build/assetManager/assetManager.js @@ -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( "", oRecord.getData( 'url' ) ) : oRecord.getData( 'url' ) + rawItems[i].url ; - menuItems.push( '
  • ' + rawItems[i].label + "
  • " ); + 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 : "{CurrentPageReport} {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( // ) - ? rawItems[i].url.replace( "", url ) - : url + rawItems[i].url - ; - menuItems.push( '
  • ' + rawItems[i].label + "
  • " ); - } - - 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
      } . $i18n->get( '99' ) . q{} . $i18n->get( "type" ) . q{} . $i18n->get( "last updated" ) . q{
    %s %s%s%s %s%s