[Bedework-commit] bedework r2077 - in trunk/deployment/webuser/webapp/resources/demoskins: default/default resources

svnadmin at bedework.org svnadmin at bedework.org
Thu Feb 26 17:50:05 EST 2009


Author: johnsa
Date: 2009-02-26 17:50:04 -0500 (Thu, 26 Feb 2009)
New Revision: 2077

Modified:
   trunk/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl
   trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkAccess.js
   trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkEventForm.js
Log:
refactoring access control widget: more to be done yet.

Modified: trunk/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl
===================================================================
--- trunk/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl	2009-02-26 06:04:14 UTC (rev 2076)
+++ trunk/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl	2009-02-26 22:50:04 UTC (rev 2077)
@@ -401,7 +401,8 @@
                   /bedework/page='attendeeRespond'">
       <script type="text/javascript" src="{$resourcesRoot}/resources/bedeworkPrefs.js">&#160;</script>
     </xsl:if>
-    <xsl:if test="/bedework/page='modCalendar'">
+    <xsl:if test="/bedework/page='modCalendar' or
+                  /bedework/page='modSchedulingPrefs'">
       <script type="text/javascript" src="{$resourcesRoot}/resources/bedeworkAccess.js">&#160;</script>
       <!-- initialize calendar acls, if present -->
       <xsl:if test="/bedework/currentCalendar/acl/ace">
@@ -7766,14 +7767,8 @@
 
   <xsl:template name="entityAccessForm">
     <xsl:param name="type"/><!-- optional: currently used for inbox and outbox to conditionally display scheduling access -->
-    <xsl:param name="method">2</xsl:param><!-- optional:
-      there are two methods of setting access
-      - method 1, the older method, uses a single request/response per principal
-      - method 2 constructs a javascript object that commits the entire ACL
-        structure in a single request
-      Both methods are currently supported.  Method two is now the default. -->
-    <xsl:param name="acl"/><!-- nodeset of entity acls used to initialize
-      javascript object. Required for method two. -->
+    <xsl:param name="acl"/><!-- required: nodeset of entity acls used to initialize javascript object. -->
+    <xsl:param name="outputId"/><!-- required: id of the current access block display to update -->
 
     <table cellpadding="0" id="shareFormTable" class="common">
       <tr>
@@ -7793,14 +7788,7 @@
               <input type="radio" value="unauth" name="whoType"/> unauthenticated<br/>
               <input type="radio" value="all" name="whoType"/> all users
             </p>
-            <xsl:choose>
-              <xsl:when test="$method = '2'">
-                <input type="button" name="updateACLs" value="add entry" onclick="bwAcl.update(this.form)"/>
-              </xsl:when>
-              <xsl:otherwise>
-                <input type="submit" name="submit" value="update access"/>
-              </xsl:otherwise>
-            </xsl:choose>
+            <input type="button" name="updateACLs" value="add entry" onclick="bwAcl.update(this.form,${id})"/>
           </div>
         </td>
         <td>
@@ -8029,137 +8017,11 @@
   </xsl:template>
 
   <xsl:template match="acl" mode="currentAccess">
-    <xsl:param name="action"/> <!-- required -->
-    <xsl:param name="calPathEncoded"/> <!-- optional (for entities) -->
-    <xsl:param name="guid"/> <!-- optional (for entities) -->
-    <xsl:param name="recurrenceId"/> <!-- optional (for entities) -->
-    <xsl:param name="what"/> <!-- optional (for scheduling only) -->
-    <xsl:param name="method">2</xsl:param> <!-- which method of access control
-      are we using: 1 (one request per pricipal) or 2 (set all with
-      javascript and send entire ACL to server) -->
     <h3>Current Access:</h3>
