%doc>
User Interface for Cable Strand Operations
%doc>
<%args>
$id => undef;
$backbone_id => undef;
$edit => undef;
$_action => undef;
$__splice1 => undef;
$__splice2 => undef;
$user => $ui->get_current_user($r)
%args>
<%attr>
title => 'Cable Strand'
%attr>
<%init>
my $DEBUG = 0;
my $o = undef;
my $edit_strand = 0;
if ( $id && $id ne "NEW" ){
$o = CableStrand->retrieve($id);
$backbone_id = $o->cable;
}
$edit_strand = 1 if ($id eq "NEW" || $edit eq "strandinfo");
# For /generic/attribute_table.mhtml
my (@field_headers, @cell_data);
my $manager = $ui->get_permission_manager($r);
%init>
<%perl>
print "
", Dumper(%ARGS), "
" if $DEBUG;
# code for inserting/updating
# -----------------------------------------------------------------------------
if ( defined($_action) ) {
print "ARGS is
", Dumper(%ARGS), "
" if $DEBUG;
my %update_info = ();
if ( !(%update_info = $ui->form_to_db(%ARGS)) ){
$m->comp("../generic/error.mhtml", error => $ui->error());
}
if ( $update_info{CableStrand}{id} ){
$id = (keys %{$update_info{CableStrand}{id}})[0];
$edit_strand = 0;
}
# Do this to 'flush' the values associated with the object
# before redisplaying
$o = undef;
$o = CableStrand->retrieve($id) if ( $id && $id ne "NEW" );
# Special case for splices, store in many to many table...
if ( defined($__splice1) || defined($__splice2) ){
# first delete all splices for this cable strand.
$o->delete_splices();
# and now add back any splices...
my @splices = ("__splice1", "__splice2");
foreach my $sp ( @splices ){
next if (!defined($ARGS{$sp}) || $ARGS{$sp} eq "");
Splice->insert({strand1=>$o, strand2=>$ARGS{$sp}});
}
}
}
# end insertion/update code
# -----------------------------------------------------------------------------
%perl>
% # interface...
% # ---------------------------------------------------------------------------