Skip to content

Commit

Permalink
Item9246: more debugging before release.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/FullCalendarPlugin@8457 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
DavidPatterson authored and DavidPatterson committed Aug 11, 2010
1 parent decc6fe commit 3110511
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 43 deletions.
8 changes: 5 additions & 3 deletions data/System/FullCalendarEventTemplate.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
%META:TOPICINFO{author="ProjectContributor" date="1275395213" format="1.1" version="1.1"}%
%META:TOPICPARENT{name="FullCalendarPlugin"}%
<verbatim>
%TMPL:DEF{apptUserList}%<select multiple size="5" id="appt_users" name="users" class="userlist urlParam" resetmultiple="5">
%SEARCH{"*" nonoise="on" topic="%USERGROUP%" web="%USERSWEB%" format="$percntFORMATLIST{$quot$pattern(.*[\t\s]*\* Set GROUP = (.*?)[\r\n].*)$quot split=$quot[\s,]$quot separator=$quot $quot format=$quot<option value=$dollarquot$dollar1$dollarquot>$dollarpercntSPACEOUT{$dollar1}$dollarpercnt</option>$quot}$percnt"}%
</select>%TMPL:END%

%TMPL:DEF{userFormElements}%
<div id="eventCat" class="foswikiFormStep">
*Post an Event:* <span class="mission"><input type="radio" name="category" value="mission" class="mission urlParam" checked="checked" /> Mission &nbsp;</span><span class="meeting"><input type="radio" name="category" value="meeting" class="meeting urlParam" /> Meeting &nbsp;</span><span class="leave"><input type="radio" name="category" value="leave" class="leave urlParam" /> Leave &nbsp;</span><span class="milestone"><input type="radio" name="category" value="milestone" class="milestone urlParam" /> Milestone</span><br>
Expand All @@ -16,9 +20,7 @@
cols="50" rows="4" class="urlParam leave" /></textarea>
</div>
<div id="appt_attendees">
<label for="users">Attendees:</label><br /> <select multiple size="5" id="appt_users" name="users" class="userlist urlParam">
%SEARCH{"*" nonoise="on" topic="%USERGROUP%" web="%USERSWEB%" format="$percntFORMATLIST{$quot$pattern(.*[\t\s]*\* Set GROUP = (.*?)[\r\n].*)$quot split=$quot[\s,]$quot separator=$quot $quot format=$quot<option value=$dollarquot$dollar1$dollarquot>$dollarpercntSPACEOUT{$dollar1}$dollarpercnt</option>$quot}$percnt"}%
</select>
<label for="users">Attendees:</label><br /> %TMPL:P{apptUserList}%
</div>
</div>
%TMPL:END%
Expand Down
32 changes: 26 additions & 6 deletions data/System/FullCalendarPlugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ As well as one-off events, repeating events can be created - daily, weekly, mont
---++ The FULLCALENDAR macro
You can have multiple calendars per page and the macro can be called with or without parameters.
|*Parameter*|*Description*|*Default*|
|"..." or calendartopic="..."|This is the topic where created events will be stored and where they will be searched for when displaying events. The format is "[&lt;web&gt;.]&lt;topic&gt;".|WebCalendar|
|reltopic="..."|All objects managed by the ObjectPlugin _can_ have a reltopic parameter that points to a related &lt;web&gt;.&lt;topic&gt;, this is so that a single topic can act as the cache for all objects with the aim of helping performance. The !FullCalendarPlugin uses this feature.|If the current topic matches the specification of the calendartopic, then there is no specified reltopic. Else, reltopic is the current topic.|
|viewall="..."|1 or 0. Depending on the setting of reltopic, all events stored in the calendartopic can be viewed or just the ones that match the reltopic setting.||

|"..." or calendartopic="..."|Optional. This is the topic where created events will be stored and where they will be searched for when displaying events. The format is "[&lt;web&gt;.]&lt;topic&gt;".|WebCalendar|
|reltopic="..."|Optional. All objects managed by the ObjectPlugin _can_ have a reltopic parameter that points to a related &lt;web&gt;.&lt;topic&gt;, this is so that a single topic can act as the cache for all objects with the aim of helping performance. The !FullCalendarPlugin uses this feature.|If the current topic matches the specification of the calendartopic, then there is no specified reltopic. Else, reltopic is the current topic.|
|viewall="..."|Optional. 1 or 0. Depending on the setting of reltopic, all events stored in the calendartopic can be viewed or just the ones that match the reltopic setting.| |