-    <table class="common scheduling" id="bwCurrentAccess">
-      <thead>
-        <tr>
-          <th>Entry</th>
-          <th>Access</th>
-          <th>Inherited from</th>
-          <th></th>
-        </tr>
-      </thead>
-      <tbody>
-        <xsl:for-each select="ace">
-          <xsl:variable name="who">
-            <xsl:choose>
-              <xsl:when test="invert">
-                <xsl:choose>
-                  <xsl:when test="invert/principal/href"><xsl:value-of select="normalize-space(invert/principal/href)"/></xsl:when>
-                  <xsl:when test="invert/principal/property"><xsl:value-of select="name(invert/principal/property/*)"/></xsl:when>
-                  <xsl:otherwise><xsl:value-of select="name(invert/principal/*)"/></xsl:otherwise>
-                </xsl:choose>
-              </xsl:when>
-              <xsl:otherwise>
-                <xsl:choose>
-                  <xsl:when test="principal/href"><xsl:value-of select="normalize-space(principal/href)"/></xsl:when>
-                  <xsl:when test="principal/property"><xsl:value-of select="name(principal/property/*)"/></xsl:when>
-                  <xsl:otherwise><xsl:value-of select="name(principal/*)"/></xsl:otherwise>
-                </xsl:choose>
-              </xsl:otherwise>
-            </xsl:choose>
-          </xsl:variable>
-          <xsl:variable name="whoType">
-            <xsl:choose>
-              <xsl:when test="contains($who,/bedework/syspars/userPrincipalRoot)">user</xsl:when>
-              <xsl:when test="contains($who,/bedework/syspars/groupPrincipalRoot)">group</xsl:when>
-              <xsl:when test="$who='authenticated'">auth</xsl:when>
-              <xsl:when test="$who='unauthenticated'">unauth</xsl:when>
-              <xsl:when test="$who='all'">all</xsl:when>
-              <xsl:when test="invert/principal/property/owner">other</xsl:when>
-              <xsl:when test="principal/property"><xsl:value-of select="name(principal/property/*)"/></xsl:when>
-              <xsl:when test="invert/principal/property"><xsl:value-of select="name(invert/principal/property/*)"/></xsl:when>
-              <xsl:otherwise></xsl:otherwise>
-            </xsl:choose>
-          </xsl:variable>
-          <xsl:variable name="shortWho">
-            <xsl:choose>
-              <xsl:when test="$whoType='user'"><xsl:value-of select="substring-after(substring-after($who,normalize-space(/bedework/syspars/userPrincipalRoot)),'/')"/></xsl:when>
-              <xsl:when test="$whoType='group'"><xsl:value-of select="substring-after(substring-after($who,normalize-space(/bedework/syspars/groupPrincipalRoot)),'/')"/></xsl:when>
-              <xsl:otherwise></xsl:otherwise> <!-- if not user or group, send no who -->
-            </xsl:choose>
-          </xsl:variable>
-          <tr>
-            <td>
-              <xsl:choose>
-                <xsl:when test="$whoType = 'user' or ($who = 'owner' and $whoType != 'other')">
-                  <img src="{$resourcesRoot}/resources/userIcon.gif" width="13" height="13" border="0" alt="user"/>
-                </xsl:when>
-                <xsl:otherwise>
-                  <img src="{$resourcesRoot}/resources/groupIcon.gif" width="13" height="13" border="0" alt="group"/>
-                </xsl:otherwise>
-              </xsl:choose>
-              <xsl:text> </xsl:text>
-              <xsl:choose>
-                <xsl:when test="$whoType = 'other'">
-                  anyone (other)
-                </xsl:when>
-                <xsl:when test="$shortWho != ''">
-                  <xsl:value-of select="$shortWho"/>
-                </xsl:when>
-                <xsl:otherwise>
-                  <xsl:value-of select="$who"/>
-                </xsl:otherwise>
-              </xsl:choose>
-            </td>
-            <td class="acls">
-              <xsl:if test="grant">
-                <span class="grant">
-                  <xsl:for-each select="grant/privilege/*">
-                    <xsl:value-of select="name(.)"/>
-                    <xsl:if test="position() != last()">, </xsl:if>
-                  </xsl:for-each>
-                </span><br/>
-              </xsl:if>
-              <xsl:if test="deny">
-                <span class="deny">
-                  <xsl:for-each select="deny/privilege/*">
-                    not-<xsl:value-of select="name(.)"/>
-                    <xsl:if test="position() != last()">, </xsl:if>
-                  </xsl:for-each>
-                </span>
-              </xsl:if>
-            </td>
-            <td>
-              <xsl:choose>
-                <xsl:when test="inherited">
-                  <xsl:value-of select="inherited/href"/>
-                </xsl:when>
-                <xsl:otherwise>
-                  Not inherited
-                </xsl:otherwise>
-              </xsl:choose>
-            </td>
-            <td>
-              <xsl:if test="not(inherited)">
-                <xsl:choose>
-                  <xsl:when test="$method = '2'">
-                    <!-- we are using javascript to update the form -->
-                    <xsl:variable name="rowPos" select="position()-1"/>
-                    <a href="javascript:bwAcl.deleteAce({$rowPos})" title="reset to default">
-                      <img src="{$resourcesRoot}/resources/trashIcon.gif" width="13" height="13" border="0" alt="reset to default"/>
-                    </a>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <a href="{$action}&amp;how=default&amp;what={$what}&amp;who={$shortWho}&amp;whoType={$whoType}&amp;calPath={$calPathEncoded}&amp;guid={$guid}&amp;recurrenceId={$recurrenceId}" title="reset to default">
-                      <img src="{$resourcesRoot}/resources/trashIcon.gif" width="13" height="13" border="0" alt="reset to default"/>
-                    </a>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </xsl:if>
-            </td>
-          </tr>
-        </xsl:for-each>
-      </tbody>
-    </table>
+    <div id="bwCurrentAccessWidget">&#160;</div>
+    <script type="text/javascript">
+      bwAcl.display("bwCurrentAccessWidget"); // display acls in the table
+    </script>
   </xsl:template>
 
   <!--==== SEARCH RESULT ====-->
