]> git.joonet.de Git - adminer.git/commitdiff
Automatically add new fields in table creation
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 15 Jun 2009 11:53:16 +0000 (11:53 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 15 Jun 2009 11:53:16 +0000 (11:53 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@700 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/functions.js
adminer/include/editing.inc.php
changes.txt

index 0686a5248d4da1e524c492631e2317fd6f44cfca..101725385b151c93e0f7c4d4c60df8727b54efb2 100644 (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) {
index 292188350d10b377d2e14a84302a4628cb0c86a0..5f0f0a32835577e2c36b08bed066c312a6590574 100644 (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') . "' />";
index 8a304a869f354d2228b55720f07cd1659fc194f1..6733523719c97d731eb17c7f3ce04df0d9ec9bfd 100644 (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: