Don't allow empty calendar titles.
authorJan Schneider <jan@horde.org>
Fri, 18 Jun 2010 17:15:57 +0000 (19:15 +0200)
committerJan Schneider <jan@horde.org>
Fri, 18 Jun 2010 17:16:18 +0000 (19:16 +0200)
kronolith/js/kronolith.js
kronolith/lib/Kronolith.php

index ac2c890..e2a8ee4 100644 (file)
@@ -217,7 +217,7 @@ KronolithCore = {
             case 'horde.message':
             case 'horde.success':
                 this.Growler.growl(
-                    m.flags.include('content.raw')
+                    m.flags && m.flags.include('content.raw')
                         ? m.message.replace(new RegExp('<a href="([^"]+)"'), '<a href="#" onclick="KronolithCore.iframeContent(\'$1\')"')
                         : m.message.escapeHTML(),
                     {
@@ -3282,12 +3282,20 @@ KronolithCore = {
      * Submits the calendar form to save the calendar data.
      *
      * @param Element form  The form node.
+     *
+     * @return boolean  Whether the save request was successfully sent.
      */
     saveCalendar: function(form)
     {
         var data = form.serialize({ hash: true });
+        if (data.name.empty()) {
+            this.showNotifications([ { type: 'horde.warning', message: data.type == 'tasklists' ? Kronolith.text.no_tasklist_title : Kronolith.text.no_calendar_title }]);
+            $('kronolithCalendar' + data.type + 'Name').focus();
+            return false;
+        }
         this.doAction('saveCalendar', data,
                       this.saveCalendarCallback.bind(this, form, data));
+        return true;
     },
 
     /**
@@ -3716,7 +3724,11 @@ KronolithCore = {
                 case 'kronolithCalendarFormtasklists':
                 case 'kronolithCalendarFormremote':
                     // Disabled for now, we have to also catch Continue buttons.
-                    //this.saveCalendar(form);
+                    //var saveButton = form.down('.kronolithCalendarSave');
+                    //saveButton.disable();
+                    //if (!this.saveCalendar(form)) {
+                    //    saveButton.enable();
+                    //}
                     //e.stop();
                     break;
                 }
@@ -4295,7 +4307,9 @@ KronolithCore = {
                 return;
             } else if (elt.hasClassName('kronolithCalendarSave')) {
                 elt.disable();
-                this.saveCalendar(elt.up('form'));
+                if (!this.saveCalendar(elt.up('form'))) {
+                    elt.enable();
+                }
                 e.stop();
                 break;
             } else if (elt.hasClassName('kronolithCalendarContinue')) {
index 123a71c..d499c11 100644 (file)
@@ -365,6 +365,8 @@ class Kronolith
             'prefs' => _("Options"),
             'shared' => _("Shared"),
             'no_url' => _("You must specify a URL."),
+            'no_calendar_title' => _("The calendar title must not be empty."),
+            'no_tasklist_title' => _("The task list title must not be empty."),
             'wrong_auth' => _("The authentication information you specified wasn't accepted."),
             'geocode_error' => _("Unable to locate requested address"),
             'wrong_date_format' => sprintf(_("You used an unknown date format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}'),