@@ -8401,8 +8263,7 @@
     </xsl:choose>
   </xsl:template>
 
-  <!-- return string values to be loaded into javascript for access control
-       forms, method 2 -->
+  <!-- return string values to be loaded into javascript for access control forms -->
   <xsl:template match="ace" mode="initJS"><!--
   --><xsl:variable name="who"><!--
    --><xsl:choose>

Modified: trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkAccess.js
===================================================================
--- trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkAccess.js	2009-02-26 06:04:14 UTC (rev 2076)
+++ trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkAccess.js	2009-02-26 22:50:04 UTC (rev 2077)
@@ -54,7 +54,10 @@
 var denyStr = "deny"
 var allStr = "all";
 
-var deleteStr = "remove";
+var bwAclWidgetDeleteStr = "remove";
+var bwAclWidgetEntryStr = "Entry";
+var bwAclWidgetAccessStr = "Access";
+var bwAclWidgetInheritedStr = "Inherited from";
 
 // note that resourcesRoot is passed in from the html head section defined in the xslt
 var trashIcon = '<img src="' + resourcesRoot  + '/resources/trashIcon.gif" width="13" height="13" border="0" alt="remove"/>';
@@ -257,8 +260,7 @@
   }
 }
 
-// Gather up the how values on access form submission and set the how field
-// (method 1) or return the value (method 2).
+// Gather up the how values on access form submission and return the value.
 // If in "basic" mode:
 //   Set the value of how to the value of the basicHowItem radio button.
 // If in "advanced" mode:
@@ -266,10 +268,7 @@
 //   named after the howItem's value (e.g. "A","R","F","N", etc).
 //   The allow/deny flag contains the final values to be returned with
 //   the "-" switch if we set the value to deny (e.g. "A" or "-A", "R" or "-R").
-// Method: there are two methods used with this function; method one sets
-//   the "how" field in the form used to update a single principal.  Method
-//   two returns the assembled how string to the calling function.
-function setAccessHow(formObj,method) {
+function setAccessHow(formObj) {
   var howString = "";
   if (formObj.setappvar[0].checked == true) { // "basic" mode is selected
     for (i = 0; i < formObj.basicHowItem.length; i++) {
@@ -289,11 +288,7 @@
       }
     }
   }
-  if (method == 2) {
-    return howString;
-  } else {
-    formObj.how.value = howString;
-  }
+  return howString;
 }
 
 /* Information about a principal
@@ -434,19 +429,15 @@
   }
 
   this.equals = function(pr) {
-    //alert("this=" + this.toString() + " pr=" + pr.toString());
-
     if (this.whoType != pr.whoType) {
       return false;
     }
-
     return this.who == pr.who;
   }
 }
 
-/* METHOD TWO FUNCTIONS*/
-// Access Control Entry (ACE) object
-
+/* Access Control Entry (ACE) object
+ */
 function bwAce(who, whoType, how, inherited, invert) {
   this.principal = new bwPrincipal(who, whoType);
   this.how = how;
@@ -554,7 +545,8 @@
 
   // row: current row in table
   // aceI: index of the ace
-  this.toFormRow = function(row, aceI) {
+  // id: id of widget output block in the html
+  this.toFormRow = function(row, aceI, id) {
     var td_0 = row.insertCell(0);
     td_0.innerHTML = this.principal.format();
     var td_1 = row.insertCell(1);
@@ -562,7 +554,7 @@
     row.insertCell(2).appendChild(document.createTextNode(this.formatInherited()));
     var td_3 = row.insertCell(3);
     if (this.inherited == "") {
-      td_3.innerHTML = "<a href=\"javascript:bwAcl.deleteAce('" + aceI + "')\">" + trashIcon + " " + deleteStr + "</a>";
+      td_3.innerHTML = "<a href=\"javascript:bwAcl.deleteAce('" + aceI + "','" + id + "')\">" + trashIcon + " " + bwAclWidgetDeleteStr + "</a>";
     }
   }
 }
@@ -602,7 +594,7 @@
   }
 
   // Update the list - expects the browser form object
