%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) %# %# %# LICENSE: %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org. %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA %# 02110-1301 or visit their web page on the internet at %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: %# %# (The following paragraph is not intended to limit the rights granted %# to you to modify and distribute this software under the terms of %# the GNU General Public License and is only of importance to you if %# you choose to contribute your changes and enhancements to the %# community by submitting them to Best Practical Solutions, LLC.) %# %# By intentionally submitting any modifications, corrections or %# derivatives to this work, or any other work intended for use with %# Request Tracker, to Best Practical Solutions, LLC, you confirm that %# you are the copyright holder for those contributions and you grant %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, %# royalty-free, perpetual, license to use, copy, create derivative %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} <& /Elements/Header, Title => loc("Assets") &> <& /Elements/Tabs &> % $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Assets => $assets, Actions => \@results); <& /Elements/ListActions, actions => \@results &>
% foreach my $var ( @{$search{'PassArguments'}} ) { % } <& /Elements/CollectionList, %search, Collection => $assets, AllowSorting => 1, DisplayFormat => $DisplayFormat, &> % if (not $assets->Count) { <&|/l&>No assets matching search criteria found. % } <& /Elements/Submit, Name => 'Update', Label => loc('Update'), CheckboxNameRegex => '/^UpdateAsset(All)?$/', CheckAll => 1, ClearAll => 1, &>
<&| /Widgets/TitleBox, title => loc("Basics"), class => "asset-basics asset-bulk-basics", title_class => "inverse" &>
<& /Asset/Elements/SelectCatalog, Name => 'UpdateCatalog', Default => $catalog_obj->id, UpdateSession => 0, &>
<& /Asset/Elements/SelectStatus, Name => 'UpdateStatus', DefaultValue => 1, Catalogs => { $catalog_obj->id => $catalog_obj } &>
% my $cfs = $catalog_obj->AssetCustomFields; % $cfs->LimitToGrouping( 'RT::Asset' => 'Basics'); % if ( $cfs->Count ) { <& /Elements/BulkCustomFields, CustomFields => $cfs, &> % } <&| /Widgets/TitleBox, title => loc("People"), class => "asset-people asset-bulk-people", title_class => "inverse" &> % for my $rname ( $asset->Roles( ACLOnly => 0 ) ) { % my $role = $asset->Role( $rname ); % if ( $role->{'Single'} ) { % my $input = "SetRoleMember-$rname"; % } else { % my $input = "AddRoleMember-$rname"; % $input = "RemoveRoleMember-$rname"; % } % } % my $cfs = $catalog_obj->AssetCustomFields; % $cfs->LimitToGrouping( 'RT::Asset' => 'People'); % if ( $cfs->Count ) { <& /Elements/BulkCustomFields, CustomFields => $cfs, &> % }
% my $cfs = $catalog_obj->AssetCustomFields; % $cfs->LimitToGrouping( 'RT::Asset' => 'Dates'); % if ( $cfs->Count ) { <&| /Widgets/TitleBox, title => loc("Dates"), class => "asset-dates asset-bulk-dates", title_class => "inverse" &> <& /Elements/BulkCustomFields, CustomFields => $cfs, &> % } % for my $group ( RT::CustomField->CustomGroupings( 'RT::Asset' ), '' ) { % my $cfs = $catalog_obj->AssetCustomFields; % $cfs->LimitToGrouping( 'RT::Asset' => $group); % if ( $cfs->Count ) { <&| /Widgets/TitleBox, class=>'asset-bulk-grouping asset-info-cfs asset-bulk-cfs', title => loc('Edit [_1]', ($group? loc($group) : loc('Custom Fields')) ), title_class => "inverse" &> <& /Elements/BulkCustomFields, CustomFields => $cfs, &> % } % } <&|/Widgets/TitleBox, title => loc('Edit Links'), class => "asset-links asset-bulk-links", title_class => "inverse" &> <& /Elements/BulkLinks, Collection => $assets, %ARGS &> % my $cfs = $catalog_obj->AssetCustomFields; % $cfs->LimitToGrouping( 'RT::Asset' => 'Links'); % if ( $cfs->Count ) { <& /Elements/BulkCustomFields, CustomFields => $cfs, &> % } <& /Elements/Submit, Label => loc('Update'), Name => 'Update' &>
<%INIT> my @results; $m->callback(ARGSRef => \%ARGS, Results => \@results, CallbackName => 'Initial'); my $catalog_obj = LoadDefaultCatalog($ARGS{'Catalog'} || ''); $ARGS{'Catalog'} = $catalog_obj->Id; my $assets = RT::Assets->new($session{CurrentUser}); my %search = ProcessAssetsSearchArguments( Assets => $assets, Catalog => $catalog_obj, ARGSRef => \%ARGS, ); my $DisplayFormat = "'__CheckBox.{UpdateAsset}__',". $search{'Format'}; $DisplayFormat =~ s/\s*,\s*('?__NEWLINE__'?)/,$1,''/gi; my $asset = RT::Asset->new( $session{'CurrentUser'} ); delete $ARGS{$_} foreach grep { $ARGS{$_} =~ /^$/ } keys %ARGS; $DECODED_ARGS->{'UpdateAssetAll'} = 1 unless @UpdateAsset; if ( $ARGS{'CreateLinkedTicket'} ){ my $url = RT->Config->Get('WebURL') . "Asset/CreateLinkedTicket.html"; $url .= '?'. $m->comp( '/Elements/QueryString', 'Assets' => \@UpdateAsset ); RT::Interface::Web::Redirect($url); } elsif ( $ARGS{Update} ) { my @attributes = $asset->WritableAttributes; @attributes = grep exists $ARGS{ 'Update'. $_ }, @attributes; my %basics = map { $_ => $ARGS{ 'Update'. $_ } } @attributes; foreach my $aid ( @UpdateAsset ) { my $asset = LoadAsset($aid); my @tmp_res; push @tmp_res, UpdateRecordObject( Object => $asset, AttributesRef => \@attributes, ARGSRef => \%basics, ); push @tmp_res, ProcessAssetRoleMembers( $asset => %ARGS ); push @tmp_res, ProcessObjectCustomFieldUpdates( Object => $asset, ARGSRef => \%ARGS ); push @tmp_res, ProcessRecordLinks( RecordObj => $asset, RecordId => 'Asset', ARGSRef => \%ARGS ); push @tmp_res, ProcessRecordBulkCustomFields( RecordObj => $asset, ARGSRef => \%ARGS ); push @results, map { loc( "Asset #[_1]: [_2]", $asset->id, $_ ) } @tmp_res; } MaybeRedirectForResults( Actions => \@results, Arguments => { map { $_ => $ARGS{$_} } grep { defined $ARGS{$_} } @{$search{'PassArguments'}} }, ); } <%ARGS> @UpdateAsset => ()