---++ The Calendar Event Object
The event attributes are defined in the EventObject topic. The default definition is in the =%<nop>SYSTEMWEB%=, but can be overridden by a new !EventObject in the =%<nop>USERSWEB%= and finally by one defined in the current web.
Expand All @@ -31,12 +30,30 @@ Just click on a day in the calendar to create a new event via the input form. Cl
* Change all instances (Update the original event record)
* Change all instances from this point onwards (Create a new event record)

*Note* that all newly created events will be done so with the matching reltopic setting.
*Note* that all newly created events will be done so with the matching =reltopic= setting.

---++ Other Event Sources
All Foswiki Macros defined in the =calendartopic= topic are expanded. If they produce suitably formatted event records, these are then included in the displayed event set. *Note that a dynamic search could have a significant impact on performance when browsing the calendar.* The format should be as follows:
<verbatim>
%OBJECT{...}%<description>%ENDOBJECT%
</verbatim>
|*Parameter* |*Description* |
|type="event" |Required to be recognised as an event object. |
|uid="..."|Required. A unique ID of the event or event group.|
|category="external"|Required as these events will not be editable.|
|allDay="..."|Required. 0 or 1. All day event or not.|
|durationDays="..."|Required. The number of days the event lasts for. Starts at 0.|
|startDate="..."|Required. ISO8601 date format, YYYY-MM-DD.|
|startTime="..."|Required. ISO8601 time format, HH:MM:SS.|
|endTime="..."|Required. ISO8601 time format, HH:MM:SS.|
|title="..."|Required.|
|url="..."|Optional. A URL to launch in a new tab/window if the event is clicked on the calendar.|
|eventSource="..."|Optional. A text string defining the source of the event.|

---++ Customisation
The EventObject and FullCalendarEventTemplate topics are provided as the default installation. View WebCalendar to see the result. As indicated above, you can create your own EventObject with attributes relevant to your installation and in UserCalEventTemplate you can customise the =userFormElements= TMPL to match your new event object.

%X% *Note, the default FullCalendarEventTemplate expects the =%USERGROUP%= variable to be set to a Group topic that gets parsed to provide a multi-select list of attendees. You can, off course, change this to be a free text field.*
%X% *Note, the default FullCalendarEventTemplate expects the =%USERGROUP%= variable to be set to a Group topic that gets parsed to provide a multi-select list of attendees. You can, off course, change this to be a free text field with auto-complete.*

---++ Future Improvements

Expand All @@ -49,6 +66,9 @@ Currently only one event form is ever loaded per page so if you load different c
---+++ User Specific Calendars
Each user can have their own calendar on which they can view the events of other calendars they are subscribed to.

---+++ Agenda List View
The events displayed on the calendar will also be displayed in a chronological list.

---+ Plugin Installation Instructions

