[interchange-cvs] interchange - heins modified 2 files
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Sat Aug 3 15:31:01 2002
User: heins
Date: 2002-08-03 19:30:43 GMT
Modified: dist/lib/UI/pages/admin menu_editor.html
Modified: dist/lib/UI/pages/include/menus Quicklinks.txt
Log:
* More updates to menu_editor:
- Handles arbitrary number of extra field names, with metadata
support
- Writes output only on Publish
- Sort field automatically updated to proper value in simple menu
- Extended parameters only shown when present
Revision Changes Path
2.3 +158 -137 interchange/dist/lib/UI/pages/admin/menu_editor.html
rev 2.3, prev_rev 2.2
Index: menu_editor.html
=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/dist/lib/UI/pages/admin/menu_editor.html,v
retrieving revision 2.2
retrieving revision 2.3
diff -u -r2.2 -r2.3
--- menu_editor.html 3 Aug 2002 06:00:16 -0000 2.2
+++ menu_editor.html 3 Aug 2002 19:30:43 -0000 2.3
@@ -16,7 +16,15 @@
@_UI_STD_HEAD_@
<!-- ----- BEGIN REAL STUFF ----- -->
=20
-[perl tables=3D"__MV_TREE_TABLE__ __ProductFiles_0__ tree [cgi qmenu_produ=
cts]"]
+[seti medit_tables]
+__MV_TREE_TABLE__
+__ProductFiles_0__
+tree
+[cgi qmenu_products]
+__UI_META_TABLE__
+[/seti]
+
+[perl tables=3D"[scratch medit_tables]"]
my $menupath =3D $Variable->{MENU_DIRECTORY} || 'include/menus';
@menufields =3D qw/code mgroup inactive msort page form name description =
extended/;
=20
@@ -312,11 +320,11 @@
}
$Scratch->{qmenu_data} =3D $filedata;
$Scratch->{qmenu_name} =3D $mn;
+ $menumeta =3D $Tag->meta_record("menu_editor::$mn");
}
=20
my %illegal;
my @illegal =3D qw/check msg code/;
- my %required;
my %suggested =3D qw/
extended 1
inactive 1
@@ -345,15 +353,15 @@
$illegal++;
}
}
- @required =3D keys %required;
@suggested =3D keys %suggested;
- for(@required) {
+ for(keys %required) {
$Tag->error({
set =3D> errmsg( "Required field '%s' missing.", $_),
});
$illegal++;
}
delete $Scratch->{qmenu_data} if $illegal;
+ @required{@required} =3D @required;
return;
[/perl]
=20
@@ -374,15 +382,14 @@
<B>Menu name:</B>
<select name=3Dqmenu_name><option value=3D"">--select--</option>[scratch =
qmenu_options]</select>
<input type=3Dsubmit value=3D"[L]Load[/L]">
+ [page href=3D"__UI_BASE__/file_transfer"
+ form=3D"
+ initial_dir=3Dinclude/menus
+ "]Delete/Manage</A>
</form>
[/if]
</td>
<td width=3D"40%">
- [page href=3D"__UI_BASE__/file_transfer"
- form=3D"
- initial_dir=3Dinclude/menus
- "]Delete/Manage files</A>
- <br>
<span class=3Dcmessage>[warnings auto=3D1]</span>
[error all=3D1 text=3D"<ul class=3Dcerror><li>%s</ul>" joiner=3D"<li>"]
</td>
@@ -402,20 +409,49 @@
</tr>
</table>
=20
-[restrict enable=3D"calc scratch loop image" log=3Dnone]
<script language=3D"JavaScript1.2">
var lines =3D new Array;
var initialized =3D 0;
var no_alert =3D 0;
var tree_mode =3D 0;
var extended;
+ var extra =3D new Array;
+ var label =3D new Array;
+ var widget =3D new Array;
var emodes;
var evalues;
=20
-[calc]
+[perl reparse=3D0]
my @out;
- for(my $i =3D 1; $i < @menufields; $i++) {
- push @out, " var \U$menufields[$i]\E =3D $i;";
+ my $i =3D 0;
+=09
+ my $metabase;
+ if($menumeta) {
+ $metabase =3D $menumeta->{name};
+ }
+ $metabase ||=3D "menu_editor::$CGI->{qmenu_name}";
+ for(@menufields) {
+ push @out, " var \U$_\E =3D $i;";
+ DOMETA: {
+ last DOMETA if $required{$_} or $_ eq 'code';
+ my $metaname =3D "${metabase}::$_";
+ my $mrecord =3D $Tag->meta_record($metaname)
+ or last DOMETA;
+ if(my $lab =3D $mrecord->{label}) {
+ push @out, " label[$i] =3D " . $Tag->jsquote($lab) . ';';
+ }
+ if(my $type =3D $mrecord->{type}) {
+ $mrecord->{name} =3D "ext_$_";
+ $mrecord->{extra} =3D qq{ onChange=3D"form_changed(1)"};
+ my $wid =3D $Tag->display( {
+ meta =3D> $mrecord,
+ override =3D> 1,
+ default =3D> '',
+ } );
+ push @out, " widget[$i] =3D " . $Tag->jsquote($wid) . ';';
+ }
+ }
+ $i++;
}
=20
for (@suggested) {
@@ -429,8 +465,9 @@
=20
push @out, "\tlines[0] =3D ['" . join("', '", @menufields) . "'];";
return join "\n", @out;
-[/calc]
+[/perl]
=20
+[restrict enable=3D"perl calc scratch loop image" log=3Dnone]
[loop head-skip=3D1 lr=3D1 list=3D"[scratch qmenu_data]"][loop-sub jsline]
sub {
$loopname =3D shift;
@@ -731,7 +768,7 @@
return;
}
=20
- function extended_name (str) {
+ function ext_name (str) {
var pos =3D str.indexOf('_') + 1;
if(pos < 1)=20
return '';
@@ -739,32 +776,6 @@
return str;
}
=20
- function find_extended () {
- var el;
- extended =3D new Array;
- emodes =3D new Array;
- var i;
- for(i =3D 0; i < form.elements.length; i++) {
- var str =3D form.elements[i].name;
- if(str.indexOf('extended_') =3D=3D 0) {
- var len =3D extended.length;
- extended.length =3D len + 1;
- emodes.length =3D len + 1;
- extended[len] =3D form.elements[i];
- emodes[len] =3D 0;
- var nm =3D extended_name(str);
- var j;
- for(j =3D 1; j < CHECK; j++) {
- if(lines[0][j] =3D=3D nm) {
- emodes[len] =3D j;
- break;
- }
- }
-// alert("Extended field name is " + nm + ", mode is " + emodes[len]);
- }
- }
- }
-
function set_mode (mode) {
if(mode =3D=3D 'toggle') {
if(tree_mode =3D=3D 0) {
@@ -797,7 +808,6 @@
for(i =3D 1; i < lines.length; i++) {
rewrite(i);
}
- setOutput();
return;
}
=20
@@ -980,7 +990,6 @@
rewrite(len);
for(i =3D idx; i <=3D len; i++)=20
rewrite(i);
- setOutput();
return;
}
=20
@@ -1044,7 +1053,6 @@
if(something > 0 && confirm("Start item out with values from form?")) {
saveForm(idx);
}
- setOutput();
return;
}
=20
@@ -1073,54 +1081,31 @@
form.description.value =3D l[DESCRIPTION];
form.mgroup.value =3D l[MGROUP];
=20
- if( EXTENDED !=3D undefined ) {
- form.extended.value =3D l[EXTENDED];
-
- if(extended.length > 0) {
- var j;
- var hash =3D l[EXTENDED];
- if(hash =3D=3D undefined || ! hash.match(/=3D>/)) {
- hash =3D '[]';
- }
- else {
- hash =3D hash.replace(/^{\s*/, '[');
- hash =3D hash.replace(/,?\s*}\s*$/, ']');
- // hash =3D hash.replace(/\\'/g, "-_ESC_QUOTE_-");
- hash =3D hash.replace(/\s*(\w+)\s+=3D>\s+/g, " '$1', ");
- hash =3D hash.replace(/\s=3D>\s/g, ", ");
- hash =3D hash.replace(/\r/g, "\\r");
- }
- var ary =3D eval(hash);
- for(j =3D 0; j < extended.length; j++) {
- var el =3D extended[j];
- var nm =3D extended_name(el.name);
-
- if(nm =3D=3D '')
- continue;
- var val;
- for(j =3D 0; j < ary.length; j =3D j + 2) {
- if( ary[j] =3D=3D nm ) {
- val =3D ary[j + 1];
- break;
- }
- }
-
- if(val =3D=3D undefined)
- val =3D '';
-
- if(el.type =3D=3D 'select') {
- for(j =3D 0; j < el.length; j++) {
- if(val =3D=3D el.options[j].value) {
- el.selectedIndex =3D j;
- break;
- }
- }
- }
- else {
- el.value =3D val;
+ for(var x =3D 0; x < extra.length; x++) {
+ var el;
+ var en =3D extra[x];
+ var un =3D en.toUpperCase();
+ var eidx;
+ eval('eidx =3D ' + un);
+ eval ('el =3D form.ext_' + en );
+// if( x < 2) {
+// alert('loading extra form value ' + en + '(' + un + '), eidx=3D' + eidx=
+ ', value=3D' + l[eidx]);
+// }
+ if(el =3D=3D undefined) {
+ alert('bad extra form element: ' + en);
+ continue;
+ }
+ if(el.type =3D=3D 'select') {
+ for(var j =3D 0; j < el.length; j++) {
+ if(el.options[j].value =3D=3D l[eidx]) {
+ el.selectedIndex =3D j;
+ break;
}
}
}
+ else {
+ el.value =3D l[eidx];
+ }
}
=20
if(INACTIVE !=3D undefined) {
@@ -1174,18 +1159,21 @@
form.label.checked =3D 0;
form.lineidx.value =3D 0;
=20
- if(extended.length > 0) {
- for(j =3D 0; j < extended.length; j++) {
- var el =3D extended[j];
- if(el.type =3D=3D 'select') {
- el.selectedIndex =3D undefined;
- }
- else {
- el.value =3D '';
- }
+ for(var x =3D 0; x < extra.length; x++) {
+ var el;
+ var en =3D extra[x];
+ var un =3D en.toUpper;
+ eval ('el =3D form.ext_' + en );
+
+ if(el.type =3D=3D 'select') {
+ el.selectedIndex =3D undefined;
+ }
+ else {
+ el.value =3D '';
}
}
=20
+
form_changed(0);
return;
}
@@ -1223,32 +1211,26 @@
ttt =3D ttt.replace(/\r\n/g, "\r");
l[DESCRIPTION] =3D ttt.replace(/\n/g, "\r");
=20
- if(EXTENDED !=3D undefined) {
- if(extended.length > 0) {
- ttt =3D "{\r";
- var j;
- for(j =3D 0; j < extended.length; j++) {
- var el =3D extended[j];
- var nm =3D extended_name(el.name);
- if(nm =3D=3D '')
- continue;
- var val;
- if(el.type =3D=3D 'select') {
- val =3D el.options[el.selectedIndex].value;
- }
- else {
- val =3D el.value;
- }
- val =3D val.replace(/'/g, "\\'");
- ttt =3D ttt + " " + nm + " =3D> '" + val + "',\n";
+ for(var x =3D 0; x < extra.length; x++) {
+ var el;
+ var en =3D extra[x];
+ var un =3D en.toUpperCase();
+ var eidx;
+ eval('eidx =3D ' + un);
+ eval('el =3D form.ext_' + en );
+
+ if(el.type =3D=3D 'select') {
+ var sel =3D el.options[el.selectedIndex];
+ if(sel =3D=3D defined) {
+ l[eidx] =3D sel.value;
+ }
+ else {
+ l[eidx] =3D '';
}
- ttt =3D ttt + "}";
}
else {
- ttt =3D form.extended.value;
+ l[eidx] =3D el.value;
}
- ttt =3D ttt.replace(/\r\n/g, "\r");
- l[EXTENDED] =3D ttt.replace(/\n/g, "\r");
}
=20
if(INACTIVE !=3D undefined) {
@@ -1267,7 +1249,6 @@
if(checkcur > 0)
checkit(checkcur);
rewrite(idx);
- setOutput();
zeroForm();
return;
}
@@ -1284,7 +1265,10 @@
ttt =3D '0' + ttt;
var tl =3D new Array;
var j;
- for( j =3D 0; j < linelen; j++) {
+ tl[0] =3D ttt;
+ if(tree_mode !=3D 1)
+ lines[i][MSORT] =3D 'x' + ttt;
+ for( j =3D 1; j < linelen; j++) {
tl[j] =3D lines[i][j];
if(tl[j] =3D=3D undefined)=20
tl[j] =3D '';
@@ -1396,7 +1380,6 @@
rewrite(x);
}
=20
- setOutput();
return;
}
=20
@@ -1462,7 +1445,6 @@
moveit(idx, motion);
}
=20
- setOutput();
return void(0);
}
=20
@@ -1485,7 +1467,7 @@
disabled=3D1
name=3Djunksubmit
value=3D".">
- <input type=3Dsubmit name=3Ddoit style=3D"font-weight: bold" value=3D"Pu=
blish" onClick=3D"check_change(1)">
+ <input type=3Dsubmit name=3Ddoit style=3D"font-weight: bold" value=3D"Pu=
blish" onClick=3D"check_change(1) && setOutput()">
<input type=3Dsubmit
onClick=3D"
@@ -1604,7 +1586,7 @@
style=3D"visibility: Hidden;"
value=3D"Copy to checked entry">
<br><br>
- <input type=3Dsubmit style=3D"font-weight: bold" name=3Ddoit value=3D"Pu=
blish" onClick=3D"check_change(1)">
+ <input type=3Dsubmit style=3D"font-weight: bold" name=3Ddoit value=3D"Pu=
blish" onClick=3D"check_change(1) && setOutput()">
<input type=3Dsubmit
onClick=3D"
@@ -1634,7 +1616,6 @@
else {
set_mode('simple');
}
- setOutput();
}
=20
set_checked_buttons();
@@ -1643,16 +1624,57 @@
document.qmenuform.inactive.disabled =3D 1;
}
initialized =3D 1;
- find_extended();
+ var reserved =3D /^(extended|inactive|description|form|mgroup|msort|name=
|page|code)$/;
+ var f =3D lines[0];
+ for (i =3D 0; i < f.length; i++) {
+ var fn =3D f[i];
+ if(! fn.match(reserved) ) {
+ var nn =3D 'ext_' + fn;
+ var un =3D fn.toUpperCase();
+// alert([jsquote]fn=3D$fn nn=3D$nn un=3D$un[/jsquote]);
+ var eidx;
+ eval('eidx =3D ' + un);
+// alert([jsquote]fn=3D$fn un=3D$un nn=3D$nn eidx=3D$eidx[/jsquote]);
+ var nidx =3D extra.length;
+ extra.length +=3D 1;
+ extra[nidx] =3D fn;
+ var lab =3D fn;
+ var wid;
+ if(label[eidx] !=3D undefined) {
+ lab =3D label[eidx];
+ }
+ if(widget[eidx] !=3D undefined) {
+ wid =3D widget[eidx];
+ }
+ else {
+ wid =3D [jsquote]<input type=3Dtext name=3D"$nn" onChange=3D"form_cha=
nged(1);">[/jsquote];
+ }
+ document.write([jsquote]
+ <tr>
+ <td class=3Dclabel>
+ $lab
+ </td>
+ <td class=3Dcdata>
+ $wid
+ </td>
+ </tr>
+ [/jsquote]);
+
+ }
+
+ }
+=09=09
if(EXTENDED !=3D undefined) {
- document.write("<tr>" +
-' <td class=3Dclabel>' +
-' Extended Parameters (advanced)' +
-' </td>' +
-' <td class=3Dcdata>' +
-' <textarea cols=3D50 rows=3D4 name=3Dextended onChange=3D"form_changed=
(1);"></textarea>' +
-' </td>' +
-' </tr>');
+ document.write([jsquote]
+ <tr>
+ <td class=3Dclabel>
+ Extended Parameters (advanced)
+ </td>
+ <td class=3Dcdata>
+ <textarea cols=3D50 rows=3D4 name=3Dextended onChange=3D"form_changed(=
1);"></textarea>
+ </td>
+ </tr>
+ [/jsquote]);
}
=20
</script>
@@ -1665,4 +1687,3 @@
</form>
<!-- ----- END REAL STUFF ----- -->
@_UI_STD_FOOTER_@
-<!-- page: @@MV_PAGE@@ -->
1.3 +42 -42 interchange/dist/lib/UI/pages/include/menus/Quicklinks=
txt
rev 1.3, prev_rev 1.2
Index: Quicklinks.txt
=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/dist/lib/UI/pages/include/menus/Quicklinks.t=
xt,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Quicklinks.txt 3 Aug 2002 06:00:16 -0000 1.2
+++ Quicklinks.txt 3 Aug 2002 19:30:43 -0000 1.3
@@ -1,43 +1,43 @@
code mgroup msort inactive page form name description extended
-001 x 0 Store Admin=09=09
-002 0 0 admin/order Orders=09=09
-003 full 0 0 admin/entry Order entry=09=09
-004 0 0=09=09=09=09=09
-005 full 0 0 admin/orderstats Order stats=09=09
-006 full 0 0 admin/trafficstats Traffic stats=09=09
-007 full 0 0 admin/affiliates Affiliates=09=09
-008 full 0 0=09=09=09=09=09
-009 0 0 admin/item Items=09=09
-010 0 0 <hr noshade size=3D1>=09=09
-011 0 0 Site Design=09=09
-012 0 0 admin/layout Site Layout=09=09
-013 0 0 admin/page Page Edit=09=09
-014 0 0 admin/regenerate Generate static=09=09
-015 0 0 admin/build_related Build related=09=09
-016 0 0 admin/search_wizard Search Builder=09=09
-017 0 0 admin/button_builder Button Builder=09=09
-018 0 0 admin/menu_editor Menu Builder Create and edit quick menus with =
a graphical UI=09
-019 0 0 <hr noshade size=3D1>=09=09
-020 0 0 Technical Admin=09=09
-021 0 0 admin/tax Tax=09=09
-022 0 0 admin/ship Shipping=09=09
-023 0 0 admin/payment Payment=09=09
-024 0 0=09=09=09=09=09
-025 0 0 admin/file_transfer File transfer=09=09
-026 0 0 admin/auto_wizard Wizard=09=09
-027 0 0=09=09=09=09=09
-028 0 0 admin/gentable Direct Table Edit=09=09
-029 0 0 admin/import_table Table import=09=09
-030 0 0 admin/export_table Table export=09=09
-031 0 0=09=09=09=09=09
-032 0 0 admin/access Administrators=09=09
-033 full 0 0 admin/group Admin Groups=09=09
-034 full 0 0 admin/access_permissions Permissions=09=09
-035 0 0=09=09=09=09=09
-036 0 0 admin/env_vars Environment=09=09
-037 0 0 admin/preferences Preferences=09=09
-038 full 0 0 admin/flex_select mv_data_table=3Dvariable&page_title=3DKnar%=
20editor&ui_meta_specific=3D1&help_name=3Dknar.main Knar editor=09=09
-039 0 0 <hr noshade size=3D1>=09=09
-040 0 0 index <b>Go to catalog</b>=09=09
-041 0 0 admin/login <b>Logout</b>=09=09
-042 0 0 admin/reconfig <b>Apply Changes</b>=09=09
+001 x001 0 Store Admin=09=09
+002 x002 0 admin/order Orders=09=09
+003 full x003 0 admin/entry Order entry=09=09
+004 x004 0=09=09=09=09=09
+005 full x005 0 admin/orderstats Order stats=09=09
+006 full x006 0 admin/trafficstats Traffic stats=09=09
+007 full x007 0 admin/affiliates Affiliates=09=09
+008 full x008 0=09=09=09=09=09
+009 x009 0 admin/item Items=09=09
+010 x010 0 <hr noshade size=3D1>=09=09
+011 x011 0 Site Design=09=09
+012 x012 0 admin/layout Site Layout=09=09
+013 x013 0 admin/page Page Edit=09=09
+014 x014 0 admin/regenerate Generate static=09=09
+015 x015 0 admin/build_related Build related=09=09
+016 x016 0 admin/search_wizard Search Builder=09=09
+017 x017 0 admin/button_builder Button Builder=09=09
+018 x018 0 admin/menu_editor Menu Builder Create and edit quick menus wi=
th a graphical UI=09
+019 x019 0 <hr noshade size=3D1>=09=09
+020 x020 0 Technical Admin=09=09
+021 x021 0 admin/tax Tax=09=09
+022 x022 0 admin/ship Shipping=09=09
+023 x023 0 admin/payment Payment=09=09
+024 x024 0=09=09=09=09=09
+025 x025 0 admin/file_transfer File transfer=09=09
+026 x026 0 admin/auto_wizard Wizard=09=09
+027 x027 0=09=09=09=09=09
+028 x028 0 admin/gentable Direct Table Edit=09=09
+029 x029 0 admin/import_table Table import=09=09
+030 x030 0 admin/export_table Table export=09=09
+031 x031 0=09=09=09=09=09
+032 x032 0 admin/access Administrators=09=09
+033 full x033 0 admin/group Admin Groups=09=09
+034 full x034 0 admin/access_permissions Permissions=09=09
+035 x035 0=09=09=09=09=09
+036 x036 0 admin/env_vars Environment=09=09
+037 x037 0 admin/preferences Preferences=09=09
+038 full x038 0 admin/flex_select mv_data_table=3Dvariable&page_title=3DKn=
ar%20editor&ui_meta_specific=3D1&help_name=3Dknar.main Knar editor=09=09
+039 x039 0 <hr noshade size=3D1>=09=09
+040 x040 0 index <b>Go to catalog</b>=09=09
+041 x041 0 admin/login <b>Logout</b>=09=09
+042 x042 0 admin/reconfig <b>Apply Changes</b>=09=09