[interchange-cvs] interchange - heins modified 2 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Mon Jul 21 14:58:00 EDT 2003


User:      heins
Date:      2003-07-21 17:58:55 GMT
Modified:  lib/Vend/Table Editor.pm
Modified:  dist/lib/UI/pages/admin db_metaconfig.html
Log:
* Add new link_blank_auto setting for table linking. This has the
  effect of:

        -- Automatically using auto-numbering
        -- setting the foreign key column to match the key of the
           edited record (as you would have to do to return the row
           once entered)
        -- Making both those fields hidden and non-changeable.

  Supported in UI with a couple of new settings.

Revision  Changes    Path
1.40      +47 -6     interchange/lib/Vend/Table/Editor.pm


rev 1.40, prev_rev 1.39
Index: Editor.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Table/Editor.pm,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- Editor.pm	19 Jul 2003 22:42:56 -0000	1.39
+++ Editor.pm	21 Jul 2003 17:58:55 -0000	1.40
@@ -1,6 +1,6 @@
 # Vend::Table::Editor - Swiss-army-knife table editor for Interchange
 #
-# $Id: Editor.pm,v 1.39 2003/07/19 22:42:56 mheins Exp $
+# $Id: Editor.pm,v 1.40 2003/07/21 17:58:55 mheins Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 2002 Mike Heins <mike at perusion.net>
@@ -26,7 +26,7 @@
 package Vend::Table::Editor;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.39 $, 10);
+$VERSION = substr(q$Revision: 1.40 $, 10);
 
 use Vend::Util;
 use Vend::Interpolate;
@@ -1237,6 +1237,7 @@
 		link_row_qual
 		link_auto_number
 		link_rows_blank
+		link_blank_auto
 		link_sort
 		link_table
 		link_template
@@ -2854,6 +2855,7 @@
 		my @lrq;
 		my @lra;
 		my @lrb;
+		my @lba;
 		my @lbefore;
 		my @lsort;
 		my $tcount = 1;
@@ -2868,6 +2870,7 @@
 			@lrq     = @{$opt->{link_row_qual}};
 			@lra     = @{$opt->{link_auto_number}};
 			@lrb     = @{$opt->{link_rows_blank}};
+			@lba     = @{$opt->{link_blank_auto}};
 			@lbefore = @{$opt->{link_before}};
 			@lsort   = @{$opt->{link_sort}};
 		}
@@ -2882,6 +2885,7 @@
 			@lrq     = $opt->{link_row_qual};
 			@lra     = $opt->{link_auto_number};
 			@lrb     = $opt->{link_rows_blank};
+			@lba     = $opt->{link_blank_auto};
 			@lbefore = $opt->{link_before};
 			@lsort   = $opt->{link_sort};
 		}
@@ -2896,6 +2900,7 @@
 			my $lrq = shift @lrq;
 			my $lra = shift @lra;
 			my $lrb = shift @lrb;
+			my $lba = shift @lba;
 
 			my $rcount = 0;
 
@@ -2915,6 +2920,12 @@
 			my $l_pkey = $ldb->config('KEY');
 			$lrq ||= $l_pkey;
 
+			if($lba) {
+				my @f = grep /\w/, split /[\s,\0]+/, $lf;
+				@f = grep $_ ne $lk && $_ ne $l_pkey, @f;
+				$lf = join " ", @f;
+			}
+
 			my $an_piece = '';
 			if($lra) {
 				$an_piece = <<EOF;
@@ -2923,26 +2934,35 @@
 EOF
 			}
 
+			## Have to produce two field lists -- one for
+			## in link_blank_auto mode (no link_key for row_edit)
+			## and one with all when not in link_blank_auto
+
 			my @cf = grep /\S/, split /[\s,\0]+/, $lf;
 			@cf = grep $_ ne $l_pkey, @cf;
 			$lf = join " ", @cf;
+
+			unshift @cf, $lk if $lba;
+			my $df = join " ", @cf;
+
 			my $lextra = $opt->{link_extra} || '';
 			$lextra = " $lextra" if $lextra;
 
 			my @lout = q{<table cellspacing=0 cellpadding=1>};
 			push @lout, qq{<tr><td$lextra>
 <input type=hidden name="mv_data_table__$tcount" value="$lt">
-<input type=hidden name="mv_data_fields__$tcount" value="$lf">
+<input type=hidden name="mv_data_fields__$tcount" value="$df">
 <input type=hidden name="mv_data_multiple__$tcount" value="1">
 <input type=hidden name="mv_data_key__$tcount" value="$l_pkey">
 <input type=hidden name="mv_data_multiple_qual__$tcount" value="$lrq">
 $an_piece
 $l_pkey</td>};
-			push @lout, $Tag->row_edit({ table => $lt, columns => $lf });
+			push @lout, $Tag->row_edit({ table => $lt, columns => "$lk $lf" });
 			push @lout, '</tr>';
 
 			my $tname = $ldb->name();
