]> code.citadel.org Git - citadel.git/blobdiff - webcit/event.c
Default value for 'repeat until' date is one week after start date
[citadel.git] / webcit / event.c
index 4618e8bd695319d72e5c10c564ca2bd118a93a9f..5aab9dc3e48baa557f941feb747cdbbae2bb28f5 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>");
@@ -402,6 +402,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                /* blank recurrence with some sensible defaults */
                memset(&recur, 0, sizeof(struct icalrecurrencetype));
                recur.count = 3;
+               recur.until = icaltime_null_time();
                recur.interval = 1;
                recur.freq = ICAL_WEEKLY_RECURRENCE;
        }
@@ -438,39 +439,32 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                _("never")
        };
 
+
+
+
        wprintf("<tr><td><b>");
-       wprintf(_("Repeats"));
+       wprintf(_("Recurrence rule"));
        wprintf("</b></td><td>");
        if ((recur.freq < 0) || (recur.freq > 6)) recur.freq = 4;
-       wprintf("%s ", _("every"));
+       wprintf("%s ", _("Repeats every"));
 
        wprintf("<input type=\"text\" name=\"interval\" maxlength=\"3\" size=\"3\" ");
        wprintf("value=\"%d\"> ", recur.interval);
 
        wprintf("<select name=\"freq\" id=\"freq_selector\" size=\"1\" "
-               "onclick=\"RecurrenceShowHide();\">\n");
+               "onChange=\"RecurrenceShowHide();\">\n");
        for (i=0; i<(sizeof frequency_units / sizeof(char *)); ++i) {
-
-               /* We only want to offer daily, weekly, monthly, or yearly, which are
-                * options 3 through 6, but if one of the others hapens to be selected,
-                * we will grudgingly add it to the list of options.
-                */
-               if ( (i == recur.freq) || ((i>=3) && (i<=6)) ) {
-                       wprintf("<option %s value=\"%d\">%s</option>\n",
-                               ((i == recur.freq) ? "selected" : ""),
-                               i,
-                               frequency_units[i]
-                       );
-               }
+               wprintf("<option %s%svalue=\"%d\">%s</option>\n",
+                       ((i == recur.freq) ? "selected " : ""),
+                       (((i == recur.freq) || ((i>=3)&&(i<=5))) ? "" : "disabled "),
+                       i,
+                       frequency_units[i]
+               );
        }
+       wprintf("</select>\n");
 
-       wprintf("</td></tr>\n");
-
-
-       wprintf("<div id=\"weekday_selector\">\n");             /* begin 'weekday_selector' div */
-       wprintf("<tr><td><b>");
-       wprintf("%s", _("on these weekdays:"));
-       wprintf("</b></td><td>");
+       wprintf("<div id=\"weekday_selector\">");       /* begin 'weekday_selector' div */
+       wprintf("%s<br>", _("on these weekdays:"));
 
        char weekday_is_selected[7];
        memset(weekday_is_selected, 0, 7);
@@ -493,9 +487,53 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                if (weekday_is_selected[i]) wprintf(" checked");
                wprintf(">%s</input>\n", weekday_labels[i]);
        }
+       wprintf("</div>\n");                            /* end 'weekday_selector' div */
 
        wprintf("</td></tr>\n");
-       wprintf("</div>\n");                            /* end 'weekday_selector' div */
+
+
+       int which_rrend_is_preselected = 0;
+       if (!icaltime_is_null_time(recur.until)) which_rrend_is_preselected = 2;
+       if (recur.count > 0) which_rrend_is_preselected = 1;
+
+       wprintf("<tr><td><b>");
+       wprintf(_("Recurrence range"));
+       wprintf("</b></td><td>\n");
+
+       wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_none\" "
+               "%s onChange=\"RecurrenceShowHide();\">",
+               ((which_rrend_is_preselected == 0) ? "checked" : "")
+       );
+       wprintf("%s</input><br />\n", _("No ending date"));
+
+       wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_count\" "
+               "%s onChange=\"RecurrenceShowHide();\">",
+               ((which_rrend_is_preselected == 1) ? "checked" : "")
+       );
+       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();\">",
+               ((which_rrend_is_preselected == 2) ? "checked" : "")
+       );
+       wprintf(_("Repeat this event until "));
+       wprintf("</input>");
+
+       if (icaltime_is_null_time(recur.until)) {
+               recur.until = icaltime_add(t_start, icaldurationtype_from_int(604800));
+       }
+       display_icaltimetype_as_webform(&recur.until, "rruntil", 1);
+       wprintf("<br />\n");
+
+       wprintf("</td></tr>\n");
+
+
+
 
        wprintf("</table>\n");
        wprintf("</div>\n");                            /* end 'rrule' div */