Remove inline edit feature
This commit is contained in:
parent
7a20d6d4df
commit
ba7913a260
@ -1961,7 +1961,7 @@ $cfg['TrustedProxies'] =
|
||||
|
||||
<dt><span id="cfg_RowActionLinks">$cfg['RowActionLinks'] </span>string
|
||||
</dt>
|
||||
<dd>Defines the place where table row links (Edit, Inline edit, Copy,
|
||||
<dd>Defines the place where table row links (Edit, Copy,
|
||||
Delete) would be put when tables contents are displayed (you may
|
||||
have them displayed at the left side, right side, both sides or nowhere).
|
||||
"left" and "right" are parsed as "top"
|
||||
|
||||
@ -31,7 +31,6 @@ function loadResult(result_path , table_name , link , ajaxEnable){
|
||||
// we assign it manually from #table-link
|
||||
window.parent.table = $('#table-link').text().trim();
|
||||
|
||||
appendInlineAnchor();
|
||||
$('#table_results').makegrid();
|
||||
}).show();
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@
|
||||
* Show edit cell, if it can be shown or it is forced.
|
||||
*/
|
||||
showEditCell: function(cell, force) {
|
||||
if ($(cell).is('.inline_edit') &&
|
||||
if ($(cell).is('.grid_edit') &&
|
||||
!g.colRsz && !g.colMov)
|
||||
{
|
||||
if (!g.isCellEditActive || force) {
|
||||
@ -790,7 +790,7 @@
|
||||
'db' : g.db,
|
||||
'ajax_request' : true,
|
||||
'sql_query' : sql_query,
|
||||
'inline_edit' : true
|
||||
'grid_edit' : true
|
||||
}, function(data) {
|
||||
$editArea.removeClass('edit_area_loading');
|
||||
if(data.success == true) {
|
||||
@ -871,7 +871,7 @@
|
||||
/**
|
||||
* @var is_unique Boolean, whether the rows in this table is unique or not
|
||||
*/
|
||||
var is_unique = $('.inline_edit_anchor').is('.nonunique') ? 0 : 1;
|
||||
var is_unique = $('.edit_row_anchor').is('.nonunique') ? 0 : 1;
|
||||
/**
|
||||
* multi edit variables
|
||||
*/
|
||||
|
||||
@ -199,7 +199,6 @@ $js_messages['strImportCSV'] = __('Note: If the file contains multiple tables, t
|
||||
/* For sql.js */
|
||||
$js_messages['strHideQueryBox'] = __('Hide query box');
|
||||
$js_messages['strShowQueryBox'] = __('Show query box');
|
||||
$js_messages['strInlineEdit'] = __('Inline Edit');
|
||||
$js_messages['strEdit'] = __('Edit');
|
||||
$js_messages['strSave'] = __('Save');
|
||||
$js_messages['strHide'] = __('Hide');
|
||||
|
||||
707
js/sql.js
707
js/sql.js
@ -25,7 +25,7 @@ function PMA_urlencode(str) {
|
||||
|
||||
/**
|
||||
* Get the field name for the current field. Required to construct the query
|
||||
* for inline editing
|
||||
* for grid editing
|
||||
*
|
||||
* @param $this_field jQuery object that points to the current field's tr
|
||||
*/
|
||||
@ -48,68 +48,6 @@ function getFieldName($this_field) {
|
||||
return field_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function that iterates over each row in the table_results and appends a
|
||||
* new inline edit anchor to each table row.
|
||||
*
|
||||
*/
|
||||
function appendInlineAnchor() {
|
||||
// TODO: remove two lines below if vertical display mode has been completely removed
|
||||
var disp_mode = $("#top_direction_dropdown").val();
|
||||
|
||||
if (disp_mode != 'vertical') {
|
||||
$('.edit_row_anchor').each(function() {
|
||||
|
||||
var $this_td = $(this);
|
||||
$this_td.removeClass('edit_row_anchor');
|
||||
|
||||
var $cloned_anchor = $this_td.clone();
|
||||
|
||||
var $img_object = $cloned_anchor.find('img').attr('title', PMA_messages['strInlineEdit']);
|
||||
if ($img_object.length != 0) {
|
||||
$img_object.removeClass('ic_b_edit');
|
||||
$img_object.addClass('ic_b_inline_edit');
|
||||
|
||||
$cloned_anchor.find('a').attr('href', '#');
|
||||
var $edit_span = $cloned_anchor.find('span:contains("' + PMA_messages['strEdit'] + '")');
|
||||
var $span = $cloned_anchor.find('a').find('span');
|
||||
if ($edit_span.length > 0) {
|
||||
$span.text(' ' + PMA_messages['strInlineEdit']);
|
||||
$span.prepend($img_object);
|
||||
} else {
|
||||
$span.text('');
|
||||
$span.append($img_object);
|
||||
}
|
||||
} else {
|
||||
// Only text is displayed. See $cfg['PropertiesIconic']
|
||||
$cloned_anchor.find('a').attr('href', '#');
|
||||
$cloned_anchor.find('a span').text(PMA_messages['strInlineEdit']);
|
||||
|
||||
// the link was too big so <input type="image"> is there
|
||||
$img_object = $cloned_anchor.find('input:image').attr('title', PMA_messages['strInlineEdit']);
|
||||
if ($img_object.length > 0) {
|
||||
$img_object.removeClass('ic_b_edit');
|
||||
$img_object.addClass('ic_b_inline_edit');
|
||||
}
|
||||
$cloned_anchor
|
||||
.find('.clickprevimage')
|
||||
.text(' ' + PMA_messages['strInlineEdit']);
|
||||
}
|
||||
|
||||
$cloned_anchor
|
||||
.addClass('inline_edit_anchor');
|
||||
|
||||
$this_td.after($cloned_anchor);
|
||||
});
|
||||
|
||||
$('#resultsForm').find('thead, tbody').find('th').each(function() {
|
||||
var $this_th = $(this);
|
||||
if ($this_th.attr('colspan') == 4) {
|
||||
$this_th.attr('colspan', '5');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**#@+
|
||||
* @namespace jQuery
|
||||
@ -124,7 +62,7 @@ function appendInlineAnchor() {
|
||||
* <li>Paginate the results table</li>
|
||||
* <li>Sort the results table</li>
|
||||
* <li>Change table according to display options</li>
|
||||
* <li>Inline editing of data</li>
|
||||
* <li>Grid editing of data</li>
|
||||
* </ul>
|
||||
*
|
||||
* @name document.ready
|
||||
@ -147,15 +85,6 @@ $(document).ready(function() {
|
||||
.toggle($(this).attr('value').length > 0);
|
||||
}).trigger('keyup');
|
||||
|
||||
/**
|
||||
* Attach the {@link appendInlineAnchor} function to a custom event, which
|
||||
* will be triggered manually everytime the table of results is reloaded
|
||||
* @memberOf jQuery
|
||||
*/
|
||||
$("#sqlqueryresults").live('appendAnchor',function() {
|
||||
appendInlineAnchor();
|
||||
})
|
||||
|
||||
/**
|
||||
* Attach the {@link makegrid} function to a custom event, which will be
|
||||
* triggered manually everytime the table of results is reloaded
|
||||
@ -167,21 +96,13 @@ $(document).ready(function() {
|
||||
|
||||
/**
|
||||
* Attach the {@link refreshgrid} function to a custom event, which will be
|
||||
* triggered manually everytime the table of results is manipulated (e.g., by inline edit)
|
||||
* triggered manually everytime the table of results is manipulated
|
||||
* @memberOf jQuery
|
||||
*/
|
||||
$("#sqlqueryresults").live('refreshgrid', function() {
|
||||
$('#table_results').refreshgrid();
|
||||
})
|
||||
|
||||
/**
|
||||
* Trigger the appendAnchor event to prepare the first table for inline edit
|
||||
* (see $GLOBALS['cfg']['AjaxEnable'])
|
||||
* @memberOf jQuery
|
||||
* @name sqlqueryresults_trigger
|
||||
*/
|
||||
$("#sqlqueryresults.ajax").trigger('appendAnchor');
|
||||
|
||||
/**
|
||||
* Append the "Show/Hide query box" message to the query input form
|
||||
*
|
||||
@ -287,7 +208,6 @@ $(document).ready(function() {
|
||||
$sqlqueryresults
|
||||
.show()
|
||||
.html(data)
|
||||
.trigger('appendAnchor')
|
||||
.trigger('makegrid');
|
||||
$('#togglequerybox').show();
|
||||
if ($("#togglequerybox").siblings(":visible").length > 0) {
|
||||
@ -329,7 +249,6 @@ $(document).ready(function() {
|
||||
$.post($form.attr('action'), $form.serialize(), function(data) {
|
||||
$("#sqlqueryresults")
|
||||
.html(data)
|
||||
.trigger('appendAnchor')
|
||||
.trigger('makegrid');
|
||||
PMA_init_slider();
|
||||
|
||||
@ -354,7 +273,6 @@ $(document).ready(function() {
|
||||
$.post($form.attr('action'), $form.serialize() + '&ajax_request=true', function(data) {
|
||||
$("#sqlqueryresults")
|
||||
.html(data)
|
||||
.trigger('appendAnchor')
|
||||
.trigger('makegrid');
|
||||
PMA_init_slider();
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
@ -381,7 +299,6 @@ $(document).ready(function() {
|
||||
$.get($anchor.attr('href'), $anchor.serialize() + '&ajax_request=true', function(data) {
|
||||
$("#sqlqueryresults")
|
||||
.html(data)
|
||||
.trigger('appendAnchor')
|
||||
.trigger('makegrid');
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}) // end $.get()
|
||||
@ -401,535 +318,12 @@ $(document).ready(function() {
|
||||
$.post($form.attr('action'), $form.serialize() + '&ajax_request=true' , function(data) {
|
||||
$("#sqlqueryresults")
|
||||
.html(data)
|
||||
.trigger('appendAnchor')
|
||||
.trigger('makegrid');
|
||||
PMA_init_slider();
|
||||
}) // end $.post()
|
||||
})
|
||||
//end displayOptionsForm handler
|
||||
|
||||
/**
|
||||
* Ajax Event handlers for Inline Editing
|
||||
*/
|
||||
|
||||
/**
|
||||
* On click, replace the fields of current row with an input/textarea
|
||||
* @memberOf jQuery
|
||||
* @name inline_edit_start
|
||||
* @see PMA_ajaxShowMessage()
|
||||
* @see getFieldName()
|
||||
*/
|
||||
$(".inline_edit_anchor span a").live('click', function(event) {
|
||||
/** @lends jQuery */
|
||||
event.preventDefault();
|
||||
|
||||
var $edit_td = $(this).parents('td');
|
||||
$edit_td.removeClass('inline_edit_anchor').addClass('inline_edit_active').parent('tr').addClass('noclick');
|
||||
|
||||
// Adding submit and hide buttons to inline edit <td>.
|
||||
// For "hide" button the original data to be restored is
|
||||
// kept in the jQuery data element 'original_data' inside the <td>.
|
||||
// Looping through all columns or rows, to find the required data and then storing it in an array.
|
||||
|
||||
var $this_children = $edit_td.children('span.nowrap').children('a').children('span.nowrap');
|
||||
// Keep the original data preserved.
|
||||
$data_a = $edit_td.children('span.nowrap').children('a').clone();
|
||||
|
||||
// Change the inline edit to save.
|
||||
var $img_object = $this_children.find('img');
|
||||
|
||||
// If texts are displayed. See $cfg['PropertiesIconic']
|
||||
if ($this_children.parent('a').find('span:contains("' + PMA_messages['strInlineEdit'] + '")').length > 0) {
|
||||
$this_children.text(' ' + PMA_messages['strSave']);
|
||||
} else {
|
||||
$this_children.empty();
|
||||
}
|
||||
|
||||
// If icons are displayed. See $cfg['PropertiesIconic']
|
||||
if ($img_object.length > 0) {
|
||||
$img_object.attr('title', PMA_messages['strSave']);
|
||||
$img_object.removeClass('ic_b_inline_edit');
|
||||
$img_object.addClass('ic_b_save');
|
||||
$this_children.prepend($img_object);
|
||||
}
|
||||
|
||||
// Clone the save link and change it to create the hide link.
|
||||
var $hide_a = $edit_td.children('span.nowrap').children('a').clone().attr('id', 'hide');
|
||||
var $hide_span = $hide_a.find('span');
|
||||
var $img_object = $hide_a.find('span img');
|
||||
|
||||
// If texts are displayed. See $cfg['PropertiesIconic']
|
||||
if ($hide_a.find('span:contains("' + PMA_messages['strSave'] + '")').length > 0) {
|
||||
$hide_span.text(' ' + PMA_messages['strHide']);
|
||||
} else {
|
||||
$hide_span.empty();
|
||||
}
|
||||
|
||||
// If icons are displayed. See $cfg['PropertiesIconic']
|
||||
if ($img_object.length > 0) {
|
||||
$img_object.attr('title', PMA_messages['strHide']);
|
||||
$img_object.removeClass('ic_b_save');
|
||||
$img_object.addClass('ic_b_close');
|
||||
$hide_span.prepend($img_object);
|
||||
}
|
||||
|
||||
// Add hide icon and/or text.
|
||||
$edit_td.children('span.nowrap').append($('<br /><br />')).append($hide_a);
|
||||
|
||||
$('#table_results tbody tr td span a#hide').click(function() {
|
||||
var $this_hide = $(this).parents('td');
|
||||
|
||||
var $this_span = $this_hide.find('span');
|
||||
$this_span.find('a, br').remove();
|
||||
$this_span.append($data_a.clone());
|
||||
|
||||
$this_hide.removeClass("inline_edit_active hover").addClass("inline_edit_anchor");
|
||||
$this_hide.parent().removeClass("hover noclick");
|
||||
$this_hide.siblings().removeClass("hover");
|
||||
|
||||
var $input_siblings = $this_hide.parent('tr').find('.inline_edit');
|
||||
var txt = '';
|
||||
$input_siblings.each(function() {
|
||||
var $this_hide_siblings = $(this);
|
||||
txt = $this_hide_siblings.data('original_data');
|
||||
if($this_hide_siblings.children('span').children().length != 0) {
|
||||
$this_hide_siblings.children('span').empty();
|
||||
$this_hide_siblings.children('span').append(txt);
|
||||
}
|
||||
});
|
||||
$(this).prev().prev().remove();
|
||||
$(this).prev().remove();
|
||||
$(this).remove();
|
||||
|
||||
// refresh the grid
|
||||
$("#sqlqueryresults").trigger('refreshgrid');
|
||||
});
|
||||
|
||||
// Initialize some variables
|
||||
var this_row_index = $edit_td.parent().index();
|
||||
var $input_siblings = $edit_td.parent('tr').find('.inline_edit');
|
||||
var where_clause = $edit_td.parent('tr').find('.where_clause').val();
|
||||
|
||||
$input_siblings.each(function() {
|
||||
/** @lends jQuery */
|
||||
/**
|
||||
* @var data_value Current value of this field
|
||||
*/
|
||||
var data_value = $(this).children('span').html();
|
||||
|
||||
// We need to retrieve the value from the server for truncated/relation fields
|
||||
// Find the field name
|
||||
|
||||
/**
|
||||
* @var this_field Object referring to this field (<td>)
|
||||
*/
|
||||
var $this_field = $(this);
|
||||
/**
|
||||
* @var this_field_span Object referring to this field's child (<span>)
|
||||
*/
|
||||
var $this_field_span = $(this).children('span');
|
||||
/**
|
||||
* @var field_name String containing the name of this field.
|
||||
* @see getFieldName()
|
||||
*/
|
||||
var field_name = getFieldName($this_field);
|
||||
/**
|
||||
* @var relation_curr_value String current value of the field (for fields that are foreign keyed).
|
||||
*/
|
||||
var relation_curr_value = $this_field.find('a').text();
|
||||
/**
|
||||
* @var relation_key_or_display_column String relational key if in 'Relational display column' mode,
|
||||
* relational display column if in 'Relational key' mode (for fields that are foreign keyed).
|
||||
*/
|
||||
var relation_key_or_display_column = $this_field.find('a').attr('title');
|
||||
/**
|
||||
* @var curr_value String current value of the field (for fields that are of type enum or set).
|
||||
*/
|
||||
var curr_value = $this_field_span.text();
|
||||
|
||||
if($this_field.is(':not(.not_null)')){
|
||||
// add a checkbox to mark null for all the field that are nullable.
|
||||
$this_field_span.html('<div class="null_div">Null :<input type="checkbox" class="checkbox_null_'+ field_name + '_' + this_row_index +'"></div>');
|
||||
// check the 'checkbox_null_<field_name>_<row_index>' if the corresponding value is null
|
||||
if($this_field.is('.null')) {
|
||||
$('.checkbox_null_' + field_name + '_' + this_row_index).attr('checked', true);
|
||||
}
|
||||
|
||||
// if the select/editor is changed un-check the 'checkbox_null_<field_name>_<row_index>'.
|
||||
if ($this_field.is('.enum, .set')) {
|
||||
$this_field.find('select').live('change', function(e) {
|
||||
$('.checkbox_null_' + field_name + '_' + this_row_index).attr('checked', false);
|
||||
})
|
||||
} else if ($this_field.is('.relation')) {
|
||||
$this_field.find('select').live('change', function(e) {
|
||||
$('.checkbox_null_' + field_name + '_' + this_row_index).attr('checked', false);
|
||||
})
|
||||
$this_field.find('.browse_foreign').live('click', function(e) {
|
||||
$('.checkbox_null_' + field_name + '_' + this_row_index).attr('checked', false);
|
||||
})
|
||||
} else {
|
||||
$this_field.find('textarea').live('keypress', function(e) {
|
||||
// FF errorneously triggers for modifier keys such as tab (bug #3357837)
|
||||
if (e.which != 0) {
|
||||
$('.checkbox_null_' + field_name + '_' + this_row_index).attr('checked', false);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// if 'checkbox_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')) {
|
||||
$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) {
|
||||
$this_field.find('select').attr('value', '');
|
||||
// if foriegn value is selected by browsing foreing values
|
||||
} else {
|
||||
$this_field.find('span.curr_value').empty();
|
||||
}
|
||||
} else {
|
||||
$this_field.find('textarea').val('');
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
$this_field_span.html('<div class="null_div"></div>');
|
||||
}
|
||||
|
||||
// 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, .set, .null)')) {
|
||||
// handle non-truncated, non-transformed, non-relation values
|
||||
|
||||
value = data_value.replace("<br>", "\n");
|
||||
// We don't need to get any more data, just wrap the value
|
||||
$this_field_span.append('<textarea>' + value + '</textarea>');
|
||||
$this_field.data('original_data', data_value);
|
||||
}
|
||||
else if($this_field.is('.truncated, .transformed')) {
|
||||
/** @lends jQuery */
|
||||
//handle truncated/transformed values values
|
||||
|
||||
/**
|
||||
* @var sql_query String containing the SQL query used to retrieve value of truncated/transformed data
|
||||
*/
|
||||
var sql_query = 'SELECT `' + field_name + '` FROM `' + window.parent.table + '` WHERE ' + PMA_urldecode(where_clause);
|
||||
|
||||
// Make the Ajax call and get the data, wrap it and insert it
|
||||
$.post('sql.php', {
|
||||
'token' : window.parent.token,
|
||||
'db' : window.parent.db,
|
||||
'ajax_request' : true,
|
||||
'sql_query' : sql_query,
|
||||
'inline_edit' : true
|
||||
}, function(data) {
|
||||
if(data.success == true) {
|
||||
$this_field_span.append('<textarea>'+data.value+'</textarea>');
|
||||
$this_field.data('original_data', data_value);
|
||||
$("#sqlqueryresults").trigger('refreshgrid');
|
||||
}
|
||||
else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
}
|
||||
}) // end $.post()
|
||||
}
|
||||
else if($this_field.is('.relation')) {
|
||||
/** @lends jQuery */
|
||||
//handle relations
|
||||
|
||||
/**
|
||||
* @var post_params Object containing parameters for the POST request
|
||||
*/
|
||||
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' : relation_curr_value,
|
||||
'relation_key_or_display_column' : relation_key_or_display_column
|
||||
}
|
||||
|
||||
$.post('sql.php', post_params, function(data) {
|
||||
$this_field_span.append(data.dropdown);
|
||||
$this_field.data('original_data', data_value);
|
||||
$("#sqlqueryresults").trigger('refreshgrid');
|
||||
}) // end $.post()
|
||||
}
|
||||
else if($this_field.is('.enum')) {
|
||||
/** @lends jQuery */
|
||||
//handle enum fields
|
||||
|
||||
/**
|
||||
* @var post_params Object containing parameters for the POST request
|
||||
*/
|
||||
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) {
|
||||
$this_field_span.append(data.dropdown);
|
||||
$this_field.data('original_data', data_value);
|
||||
$("#sqlqueryresults").trigger('refreshgrid');
|
||||
}) // 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_span.append(data.select);
|
||||
$this_field.data('original_data', data_value);
|
||||
$("#sqlqueryresults").trigger('refreshgrid');
|
||||
}) // end $.post()
|
||||
}
|
||||
else if($this_field.is('.null')) {
|
||||
//handle null fields
|
||||
$this_field_span.append('<textarea></textarea>');
|
||||
$this_field.data('original_data', 'NULL');
|
||||
}
|
||||
});
|
||||
|
||||
// refresh the grid
|
||||
$("#sqlqueryresults").trigger('refreshgrid');
|
||||
|
||||
}) // End On click, replace the current field with an input/textarea
|
||||
|
||||
/**
|
||||
* After editing, clicking again should post data
|
||||
*
|
||||
* @memberOf jQuery
|
||||
* @name inline_edit_save
|
||||
* @see PMA_ajaxShowMessage()
|
||||
* @see getFieldName()
|
||||
*/
|
||||
$(".inline_edit_active span a").live('click', function(event) {
|
||||
/** @lends jQuery */
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
/**
|
||||
* @var $this_td Object referring to the td containing the
|
||||
* "Inline Edit" link that was clicked to save the row that is
|
||||
* being edited
|
||||
*
|
||||
*/
|
||||
var $this_td = $(this).parents('td');
|
||||
var $test_element = ''; // to test the presence of a element
|
||||
|
||||
// Initialize variables
|
||||
var $input_siblings = $this_td.parent('tr').find('.inline_edit');
|
||||
var where_clause = $this_td.parent('tr').find('.where_clause').val();
|
||||
|
||||
/**
|
||||
* @var nonunique Boolean, whether this row is unique or not
|
||||
*/
|
||||
if($this_td.is('.nonunique')) {
|
||||
var nonunique = 0;
|
||||
}
|
||||
else {
|
||||
var nonunique = 1;
|
||||
}
|
||||
|
||||
// Collect values of all fields to submit, we don't know which changed
|
||||
/**
|
||||
* @var relation_fields Array containing the name/value pairs of relational fields
|
||||
*/
|
||||
var relation_fields = {};
|
||||
/**
|
||||
* @var relational_display string 'K' if relational key, 'D' if relational display column
|
||||
*/
|
||||
var relational_display = $("#relational_display_K").attr('checked') ? 'K' : 'D';
|
||||
/**
|
||||
* @var transform_fields Array containing the name/value pairs for transformed fields
|
||||
*/
|
||||
var transform_fields = {};
|
||||
/**
|
||||
* @var transformation_fields Boolean, if there are any transformed fields in this row
|
||||
*/
|
||||
var transformation_fields = false;
|
||||
|
||||
/**
|
||||
* @var sql_query String containing the SQL query to update this row
|
||||
*/
|
||||
var sql_query = 'UPDATE `' + window.parent.table + '` SET ';
|
||||
|
||||
var need_to_post = false;
|
||||
|
||||
var new_clause = '';
|
||||
var prev_index = -1;
|
||||
|
||||
$input_siblings.each(function() {
|
||||
/** @lends jQuery */
|
||||
/**
|
||||
* @var this_field Object referring to this field (<td>)
|
||||
*/
|
||||
var $this_field = $(this);
|
||||
|
||||
/**
|
||||
* @var field_name String containing the name of this field.
|
||||
* @see getFieldName()
|
||||
*/
|
||||
var field_name = getFieldName($this_field);
|
||||
|
||||
/**
|
||||
* @var this_field_params Array temporary storage for the name/value of current field
|
||||
*/
|
||||
var this_field_params = {};
|
||||
|
||||
if($this_field.is('.transformed')) {
|
||||
transformation_fields = true;
|
||||
}
|
||||
/**
|
||||
* @var is_null String capturing whether 'checkbox_null_<field_name>_<row_index>' is checked.
|
||||
*/
|
||||
var is_null = $this_field.find('input:checkbox').is(':checked');
|
||||
var value;
|
||||
var addQuotes = true;
|
||||
|
||||
if (is_null) {
|
||||
sql_query += ' `' + field_name + "`=NULL , ";
|
||||
need_to_post = true;
|
||||
} else {
|
||||
if($this_field.is(":not(.relation, .enum, .set, .bit)")) {
|
||||
this_field_params[field_name] = $this_field.find('textarea').val();
|
||||
if($this_field.is('.transformed')) {
|
||||
$.extend(transform_fields, this_field_params);
|
||||
}
|
||||
} else if ($this_field.is('.bit')) {
|
||||
this_field_params[field_name] = '0b' + $this_field.find('textarea').val();
|
||||
addQuotes = false;
|
||||
} 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) {
|
||||
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')) {
|
||||
$.extend(relation_fields, this_field_params);
|
||||
}
|
||||
}
|
||||
if(where_clause.indexOf(field_name) > prev_index){
|
||||
new_clause += '`' + window.parent.table + '`.' + '`' + field_name + "` = '" + this_field_params[field_name].replace(/'/g,"''") + "'" + ' AND ';
|
||||
}
|
||||
if (this_field_params[field_name] != $this_field.data('original_data')) {
|
||||
if (addQuotes == true) {
|
||||
sql_query += ' `' + field_name + "`='" + this_field_params[field_name].replace(/'/g, "''") + "', ";
|
||||
} else {
|
||||
sql_query += ' `' + field_name + "`=" + this_field_params[field_name].replace(/'/g, "''") + ", ";
|
||||
}
|
||||
need_to_post = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
* update the where_clause, remove the last appended ' AND '
|
||||
* */
|
||||
|
||||
//Remove the last ',' appended in the above loop
|
||||
sql_query = sql_query.replace(/,\s$/, '');
|
||||
//Fix non-escaped backslashes
|
||||
sql_query = sql_query.replace(/\\/g, '\\\\');
|
||||
new_clause = new_clause.substring(0, new_clause.length-5);
|
||||
new_clause = PMA_urlencode(new_clause);
|
||||
sql_query += ' WHERE ' + PMA_urldecode(where_clause);
|
||||
// Avoid updating more than one row in case there is no primary key
|
||||
// (happened only for duplicate rows)
|
||||
sql_query += ' LIMIT 1';
|
||||
/**
|
||||
* @var rel_fields_list String, url encoded representation of {@link relations_fields}
|
||||
*/
|
||||
var rel_fields_list = $.param(relation_fields);
|
||||
|
||||
/**
|
||||
* @var transform_fields_list String, url encoded representation of {@link transform_fields}
|
||||
*/
|
||||
var transform_fields_list = $.param(transform_fields);
|
||||
|
||||
// if inline_edit is successful, we need to go back to default view
|
||||
var $del_hide = $(this).parent();
|
||||
var $chg_submit = $(this);
|
||||
|
||||
if (need_to_post) {
|
||||
// Make the Ajax post after setting all parameters
|
||||
/**
|
||||
* @var post_params Object containing parameters for the POST request
|
||||
*/
|
||||
var post_params = {'ajax_request' : true,
|
||||
'sql_query' : sql_query,
|
||||
'token' : window.parent.token,
|
||||
'db' : window.parent.db,
|
||||
'table' : window.parent.table,
|
||||
'clause_is_unique' : nonunique,
|
||||
'where_clause' : where_clause,
|
||||
'rel_fields_list' : rel_fields_list,
|
||||
'do_transformations' : transformation_fields,
|
||||
'transform_fields_list' : transform_fields_list,
|
||||
'relational_display' : relational_display,
|
||||
'goto' : 'sql.php',
|
||||
'submit_type' : 'save'
|
||||
};
|
||||
|
||||
$.post('tbl_replace.php', post_params, function(data) {
|
||||
if(data.success == true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
$this_td.parent('tr').find('.where_clause').attr('value', new_clause);
|
||||
// remove possible previous feedback message
|
||||
$('#result_query').remove();
|
||||
if (typeof data.sql_query != 'undefined') {
|
||||
// display feedback
|
||||
$('#sqlqueryresults').prepend(data.sql_query);
|
||||
}
|
||||
PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings, data);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
};
|
||||
}) // end $.post()
|
||||
} else {
|
||||
// no posting was done but still need to display the row
|
||||
// in its previous format
|
||||
PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings, '');
|
||||
}
|
||||
}) // End After editing, clicking again should post data
|
||||
|
||||
/**
|
||||
* Ajax Event for table row change
|
||||
* */
|
||||
@ -1085,101 +479,6 @@ $(document).ready(function() {
|
||||
}, 'top.frame_content') // end $(document).ready()
|
||||
|
||||
|
||||
/**
|
||||
* Visually put back the row in the state it was before entering Inline edit
|
||||
*
|
||||
* (when called in the situation where no posting was done, the data
|
||||
* parameter is empty)
|
||||
*/
|
||||
function PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings, data) {
|
||||
|
||||
// deleting the hide button. remove <br><br><a> tags
|
||||
$del_hide.find('a, br').remove();
|
||||
// append inline edit button.
|
||||
$del_hide.append($data_a.clone());
|
||||
|
||||
// changing inline_edit_active to inline_edit_anchor
|
||||
$this_td.removeClass('inline_edit_active').addClass('inline_edit_anchor');
|
||||
|
||||
// removing hover, marked and noclick classes
|
||||
$this_td.parent('tr').removeClass('noclick');
|
||||
$this_td.parent('tr').removeClass('hover').find('td').removeClass('hover');
|
||||
|
||||
$input_siblings.each(function() {
|
||||
// Inline edit post has been successful.
|
||||
$this_sibling = $(this);
|
||||
$this_sibling_span = $(this).children('span');
|
||||
|
||||
var is_null = $this_sibling.find('input:checkbox').is(':checked');
|
||||
if (is_null) {
|
||||
$this_sibling_span.html('NULL');
|
||||
$this_sibling.addClass('null');
|
||||
} else {
|
||||
$this_sibling.removeClass('null');
|
||||
if($this_sibling.is(':not(.relation, .enum, .set)')) {
|
||||
/**
|
||||
* @var new_html String containing value of the data field after edit
|
||||
*/
|
||||
var new_html = $this_sibling.find('textarea').val();
|
||||
|
||||
if($this_sibling.is('.transformed')) {
|
||||
var field_name = getFieldName($this_sibling);
|
||||
if (typeof data.transformations != 'undefined') {
|
||||
$.each(data.transformations, function(key, value) {
|
||||
if(key == field_name) {
|
||||
if($this_sibling.is('.text_plain, .application_octetstream')) {
|
||||
new_html = value;
|
||||
return false;
|
||||
} else {
|
||||
var new_value = $this_sibling.find('textarea').val();
|
||||
new_html = $(value).append(new_value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var new_html = '';
|
||||
var new_value = '';
|
||||
$test_element = $this_sibling.find('select');
|
||||
if ($test_element.length != 0) {
|
||||
new_value = $test_element.val();
|
||||
}
|
||||
$test_element = $this_sibling.find('span.curr_value');
|
||||
if ($test_element.length != 0) {
|
||||
new_value = $test_element.text();
|
||||
}
|
||||
|
||||
if($this_sibling.is('.relation')) {
|
||||
var field_name = getFieldName($this_sibling);
|
||||
if (typeof data.relations != 'undefined') {
|
||||
$.each(data.relations, function(key, value) {
|
||||
if(key == field_name) {
|
||||
new_html = $(value);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
}
|
||||
} 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_span.html(new_html);
|
||||
}
|
||||
})
|
||||
|
||||
// refresh the grid
|
||||
$("#sqlqueryresults").trigger('refreshgrid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting from some th, change the class of all td under it.
|
||||
* If isAddClass is specified, it will be used to determine whether to add or remove the class.
|
||||
|
||||
@ -66,7 +66,6 @@ $(document).ready(function() {
|
||||
if (typeof response == 'string') {
|
||||
// found results
|
||||
$("#sqlqueryresults").html(response);
|
||||
$("#sqlqueryresults").trigger('appendAnchor');
|
||||
$("#sqlqueryresults").trigger('makegrid');
|
||||
$('#tbl_search_form')
|
||||
// work around for bug #3168569 - Issue on toggling the "Hide search criteria" in chrome.
|
||||
|
||||
@ -1003,16 +1003,16 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @global boolean $GLOBALS['inline_edit']
|
||||
* @global boolean $GLOBALS['grid_edit']
|
||||
*
|
||||
* Set to true if this is a request made during an inline edit process. This
|
||||
* Set to true if this is a request made during an grid edit process. This
|
||||
* request is made to retrieve the non-truncated/transformed values.
|
||||
*/
|
||||
if (isset($_REQUEST['inline_edit']) && $_REQUEST['inline_edit'] == true) {
|
||||
$GLOBALS['inline_edit'] = true;
|
||||
if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) {
|
||||
$GLOBALS['grid_edit'] = true;
|
||||
}
|
||||
else {
|
||||
$GLOBALS['inline_edit'] = false;
|
||||
$GLOBALS['grid_edit'] = false;
|
||||
}
|
||||
|
||||
if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
|
||||
|
||||
@ -2258,7 +2258,7 @@ $cfg['CharTextareaRows'] = 2;
|
||||
$cfg['LimitChars'] = 50;
|
||||
|
||||
/**
|
||||
* Where to show the edit/inline_edit/delete links in browse mode
|
||||
* Where to show the edit/copy/delete links in browse mode
|
||||
* Possible values are 'left', 'right', 'both' and 'none';
|
||||
* which will be interpreted as 'top', 'bottom', 'both' and 'none'
|
||||
* respectively for vertical display mode
|
||||
|
||||
@ -316,7 +316,7 @@ $strConfigMcryptDisableWarning_desc = __('Disable the default warning that is di
|
||||
$strConfigMcryptDisableWarning_name = __('mcrypt warning');
|
||||
$strConfigMemoryLimit_desc = __('The number of bytes a script is allowed to allocate, eg. [kbd]32M[/kbd] ([kbd]0[/kbd] for no limit)');
|
||||
$strConfigMemoryLimit_name = __('Memory limit');
|
||||
$strConfigRowActionLinks_desc = __('These are Edit, Inline edit, Copy and Delete links');
|
||||
$strConfigRowActionLinks_desc = __('These are Edit, Copy and Delete links');
|
||||
$strConfigRowActionLinks_name = __('Where to show the table row links');
|
||||
$strConfigNaturalOrder_desc = __('Use natural order for sorting table and database names');
|
||||
$strConfigNaturalOrder_name = __('Natural order');
|
||||
|
||||
@ -1095,7 +1095,7 @@ function PMA_buildValueDisplay($class, $condition_field, $value) {
|
||||
* @return string the td
|
||||
*/
|
||||
function PMA_buildNullDisplay($class, $condition_field) {
|
||||
// the null class is needed for inline editing
|
||||
// the null class is needed for grid editing
|
||||
return '<td align="right"' . ' class="' . $class . ($condition_field ? ' condition' : '') . ' null"><i>NULL</i></td>';
|
||||
}
|
||||
|
||||
@ -1216,8 +1216,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
$vertical_display['delete'] = array();
|
||||
$vertical_display['data'] = array();
|
||||
$vertical_display['row_delete'] = array();
|
||||
// name of the class added to all inline editable elements
|
||||
$inline_edit_class = 'inline_edit';
|
||||
// name of the class added to all grid editable elements
|
||||
$grid_edit_class = 'grid_edit';
|
||||
|
||||
// prepare to get the column order, if available
|
||||
if (PMA_isSelect()) {
|
||||
@ -1315,7 +1315,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
$edit_str = PMA_getIcon('b_edit.png', __('Edit'), true);
|
||||
$copy_str = PMA_getIcon('b_insrow.png', __('Copy'), true);
|
||||
|
||||
// Class definitions required for inline editing jQuery scripts
|
||||
// Class definitions required for grid editing jQuery scripts
|
||||
$edit_anchor_class = "edit_row_anchor";
|
||||
if ( $clause_is_unique == 0) {
|
||||
$edit_anchor_class .= ' nonunique';
|
||||
@ -1403,8 +1403,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
$pointer = $i;
|
||||
$is_field_truncated = false;
|
||||
//If the previous column had blob data, we need to reset the class
|
||||
// to $inline_edit_class
|
||||
$class = 'data ' . $inline_edit_class . ' ' . $not_null_class . ' ' . $relation_class; //' ' . $alternating_color_class .
|
||||
// to $grid_edit_class
|
||||
$class = 'data ' . $grid_edit_class . ' ' . $not_null_class . ' ' . $relation_class; //' ' . $alternating_color_class .
|
||||
|
||||
// See if this column should get highlight because it's used in the
|
||||
// where-query.
|
||||
@ -1490,8 +1490,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
$field_flags = PMA_DBI_field_flags($dt_result, $i);
|
||||
|
||||
if (stristr($field_flags, 'BINARY')) {
|
||||
// remove 'inline_edit' from $class as we can't edit binary data.
|
||||
$class = str_replace('inline_edit', '', $class);
|
||||
// remove 'grid_edit' from $class as we can't edit binary data.
|
||||
$class = str_replace('grid_edit', '', $class);
|
||||
|
||||
if (! isset($row[$i]) || is_null($row[$i])) {
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field);
|
||||
@ -1533,8 +1533,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
// g e o m e t r y
|
||||
} elseif ($meta->type == 'geometry') {
|
||||
|
||||
// Remove 'inline_edit' from $class as we do not allow to inline-edit geometry data.
|
||||
$class = str_replace('inline_edit', '', $class);
|
||||
// Remove 'grid_edit' from $class as we do not allow to inline-edit geometry data.
|
||||
$class = str_replace('grid_edit', '', $class);
|
||||
|
||||
// Display as [GEOMETRY - (size)]
|
||||
if ('GEOM' == $_SESSION['tmp_user_values']['geometry_display']) {
|
||||
@ -2745,7 +2745,7 @@ function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $wher
|
||||
. PMA_linkOrButton($edit_url, $edit_str, array(), false);
|
||||
/*
|
||||
* Where clause for selecting this row uniquely is provided as
|
||||
* a hidden input. Used by jQuery scripts for handling inline editing
|
||||
* a hidden input. Used by jQuery scripts for handling grid editing
|
||||
*/
|
||||
if (! empty($where_clause)) {
|
||||
$ret .= '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />';
|
||||
@ -2775,7 +2775,7 @@ function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, $where_clause
|
||||
. PMA_linkOrButton($copy_url, $copy_str, array(), false);
|
||||
/*
|
||||
* Where clause for selecting this row uniquely is provided as
|
||||
* a hidden input. Used by jQuery scripts for handling inline editing
|
||||
* a hidden input. Used by jQuery scripts for handling grid editing
|
||||
*/
|
||||
if (! empty($where_clause)) {
|
||||
$ret .= '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />';
|
||||
|
||||
10
sql.php
10
sql.php
@ -58,7 +58,7 @@ if (isset($fields['dbase'])) {
|
||||
}
|
||||
|
||||
/**
|
||||
* During inline edit, if we have a relational field, show the dropdown for it
|
||||
* During grid edit, if we have a relational field, show the dropdown for it
|
||||
*
|
||||
* Logic taken from libraries/display_tbl_lib.php
|
||||
*
|
||||
@ -104,7 +104,7 @@ if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_value
|
||||
}
|
||||
|
||||
/**
|
||||
* Just like above, find possible values for enum fields during inline edit.
|
||||
* Just like above, find possible values for enum fields during grid edit.
|
||||
*
|
||||
* Logic taken from libraries/display_tbl_lib.php
|
||||
*/
|
||||
@ -133,7 +133,7 @@ if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Find possible values for set fields during inline edit.
|
||||
* Find possible values for set fields during grid edit.
|
||||
*/
|
||||
if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
|
||||
$field_info_query = 'SHOW FIELDS FROM `' . $db . '`.`' . $table . '` LIKE \'' . $_REQUEST['column'] . '\' ;';
|
||||
@ -696,7 +696,7 @@ if (0 == $num_rows || $is_affected) {
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
|
||||
/**
|
||||
* If we are in inline editing, we need to process the relational and
|
||||
* If we are in grid editing, we need to process the relational and
|
||||
* transformed fields, if they were edited. After that, output the correct
|
||||
* link/transformed value and exit
|
||||
*
|
||||
@ -859,7 +859,7 @@ if (0 == $num_rows || $is_affected) {
|
||||
else {
|
||||
//If we are retrieving the full value of a truncated field or the original
|
||||
// value of a transformed field, show it here and exit
|
||||
if ($GLOBALS['inline_edit'] == true && $GLOBALS['cfg']['AjaxEnable']) {
|
||||
if ($GLOBALS['grid_edit'] == true && $GLOBALS['cfg']['AjaxEnable']) {
|
||||
$row = PMA_DBI_fetch_row($result);
|
||||
$extra_data = array();
|
||||
$extra_data['value'] = $row[0];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user