[Bps-public-commit] rt-extension-assets branch, user-assets-search-bulk, created. 1.02rc1-4-gf494df2

Todd Wade todd at bestpractical.com
Thu Nov 6 17:14:39 EST 2014


The branch, user-assets-search-bulk has been created
        at  f494df2fccc5281f9b34722e0c267e904ed6417b (commit)

- Log -----------------------------------------------------------------
commit f494df2fccc5281f9b34722e0c267e904ed6417b
Author: Todd Wade <todd at bestpractical.com>
Date:   Thu Nov 6 17:09:50 2014 -0500

    allow searching and bulk updates for all of a user's assets
    
    * update AssetList to link to search showing the assets listed
    * update asset searching to list all of a user's assets
      - added AllRoles mode to ProcessAssetsSearchArguments
      - updated code to not restrict on catalog when in this mode
    
    * update asset bulk update to allow updating for all assets for a user
      - still in progress, its still restricting to default catalog
      - probably need to deal with unwantedly overwriting catalog

diff --git a/html/Asset/Search/Bulk.html b/html/Asset/Search/Bulk.html
index 74fe7db..f358853 100644
--- a/html/Asset/Search/Bulk.html
+++ b/html/Asset/Search/Bulk.html
@@ -149,7 +149,9 @@ my @results;
 $m->callback(ARGSRef => \%ARGS, Results => \@results, CallbackName => 'Initial');
 
 my $catalog_obj = LoadDefaultCatalog($ARGS{'Catalog'} || '');
-$ARGS{'Catalog'} = $catalog_obj->Id;
+if ( ! $ARGS{AllRoles} ) {
+    $ARGS{'Catalog'} = $catalog_obj->Id;
+}
 
 my $assets = RT::Assets->new($session{CurrentUser});
 my %search = ProcessAssetsSearchArguments(
diff --git a/html/Asset/Search/index.html b/html/Asset/Search/index.html
index a0eb3fd..e8929f6 100644
--- a/html/Asset/Search/index.html
+++ b/html/Asset/Search/index.html
@@ -47,7 +47,9 @@
 %# END BPS TAGGED BLOCK }}}
 <%init>
 my $catalog_obj = LoadDefaultCatalog($ARGS{'Catalog'} || '');
-$ARGS{'Catalog'} = $catalog_obj->Id;
+if ( ! $ARGS{AllRoles} ) {
+    $ARGS{'Catalog'} = $catalog_obj->Id;
+}
 
 my $assets = RT::Assets->new($session{CurrentUser});
 my %search = ProcessAssetsSearchArguments(
diff --git a/html/User/Elements/AssetList b/html/User/Elements/AssetList
index ef5a6a9..bdab06c 100644
--- a/html/User/Elements/AssetList
+++ b/html/User/Elements/AssetList
@@ -62,7 +62,7 @@ my $Format = q[
 ];
 $m->callback( CallbackName => 'ModifyFormat', %ARGS, Format => \$Format );
 </%init>
-<&| /Widgets/TitleBox, title => $Title, class => "user asset-list" &>
+<&| /Widgets/TitleBox, title => $Title, title_href => $title_href, class => "user asset-list" &>
     <& /Elements/CollectionList,
         Collection      => $assets,
         OrderBy         => 'id',
@@ -75,4 +75,5 @@ $m->callback( CallbackName => 'ModifyFormat', %ARGS, Format => \$Format );
 $User
 $Title
 @Roles
+$title_href => ''
 </%args>
diff --git a/html/User/Elements/Portlets/UserAssets b/html/User/Elements/Portlets/UserAssets
index 8bec6b1..567cbf1 100644
--- a/html/User/Elements/Portlets/UserAssets
+++ b/html/User/Elements/Portlets/UserAssets
@@ -45,8 +45,17 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
+<%init>
+my $format = RT->Config->Get('WebPath') . '/Asset/Search/index.html?AllRoles=1&PrincipalId=%d&SearchAssets=Search';
+my $search = sprintf $format, $User->PrincipalId;
+</%init>
 %# Roles => [''] triggers the magical RoleLimit behavior that matches any role
-<& /User/Elements/AssetList, User => $User, Roles => [''], Title => loc('Assigned Assets') &>
+<& /User/Elements/AssetList,
+    User       => $User,
+    Roles      => [''],
+    Title      => loc('Assigned Assets'),
+    title_href => $search,
+&>
 <%ARGS>
 $User
 </%ARGS>
diff --git a/lib/RT/Extension/Assets.pm b/lib/RT/Extension/Assets.pm
index 83145fa..91ba2ed 100644
--- a/lib/RT/Extension/Assets.pm
+++ b/lib/RT/Extension/Assets.pm
@@ -258,6 +258,13 @@ RT->AddJavaScript("RTx-Assets.js");
                         VALUE => $value,
                         ENTRYAGGREGATOR => "AND",
                     );
+                } elsif ($key eq 'AllRoles') {
+                    $args{'Assets'}->RoleLimit(
+                        TYPE      => '',
+                        VALUE     => $ARGSRef->{PrincipalId},
+                        SUBCLAUSE => "Role",
+                    );
+                    push @PassArguments, 'PrincipalId';
                 } elsif ($key =~ /^Role\.(.+)/) {
                     my $role = $1;
                     $args{'Assets'}->RoleLimit(
@@ -299,8 +306,8 @@ RT->AddJavaScript("RTx-Assets.js");
         }
 
         my $Format = RT->Config->Get('AssetSearchFormat');
-        $Format = $Format->{$args{'Catalog'}->id}
-            || $Format->{$args{'Catalog'}->Name}
+        $Format = $Format->{$args{'Catalog'} && $args{'Catalog'}->id}
+            || $Format->{$args{'Catalog'} && $args{'Catalog'}->Name}
             || $Format->{''} if ref $Format;
         $Format ||= q[
             '<b><a href="__WebPath__/Asset/Display.html?id=__id__">__id__</a></b>/TITLE:#',

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list