<%doc> User Interface for Cable Strand Operations <%args> $id => undef; $backbone_id => undef; $edit => undef; $_action => undef; $__splice1 => undef; $__splice2 => undef; $user => $ui->get_current_user($r) <%attr> title => 'Cable Strand' <%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); <%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 # ----------------------------------------------------------------------------- % # interface... % # ---------------------------------------------------------------------------
Cable Strand: % if (defined($o)) { <% $o->name %> % }
"> % if ($edit_strand) { % } else { % if ( $manager && $manager->can($user, 'access_admin_section', 'cable_strand:new') ){ [new] % } % if ( $manager && $manager->can($user, 'edit', $o) ){ [edit] % } % if ( $manager && $manager->can($user, 'delete', $o) ){ [delete] % }   % }
<%perl> (@field_headers, @cell_data) = (); push( @field_headers, "Name: " ); push( @cell_data, $ui->form_field(object=>$o, table=>"CableStrand", column=>"name", edit=>$edit_strand, returnValOnly=>1) ); push( @field_headers, "Number: " ); push( @cell_data, $o ? $o->number : "" ); push( @field_headers, "Backbone: " ); if ( !$edit_strand ){ push( @cell_data, ''.$o->cable->name.'' ); }else{ push( @cell_data, $ui->form_field(object=>$o, table=>"CableStrand", column=>"cable", lookup=>"BackboneCable", edit=>$edit_strand, returnValOnly=>1) ); } push( @field_headers, "Status: " ); push( @cell_data, $ui->form_field(object=>$o, table=>"CableStrand", column=>"status", lookup=>"StrandStatus", edit=>$edit_strand, returnValOnly=>1) ); push( @field_headers, "Spliced with: " ); <&| "/generic/HERE.mhtml" &> % if ( !$edit_strand ){ % my @splices = $o->splices; % if (scalar(@splices)) { <% $splices[0]->strand2->name %> % } % if (scalar(@splices) == 2) { , <% $splices[1]->strand2->name %> % } % } elsif ($edit_strand && defined($o)) { <%perl> # first we need to grab all backbones for start and end sites of this strand. my ($start_site, $end_site) = ($o->cable->start_closet->room->floor->site, $o->cable->end_closet->room->floor->site) if ($o->cable->start_closet->room->floor && $o->cable->end_closet->room->floor); my @backbones = (); if ($start_site && $end_site){ foreach my $closet (($start_site->closets, $end_site->closets)){ map { push (@backbones, $_) } (BackboneCable->search(start_closet=>$closet), BackboneCable->search(end_closet=>$closet)); } }  
  % } <%perl> push( @cell_data, $_ ); if ( defined($o) && !$edit_strand ){ push( @field_headers, "Part of Sequence:" ); my @strands = ($o); push( @cell_data, $m->scomp( "display_sequence.mhtml", strands=>\@strands ) ); } push( @field_headers, "Circuit: " ); push( @cell_data, $ui->form_field(object=>$o, column=>"circuit_id", lookup=>"Circuit", edit=>$edit_strand, returnValOnly=>1, linkPage => "circuit.html") ); push( @field_headers, "Fiber Type: " ); push( @cell_data, $ui->form_field(object=>$o, column=>"fiber_type", lookup=>"FiberType", edit=>$edit_strand, returnValOnly=>1) ); push( @field_headers, "Description: " ); push( @cell_data, $ui->form_field(object=>$o, column=>"description", edit=>$edit_strand, returnValOnly=>1) ); <& /generic/attribute_table.mhtml, width=>"2", field_headers=>\@field_headers, data=>\@cell_data &>
Comments:
<% $ui->form_field(object=>$o, column=>"info", edit=>$edit_strand, htmlExtra=>"rows='3' cols='80'", returnValOnly=>1) %>