Send Netdot-devel mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://osl.uoregon.edu/mailman/listinfo/netdot-devel
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-devel digest..."


Today's Topics:

   1. [Netdot - Bug #1806] (New) select_lookup() method in
      lib/Netdot/UI.pm fails to deal with NULLable columns
      ([email protected])
   2. [Netdot - Bug #1806] select_lookup() method in
      lib/Netdot/UI.pm fails to deal with NULLable columns
      ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Wed, 7 May 2014 05:11:51 -0700
From: [email protected]
Subject: [Netdot-devel] [Netdot - Bug #1806] (New) select_lookup()
        method in       lib/Netdot/UI.pm fails to deal with NULLable columns
To: [email protected], [email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8


Issue #1806 has been reported by William Bulley.

----------------------------------------
Bug #1806: select_lookup() method in lib/Netdot/UI.pm fails to deal with 
NULLable columns
https://osl.uoregon.edu/redmine/issues/1806

Author: William Bulley
Status: New
Priority: Low
Assignee: Carlos Vicente
Category: UserInterface
Target version: 1.0.6
Resolution: 


the select_lookup() method in lib/Netdot/UI.pm will insert a "[null]" select 
<option> element under certain conditions when building an HTML <select> 
pull-down menu

the "edit" argument controls whether the <select> menu is created when "edit" 
is "true"

when showing the <select> box a "[null]" <option> is unconditionally added just 
before
the closing </select> tag in both code paths when the "edit" argument is "true

--- UI.pm.orig  2014-04-10 16:24:50.000000000 -0400
+++ UI.pm       2014-05-07 08:09:02.000000000 -0400
@@ -610,11 +610,15 @@
                 next if ( $o && $o->$column && ($fo->id == $o->$column->id) );
                my $selected = ($fo->id == $args{default} ? 'selected' : '');
                 $output .= sprintf('<option value="%s" %s>%s</option>', 
                                   $fo->id, $selected, $fo->get_label);
             }
+           if ( $o && $o->$column ){
+               if ($o->$column->is_nullable() ){
            $output .= sprintf('<option value="">[null]</option>');
+               }
+           }
             $output .= sprintf('</select>');
         }else{
            # ...otherwise provide tools to narrow the selection to a managable 
size.
             my $srchf = '_' . $id . '_' . $column . '_srch';
             $output .= '<nobr>';   # forces the text field and button to be on 
the same line
@@ -630,11 +634,15 @@
             $output .= sprintf('<option value="" selected>-- Select 
--</option>');
             if ( $o && $o->$column ){
                 $output .= sprintf('<option value="%s" selected>%s</option>', 
                                   $o->$column->id, $o->$column->get_label);
             }
+           if ( $o && $o->$column ){
+               if ($o->$column->is_nullable() ){
            $output .= sprintf('<option value="">[null]</option>');
+               }
+           }
             $output .= sprintf('</select>');
         }
 
        if ( $args{new_button} ){
            # show link to add new item to this table



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://osl.uoregon.edu/redmine/my/account


------------------------------

Message: 2
Date: Wed, 7 May 2014 11:28:32 -0700
From: [email protected]
Subject: [Netdot-devel] [Netdot - Bug #1806] select_lookup() method in
        lib/Netdot/UI.pm fails to deal with NULLable columns
To: [email protected], [email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8


Issue #1806 has been updated by William Bulley.


found out in testing that some more changes were needed:

--- UI.pm.orig  2014-04-10 16:24:50.000000000 -0400
+++ UI.pm       2014-05-07 14:24:42.000000000 -0400
@@ -1,10 +1,11 @@
 package Netdot::UI;
 
 use lib "<<Make:LIB>>";
 use base qw( Netdot );
 use Netdot::Model;
+use Netdot::Meta::Table::Column;
 use Apache::Session::File;
 use Apache::Session::Lock::File;
 use GraphViz;
 use Apache2::SiteControl;
 use strict;
@@ -349,11 +350,11 @@
     ################################################
     ## The column is a foreign key. Provide a list to select.
     if ( defined $f_table  ){
         $value = $self->select_lookup(object=>$o, table=>$table, 
column=>$column, htmlExtra=>$args{htmlExtra}, 
                                      lookup=>$f_table, edit=>$args{edit}, 
new_button=>$args{new_button},
-                                     linkPage=>$args{linkPage}, 
default=>$args{default},
+                                     linkPage=>$args{linkPage}, 
default=>$args{default}, maxCount=>$args{maxCount},
                                      defaults=>$args{defaults}, 
returnAsVar=>1, shortFieldName=>$args{shortFieldName});
     }
     ################################################
     ## column is a local field
     else {
@@ -569,11 +570,11 @@
         }

         
         # if the selected objects are within our limits,
        # or if we've been passed a specific default list, 
        # show the select box.
-        if ( $count <= $args{maxCount} || @defaults ){
+       if ( $count <= $args{maxCount} ){
             if ( !$args{where} && !@defaults ){
                @fo = $args{lookup}->retrieve_all();
            }
            unless ( @defaults ){
                # Assume the list is ordered when passed to us
@@ -610,11 +611,17 @@
                 next if ( $o && $o->$column && ($fo->id == $o->$column->id) );
                my $selected = ($fo->id == $args{default} ? 'selected' : '');
                 $output .= sprintf('<option value="%s" %s>%s</option>', 
                                   $fo->id, $selected, $fo->get_label);
             }
+           if ( $o && $o->$column ){
+               my $mtable  = $table->meta_data;
+               my $mcol = $mtable->get_column($column);
+               if ($mcol->is_nullable() ){
            $output .= sprintf('<option value="">[null]</option>');
+               }
+           }
             $output .= sprintf('</select>');
         }else{
            # ...otherwise provide tools to narrow the selection to a managable 
size.
             my $srchf = '_' . $id . '_' . $column . '_srch';
             $output .= '<nobr>';   # forces the text field and button to be on 
the same line
@@ -630,11 +637,17 @@
             $output .= sprintf('<option value="" selected>-- Select 
--</option>');
             if ( $o && $o->$column ){
                 $output .= sprintf('<option value="%s" selected>%s</option>', 
                                   $o->$column->id, $o->$column->get_label);
             }
+           if ( $o && $o->$column ){
+               my $mtable  = $table->meta_data;
+               my $mcol = $mtable->get_column($column);
+               if ($mcol->is_nullable() ){
            $output .= sprintf('<option value="">[null]</option>');
+               }
+           }
             $output .= sprintf('</select>');
         }
 
        if ( $args{new_button} ){
            # show link to add new item to this table

----------------------------------------
Bug #1806: select_lookup() method in lib/Netdot/UI.pm fails to deal with 
NULLable columns
https://osl.uoregon.edu/redmine/issues/1806#change-3173

Author: William Bulley
Status: New
Priority: Low
Assignee: Carlos Vicente
Category: UserInterface
Target version: 1.0.6
Resolution: 


the select_lookup() method in lib/Netdot/UI.pm will insert a "[null]" select 
<option> element under certain conditions when building an HTML <select> 
pull-down menu

the "edit" argument controls whether the <select> menu is created when "edit" 
is "true"

when showing the <select> box a "[null]" <option> is unconditionally added just 
before
the closing </select> tag in both code paths when the "edit" argument is "true

--- UI.pm.orig  2014-04-10 16:24:50.000000000 -0400
+++ UI.pm       2014-05-07 08:09:02.000000000 -0400
@@ -610,11 +610,15 @@
                 next if ( $o && $o->$column && ($fo->id == $o->$column->id) );
                my $selected = ($fo->id == $args{default} ? 'selected' : '');
                 $output .= sprintf('<option value="%s" %s>%s</option>', 
                                   $fo->id, $selected, $fo->get_label);
             }
+           if ( $o && $o->$column ){
+               if ($o->$column->is_nullable() ){
            $output .= sprintf('<option value="">[null]</option>');
+               }
+           }
             $output .= sprintf('</select>');
         }else{
            # ...otherwise provide tools to narrow the selection to a managable 
size.
             my $srchf = '_' . $id . '_' . $column . '_srch';
             $output .= '<nobr>';   # forces the text field and button to be on 
the same line
@@ -630,11 +634,15 @@
             $output .= sprintf('<option value="" selected>-- Select 
--</option>');
             if ( $o && $o->$column ){
                 $output .= sprintf('<option value="%s" selected>%s</option>', 
                                   $o->$column->id, $o->$column->get_label);
             }
+           if ( $o && $o->$column ){
+               if ($o->$column->is_nullable() ){
            $output .= sprintf('<option value="">[null]</option>');
+               }
+           }
             $output .= sprintf('</select>');
         }
 
        if ( $args{new_button} ){
            # show link to add new item to this table



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://osl.uoregon.edu/redmine/my/account


------------------------------

_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel


End of Netdot-devel Digest, Vol 86, Issue 5
*******************************************

Reply via email to