From f74b283fd47429add5955577a9e06ae5b34803c1 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 22 Aug 2008 03:39:51 -0400
Subject: [PATCH] - Fix buttons status after contacts deletion (#1485233)

---
 CHANGELOG         |    1 +
 program/js/app.js |   24 ++++++++++++++++--------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 8f34632..49c0a05 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
   message (#1485288)
 - Removed PHP4 class constructors
 - Fix html message charset conversion for charsets with underline (#1485287) 
+- Fix buttons status after contacts deletion (#1485233)
 
 2008/08/21 (estadtherr)
 ----------
diff --git a/program/js/app.js b/program/js/app.js
index c82ebf9..df2c839 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -2464,8 +2464,8 @@
       else if (this.env.contentframe)
         this.show_contentframe(false);
 
-      this.enable_command('edit', id?true:false);
       this.enable_command('compose', list.selection.length > 0);
+      this.enable_command('edit', (id && this.env.address_sources && !this.env.address_sources[this.env.source].readonly) ? true : false);
       this.enable_command('delete', list.selection.length && this.env.address_sources && !this.env.address_sources[this.env.source].readonly);
 
       return false;
@@ -3650,15 +3650,22 @@
       {
 
       case 'delete':
+	if (this.task == 'addressbook')
+	  {
+	    var uid = this.contact_list.get_selection();
+	    this.enable_command('compose', (uid && this.contact_list.rows[uid]));
+	    this.enable_command('delete', 'edit', (uid && this.contact_list.rows[uid] && this.env.address_sources && !this.env.address_sources[this.env.source].readonly));
+	    break;  
+	  }
       case 'moveto':
         if (this.env.action=='show')
           this.command('list');
         else if (this.message_list)
           this.message_list.init();
-
+	  
       case 'purge':
       case 'expunge':      
-	if (!this.env.messagecount)
+	if (!this.env.messagecount && this.task == 'mail')
     	  {
 	    // clear preview pane content
 	    if (this.env.contentframe)
@@ -3667,7 +3674,6 @@
 	    this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource',
 	      'print', 'load-attachment', 'purge', 'expunge', 'select-all', 'select-none', 'sort', false);
 	  }
-
 	break;
 
       case 'list':
@@ -3675,13 +3681,15 @@
 
       case 'check-recent':
       case 'getunread':
-	this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0));
-	var mailboxtest = (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox 
+	if (this.task == 'mail')
+	{
+	  this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0));
+	  var mailboxtest = (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox 
 	    || this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter)) 
 	    || this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter))) ? true : false;
 	
-	this.enable_command('purge', (this.env.messagecount && mailboxtest));
-
+	  this.enable_command('purge', (this.env.messagecount && mailboxtest));
+	}
 	break;
 
       }

--
Gitblit v1.9.1