Consistent filter remove buttons

Match row removal buttons on alter table screens.
This commit is contained in:
Roy Orbitson 2023-11-21 11:24:02 +10:30
parent 0fe04741c2
commit ccbee25538
5 changed files with 22 additions and 16 deletions

View file

@ -372,8 +372,8 @@ class Adminer {
. 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)
. ' <button type="button" class="jsonly" title="', h(lang('Remove')), '">x</button>'
. script('qsl("button").onclick = selectRemoveRow;', "")
. " <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++;
}
@ -410,8 +410,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 '<button type="button" class="jsonly" title="', h(lang('Remove')), '">x</button>';
echo script('qsl("button").onclick = selectRemoveRow;', "");
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";
}
}
@ -431,16 +431,16 @@ class Adminer {
if ($val != "") {
echo "<div>" . select_input(" name='order[$i]'", $columns, $val, "selectFieldChange");
echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending'));
echo ' <button type="button" class="jsonly" title="', h(lang('Remove')), '">x</button>';
echo script('qsl("button").onclick = selectRemoveRow;', "");
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'));
echo ' <button type="button" class="jsonly" title="', h(lang('Remove')), '">x</button>';
echo script('qsl("button").onclick = selectRemoveRow;', "");
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";
}

View file

@ -243,6 +243,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, $columns, $indexes);

View file

@ -33,8 +33,8 @@ input[type='submit'] { padding-left: 10px; padding-right: 10px; }
select { border-radius: 5px; padding: 2px; vertical-align: middle;; }
fieldset label input[type='checkbox'] { margin-bottom: 6px; }
fieldset a { line-height: 20px; }
#fieldset-select div:last-child > button, #fieldset-search div:last-child > button, #fieldset-sort div:last-child > button { display: none; }
#fieldset-select button, #fieldset-search button, #fieldset-sort button { width: 16px; height: 16px; margin-bottom: 8px; line-height: 8px; border: 0px; }
#fieldset-select .icon, #fieldset-search .icon, #fieldset-sort .icon { cursor: pointer; }
#fieldset-select div:last-child > .icon, #fieldset-search div:last-child > .icon, #fieldset-sort div:last-child > .icon { display: none; }
span.separator { margin-left: 5px; margin-right: 5px; }
.block { display: block; }
.version { color: #777; font-size: 50%; }

View file

@ -386,6 +386,10 @@ function selectAddRow() {
}
var inputs = qsa('input', row);
for (var i=0; i < inputs.length; i++) {
if (inputs[i].type === 'image') {
// button
continue;
}
inputs[i].name = inputs[i].name.replace(/[a-z]\[\d+/, '$&1');
inputs[i].className = '';
if (inputs[i].type == 'checkbox') {
@ -394,7 +398,7 @@ function selectAddRow() {
inputs[i].value = '';
}
}
var buttons = qsa('button', row);
var buttons = qsa('.icon', row);
for (var i=0; i < buttons.length; i++) {
buttons[i].onclick = selectRemoveRow;
}
@ -402,7 +406,7 @@ function selectAddRow() {
}
/** Remove a row in select fieldset
* @this HTMLButtonElement
* @this HTMLInputElement
*/
function selectRemoveRow() {
var button = this;
@ -411,9 +415,10 @@ function selectRemoveRow() {
while (nextRow = nextRow.nextSibling) {
if (nextRow.tagName === row.tagName) {
row.parentNode.removeChild(row);
return;
break;
}
}
return false;
}
/** Prevent onsearch handler on Enter

View file

@ -260,7 +260,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
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});", "");
echo '<button type="button" class="jsonly" title="', h(lang('remove')), '">x</button>' . script('qsl("button").onclick = selectRemoveRow;', "");
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++;
}
@ -270,8 +270,8 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
echo html_select("where[$i][op]", array(-1 => "") + $this->operators);
echo "<input type='search' name='where[$i][val]'>";
echo script("mixin(qsl('input'), {onchange: function () { this.parentNode.firstChild.onchange(); }, onsearch: selectSearchSearch});");
echo '<button type="button" class="jsonly" title="', h(lang('remove')), '">x</button>';
echo script('qsl("button").onclick = selectRemoveRow;', "");
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";
}