[interchange-cvs] interchange - heins modified 2 files
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Tue Sep 17 15:04:01 2002
User: heins
Date: 2002-09-17 19:03:07 GMT
Modified: code/UI_Tag display.coretag table_editor.coretag
Log:
* The final update (at least from me) for the [table-editor] tag as
we know it. This adds some additional formatting capability, but no one
will ever use it (at least I hope).
The plan is to create a new module, Vend::TableEditor (or Vend::Table::Ed=
itor?)
which will break out all of the table-editor functions into a module.
More on that on the core list.
Revision Changes Path
1.8 +4 -0 interchange/code/UI_Tag/display.coretag
rev 1.8, prev_rev 1.7
Index: display.coretag
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/code/UI_Tag/display.coretag,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- display.coretag 24 Jun 2002 19:15:10 -0000 1.7
+++ display.coretag 17 Sep 2002 19:03:06 -0000 1.8
@@ -283,12 +283,15 @@
HELP =3D> $opt->{applylocale}
? errmsg($record->{help})
: $record->{help},
+ META_URL =3D> $opt->{meta_url},
HELP_URL =3D> $record->{help_url},
LABEL =3D> $opt->{applylocale}
? errmsg($record->{label})
: $record->{label},
);
=20
+ $sub{HELP_EITHER} =3D $sub{HELP} || $sub{HELP_URL};
+
if($array_return) {
return ($w, $sub{LABEL}, $sub{HELP}, $record->{help_url});
}
@@ -296,6 +299,7 @@
# Strip the {TAG} {/TAG} pairs if nothing there
$template =3D~ s#{([A-Z_]+)}(.*?){/\1}#$sub{$1} ? $2: '' #ges;
# Insert the TAG
+ $sub{HELP_URL} ||=3D 'javascript:void(0)';
$template =3D~ s/\$([A-Z_]+)\$/$sub{$1}/g;
return $template;
}
1.13 +129 -65 interchange/code/UI_Tag/table_editor.coretag
rev 1.13, prev_rev 1.12
Index: table_editor.coretag
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/code/UI_Tag/table_editor.coretag,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- table_editor.coretag 12 Sep 2002 05:33:29 -0000 1.12
+++ table_editor.coretag 17 Sep 2002 19:03:06 -0000 1.13
@@ -138,7 +138,6 @@
my @messages;
my @errors;
=20
-#Debug("labels=3D" . uneval($opt->{label}));
FORMATS: {
no strict 'refs';
my $ref;
@@ -186,7 +185,7 @@
my $span =3D $rowdiv * 2;
my $oddspan =3D $span - 1;
my $def =3D $opt->{default_ref} || $::Values;
-#::logDebug("view=3D$opt->{ui_meta_view}, default_ref: " . uneval($def));
+
$opt->{table_width} =3D '60%' if ! $opt->{table_width};
$opt->{left_width} =3D '30%' if ! $opt->{left_width};
if (! $opt->{inner_table_width}) {
@@ -223,8 +222,7 @@
my $widget =3D $opt->{widget};
my $width =3D $opt->{width};
my $pmeta =3D $opt->{meta};
-#::logDebug("widget=3D" . ::uneval_it($widget) );
-#::logDebug("label=3D" . ::uneval_it($label) );
+
=20
#my $blabel =3D $opt->{begin_label} || '<b>';
#my $elabel =3D $opt->{end_label} || '</b>';
@@ -390,10 +388,8 @@
foreach my $row (@hmap) {
my @keys =3D grep $_ =3D~ $row->[0], @cgi;
for(@keys) {
-#::logDebug("found key $_");
/^ui_\w+:(\S+)/
and $row->[1]->{$1} =3D $CGI->{$_};
-#::logDebug("set $1=3D$_");
}
}
$table =3D $opt->{mv_data_table};
@@ -512,7 +508,6 @@
=20
$opt->{clear_image} =3D "bg.gif" if ! $opt->{clear_image};
=20
-#::logDebug("table-editor opt: " . ::uneval($opt));
my $die =3D sub {
::logError(@_);
$Scratch->{ui_error} .=3D "<BR>\n" if $Scratch->{ui_error};
@@ -553,10 +548,8 @@
=20
$opt->{ui_data_fields} =3D~ s/\r\n/\n/g;
$opt->{ui_data_fields} =3D~ s/\r/\n/g;
-#::logDebug("ui_data_fields=3D$opt->{ui_data_fields}");
=20
if($opt->{ui_data_fields} =3D~ /\n\n/) {
-#::logDebug("Found break fields");
my @breaks;
my @break_labels;
while ($opt->{ui_data_fields} =3D~ s/\n+(?:\n[ \t]*=3D(.*))?\n+[ \t]*(\w=
[:.\w]+)/\n$2/) {
@@ -565,10 +558,8 @@
}
$opt->{ui_break_before} =3D join(" ", @breaks)
if ! $opt->{ui_break_before};
-#::logDebug("break_before=3D$opt->{ui_break_before}");
$opt->{ui_break_before_label} =3D join(",", @break_labels)
if ! $opt->{ui_break_before_label};
-#::logDebug("break_before_label=3D$opt->{ui_break_before_label}");
}
=20
$opt->{ui_data_fields} ||=3D $opt->{mv_data_fields};
@@ -826,11 +817,10 @@
$opt->{mv_update_empty} =3D 1 unless defined $opt->{mv_update_empty};
=20
my $url_base =3D $opt->{secure} ? $Config->{SecureURL} : $Config->{VendUR=
L};
-#Debug("Urlbase=3D$url_base");
+
$opt->{href} =3D "$url_base/ui" if ! $opt->{href};
$opt->{href} =3D "$url_base/$opt->{href}"
if $opt->{href} !~ m{^(https?:|)/};
-#Debug("href=3D$opt->{href}");
=20
my $sidstr;
if ($opt->{get}) {
@@ -1124,7 +1114,6 @@
my %break;
my %break_label;
if($opt->{ui_break_before}) {
-#::logDebug("Have a break_before");
my @tmp =3D grep /\S/, split /[\s,\0]+/, $opt->{ui_break_before};
@break{@tmp} =3D @tmp;
if($opt->{ui_break_before_label}) {
@@ -1141,7 +1130,6 @@
=20
my $passed_fields =3D $opt->{ui_data_fields};
=20
-#::logDebug("extra=3D" . ::uneval($extra));
my @extra_cols;
my %email_cols;
my %ok_col;
@@ -1220,24 +1208,74 @@
=20
my @data_enable =3D ($opt->{mv_blob_pointer}, $opt->{mv_blob_field});
my @ext_enable;
- my $row_template =3D $opt->{row_template} || <<EOF;
- <td class=3Dclabel width=3D"$opt->{left_width}">=20
- $blabel\$LABEL\$$elabel~META~
- </td>
- <td class=3Dcdata>=20
- <table cellspacing=3D0 cellmargin=3D0 width=3D"100%">
- <tr>=20
- <td class=3Dcwidget>=20
- \$WIDGET\$
- </td>
- <td class=3Dchelp>~TKEY~<i>\$HELP\$</i>{HELP_URL}<BR><A HREF=3D"\=
$HELP_URL\$">help</A>{/HELP_URL}</FONT></td>
- </tr>
- </table>
- </td>
+=20
+ # Init the cell stuff
+ my %td_extra;
+ my %td_default =3D (
+ widget_cell_class =3D> 'cwidget',
+ label_cell_class =3D> 'clabel',
+ data_cell_class =3D> 'cdata',
+ help_cell_class =3D> 'chelp',
+ );
+=20
+ for my $ctype (qw/label data widget help/) {
+ $td_extra{$ctype} =3D '';
+ for my $ptype (qw/class style align valign width/) {
+ my $parm =3D $ctype . '_cell_' . $ptype;
+ if(defined $opt->{$parm}) {
+ $td_extra{$ctype} .=3D qq{ $ptype=3D"$opt->{$parm}"};
+ }
+ elsif ($td_default{$parm}) {
+ $td_extra{$ctype} .=3D qq{ $ptype=3D"$td_default{$parm}"};
+ }
+ }
+ if(my $thing =3D $opt->{$ctype . "_cell_extra"}) {
+ $td_extra{$ctype} .=3D " $thing";
+ }
+ }
+=20
+ if($opt->{left_width} and ! $opt->{label_cell_width}) {
+ $td_extra{label} .=3D qq{ width=3D"$opt->{left_width}"};
+ }
+=20
+ my $row_template =3D $opt->{row_template};
+ $opt->{meta_anchor} ||=3D errmsg('meta');
+ $opt->{meta_anchor_specific} ||=3D errmsg('item-specific meta');
+=20=20=20=20=20=20=20
+ if(! $row_template) {
+ if($opt->{simple_row}) {
+ $opt->{help_anchor} ||=3D 'help';
+ $row_template =3D <<EOF;
+ <td$td_extra{label}>=20
+ \$LABEL\$
+ </td>
+ <td$td_extra{widget}>\$WIDGET\${HELP_EITHER} <a href=3D"\$HELP_URL\=
$" title=3D"\$HELP\$">$opt->{help_anchor}</a>{/HELP_EITHER} {META_URL}=
<a href=3D"\$META_URL\$">$opt->{meta_anchor}</A>{/META_URL}
+ </td>
+EOF
+ }
+ else {
+ $row_template =3D <<EOF;
+ <td$td_extra{label}>=20
+ $blabel\$LABEL\$$elabel~META~
+ </td>
+ <td$td_extra{data}>
+ <table cellspacing=3D0 cellmargin=3D0 width=3D"100%">
+ <tr>=20
+ <td$td_extra{widget}>
+ \$WIDGET\$
+ </td>
+ <td$td_extra{help}>~TKEY~<i>\$HELP\$</i>{HELP_URL}<BR><A HREF=3D"\$HEL=
P_URL\$">help</A>{/HELP_URL}</FONT></td>
+ </tr>
+ </table>
+ </td>
EOF
+ }
+ }
+
$row_template =3D~ s/~OPT:(\w+)~/$opt->{$1}/g;
$row_template =3D~ s/~BLABEL~/$blabel/g;
$row_template =3D~ s/~ELABEL~/$elabel/g;
+ $row_template =3D~ s/~([A-Z]+)_EXTRA~/$td_extra{lc $1}/g;
=20
my %serialize;
my %serial_data;
@@ -1539,6 +1577,8 @@
}
=20
my $meta =3D '';
+ my $meta_url;
+ my $meta_url_specific;
my $template =3D $row_template;
if($error->{$c}) {
my $parm =3D {
@@ -1555,6 +1595,65 @@
}
$template =3D~ s/\$LABEL\$/$Tag->error($parm)/eg;
}
+
+ if($show_meta) {
+ $opt->{meta_prepend} =3D '<br><font size=3D1>'
+ unless defined $opt->{meta_prepend};
+
+ $opt->{meta_anchor} ||=3D errmsg('meta');
+ $opt->{meta_extra} =3D " $opt->{meta_extra}"
+ if $opt->{meta_extra};
+ $opt->{meta_extra} ||=3D "";
+ $opt->{meta_extra} .=3D qq{ class=3D"$opt->{meta_class}"}
+ if $opt->{meta_class};
+ # Get global variables
+ my $base =3D $Tag->var('UI_BASE', 1) || 'admin';
+ my $page =3D $Tag->var('MV_PAGE', 1);
+ my $id =3D $t . "::$c";
+ $id =3D $opt->{ui_meta_view} . "::$id"
+ if $opt->{ui_meta_view} and $opt->{ui_meta_view} ne 'metaconfig';
+
+ my $return =3D <<EOF;
+ui_return_to=3D$page
+ui_return_to=3Ditem_id=3D$opt->{item_id}
+ui_return_to=3Dui_meta_view=3D$opt->{ui_meta_view}
+ui_return_to=3Dmv_return_table=3D$t
+mv_return_table=3D$table
+ui_return_stack=3D$CGI->{ui_return_stack}
+EOF
+
+ $meta_url =3D $Tag->area({
+ href =3D> "$base/meta_editor",
+ form =3D> qq(
+ item_id=3D$id
+ $return
+ ),
+ });
+ my $meta_specific =3D '';
+ if($opt->{ui_meta_specific}) {
+ my $meta_specific_url =3D $Tag->area({
+ href =3D> "$base/meta_editor",
+ form =3D> qq(
+ item_id=3D${t}::${c}::$key
+ $return
+ ),
+ });
+ $opt->{meta_anchor_specific} ||=3D errmsg('item-specific meta');
+ $meta_specific =3D <<EOF;
+<br><a href=3D"$meta_specific_url"$opt->{meta_extra}>$opt->{meta_anchor_sp=
ecific}</A>
+EOF
+ }
+=09=09=09=09=09=09=09=09=09=09=09=09=09
+ $opt->{meta_apppend} =3D '</FONT>'
+ unless defined $opt->{meta_append};
+
+ $meta =3D <<EOF;
+$opt->{meta_prepend}<a href=3D"$meta_url"$opt->{meta_extra}>$opt->{meta_an=
chor}</A>
+$meta_specific$opt->{meta_append}
+EOF
+
+ }
+
$template =3D~ s/~TKEY~/$tkey_message || ''/eg;
#::logDebug("col=3D$c currval=3D$currval widget=3D$widget->{$c} label=3D$l=
abel->{$c} (type=3D$type)");
my $display =3D $Tag->display({
@@ -1572,6 +1671,7 @@
label =3D> $label->{$c},
key =3D> $key,
meta =3D> $pmeta->{$c},
+ =
meta_url =3D> $meta_url,
name =3D> $namecol,
override =3D> $overridden,
passed =3D> $passed->{$c},
@@ -1596,42 +1696,6 @@
next;
}
=20
- if($show_meta) {
- $meta .=3D '<BR><FONT SIZE=3D1>';
- # Get global variables
- my $base =3D $Tag->var('UI_BASE', 1);
- my $page =3D $Tag->var('MV_PAGE', 1);
- my $id =3D $t . "::$c";
- $id =3D $opt->{ui_meta_view} . "::$id"
- if $opt->{ui_meta_view} and $opt->{ui_meta_view} ne 'metaconfig';
-
- my $return =3D <<EOF;
-ui_return_to=3D$page
-ui_return_to=3Ditem_id=3D$opt->{item_id}
-ui_return_to=3Dui_meta_view=3D$opt->{ui_meta_view}
-ui_return_to=3Dmv_return_table=3D$t
-mv_return_table=3D$table
-ui_return_stack=3D$CGI->{ui_return_stack}
-EOF
-
- $meta .=3D $Tag->page(
- { href =3D> "$base/meta_editor",
- form =3D> qq{
- item_id=3D$id
- $return
- }
- });
- $meta .=3D 'meta</A>';
- $meta .=3D '<br>' . $Tag->page(
- { href =3D> "$base/meta_editor",
- form =3D> qq{
- item_id=3D${t}::${c}::$key
- $return
- }
- }) . 'item-specific meta</A></FONT>'
- if $opt->{ui_meta_specific};
- $meta .=3D '</FONT>';
- }
$display =3D~ s/\~META\~/$meta/g;
$display =3D~ s/\~ERROR\~/$Tag->error({ name =3D> $c, keep =3D> 1 })/eg;
=20=20=20=20=20=20=20=20=20