From 0b657415058fc67bc4301cfacf4ab4b62100aec8 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Mar 2015 16:34:00 +0530 Subject: [PATCH 1/7] Use an icon consistent with the rows Signed-off-by: Madhura Jayaratne --- libraries/central_columns.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php index e0807fa6c1..e7345d58b4 100644 --- a/libraries/central_columns.lib.php +++ b/libraries/central_columns.lib.php @@ -1077,7 +1077,7 @@ function PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir) $html_output .= PMA_Util::getButtonOrImage( 'delete_central_columns', 'mult_submit', 'submit_mult_central_columns_remove', - __('Delete'), 'centralColumns_delete.png', + __('Delete'), 'b_drop.png', 'remove_from_central_columns' ); return $html_output; From 390796c01e1814580a2b9ef065cc97eaed54005b Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Mar 2015 16:45:18 +0530 Subject: [PATCH 2/7] Use column order similar to create table page Signed-off-by: Madhura Jayaratne --- libraries/central_columns.lib.php | 55 ++++++++++++++++--------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php index e7345d58b4..bdcaa9a76f 100644 --- a/libraries/central_columns.lib.php +++ b/libraries/central_columns.lib.php @@ -692,6 +692,8 @@ function PMA_getCentralColumnsTableHeader($class='', $title='', $actionCount=0) . __('Type') . '
' . '' . __('Length/Values') . '
' + . '' + . __('Default') . '
' . '' . __('Collation') . '
' . '' . '' . __('Extra') . '
' - . '' - . __('Default') . '
' . ''; $tableheader .= ''; return $tableheader; @@ -875,6 +875,28 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db) . PMA_getHtmlForColumnLength($row_num, 2, 0, 8, $row['col_length']) . ''; + $meta = array(); + if (!isset($row['col_default']) || $row['col_default'] == '') { + $meta['DefaultType'] = 'NONE'; + } else { + if ($row['col_default'] == 'CURRENT_TIMESTAMP' + || $row['col_default'] == 'NULL' + ) { + $meta['DefaultType'] = $row['col_default']; + } else { + $meta['DefaultType'] = 'USER_DEFINED'; + $meta['DefaultValue'] = $row['col_default']; + } + } + $tableHtml .= + '' . (isset($row['col_default']) + ? htmlspecialchars($row['col_default']) : 'None') + . '' + . PMA_getHtmlForColumnDefault( + $row_num, 6, 0, /*overload*/mb_strtoupper($row['col_type']), '', $meta + ) + . ''; + $tableHtml .= '' . '' . htmlspecialchars($row['col_collation']) . '' @@ -906,28 +928,9 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db) . '' . '' . ''; - $meta = array(); - if (!isset($row['col_default']) || $row['col_default'] == '') { - $meta['DefaultType'] = 'NONE'; - } else { - if ($row['col_default'] == 'CURRENT_TIMESTAMP' - || $row['col_default'] == 'NULL' - ) { - $meta['DefaultType'] = $row['col_default']; - } else { - $meta['DefaultType'] = 'USER_DEFINED'; - $meta['DefaultValue'] = $row['col_default']; - } - } - $tableHtml .= - '' . (isset($row['col_default']) - ? htmlspecialchars($row['col_default']) : 'None') - . '' - . PMA_getHtmlForColumnDefault( - $row_num, 6, 0, /*overload*/mb_strtoupper($row['col_type']), '', $meta - ) - . ''; + $tableHtml .= ''; + return $tableHtml; } @@ -1164,6 +1167,9 @@ function PMA_getHTMLforAddNewColumn($db) . '' . PMA_getHtmlForColumnLength(0, 2, 0, 8, '') . '' + . '' + . PMA_getHtmlForColumnDefault(0, 6, 0, '', '', array()) + . '' . '' . PMA_getHtmlForColumnCollation( 0, 3, 0, array() @@ -1181,9 +1187,6 @@ function PMA_getHTMLforAddNewColumn($db) . '' . '' - . '' - . PMA_getHtmlForColumnDefault(0, 6, 0, '', '', array()) - . '' . ' ' . '' From 5e5f5de6dd89bd12403a8826059589703867f8dc Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Mar 2015 16:53:22 +0530 Subject: [PATCH 3/7] Use same column order here as well Signed-off-by: Madhura Jayaratne --- libraries/central_columns.lib.php | 43 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php index bdcaa9a76f..2a5ded357c 100644 --- a/libraries/central_columns.lib.php +++ b/libraries/central_columns.lib.php @@ -965,7 +965,25 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num) '' . PMA_getHtmlForColumnLength($row_num, 2, 0, 8, $row['col_length']) . ''; - + $meta = array(); + if (!isset($row['col_default']) || $row['col_default'] == '') { + $meta['DefaultType'] = 'NONE'; + } else { + if ($row['col_default'] == 'CURRENT_TIMESTAMP' + || $row['col_default'] == 'NULL' + ) { + $meta['DefaultType'] = $row['col_default']; + } else { + $meta['DefaultType'] = 'USER_DEFINED'; + $meta['DefaultValue'] = $row['col_default']; + } + } + $tableHtml .= + '' + . PMA_getHtmlForColumnDefault( + $row_num, 6, 0, /*overload*/mb_strtoupper($row['col_default']), '', $meta + ) + . ''; $tableHtml .= '' . PMA_getHtmlForColumnCollation( @@ -993,25 +1011,6 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num) . ' value="auto_increment">' . __('auto_increment') . '' . '' . ''; - $meta = array(); - if (!isset($row['col_default']) || $row['col_default'] == '') { - $meta['DefaultType'] = 'NONE'; - } else { - if ($row['col_default'] == 'CURRENT_TIMESTAMP' - || $row['col_default'] == 'NULL' - ) { - $meta['DefaultType'] = $row['col_default']; - } else { - $meta['DefaultType'] = 'USER_DEFINED'; - $meta['DefaultValue'] = $row['col_default']; - } - } - $tableHtml .= - '' - . PMA_getHtmlForColumnDefault( - $row_num, 6, 0, /*overload*/mb_strtoupper($row['col_type']), '', $meta - ) - . ''; $tableHtml .= ''; return $tableHtml; } @@ -1207,8 +1206,8 @@ function PMA_getHTMLforEditingPage($selected_fld,$selected_db) { $html = '
'; $header_cells = array( - __('Name'), __('Type'), __('Length/Values'), __('Collation'), - __('Attributes'), __('Null'), __('Extra'), __('Default') + __('Name'), __('Type'), __('Length/Values'), __('Default'), + __('Collation'), __('Attributes'), __('Null'), __('Extra') ); $html .= PMA_getCentralColumnsEditTableHeader($header_cells); $selected_fld_safe = array(); From 80fad9010c974972beffcf33a62c5b3b11897ca2 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Mar 2015 16:55:40 +0530 Subject: [PATCH 4/7] on update CURRENT_TIMESTAMP is now under attributes Signed-off-by: Madhura Jayaratne --- libraries/central_columns.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php index 2a5ded357c..9337429010 100644 --- a/libraries/central_columns.lib.php +++ b/libraries/central_columns.lib.php @@ -1183,8 +1183,7 @@ function PMA_getHTMLforAddNewColumn($db) . '' . '' + . '' . '' . ' ' . ' Date: Wed, 11 Mar 2015 17:46:03 +0530 Subject: [PATCH 5/7] Use a checkbox for the extra column Signed-off-by: Madhura Jayaratne --- db_central_columns.php | 2 +- js/db_central_columns.js | 4 +- libraries/central_columns.lib.php | 50 +++++++++---------- libraries/tbl_columns_definition_form.lib.php | 25 ++++++++++ 4 files changed, 51 insertions(+), 30 deletions(-) diff --git a/db_central_columns.php b/db_central_columns.php index aaf3de92c4..6a0369641c 100644 --- a/db_central_columns.php +++ b/db_central_columns.php @@ -22,7 +22,7 @@ if (isset($_POST['edit_save']) || isset($_POST['add_new_column'])) { if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') { $col_default = ""; } - $col_extra = $_POST['col_extra']; + $col_extra = isset($_POST['col_extra']) ? $_POST['col_extra'] : ''; $col_isNull = isset($_POST['col_isNull'])?1:0; $col_length = $_POST['col_length']; $col_attribute = $_POST['col_attribute']; diff --git a/js/db_central_columns.js b/js/db_central_columns.js index 42499fde67..b6a320cde4 100644 --- a/js/db_central_columns.js +++ b/js/db_central_columns.js @@ -104,10 +104,8 @@ AJAX.registerOnload('db_central_columns.js', function () { $(this).hide(); $('#f_' + rownum + ' td span').hide(); $('#f_' + rownum + ' input, #f_' + rownum + ' select, #f_' + rownum + ' .open_enum_editor').show(); - var extra_val = $('#f_' + rownum + ' td[name=col_extra] span').html(); var attribute_val = $('#f_' + rownum + ' td[name=col_attribute] span').html(); $('#f_' + rownum + ' select[name=field_attribute\\['+ rownum +'\\] ] option[value="' + attribute_val + '"]').attr("selected","selected"); - $('#f_' + rownum + ' select[name=col_extra] option[value="' + extra_val + '"]').attr("selected","selected"); if($('#f_' + rownum + ' .default_type').val() === 'USER_DEFINED') { $('#f_' + rownum + ' .default_type').siblings('.default_value').show(); } else { @@ -174,7 +172,7 @@ AJAX.registerOnload('db_central_columns.js', function () { $('#f_' + rownum + ' td[name=collation] span').text($('#f_' + rownum + ' select[name=collation]').val()).html(); $('#f_' + rownum + ' td[name=col_attribute] span').text($('#f_' + rownum + ' select[name=col_attribute]').val()).html(); $('#f_' + rownum + ' td[name=col_isNull] span').text($('#f_' + rownum +' input[name=col_isNull]').is(":checked")?"Yes":"No").html(); - $('#f_' + rownum + ' td[name=col_extra] span').text($('#f_' + rownum + ' select[name=col_extra]').val()).html(); + $('#f_' + rownum + ' td[name=col_extra] span').text($('#f_' + rownum + ' input[name=col_extra]').is(":checked") ? "auto_increment" : "").html(); $('#f_' + rownum + ' td[name=col_default] span').text($('#f_' + rownum + ' :input[name=col_default]').val()).html(); } $('#save_' + rownum).hide(); diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php index 9337429010..1fbeae7fc7 100644 --- a/libraries/central_columns.lib.php +++ b/libraries/central_columns.lib.php @@ -579,6 +579,9 @@ function PMA_updateMultipleColumn() } else if ($col_default[$i] == 'USER_DEFINED') { $col_default[$i] = $_POST['field_default_value'][$i]; } + if (! isset($_POST['col_extra'][$i])) { + $col_extra[$i] = ''; + } $message = PMA_updateOneColumn( $db, $orig_col_name[$i], $col_name[$i], $col_type[$i], $col_attribute[$i], $col_length[$i], $col_isNull[$i], $collation[$i], @@ -702,7 +705,7 @@ function PMA_getCentralColumnsTableHeader($class='', $title='', $actionCount=0) . '' . __('Null') . '
' . '' - . __('Extra') . '
' + . __('A_I') . '
' . ''; $tableheader .= ''; return $tableheader; @@ -893,7 +896,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db) ? htmlspecialchars($row['col_default']) : 'None') . '' . PMA_getHtmlForColumnDefault( - $row_num, 6, 0, /*overload*/mb_strtoupper($row['col_type']), '', $meta + $row_num, 3, 0, /*overload*/mb_strtoupper($row['col_type']), '', $meta ) . ''; @@ -901,7 +904,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db) '' . '' . htmlspecialchars($row['col_collation']) . '' . PMA_getHtmlForColumnCollation( - $row_num, 3, 0, array('Collation'=>$row['col_collation']) + $row_num, 4, 0, array('Collation'=>$row['col_collation']) ) . ''; $tableHtml .= @@ -911,22 +914,22 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db) ? htmlspecialchars($row['col_attribute']) : "" ) . '' . PMA_getHtmlForColumnAttribute( - $row_num, 4, 0, array(), $row['col_attribute'], false, null + $row_num, 5, 0, array(), $row['col_attribute'], false, null ) . ''; $tableHtml .= '' . '' . ($row['col_isNull'] ? __('Yes') : __('No')) . '' - . PMA_getHtmlForColumnNull($row_num, 5, 0, array('Null'=>$row['col_isNull'])) + . PMA_getHtmlForColumnNull($row_num, 6, 0, array('Null'=>$row['col_isNull'])) . ''; $tableHtml .= '' . htmlspecialchars($row['col_extra']) . '' - . '' + . PMA_getHtmlForColumnExtra( + $row_num, 7, 0, array('Extra'=>$row['col_extra']) + ) . ''; $tableHtml .= ''; @@ -981,35 +984,32 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num) $tableHtml .= '' . PMA_getHtmlForColumnDefault( - $row_num, 6, 0, /*overload*/mb_strtoupper($row['col_default']), '', $meta + $row_num, 3, 0, /*overload*/mb_strtoupper($row['col_default']), '', $meta ) . ''; $tableHtml .= '' . PMA_getHtmlForColumnCollation( - $row_num, 3, 0, array('Collation'=>$row['col_collation']) + $row_num, 4, 0, array('Collation'=>$row['col_collation']) ) . ''; $tableHtml .= '' . PMA_getHtmlForColumnAttribute( - $row_num, 4, 0, array("attribute"=>$row['col_attribute']), + $row_num, 5, 0, array("attribute"=>$row['col_attribute']), array(), false, null ) . ''; $tableHtml .= '' - . PMA_getHtmlForColumnNull($row_num, 5, 0, array('Null'=>$row['col_isNull'])) + . PMA_getHtmlForColumnNull($row_num, 6, 0, array('Null'=>$row['col_isNull'])) . ''; $extra_val = $row['col_extra']; $tableHtml .= '' - . '' + . PMA_getHtmlForColumnExtra( + $row_num, 7, 0, array('Extra' => $row['col_extra']) + ) . ''; $tableHtml .= ''; return $tableHtml; @@ -1167,23 +1167,21 @@ function PMA_getHTMLforAddNewColumn($db) . PMA_getHtmlForColumnLength(0, 2, 0, 8, '') . '' . '' - . PMA_getHtmlForColumnDefault(0, 6, 0, '', '', array()) + . PMA_getHtmlForColumnDefault(0, 3, 0, '', '', array()) . '' . '' . PMA_getHtmlForColumnCollation( - 0, 3, 0, array() + 0, 4, 0, array() ) . '' . '' - . PMA_getHtmlForColumnAttribute(0, 4, 0, array(), array(), false, null) + . PMA_getHtmlForColumnAttribute(0, 5, 0, array(), array(), false, null) . '' . '' - . PMA_getHtmlForColumnNull(0, 5, 0, array()) + . PMA_getHtmlForColumnNull(0, 6, 0, array()) . '' . '' - . '' + . PMA_getHtmlForColumnExtra(0, 7, 0, array()) . '' . ' ' . ' Date: Wed, 11 Mar 2015 17:57:16 +0530 Subject: [PATCH 6/7] Fix failing test Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index 6c6a4abc46..e2d6fcc201 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -431,7 +431,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase ); $this->assertContains( PMA_getHtmlForColumnDefault( - 1, 6, 0, /*overload*/mb_strtoupper($row['col_type']), '', + 1, 3, 0, /*overload*/mb_strtoupper($row['col_type']), '', array('DefaultType'=>'NONE') ), $result @@ -442,7 +442,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase ); $this->assertContains( PMA_getHtmlForColumnDefault( - 1, 6, 0, /*overload*/mb_strtoupper($row['col_type']), '', + 1, 3, 0, /*overload*/mb_strtoupper($row['col_type']), '', array('DefaultType'=>'USER_DEFINED', 'DefaultValue'=>100) ), $result_1 @@ -453,7 +453,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase ); $this->assertContains( PMA_getHtmlForColumnDefault( - 1, 6, 0, /*overload*/mb_strtoupper($row['col_type']), '', + 1, 3, 0, /*overload*/mb_strtoupper($row['col_type']), '', array('DefaultType'=>'CURRENT_TIMESTAMP') ), $result_2 From ebbaf9685c6b63f91108c51f7f1495aa2ac3ff42 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 11 Mar 2015 18:05:43 +0530 Subject: [PATCH 7/7] Improve UI consistency Signed-off-by: Madhura Jayaratne --- js/db_central_columns.js | 6 ------ libraries/central_columns.lib.php | 7 +++---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/js/db_central_columns.js b/js/db_central_columns.js index b6a320cde4..16c8ab07f4 100644 --- a/js/db_central_columns.js +++ b/js/db_central_columns.js @@ -76,12 +76,6 @@ AJAX.registerOnload('db_central_columns.js', function () { PMA_ajaxShowMessage(); $.post('db_central_columns.php', multi_column_edit_data, AJAX.responseHandler); }); - $('#multi_edit_central_columns #cancel_multi_edit').click(function(event){ - event.preventDefault(); - var cancel_edit = 'ajax_request=true&ajax_page_request=true&token='+PMA_commonParams.get('token')+'&db='+PMA_commonParams.get('db'); - PMA_ajaxShowMessage(); - $.get('db_central_columns.php', cancel_edit, AJAX.responseHandler); - }); $('#add_new td').each(function(){ if ($(this).attr('name') !== 'undefined') { $(this).find('input,select:first').attr('name', $(this).attr('name')); diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php index 1fbeae7fc7..b69e937008 100644 --- a/libraries/central_columns.lib.php +++ b/libraries/central_columns.lib.php @@ -721,7 +721,8 @@ function PMA_getCentralColumnsTableHeader($class='', $title='', $actionCount=0) */ function PMA_getCentralColumnsEditTableHeader($header_cells) { - $html = ''; + $html = '
'; $html .= ''; foreach ($header_cells as $header_val) { @@ -1093,11 +1094,9 @@ function PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir) */ function PMA_getCentralColumnsEditTableFooter() { - $html_output = '
' + $html_output = '
' . '' - . '' . '
'; return $html_output; }
' . __('Structure'); $html .= '