Add button for dropping an index
This commit is contained in:
parent
2f1b337d9e
commit
1a0ba88f8d
|
@ -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') . "'> "
|
||||
. "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'> "
|
||||
: "");
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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> </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++;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue