The branch, master has been updated via 5a75ca180ae0eb5c47a80428c7707cca6d5d1269 (commit) from f3f41cbe78693781a9874c59a8ae736d324797bd (commit)
- Log ----------------------------------------------------------------- commit 5a75ca180ae0eb5c47a80428c7707cca6d5d1269 Author: Marc Delisle marc@infomarc.info Date: Sat Apr 17 19:22:12 2010 -0400
rfe #2988633 Improve ON DELETE/ON UPDATE drop-downs
-----------------------------------------------------------------------
Summary of changes: ChangeLog | 1 + js/tbl_relation.js | 26 ++++++++++++++++++++++++++ tbl_relation.php | 12 ++++++++---- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 js/tbl_relation.js
diff --git a/ChangeLog b/ChangeLog index f3dd9fc..57c1c8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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, diff --git a/js/tbl_relation.js b/js/tbl_relation.js new file mode 100644 index 0000000..5cdb0d7 --- /dev/null +++ b/js/tbl_relation.js @@ -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)); + }); +}); diff --git a/tbl_relation.php b/tbl_relation.php index 997ef60..e1b3253 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -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;
hooks/post-receive