Foswiki on GitHub is open for business! Next release meeting: Monday September 15, 1300Z

Item11155: ActionTrackerPlugin pop-up action editor hardcodes the date format, and does not use the defined formats for the site, or the web

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Closed Extension ActionTrackerPlugin  
The pop-up action editor in ActionTrackerPlugin hardcodes the date format, thus ignoring any setting of the same and forcing it to '%e %B %Y'.

To correct this, I suggest the following simple change to Format.pm

diff --git a/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/Format.pm b/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/Format.pm
index 5328808..7694a27 100644
--- a/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/Format.pm
+++ b/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/Format.pm
@@ -400,11 +400,12 @@ sub _formatFieldForEdit {
             # make sure JSCalendar is there
             eval 'use Foswiki::Contrib::JSCalendarContrib';
             unless ($@) {
+                my $dateformat = $Foswiki::cfg{JSCalendarContrib}{format} || '%e %B %Y';
                 @extras = ( id => "date_$attrname" );
                 $content = CGI::image_button(
                     -name => 'calendar',
                     -onclick =>
-                      "return showCalendar('date_$attrname','%e %B %Y')",
+                      "return showCalendar('date_$attrname','$dateformat')",
                     -src => Foswiki::Func::getPubUrlPath() . '/'
                       . $Foswiki::cfg{SystemWebName}
                       . '/JSCalendarContrib/img.gif',

Crawford, since you have set this plugin to "CoordinateWithAuthor", can you confirm that I can apply the above change to trunk?

Thanks,

-- RaulFRodriguez - 28 Sep 2011

In fact, so that a possible Web preference setting is taken into account too, the change should be:

diff --git a/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/Format.pm b/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/Format.pm
index 5328808..be30acb 100644
--- a/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/Format.pm
+++ b/ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin/Format.pm
@@ -400,11 +400,14 @@ sub _formatFieldForEdit {
             # make sure JSCalendar is there
             eval 'use Foswiki::Contrib::JSCalendarContrib';
             unless ($@) {
+                my $dateformat = Foswiki::Func::getPreferencesValue('DATEFIELDPLUGIN_DATEFORMAT') ||
+                                 $Foswiki::cfg{JSCalendarContrib}{format} ||
+                                 '%e %B %Y';
                 @extras = ( id => "date_$attrname" );
                 $content = CGI::image_button(
                     -name => 'calendar',
                     -onclick =>
-                      "return showCalendar('date_$attrname','%e %B %Y')",
+                      "return showCalendar('date_$attrname','$dateformat')",
                     -src => Foswiki::Func::getPubUrlPath() . '/'
                       . $Foswiki::cfg{SystemWebName}

-- RaulFRodriguez - 28 Sep 2011

Hi Raul,

I have never heard of the DateFieldPlugin. The standard preference for date formats is JSCALENDARCONTRIB_FORMAT. So long as you use the standard, go ahead. Oh, and please document the fact that this preference is used.

memo to self: add an API to the JSCalendarContrib to retrieve the format.

-- CrawfordCurrie - 29 Sep 2011

Thanks for you response Crawford,

Yes, right. That's JSCALENDARCONTRIB_FORMAT.

Apparently that other setting used to be in some old versions in Twiki (you created this DateFieldPlugin page to explain it wink ). I guess it is still in trunk for archival purposes (where I found it looking for examples of alternate assignments and was mislead by it).

That will teach to take the time to re-read the documentation before posting (or not to post at a late hour big grin ).

Anyway, indeed, I'll document the fact that this setting is used. That's important for anyone having customised its site JSCalendarContrib settings to see the plugin behave consistently.

-- RaulFRodriguez - 29 Sep 2011

I just checked-in the changes to trunk, including additions to the documentation of this plugin.

In order to facilitate linking from this documentation to the relevant section in JSCalendarContrib docs, I would suggest adding an anchor in the JSCalendarContrib description topic. That would be System.JSCalendarContrib#CustomizingTheAppearance and would be placed at section "Customizing the appearance of the calendar" near the end of the document.

I'll create a separate task for that, and I'll then close this Task.

-- RaulFRodriguez - 27 Oct 2011

Fine by me. Over to you.

-- CrawfordCurrie - 28 Jan 2012

Fixed in 2.4.10

-- CrawfordCurrie - 27 Feb 2013

 

ItemTemplate edit

Summary ActionTrackerPlugin pop-up action editor hardcodes the date format, and does not use the defined formats for the site, or the web
ReportedBy RaulFRodriguez
Codebase trunk
SVN Range
AppliesTo Extension
Component ActionTrackerPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins Foswikirev:12899
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
Release01x01Checkins
Topic revision: r11 - 27 Feb 2013, CrawfordCurrie
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License