diff --git a/ChangeLog b/ChangeLog index 577bd26024..4e1afff882 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ phpMyAdmin - ChangeLog + rfe #1479 Relations edit form for larger monitors + rfe #1475 Inline query box vertical resize + rfe #1500 [interface] Add bottom border to top menu container ++ rfe #1498 Add datepicker for 'TIME' type 4.1.7.0 (not yet released) - bug #4245 initial Browse query does not match sorting order diff --git a/js/functions.js b/js/functions.js index 1f2cdb7b00..34bc714930 100644 --- a/js/functions.js +++ b/js/functions.js @@ -194,12 +194,12 @@ function displayPasswordGenerateButton() * * @param object $this_element a jQuery object pointing to the element */ -function PMA_addDatepicker($this_element, options) -{ - var showTimeOption = false; - if ($this_element.is('.datetimefield')) { - showTimeOption = true; - } +function PMA_addDatepicker($this_element, type, options) +{ + var showTimepicker = true; + if (type=="date") { + showTimepicker = false; + } var defaultOptions = { showOn: 'button', @@ -210,7 +210,7 @@ function PMA_addDatepicker($this_element, options) showSecond: true, showMillisec: true, showMicrosec: true, - showTimepicker: showTimeOption, + showTimepicker: showTimepicker, showButtonPanel: false, dateFormat: 'yy-mm-dd', // yy means year with four digits timeFormat: 'HH:mm:ss.lc', @@ -232,10 +232,14 @@ function PMA_addDatepicker($this_element, options) $this_element.data('comes_from', ''); } }; - if (showTimeOption || (typeof(options) != 'undefined' && options.showTimepicker)) { + if (type == "datetime") { $this_element.datetimepicker($.extend(defaultOptions, options)); - } else { - $this_element.datepicker($.extend(defaultOptions, options)); + } + else if (type == "date") { + $this_element.datetimepicker($.extend(defaultOptions, options)); + } + else if (type == "time") { + $this_element.timepicker($.extend(defaultOptions, options)); } } @@ -857,21 +861,21 @@ function insertValueQuery() */ function addDateTimePicker() { if ($.timepicker !== undefined) { - $('input.datefield, input.datetimefield').each(function () { + $('input.timefield, input.datefield, input.datetimefield').each(function () { - no_decimals = $(this).parent().data('decimals'); + no_decimals = $(this).parent().attr('data-decimals'); var showMillisec = false; var showMicrosec = false; var timeFormat = 'HH:mm:ss'; // check for decimal places of seconds - if (($(this).parent().data('decimals') > 0) && ($(this).parent().data('type').indexOf('time') != -1)){ + if (($(this).parent().attr('data-decimals') > 0) && ($(this).parent().attr('data-type').indexOf('time') != -1)){ showMillisec = true; timeFormat = 'HH:mm:ss.lc'; - if ($(this).parent().data('decimals') > 3) { + if ($(this).parent().attr('data-decimals') > 3) { showMicrosec = true; } } - PMA_addDatepicker($(this), { + PMA_addDatepicker($(this), $(this).parent().attr('data-type'), { showMillisec: showMillisec, showMicrosec: showMicrosec, timeFormat: timeFormat, diff --git a/js/makegrid.js b/js/makegrid.js index fa9a90a2ae..0f9c417aaf 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -630,12 +630,12 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi : $this_field.data('value'); //remove decimal places if column type not supported - if (($this_field.data('decimals') == 0) && ( $this_field.data('type').indexOf('time') != -1)){ + if (($this_field.attr('data-decimals') == 0) && ( $this_field.attr('data-type').indexOf('time') != -1)){ new_html = new_html.substring(0, new_html.indexOf('.')); } //remove addtional decimal places - if (($this_field.data('decimals') > 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.attr('data-decimals') > 0) && ( $this_field.attr('data-type').indexOf('time') != -1)){ + new_html = new_html.substring(0, new_html.length - (6 - $this_field.attr('data-decimals'))); } if ($this_field.is('.truncated')) { if (new_html.length > g.maxTruncatedLen) { @@ -971,99 +971,47 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $editArea.show(); } g.isEditCellTextEditable = true; - } else if ($td.is('.datefield, .datetimefield, .timestampfield')) { + } else if ($td.is('.timefield, .datefield, .datetimefield, .timestampfield')) { var $input_field = $(g.cEdit).find('.edit_box'); // remember current datetime value in $input_field, if it is not null var is_null = $td.is('.null'); - var current_datetime_value = !is_null ? $input_field.val() : ''; - - var showTimeOption = true; - if ($td.is('.datefield')) { - showTimeOption = false; - } + var current_datetime_value = !is_null ? $input_field.val() : ''; 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)){ + if (($td.attr('data-decimals') > 0) && ($td.attr('data-type').indexOf('time') != -1)){ showMillisec = true; timeFormat = 'HH:mm:ss.lc'; - if ($td.data('decimals') > 3) { + if ($td.attr('data-decimals') > 3) { showMicrosec = true; } } - PMA_addDatepicker($editArea, { + // add datetime picker + PMA_addDatepicker($input_field, $td.attr('data-type'), { showMillisec: showMillisec, showMicrosec: showMicrosec, - timeFormat: timeFormat, - altField: $input_field, - showTimepicker: showTimeOption, - onSelect: function (dateText, inst) { - // remove null checkbox if it exists - $(g.cEdit).find('.null_div input[type=checkbox]').prop('checked', false); - } + timeFormat: timeFormat }); + $input_field.datepicker("show"); + + var edit_area_top = $('#ui-datepicker-div').height()+32; + $('.edit_area').css({'top' : edit_area_top+'px', 'position': 'absolute'}); + + if(is_null){ + $('.edit_area').hide(); + } + // cancel any click on the datepicker element $editArea.find('> *').click(function (e) { e.stopPropagation(); }); - // force to restore modified $input_field value after adding datepicker - // (after adding a datepicker, the input field doesn't display the time anymore, only the date) - if (is_null - || current_datetime_value == '0000-00-00' - || current_datetime_value == '0000-00-00 00:00:00.000000' - ) { - $input_field.val(current_datetime_value); - } else { - var date = new Date( - current_datetime_value.substring(0, 4), - parseInt(current_datetime_value.substring(5, 7)) - 1, - parseInt(current_datetime_value.substring(8, 10)) - ); - 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); - 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); - } - 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); - } - $editArea.append('
' + g.cellEditHint + '
'); - - // remove {cursor: 'pointer'} added inside - // jquery-ui-timepicker-addon.js - $input_field.css('cursor', ''); - // make the cell editable, so one can can bypass the timepicker - // and enter date/time value manually - g.isEditCellTextEditable = true; } else { g.isEditCellTextEditable = true; // only append edit area hint if there is a null checkbox @@ -1074,7 +1022,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi if ($(g.cEdit).offset().left + $editArea.outerWidth() > $(document.body).width()) { $editArea.addClass('edit_area_right'); } - if ($editArea.children().length > 0) { + if ($editArea.children().length > 0 && !is_null) { $editArea.show(); } } @@ -1087,8 +1035,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi if (g.isSaving) { return; } - g.isSaving = true; - + g.isSaving = true; /** * @var relation_fields Array containing the name/value pairs of relational fields */ @@ -1678,7 +1625,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi // adjust g.cEdit g.cEdit.className = 'cEdit'; - $(g.cEdit).html('
'); + $(g.cEdit).html('
'); $(g.cEdit).hide(); // assign cell editing hint @@ -1761,8 +1708,8 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi } }); $('html').click(function (e) { - // hide edit cell if the click is not from g.cEdit - if ($(e.target).parents().index(g.cEdit) == -1) { + // hide edit cell if the click is not from the datepicker + if ($(e.target).parents().index($('#ui-datepicker-div')) == -1) { g.hideEditCell(); } }).keydown(function (e) { diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 8f8545a922..cca2d4fa80 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -2374,7 +2374,7 @@ class PMA_DisplayResults private function _buildNullDisplay($class, $condition_field, $meta, $align = '') { // the null class is needed for grid editing - return 'decimals.'" data-type="'.$meta->type.'" class="' . $this->_addClass( $class, $condition_field, $meta, '' ) @@ -3618,9 +3618,14 @@ class PMA_DisplayResults || ($type == self::DATETIME_FIELD) ) { $field_type_class = 'datetimefield'; - } else if ($type == self::DATE_FIELD) { + } + else if ($type == self::DATE_FIELD) { $field_type_class = 'datefield'; - } else { + } + else if ($type == self::TIME_FIELD) { + $field_type_class = 'timefield'; + } + else { $field_type_class = ''; } return $field_type_class; diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 22a84549cd..80e79a41c5 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -1173,7 +1173,11 @@ function PMA_getHTMLinput($column, $column_name_appendix, $special_chars, // verify True_Type which does not contain the parentheses and length if ($column['True_Type'] === 'date') { $the_class .= ' datefield'; - } elseif ($column['True_Type'] === 'datetime' + } + else if ($column['True_Type'] === 'time') { + $the_class .= ' timefield'; + } + else if ($column['True_Type'] === 'datetime' || $column['True_Type'] === 'timestamp' ) { $the_class .= ' datetimefield'; @@ -1752,10 +1756,9 @@ function PMA_getSpecialCharsAndBackupFieldForInsertingMode( if ($column['True_Type'] == 'bit') { $special_chars = PMA_Util::convertBitDefaultValue($column['Default']); - } elseif ((substr($column['True_Type'], 0, 9) == 'timestamp' + } elseif (substr($column['True_Type'], 0, 9) == 'timestamp' || $column['True_Type'] == 'datetime' - || $column['True_Type'] == 'time') - && strpos($column['Default'], '.') === true + || $column['True_Type'] == 'time' ) { $special_chars = PMA_Util::addMicroseconds($column['Default']); } else { diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php index bfd9137a04..3ad0567dc2 100644 --- a/themes/original/css/common.css.php +++ b/themes/original/css/common.css.php @@ -2295,7 +2295,7 @@ fieldset .disabled-field td { .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; } .ui-timepicker-div dl { text-align: left; } .ui-timepicker-div dl dt { height: 25px; } -.ui-timepicker-div dl dd { margin: -25px 0 10px 65px; } +.ui-timepicker-div dl dd { margin: -25px 0 10px 85px; } .ui-timepicker-div td { font-size: 90%; } input.btn { diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php index fae101970b..c5e3ac20a9 100644 --- a/themes/pmahomme/css/common.css.php +++ b/themes/pmahomme/css/common.css.php @@ -2729,7 +2729,7 @@ fieldset .disabled-field td { padding: 0; } -.cEdit .edit_area { +.cEdit .edit_area { background: #FFF; border: 1px solid #999; min-width: 10em; @@ -2787,7 +2787,7 @@ fieldset .disabled-field td { .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; } .ui-timepicker-div dl { text-align: ; } .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; } -.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; } +.ui-timepicker-div dl dd { margin: 0 10px 10px 85px; } .ui-timepicker-div td { font-size: 90%; } .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; } .ui-timepicker-rtl { direction: rtl; }