Automatically add new fields in table creation

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@700 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-06-15 11:53:16 +00:00
parent c67557c82a
commit d60dbc379f
3 changed files with 12 additions and 17 deletions

View file

@ -85,32 +85,26 @@ function editing_add_row(button, allowed) {
var tags = row.getElementsByTagName('select');
var tags2 = row2.getElementsByTagName('select');
for (var i=0; i < tags.length; i++) {
tags[i].name = tags[i].name.replace(/([0-9.]+)/, x);
tags2[i].name = tags[i].name.replace(/([0-9.]+)/, x);
tags2[i].selectedIndex = tags[i].selectedIndex;
}
tags = row.getElementsByTagName('input');
var ai;
tags2 = row2.getElementsByTagName('input');
for (var i=0; i < tags.length; i++) {
if (tags[i].name == 'auto_increment_col') {
tags[i].value = x;
if (tags[i].checked) {
ai = i;
tags[i].checked = false;
}
tags2[i].value = x;
tags2[i].checked = false;
}
tags[i].name = tags[i].name.replace(/([0-9.]+)/, x);
tags2[i].name = tags[i].name.replace(/([0-9.]+)/, x);
if (/\[(orig|field|comment)/.test(tags[i].name)) {
tags[i].value = '';
tags2[i].value = '';
}
}
row.parentNode.insertBefore(row2, row);
if (ai !== undefined) {
row2.getElementsByTagName('input')[ai].checked = true;
}
tags[0].focus();
tags[0].onchange = function () { };
row.parentNode.insertBefore(row2, row.nextSibling);
added += '0';
row_count++;
return true;
return tags2[0];
}
function editing_remove_row(button) {

View file

@ -144,7 +144,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0) {
?>
<tr<?php echo ($display ? "" : " style='display: none;'"); ?>>
<?php if ($type == "PROCEDURE") { ?><td><select name="fields[<?php echo $i; ?>][inout]"><?php echo optionlist($inout, $field["inout"]); ?></select></td><?php } ?>
<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo htmlspecialchars($field["field"]); ?>" maxlength="64" /><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo htmlspecialchars($field[($_POST ? "orig" : "field")]); ?>" /></th>
<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo htmlspecialchars($field["field"]); ?>"<?php echo (strlen($field["field"]) || count($fields) > 1 ? "" : " onchange='editing_add_row(this, $allowed);'"); ?> maxlength="64" /><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo htmlspecialchars($field[($_POST ? "orig" : "field")]); ?>" /></th>
<?php edit_type("fields[$i]", $field, $collations); ?>
<?php if ($type == "TABLE") { ?>
<td><input type="checkbox" name="fields[<?php echo $i; ?>][null]" value="1"<?php if ($field["null"]) { ?> checked="checked"<?php } ?> /></td>
@ -152,7 +152,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0) {
<td<?php echo ($column_comments ? "" : " class='hidden'"); ?>><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
<?php } ?>
<?php
echo "<td class='nowrap'><input type='image' name='add[$i]' src='plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editing_add_row(this, $allowed);' />";
echo "<td class='nowrap'><input type='image' name='add[$i]' src='plus.gif' alt='+' title='" . lang('Add next') . "' onclick='var x = editing_add_row(this, $allowed); if (x) { x.focus(); x.onchange = function () { }; } return !x;' />";
echo "&nbsp;<input type='image' name='drop_col[$i]' src='cross.gif' alt='x' title='" . lang('Remove') . "' onclick='return !editing_remove_row(this);' />";
echo "&nbsp;<input type='image' name='up[$i]' src='up.gif' alt='^' title='" . lang('Move up') . "' />";
echo "&nbsp;<input type='image' name='down[$i]' src='down.gif' alt='v' title='" . lang('Move down') . "' />";

View file

@ -15,6 +15,7 @@ Export only selected columns in select
Bulk database creation
Include views in drop and move on database overview
Hide fieldsets in select
Automatically add new fields in table creation
Use \n in SQL commands
phpMinAdmin 1.10.1: