Highlight primary key

This commit is contained in:
2025-04-21 17:46:56 -07:00
parent 6c062ad532
commit ff375abc90
2 changed files with 12 additions and 5 deletions

View File

@@ -392,13 +392,15 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
</td>
<td align="center" class="primary">
<?php
if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || ($primary && $primary->hasColumn($field_name))) {
$primary_enabled = false;
if ($primary && $primary->hasColumn($field_name)) {
$primary_extra_class = ' highlight';
} elseif ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
$primary_extra_class = ' disabled';
} else {
$primary_enabled = true;
$primary_extra_class = '';
}
?>
<a class="add_primary_key_anchor<?php echo $primary_enabled ? '' : ' disabled' ?>" href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
?>
<a class="add_primary_key_anchor<?php echo $primary_extra_class ?>" href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
<?php echo $titles['Primary']; ?></a>
</td>
<td align="center" class="unique">

View File

@@ -78,6 +78,11 @@ a.disabled {
filter: grayscale(1);
}
a.highlight {
cursor: default;
filter: grayscale(10%) sepia(40%) hue-rotate(50deg) saturate(150%);
}
dfn {
font-style: normal;
}