]> err.no Git - scalable-opengroupware.org/commitdiff
implemented async read/unread marking
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sun, 13 Feb 2005 02:22:54 +0000 (02:22 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sun, 13 Feb 2005 02:22:54 +0000 (02:22 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@551 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/Mailer/ChangeLog
SOGo/UI/Mailer/UIxMailListView.m
SOGo/UI/Mailer/UIxMailListView.wox
SOGo/UI/Mailer/Version
SOGo/UI/Mailer/mailer.js

index 092e698c0034f19e6657afe23c56c1f71df17648..0a2cd6e201c5a93e88af9c6bd407eff32d59d3e1 100644 (file)
@@ -1,5 +1,8 @@
 2005-02-13  Helge Hess  <helge.hess@opengroupware.org>
 
+       * UIxMailListView.wox: added mark read/unread without page refresh
+         using XMLHttpRequest (v0.9.103)
+
        * product.plist, UIxMailListView.wox, mailer.js: added bulk
          reply/replyall/forward (v0.9.102)
 
index 08b0341b8db48708b4ce30c1276980ed7685a43b..85683e802b8f3927b63bda1e88fb70a0a6e388ba 100644 (file)
@@ -340,10 +340,14 @@ static int attachmentFlagSize = 8096;
   return [NSString stringWithFormat:@"clickedUid(this, '%@'); return false", 
                     [self messageUidString]];
 }
+
+// the following are unused?
 - (NSString *)dblClickedMsgJS {
   return [NSString stringWithFormat:@"doubleClickedUid(this, '%@')", 
                     [self messageUidString]];
 }
+
+// the following are unused?
 - (NSString *)highlightRowJS {
   return [NSString stringWithFormat:@"highlightUid(this, '%@')", 
                     [self messageUidString]];
@@ -353,6 +357,19 @@ static int attachmentFlagSize = 8096;
                     [self messageUidString]];
 }
 
+- (NSString *)markUnreadJS {
+  return [NSString stringWithFormat:
+                    @"mailListMarkMessage(this, 'markMessageUnread', "
+                    @"'%@', false)", 
+                    [self messageUidString]];
+}
+- (NSString *)markReadJS {
+  return [NSString stringWithFormat:
+                    @"mailListMarkMessage(this, 'markMessageRead', "
+                    @"'%@', true)", 
+                    [self messageUidString]];
+}
+
 - (NSString *)jsCode {
   static NSString *script = \
   @"var rowSelectionCount = 0;\n"
@@ -421,12 +438,26 @@ static int attachmentFlagSize = 8096;
   return self;
 }
 
+- (BOOL)isJavaScriptRequest {
+  return [[[[self context] request] formValueForKey:@"jsonly"] boolValue];
+}
+- (id)javaScriptOK {
+  WOResponse *r;
+
+  r = [[self context] response];
+  [r setStatus:200 /* OK */];
+  return r;
+}
+
 - (id)markMessageUnreadAction {
   NSException *error;
   
   if ((error = [[self lookupActiveMessage] removeFlags:@"seen"]) != nil)
     // TODO: improve error handling
     return error;
+
+  if ([self isJavaScriptRequest])
+    return [self javaScriptOK];
   
   return [self redirectToLocation:@"view"];
 }
@@ -437,6 +468,9 @@ static int attachmentFlagSize = 8096;
     // TODO: improve error handling
     return error;
   
+  if ([self isJavaScriptRequest])
+    return [self javaScriptOK];
+  
   return [self redirectToLocation:@"view"];
 }
 
index 16abefd0c8b00ae1e5fd29dfa4bf6582321c1d0a..e82c07fdfc2ba14acbf4cd04a6f05ae7e1a02a54 100644 (file)
               <div class="mailer_readicon"
                    var:style="msgIconReadVisibility"
                    var:id="msgIconReadDivID">
-                <a href="markMessageUnread" var:_uid="message.uid"
+                <a href="#" var:onclick="markUnreadJS"
                    label:title="Mark Unread"> </a>
               </div>
               <div class="mailer_unreadicon"  
                    var:style="msgIconUnreadVisibility"
                    var:id="msgIconUnreadDivID">
-                <a href="markMessageRead" var:_uid="message.uid"
+                <a href="#" var:onclick="markReadJS"
                    label:title="Mark Read"> </a>
               </div>
             </td>
