Relational values are now retrieved from the server for inline editing. However, the displaying of relational values after a successful inline edit has to be handled better. The link to the sql query is lost, and we dont know how the relational display column setting will be handled
This commit is contained in:
55
js/sql.js
55
js/sql.js
@@ -115,19 +115,7 @@ $(document).ready(function() {
|
|||||||
$(input_siblings).each(function() {
|
$(input_siblings).each(function() {
|
||||||
var data_value = $(this).html();
|
var data_value = $(this).html();
|
||||||
|
|
||||||
// In each input sibling, wrap the current value in a textarea
|
// We need to retrieve the value from the server for truncated/relation fields
|
||||||
// and store the current value in a hidden span
|
|
||||||
if($(this).is(':not(.truncated, .transformed, .relation)')) {
|
|
||||||
// handle non-truncated, non-transformed, non-relation values
|
|
||||||
// We don't need to get any more data, just wrap the value
|
|
||||||
$(this).html('<textarea>'+data_value+'</textarea>')
|
|
||||||
.append('<span class="original_data">'+data_value+'</span>');
|
|
||||||
$(".original_data").hide();
|
|
||||||
}
|
|
||||||
else if($(this).is('.truncated, .transformed')) {
|
|
||||||
//handle truncated/transformed values values
|
|
||||||
|
|
||||||
// We need to retrieve the value from the server
|
|
||||||
// Find the field name
|
// Find the field name
|
||||||
if(disp_mode == 'vertical') {
|
if(disp_mode == 'vertical') {
|
||||||
var this_field = $(this);
|
var this_field = $(this);
|
||||||
@@ -146,6 +134,19 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
field_name = $.trim(field_name);
|
field_name = $.trim(field_name);
|
||||||
|
|
||||||
|
// In each input sibling, wrap the current value in a textarea
|
||||||
|
// and store the current value in a hidden span
|
||||||
|
if($(this).is(':not(.truncated, .transformed, .relation)')) {
|
||||||
|
// handle non-truncated, non-transformed, non-relation values
|
||||||
|
// We don't need to get any more data, just wrap the value
|
||||||
|
$(this).html('<textarea>'+data_value+'</textarea>')
|
||||||
|
.append('<span class="original_data">'+data_value+'</span>');
|
||||||
|
$(".original_data").hide();
|
||||||
|
}
|
||||||
|
else if($(this).is('.truncated, .transformed')) {
|
||||||
|
//handle truncated/transformed values values
|
||||||
|
|
||||||
var sql_query = 'SELECT ' + field_name + ' FROM ' + window.parent.table + ' WHERE ' + where_clause;
|
var sql_query = 'SELECT ' + field_name + ' FROM ' + window.parent.table + ' WHERE ' + where_clause;
|
||||||
|
|
||||||
// Make the Ajax call and get the data, wrap it and insert it
|
// Make the Ajax call and get the data, wrap it and insert it
|
||||||
@@ -168,6 +169,24 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
else if($(this).is('.relation')) {
|
else if($(this).is('.relation')) {
|
||||||
//handle relations
|
//handle relations
|
||||||
|
|
||||||
|
var curr_value = $(this).find('a').text();
|
||||||
|
|
||||||
|
var post_params = {
|
||||||
|
'ajax_request' : true,
|
||||||
|
'get_relational_values' : true,
|
||||||
|
'db' : window.parent.db,
|
||||||
|
'table' : window.parent.table,
|
||||||
|
'column' : field_name,
|
||||||
|
'token' : window.parent.token,
|
||||||
|
'curr_value' : curr_value
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post('sql.php', post_params, function(data) {
|
||||||
|
$(this_field).html(data.dropdown)
|
||||||
|
.append('<span class="original_data">'+data_value+'</span>');
|
||||||
|
$(".original_data").hide();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}) // End On click, replace the current field with an input/textarea
|
}) // End On click, replace the current field with an input/textarea
|
||||||
@@ -218,7 +237,12 @@ $(document).ready(function() {
|
|||||||
field_name = $.trim(field_name);
|
field_name = $.trim(field_name);
|
||||||
|
|
||||||
var this_field_params = {};
|
var this_field_params = {};
|
||||||
|
if($(this).is(":not(.relation)")) {
|
||||||
this_field_params[field_name] = $(this).find('textarea').val();
|
this_field_params[field_name] = $(this).find('textarea').val();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this_field_params[field_name] = $(this).find('select').val();
|
||||||
|
}
|
||||||
|
|
||||||
$.extend(params_to_submit, this_field_params);
|
$.extend(params_to_submit, this_field_params);
|
||||||
})
|
})
|
||||||
@@ -253,8 +277,11 @@ $(document).ready(function() {
|
|||||||
// Inline edit post has been successful.
|
// Inline edit post has been successful.
|
||||||
if($(this).is(':not(.relation)')) {
|
if($(this).is(':not(.relation)')) {
|
||||||
var new_html = $(this).find('textarea').val();
|
var new_html = $(this).find('textarea').val();
|
||||||
$(this).html(new_html);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
var new_html = $(this).find('select').val();
|
||||||
|
}
|
||||||
|
$(this).html(new_html);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
23
sql.php
23
sql.php
@@ -48,6 +48,29 @@ if (isset($fields['dbase'])) {
|
|||||||
$db = $fields['dbase'];
|
$db = $fields['dbase'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* During inline edit, if we have a relational field, show the dropdown for it
|
||||||
|
*
|
||||||
|
* This doesn't seem to be the right place to do this, but I can't think of any
|
||||||
|
* better place either.
|
||||||
|
*/
|
||||||
|
if(isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values'] == true) {
|
||||||
|
require_once 'libraries/relation.lib.php';
|
||||||
|
|
||||||
|
$column = $_REQUEST['column'];
|
||||||
|
$foreigners = PMA_getForeigners($db, $table, $column);
|
||||||
|
|
||||||
|
$foreignData = PMA_getForeignData($foreigners, $column, false, '', '');
|
||||||
|
|
||||||
|
$dropdown = PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $_REQUEST['curr_value'], $cfg['ForeignKeyMaxLimit']);
|
||||||
|
|
||||||
|
$dropdown = '<select>' . $dropdown . '</select>';
|
||||||
|
|
||||||
|
$extra_data['dropdown'] = $dropdown;
|
||||||
|
PMA_ajaxResponse(NULL, true, $extra_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Default to browse if no query set and we have table
|
// Default to browse if no query set and we have table
|
||||||
// (needed for browsing from DefaultTabTable)
|
// (needed for browsing from DefaultTabTable)
|
||||||
if (empty($sql_query) && strlen($table) && strlen($db)) {
|
if (empty($sql_query) && strlen($table) && strlen($db)) {
|
||||||
|
Reference in New Issue
Block a user