Fixing bug for when the table is a view or information_schema

This commit is contained in:
lorilee
2010-07-27 10:25:12 -07:00
parent 960f6ef3ff
commit 64b5900d96
2 changed files with 78 additions and 65 deletions

View File

@@ -1841,34 +1841,36 @@ $(document).ready(function() {
* in a dropdown menu when the user hovers over the word "More."
*/
// Remove the actions from the table cells (they are available by default for JavaScript-disabled browsers)
$("table[id='tablestructure'] td[class='browse']").remove();
$("table[id='tablestructure'] td[class='primary']").remove();
$("table[id='tablestructure'] td[class='unique']").remove();
$("table[id='tablestructure'] td[class='index']").remove();
$("table[id='tablestructure'] td[class='fulltext']").remove();
// if the table is not a view or information_schema (otherwise there is only one action to hide and there's no point)
if($("input[type='hidden'][name='table_type']").attr("value") == "table") {
$("table[id='tablestructure'] td[class='browse']").remove();
$("table[id='tablestructure'] td[class='primary']").remove();
$("table[id='tablestructure'] td[class='unique']").remove();
$("table[id='tablestructure'] td[class='index']").remove();
$("table[id='tablestructure'] td[class='fulltext']").remove();
// Display the "more" text
$("table[id='tablestructure'] td[class='more_opts']").show()
// Display the "more" text
$("table[id='tablestructure'] td[class='more_opts']").show()
// Move the dropdown to the left so the right edge is aligned with the parent cell's right edge
// All the more_opts table cells have the same left offset so choose any
var parent_cell = $("table[id='tablestructure'] td[class='more_opts']");
var cell_right_edge_offset = parent_cell.offset().left + parent_cell.innerWidth();
// All the structure_actions_dropdown divs have the same left offset so choose any
var left_offset = cell_right_edge_offset - $(".structure_actions_dropdown").innerWidth();
// var curr_top_offset = $(".structure_actions_dropdown").offset().top;
// Move the dropdown to the left so the right edge is aligned with the parent cell's right edge
// All the more_opts table cells have the same left offset so choose any
var parent_cell = $("table[id='tablestructure'] td[class='more_opts']");
var cell_right_edge_offset = parent_cell.offset().left + parent_cell.innerWidth();
// All the structure_actions_dropdown divs have the same left offset so choose any
var left_offset = cell_right_edge_offset - $(".structure_actions_dropdown").innerWidth();
$.each($(".structure_actions_dropdown"), function() {
$(this).offset({ left: left_offset });
});
$.each($(".structure_actions_dropdown"), function() {
$(this).offset({ left: left_offset });
});
// When "more" is hovered over, show the hidden actions
$("table[id='tablestructure'] td[class='more_opts']").hover(
function() {
$(this).children(".structure_actions_dropdown").show();
},
function() {
$(this).children(".structure_actions_dropdown").hide();
}
);
// When "more" is hovered over, show the hidden actions
$("table[id='tablestructure'] td[class='more_opts']").hover(
function() {
$(this).children(".structure_actions_dropdown").show();
},
function() {
$(this).children(".structure_actions_dropdown").hide();
}
);
}
});

View File

@@ -199,10 +199,17 @@ $i = 0;
</tr>
</thead>
<tbody>
<?php
unset($i);
echo '<input type="hidden" name="table_type" value=';
if($db_is_information_schema) {
echo '"information_schema" />';
} else if ($tbl_is_view) {
echo '"view" />';
} else {
echo '"table" />';
}
// table body
// prepare comments
@@ -469,52 +476,56 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
</div>
<div class="action_primary">
<?php
if($primary) { ?>
<a 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;zero_rows=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>"
onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
<?php echo $hidden_titles['Primary']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoPrimary'];
}
?>
if(isset($primary_enabled)) {
if($primary_enabled) { ?>
<a 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;zero_rows=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>"
onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
<?php echo $hidden_titles['Primary']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoPrimary'];
}
} ?>
</div>
<div class="action_unique">
<?php
if($unique_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Unique']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoUnique'];
}
?>
if(isset($unique_enabled)) {
if($uniqe_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Unique']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoUnique'];
}
} ?>
</div>
<div class="action_index">
<?php
if($index_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Index']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoIndex'];
}
?>
if(isset($index_enabled)) {
if($index_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Index']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoIndex'];
}
} ?>
</div>
<div class="action_fulltext">
<?php
if($fulltext_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['IdxFulltext']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoIdxFulltext'];
}
?>
if(isset($fulltext_enabled)) {
if($fulltext_enabled) { ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['IdxFulltext']; ?>
</a>
<?php
} else {
echo $hidden_titles['NoIdxFulltext'];
}
} ?>
</div>
</div>
</td>