The branch, master has been updated via 0f156b19dd3692475bd08e9f3b157385771d68b4 (commit) from 634db1c81de4545f7d63ff92b66f076b2e329f13 (commit)
- Log ----------------------------------------------------------------- commit 0f156b19dd3692475bd08e9f3b157385771d68b4 Author: Marc Delisle marc@infomarc.info Date: Sun Oct 17 09:40:15 2010 -0400
other fixes for inline edit links in vertical mode
-----------------------------------------------------------------------
Summary of changes: js/sql.js | 78 +++++++++++++++++++---------------- libraries/display_tbl.lib.php | 36 ++++------------ libraries/display_tbl_links.lib.php | 33 +++++++++------ 3 files changed, 71 insertions(+), 76 deletions(-)
diff --git a/js/sql.js b/js/sql.js index b95418b..457396f 100644 --- a/js/sql.js +++ b/js/sql.js @@ -32,8 +32,8 @@ function getFieldName(this_field_obj, disp_mode) { else { var this_field_index = $(this_field_obj).index(); if(window.parent.text_dir == 'ltr') { - // 4 columns to account for the checkbox, edit, delete and appended inline edit anchors - var field_name = $(this_field_obj).parents('table').find('thead').find('th:nth('+ (this_field_index-4 )+') a').text(); + // 4 columns to account for the checkbox, edit, delete and appended inline edit anchors but index is zero-based so substract 3 + var field_name = $(this_field_obj).parents('table').find('thead').find('th:nth('+ (this_field_index-3 )+') a').text(); } else { var field_name = $(this_field_obj).parents('table').find('thead').find('th:nth('+ this_field_index+') a').text(); @@ -53,27 +53,33 @@ function getFieldName(this_field_obj, disp_mode) { */ function appendInlineAnchor(disp_mode) { if(disp_mode == 'vertical') { - var $cloned_row = $('.edit_row_anchor').removeClass('edit_row_anchor').parent('tr').clone(); + // there can be one or two tr containing this class, depending + // on the ModifyDeleteAtLeft and ModifyDeleteAtRight cfg parameters + $('#table_results tr').find('.edit_row_anchor').parent().each(function() { + var $this_tr = $(this); + var $cloned_tr = $this_tr.clone();
- var $img_object = $cloned_row.find('img:first').attr('title', PMA_messages['strInlineEdit']); + var $img_object = $cloned_tr.find('img:first').attr('title', PMA_messages['strInlineEdit']);
- $cloned_row.find('td').addClass('edit_row_anchor') - .find('a').attr('href', '#') - .find('span') - .text(PMA_messages['strInlineEdit']) - .prepend($img_object); + $cloned_tr.find('td') + .find('a').attr('href', '#') + .find('span') + .text(PMA_messages['strInlineEdit']) + .prepend($img_object);
- $cloned_row.insertBefore($('.where_clause').parent('tr')); + $cloned_tr.insertAfter($this_tr); + });
- $("#table_results").find('tr:first').find('th') - .attr('rowspan', '4'); + $("#table_results").find('tr').find(':checkbox').closest('tr').find('th') + .attr('rowspan', '4'); } else { $('.edit_row_anchor').each(function() {
- $(this).removeClass('edit_row_anchor'); + $this_td = $(this) + $this_td.removeClass('edit_row_anchor');
- var $cloned_anchor = $(this).clone(); + var $cloned_anchor = $this_td.clone();
var $img_object = $cloned_anchor.find('img').attr('title', PMA_messages['strInlineEdit']);
@@ -83,8 +89,7 @@ function appendInlineAnchor(disp_mode) { .text(PMA_messages['strInlineEdit']) .prepend($img_object);
- $(this).nextAll('.where_clause:eq(0)') - .before($cloned_anchor); + $this_td.after($cloned_anchor); });
$('#rowsDeleteForm').find('thead').find('th').each(function() { @@ -316,7 +321,7 @@ $(document).ready(function() { */
/** - * On click, replace the current field with an input/textarea + * On click, replace the fields of current row with an input/textarea * @memberOf jQuery * @name inline_edit_start * @see PMA_ajaxShowMessage() @@ -482,35 +487,38 @@ $(document).ready(function() { event.preventDefault();
/** - * @var this_row Object referring to current row that is being edited + * @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_row = $(this); + var $this_td = $(this);
// Initialize variables if(disp_mode == 'vertical') { /** - * @var this_row_index Index of the current <td> in the parent <tr> + * @var this_td_index Index of the current <td> in the parent <tr> * Current <td> is the inline edit anchor. */ - var this_row_index = $(this).index(); + var this_td_index = $this_td.index(); /** * @var input_siblings Object referring to all inline editable events from same row */ - var input_siblings = $(this).parents('tbody').find('tr').find('.data_inline_edit:nth('+this_row_index+')'); + var input_siblings = $this_td.parents('tbody').find('tr').find('.data_inline_edit:nth('+this_td_index+')'); /** * @var where_clause String containing the WHERE clause to select this row */ - var where_clause = $(this).parents('tbody').find('tr').find('.where_clause:nth('+this_row_index+')').val(); + var where_clause = $this_td.parents('tbody').find('tr').find('.where_clause:nth('+this_td_index+')').val(); } else { - var input_siblings = $(this).parent('tr').find('.data_inline_edit'); - var where_clause = $(this).parent('tr').find('.where_clause').val(); + var input_siblings = $this_td.parent('tr').find('.data_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).is('.nonunique')) { + if($this_td.is('.nonunique')) { var nonunique = 0; } else { @@ -540,32 +548,32 @@ $(document).ready(function() { /** * @var this_field Object referring to this field (<td>) */ - var this_field = $(this); + var $this_field = $(this); /** * @var field_name String containing the name of this field. * @see getFieldName() */ - var field_name = getFieldName($(this), disp_mode); + var field_name = getFieldName($this_field, disp_mode);
/** * @var this_field_params Array temporary storage for the name/value of current field */ var this_field_params = {};
- if($(this).is('.transformed')) { + if($this_field.is('.transformed')) { transformation_fields = true; }
- if($(this).is(":not(.relation, .enum)")) { - this_field_params[field_name] = $(this).find('textarea').val(); - if($(this).is('.transformed')) { + if($this_field.is(":not(.relation, .enum)")) { + this_field_params[field_name] = $this_field.find('textarea').val(); + if($this_field.is('.transformed')) { $.extend(transform_fields, this_field_params); } } else { - this_field_params[field_name] = $(this).find('select').val(); + this_field_params[field_name] = $this_field.find('select').val();
- if($(this).is('.relation')) { + if($this_field.is('.relation')) { $.extend(relation_fields, this_field_params); } } @@ -619,7 +627,7 @@ $(document).ready(function() { $.post('tbl_replace.php', post_params, function(data) { if(data.success == true) { PMA_ajaxShowMessage(data.message); - $(this_row).removeClass('edit_row_anchor_active').addClass('edit_row_anchor'); + $this_td.removeClass('edit_row_anchor_active').addClass('edit_row_anchor');
$(input_siblings).each(function() { // Inline edit post has been successful. diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 2acf368..0dafdec 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -1442,7 +1442,6 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { $vertical_display['edit'][$row_no] = ''; $vertical_display['delete'][$row_no] = ''; $vertical_display['row_delete'][$row_no] = ''; - $vertical_display['where_clause'][$row_no] = ''; }
$column_style_vertical = ''; @@ -1466,9 +1465,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { }
if (isset($edit_url)) { - $vertical_display['edit'][$row_no] .= ' <td align="center" class="' . $alternating_color_class . ' ' . $edit_anchor_class . '" ' . $column_style_vertical . '>' . "\n" - . PMA_linkOrButton($edit_url, $edit_str, array(), false) - . ' </td>' . "\n"; + $vertical_display['edit'][$row_no] .= '<td align="center" class="' . $alternating_color_class . ' ' . $edit_anchor_class . '" ' . $column_style_vertical . '>' . "\n" + . PMA_linkOrButton($edit_url, $edit_str, array(), false); + // Generates the 'where_clause' hidden input field + // for inline ajax edit if required + if(! empty($where_clause) ) { + $vertical_display['edit'][$row_no] .= '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />'; + } + $vertical_display['edit'][$row_no] .= '</td>'; } else { unset($vertical_display['edit'][$row_no]); } @@ -1481,13 +1485,6 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { unset($vertical_display['delete'][$row_no]); }
- if( !empty($where_clause) ) { - $vertical_display['where_clause'][$row_no] = '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />'; - } - else { - unset($vertical_display['where_clause'][$row_no]); - } - echo (($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') ? "\n" : ''); $row_no++; } // end while @@ -1500,7 +1497,6 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
/** * Do display the result table with the vertical direction mode. - * Credits for this feature goes to Garvin Hicking hicking@faktor-e.de. * * @return boolean always true * @@ -1567,22 +1563,6 @@ function PMA_displayVerticalTable() echo '</tr>' . "\n"; } // end if
- // Generates the 'where_clause' hidden input field for inline ajax edit if required - if ( is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 ) ) { - echo '<tr>' . "\n"; - - $foo_counter = 0; - foreach ($vertical_display['where_clause'] as $val) { - if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) { - echo '<th></th>' . "\n"; - } - - echo $val; - $foo_counter++; - } // end while - echo '</tr>' . "\n"; - } // end if - // Displays data foreach ($vertical_display['desc'] AS $key => $val) {
diff --git a/libraries/display_tbl_links.lib.php b/libraries/display_tbl_links.lib.php index 7398910..43603de 100644 --- a/libraries/display_tbl_links.lib.php +++ b/libraries/display_tbl_links.lib.php @@ -26,9 +26,16 @@ if ($doWriteModifyAt == 'left') { . ' </td>' . "\n"; } if (!empty($edit_url)) { - echo ' <td class="' . $edit_anchor_class . '" align="center">' . "\n" - . PMA_linkOrButton($edit_url, $edit_str, '', FALSE) - . ' </td>' . "\n"; + echo '<td class="' . $edit_anchor_class . '" align="center">' + . PMA_linkOrButton($edit_url, $edit_str, '', FALSE); + /* + * Where clause for selecting this row uniquely is provided as + * a hidden input. Used by jQuery scripts for handling inline editing + */ + if(! empty($where_clause)) { + echo '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />'; + } + echo '</td>'; } if (!empty($del_url)) { echo ' <td align="center">' . "\n" @@ -42,9 +49,16 @@ if ($doWriteModifyAt == 'left') { . ' </td>' . "\n"; } if (!empty($edit_url)) { - echo ' <td class="' . $edit_anchor_class . '" align="center">' . "\n" - . PMA_linkOrButton($edit_url, $edit_str, '', FALSE) - . ' </td>' . "\n"; + echo '<td class="' . $edit_anchor_class . '" align="center">' + . PMA_linkOrButton($edit_url, $edit_str, '', FALSE); + /* + * Where clause for selecting this row uniquely is provided as + * a hidden input. Used by jQuery scripts for handling inline editing + */ + if(! empty($where_clause)) { + echo '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />'; + } + echo ' </td>'; } if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { echo ' <td align="center">' . "\n" @@ -54,11 +68,4 @@ if ($doWriteModifyAt == 'left') { . ' </td>' . "\n"; } } -/* - * Where clause for selecting this row uniquely is provided as a hidden input. - * Used by jQuery scripts for handling inline editing - */ -if( !empty($where_clause)) { - echo '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />'; -} ?>
hooks/post-receive