First stab at a pretty autocompleter for event attendees.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 10 Mar 2010 20:21:02 +0000 (15:21 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 10 Mar 2010 20:21:02 +0000 (15:21 -0500)
Mostly working...there seems to be an issue with the fb grid never
resetting, even when opening a different event, but that seems to
have broken before...

kronolith/index.php
kronolith/js/kronolith.js
kronolith/lib/Ajax/Application.php
kronolith/lib/Ajax/Imple/ContactAutoCompleter.php
kronolith/templates/index/edit.inc
kronolith/themes/screen.css

index c17d279..32e83aa 100644 (file)
@@ -96,4 +96,14 @@ Horde_Ajax_Imple::factory(
           'pretty' => true,
           'var' => 'kronolithCTagAc'))
     ->attach();
+
+Horde_Ajax_Imple::factory(
+    array('kronolith', 'ContactAutoCompleter'),
+    array('triggerId' => 'kronolithEventAttendees',
+          'triggerContainer' => 'kronolithAttendeesACTriggerContainer',
+          'box' => 'kronolithAttendeesACBox',
+          'pretty' => true,
+          'var' => 'kronolithEAttendeesAc'))
+    ->attach();
+
 echo "</body>\n</html>";
index 33c0f6a..9bcb701 100644 (file)
@@ -3858,6 +3858,7 @@ KronolithCore = {
             this.doAction('getEvent', { cal: calendar, id: id, date: date }, this.editEventCallback.bind(this));
             $('kronolithEventTopTags').update();
         } else {
+            kronolithEAttendeesAc.reset();
             kronolithETagAc.reset();
             this.doAction('listTopTags', null, this.topTagsCallback.curry('kronolithEventTopTags', 'kronolithEventTag'));
             var d;
@@ -4071,10 +4072,11 @@ KronolithCore = {
         }
 
         /* Attendees */
+        kronolithEAttendeesAc.reset();
         this.freeBusy = $H();
         $('kronolithEventStartDate').stopObserving('change');
         if (!Object.isUndefined(ev.at)) {
-            $('kronolithEventAttendees').setValue(ev.at.pluck('l').join(', '));
+            kronolithEAttendeesAc.reset(ev.at.pluck('l'));
             var table = $('kronolithEventTabAttendees').down('tbody');
             table.select('tr').invoke('remove');
             ev.at.each(function(attendee) {
index 12f06fe..457727a 100644 (file)
@@ -91,6 +91,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
         }
 
         $event->readForm();
+
         $result = $this->_saveEvent($event);
         if (($result !== true) && $this->_vars->sendupdates) {
             Kronolith::sendITipNotifications($event, $GLOBALS['notification'], Kronolith::ITIP_REQUEST);
index 01da4db..b0f2f5c 100644 (file)
@@ -23,14 +23,22 @@ class Kronolith_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_AutoCom
     {
         $js_params['indicator'] = $this->_params['triggerId'] . '_loading_img';
 
-        return array(
-            'ajax' => 'ContactAutoCompleter',
-            'params' => $js_params,
-            'raw_params' => array(
-                'onSelect' => 'function (v) { if (!v.endsWith(";")) { v += ","; } return v + " "; }',
-                'onType' => 'function (e) { return e.include("<") ? "" : e; }'
-            ),
-        );
+        $ret = array('params' => $js_params,
+                     'raw_params' => array(
+                         'onSelect' => 'function (v) { if (!v.endsWith(";")) { v += ","; } return v + " "; }',
+                         'onType' => 'function (e) { return e.include("<") ? "" : e; }'
+                      ));
+        if (empty($this->_params['pretty'])) {
+            $ret['ajax'] = 'ContactAutoCompleter';
+        } else {
+            $ret['pretty'] = 'ContactAutoCompleter';
+        }
+
+        if (!empty($this->_params['var'])) {
+            $ret['var'] = $this->_params['var'];
+        }
+
+        return $ret;
     }
 
     /**
index a5282ae..43a877c 100644 (file)
 <div id="kronolithEventTabAttendees" class="kronolithTabsOption" style="display:none">
   <label>
     <?php echo _("Add attendees e-mail addresses") ?>:<br />
-    <textarea name="attendees" id="kronolithEventAttendees" rows="2" cols="100" class="kronolithLongField"></textarea>
+    <input id="kronolithEventAttendees" name="attendees" />
+    <span id="kronolithEventAttendees_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
   </label>
   <br />
   <label>
index b348089..a436d4f 100644 (file)
@@ -838,7 +838,7 @@ div.kronolithFormActions {
     margin: 0;
     height: 100%;
 }
-#kronolithEventACBox, #kronolithCalendarinternalACBox {
+#kronolithEventACBox, #kronolithCalendarinternalACBox, #kronolithAttendeesACBox {
     line-height: 100%;
 }