Merge pull request #77 from Roy-Orbison/select-remove-buttons
Filter removal buttons on table select pages
This commit is contained in:
commit
bc577cfb1e
4 changed files with 41 additions and 5 deletions
|
@ -371,7 +371,10 @@ class Adminer {
|
|||
. optionlist(array(-1 => "") + array_filter(array(lang('Functions') => $functions, lang('Aggregation') => $grouping)), $val["fun"] ?? null) . "</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)
|
||||
. ' <button type="button" class="jsonly" title="', h(lang('remove')), '">x</button>'
|
||||
. script('qsl("button").onclick = selectRemoveRow;', "")
|
||||
. "</div>\n";
|
||||
$i++;
|
||||
}
|
||||
echo "</div></fieldset>\n";
|
||||
|
@ -407,6 +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 "</div>\n";
|
||||
}
|
||||
}
|
||||
|
@ -425,12 +430,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 ' <button type="button" class="jsonly" title="', h(lang('remove')), '">x</button>';
|
||||
echo script('qsl("button").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 ' <button type="button" class="jsonly" title="', h(lang('remove')), '">x</button>';
|
||||
echo script('qsl("button").onclick = selectRemoveRow;', "");
|
||||
echo "</div>\n";
|
||||
echo "</div></fieldset>\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ 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; }
|
||||
span.separator { margin-left: 5px; margin-right: 5px; }
|
||||
.block { display: block; }
|
||||
.version { color: #777; font-size: 50%; }
|
||||
|
|
|
@ -394,9 +394,28 @@ function selectAddRow() {
|
|||
inputs[i].value = '';
|
||||
}
|
||||
}
|
||||
var buttons = qsa('button', row);
|
||||
for (var i=0; i < buttons.length; i++) {
|
||||
buttons[i].onclick = selectRemoveRow;
|
||||
}
|
||||
field.parentNode.parentNode.appendChild(row);
|
||||
}
|
||||
|
||||
/** Remove a row in select fieldset
|
||||
* @this HTMLButtonElement
|
||||
*/
|
||||
function selectRemoveRow() {
|
||||
var button = this;
|
||||
var row = button.parentNode;
|
||||
var nextRow = row;
|
||||
while (nextRow = nextRow.nextSibling) {
|
||||
if (nextRow.tagName === row.tagName) {
|
||||
row.parentNode.removeChild(row);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Prevent onsearch handler on Enter
|
||||
* @param KeyboardEvent
|
||||
* @this HTMLInputElement
|
||||
|
|
|
@ -259,15 +259,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 '<button type="button" class="jsonly" title="', h(lang('remove')), '">x</button>' . script('qsl("button").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 '<button type="button" class="jsonly" title="', h(lang('remove')), '">x</button>';
|
||||
echo script('qsl("button").onclick = selectRemoveRow;', "");
|
||||
echo "</div>";
|
||||
echo "</div></fieldset>\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue