1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 15:47:00 +02:00

Confirm before exiting edited edit form

This commit is contained in:
Jakub Vrana
2025-03-20 17:15:18 +01:00
parent a2586e7265
commit a705be7a94
4 changed files with 27 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
## Adminer dev
- Confirm before exiting edited edit form
- Display collation at table structure if different from table
- PostgreSQL: Display auto_increment of inserted rows
- PostgreSQL: Display description of system variables

View File

@@ -81,6 +81,7 @@ if ($in) {
echo "\n";
}
echo "</table>\n";
echo script("setupEditChange(qsl('form'));");
}
?>
<p>

View File

@@ -337,7 +337,7 @@ function input($field, $value, $function, $autofocus = false) {
$first++;
}
if ($first) {
echo script("mixin(qsl('td'), {onchange: partial(skipOriginal, $first), oninput: function () { this.onchange(); }});");
echo script("mixin(qsl('td'), {oninput: partial(skipOriginal, $first)});");
}
}
}
@@ -513,6 +513,7 @@ function edit_form($table, $fields, $row, $update) {
;
}
echo "</table>\n";
echo script("setupEditChange(qsl('form'));");
}
echo "<p>\n";
if ($fields) {

View File

@@ -575,6 +575,29 @@ function fieldChange() {
let editChanged;
/** Setup saving editChanged on form fields
* @this HTMLFormElement
*/
function setupEditChange(form) {
for (const el of qsa('input, select, textarea', form)) {
el.addEventListener('change', () => {
editChanged = true;
});
}
form.onsubmit = () => {
editChanged = null; // false doesn't work in Chrome
}
}
onbeforeunload = () => {
// all modern browsers ignore string returned from here
return editChanged;
};
/** Create AJAX request
* @param string
* @param function (XMLHttpRequest)