<& /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'}} ) { % } % foreach my $var (qw(Query Format OrderBy Order Rows Page Token)) { %} <& /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)?$/', &>
<&| /Widgets/TitleBox, title => loc("Basics"), class => "asset-basics asset-bulk-basics", title_class => "inverse" &>
<& /Asset/Elements/SelectCatalog, Name => 'UpdateCatalog', UpdateSession => 0, ShowNullOption => 1 &>
<& /Asset/Elements/SelectStatus, Name => 'UpdateStatus', DefaultValue => 1 &>
<&| /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"; % } % }
% 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-bulk-cfs', title => loc('Edit [_1]', ($group? loc($group) : loc('Custom Fields')) ) &> <& /Elements/BulkCustomFields, CustomFields => $cfs, &> % } % } <&|/Widgets/TitleBox, title => loc('Edit Links'), color => "#336633"&> <& /Elements/BulkLinks, Collection => $assets, %ARGS &> <& /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; if ( $ARGS{Query} ) { $assets->FromSQL($ARGS{Query}); } else { %search = ProcessAssetsSearchArguments( Assets => $assets, Catalog => $catalog_obj, ARGSRef => \%ARGS, ); } $search{Format} ||= RT->Config->Get('AssetSearchFormat'); my $DisplayFormat = "'__CheckBox.{UpdateAsset}__',". ($ARGS{Format} || $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'}}, qw(Query Format OrderBy Order Rows Page Token) }, ); } <%ARGS> @UpdateAsset => ()