Update UI when coming from history

This commit is contained in:
Jakub Vrana 2018-02-09 17:35:17 +01:00
parent eeb7ce1939
commit 7ac96dd0b2
2 changed files with 16 additions and 2 deletions

View file

@ -190,8 +190,8 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
<?php if (!$_POST["defaults"]) { echo script("editingHideDefaults();"); } ?>
<?php echo (support("comment")
? "<label><input type='checkbox' name='comments' value='1' class='jsonly'" . ($comments ? " checked" : "") . ">" . lang('Comment') . "</label>"
. script("qsl('input').onclick = function () { columnShow(this.checked, 6); toggle('Comment'); if (this.checked) this.form['Comment'].focus(); };")
. ' <input name="Comment" id="Comment" value="' . h($row["Comment"]) . '" maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? '' : ' class="hidden"') . '>'
. script("qsl('input').onclick = partial(editingCommentsClick, true);")
. ' <input name="Comment" value="' . h($row["Comment"]) . '" maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? '' : ' class="hidden"') . '>'
: '')
; ?>
<p>
@ -225,3 +225,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']);" : "")); ?>

View file

@ -409,6 +409,19 @@ function partitionNameChange() {
this.oninput = function () {};
}
/** Show or hide comment fields
* @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) {
comment.focus();
}
}
/** Uncheck 'all' checkbox