index ceaa66e5b5199d806c92b0491adc7a0ef4b431be..c230851eee6eb94c0a9ddf83d09a599502d7612d 100644 (file)
@@ -1,6 +1,6 @@
 # version file
 
-SUBMINOR_VERSION:=102
+SUBMINOR_VERSION:=103
 
 # v0.9.100 requires libNGMime        v4.5.213
 # v0.9.99  requires libNGMime        v4.5.212
index a01927a9f05710bfc30ce437fb15ca43898e32ee..0a4f06ccfa7b5237c702d16e5c098075790e9c81 100644 (file)
@@ -32,36 +32,6 @@ function doubleClickedUid(sender, msguid) {
   return false;
 }
 
-function highlightUid(sender, msguid) {
-  // var row = document.getElementById(msguid);
-  // row.className="mailer_readmailsubject_high";
-  return true;
-}
-function lowlightUid(sender, msguid) {
-  // var row = document.getElementById(msguid);
-  // row.className="mailer_readmailsubject";
-  return true;
-}
-
-function singleClickedTableRow(clickEvent, sender) {
-  var rowid = sender.id;
-  var field;
-  
-  field = document.forms['pageform'].elements[rowid];
-  if (field.value == "1") {
-    field.value = "0";
-    sender.className = "tableview";
-  }
-  else {
-    field.value = "1";
-    sender.className = "tableview_selected";
-  }
-}
-function doubleClickedTableRow(clickEvent, sender) {
-  var rowid = sender.id;
-  resetSelection(window);
-}
-
 function toggleMailSelect(sender) {
   var row;
   row = document.getElementById(sender.name);
@@ -203,7 +173,7 @@ function clickedNewFilter(sender) {
 
 /* generic stuff */
 
-function getHTTPClient() {
+function createHTTPClient() {
   // http://developer.apple.com/internet/webcontent/xmlhttpreq.html
   if (typeof XMLHttpRequest != "undefined")
     return new XMLHttpRequest();
@@ -267,23 +237,35 @@ function triggerOpenerCallback() {
 
 /* mail list DOM changes */
 
-function markMailReadInWindow(win, msguid) {
+function markMailInWindow(win, msguid, markread) {
   var msgDiv;
   
   msgDiv = win.document.getElementById("div_" + msguid);
   if (msgDiv) {
-    msgDiv.className = "mailer_readmailsubject";
+    if (markread) {
+      msgDiv.className = "mailer_readmailsubject";
     
-    msgDiv = win.document.getElementById("unreaddiv_" + msguid);
-    if (msgDiv) msgDiv.style.display = "none";
-    msgDiv = win.document.getElementById("readdiv_" + msguid);
-    if (msgDiv) msgDiv.style.display = "block";
+      msgDiv = win.document.getElementById("unreaddiv_" + msguid);
+      if (msgDiv) msgDiv.style.display = "none";
+      msgDiv = win.document.getElementById("readdiv_" + msguid);
+      if (msgDiv) msgDiv.style.display = "block";
+    }
+    else {
+      msgDiv.className = "mailer_unreadmailsubject";
     
+      msgDiv = win.document.getElementById("readdiv_" + msguid);
+      if (msgDiv) msgDiv.style.display = "none";
+      msgDiv = win.document.getElementById("unreaddiv_" + msguid);
+      if (msgDiv) msgDiv.style.display = "block";
+    }
     return true;
   }
   else
     return false;
 }
+function markMailReadInWindow(win, msguid) {
+  return markMailInWindow(win, msguid, true);
+}
 
 /* main window */
 
@@ -313,3 +295,27 @@ function openMessageWindowsForSelection(sender, action) {
   for (var i = 0; i < rows.length; i++)
     win = openMessageWindow(sender, rows[i], rows[i] + "/" + action);
 }
+
+function mailListMarkMessage(sender, action, msguid, markread) {
+  var url;
+  var http = createHTTPClient();
+
+  url = action + "?uid=" + msguid;
+
+  if (http) {
+    // TODO: add parameter to signal that we are only interested in OK
+    http.open("GET", url + "&jsonly=1", false);
+    http.send(null);
+    if (http.status != 200) {
+      // TODO: refresh page?
+      alert("Message Mark Failed: " + http.statusText);
+      window.opener.location.reload();
+    }
+    else {
+      markMailInWindow(window, msguid, markread);
+    }
+  }
+  else {
+    window.opener.location.href = url;
+  }
+}