Remember visible columns in Create Table form (bug #493)
This commit is contained in:
parent
7defb7787d
commit
21f0481a1d
|
@ -27,6 +27,10 @@ if ($row["auto_increment_col"]) {
|
||||||
$row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
|
$row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_POST) {
|
||||||
|
set_adminer_settings(array("comments" => $_POST["comments"], "defaults" => $_POST["defaults"]));
|
||||||
|
}
|
||||||
|
|
||||||
if ($_POST && !process_fields($row["fields"]) && !$error) {
|
if ($_POST && !process_fields($row["fields"]) && !$error) {
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
queries_redirect(substr(ME, 0, -1), lang('Table has been dropped.'), drop_tables(array($TABLE)));
|
queries_redirect(substr(ME, 0, -1), lang('Table has been dropped.'), drop_tables(array($TABLE)));
|
||||||
|
@ -173,27 +177,16 @@ foreach ($engines as $engine) {
|
||||||
<div class="scrollable">
|
<div class="scrollable">
|
||||||
<table cellspacing="0" id="edit-fields" class="nowrap">
|
<table cellspacing="0" id="edit-fields" class="nowrap">
|
||||||
<?php
|
<?php
|
||||||
$comments = ($_POST ? $_POST["comments"] : $row["Comment"] != "");
|
edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
|
||||||
if (!$_POST && !$comments) {
|
|
||||||
foreach ($row["fields"] as $field) {
|
|
||||||
if ($field["comment"] != "") {
|
|
||||||
$comments = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
|
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" size="6" value="<?php echo h($row["Auto_increment"]); ?>">
|
<?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" size="6" value="<?php echo h($row["Auto_increment"]); ?>">
|
||||||
<?php echo checkbox("defaults", 1, !$_POST || $_POST["defaults"], lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
|
<?php echo checkbox("defaults", 1, ($_POST ? $_POST["defaults"] : adminer_setting("defaults")), lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
|
||||||
<?php echo ($_POST ? "" : script("editingHideDefaults();")); ?>
|
|
||||||
<?php echo (support("comment")
|
<?php echo (support("comment")
|
||||||
? "<label><input type='checkbox' name='comments' value='1' class='jsonly'" . ($comments ? " checked" : "") . ">" . lang('Comment') . "</label>"
|
? checkbox("comments", 1, ($_POST ? $_POST["comments"] : adminer_setting("comments")), lang('Comment'), "editingCommentsClick(this, true);", "jsonly")
|
||||||
. script("qsl('input').onclick = partial(editingCommentsClick, true);")
|
. ' <input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '">'
|
||||||
. ' <input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? '' : ' class="hidden"') . '>'
|
|
||||||
: '')
|
: '')
|
||||||
; ?>
|
; ?>
|
||||||
<p>
|
<p>
|
||||||
|
@ -227,4 +220,4 @@ foreach ($row["partition_names"] as $key => $val) {
|
||||||
?>
|
?>
|
||||||
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||||
</form>
|
</form>
|
||||||
<?php echo script("qs('#form')['defaults'].onclick();" . (support("comment") ? " editingCommentsClick.call(qs('#form')['comments']);" : "")); ?>
|
<?php echo script("qs('#form')['defaults'].onclick();" . (support("comment") ? " editingCommentsClick(qs('#form')['comments']);" : "")); ?>
|
||||||
|
|
|
@ -112,6 +112,31 @@ function referencable_primary($self) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get settings stored in a cookie
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function adminer_settings() {
|
||||||
|
parse_str($_COOKIE["adminer_settings"], $settings);
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get setting stored in a cookie
|
||||||
|
* @param string
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function adminer_setting($key) {
|
||||||
|
$settings = adminer_settings();
|
||||||
|
return $settings[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Store settings to a cookie
|
||||||
|
* @param array
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function set_adminer_settings($settings) {
|
||||||
|
return cookie("adminer_settings", http_build_query($settings + adminer_settings()));
|
||||||
|
}
|
||||||
|
|
||||||
/** Print SQL <textarea> tag
|
/** Print SQL <textarea> tag
|
||||||
* @param string
|
* @param string
|
||||||
* @param string or array in which case [0] of every element is used
|
* @param string or array in which case [0] of every element is used
|
||||||
|
@ -236,10 +261,9 @@ function type_class($type) {
|
||||||
* @param array
|
* @param array
|
||||||
* @param string TABLE or PROCEDURE
|
* @param string TABLE or PROCEDURE
|
||||||
* @param array returned by referencable_primary()
|
* @param array returned by referencable_primary()
|
||||||
* @param bool display comments column
|
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = array(), $comments = false) {
|
function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = array()) {
|
||||||
global $inout;
|
global $inout;
|
||||||
$fields = array_values($fields);
|
$fields = array_values($fields);
|
||||||
?>
|
?>
|
||||||
|
@ -259,7 +283,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
|
||||||
'mssql' => "ms186775.aspx",
|
'mssql' => "ms186775.aspx",
|
||||||
)); ?>
|
)); ?>
|
||||||
<td id="label-default"><?php echo lang('Default value'); ?>
|
<td id="label-default"><?php echo lang('Default value'); ?>
|
||||||
<?php echo (support("comment") ? "<td id='label-comment'" . ($comments ? "" : " class='hidden'") . ">" . lang('Comment') : ""); ?>
|
<?php echo (support("comment") ? "<td id='label-comment'>" . lang('Comment') : ""); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<td><?php echo "<input type='image' class='icon' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>" . script("row_count = " . count($fields) . ";"); ?>
|
<td><?php echo "<input type='image' class='icon' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>" . script("row_count = " . count($fields) . ";"); ?>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -280,7 +304,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
|
||||||
<td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?>
|
<td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?>
|
||||||
<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> aria-labelledby="label-ai"></label><td><?php
|
<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> aria-labelledby="label-ai"></label><td><?php
|
||||||
echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php
|
echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php
|
||||||
echo (support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . "><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' data-maxlength='" . (min_version(5.5) ? 1024 : 255) . "' aria-labelledby='label-comment'>" : "");
|
echo (support("comment") ? "<td><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' data-maxlength='" . (min_version(5.5) ? 1024 : 255) . "' aria-labelledby='label-comment'>" : "");
|
||||||
}
|
}
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
echo (support("move_col") ?
|
echo (support("move_col") ?
|
||||||
|
|
|
@ -460,14 +460,6 @@ function columnShow(checked, column) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hide column with default values in narrow window
|
|
||||||
*/
|
|
||||||
function editingHideDefaults() {
|
|
||||||
if (innerWidth < document.documentElement.scrollWidth) {
|
|
||||||
qs('#form')['defaults'].checked = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Display partition options
|
/** Display partition options
|
||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
|
@ -489,14 +481,14 @@ function partitionNameChange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show or hide comment fields
|
/** Show or hide comment fields
|
||||||
|
* @param HTMLInputElement
|
||||||
* @param [boolean] whether to focus Comment if checked
|
* @param [boolean] whether to focus Comment if checked
|
||||||
* @this HTMLInputElement
|
|
||||||
*/
|
*/
|
||||||
function editingCommentsClick(focus) {
|
function editingCommentsClick(el, focus) {
|
||||||
var comment = this.form['Comment'];
|
var comment = el.form['Comment'];
|
||||||
columnShow(this.checked, 6);
|
columnShow(el.checked, 6);
|
||||||
alterClass(comment, 'hidden', !this.checked);
|
alterClass(comment, 'hidden', !el.checked);
|
||||||
if (focus && this.checked) {
|
if (focus && el.checked) {
|
||||||
comment.focus();
|
comment.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
Adminer 4.7.1-dev:
|
Adminer 4.7.1-dev:
|
||||||
Display the tables scrollbar (bug #647)
|
Display the tables scrollbar (bug #647)
|
||||||
|
Remember visible columns in Create Table form (bug #493)
|
||||||
Add autocomplete attributes to login form
|
Add autocomplete attributes to login form
|
||||||
PHP <5.4 compatibility even with ClickHouse enabled (regression from 4.7.0)
|
PHP <5.4 compatibility even with ClickHouse enabled (regression from 4.7.0)
|
||||||
SQLite: Hide server field in login form
|
SQLite: Hide server field in login form
|
||||||
|
|
Loading…
Reference in a new issue