]> err.no Git - scalable-opengroupware.org/commitdiff
added inline editing to contact tableview
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 18 Feb 2005 17:43:35 +0000 (17:43 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 18 Feb 2005 17:43:35 +0000 (17:43 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@587 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/Contacts/UIxContactEditor.m
SOGo/UI/MailerContacts/ChangeLog
SOGo/UI/MailerContacts/Version
SOGo/UI/MailerContacts/mailercontacts.js
SOGo/UI/Templates/UIxMailContactList.wox

index 674141f67f2007edcf7b02c3d115f2a51c4322cb..d37eb1ea454a261bd413e4637252541988a234b1 100644 (file)
   
   [self saveValuesIntoRecord:record];
   
+  // TODO: directly hacking the content, hm, not so nice or reasonable?
   recstr = [record description]; // make plist
   ex = [[self clientObject] saveContentString:recstr];
   if (ex != nil) {
index 36245ec2f386134207d3fd011fff043d5460a0f4..d4eca3b3f998efc9cb2af38ca0fe6dde53e28d1b 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-18  Helge Hess  <helge.hess@opengroupware.org>
+
+       * mailercontacts.js: added some function to allow inline editing of
+         fields in a tableview (v0.9.6)
+
 2005-02-17  Helge Hess  <helge.hess@opengroupware.org>
 
        * removed DUP Images directory, resource lookup now properly works for
index 84f2fb429f107e2263091e59dd339c54c30bd89e..dacebf417846ced1b9e5b49e7f4eec58257348e5 100644 (file)
@@ -1,5 +1,5 @@
 # version file
 
-SUBMINOR_VERSION:=5
+SUBMINOR_VERSION:=6
 
 # v0.9.5 requires MailerUI v0.9.116
index bb3a540cbb65ca0d353d76d075089fe366b20d67..536253cf9957c5a70b249619522e7adc945f94cd 100644 (file)
@@ -36,3 +36,121 @@ function cl_highlight(sender) {
 function cl_lowlight(sender) {
   sender.className = "tableview";
 }
+
+/* edit field */
+
+function cl_stripActionInURL(url) {
+  if (url[url.length - 1] != '/') {
+    var i;
+
+    i = url.lastIndexOf("/");
+    if (i != -1) url = url.substring(0, i);
+  }
+  if (url[url.length - 1] != '/') // ensure trailing slash
+    url = url + "/";
+  return url;
+}
+
+function cl_saveFieldValue(sender, keyName) {
+  var http = createHTTPClient();
+
+  if (http) {
+    var tableRow = sender.parentNode.parentNode;
+    var recordID = tableRow.id;
+    var url      = window.location.href;
+    var content;
+    
+    url = cl_stripActionInURL(url);
+    url = url + recordID + "/patchOneField";
+    // TODO: confuses SOPE?!: url = url + "?jsonly=1"
+    
+    // TODO: need to use XML!
+    content = keyName + "\n" + sender.value;
+    
+    http.open("POST", url, false);
+    http.send(content);
+    if (http.status != 200) {
+      // TODO: localize, improve error message
+      alert("Store Failed: " + http.statusText);
+    }
+    else {
+      return true;
+    }
+  }
+  else {
+    // TODO: we should disable the functionality now
+  }
+  return false;
+}
+
+var currentEditField = null;
+var currentEditDiv   = null;
+var oldFieldValue    = null;
+var currentKeyName   = null;
+
+function cl_findEditField(sender) {
+  var f;
+
+  f = sender.parentNode.getElementsByTagName("input");
+  return (f.length > 0) ? f[0] : null;
+}
+
+function cl_showEditField(sender, e, keyName) {
+  var inputField;
+
+  if (currentEditDiv != null)
+    cl_findEditField(currentEditField);
+  
+  e.stopPropagation();
+  
+  currentKeyName   = keyName;
+  currentEditDiv   = sender;
+  currentEditField = cl_findEditField(sender);
+  oldFieldValue    = unescapeHTML(sender.innerHTML);
+  
+  inputField               = cl_findEditField(sender);
+  inputField.value         = oldFieldValue;
+  sender.style.display     = "none";
+  inputField.style.display = "inline";
+
+  inputField.focus();
+  inputField.select();
+  
+  return true;
+}
+
+function cl_finishEditField(sender) {
+  // this might trigger onblur!
+
+  if (sender != currentEditField && sender != null)
+    return;
+  
+  currentEditField.style.display = "none";
+  currentEditDiv.style.display   = "inline";
+  currentEditField = null;
+  currentEditDiv   = null;
+  currentKeyName   = null;
+  oldFieldValue    = null;
+}
+
+function cl_editFieldKeyPress(sender, e) {
+  if (e.keyCode == 27) { /* escape, cancel editing */
+    cl_finishEditField(null);
+    return false;
+  }
+  if (e.keyCode == 13) { /* save using XMLHttpRequest */
+    if (cl_saveFieldValue(sender, currentKeyName)) {
+      // copy new value to div
+      currentEditDiv.innerHTML = escapeHTML(sender.value);
+      cl_finishEditField(null);
+    }
+    else {
+      // alert blurs!: alert("field save failed!"); // TODO: localize
+      // TODO: do we have beep or something?
+    }
+    return false;
+  }
+
+  // TODO: we could support "tab" for jumping to the next field
+  return true;
+}
index f997f2bf5ed67814ed45ea38e8a23b0798b3e061..cac769e370b167450b8417d5fb7b32f606de69fc 100644 (file)
                                var:queryDictionary="queryParameters"
 -->
 
+<style>
+span.cl_inline {
+  width: 100%;
+}
+input.cl_inlinefield {
+  font-size:    8pt;
+  border-width: 1px;
+  border-color: black;
+  display:      none;
+  width:        95%;
+}
+</style>
+
   <script language="JavaScript" rsrc:src="mailercontacts.js">
   </script>
 
 
         <!-- actual table contents -->
         <var:foreach list="contactInfos" item="contact">
-          <tr class="tableview" var:id="contact.cName"
+          <tr class="tableview" 
+              var:id="contact.cName"
               onclick="openContact(this, this.id)"
               onmouseover="cl_highlight(this)"
               onmouseout="cl_lowlight(this)"
               style="cursor: pointer;"
           >
             <td><var:string value="contact.sn" /><entity name="nbsp"/></td>
+
             <td>
-              <var:string value="contact.givenname" />
+              <span class="cl_inline" 
+                    onclick="cl_showEditField(this, event, 'givenName')"
+                ><var:string value="contact.givenname" /></span>
+
+              <input type="text" class="cl_inlinefield"
+                     autocomplete="off"
+                     onkeypress="cl_editFieldKeyPress(this, event)"
+                     onclick="event.stopPropagation(); return true"
+                     onblur="cl_finishEditField(this)" 
+                     />
               <entity name="nbsp"/>
             </td>
+
             <td><var:string value="contact.mail" /><entity name="nbsp"/></td>
             <td>
               <var:string value="contact.telephonenumber" />