diff options
author | Hugues Peccatte <hugues.peccatte@gmail.com> | 2014-12-15 22:54:00 +0300 |
---|---|---|
committer | Hugues Peccatte <hugues.peccatte@gmail.com> | 2014-12-15 22:54:00 +0300 |
commit | 8035d00773225e09681acf2164714599d2e1e763 (patch) | |
tree | a3beb828f30b98e61266385eb03570844830bd08 /js/tbl_relation.js | |
parent | 91ead40b85c142014e146e62343ee9d18d01da8e (diff) |
Implement #1579 Default to primary key when adding relation.
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
Diffstat (limited to 'js/tbl_relation.js')
-rw-r--r-- | js/tbl_relation.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/js/tbl_relation.js b/js/tbl_relation.js index 8858fabf41..fd35443d40 100644 --- a/js/tbl_relation.js +++ b/js/tbl_relation.js @@ -17,13 +17,13 @@ function show_hide_clauses($thisDropdown) /** * Sets dropdown options to values */ -function setDropdownValues($dropdown, values) { +function setDropdownValues($dropdown, values, selectedValue) { $dropdown.empty(); var optionsAsString = ''; // add an empty string to the beginning for empty selection values.unshift(''); $.each(values, function () { - optionsAsString += "<option value='" + this + "'>" + this + "</option>"; + optionsAsString += "<option value='" + this + "'" + (selectedValue == this ? " selected='selected'" : "") + ">" + this + "</option>"; }); $dropdown.append($(optionsAsString)); } @@ -94,7 +94,13 @@ function getDropdownValues($dropdown) { setDropdownValues($columnDd, []); } else { // if a table selector // set values for the column dropdown - setDropdownValues($columnDd, data.columns); + var primary = null; + if (typeof data.primary !== 'undefined' + && 1 === data.primary.length + ) { + primary = data.primary[0]; + } + setDropdownValues($columnDd, data.columns, primary); } } else { PMA_ajaxShowMessage(data.error, false); |