config.jelly 4.1 KB
Newer Older
1
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
2 3 4 5 6
	<f:block xmlns:local="local">
    <j:set var="groups" value="${descriptor.allGroups}"/>
    <d:taglib uri="local">
      <!-- generate one row for the sid name @sid -->
      <d:tag name="row">
K
kohsuke 已提交
7
        <td class="left-most">${title}</td>
8 9
        <j:forEach var="g" items="${groups}">
          <j:forEach var="p" items="${g.permissions}">
K
kohsuke 已提交
10
            <td width="*">
K
kohsuke 已提交
11 12 13 14 15
              <!--
                since '.' is handled in a special way, replace them by '-'
                '-' is not a part of Java identifier, so this transformation
                doesn't cause ambuguity.
               -->
K
kohsuke 已提交
16
              <f:checkbox name="${p.id.replace('.','-')}" checked="${instance.hasPermission(attrs.sid,p)}"/>
17 18 19
            </td>
          </j:forEach>
        </j:forEach>
K
kohsuke 已提交
20 21 22 23 24 25 26
        <td class="stop">
          <j:if test="${attrs.sid!='anonymous'}">
            <a href="#">
              <img alt="remove" src="${imagesURL}/16x16/stop.gif"/>
            </a>
          </j:if>
        </td>
27 28
      </d:tag>
    </d:taglib>
K
kohsuke 已提交
29 30
    <link rel="stylesheet" href="${h.getViewResource(descriptor,'table.css')}" type="text/css" />
    <table id="global-matrix-authorization-strategy-table" class="center-align" name="data" width="100%">
31

32
      <!-- The first row will show grouping -->
K
kohsuke 已提交
33
      <tr class="group-row">
34
        <td rowspan="2" class="pane-header blank">
35
          ${%User/group}
36
        </td>
37
        <j:forEach var="g" items="${groups}">
38
          <td class="pane-header" colspan="${g.size()}">
39
            ${g.title}
40
          </td>
41
        </j:forEach>
K
kohsuke 已提交
42
        <td rowspan="2" class="stop" />
43
      </tr>
44
      <!-- The second row for individual permission -->
K
kohsuke 已提交
45
      <tr class="caption-row">
46 47
        <j:forEach var="g" items="${groups}">
          <j:forEach var="p" items="${g.permissions}">
48
            <th class="pane">
49 50 51 52 53 54
              ${p.name}
            </th>
          </j:forEach>
        </j:forEach>
      </tr>

K
kohsuke 已提交
55 56
      <j:forEach var="sid" items="${instance.allSIDs}">
        <tr name="${sid}">
K
kohsuke 已提交
57
          <local:row title="${sid}" sid="${sid}"/>
K
kohsuke 已提交
58 59
        </tr>
      </j:forEach>
60
      <tr name="anonymous">
61
        <local:row sid="anonymous" title="${%Anonymous}" />
62 63
      </tr>

K
kohsuke 已提交
64

65
      <!-- template row to be used for adding a new row -->
K
kohsuke 已提交
66
      <j:set var="id" value="${h.generateId()}"/>
67 68 69
      <tr id="${id}" style="display:none">
        <local:row sid="${null}" />
      </tr>
70
    </table>
K
kohsuke 已提交
71
    <div style="margin-top:0.5em; margin-left: 2em;">
72
      ${%User/group to add}:
73
      <input type="text" id="${id}text" />
74
      <input type="button" value="${%Add}" id="${id}button"/>
75 76
    </div>
    <script>
K
kohsuke 已提交
77 78
      (function() {
        <!-- place master outside the DOM tree so that it won't creep into the submitted form -->
79
        var master = document.getElementById('${id}');
K
kohsuke 已提交
80 81
        var table = master.parentNode;
        table.removeChild(master);
K
kohsuke 已提交
82 83
      
        makeButton("${id}button", function (e) {
K
kohsuke 已提交
84 85 86 87 88 89 90 91 92 93 94
          <!-- when 'add' is clicked... -->
          var name = $$('${id}text').value;
          if(name=="") {
            alert("Please enter an user name or a group name");
            return;
          }
          if(findElementsBySelector(table,"TR").find(function(n){return n.getAttribute("name")==name;})!=null) {
            alert("Entry for '"+name+"' already exists");
            return;
          }

K
kohsuke 已提交
95 96 97 98 99
          var copy = document.importNode(master,true);
          copy.removeAttribute("id");
          copy.removeAttribute("style");
          copy.firstChild.innerHTML = name;
          copy.setAttribute("name",name);
K
kohsuke 已提交
100 101
          table.appendChild(copy);
          Behaviour.applySubtree(findAncestor(table,"TABLE"));
K
kohsuke 已提交
102 103
        });
      })();
K
kohsuke 已提交
104 105 106 107 108 109 110 111 112 113 114

      Behaviour.register({
        "#global-matrix-authorization-strategy-table TD.stop A" : function(e) {
          e.onclick = function() {
            var tr = findAncestor(this,"TR");
            tr.parentNode.removeChild(tr);
            return false;
          }
          e = null; <!-- avoid memory leak -->
        }
      });
115
    </script>
116 117
  </f:block>
</j:jelly>