rfe #2988633 Improve ON DELETE/ON UPDATE drop-downs

This commit is contained in:
Marc Delisle
2010-04-17 19:22:12 -04:00
parent f3f41cbe78
commit 5a75ca180a
3 changed files with 35 additions and 4 deletions

View File

@@ -75,6 +75,7 @@ $Id$
- rfe #2972969 [interface] Fix flipping of headers in non-IE browsers.
+ rfe #2964518 [interface] Allow to choose servers from configuration for
synchronisation.
+ rfe #2988633 [relation] Improve ON DELETE/ON UPDATE drop-downs
3.3.3.0 (not yet released)
- patch #2982480 [navi] Do not group if there would be one table in group,

26
js/tbl_relation.js Normal file
View File

@@ -0,0 +1,26 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* for tbl_relation.php
*
*/
function show_hide_clauses(thisDropdown) {
// here, one span contains the label and the clause dropdown
// and we have one span for ON DELETE and one for ON UPDATE
//
if (thisDropdown.val() != '') {
thisDropdown.parent().next('span').show().next('span').show();
} else {
thisDropdown.parent().next('span').hide().next('span').hide();
}
}
$(document).ready(function() {
// initial display
$('.referenced_column_dropdown').each(function(index, one_dropdown) {
show_hide_clauses($(one_dropdown));
});
// change
$('.referenced_column_dropdown').change(function() {
show_hide_clauses($(this));
});
});

View File

@@ -18,6 +18,8 @@
* Gets some core libraries
*/
require_once './libraries/common.inc.php';
$GLOBALS['js_include'][] = 'tbl_relation.js';
require_once './libraries/tbl_common.php';
$url_query .= '&goto=tbl_sql.php';
@@ -61,7 +63,6 @@ function PMA_generate_dropdown($dropdown_question, $select_name, $choices, $sele
echo htmlspecialchars($dropdown_question) . '  ';
echo '<select name="' . htmlspecialchars($select_name) . '">' . "\n";
echo '<option value=""></option>' . "\n";
foreach ($choices as $one_value => $one_label) {
echo '<option value="' . htmlspecialchars($one_value) . '"';
@@ -471,7 +472,7 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
if (!empty($save_row[$i]['Key'])) {
?>
<span class="formelement">
<select name="destination_foreign[<?php echo $myfield_md5; ?>]">
<select name="destination_foreign[<?php echo $myfield_md5; ?>]" class="referenced_column_dropdown">
<?php
if (isset($existrel_foreign[$myfield])) {
// need to backquote to support a dot character inside
@@ -508,10 +509,13 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
</span>
<span class="formelement">
<?php
// For ON DELETE and ON UPDATE, the default action
// is RESTRICT as per MySQL doc; however, a SHOW CREATE TABLE
// won't display the clause if it's set as RESTRICT.
PMA_generate_dropdown('ON DELETE',
'on_delete[' . $myfield_md5 . ']',
$options_array,
isset($existrel_foreign[$myfield]['on_delete']) ? $existrel_foreign[$myfield]['on_delete']: '');
isset($existrel_foreign[$myfield]['on_delete']) ? $existrel_foreign[$myfield]['on_delete']: 'RESTRICT');
echo '</span>' . "\n"
.'<span class="formelement">' . "\n";
@@ -519,7 +523,7 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
PMA_generate_dropdown('ON UPDATE',
'on_update[' . $myfield_md5 . ']',
$options_array,
isset($existrel_foreign[$myfield]['on_update']) ? $existrel_foreign[$myfield]['on_update']: '');
isset($existrel_foreign[$myfield]['on_update']) ? $existrel_foreign[$myfield]['on_update']: 'RESTRICT');
echo '</span>' . "\n";
} else {
echo $strNoIndex;