More recurrence editor code
authorArt Cancro <ajc@citadel.org>
Tue, 30 Sep 2008 14:48:22 +0000 (14:48 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 30 Sep 2008 14:48:22 +0000 (14:48 +0000)
webcit/calendar.c
webcit/calendar_tools.c
webcit/event.c
webcit/static/wclib.js
webcit/webcit.h

index b966c264bf02c049d32c65d8abdcef751dc1a837..b3200fcb23209708d3247736885f66fefe49399e 100644 (file)
@@ -637,7 +637,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        }
        else
                IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
-       display_icaltimetype_as_webform(&IcalTime, "dtstart");
+       display_icaltimetype_as_webform(&IcalTime, "dtstart", 0);
        wprintf("</TD></TR>\n");
 
        wprintf("<TR><TD>");
@@ -658,7 +658,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        }
        else
                IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
-       display_icaltimetype_as_webform(&IcalTime, "due");
+       display_icaltimetype_as_webform(&IcalTime, "due", 0);
                
        wprintf("</TD></TR>\n");
        todoStatus = icalcomponent_get_status(vtodo);
index 1a9f9c99a080fdd841f2b432fb8fbb6b89bb5d44..3e946d945fdcc7ea23dae04d835292e9031e1439 100644 (file)
@@ -33,7 +33,7 @@ char *hourname[] = {
  * might be to allow the user to specify his/her timezone.
  */
 
-void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
+void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int date_only) {
        int i;
        time_t now;
        struct tm tm_now;
@@ -73,6 +73,14 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        wprintf(prefix);
        wprintf("', '%s');\n", get_selected_language());
        wprintf("</script>");
+
+       /* If we're editing a date only, we still generate the time boxes, but we hide them.
+        * This keeps the data model consistent.
+        */
+       if (date_only) {
+               wprintf("<div style=\"display:none\">");
+       }
+
        wprintf(_("Hour: "));
        wprintf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
        for (i=0; i<=23; ++i) {
@@ -104,6 +112,10 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
                }
        }
        wprintf("</SELECT>\n");
+
+       if (date_only) {
+               wprintf("</div>");
+       }
 }
 
 /*
index 2ac6982591258ab1e317d4a913d6c467c505e501..86014aaba470df76b5b7b3eb9e7dfe5056d2ebab 100644 (file)
@@ -191,7 +191,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                t_start.is_utc = 1;
 
        }
-       display_icaltimetype_as_webform(&t_start, "dtstart");
+       display_icaltimetype_as_webform(&t_start, "dtstart", 0);
 
        wprintf("<INPUT TYPE=\"checkbox\" id=\"alldayevent\" NAME=\"alldayevent\" "
                "VALUE=\"yes\" onclick=\"eventEditAllDay();\""
@@ -232,7 +232,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                        /* t_end = icaltime_from_timet(now, 0); */
                }
        }
-       display_icaltimetype_as_webform(&t_end, "dtend");
+       display_icaltimetype_as_webform(&t_end, "dtend", 0);
        wprintf("</TD></TR>\n");
 
        wprintf("<TR><TD><B>");
@@ -492,7 +492,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
 
 
-
+       // FIXME preselect the correct radio button
 
        wprintf("<tr><td><b>");
        wprintf(_("Recurrence range"));
@@ -508,15 +508,21 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                "%s onChange=\"RecurrenceShowHide();\">",
                (0 ? "checked" : "")
        );
-       wprintf(_("Repeat this event %d times"), 0);
-       wprintf("</input><br />\n");
+       wprintf(_("Repeat this event"));
+       wprintf("</input> ");
+       wprintf("<input type=\"text\" name=\"rrcount\" id=\"rrcount\" maxlength=\"3\" size=\"3\" ");
+       wprintf("value=\"%d\"> ", recur.count);
+       wprintf(_("times"));
+       wprintf("<br />\n");
 
        wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_until\" "
                "%s onChange=\"RecurrenceShowHide();\">",
                (0 ? "checked" : "")
        );
-       wprintf(_("Repeat this event until %s"), "FIXME");
-       wprintf("</input><br />\n");
+       wprintf(_("Repeat this event until "));
+       wprintf("</input>");
+       display_icaltimetype_as_webform(&recur.until, "rruntil", 1);
+       wprintf("<br />\n");
 
        wprintf("</td></tr>\n");
 
index 2ba65152d6c1f86a86c4f36b4badec11711cb7b8..09a1fb59eac76d90dc40915b468c86f9a6f06cb5 100644 (file)
@@ -1004,4 +1004,18 @@ function RecurrenceShowHide() {
                $('weekday_selector').style.display = 'none';
        }
 
+       if ($('rrend_count').checked) {
+               $('rrcount').disabled = false;
+       }
+       else {
+               $('rrcount').disabled = true;
+       }
+
+       if ($('rrend_until').checked) {
+               $('rruntil').disabled = false;
+       }
+       else {
+               $('rruntil').disabled = true;
+       }
+
 }
index 06a2e66b2f8a7b63be52c944707e33752edd2e62..0e9c1338c94d0e3177b09657453025aa2615cb51 100644 (file)
@@ -772,7 +772,7 @@ void display_pictureview(void);
 void display_edit_task(void);
 void display_edit_event(void);
 icaltimezone *get_default_icaltimezone(void);
-void display_icaltimetype_as_webform(struct icaltimetype *, char *);
+void display_icaltimetype_as_webform(struct icaltimetype *, char *, int);
 void icaltime_from_webform(struct icaltimetype *result, char *prefix);
 void icaltime_from_webform_dateonly(struct icaltimetype *result, char *prefix);
 void display_edit_individual_event(icalcomponent *supplied_vtodo, long msgnum, char *from, int unread);