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;
|
||||
}
|
||||
|
||||
if ($_POST) {
|
||||
set_adminer_settings(array("comments" => $_POST["comments"], "defaults" => $_POST["defaults"]));
|
||||
}
|
||||
|
||||
if ($_POST && !process_fields($row["fields"]) && !$error) {
|
||||
if ($_POST["drop"]) {
|
||||
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">
|
||||
<table cellspacing="0" id="edit-fields" class="nowrap">
|
||||
<?php
|
||||
$comments = ($_POST ? $_POST["comments"] : $row["Comment"] != "");
|
||||
if (!$_POST && !$comments) {
|
||||
foreach ($row["fields"] as $field) {
|
||||
if ($field["comment"] != "") {
|
||||
$comments = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
|
||||
edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
<p>
|
||||
<?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 ($_POST ? "" : script("editingHideDefaults();")); ?>
|
||||
<?php echo checkbox("defaults", 1, ($_POST ? $_POST["defaults"] : adminer_setting("defaults")), lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
|
||||
<?php echo (support("comment")
|
||||
? "<label><input type='checkbox' name='comments' value='1' class='jsonly'" . ($comments ? " checked" : "") . ">" . lang('Comment') . "</label>"
|
||||
. script("qsl('input').onclick = partial(editingCommentsClick, true);")
|
||||
. ' <input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? '' : ' class="hidden"') . '>'
|
||||
? checkbox("comments", 1, ($_POST ? $_POST["comments"] : adminer_setting("comments")), lang('Comment'), "editingCommentsClick(this, true);", "jsonly")
|
||||
. ' <input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '">'
|
||||
: '')
|
||||
; ?>
|
||||
<p>
|
||||
|
@ -227,4 +220,4 @@ foreach ($row["partition_names"] as $key => $val) {
|
|||
?>
|
||||
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||
</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;
|
||||
}
|
||||
|
||||
/** 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
|
||||
* @param string
|
||||
* @param string or array in which case [0] of every element is used
|
||||
|
@ -236,10 +261,9 @@ function type_class($type) {
|
|||
* @param array
|
||||
* @param string TABLE or PROCEDURE
|
||||
* @param array returned by referencable_primary()
|
||||
* @param bool display comments column
|
||||
* @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;
|
||||
$fields = array_values($fields);
|
||||
?>
|
||||
|
@ -259,7 +283,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
|
|||
'mssql' => "ms186775.aspx",
|
||||
)); ?>
|
||||
<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 } ?>
|
||||
<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>
|
||||
|
@ -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><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 (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 (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
|
||||
* @this HTMLSelectElement
|
||||
*/
|
||||
|
@ -489,14 +481,14 @@ function partitionNameChange() {
|
|||
}
|
||||
|
||||
/** Show or hide comment fields
|
||||
* @param HTMLInputElement
|
||||
* @param [boolean] whether to focus Comment if checked
|
||||
* @this HTMLInputElement
|
||||
*/
|
||||
function editingCommentsClick(focus) {
|
||||
var comment = this.form['Comment'];
|
||||
columnShow(this.checked, 6);
|
||||
alterClass(comment, 'hidden', !this.checked);
|
||||
if (focus && this.checked) {
|
||||
function editingCommentsClick(el, focus) {
|
||||
var comment = el.form['Comment'];
|
||||
columnShow(el.checked, 6);
|
||||
alterClass(comment, 'hidden', !el.checked);
|
||||
if (focus && el.checked) {
|
||||
comment.focus();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Adminer 4.7.1-dev:
|
||||
Display the tables scrollbar (bug #647)
|
||||
Remember visible columns in Create Table form (bug #493)
|
||||
Add autocomplete attributes to login form
|
||||
PHP <5.4 compatibility even with ClickHouse enabled (regression from 4.7.0)
|
||||
SQLite: Hide server field in login form
|
||||
|
|
Loading…
Reference in a new issue