-  this.update = function(formObj) {
+  this.update = function(formObj,id) {
     // get the type of ace being set
     var type;
     for (i = 0; i < formObj.whoType.length; i++) {
@@ -619,7 +611,7 @@
     }
 
     // get the how string from the form
-    var how = setAccessHow(formObj, 2);
+    var how = setAccessHow(formObj);
 
     //alert("About to update who=" + formObj.who.value +
     //       "\ntype= " + type + "\nhow=" + how);
@@ -632,10 +624,10 @@
     formAcl.value = this.toXml();
 
     // redraw the display
-    this.display();
+    this.display(id);
   }
 
-  this.deleteAce = function(index) {
+  this.deleteAce = function(index,id) {
     var ace = aces[index];
     var replace = false;
 
@@ -658,27 +650,44 @@
     formAcl.value = this.toXml();
 
     // redraw the display
-    this.display();
+    this.display(id);
   }
 
-  // update the ACL table displayed on screen
-  this.display = function() {
+  // build the ACL widget displayed on screen in the given id
+  this.display = function(id) {
     try {
+
+      var aclWidget = document.getElementById(id);
+      aclWidget.innerHTML = "";
+
+      var bwCurrentAccess = document.createElement("table");
+      bwCurrentAccess.className = "common scheduling";
+      bwCurrentAccess.id = "bwCurrentAccess";
+      bwCurrentAccess.createTHead();
+      bwCurrAccessHead = bwCurrentAccess.tHead.insertRow(0);
+      bwCurrAccessHead.innerHTML = '<th>' + bwAclWidgetEntryStr + '</th>' +  '<th>' + bwAclWidgetAccessStr + '</th>' + '<th>' + bwAclWidgetInheritedStr + '</th><th></th>';
+      var bwCurrAccessTBody = document.createElement("tbody");
+      bwCurrentAccess.appendChild(bwCurrAccessTBody);
+
+      // finally, write the table back to the display
+      aclWidget.appendChild(bwCurrentAccess);
+
       // get the table body
       var aclTableBody = document.getElementById("bwCurrentAccess").tBodies[0];
 
       // remove existing rows
-      for (i = aclTableBody.rows.length - 1; i >= 0; i--) {
-        aclTableBody.deleteRow(i);
-      }
+      //for (i = aclTableBody.rows.length - 1; i >= 0; i--) {
+      //  aclTableBody.deleteRow(i);
+      //}
 
-      // recreate the table rows
+      // create the table rows
       for (var j = 0; j < aces.length; j++) {
         var curAce = aces[j];
         var tr = aclTableBody.insertRow(j);
 
-        curAce.toFormRow(tr, j);
+        curAce.toFormRow(tr, j, id);
       }
+
     } catch (e) {
       alert(e);
     }

Modified: trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkEventForm.js
===================================================================
--- trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkEventForm.js	2009-02-26 06:04:14 UTC (rev 2076)
+++ trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkEventForm.js	2009-02-26 22:50:04 UTC (rev 2077)
@@ -242,7 +242,7 @@
     setRecurrence(formObj);
   } // else we are editing an instance of a recurrence
   setBedeworkXProperties(formObj,submitter);
-  setAccessHow(formObj,1);
+  setAccessHow(formObj);
   //setAccessAcl(formObj);
 }
 /* Set dates based on jQuery widgets */



More information about the Bedework-commit mailing list