]> git.joonet.de Git - adminer.git/commitdiff
Add button for dropping an index
authorJakub Vrana <jakub@vrana.cz>
Sun, 7 Jul 2013 06:35:26 +0000 (23:35 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sun, 7 Jul 2013 06:35:26 +0000 (23:35 -0700)
adminer/include/editing.inc.php
adminer/indexes.inc.php
adminer/static/editing.js
changes.txt

index 814e6778af6742de41673ab3ff5a0ccf28bdc50e..97dc62d84a206baace319310a42f3224c1608c57 100644 (file)
@@ -260,7 +260,7 @@ echo checkbox("fields[$i][has_default]", 1, $field["has_default"]); ?><input nam
                        . "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'>&nbsp;"
                        . "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'>&nbsp;"
                : "");
-               echo ($orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick='return !editingRemoveRow(this);'>" : "");
+               echo ($orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'fields\$1[field]');\">" : "");
                echo "\n";
        }
 }
index 8ca12c617899cc7950dfbba4f5bd449b95e7c42b..bc4291f8487b4d25f83877b4994b2d0aba4e52a9 100644 (file)
@@ -12,7 +12,7 @@ if ($jush == "sqlite") { // doesn't support primary key
 }
 $row = $_POST;
 
-if ($_POST && !$error && !$_POST["add"]) {
+if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
        $alter = array();
        foreach ($row["indexes"] as $index) {
                $name = $index["name"];
@@ -94,23 +94,27 @@ if (!$row) {
 
 <form action="" method="post">
 <table cellspacing="0" class="nowrap">
-<thead><tr><th><?php echo lang('Index Type'); ?><th><?php echo lang('Column (length)'); ?><th><?php echo lang('Name'); ?></thead>
+<thead><tr><th><?php echo lang('Index Type'); ?><th><?php echo lang('Column (length)'); ?><th><?php echo lang('Name'); ?><th>&nbsp;</thead>
 <?php
 $j = 1;
 foreach ($row["indexes"] as $index) {
-       echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow(this);" : 1)) . "<td>";
-       ksort($index["columns"]);
-       
-       $i = 1;
-       foreach ($index["columns"] as $key => $column) {
-               echo "<span>" . html_select("indexes[$j][columns][$i]", array(-1 => "") + $fields, $column, ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . "(this, '" . js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "');");
-               echo ($jush == "sql" || $jush == "mssql" ? "<input type='number' name='indexes[$j][lengths][$i]' class='size' value='" . h($index["lengths"][$key]) . "'>" : "");
-               echo ($jush != "sql" ? checkbox("indexes[$j][descs][$i]", 1, $index["descs"][$key], lang('descending')) : "");
-               echo " </span>";
-               $i++;
+       if (!$_POST["drop_col"] || $j != key($_POST["drop_col"])) {
+               echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow(this);" : 1));
+               
+               echo "<td>";
+               ksort($index["columns"]);
+               $i = 1;
+               foreach ($index["columns"] as $key => $column) {
+                       echo "<span>" . html_select("indexes[$j][columns][$i]", array(-1 => "") + $fields, $column, ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . "(this, '" . js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "');");
+                       echo ($jush == "sql" || $jush == "mssql" ? "<input type='number' name='indexes[$j][lengths][$i]' class='size' value='" . h($index["lengths"][$key]) . "'>" : "");
+                       echo ($jush != "sql" ? checkbox("indexes[$j][descs][$i]", 1, $index["descs"][$key], lang('descending')) : "");
+                       echo " </span>";
+                       $i++;
+               }
+               
+               echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off'>\n";
+               echo "<td><input type='image' class='icon' name='drop_col[$j]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'indexes\$1[type]');\">\n";
        }
-       
-       echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off'>\n";
        $j++;
 }
 ?>
index 4fc0233c0b5335a1280b1b9a73c5d4fb4c72fa7f..807c7f4a4fdc0fc97242ee1315b100513dee878f 100644 (file)
@@ -335,10 +335,11 @@ function editingAddRow(button, focus) {
 
 /** Remove table row for field
 * @param HTMLInputElement
+* @param string
 * @return boolean
 */
-function editingRemoveRow(button) {
-       var field = formField(button.form, button.name.replace(/drop_col(.+)/, 'fields$1[field]'));
+function editingRemoveRow(button, name) {
+       var field = formField(button.form, button.name.replace(/drop_col(.+)/, name));
        field.parentNode.removeChild(field);
        parentTag(button, 'tr').style.display = 'none';
        return true;
index aa1bf0f0b83006166e5376f2bcc9cbdbdcd23ec7..ca1c3d56f4d906ec968ac37433d25696bd4fceaf 100644 (file)
@@ -3,6 +3,7 @@ Save and continue edit by AJAX
 Add a new column in alter table on key press
 Mark length as required for strings
 Add label to database selection
+Add button for dropping an index
 PostgreSQL: Fix handling of nextval() default values
 
 Adminer 3.7.1 (released 2013-06-29):