From d483b9f03af05f646ee33f406e5a8bb1b5d13e0a Mon Sep 17 00:00:00 2001 From: Viduranga Wijesooriya Date: Thu, 30 Jan 2014 16:09:55 +0530 Subject: [PATCH 1/8] fixed bug #4257 Hide fractional seconds Signed-off-by: Viduranga Wijesooriya --- js/functions.js | 6 ++-- js/jquery/jquery-ui-timepicker-addon.js | 12 ++++--- js/makegrid.js | 48 ++++++++++++++++++++++--- libraries/DisplayResults.class.php | 9 ++--- 4 files changed, 60 insertions(+), 15 deletions(-) diff --git a/js/functions.js b/js/functions.js index 634e7c9eed..a04d094eef 100644 --- a/js/functions.js +++ b/js/functions.js @@ -208,12 +208,12 @@ function PMA_addDatepicker($this_element, options) stepMinutes: 1, stepHours: 1, showSecond: true, - showMillisec: true, - showMicrosec: true, + showMillisec: false, + showMicrosec: false, showTimepicker: showTimeOption, showButtonPanel: false, dateFormat: 'yy-mm-dd', // yy means year with four digits - timeFormat: 'HH:mm:ss.lc', + timeFormat: 'HH:mm:ss', constrainInput: false, altFieldTimeOnly: false, showAnim: '', diff --git a/js/jquery/jquery-ui-timepicker-addon.js b/js/jquery/jquery-ui-timepicker-addon.js index 1a22b0cbb6..cf4bda8377 100644 --- a/js/jquery/jquery-ui-timepicker-addon.js +++ b/js/jquery/jquery-ui-timepicker-addon.js @@ -369,11 +369,15 @@ // Prevent displaying twice if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { var noDisplay = ' style="display:none;"', - html = '
' + '
' + o.timeText + '
' + - '
'; - + html = '
'; + var units_length = this.units.length; + //check for decimal places of seconds + if(units_length > 3){ + html += '
' + o.timeText + '
' + + '
'; + } // Create the markup - for(i=0,l=this.units.length; i 0) && ( $this_field.data('type').indexOf('time') != -1)){ + new_html = new_html.substring(0, new_html.length - (6 - $this_field.data('decimals'))); + } if ($this_field.is('.truncated')) { if (new_html.length > g.maxTruncatedLen) { new_html = new_html.substring(0, g.maxTruncatedLen) + '...'; @@ -967,7 +976,24 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi if ($td.is('.datefield')) { showTimeOption = false; } + + var showMillisec = false; + var showMicrosec = false; + var timeFormat = 'HH:mm:ss'; + // check for decimal places of seconds + if (($td.data('decimals') > 0) && ($td.data('type').indexOf('time') != -1)){ + showMillisec = true; + timeFormat = 'HH:mm:ss.lc'; + if ($td.data('decimals') > 3) { + showMicrosec = true; + } + + } + PMA_addDatepicker($editArea, { + showMillisec: showMillisec, + showMicrosec: showMicrosec, + timeFormat: timeFormat, altField: $input_field, showTimepicker: showTimeOption, onSelect: function (dateText, inst) { @@ -994,15 +1020,29 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi parseInt(current_datetime_value.substring(5, 7)) - 1, parseInt(current_datetime_value.substring(8, 10)) ); - if (current_datetime_value.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}$/)) { + if (current_datetime_value.match("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{"+ no_decimals +"}$")) { var hour = current_datetime_value.substring(11, 13); var min = current_datetime_value.substring(14, 16); var sec = current_datetime_value.substring(17, 19); - var milli = current_datetime_value.substring(20, 23); - var micro = current_datetime_value.substring(23); + + if (no_decimals > 3){ + var milli = current_datetime_value.substring(20, 23); + var micro = current_datetime_value.substring(23); + for (var i = 0; i < 6-no_decimals ; i++) { + micro += "0"; + } + } + if (no_decimals <= 3){ + var milli = current_datetime_value.substring(20); + for (var i = 0; i < 3-no_decimals ; i++) { + milli += "0"; + } + var micro = "000"; + } + date.setHours(hour, min, sec, milli); date.setMicroseconds(micro); - } + } $editArea.datetimepicker('setDate', date); } $editArea.append('
' + g.cellEditHint + '
'); diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 44024f017d..45413285ae 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -3945,9 +3945,10 @@ class PMA_DisplayResults ); $formatted = true; } - } elseif ((substr($meta->type, 0, 9) == self::TIMESTAMP_FIELD) - || ($meta->type == self::DATETIME_FIELD) - || ($meta->type == self::TIME_FIELD) + } elseif (((substr($meta->type, 0, 9) == self::TIMESTAMP_FIELD) + || ($meta->type == self::DATETIME_FIELD) + || ($meta->type == self::TIME_FIELD) + || ($meta->type == self::TIME_FIELD)) && (strpos ($column,"." ) === TRUE) ) { $column = PMA_Util::addMicroseconds($column); } @@ -5523,7 +5524,7 @@ class PMA_DisplayResults $relational_display = $_SESSION['tmpval']['relational_display']; $printview = $this->__get('printview'); - $result = 'decimals.'" data-type="'.$meta->type.'" class="' . $this->_addClass( $class, $condition_field, $meta, $nowrap, $is_field_truncated, $transformation_plugin, $default_function From efa453a8a0603d1350c74656785fb17f0bc0fcd3 Mon Sep 17 00:00:00 2001 From: Viduranga Wijesooriya Date: Thu, 30 Jan 2014 19:04:04 +0530 Subject: [PATCH 2/8] fixed bug #4257 Hide fractional seconds #2 Signed-off-by: Viduranga Wijesooriya --- js/makegrid.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 5d95c717d0..6200b19313 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -1020,11 +1020,12 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi parseInt(current_datetime_value.substring(5, 7)) - 1, parseInt(current_datetime_value.substring(8, 10)) ); - if (current_datetime_value.match("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{"+ no_decimals +"}$")) { - var hour = current_datetime_value.substring(11, 13); - var min = current_datetime_value.substring(14, 16); - var sec = current_datetime_value.substring(17, 19); + var no_decimals = $td.data('decimals'); + var hour = current_datetime_value.substring(11, 13); + var min = current_datetime_value.substring(14, 16); + var sec = current_datetime_value.substring(17, 19); + if (current_datetime_value.match("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{"+ no_decimals +"}$")) { if (no_decimals > 3){ var milli = current_datetime_value.substring(20, 23); var micro = current_datetime_value.substring(23); @@ -1042,6 +1043,10 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi date.setHours(hour, min, sec, milli); date.setMicroseconds(micro); + } + if (current_datetime_value.match("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}")) { + console.log("G"); + date.setHours(hour, min, sec); } $editArea.datetimepicker('setDate', date); } From fc4ad4b6acfbde357309a98dc9cdeedc08c626fe Mon Sep 17 00:00:00 2001 From: Viduranga Wijesooriya Date: Thu, 30 Jan 2014 21:55:46 +0530 Subject: [PATCH 3/8] fixed bug #4257 Hide fractional seconds #3 Signed-off-by: Viduranga Wijesooriya --- js/jquery/jquery-ui-timepicker-addon.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/js/jquery/jquery-ui-timepicker-addon.js b/js/jquery/jquery-ui-timepicker-addon.js index cf4bda8377..2b839bf4cb 100644 --- a/js/jquery/jquery-ui-timepicker-addon.js +++ b/js/jquery/jquery-ui-timepicker-addon.js @@ -369,15 +369,11 @@ // Prevent displaying twice if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { var noDisplay = ' style="display:none;"', - html = '
'; - var units_length = this.units.length; - //check for decimal places of seconds - if(units_length > 3){ - html += '
' + o.timeText + '
' + - '
'; - } + html = '
' + '
' + o.timeText + '
' + + '
'; + // Create the markup - for(i = 0, l = units_length; i < l; i++){ + for(i=0,l=this.units.length; i Date: Fri, 31 Jan 2014 01:52:52 +0530 Subject: [PATCH 4/8] bug#4257 - fixed datetimepicker view of record edit page Signed-off-by: Viduranga Wijesooriya --- js/functions.js | 27 ++++++++++++++++++++++----- libraries/Util.class.php | 2 +- libraries/insert_edit.lib.php | 15 ++++++++++++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/js/functions.js b/js/functions.js index a04d094eef..3325d9ed95 100644 --- a/js/functions.js +++ b/js/functions.js @@ -208,12 +208,12 @@ function PMA_addDatepicker($this_element, options) stepMinutes: 1, stepHours: 1, showSecond: true, - showMillisec: false, - showMicrosec: false, + showMillisec: true, + showMicrosec: true, showTimepicker: showTimeOption, showButtonPanel: false, dateFormat: 'yy-mm-dd', // yy means year with four digits - timeFormat: 'HH:mm:ss', + timeFormat: 'HH:mm:ss.lc', constrainInput: false, altFieldTimeOnly: false, showAnim: '', @@ -858,8 +858,25 @@ function insertValueQuery() function addDateTimePicker() { if ($.timepicker !== undefined) { $('input.datefield, input.datetimefield').each(function () { - PMA_addDatepicker($(this)); - }); + + no_decimals = $(this).data('decimals'); + var showMillisec = false; + var showMicrosec = false; + var timeFormat = 'HH:mm:ss'; + // check for decimal places of seconds + if (($(this).data('decimals') > 0) && ($(this).data('type').indexOf('time') != -1)){ + showMillisec = true; + timeFormat = 'HH:mm:ss.lc'; + if ($(this).data('decimals') > 3) { + showMicrosec = true; + } + } + PMA_addDatepicker($(this), { + showMillisec: showMillisec, + showMicrosec: showMicrosec, + timeFormat: timeFormat + }); + }) } } diff --git a/libraries/Util.class.php b/libraries/Util.class.php index 8ff48770b2..8db4840f65 100644 --- a/libraries/Util.class.php +++ b/libraries/Util.class.php @@ -4358,7 +4358,7 @@ class PMA_Util $value .= '000000'; return substr($value, 0, strpos($value, '.') + 7); } else { - return $value . '.000000'; + return $value; } } } diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 1d3e394260..35bd1a0b2e 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -1183,11 +1183,18 @@ function PMA_getHTMLinput($column, $column_name_appendix, $special_chars, $input_type = 'text'; // do not use the 'date' or 'time' types here; they have no effect on some // browsers and create side effects (see bug #4218) + $no_decimals=0; + $type = current(explode("(", $column['pma_type'])); + if(preg_match('/\(([^()]+)\)/', $column['pma_type'], $match)){ + $match[0] = trim($match[0], '()'); + $no_decimals=$match[0]; + } + $the_class = 'textfield'; if ($column['pma_type'] === 'date') { $the_class .= ' datefield'; - } elseif ($column['pma_type'] === 'datetime' - || substr($column['pma_type'], 0, 9) === 'timestamp' + } elseif ( strpos($column['pma_type'], 'datetime') !== false + || strpos($column['pma_type'], 'timestamp') !== false ) { $the_class .= ' datetimefield'; } @@ -1210,6 +1217,8 @@ function PMA_getHTMLinput($column, $column_name_appendix, $special_chars, . ($input_min_max !== false ? ' ' . $input_min_max : '') . ($input_type === 'time' ? ' step="1"' : '') . ' class="' . $the_class . '" ' . $unnullify_trigger + . ' data-decimals="' .$no_decimals .'"' + . ' data-type="' .$type .'"' . ' tabindex="' . ($tabindex + $tabindex_for_value). '"' . ' id="field_' . ($idindex) . '_3" />'; } @@ -1755,7 +1764,7 @@ function PMA_getSpecialCharsAndBackupFieldForInsertingMode( $column, $real_null_value ) { if (! isset($column['Default'])) { - $column['Default'] = ''; + $column['Default'] = ''; $real_null_value = true; $data = ''; } else { From 2f2dd3b548e769f2e65ab838cd5cca9fbb8c2561 Mon Sep 17 00:00:00 2001 From: Viduranga Wijesooriya Date: Fri, 31 Jan 2014 01:58:33 +0530 Subject: [PATCH 5/8] bug#4257 - refixed datetimepicker view of record edit page Signed-off-by: Viduranga Wijesooriya --- js/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/functions.js b/js/functions.js index 3325d9ed95..a136be8b6f 100644 --- a/js/functions.js +++ b/js/functions.js @@ -874,7 +874,7 @@ function addDateTimePicker() { PMA_addDatepicker($(this), { showMillisec: showMillisec, showMicrosec: showMicrosec, - timeFormat: timeFormat + timeFormat: timeFormat, }); }) } From 8cc01b38ae313d5f3e8576b1b4180e8ee1e92896 Mon Sep 17 00:00:00 2001 From: Viduranga Wijesooriya Date: Fri, 31 Jan 2014 12:09:46 +0530 Subject: [PATCH 6/8] bug#4257 - fixed test failures Signed-off-by: Viduranga Wijesooriya --- js/functions.js | 6 +++--- libraries/DisplayResults.class.php | 1 + libraries/Util.class.php | 4 ++-- libraries/insert_edit.lib.php | 26 +++++++++++++------------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/js/functions.js b/js/functions.js index a136be8b6f..2f36bc8ec6 100644 --- a/js/functions.js +++ b/js/functions.js @@ -859,15 +859,15 @@ function addDateTimePicker() { if ($.timepicker !== undefined) { $('input.datefield, input.datetimefield').each(function () { - no_decimals = $(this).data('decimals'); + no_decimals = $(this).parent().data('decimals'); var showMillisec = false; var showMicrosec = false; var timeFormat = 'HH:mm:ss'; // check for decimal places of seconds - if (($(this).data('decimals') > 0) && ($(this).data('type').indexOf('time') != -1)){ + if (($(this).parent().data('decimals') > 0) && ($(this).parent().data('type').indexOf('time') != -1)){ showMillisec = true; timeFormat = 'HH:mm:ss.lc'; - if ($(this).data('decimals') > 3) { + if ($(this).parent().data('decimals') > 3) { showMicrosec = true; } } diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 45413285ae..150e9fb360 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -6034,3 +6034,4 @@ class PMA_DisplayResults } ?> +da \ No newline at end of file diff --git a/libraries/Util.class.php b/libraries/Util.class.php index 8db4840f65..8a8fddce57 100644 --- a/libraries/Util.class.php +++ b/libraries/Util.class.php @@ -4358,9 +4358,9 @@ class PMA_Util $value .= '000000'; return substr($value, 0, strpos($value, '.') + 7); } else { - return $value; + return $value . '.000000'; } } } -?> +?> \ No newline at end of file diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 35bd1a0b2e..c30462bd30 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -1183,13 +1183,7 @@ function PMA_getHTMLinput($column, $column_name_appendix, $special_chars, $input_type = 'text'; // do not use the 'date' or 'time' types here; they have no effect on some // browsers and create side effects (see bug #4218) - $no_decimals=0; - $type = current(explode("(", $column['pma_type'])); - if(preg_match('/\(([^()]+)\)/', $column['pma_type'], $match)){ - $match[0] = trim($match[0], '()'); - $no_decimals=$match[0]; - } - + $the_class = 'textfield'; if ($column['pma_type'] === 'date') { $the_class .= ' datefield'; @@ -1216,9 +1210,7 @@ function PMA_getHTMLinput($column, $column_name_appendix, $special_chars, . ' value="' . $special_chars . '" size="' . $fieldsize . '"' . ($input_min_max !== false ? ' ' . $input_min_max : '') . ($input_type === 'time' ? ' step="1"' : '') - . ' class="' . $the_class . '" ' . $unnullify_trigger - . ' data-decimals="' .$no_decimals .'"' - . ' data-type="' .$type .'"' + . ' class="' . $the_class . '" ' . $unnullify_trigger . ' tabindex="' . ($tabindex + $tabindex_for_value). '"' . ' id="field_' . ($idindex) . '_3" />'; } @@ -2826,12 +2818,20 @@ function PMA_getHtmlForInsertEditFormColumn($table_columns, $i, $column, $tabindex, $tabindex_for_null, $idindex, $vkey, $foreigners, $foreignData ); - + // The value column (depends on type) // ---------------- // See bug #1667887 for the reason why we don't use the maxlength - // HTML attribute - $html_output .= ' ' . "\n"; + // HTML attribute + + //add data attributes "no of decimals" and "data type" + $no_decimals=0; + $type = current(explode("(", $column['pma_type'])); + if(preg_match('/\(([^()]+)\)/', $column['pma_type'], $match)){ + $match[0] = trim($match[0], '()'); + $no_decimals=$match[0]; + } + $html_output .= '' . "\n"; // Will be used by js/tbl_change.js to set the default value // for the "Continue insertion" feature $html_output .= '' From 4616eb093ecd8b2f4a5fbb29f641a7f64fc238b4 Mon Sep 17 00:00:00 2001 From: Viduranga Wijesooriya Date: Fri, 31 Jan 2014 12:17:24 +0530 Subject: [PATCH 7/8] bug#4257 - readded something missed Signed-off-by: Viduranga Wijesooriya --- libraries/insert_edit.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index c30462bd30..2252d6d39d 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -1672,9 +1672,10 @@ function PMA_getSpecialCharsAndBackupFieldForExistingRow( $special_chars = PMA_Util::printableBitValue( $current_row[$column['Field']], $extracted_columnspec['spec_in_brackets'] ); - } elseif (substr($column['True_Type'], 0, 9) == 'timestamp' + } elseif ((substr($column['True_Type'], 0, 9) == 'timestamp' || $column['True_Type'] == 'datetime' - || $column['True_Type'] == 'time' + || $column['True_Type'] == 'time') + && (strpos ($current_row[$column['Field']],"." ) === TRUE) ) { $current_row[$column['Field']] = PMA_Util::addMicroseconds( $current_row[$column['Field']] From 03e61d4f510b4cb454f4858465a025c028520d71 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 31 Jan 2014 08:12:12 -0500 Subject: [PATCH 8/8] ChangeLog entry for fix of bug #4257 Signed-off-by: Marc Delisle --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 8b320aabaf..8882773379 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ phpMyAdmin - ChangeLog - bug #4253 "New" text in navigation frame acts like a database - bug #4262 Cannot define a column with fractional seconds - bug #4265 Missing datepicker icon for DATETIME(length) +- bug #4257 Hide fractional seconds when applicable 4.1.6.0 (2014-01-26) - bug #4232 User not found after creating the user