%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2004 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., 675 Mass Ave, Cambridge, MA 02139, USA. %# %# %# 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("Create a new asset") &> <& /AssetTracker/Elements/Tabs, current_toptab => "AssetTracker/Asset/Create.html", Title => loc("Create a new asset") &> <& /Elements/ListActions, actions => \@results &>
<&| /Widgets/TitleBox, title => loc("Create a new asset") &> %foreach my $role ( $TypeObj->ActiveRoleArray() ) { %}
<&|/l&>Type: <% $TypeObj->Name %>
<&|/l&>Name:
<&|/l&>Status: <& /AssetTracker/Elements/SelectStatus, Name => "Status", Default => $ARGS{Status}||'new', DefaultValue => 0 &>
<% $role %>: <& /Elements/EmailInput, Name => $role, Size => 80, Default => $ARGS{$role} &>
<&|/l&>Description:
<& /AssetTracker/Asset/Elements/EditCustomFields, TypeObj => $TypeObj &>
% $m->callback( CallbackName => 'AfterBasics', TypeObj => $TypeObj, ARGSRef => \%ARGS ); <&| /Widgets/TitleBox, title => loc('Links'), class=> 'asset-info-links' &> <&|/l&>(Enter ticket ids or URLs, separated with spaces) %foreach my $type ( @link_order ) { % if ( $link_types{$type}{Mode} eq 'Target' ) { % } elsif ( $link_types{$type}{Mode} eq 'Base' ) { % } %}
<&|/l&><% $link_types{$type}{Name} %>" />" />
<&| /Widgets/TitleBox, title => 'Change Comment', class => 'asset-info-comment', width => "100%" &> <& /AssetTracker/Asset/Elements/ChangeComment, Name => "GlobalComment", Default => $ARGS{ChangeComment} &> <& /Elements/Submit, Label => loc("Create")&>




<%INIT> my %link_types = %{ RTx::AssetTracker::Asset::LINKTYPEMAP() }; my @link_order = RTx::AssetTracker::Asset::LINKORDER(); my $CloneAssetObj; if ($CloneAsset) { $CloneAssetObj = RTx::AssetTracker::Asset->new( $session{CurrentUser} ); $CloneAssetObj->Load($CloneAsset) or Abort( loc("Asset could not be loaded") ); my $clone = { }; foreach my $role ( $CloneAssetObj->TypeObj->ActiveRoleArray() ) { my $role_method = $role . 'RoleGroup'; $clone->{$role} = join( ',', $CloneAssetObj->$role_method->MemberEmailAddressesAsString ); } $clone->{$_} = $CloneAssetObj->$_() for qw/Name Description Status/; if (0) { # Temporarily disabled my $members = $CloneAssetObj->Members; my ( @members, @members_of, @refers, @refers_by, @depends, @depends_by ); my $refers = $CloneAssetObj->RefersTo; while ( my $refer = $refers->Next ) { push @refers, $refer->LocalTarget; } $clone->{'new-RefersTo'} = join ' ', @refers; my $refers_by = $CloneAssetObj->ReferredToBy; while ( my $refer_by = $refers_by->Next ) { push @refers_by, $refer_by->LocalBase; } $clone->{'RefersTo-new'} = join ' ', @refers_by; my $depends = $CloneAssetObj->DependsOn; while ( my $depend = $depends->Next ) { push @depends, $depend->LocalTarget; } $clone->{'new-DependsOn'} = join ' ', @depends; my $depends_by = $CloneAssetObj->DependedOnBy; while ( my $depend_by = $depends_by->Next ) { push @depends_by, $depend_by->LocalBase; } $clone->{'DependsOn-new'} = join ' ', @depends_by; while ( my $member = $members->Next ) { push @members, $member->LocalBase; } $clone->{'MemberOf-new'} = join ' ', @members; my $members_of = $CloneAssetObj->MemberOf; while ( my $member_of = $members_of->Next ) { push @members_of, $member_of->LocalTarget; } $clone->{'new-MemberOf'} = join ' ', @members_of; } my $cfs = $CloneAssetObj->TypeObj->AssetCustomFields(); while ( my $cf = $cfs->Next ) { my $cf_id = $cf->id; my $cf_values = $CloneAssetObj->CustomFieldValues( $cf->id ); my @cf_values; while ( my $cf_value = $cf_values->Next ) { push @cf_values, $cf_value->Content; } $clone->{"Object-RTx::AssetTracker::Asset--CustomField-$cf_id-Value"} = join "\n", @cf_values; } $clone->{'ChangeComment'} = "Cloned from asset #$CloneAsset."; for ( keys %$clone ) { $ARGS{$_} = $clone->{$_} if not defined $ARGS{$_}; } } my @results; my $TypeObj = new RTx::AssetTracker::Type($session{'CurrentUser'}); $TypeObj->Load($Type) || Abort(loc("Type could not be loaded.")); my $CFs = $TypeObj->AssetCustomFields(); my $ValidCFs = $m->comp( '/Elements/ValidateCustomFields', CustomFields => $CFs, ARGSRef => \%ARGS, NamePrefix => "Object-RTx::AssetTracker::Asset--CustomField-" ); if (defined($ARGS{'id'}) and $ARGS{'id'} eq 'new') { # new asset? if ( $ValidCFs ) { $m->comp('Display.html', %ARGS); $RT::Logger->crit("After display call; error is $@"); $m->abort(); } elsif ( !$ValidCFs ) { # Invalid CFs while (my $CF = $CFs->Next) { my $msg = $m->notes('InvalidField-' . $CF->Id) or next; push @results, $CF->Name . ': ' . $msg; } } } <%ARGS> $Type => undef $CloneAsset => undef