%$INSTALL_INSTRUCTIONS%
Expand Down
16 changes: 9 additions & 7 deletions lib/Foswiki/Plugins/FullCalendarPlugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ sub _handleFullCalendar {

my $calendartopic = $attrs->{_DEFAULT} || $attrs->{calendartopic} || 'WebCalendar';
$calendartopic =~ s/\s*//;
my $reltopic = $attrs->{reltopic} || $topic eq $calendartopic ? '' : $topic;
my ($cw, $ct) = Foswiki::Func::normalizeWebTopicName($web, $calendartopic);
$calendartopic = "$cw.$ct";
my $reltopic = $attrs->{reltopic} || $topic;
my ($rw, $rt) = Foswiki::Func::normalizeWebTopicName($web, $reltopic);
$reltopic = "$rw.$rt" eq $calendartopic ? '' : "$rw.$rt";
my $viewall = $attrs->{viewall} || '';
my $templates = Foswiki::Func::loadTemplate( 'FullCalendarEvent' );
my $fcpCSS = Foswiki::Func::expandTemplate( 'fcpCSS' );
Expand All @@ -70,15 +74,13 @@ sub _handleFullCalendar {
my $calendar = <<"HERE";
<noautolink>
%ADDTOZONE{"head" requires="JQUERYPLUGIN::THEME" text="$fcpCSS"}%
<div id="calendar$rand"></div>
%ADDTOZONE{"body" requires="HIJAXPLUGIN_JS" text="
$fcpJS
<div id="calendar$rand" class="fcp_calendar"></div>
%ADDTOZONE{"body" requires="HIJAXPLUGIN_JS" text="$fcpJS
<script type='text/javascript'>
jQuery(function(){
foswiki.FullCalendar.init('#calendar$rand','$calendartopic','$reltopic','$viewall');
});
</script>
"}%
</script>"}%
</noautolink>
HERE
return $calendar;
Expand Down Expand Up @@ -176,7 +178,7 @@ sub _dateRangeSearch {
my $end = $query->param('end');
my $reltopic = $query->param('reltopic') || '';
my $calendartopic = $query->param('calendartopic');
($web, $topic) = Foswiki::Func::normalizeWebTopicName('', $calendartopic);
($web, $topic) = Foswiki::Func::normalizeWebTopicName($web, $calendartopic);
# writeDebug("$start $end");
$start = Foswiki::Time::formatTime($start, 'iso');
$end = Foswiki::Time::formatTime($end, 'iso');
Expand Down
2 changes: 2 additions & 0 deletions lib/Foswiki/Plugins/FullCalendarPlugin/Event.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ sub withinRange {
sub setFullCalendarAttrs {
my $this = shift;
$this->{id} = $this->{uid};
$this->{category} ||= 'external';
$this->{className} = $this->{category};
$this->{editable} = 0 if $this->{category} eq 'external';
$this->{allDay} += 0;
$this->{title} ||= 'no title'; # one of the required fields in an FC Event Object
}
Expand Down
12 changes: 4 additions & 8 deletions lib/Foswiki/Plugins/FullCalendarPlugin/EventSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,24 @@ require Foswiki::Plugins::ObjectPlugin;
# }

sub load {
my ($web, $topic) = @_;
my ($web, $topic, $reltopic) = @_;
my $setClass = 'Foswiki::Plugins::FullCalendarPlugin::EventSet';
my $objectClass = 'Foswiki::Plugins::FullCalendarPlugin::Event';
return Foswiki::Plugins::ObjectPlugin::ObjectSet::load(
$web, $topic, undef, 'VIEW', 0, 0, $setClass, $objectClass );
$web, $topic, undef, 'VIEW', 1, 0, $setClass, $objectClass, $reltopic );
}

sub dateRangeSearch {
my ( $web, $topic, $start, $end, $reltopic ) = @_;

my $chosen = new Foswiki::Plugins::FullCalendarPlugin::EventSet();

my $es = load($web, $topic);
my $es = load($web, $topic, $reltopic);
# Foswiki::Func::writeDebug(Dumper($es));
foreach my $event ( @{$es->{OBJECTS}} ) {
# Foswiki::Func::writeDebug(ref($event));
if ( ref($event) && $event->withinRange( $start, $end ) ) {
if ($reltopic) {
$chosen->add( $event ) if ($event->{reltopic} && $event->{reltopic} eq $reltopic);
} else {
$chosen->add( $event );
}
$chosen->add( $event );
}
}

Expand Down
10 changes: 5 additions & 5 deletions pub/System/FullCalendarPlugin/fcp.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
width:5em;
text-align:right;
}
#calendar .action a {
.fcp_calendar .action a {
background-color:red;
}
#calendar .meeting a, #eventCat .meeting {
.fcp_calendar .meeting a, #eventCat .meeting {
background-color:blue;
color:#fff;
}
#calendar .mission a, #eventCat .mission {
.fcp_calendar .mission a, #eventCat .mission {
background-color:green;
color:#fff;
}
#calendar .leave a, #eventCat .leave {
.fcp_calendar .leave a, #eventCat .leave {
background-color:yellow;
color:#000;
}
#calendar .milestone a, #eventCat .milestone {
.fcp_calendar .milestone a, #eventCat .milestone {
background-color:#000;
color:#fff;
}
Expand Down
54 changes: 40 additions & 14 deletions pub/System/FullCalendarPlugin/fcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function initForm(html) {
$('#recur_data').hide();
$recur.attr('checked',false);
default:
$("#appt_users").attr({'multiple':true,'size':5});
resetUserList();
$('#appt_attendees').find("label[for='users']").text("Attendees:");
break;
}
Expand Down Expand Up @@ -162,15 +162,14 @@ function cancelForm($form) {
$form.find('input[id^=fcp_]').val('');
$('#recur_data').find('.urlParam').removeClass('urlParam');
$('#appt_form_cancel').unbind('click.revert');
$form.removeData('reltopic');
$('#fcp_reltopic').val('');
resetForm();
resetUserList();
}
function resetForm() {
$("#recur_data").find('.appt_recur_form').andSelf().hide();
$("#appt_recur").attr("checked",false);

$("#appt_users").attr({'multiple':true,'size':5});

$(".fcp_timeperiod").show();
$("#appt_allDay").attr("checked",false);

Expand All @@ -180,14 +179,22 @@ function resetForm() {
$('#calEventUpdate').hide();
$('#recur_event_change').hide();
}
function resetUserList() {
$("#appt_users").each(function(){
if ($(this).attr('resetmultiple')) {
var size = $(this).attr('resetmultiple');
$(this).attr({'multiple':true,'size':size});
}
});
}
function setAllDay($allday) {
$allday.attr('checked',true);
$('#newCalEvent .fcp_timeperiod').hide();
}
function getEvent(event,func) {
var startSecs = Math.floor(event.start.getTime()/1000);
var d = new Date();
var tzoffset = -d.getTimezoneOffset() * 60; // messy handling of local tz, is there better?
var tzoffset = -d.getTimezoneOffset() * 60; // ugly handling of local tz, is there better?
startSecs += tzoffset;
var endSecs = startSecs + (60*60*24) + 1; // + 1 day & 1 sec
foswiki.HijaxPlugin.serverAction({
Expand Down Expand Up @@ -337,7 +344,7 @@ loadForm : function(event) {
$('#appt_desc').val(event.text);
$('#appt_users').val(event.users);
var dateformat = 'd MMM yyyy-HH:mm:ss';
var dateStr = $.fullCalendar.formatDate(event.start, dateformat)
var dateStr = $.fullCalendar.formatDate(event.start, dateformat);
var dateArray = dateStr.split('-');
$startDate = $('#appt_startDate').val(dateArray[0]);
$('#appt_startTime').val(dateArray[1]);
Expand All @@ -352,7 +359,7 @@ loadForm : function(event) {
$('#fcp_uid').val(event.uid);
var topic = event.web+'.'+event.topic;
$('#fcp_topic').val(topic);
$('#fcp_reltopic').val($form.data('reltopic'));
$('#fcp_reltopic').val(event.reltopic);
$('#appt_form_submit').hide();
$('#calEventUpdate').show();
if (event.repeater) {
Expand Down Expand Up @@ -413,7 +420,6 @@ init : function(cal,calendartopic,reltopic,viewall) {
if (calendartopic.search(/\./) == -1) calendartopic = foswiki.web+'.'+calendartopic; // SMELL: a bit simple
$(cal).mouseup(function(){
$form.data('calendar',this);
$form.data('reltopic',reltopic);
}).fullCalendar({
theme: true,
header: {
Expand Down Expand Up @@ -510,16 +516,36 @@ init : function(cal,calendartopic,reltopic,viewall) {
$('#appt_endDate').val(dateArray[0]);
}
$('#fcp_topic').val(calendartopic);
$('#fcp_reltopic').val(reltopic);
$form.parent().centerInClient({forceAbsolute:true}).fadeIn();
},
eventClick: function(calEvent, jsEvent, view) {
if (calEvent.className == 'action') {
alert("Action Tracker integration is ongoing.\nPlease use the Action Tracker interface available via the toolbar or visit the WebActions page.\n\n" + calEvent.text);
} else {
getEvent(calEvent, function(event){
foswiki.FullCalendar.loadForm(event);
});
switch (calEvent.category) {
case 'action':
foswiki.HijaxPlugin.showOops("Action Tracker integration is ongoing.\
Please use the Action Tracker interface available via the toolbar or visit the WebActions page.\n\n" +
calEvent.text);
break;
case 'external':
var dateformat = 'd MMM yyyy at HH:mm:ss';
var start = $.fullCalendar.formatDate(calEvent.start, dateformat);
var end = $.fullCalendar.formatDate(calEvent.end, dateformat);
var message = "<h2>"+calEvent.title+"</h2>\
<p>Starting: " + start + "</p><p>Ending: " + end + "</p><p>" + calEvent.text + "</p>";
if (calEvent.eventSource) {
message = message + "<hr />From: " + calEvent.eventSource;
}
foswiki.HijaxPlugin.showOops(message);
break;
default:
getEvent(calEvent, function(event){
foswiki.FullCalendar.loadForm(event);
});
}
if (calEvent.url) {
window.open(calEvent.url);
return false;
}
}
});
if (!$form) getForm();
Expand Down

0 comments on commit 3110511

Please sign in to comment.