Compare commits

...

2 Commits

Author SHA1 Message Date
6180c4ec60 Highlight primary key 2025-04-21 17:46:56 -07:00
ce16b8c77c Cleanup indexes bar 2025-04-21 17:24:06 -07:00
3 changed files with 47 additions and 53 deletions

View File

@@ -438,9 +438,6 @@ class PMA_Index
$r .= '<table>';
$r .= '<thead>';
$r .= '<tr>';
if (! $print_mode) {
$r .= '<th colspan="2">' . __('Action') . '</th>';
}
$r .= '<th>' . __('Keyname') . '</th>';
$r .= '<th>' . __('Type') . '</th>';
$r .= '<th>' . __('Unique') . '</th>';
@@ -450,6 +447,9 @@ class PMA_Index
$r .= '<th>' . __('Collation') . '</th>';
$r .= '<th>' . __('Null') . '</th>';
$r .= '<th>' . __('Comment') . '</th>';
if (! $print_mode) {
$r .= '<th colspan="2">' . __('Action') . '</th>';
}
$r .= '</tr>';
$r .= '</thead>';
$r .= '<tbody>';
@@ -460,37 +460,6 @@ class PMA_Index
$r .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
if (! $print_mode) {
$this_params = $GLOBALS['url_params'];
$this_params['index'] = $index->getName();
$r .= '<td ' . $row_span . '>'
. ' <a href="tbl_indexes.php' . PMA_generate_common_url($this_params)
. '">' . PMA_getIcon('b_edit.png', __('Edit')) . '</a>'
. '</td>' . "\n";
$this_params = $GLOBALS['url_params'];
if ($index->getName() == 'PRIMARY') {
$this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY';
$this_params['message_to_show'] = __('The primary key has been dropped');
$js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY');
} else {
$this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP INDEX ' . PMA_backquote($index->getName());
$this_params['message_to_show'] = sprintf(__('Index %s has been dropped'), $index->getName());
$js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName());
}
$r .= '<td ' . $row_span . '>';
$r .= '<input type="hidden" class="drop_primary_key_index_msg" value="' . $js_msg . '" />';
$r .= ' <a ';
if ($GLOBALS['cfg']['AjaxEnable']) {
$r .= 'class="drop_primary_key_index_anchor" ';
}
$r .= ' href="sql.php' . PMA_generate_common_url($this_params)
. '" >'
. PMA_getIcon('b_drop.png', __('Drop')) . '</a>'
. '</td>' . "\n";
}
$r .= '<th ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</th>';
$r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getType()) . '</td>';
$r .= '<td ' . $row_span . '>' . $index->isUnique(true) . '</td>';
@@ -513,6 +482,38 @@ class PMA_Index
$r .= '<td ' . $row_span . '>'
. htmlspecialchars($index->getComments()) . '</td>';
}
if (! $print_mode) {
$this_params = $GLOBALS['url_params'];
$this_params['index'] = $index->getName();
$r .= '<td ' . $row_span . '>'
. ' <a href="tbl_indexes.php' . PMA_generate_common_url($this_params)
. '">' . PMA_getOnlyIcon('b_edit.png', __('Edit')) . '</a>'
. '</td>' . "\n";
$this_params = $GLOBALS['url_params'];
if ($index->getName() == 'PRIMARY') {
$this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY';
$this_params['message_to_show'] = __('The primary key has been dropped');
$js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY');
} else {
$this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP INDEX ' . PMA_backquote($index->getName());
$this_params['message_to_show'] = sprintf(__('Index %s has been dropped'), $index->getName());
$js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName());
}
$r .= '<td ' . $row_span . '>';
$r .= '<input type="hidden" class="drop_primary_key_index_msg" value="' . $js_msg . '" />';
$r .= ' <a ';
if ($GLOBALS['cfg']['AjaxEnable']) {
$r .= 'class="drop_primary_key_index_anchor" ';
}
$r .= ' href="sql.php' . PMA_generate_common_url($this_params)
. '" >'
. PMA_getOnlyIcon('b_drop.png', __('Drop')) . '</a>'
. '</td>' . "\n";
}
$r .= '</tr>';
} // end foreach $index['Sequences']

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">
@@ -602,20 +604,6 @@ if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
*/
echo PMA_Index::getView($table, $db);
?>
<br />
<form action="./tbl_indexes.php" method="post"
onsubmit="return checkFormElementInRange(this, 'added_fields',
'<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
1)">
<fieldset>
<?php
echo PMA_generate_common_hidden_inputs($db, $table);
echo sprintf(__('Create an index on &nbsp;%s&nbsp;columns'),
'<input type="text" size="2" name="added_fields" value="1" />');
?>
<input type="submit" name="create_index" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>
<br />
<?php
}

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;
}