diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index bbf788b1..2346a5f7 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -406,7 +406,10 @@ class Adminer { . optionlist(array(-1 => "") + array_filter(array(lang('Functions') => $functions, lang('Aggregation') => $grouping)), $val["fun"]) . "" . 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) . "\n"; + . "($column)" : $column) + . " " + . script('qsl(".icon").onclick = selectRemoveRow;', "") + . "\n"; $i++; } echo "\n"; @@ -442,6 +445,8 @@ class Adminer { echo html_select("where[$i][op]", $this->operators, $val["op"], $change_next); echo ""; echo script("mixin(qsl('input'), {oninput: function () { $change_next }, onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", ""); + echo " "; + echo script('qsl(".icon").onclick = selectRemoveRow;', ""); echo "\n"; } } @@ -460,12 +465,18 @@ class Adminer { foreach ((array) $_GET["order"] as $key => $val) { if ($val != "") { echo "
" . select_input(" name='order[$i]'", $columns, $val, "selectFieldChange"); - echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending')) . "
\n"; + echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending')); + echo " "; + echo script('qsl(".icon").onclick = selectRemoveRow;', ""); + echo "\n"; $i++; } } echo "
" . select_input(" name='order[$i]'", $columns, "", "selectAddRow"); - echo checkbox("desc[$i]", 1, false, lang('descending')) . "
\n"; + echo checkbox("desc[$i]", 1, false, lang('descending')); + echo " "; + echo script('qsl(".icon").onclick = selectRemoveRow;', ""); + echo "\n"; echo "\n"; } diff --git a/adminer/select.inc.php b/adminer/select.inc.php index b886b175..97afbd66 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -253,6 +253,7 @@ if (!$columns && support("table")) { hidden_fields_get(); echo (DB != "" ? '' . (isset($_GET["ns"]) ? '' : "") : ""); // not used in Editor echo ''; + echo ''; # hidden default submit so filter remove buttons aren't "clicked" on submission from enter key echo "\n"; $adminer->selectColumnsPrint($select, $columns); $adminer->selectSearchPrint($where, $search_columns, $indexes); diff --git a/adminer/static/default.css b/adminer/static/default.css index beeba98d..6c18286f 100644 --- a/adminer/static/default.css +++ b/adminer/static/default.css @@ -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; } diff --git a/adminer/static/functions.js b/adminer/static/functions.js index c27acf4b..787e3619 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -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 diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 5cf02dc9..fc30d10f 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -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 "
"; echo html_select("where[$i][op]", array(-1 => "") + $this->operators, $val["op"]); - echo "" . script("mixin(qsl('input'), {onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", "") . "
\n"; + echo "" . script("mixin(qsl('input'), {onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", ""); + echo " " . script('qsl(".icon").onclick = selectRemoveRow;', ""); + echo "\n"; $i++; } } echo "
"; echo script("qsl('select').onchange = selectAddRow;", ""); echo html_select("where[$i][op]", array(-1 => "") + $this->operators); - echo "
"; + echo ""; echo script("mixin(qsl('input'), {onchange: function () { this.parentNode.firstChild.onchange(); }, onsearch: selectSearchSearch});"); + echo " "; + echo script('qsl(".icon").onclick = selectRemoveRow;', ""); + echo ""; echo "\n"; }