Delete length when changing type

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1272 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-12-17 12:54:17 +00:00
parent 2a897fa301
commit 34a06f9901
4 changed files with 11 additions and 2 deletions

View file

@ -108,7 +108,7 @@ function referencable_primary($self) {
function edit_type($key, $field, $collations, $foreign_keys = array()) {
global $structured_types, $unsigned, $inout;
?>
<td><select name="<?php echo $key; ?>[type]" class="type" onchange="editing_type_change(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
<td><select name="<?php echo $key; ?>[type]" class="type" onfocus="last_type = select_value(this);" onchange="editing_type_change(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editing_length_focus(this);">
<td><?php
echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';

View file

@ -385,7 +385,7 @@ function exact_value($val) {
$types = array();
$structured_types = array();
foreach (array(
lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "float" => 12, "double" => 21, "decimal" => 66),
lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21),
lang('Date and time') => array("date" => 10, "datetime" => 19, "timestamp" => 19, "time" => 10, "year" => 4),
lang('Strings') => array("char" => 255, "varchar" => 65535, "tinytext" => 255, "text" => 65535, "mediumtext" => 16777215, "longtext" => 4294967295),
lang('Binary') => array("binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295),

View file

@ -146,11 +146,18 @@ function editing_remove_row(button) {
return true;
}
var last_type = '';
function editing_type_change(type) {
var name = type.name.substr(0, type.name.length - 6);
var text = select_value(type);
for (var i=0; i < type.form.elements.length; i++) {
var el = type.form.elements[i];
if (el.name == name + '[length]' && !(
(/(char|binary)$/.test(last_type) && /(char|binary)$/.test(text))
|| (/(enum|set)$/.test(last_type) && /(enum|set)$/.test(text))
)) {
el.value = '';
}
if (el.name == name + '[collation]') {
el.className = (/(char|text|enum|set)$/.test(text) ? '' : 'hidden');
}

View file

@ -1,6 +1,8 @@
Adminer 2.2.2-dev:
Add Delete button to Edit page (regression from 2.0.0)
Simplify SQL syntax error message
Print SQL query info if available
Delete length when changing type
Adminer 2.2.1 (released 2009-11-26):
Highlight current links