Skip to content

Commit

Permalink
Revert "Replace date selection dropdown boxes with datetime picker"
Browse files Browse the repository at this point in the history
This reverts commit 1721c39.
  • Loading branch information
cproensa authored and dregad committed Apr 16, 2017
1 parent 0709146 commit daa6d90
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 73 deletions.
2 changes: 1 addition & 1 deletion core/date_api.php
Expand Up @@ -243,7 +243,7 @@ function print_date_selection_set( $p_name, $p_format, $p_date = 0, $p_default_d

$t_disable = '';
if( $p_default_disable == true ) {
$t_disable = ' readonly="readonly"';
$t_disable = ' disabled="disabled"';
}
$t_blank_line = '';
if( $p_allow_blank == true ) {
Expand Down
4 changes: 0 additions & 4 deletions core/filter_constants_inc.php
Expand Up @@ -40,8 +40,6 @@
define( 'FILTER_PROPERTY_DATE_SUBMITTED_END_MONTH', 'end_month' );
define( 'FILTER_PROPERTY_DATE_SUBMITTED_END_YEAR', 'end_year' );
define( 'FILTER_PROPERTY_FILTER_BY_DATE_SUBMITTED', 'filter_by_date' ); #do_filter_by_date
define( 'FILTER_PROPERTY_FILTER_BY_START_DATE_SUBMITTED', 'filter_by_start_date' );
define( 'FILTER_PROPERTY_FILTER_BY_END_DATE_SUBMITTED', 'filter_by_end_date' );

define( 'FILTER_PROPERTY_LAST_UPDATED_START_DAY', 'last_updated_start_day' );
define( 'FILTER_PROPERTY_LAST_UPDATED_START_MONTH', 'last_updated_start_month' );
Expand All @@ -50,8 +48,6 @@
define( 'FILTER_PROPERTY_LAST_UPDATED_END_MONTH', 'last_updated_end_month' );
define( 'FILTER_PROPERTY_LAST_UPDATED_END_YEAR', 'last_updated_end_year' );
define( 'FILTER_PROPERTY_FILTER_BY_LAST_UPDATED_DATE', 'filter_by_last_updated_date' ); #do_filter_by_last_updated_date
define( 'FILTER_PROPERTY_FILTER_BY_LAST_UPDATED_START_DATE', 'filter_by_last_updated_start_date' );
define( 'FILTER_PROPERTY_FILTER_BY_LAST_UPDATED_END_DATE', 'filter_by_last_updated_end_date' );

define( 'FILTER_PROPERTY_RELATIONSHIP_TYPE', 'relationship_type' );
define( 'FILTER_PROPERTY_RELATIONSHIP_BUG', 'relationship_bug' );
Expand Down
118 changes: 83 additions & 35 deletions core/filter_form_api.php
Expand Up @@ -1307,7 +1307,7 @@ function print_filter_do_filter_by_date( $p_hide_checkbox = false, array $p_filt
<?php

if( ON != $p_filter[FILTER_PROPERTY_FILTER_BY_DATE_SUBMITTED] ) {
$t_menu_readonly = ' readonly="readonly" ';
$t_menu_disabled = ' disabled="disabled" ';
}
}
?>
Expand All @@ -1318,14 +1318,26 @@ function print_filter_do_filter_by_date( $p_hide_checkbox = false, array $p_filt
<?php echo lang_get( 'start_date_label' )?>
</td>
<td class="nowrap">
<?php
echo '<input type="text" name="' . FILTER_PROPERTY_FILTER_BY_START_DATE_SUBMITTED . '" ' .
' class="datetimepicker input-xs" ' . $t_menu_readonly .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
?>
<?php
$t_chars = preg_split( '//', config_get( 'short_date_format' ), -1, PREG_SPLIT_NO_EMPTY );
foreach( $t_chars as $t_char ) {
if( strcasecmp( $t_char, 'M' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_DATE_SUBMITTED_START_MONTH, '"', $t_menu_disabled, '>';
print_month_option_list( $p_filter[FILTER_PROPERTY_DATE_SUBMITTED_START_MONTH] );
print "</select>\n";
}
if( strcasecmp( $t_char, 'D' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_DATE_SUBMITTED_START_DAY, '"', $t_menu_disabled, '>';
print_day_option_list( $p_filter[FILTER_PROPERTY_DATE_SUBMITTED_START_DAY] );
print "</select>\n";
}
if( strcasecmp( $t_char, 'Y' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_DATE_SUBMITTED_START_YEAR, '"', $t_menu_disabled, '>';
print_year_option_list( $p_filter[FILTER_PROPERTY_DATE_SUBMITTED_START_YEAR] );
print "</select>\n";
}
}
?>
</td>
</tr>
<!-- End date -->
Expand All @@ -1334,14 +1346,26 @@ function print_filter_do_filter_by_date( $p_hide_checkbox = false, array $p_filt
<?php echo lang_get( 'end_date_label' )?>
</td>
<td>
<?php
echo '<input type="text" name="' . FILTER_PROPERTY_FILTER_BY_END_DATE_SUBMITTED . '" ' .
' class="datetimepicker input-xs" ' . $t_menu_readonly .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
?>
<?php
$t_chars = preg_split( '//', config_get( 'short_date_format' ), -1, PREG_SPLIT_NO_EMPTY );
foreach( $t_chars as $t_char ) {
if( strcasecmp( $t_char, 'M' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_DATE_SUBMITTED_END_MONTH, '"', $t_menu_disabled, '>';
print_month_option_list( $p_filter[FILTER_PROPERTY_DATE_SUBMITTED_END_MONTH] );
print "</select>\n";
}
if( strcasecmp( $t_char, 'D' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_DATE_SUBMITTED_END_DAY, '"', $t_menu_disabled, '>';
print_day_option_list( $p_filter[FILTER_PROPERTY_DATE_SUBMITTED_END_DAY] );
print "</select>\n";
}
if( strcasecmp( $t_char, 'Y' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_DATE_SUBMITTED_END_YEAR, '"', $t_menu_disabled, '>';
print_year_option_list( $p_filter[FILTER_PROPERTY_DATE_SUBMITTED_END_YEAR] );
print "</select>\n";
}
}
?>
</td>
</tr>
</table>
Expand Down Expand Up @@ -1418,7 +1442,7 @@ function print_filter_do_filter_by_last_updated_date( $p_hide_checkbox = false,
?>
<table cellspacing="0" cellpadding="0">
<?php
$t_menu_readonly = '';
$t_menu_disabled = '';
if( !$p_hide_checkbox ) {
?>
<tr>
Expand All @@ -1435,7 +1459,7 @@ function print_filter_do_filter_by_last_updated_date( $p_hide_checkbox = false,
<?php

if( ON != $p_filter[FILTER_PROPERTY_FILTER_BY_LAST_UPDATED_DATE] ) {
$t_menu_readonly = ' readonly="readonly" ';
$t_menu_disabled = ' disabled="disabled" ';
}
}
?>
Expand All @@ -1446,14 +1470,26 @@ function print_filter_do_filter_by_last_updated_date( $p_hide_checkbox = false,
<?php echo lang_get( 'start_date_label' )?>
</td>
<td class="nowrap">
<?php
echo '<input type="text" name="' . FILTER_PROPERTY_FILTER_BY_LAST_UPDATED_START_DATE . '" ' .
' class="datetimepicker input-xs" ' . $t_menu_readonly .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
?>
<?php
$t_chars = preg_split( '//', config_get( 'short_date_format' ), -1, PREG_SPLIT_NO_EMPTY );
foreach( $t_chars as $t_char ) {
if( strcasecmp( $t_char, 'M' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_LAST_UPDATED_START_MONTH, '"', $t_menu_disabled, '>';
print_month_option_list( $p_filter[FILTER_PROPERTY_LAST_UPDATED_START_MONTH] );
print "</select>\n";
}
if( strcasecmp( $t_char, 'D' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_LAST_UPDATED_START_DAY, '"', $t_menu_disabled, '>';
print_day_option_list( $p_filter[FILTER_PROPERTY_LAST_UPDATED_START_DAY] );
print "</select>\n";
}
if( strcasecmp( $t_char, 'Y' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_LAST_UPDATED_START_YEAR, '"', $t_menu_disabled, '>';
print_year_option_list( $p_filter[FILTER_PROPERTY_LAST_UPDATED_START_YEAR] );
print "</select>\n";
}
}
?>
</td>
</tr>
<!-- End date -->
Expand All @@ -1462,14 +1498,26 @@ function print_filter_do_filter_by_last_updated_date( $p_hide_checkbox = false,
<?php echo lang_get( 'end_date_label' )?>
</td>
<td>
<?php
echo '<input type="text" name="' . FILTER_PROPERTY_FILTER_BY_LAST_UPDATED_END_DATE . '" ' .
' class="datetimepicker input-xs" ' . $t_menu_readonly .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
?>
<?php
$t_chars = preg_split( '//', config_get( 'short_date_format' ), -1, PREG_SPLIT_NO_EMPTY );
foreach( $t_chars as $t_char ) {
if( strcasecmp( $t_char, 'M' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_LAST_UPDATED_END_MONTH, '"', $t_menu_disabled, '>';
print_month_option_list( $p_filter[FILTER_PROPERTY_LAST_UPDATED_END_MONTH] );
print "</select>\n";
}
if( strcasecmp( $t_char, 'D' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_LAST_UPDATED_END_DAY, '"', $t_menu_disabled, '>';
print_day_option_list( $p_filter[FILTER_PROPERTY_LAST_UPDATED_END_DAY] );
print "</select>\n";
}
if( strcasecmp( $t_char, 'Y' ) == 0 ) {
echo '<select class="input-xs" name="', FILTER_PROPERTY_LAST_UPDATED_END_YEAR, '"', $t_menu_disabled, '>';
print_year_option_list( $p_filter[FILTER_PROPERTY_LAST_UPDATED_END_YEAR] );
print "</select>\n";
}
}
?>
</td>
</tr>
</table>
Expand Down
58 changes: 25 additions & 33 deletions js/common.js
Expand Up @@ -136,9 +136,6 @@ $(document).ready( function() {
context: $('#' + targetID),
success: function(html) {
$(this).html(html);
$(this).find('input[type=text].datetimepicker').each(function(index, element) {
enableDatTimePicker(this);
});
},
error: function(obj,status,error) {
$(this).html('<span class="error-msg">' + status + ': ' + error + '</span>');
Expand Down Expand Up @@ -228,7 +225,24 @@ $(document).ready( function() {
});

$('input[type=text].datetimepicker').each(function(index, element) {
enableDatTimePicker(this);
$(this).datetimepicker({
locale: $(this).data('picker-locale'),
format: $(this).data('picker-format'),
useCurrent: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-arrows ',
clear: 'fa fa-trash',
close: 'fa fa-times'
}
}).next().on(ace.click_event, function() {
$(this).prev().focus();
});
});

if( $( ".dropzone-form" ).length ) {
Expand Down Expand Up @@ -268,32 +282,32 @@ $(document).ready( function() {
$(document).on('change', '.js_switch_date_inputs_trigger', function() {
$(this).closest('table')
.find('select')
.prop('readonly', !$(this).prop('checked'));
.prop('disabled', !$(this).prop('checked'));
});

/* Handle custom field of date type */
$(document).on('change', 'select[name^=custom_field_][name$=_control]', function() {
var table = $(this).closest('table');
switch(this.value) {
case '2': // between
$(table).find("input[name*=_start_date]").prop('readonly', false);
$(table).find("input[name*=_end_date]").prop('readonly', false);
$(table).find("input[name*=_start_date]").prop('disabled', false);
$(table).find("input[name*=_end_date]").prop('disabled', false);
break;

case '3': // on or before
case '4': // before
case '5': // on
case '6': // after
case '7': // on or after
$(table).find("input[name*=_start_date]").prop('readonly', false);
$(table).find("input[name*=_end_date]").prop('readonly', true);
$(table).find("input[name*=_start_date]").prop('disabled', false);
$(table).find("input[name*=_end_date]").prop('disabled', true);
break;

case '0': // any
case '1': // none
default:
$(table).find("input[name*=_start_date]").prop('readonly', true);
$(table).find("input[name*=_end_date]").prop('readonly', true);
$(table).find("input[name*=_start_date]").prop('disabled', true);
$(table).find("input[name*=_end_date]").prop('disabled', true);
break;
}
});
Expand Down Expand Up @@ -455,28 +469,6 @@ function toggleDisplay(idTag)
setDisplay( idTag, (document.getElementById(idTag).style.display == 'none')?1:0 );
}

// Datetime picker handler
function enableDatTimePicker( p_element ) {
$(p_element).datetimepicker({
locale: $(p_element).data('picker-locale'),
format: $(p_element).data('picker-format'),
useCurrent: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-arrows ',
clear: 'fa fa-trash',
close: 'fa fa-times'
}
}).next().on(ace.click_event, function() {
$(this).prev().focus();
});
}

// Dropzone handler
Dropzone.autoDiscover = false;
function enableDropzone( classPrefix, autoUpload ) {
Expand Down

0 comments on commit daa6d90

Please sign in to comment.