date picker for custom date field
Moderators: Developer, Contributor
date picker for custom date field
Is it possible to use date picker (jscalendar) for custom field of date type?
Re: date picker for custom date field
You can write plugin for this in MantisBT 1.2.x version
Re: date picker for custom date field
The current implementation is quite weak, so I would prefer to have this in MantisBT core and not as an additional plugin. (Of course beeing able to have plugins for any kind of own dialogs is certainly a good idea)
This feature request is already know and can be followed at:
http://www.mantisbt.org/bugs/view.php?id=8957
Monitoring the issue might push a little bit developers to have a look at it.
Or even better @poooool if you could provide a patch for it.
This feature request is already know and can be followed at:
http://www.mantisbt.org/bugs/view.php?id=8957
Monitoring the issue might push a little bit developers to have a look at it.
Or even better @poooool if you could provide a patch for it.
Re: date picker for custom date field
I am not so good developer to create plugin nor patch. So I will wait until it is in core.
Thanks for replays.
Thanks for replays.
-
- Posts: 12
- Joined: 02 Nov 2010, 13:12
- Location: France
Re: date picker for custom date field
I wrote it for a company. So I can provide a patch (next week-end).
changes in Mantis core
I reuse this variable in config_inc.php
$g_use_date_picker_javascript = ON;
core/date_api.php
in function print_date_selection_set
line 211
On line 2, I think there is better solution than && "/return_dynamic_filters.php" != $_SERVER["SCRIPT_NAME"]
if (ON == config_get( 'use_date_picker_javascript' )
&& "/return_dynamic_filters.php" != $_SERVER["SCRIPT_NAME"]
) {
$p_date = is_numeric( $p_date ) ? $p_date : time();
$t_date = preg_split( '/-/', date( 'Y-m-d', $p_date ), -1, PREG_SPLIT_NO_EMPTY );
$t_date_to_display = $t_date ? $t_date[0] . "-". $t_date[1] . "-". $t_date[2] : '';
print "<input ".helper_get_tab_index()." type=\"text\" size=\"14\" id=\"$p_name\" name=\"$p_name\" size=\"20\" maxlength=\"12\" value=\"".$t_date_to_display."\" />";
date_print_calendar("trigger".$p_name);
date_finish_calendar( $p_name, "trigger".$p_name);
} else {
//current code
}
core/gpc_api.php, deux change to do
function gpc_isset_custom_field
line 174
if (ON == config_get( 'use_date_picker_javascript' )) {
return gpc_isset( $t_field_name ) ;
} else {
//current code
}
function gpc_get_custom_field
line 220
if (ON == config_get( 'use_date_picker_javascript' )) {
return strtotime( gpc_get_string( $p_var_name, time() ));
} else {
//current code there
}
It works very fine on the Mantis I set up.
changes in Mantis core
I reuse this variable in config_inc.php
$g_use_date_picker_javascript = ON;
core/date_api.php
in function print_date_selection_set
line 211
On line 2, I think there is better solution than && "/return_dynamic_filters.php" != $_SERVER["SCRIPT_NAME"]
if (ON == config_get( 'use_date_picker_javascript' )
&& "/return_dynamic_filters.php" != $_SERVER["SCRIPT_NAME"]
) {
$p_date = is_numeric( $p_date ) ? $p_date : time();
$t_date = preg_split( '/-/', date( 'Y-m-d', $p_date ), -1, PREG_SPLIT_NO_EMPTY );
$t_date_to_display = $t_date ? $t_date[0] . "-". $t_date[1] . "-". $t_date[2] : '';
print "<input ".helper_get_tab_index()." type=\"text\" size=\"14\" id=\"$p_name\" name=\"$p_name\" size=\"20\" maxlength=\"12\" value=\"".$t_date_to_display."\" />";
date_print_calendar("trigger".$p_name);
date_finish_calendar( $p_name, "trigger".$p_name);
} else {
//current code
}
core/gpc_api.php, deux change to do
function gpc_isset_custom_field
line 174
if (ON == config_get( 'use_date_picker_javascript' )) {
return gpc_isset( $t_field_name ) ;
} else {
//current code
}
function gpc_get_custom_field
line 220
if (ON == config_get( 'use_date_picker_javascript' )) {
return strtotime( gpc_get_string( $p_var_name, time() ));
} else {
//current code there
}
It works very fine on the Mantis I set up.
-
- Posts: 12
- Joined: 02 Nov 2010, 13:12
- Location: France
Re: date picker for custom date field
I have just added this in core/date_api.php
If Mantis Team is interested by this change, I can send it in a patch.
line 306
function date_finish_calendar( $p_field_name, $p_button_name ) {
if(( ON == config_get( 'dhtml_filters' ) ) && ( ON == config_get( 'use_javascript' ) ) ) {
$t_format = config_get( 'calendar_js_date_format' );
$t_date_picker_configure = config_get( 'date_picker_configure' );
echo "<script type=\"text/javascript\">\n";
echo "Calendar.setup (\n";
echo "{\n";
echo "inputField : \"" . $p_field_name . "\",\n";
echo "ifFormat : \"" . $t_format . "\", \n";
foreach ($t_date_picker_configure as $t_key => $t_value ) {
$quote = ($t_value == 'true' || $t_value == 'false' || is_numeric($t_value)) ? "" : '"';
echo "$t_key : $quote$t_value$quote,\n";
}
echo "button : \"" . $p_button_name . "\"\n";
echo "}\n";
echo ");\n";
echo "</script>\n";
}
}
You need to add following variable in config_inc.php
$g_date_picker_configure = array(
'timeFormat' => 24,
'firstDay' => 1,
'cache' => 'true',
'showsTime' => 'true',
);
you can any variable authorized in calendar, except : inputfield, ifformat and button
* inputField | the ID of an input field to store the date
* displayArea | the ID of a DIV or other element to show the date
* button | ID of a button or other element that will trigger the calendar
* eventName | event that will trigger the calendar, without the "on" prefix (default: "click")
* ifFormat | date format that will be stored in the input field
* daFormat | the date format that will be used to display the date in displayArea
* singleClick | (true/false) wether the calendar is in single click mode or not (default: true)
* firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc.
* align | alignment (default: "Br"); if you don't know what's this see the calendar documentation
* range | array with 2 elements. Default: [1900, 2999] -- the range of years available
* weekNumbers | (true/false) if it's true (default) the calendar will display week numbers
* flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID
* flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar)
* disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar
* onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay)
* onClose | function that gets called when the calendar is closed. [default]
* onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar.
* date | the date that the calendar will be initially displayed to
* showsTime | default: false; if true the calendar will include a time selector
* timeFormat | the time format; can be "12" or "24", default is "12"
* electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close
* step | configures the step of the years in drop-down boxes; default: 2
* position | configures the calendar absolute position; default: null
* cache | if "true" (but default: "false") it will reuse the same calendar object, where possible
* showOthers | if "true" (but default: "false") it will show days from other months too
Verified on my Mantis installation.
If Mantis Team is interested by this change, I can send it in a patch.
line 306
function date_finish_calendar( $p_field_name, $p_button_name ) {
if(( ON == config_get( 'dhtml_filters' ) ) && ( ON == config_get( 'use_javascript' ) ) ) {
$t_format = config_get( 'calendar_js_date_format' );
$t_date_picker_configure = config_get( 'date_picker_configure' );
echo "<script type=\"text/javascript\">\n";
echo "Calendar.setup (\n";
echo "{\n";
echo "inputField : \"" . $p_field_name . "\",\n";
echo "ifFormat : \"" . $t_format . "\", \n";
foreach ($t_date_picker_configure as $t_key => $t_value ) {
$quote = ($t_value == 'true' || $t_value == 'false' || is_numeric($t_value)) ? "" : '"';
echo "$t_key : $quote$t_value$quote,\n";
}
echo "button : \"" . $p_button_name . "\"\n";
echo "}\n";
echo ");\n";
echo "</script>\n";
}
}
You need to add following variable in config_inc.php
$g_date_picker_configure = array(
'timeFormat' => 24,
'firstDay' => 1,
'cache' => 'true',
'showsTime' => 'true',
);
you can any variable authorized in calendar, except : inputfield, ifformat and button
* inputField | the ID of an input field to store the date
* displayArea | the ID of a DIV or other element to show the date
* button | ID of a button or other element that will trigger the calendar
* eventName | event that will trigger the calendar, without the "on" prefix (default: "click")
* ifFormat | date format that will be stored in the input field
* daFormat | the date format that will be used to display the date in displayArea
* singleClick | (true/false) wether the calendar is in single click mode or not (default: true)
* firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc.
* align | alignment (default: "Br"); if you don't know what's this see the calendar documentation
* range | array with 2 elements. Default: [1900, 2999] -- the range of years available
* weekNumbers | (true/false) if it's true (default) the calendar will display week numbers
* flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID
* flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar)
* disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar
* onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay)
* onClose | function that gets called when the calendar is closed. [default]
* onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar.
* date | the date that the calendar will be initially displayed to
* showsTime | default: false; if true the calendar will include a time selector
* timeFormat | the time format; can be "12" or "24", default is "12"
* electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close
* step | configures the step of the years in drop-down boxes; default: 2
* position | configures the calendar absolute position; default: null
* cache | if "true" (but default: "false") it will reuse the same calendar object, where possible
* showOthers | if "true" (but default: "false") it will show days from other months too
Verified on my Mantis installation.
Re: date picker for custom date field
See http://docs.mantisbt.org/master/en/deve ... RIB.SUBMITphilou2024 wrote: If Mantis Team is interested by this change, I can send it in a patch.
You could add the patch as attachment at
http://www.mantisbt.org/bugs/view.php?id=8957
-
- Posts: 12
- Joined: 02 Nov 2010, 13:12
- Location: France
Re: date picker for custom date field
Done, patch is available there: http://www.mantisbt.org/bugs/view.php?id=8957
Re: date picker for custom date field
philou2024, thanks for the patch.
I am wondering that your patch is quite big.
There are a lot of changes on file config_defaults_inc.php which are not related to date field
I am wondering that your patch is quite big.
There are a lot of changes on file config_defaults_inc.php which are not related to date field
-
- Posts: 12
- Joined: 02 Nov 2010, 13:12
- Location: France
Re: date picker for custom date field
There is only 2 changes in config file:
Parameter to use calendar
array to configure calendar
And there is changes in other files.
I'll check files tomorrow or saturday
Parameter to use calendar
array to configure calendar
And there is changes in other files.
I'll check files tomorrow or saturday
-
- Posts: 12
- Joined: 02 Nov 2010, 13:12
- Location: France
Re: date picker for custom date field
I know why, I correct patch asap
Re: date picker for custom date field
Any news? I fear that this feature won't be implemented as long as the unnecessary changes are part of the patchphilou2024 wrote:I know why, I correct patch asap
Re: date picker for custom date field
Here are the actions to make this work under 1.2.10.
Just reviewed the work of Philou and took out what was not needed.
No, i did not create a patch but these instructions are pretty clear and can be moved into core very easily (which should have been done a long time ago)
Just reviewed the work of Philou and took out what was not needed.
No, i did not create a patch but these instructions are pretty clear and can be moved into core very easily (which should have been done a long time ago)
- Attachments
-
- Custom_date_field_date_picker.zip
- (1.51 KiB) Downloaded 1028 times
-
- Posts: 1
- Joined: 29 Dec 2012, 09:36
Re: date picker for custom date field
I am using custom field of type date with date picker and i want to know how to set default value to "no due date" instead of "01-01-1970", either to set empty.
Re: date picker for custom date field
Hi everybody.
I´m also using costum fields with the date picker.
Unfortunately my date is also automatically set to 01-01-1970 when it´s not filled.
It should rather be empty.
What do I have to change to disable the default date?
Thanks in advance
I´m also using costum fields with the date picker.
Unfortunately my date is also automatically set to 01-01-1970 when it´s not filled.
It should rather be empty.
What do I have to change to disable the default date?
Thanks in advance