mirror of
https://github.com/vrana/adminer.git
synced 2025-08-29 17:19:52 +02:00
Add removal buttons to table data filter
This commit is contained in:
@@ -406,7 +406,10 @@ class Adminer {
|
||||
. optionlist(array(-1 => "") + array_filter(array(lang('Functions') => $functions, lang('Aggregation') => $grouping)), $val["fun"]) . "</select>"
|
||||
. on_help("getTarget(event).value && getTarget(event).value.replace(/ |\$/, '(') + ')'", 1)
|
||||
. script("qsl('select').onchange = function () { helpClose();" . ($key !== "" ? "" : " qsl('select, input', this.parentNode).onchange();") . " };", "")
|
||||
. "($column)" : $column) . "</div>\n";
|
||||
. "($column)" : $column)
|
||||
. " <input type='image' src='../adminer/static/cross.gif' class='jsonly icon' title='" . h(lang('Remove')) . "' alt='x'>"
|
||||
. script('qsl(".icon").onclick = selectRemoveRow;', "")
|
||||
. "</div>\n";
|
||||
$i++;
|
||||
}
|
||||
echo "</div></fieldset>\n";
|
||||
@@ -442,6 +445,8 @@ class Adminer {
|
||||
echo html_select("where[$i][op]", $this->operators, $val["op"], $change_next);
|
||||
echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "'>";
|
||||
echo script("mixin(qsl('input'), {oninput: function () { $change_next }, onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", "");
|
||||
echo " <input type='image' src='../adminer/static/cross.gif' class='jsonly icon' title='" . h(lang('Remove')) . "' alt='x'>";
|
||||
echo script('qsl(".icon").onclick = selectRemoveRow;', "");
|
||||
echo "</div>\n";
|
||||
}
|
||||
}
|
||||
@@ -460,12 +465,18 @@ class Adminer {
|
||||
foreach ((array) $_GET["order"] as $key => $val) {
|
||||
if ($val != "") {
|
||||
echo "<div>" . select_input(" name='order[$i]'", $columns, $val, "selectFieldChange");
|
||||
echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending')) . "</div>\n";
|
||||
echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending'));
|
||||
echo " <input type='image' src='../adminer/static/cross.gif' class='jsonly icon' title='" . h(lang('Remove')) . "' alt='x'>";
|
||||
echo script('qsl(".icon").onclick = selectRemoveRow;', "");
|
||||
echo "</div>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo "<div>" . select_input(" name='order[$i]'", $columns, "", "selectAddRow");
|
||||
echo checkbox("desc[$i]", 1, false, lang('descending')) . "</div>\n";
|
||||
echo checkbox("desc[$i]", 1, false, lang('descending'));
|
||||
echo " <input type='image' src='../adminer/static/cross.gif' class='jsonly icon' title='" . h(lang('Remove')) . "' alt='x'>";
|
||||
echo script('qsl(".icon").onclick = selectRemoveRow;', "");
|
||||
echo "</div>\n";
|
||||
echo "</div></fieldset>\n";
|
||||
}
|
||||
|
||||
|
@@ -253,6 +253,7 @@ if (!$columns && support("table")) {
|
||||
hidden_fields_get();
|
||||
echo (DB != "" ? '<input type="hidden" name="db" value="' . h(DB) . '">' . (isset($_GET["ns"]) ? '<input type="hidden" name="ns" value="' . h($_GET["ns"]) . '">' : "") : ""); // not used in Editor
|
||||
echo '<input type="hidden" name="select" value="' . h($TABLE) . '">';
|
||||
echo '<input type="submit" value="' . h(lang('Select')) . '">'; # hidden default submit so filter remove buttons aren't "clicked" on submission from enter key
|
||||
echo "</div>\n";
|
||||
$adminer->selectColumnsPrint($select, $columns);
|
||||
$adminer->selectSearchPrint($where, $search_columns, $indexes);
|
||||
|
@@ -87,6 +87,7 @@ input::placeholder { color: #000; opacity: 0.4; }
|
||||
#schema .references { position: absolute; }
|
||||
#tables-filter, #database-select, #scheme-select { width: 100%; }
|
||||
#help { position: absolute; border: 1px solid #999; background: #eee; padding: 5px; font-family: monospace; z-index: 1; }
|
||||
#fieldset-select div:last-child > .icon, #fieldset-search div:last-child > .icon, #fieldset-sort div:last-child > .icon { display: none; }
|
||||
|
||||
.rtl h2 { margin: 0 -18px 20px 0; }
|
||||
.rtl p, .rtl table, .rtl .error, .rtl .message { margin: 1em 0 0 20px; }
|
||||
|
@@ -450,32 +450,61 @@ function menuOut() {
|
||||
|
||||
|
||||
|
||||
/** Add row in select fieldset
|
||||
* @this HTMLSelectElement
|
||||
*/
|
||||
/**
|
||||
* Adds row in select fieldset.
|
||||
*
|
||||
* @this HTMLSelectElement
|
||||
*/
|
||||
function selectAddRow() {
|
||||
var field = this;
|
||||
var row = cloneNode(field.parentNode);
|
||||
const field = this;
|
||||
const row = cloneNode(field.parentNode);
|
||||
|
||||
field.onchange = selectFieldChange;
|
||||
field.onchange();
|
||||
var selects = qsa('select', row);
|
||||
for (var i=0; i < selects.length; i++) {
|
||||
selects[i].name = selects[i].name.replace(/[a-z]\[\d+/, '$&1');
|
||||
selects[i].selectedIndex = 0;
|
||||
|
||||
const selects = qsa('select', row);
|
||||
for (const select of selects) {
|
||||
select.name = select.name.replace(/[a-z]\[\d+/, '$&1');
|
||||
select.selectedIndex = 0;
|
||||
}
|
||||
var inputs = qsa('input', row);
|
||||
for (var i=0; i < inputs.length; i++) {
|
||||
inputs[i].name = inputs[i].name.replace(/[a-z]\[\d+/, '$&1');
|
||||
inputs[i].className = '';
|
||||
if (inputs[i].type === 'checkbox') {
|
||||
inputs[i].checked = false;
|
||||
|
||||
const inputs = qsa('input', row);
|
||||
for (const input of inputs) {
|
||||
// Skip buttons.
|
||||
if (input.type === 'image') {
|
||||
continue;
|
||||
}
|
||||
|
||||
input.name = input.name.replace(/[a-z]\[\d+/, '$&1');
|
||||
input.className = '';
|
||||
if (input.type === 'checkbox') {
|
||||
input.checked = false;
|
||||
} else {
|
||||
inputs[i].value = '';
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
const buttons = qsa('.icon', row);
|
||||
for (const button of buttons) {
|
||||
button.onclick = selectRemoveRow;
|
||||
}
|
||||
|
||||
field.parentNode.parentNode.appendChild(row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a row in select fieldset.
|
||||
*
|
||||
* @this HTMLInputElement
|
||||
*/
|
||||
function selectRemoveRow() {
|
||||
const row = this.parentNode;
|
||||
|
||||
row.parentNode.removeChild(row);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Prevent onsearch handler on Enter
|
||||
* @param KeyboardEvent
|
||||
* @this HTMLInputElement
|
||||
|
@@ -262,15 +262,20 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||
if (($val["col"] == "" || $columns[$val["col"]]) && "$val[col]$val[val]" != "") {
|
||||
echo "<div><select name='where[$i][col]'><option value=''>(" . lang('anywhere') . ")" . optionlist($columns, $val["col"], true) . "</select>";
|
||||
echo html_select("where[$i][op]", array(-1 => "") + $this->operators, $val["op"]);
|
||||
echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "'>" . script("mixin(qsl('input'), {onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", "") . "</div>\n";
|
||||
echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "'>" . script("mixin(qsl('input'), {onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", "");
|
||||
echo " <input type='image' src='../adminer/static/cross.gif' class='jsonly icon' title='" . h(lang('Remove')) . "' alt='x'>" . script('qsl(".icon").onclick = selectRemoveRow;', "");
|
||||
echo "</div>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo "<div><select name='where[$i][col]'><option value=''>(" . lang('anywhere') . ")" . optionlist($columns, null, true) . "</select>";
|
||||
echo script("qsl('select').onchange = selectAddRow;", "");
|
||||
echo html_select("where[$i][op]", array(-1 => "") + $this->operators);
|
||||
echo "<input type='search' name='where[$i][val]'></div>";
|
||||
echo "<input type='search' name='where[$i][val]'>";
|
||||
echo script("mixin(qsl('input'), {onchange: function () { this.parentNode.firstChild.onchange(); }, onsearch: selectSearchSearch});");
|
||||
echo " <input type='image' src='../adminer/static/cross.gif' class='jsonly icon' title='" . h(lang('Remove')) . "' alt='x'>";
|
||||
echo script('qsl(".icon").onclick = selectRemoveRow;', "");
|
||||
echo "</div>";
|
||||
echo "</div></fieldset>\n";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user