-			my $lfor = $key;
+			my $k = $key;
+			my $lfor = $k;
 			$lfor = $ldb->quote($key, $lk);
 			my $q = "SELECT $l_pkey FROM $tname WHERE $lk = $lfor";
 			$q .= " ORDER BY $ls" if $ls;
@@ -2954,6 +2974,12 @@
 				$hid .= HTML::Entities::encode($rk);
 				$hid .= qq{">};
 				push @lout, qq{<tr><td$lextra>$rk$hid</td>};
+				if($lba) {
+					my $hid = qq{<input type=hidden name="$pp${lk}__$tcount" value="};
+					$hid .= HTML::Entities::encode($k);
+					$hid .= qq{">};
+					push @lout, qq{<td$lextra>$k$hid</td>};
+				}
 				my %o = (
 					table => $lt,
 					key => $_->[0],
@@ -2966,6 +2992,13 @@
 				push @lout, $Tag->row_edit(\%o);
 				push @lout, "</tr>";
 			}
+
+			if($lba and $lrq eq $lk || $lrq eq $l_pkey) {
+				my $colcount = scalar(@cf) + 1;
+				push @lout, "<td colspan=$colcount>Link row qualifier must be different than link_key and primary code when in auto mode.</td>";
+				$lnb = 1;
+			}
+
 			unless($lnb) {
 				my $start_ptr = 999000;
 				$lrb ||= 1;
@@ -2978,9 +3011,17 @@
 						stacker => $tcount,
 						columns => $lf,
 					);
+					my $ktype = $lba ? 'hidden' : 'text';
 					push @lout, qq{<tr><td$lextra>};
-					push @lout, qq{<input size=8 name="${start_ptr}_${l_pkey}__$tcount" value="">};
+					push @lout, qq{<input size=8 type=$ktype name="${start_ptr}_${l_pkey}__$tcount" value="">};
+					push @lout, '(auto)' if $lba;
 					push @lout, '</td>';
+					if($lba) {
+						my $hid = qq{<input type=hidden name="${start_ptr}_${lk}__$tcount" value="};
+						$hid .= HTML::Entities::encode($k);
+						$hid .= qq{">};
+						push @lout, qq{<td$lextra>$k$hid</td>};
+					}
 					push @lout, $Tag->row_edit(\%o);
 					push @lout, '</tr>';
 					$start_ptr++;



2.16      +7 -4      interchange/dist/lib/UI/pages/admin/db_metaconfig.html


rev 2.16, prev_rev 2.15
Index: db_metaconfig.html
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/pages/admin/db_metaconfig.html,v
retrieving revision 2.15
retrieving revision 2.16
diff -u -r2.15 -r2.16
--- db_metaconfig.html	10 Apr 2003 17:52:47 -0000	2.15
+++ db_metaconfig.html	21 Jul 2003 17:58:55 -0000	2.16
@@ -100,8 +100,8 @@
 		extended.link_sort
 		extended.link_fields
 		extended.link_auto_number extended.link_row_qual
-		extended.link_rows_blank extended.link_view
-		extended.link_extra
+		extended.link_rows_blank extended.link_blank_auto
+		extended.link_view extended.link_extra
 
 		=Included form
 
@@ -176,6 +176,7 @@
 		'extended.ui_special_add'		=> 'Special Additions',
 		'extended.link_table'			=> 'Table to link in cell',
 		'extended.link_rows_blank'		=> 'Number of blank rows',
+		'extended.link_blank_auto'		=> 'Auto handling blank row link key',
 		'extended.link_row_qual'		=> 'Field indicating valid row',
 		'extended.link_auto_number'		=> 'Allow auto_number in link',
 		'extended.link_before'			=> 'Column to appear before',
@@ -227,7 +228,8 @@
 </pre>
 			</blockquote>},
 		'extended.link_rows_blank'		=> 'default 1',
-		'extended.link_row_qual'		=> 'Default is key field, needs to be different field if auto-numbering.',
+		'extended.link_row_qual'		=> 'Default is key field, needs to be different field if auto-numbering. Must not be same as Foreign Key if in auto mode.',
+		'extended.link_blank_auto'		=> 'Requires link row qualifier be separate from primary key and foreign key in linked table.',
 		'extended.tab_horiz_offset'		=> 'Tab Horizontal Offset',
 		'extended.tab_vert_offset'		=> 'Tab Vertical Offset',
 		'extended.tab_width'			=> 'Default 100 pixels.',
@@ -288,6 +290,7 @@
 		'extended.link_fields'			=> 'text_70',
 		'extended.link_key'			=> 'text_20',
 		'extended.link_rows_blank'	=> 'text_3',
+		'extended.link_blank_auto'		=> 'yesno',
 		'extended.link_row_qual'	=> 'text_12',
 		'extended.link_auto_number'	=> 'yesno',
 		'extended.top_buttons'		=> 'yesno',
@@ -358,4 +361,4 @@
 
 ]
 @_UI_STD_FOOTER_@
-<!-- page: @@MV_PAGE@@ version: $Revision: 2.15 $ -->
+<!-- page: @@MV_PAGE@@ version: $Revision: 2.16 $ -->







More information about the interchange-cvs mailing list