Browse foreign values did not work with inline edit

Use known message "Browse foreign values" instead of "Search foreign
data"
Use jQuery to attach handler instead of "onclick" for
browse_foreigners.php when called from sql.php
This commit is contained in:
Marc Delisle
2010-12-24 07:50:42 -05:00
parent ef8687b5de
commit c72cc2c8f5
3 changed files with 52 additions and 7 deletions

View File

@@ -98,6 +98,16 @@ require_once './libraries/header_scripts.inc.php';
//<![CDATA[ //<![CDATA[
self.focus(); self.focus();
function formupdate(fieldmd5, key) { function formupdate(fieldmd5, key) {
var $inline = window.opener.jQuery('.browse_foreign_clicked');
if ($inline.length != 0) {
$inline.removeClass('browse_foreign_clicked')
// puts new value in the previous element which is
// a span with class curr_value
.prev().text(key);
self.close();
return false;
}
if (opener && opener.document && opener.document.insertForm) { if (opener && opener.document && opener.document.insertForm) {
var field = 'fields'; var field = 'fields';

View File

@@ -503,6 +503,8 @@ $(document).ready(function() {
*/ */
var $this_td = $(this); var $this_td = $(this);
var $test_element = ''; // to test the presence of a element
// Initialize variables // Initialize variables
if(disp_mode == 'vertical') { if(disp_mode == 'vertical') {
/** /**
@@ -580,7 +582,17 @@ $(document).ready(function() {
} }
} }
else { else {
this_field_params[field_name] = $this_field.find('select').val(); // results from a drop-down
$test_element = $this_field.find('select');
if ($test_element.length != 0) {
this_field_params[field_name] = $test_element.val();
}
// results from Browse foreign value
$test_element = $this_field.find('span.curr_value');
if ($test_element.length != 0) {
this_field_params[field_name] = $test_element.text();
}
if($this_field.is('.relation')) { if($this_field.is('.relation')) {
$.extend(relation_fields, this_field_params); $.extend(relation_fields, this_field_params);
@@ -667,19 +679,33 @@ $(document).ready(function() {
} }
} }
else { else {
var new_html = $(this).find('select').val(); var new_html = '';
var new_value = '';
$test_element = $(this).find('select');
if ($test_element.length != 0) {
new_value = $test_element.val();
}
$test_element = $(this).find('span.curr_value');
if ($test_element.length != 0) {
new_value = $test_element.text();
}
if($(this).is('.relation')) { if($(this).is('.relation')) {
var field_name = getFieldName($(this), disp_mode); var field_name = getFieldName($(this), disp_mode);
var this_field = $(this); var this_field = $(this);
$.each(data.relations, function(key, value) { $.each(data.relations, function(key, value) {
if(key == field_name) { if(key == field_name) {
var new_value = $(this_field).find('select').val();
new_html = $(value).append(new_value); new_html = $(value).append(new_value);
return false; return false;
} }
}) })
} }
if($(this).is('.enum')) {
new_html = new_value;
}
} }
$(this).html(new_html); $(this).html(new_html);
}) })
@@ -706,6 +732,15 @@ function PMA_changeClassForColumn($this_th, newclass) {
} }
$(document).ready(function() { $(document).ready(function() {
$('.browse_foreign').live('click', function(e) {
e.preventDefault();
window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes,resizable=yes');
$anchor = $(this);
$anchor.addClass('browse_foreign_clicked');
return false;
});
/** /**
* vertical column highlighting in horizontal mode when hovering over the column header * vertical column highlighting in horizontal mode when hovering over the column header
*/ */

View File

@@ -57,7 +57,7 @@ if (isset($fields['dbase'])) {
* This doesn't seem to be the right place to do this, but I can't think of any * This doesn't seem to be the right place to do this, but I can't think of any
* better place either. * better place either.
*/ */
if(isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values'] == true) { if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values'] == true) {
require_once 'libraries/relation.lib.php'; require_once 'libraries/relation.lib.php';
$column = $_REQUEST['column']; $column = $_REQUEST['column'];
@@ -75,9 +75,9 @@ if(isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values
'field' => $column 'field' => $column
); );
$dropdown = '<a href="browse_foreigners.php' . PMA_generate_common_url($_url_params) . '"' $dropdown = '<span class="curr_value">' . htmlspecialchars($_REQUEST['curr_value']) . '</span> <a href="browse_foreigners.php' . PMA_generate_common_url($_url_params) . '"'
. ' target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes,resizable=yes\'); return false"' . ' target="_blank" class="browse_foreign" '
.'>Search Foreign Data</a>'; .'>' . __('Browse foreign values') . '</a>';
} }
else { else {
$dropdown = '<select>' . $dropdown . '</select>'; $dropdown = '<select>' . $dropdown . '</select>';