[Bps-public-commit] rt-extension-assets branch, user-assets-search-bulk, created. 1.02rc1-4-g0554a1a
Todd Wade
todd at bestpractical.com
Tue Nov 25 07:11:46 EST 2014
The branch, user-assets-search-bulk has been created
at 0554a1a7301e7ba54cbd7eec9389733c1648f22b (commit)
- Log -----------------------------------------------------------------
commit 0554a1a7301e7ba54cbd7eec9389733c1648f22b
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
- allow AllRoles params to pass through to bulk updater
- show null option in SelectCatalog when called as UpdateCatalog
* TitleRight UserAssets portlet callback
- callback for user to set titleright properties on UserAssets titlebox
- pass through titleright options in AssetList
diff --git a/html/Asset/Elements/SelectCatalog b/html/Asset/Elements/SelectCatalog
index 48e9df0..4ff9caa 100644
--- a/html/Asset/Elements/SelectCatalog
+++ b/html/Asset/Elements/SelectCatalog
@@ -48,7 +48,7 @@
<& /Elements/SelectObject,
Name => "Catalog",
ShowAll => $ShowAll,
- ShowNullOption => 0,
+ ShowNullOption => $ShowNullOption,
CheckRight => "CreateAsset",
%ARGS,
ObjectType => "Catalog",
@@ -61,8 +61,12 @@ $Default => undef
$UpdateSession => 1
</%args>
<%init>
+my $ShowNullOption = 0;
my $catalog_obj = LoadDefaultCatalog($Default || '');
-if ( $UpdateSession && $catalog_obj->Id ){
+
+if ( $ARGS{Name} && ($ARGS{Name} eq 'UpdateCatalog') ) {
+ $ShowNullOption = 1;
+} elsif ( $UpdateSession && $catalog_obj->Id ){
$session{'DefaultCatalog'} = $catalog_obj->Id;
$Default = $catalog_obj->Id;
}
diff --git a/html/Asset/Search/Bulk.html b/html/Asset/Search/Bulk.html
index 74fe7db..7f331d6 100644
--- a/html/Asset/Search/Bulk.html
+++ b/html/Asset/Search/Bulk.html
@@ -77,7 +77,7 @@
<table>
<tr class="asset-catalog">
<td class="label"><label for="UpdateCatalog"><&|/l&>Catalog</&></label></td>
- <td><& /Asset/Elements/SelectCatalog, Name => 'UpdateCatalog', Default => $catalog_obj->id, UpdateSession => 0, &></td>
+ <td><& /Asset/Elements/SelectCatalog, Name => 'UpdateCatalog', Default => ( $ARGS{'Catalog'} && $catalog_obj->id ), UpdateSession => 0, &></td>
</tr>
<tr class="asset-name">
<td class="label"><label for="UpdateName"><&|/l&>Name</&></label></td>
@@ -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/Callbacks/RT-Extension-Assets/Elements/Tabs/Privileged b/html/Callbacks/RT-Extension-Assets/Elements/Tabs/Privileged
index cc0c912..225b912 100644
--- a/html/Callbacks/RT-Extension-Assets/Elements/Tabs/Privileged
+++ b/html/Callbacks/RT-Extension-Assets/Elements/Tabs/Privileged
@@ -157,7 +157,7 @@ elsif ($Path =~ m{^/Asset/Search/}) {
my %search = map @{$_},
grep defined $_->[1] && length $_->[1],
map {ref $DECODED_ARGS->{$_} ? [$_, $DECODED_ARGS->{$_}[0]] : [$_, $DECODED_ARGS->{$_}] }
- grep /^(?:q|SearchAssets|!?(Name|Description|Catalog|Status|Role\..+|CF\..+)|Order(?:By)?|Page)$/,
+ grep /^(?:q|SearchAssets|!?(Name|Description|Catalog|Status|Role\..+|CF\..+)|Order(?:By)?|Page|AllRoles|PrincipalId)$/,
keys %$DECODED_ARGS;
if ( $Path =~ /Bulk/) {
$page->child('search',
diff --git a/html/User/Elements/AssetList b/html/User/Elements/AssetList
index ef5a6a9..90c24e7 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", %$titleright &>
<& /Elements/CollectionList,
Collection => $assets,
OrderBy => 'id',
@@ -75,4 +75,6 @@ $m->callback( CallbackName => 'ModifyFormat', %ARGS, Format => \$Format );
$User
$Title
@Roles
+$title_href => ''
+$titleright => {}
</%args>
diff --git a/html/User/Elements/Portlets/UserAssets b/html/User/Elements/Portlets/UserAssets
index 8bec6b1..6fd386d 100644
--- a/html/User/Elements/Portlets/UserAssets
+++ b/html/User/Elements/Portlets/UserAssets
@@ -45,8 +45,21 @@
%# 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;
+
+my $titleright_args = {};
+$m->callback( CallbackName => 'TitleRight', %ARGS, TitleRightArgs => $titleright_args );
+</%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,
+ titleright => $titleright_args,
+&>
<%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