Fix IMP's address book selection pref UI. Still doesn't save properly, but
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 23 Sep 2009 16:57:26 +0000 (12:57 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 23 Sep 2009 16:58:48 +0000 (12:58 -0400)
now at least the UI is working somewhat normally.

imp/js/addressbooksprefs.js
imp/templates/prefs/sourceselect.inc

index 53238ad..dcb00f0 100644 (file)
@@ -10,7 +10,7 @@ var ImpAddressbooksPrefs = {
 
     deselectHeaders: function()
     {
-        $F('unselected_search_sources').selectedIndex = $F('selected_search_sources').selectedIndex = -1;
+        $('unselected_search_sources').selectedIndex = $('selected_search_sources').selectedIndex = -1;
     },
 
     resetHidden: function()
@@ -34,7 +34,7 @@ var ImpAddressbooksPrefs = {
 
         $A(from.options).slice(1).each(function(s) {
             if (s.selected) {
-                to[i] = s.cloneNode(false);
+                to.appendChild(s.cloneNode(true));
                 s.remove();
             }
             ++i;
@@ -88,7 +88,6 @@ var ImpAddressbooksPrefs = {
             sf = $('search_fields');
 
         sf.update('');
-
         this.fields.each(function(f) {
             if (f[0] == sv) {
                 f.slice(1).each(function(o) {
@@ -107,9 +106,14 @@ var ImpAddressbooksPrefs = {
     _getSelectedValue: function(index)
     {
         var sss = $('selected_search_sources');
-
         if (sss) {
-            return index ? sss.selectedIndex : sss.options[sss.selectedIndex].value;
+            if (index) {
+                return sss.selectedIndex;
+            }
+            if (sss.selectedIndex >= 0) {
+                return sss.options[sss.selectedIndex].value;
+            }
+            return '';
         } else {
             return index ? 0 : this.fields[0][0];
         }
@@ -123,7 +127,7 @@ var ImpAddressbooksPrefs = {
             sv = this._getSelectedValue(true);
 
         $A(sf.options).each(function(o) {
-            this.fields[sv][i + 1][2] = o.selected;
+            this.fields[sv][i][2] = o.selected;
             ++i;
         }.bind(this));
 
@@ -136,7 +140,6 @@ var ImpAddressbooksPrefs = {
             });
             data.push(tmp.join("\t"));
         });
-
         $('search_fields_string').setValue(data.join("\n"));
     },
 
@@ -149,9 +152,9 @@ var ImpAddressbooksPrefs = {
         }
 
         if ($('unselected_search_sources')) {
-            $('unselected_search_sources').observe('change', this.deselectHeaders.bind(this));
+            //$('unselected_search_sources').observe('change', this.deselectHeaders.bind(this));
             $('selected_search_sources').observe('change', function() {
-                this.deselectHeaders();
+                //this.deselectHeaders();
                 this.updateSearchFields();
             }.bind(this));
             $('addsource').observe('click', this.addSource.bind(this));
index 2a8e1ea..b46ab59 100644 (file)
@@ -12,7 +12,7 @@ $imagedir = $registry->getImageDir('horde');
  <tr>
   <td>
    <label for="unselected_search_sources" class="hidden"><?php echo _("Available Address books:") ?></label>
-   <select id="unselected_search_sources" name="unselected_search_sources" multiple="multiple" size="5" style="width:20em">
+   <select id="unselected_search_sources" name="unselected_search_sources" id="unselected_search_sources" multiple="multiple" size="5" style="width:20em">
     <option value=""><?php echo _("Available Address books:") ?></option>
 <?php foreach ($cache['readSelect'] as $val): ?>
     <option value="<?php echo $val ?>"><?php echo $cache['readable'][$val] ?></option>
@@ -26,7 +26,7 @@ $imagedir = $registry->getImageDir('horde');
   </td>
   <td>
    <label for="selected_search_sources" class="hidden"><?php echo _("Selected Address books:") ?></label>
-   <select name="selected_search_sources" multiple="multiple" size="5" style="width:20em">
+   <select name="selected_search_sources" multiple="multiple" size="5" style="width:20em" id="selected_search_sources">
     <option value=""><?php echo _("Selected Address books:") ?></option>
 <?php foreach ($cache['prefSelect'] as $key => $val): ?>
     <option value="<?php echo $key ?>"><?php echo $val ?></option>