Added handling of enum values to inline editing
This commit is contained in:
26
js/sql.js
26
js/sql.js
@@ -137,7 +137,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
// In each input sibling, wrap the current value in a textarea
|
// In each input sibling, wrap the current value in a textarea
|
||||||
// and store the current value in a hidden span
|
// and store the current value in a hidden span
|
||||||
if($(this).is(':not(.truncated, .transformed, .relation)')) {
|
if($(this).is(':not(.truncated, .transformed, .relation, .enum)')) {
|
||||||
// handle non-truncated, non-transformed, non-relation values
|
// handle non-truncated, non-transformed, non-relation values
|
||||||
// We don't need to get any more data, just wrap the value
|
// We don't need to get any more data, just wrap the value
|
||||||
$(this).html('<textarea>'+data_value+'</textarea>')
|
$(this).html('<textarea>'+data_value+'</textarea>')
|
||||||
@@ -182,6 +182,26 @@ $(document).ready(function() {
|
|||||||
'curr_value' : curr_value
|
'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();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if($(this).is('.enum')) {
|
||||||
|
//handle enum fields
|
||||||
|
var curr_value = $(this).text();
|
||||||
|
|
||||||
|
var post_params = {
|
||||||
|
'ajax_request' : true,
|
||||||
|
'get_enum_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) {
|
$.post('sql.php', post_params, function(data) {
|
||||||
$(this_field).html(data.dropdown)
|
$(this_field).html(data.dropdown)
|
||||||
.append('<span class="original_data">'+data_value+'</span>');
|
.append('<span class="original_data">'+data_value+'</span>');
|
||||||
@@ -237,7 +257,7 @@ $(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)")) {
|
if($(this).is(":not(.relation, .enum)")) {
|
||||||
this_field_params[field_name] = $(this).find('textarea').val();
|
this_field_params[field_name] = $(this).find('textarea').val();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -275,7 +295,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$(input_siblings).each(function() {
|
$(input_siblings).each(function() {
|
||||||
// Inline edit post has been successful.
|
// Inline edit post has been successful.
|
||||||
if($(this).is(':not(.relation)')) {
|
if($(this).is(':not(.relation, .enum)')) {
|
||||||
var new_html = $(this).find('textarea').val();
|
var new_html = $(this).find('textarea').val();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -2360,11 +2360,17 @@ function PMA_handle_non_printable_contents($category, $content, $transform_funct
|
|||||||
function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated ) {
|
function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated ) {
|
||||||
|
|
||||||
$data_inline_edit_class = 'data_inline_edit';
|
$data_inline_edit_class = 'data_inline_edit';
|
||||||
|
$enum_class = '';
|
||||||
|
if(strpos($meta->flags, 'enum') !== false) {
|
||||||
|
$enum_class = ' enum';
|
||||||
|
}
|
||||||
|
|
||||||
// continue the <td> tag started before calling this function:
|
// continue the <td> tag started before calling this function:
|
||||||
$result = $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . $nowrap
|
$result = $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . $nowrap
|
||||||
. ' ' . $data_inline_edit_class . ($is_field_truncated ? ' truncated' : '')
|
. ' ' . $data_inline_edit_class . ($is_field_truncated ? ' truncated' : '')
|
||||||
. ($transform_function != $default_function ? ' transformed' : '')
|
. ($transform_function != $default_function ? ' transformed' : '')
|
||||||
. (isset($map[$meta->name]) ? ' relation' : '') . '">';
|
. (isset($map[$meta->name]) ? ' relation' : '')
|
||||||
|
. $enum_class . '">';
|
||||||
|
|
||||||
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
|
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
|
||||||
foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
|
foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
|
||||||
|
26
sql.php
26
sql.php
@@ -70,6 +70,32 @@ if(isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values
|
|||||||
PMA_ajaxResponse(NULL, true, $extra_data);
|
PMA_ajaxResponse(NULL, true, $extra_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just like above, find possible values for enum fields during inline edit.
|
||||||
|
*/
|
||||||
|
if(isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true) {
|
||||||
|
$field_info_query = 'SHOW FIELDS FROM `' . $db . '`.`' . $table . '` LIKE \'' . $_REQUEST['column'] . '\' ;';
|
||||||
|
|
||||||
|
$field_info_result = PMA_DBI_fetch_result($field_info_query, null, null, null, PMA_DBI_QUERY_STORE);
|
||||||
|
|
||||||
|
$search = array('enum', '(', ')', "'");
|
||||||
|
|
||||||
|
$values = explode(',', str_replace($search, '', $field_info_result[0]['Type']));
|
||||||
|
|
||||||
|
$dropdown = '';
|
||||||
|
foreach($values as $value) {
|
||||||
|
$dropdown .= '<option value="' . htmlspecialchars($value) . '"';
|
||||||
|
if($value == $_REQUEST['curr_value']) {
|
||||||
|
$dropdown .= ' selected="selected"';
|
||||||
|
}
|
||||||
|
$dropdown .= '>' . $value . '</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$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)
|
||||||
|
Reference in New Issue
Block a user