* "All day event" shows as a single checkbox, instead of one for the start
authorArt Cancro <ajc@citadel.org>
Wed, 13 Nov 2002 04:49:23 +0000 (04:49 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 13 Nov 2002 04:49:23 +0000 (04:49 +0000)
  time and one for the end time.  Added nifty JavaScript to zero and shade
  the hour/minute and all end time fields when all-day-event is checked.

webcit/ChangeLog
webcit/calendar_tools.c
webcit/event.c
webcit/webcit.c

index a28e61d1c8f2d4bf4cdd5379692b3780703bc15b..b0b471244a8aad0141903b826a7510a78f119954 100644 (file)
@@ -1,4 +1,9 @@
 $Log$
+Revision 400.48  2002/11/13 04:49:23  ajc
+* "All day event" shows as a single checkbox, instead of one for the start
+  time and one for the end time.  Added nifty JavaScript to zero and shade
+  the hour/minute and all end time fields when all-day-event is checked.
+
 Revision 400.47  2002/11/12 05:57:27  ajc
 * Display a nicer looking screen when replying to calendar invitations
 * When displaying day view, don't show all day events twice
@@ -1104,4 +1109,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index f61828e935407ed58856a40368cf80575131ee24..10d898baf404eca8b303c82f8d979258ec448f8e 100644 (file)
@@ -110,11 +110,6 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
                );
        }
        wprintf("</SELECT>\n");
-
-       wprintf("<INPUT TYPE=\"checkbox\" NAME=\"%s_alldayevent\" "
-               "VALUE=\"yes\" %s> All day event",
-               prefix,
-               ((t->is_date) ? "CHECKED" : ""));
 }
 
 
@@ -132,15 +127,6 @@ struct icaltimetype icaltime_from_webform(char *prefix) {
        sprintf(vname, "%s_hour", prefix);      t.hour = atoi(bstr(vname));
        sprintf(vname, "%s_minute", prefix);    t.minute = atoi(bstr(vname));
 
-       sprintf(vname, "%s_alldayevent", prefix);
-       if (!strcasecmp(bstr(vname), "yes")) {
-               t.hour = 0;
-               t.minute = 0;
-               t.second = 0;
-               t.is_date = 1;
-               lprintf(9, "icaltime_from_webform() setting is_date\n");
-       }
-
        t = icaltime_normalize(t);
        return(t);
 }
