]> git.joonet.de Git - adminer.git/commitdiff
Speed up alter table form
authorJakub Vrana <jakub@vrana.cz>
Fri, 20 Dec 2019 12:50:20 +0000 (13:50 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 20 Dec 2019 12:50:20 +0000 (13:50 +0100)
adminer/create.inc.php
adminer/include/editing.inc.php
adminer/procedure.inc.php
adminer/static/editing.js
changes.txt

index 0b34a90f38f2d2053229d6e7ebdd6a2871dc83b9..05a4df412abc99d9ef5f307401842a8016516788 100644 (file)
@@ -180,6 +180,7 @@ foreach ($engines as $engine) {
 edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
 ?>
 </table>
+<?php echo script("editFields();"); ?>
 </div>
 <p>
 <?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" size="6" value="<?php echo h($row["Auto_increment"]); ?>">
index 18594eb34691f5d286e81c987ea73391259a8276..c8677c85a7c1cf1a3a512ea4fabcf1125764195a 100644 (file)
@@ -177,9 +177,7 @@ if ($foreign_keys) {
        $structured_types[lang('Foreign keys')] = $foreign_keys;
 }
 echo optionlist(array_merge($extra_types, $structured_types), $type);
-?></select><?php echo on_help("getTarget(event).value", 1); ?>
-<?php echo script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});", ""); ?>
-<td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); //! type="number" with enabled JavaScript ?> aria-labelledby="label-length"><?php echo script("mixin(qsl('input'), {onfocus: editingLengthFocus, oninput: editingLengthChange});", ""); ?><td class="options"><?php
+?></select><td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); //! type="number" with enabled JavaScript ?> aria-labelledby="label-length"><td class="options"><?php
        echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
        echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match(number_type(), $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
        echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), (preg_match('~^CURRENT_TIMESTAMP~i', $field["on_update"]) ? "CURRENT_TIMESTAMP" : $field["on_update"])) . '</select>' : '');
@@ -296,7 +294,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
                ?>
 <tr<?php echo ($display ? "" : " style='display: none;'"); ?>>
 <?php echo ($type == "PROCEDURE" ? "<td>" . html_select("fields[$i][inout]", explode("|", $inout), $field["inout"]) : ""); ?>
-<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" data-maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php echo script("qsl('input').oninput = function () { editingNameChange.call(this);" . ($field["field"] != "" || count($fields) > 1 ? "" : " editingAddRow.call(this);") . " };", ""); ?><?php } ?>
+<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" data-maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?>
 <input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>"><?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
 <?php if ($type == "TABLE") { ?>
 <td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?>
index cd3594d0704ca8c2bf0ede58de64edf1809351b4..949ecb533305856bee5b2ad5dcd9a9fc9d13a69d 100644 (file)
@@ -48,6 +48,7 @@ if (isset($_GET["function"])) {
 }
 ?>
 </table>
+<?php echo script("editFields();"); ?>
 </div>
 <p><?php textarea("definition", $row["definition"]); ?>
 <p>
index d4ae1d239fcc53962620a7e74c29cab89977511f..a3b5157037819320fefc5b0f098f4861369dc1d8 100644 (file)
@@ -207,6 +207,33 @@ function idfEscape(s) {
 
 
 
+/** Set up event handlers for edit_fields().
+*/
+function editFields() {
+       var els = qsa('[name$="[field]"]');
+       for (var i = 0; i < els.length; i++) {
+               els[i].oninput = function () {
+                       editingNameChange.call(this);
+                       if (!this.defaultValue) {
+                               editingAddRow.call(this);
+                       }
+               }
+       }
+       els = qsa('[name$="[length]"]');
+       for (var i = 0; i < els.length; i++) {
+               mixin(els[i], {onfocus: editingLengthFocus, oninput: editingLengthChange});
+       }
+       els = qsa('[name$="[type]"]');
+       for (var i = 0; i < els.length; i++) {
+               mixin(els[i], {
+                       onfocus: function () { lastType = selectValue(this); },
+                       onchange: editingTypeChange,
+                       onmouseover: function (event) { helpMouseover.call(this, event, getTarget(event).value, 1) },
+                       onmouseout: helpMouseout
+               });
+       }
+}
+
 /** Handle clicks on fields editing
 * @param MouseEvent
 * @return boolean false to cancel action
@@ -289,7 +316,7 @@ function editingNameChange() {
 }
 
 /** Add table row for next field
-* @param boolean
+* @param [boolean]
 * @return boolean false
 * @this HTMLInputElement
 */
index b7705c45a1ffabf736fb29e0a71fb229235842a8..c43d33ceef2f848cb1c3a090e5b8670b5903efe2 100644 (file)
@@ -1,4 +1,5 @@
 Adminer 4.7.6-dev:
+Speed up alter table form (regression from 4.4.0)
 Fix clicking on non-input fields in alter table (regression from 4.6.2)
 MySQL: Always set foreign_key_checks in export
 Editor: Fix focusing foreign key search in select
@@ -686,7 +687,7 @@ Print ALTER export instead of executing it
 Click on row selects it
 Fix Editor date format
 Fix long SQL query crash (bug #2839231)
-Speedup of simple alter table
+Speed up simple alter table
 Traditional Chinese translation
 
 Adminer 2.0.0 (released 2009-08-06):