The branch, master has been updated
via abfb718c89c7e68ecb5e5c25c55d426c449d9883 (commit)
from 3400dddadd34963b0322646022cafb5855260d23 (commit)
- Log -----------------------------------------------------------------
commit abfb718c89c7e68ecb5e5c25c55d426c449d9883
Author: Madhura Jayaratne <[email protected]>
Date: Wed Feb 23 23:38:34 2011 +0530
Inline edit extended to fields of type set.
-----------------------------------------------------------------------
Summary of changes:
js/sql.js | 60 +++++++++++++++++++++++++++++++++-------
libraries/display_tbl.lib.php | 7 ++++-
sql.php | 28 +++++++++++++++++++
3 files changed, 83 insertions(+), 12 deletions(-)
diff --git a/js/sql.js b/js/sql.js
index 34e1e74..1cbbca2 100644
--- a/js/sql.js
+++ b/js/sql.js
@@ -458,9 +458,9 @@ $(document).ready(function() {
*/
var relation_curr_value = $this_field.find('a').text();
/**
- * @var enum_curr_value String current value of the field (for
fields that are of type enum).
+ * @var curr_value String current value of the field (for fields
that are of type enum or set).
*/
- var enum_curr_value = $this_field.text();
+ var curr_value = $this_field.text();
if($this_field.is(':not(.not_null)')){
// add a checkbox to mark null for all the field that are
nullable.
@@ -490,8 +490,13 @@ $(document).ready(function() {
// if 'chechbox_null_<field_name>_<row_index>' is clicked
empty the corresponding select/editor.
$('.checkbox_null_' + field_name + '_' +
this_row_index).bind('click', function(e) {
- if ($this_field.is('.enum, .set')) {
+ if ($this_field.is('.enum')) {
$this_field.find('select').attr('value', '');
+ } else if ($this_field.is('.set')) {
+
$this_field.find('select').find('option').each(function() {
+ var $option = $(this);
+ $option.attr('selected', false);
+ })
} else if ($this_field.is('.relation')) {
// if the dropdown is there to select the foreign value
if ($this_field.find('select').length > 0) {
@@ -511,7 +516,7 @@ $(document).ready(function() {
// In each input sibling, wrap the current value in a textarea
// and store the current value in a hidden span
- if($this_field.is(':not(.truncated, .transformed, .relation,
.enum, .null)')) {
+ if($this_field.is(':not(.truncated, .transformed, .relation,
.enum, .set, .null)')) {
// handle non-truncated, non-transformed, non-relation values
// We don't need to get any more data, just wrap the value
$this_field.append('<textarea>'+data_value+'</textarea>');
@@ -582,7 +587,7 @@ $(document).ready(function() {
'table' : window.parent.table,
'column' : field_name,
'token' : window.parent.token,
- 'curr_value' : enum_curr_value
+ 'curr_value' : curr_value
}
$.post('sql.php', post_params, function(data) {
@@ -591,6 +596,29 @@ $(document).ready(function() {
$(".original_data").hide();
}) // end $.post()
}
+ else if($this_field.is('.set')) {
+ /** @lends jQuery */
+ //handle set fields
+
+ /**
+ * @var post_params Object containing parameters for the POST
request
+ */
+ var post_params = {
+ 'ajax_request' : true,
+ 'get_set_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.append(data.select);
+ $this_field.append('<span
class="original_data">'+data_value+'</span>');
+ $(".original_data").hide();
+ }) // end $.post()
+ }
else if($this_field.is('.null')) {
//handle null fields
$this_field.append('<textarea></textarea>');
@@ -701,13 +729,17 @@ $(document).ready(function() {
if (is_null) {
sql_query += ' ' + field_name + "=NULL , ";
} else {
- if($this_field.is(":not(.relation, .enum)")) {
+ if($this_field.is(":not(.relation, .enum, .set)")) {
this_field_params[field_name] =
$this_field.find('textarea').val();
if($this_field.is('.transformed')) {
$.extend(transform_fields, this_field_params);
}
- }
- else {
+ } else if ($this_field.is('.set')) {
+ $test_element = $this_field.find('select');
+ this_field_params[field_name] =
$test_element.map(function(){
+ return $(this).val();
+ }).get().join(",");
+ } else {
// results from a drop-down
$test_element = $this_field.find('select');
if ($test_element.length != 0) {
@@ -777,7 +809,7 @@ $(document).ready(function() {
$this_sibling.addClass('null');
} else {
$this_sibling.removeClass('null');
- if($this_sibling.is(':not(.relation, .enum)')) {
+ if($this_sibling.is(':not(.relation, .enum, .set)')) {
/**
* @var new_html String containing value of the
data field after edit
*/
@@ -821,9 +853,15 @@ $(document).ready(function() {
return false;
}
})
- }
- if($this_sibling.is('.enum')) {
+ } else if ($this_sibling.is('.enum')) {
new_html = new_value;
+ } else if ($this_sibling.is('.set')) {
+ if (new_value != null) {
+ $.each(new_value, function(key, value) {
+ new_html = new_html + value + ',';
+ })
+ new_html = new_html.substring(0,
new_html.length-1);
+ }
}
}
$this_sibling.html(new_html);
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index a57abb2..d47e94d 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -2419,6 +2419,11 @@ function PMA_prepare_row_data($class, $condition_field,
$analyzed_sql, $meta, $m
$enum_class = ' enum';
}
+ $set_class = '';
+ if(strpos($meta->flags, 'set') !== false) {
+ $set_class = ' set';
+ }
+
$mime_type_class = '';
if(isset($meta->mimetype)) {
$mime_type_class = ' ' . preg_replace('/\//', '_', $meta->mimetype);
@@ -2428,7 +2433,7 @@ function PMA_prepare_row_data($class, $condition_field,
$analyzed_sql, $meta, $m
$result = ' class="' . $class . ($condition_field ? ' condition' : '') .
$nowrap
. ' ' . ($is_field_truncated ? ' truncated' : '')
. ($transform_function != $default_function ? ' transformed' : '')
- . $enum_class . $mime_type_class . '">';
+ . $enum_class . $set_class . $mime_type_class . '">';
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) {
diff --git a/sql.php b/sql.php
index 42dff07..41f1ec6 100644
--- a/sql.php
+++ b/sql.php
@@ -115,6 +115,34 @@ if(isset($_REQUEST['get_enum_values']) &&
$_REQUEST['get_enum_values'] == true)
PMA_ajaxResponse(NULL, true, $extra_data);
}
+/**
+ * Find possible values for set fields during inline edit.
+ */
+if(isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_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);
+
+ $selected_values = explode(',', $_REQUEST['curr_value']);
+
+ $search = array('set', '(', ')', "'");
+ $values = explode(',', str_replace($search, '',
$field_info_result[0]['Type']));
+
+ $select = '';
+ foreach($values as $value) {
+ $select .= '<option value="' . htmlspecialchars($value) . '"';
+ if(in_array($value, $selected_values, true)) {
+ $select .= ' selected="selected"';
+ }
+ $select .= '>' . $value . '</option>';
+ }
+
+ $select_size = (sizeof($values) > 10) ? 10 : sizeof($values);
+ $select = '<select multiple="multiple" size="' . $select_size . '">' .
$select . '</select>';
+
+ $extra_data['select'] = $select;
+ PMA_ajaxResponse(NULL, true, $extra_data);
+}
// Default to browse if no query set and we have table
// (needed for browsing from DefaultTabTable)
if (empty($sql_query) && strlen($table) && strlen($db)) {
hooks/post-receive
--
phpMyAdmin
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Phpmyadmin-git mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/phpmyadmin-git