index 11ece54543922a827954ffa17bd6cd490db3b8ca..b2bb386cc955cd0a2e8e8dbd04b11dc3aab967a7 100644 (file)
@@ -37,7 +37,7 @@
 void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) {
        icalcomponent *vevent;
        icalproperty *p;
-       struct icaltimetype t;
+       struct icaltimetype t_start, t_end;
        time_t now;
        int created_new_vevent = 0;
 
@@ -104,23 +104,70 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        wprintf("<TR><TD><B>Start</B></TD><TD>\n");
        p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
        if (p != NULL) {
-               t = icalproperty_get_dtstart(p);
+               t_start = icalproperty_get_dtstart(p);
+               if (t_start.is_date) {
+                       t_start.hour = 0;
+                       t_start.minute = 0;
+                       t_start.second = 0;
+               }
        }
        else {
-               t = icaltime_from_timet(now, 0);
+               t_start = icaltime_from_timet(now, 0);
        }
-       display_icaltimetype_as_webform(&t, "dtstart");
+       display_icaltimetype_as_webform(&t_start, "dtstart");
+
+       wprintf("<INPUT TYPE=\"checkbox\" NAME=\"alldayevent\" "
+               "VALUE=\"yes\" onClick=\"
+
+                       if (this.checked) {
+                                this.form.dtstart_hour.value='0';
+                                this.form.dtstart_hour.disabled = true;
+                                this.form.dtstart_minute.value='0';
+                                this.form.dtstart_minute.disabled = true;
+                                this.form.dtend_hour.value='0';
+                                this.form.dtend_hour.disabled = true;
+                                this.form.dtend_minute.value='0';
+                                this.form.dtend_minute.disabled = true;
+                                this.form.dtend_month.disabled = true;
+                                this.form.dtend_day.disabled = true;
+                                this.form.dtend_year.disabled = true;
+                        }
+                        else {
+                                this.form.dtstart_hour.disabled = false;
+                                this.form.dtstart_minute.disabled = false;
+                                this.form.dtend_hour.disabled = false;
+                                this.form.dtend_minute.disabled = false;
+                                this.form.dtend_month.disabled = false;
+                                this.form.dtend_day.disabled = false;
+                                this.form.dtend_year.disabled = false;
+                        }
+
+
+               \" %s >All day event",
+               (t_start.is_date ? "CHECKED" : "" )
+       );
+
        wprintf("</TD></TR>\n");
 
+       /* If this is an all-day-event, set the end time to be identical to
+        * the start time (the hour/minute/second will be set to midnight).
+        * Otherwise extract or create it.
+        */
        wprintf("<TR><TD><B>End</B></TD><TD>\n");
-       p = icalcomponent_get_first_property(vevent, ICAL_DTEND_PROPERTY);
-       if (p != NULL) {
-               t = icalproperty_get_dtend(p);
+       if (t_start.is_date) {
+               t_end = t_start;
        }
        else {
-               t = icaltime_from_timet(now, 0);
+               p = icalcomponent_get_first_property(vevent,
+                                                       ICAL_DTEND_PROPERTY);
+               if (p != NULL) {
+                       t_end = icalproperty_get_dtend(p);
+               }
+               else {
+                       t_end = icaltime_from_timet(now, 0);
+               }
        }
-       display_icaltimetype_as_webform(&t, "dtend");
+       display_icaltimetype_as_webform(&t_end, "dtend");
        wprintf("</TD></TR>\n");
 
        wprintf("<TR><TD><B>Notes</B></TD><TD>\n"
@@ -200,11 +247,32 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                      ICAL_DTSTART_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vevent, prop);
                }
-               event_start = icaltime_from_webform("dtstart");
-               if (event_start.is_date) {
-                       lprintf(9, "*** all day event ***\n");
+
+               if (!strcmp(bstr("alldayevent"), "yes")) {
                        all_day_event = 1;
+                       lprintf(9, "*** all day event ***\n");
                }
+               else {
+                       all_day_event = 0;
+               }
+
+               event_start = icaltime_from_webform("dtstart");
+               if (all_day_event) {
+                       event_start.is_date = 1;
+                       event_start.hour = 0;
+                       event_start.minute = 0;
+                       event_start.second = 0;
+               }
+               lprintf(9, "dtstart: %s\n",
+                       icaltime_as_ical_string(event_start)
+               );
+
+       /* FIXME.  Somewhere between here and when we save the event, we are
+        * somehow losing the "is_date" setting of dtstart.  The problem might
+        * be with WebCit or it might be in libical.  Check to see if this
+        * problem goes away when we upgrade libical.  --IG
+        */
+
                icalcomponent_add_property(vevent,
                        icalproperty_new_dtstart(event_start)
                );
@@ -217,10 +285,11 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                      ICAL_DURATION_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vevent, prop);
                }
+
                if (all_day_event == 0) {
                        icalcomponent_add_property(vevent,
-                               icalproperty_new_dtend(
-                                       icaltime_from_webform("dtend")
+                               icalproperty_new_dtend(icaltime_normalize(
+                                       icaltime_from_webform("dtend"))
                                )
                        );
                }
@@ -233,7 +302,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                                icalproperty_new_uid(buf)
                        );
                }
-       
+
                /* Serialize it and save it to the message base */
                serv_puts("ENT0 1|||4");
                serv_gets(buf);
index ba8e71ca2c17d679bfc869db66e0537fc1458ec6..481a1fbb413a506a1ea8cfa7a1b0ee6207976d4d 100644 (file)
@@ -155,7 +155,7 @@ char *bstr(char *key)
 void wprintf(const char *format,...)
 {
        va_list arg_ptr;
-       char wbuf[1024];
+       char wbuf[4096];
 
        va_start(arg_ptr, format);
        vsprintf(wbuf, format, arg_ptr);