Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 039f95d209ff6dbf9ac6b1345b299fad009f8ef2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!-- **************************************************************************
#
# Copyright  (c) 2004-2011 Oracle Corporation.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors: 
#
#    Kohsuke Kawaguchi, Nikita Levyankov
#        
#
#************************************************************************** --> 


<?jelly escape-by-default='true'?>
<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" xmlns:local="local">
  <st:documentation>
    Outer most tag for creating a heterogeneous list, where the user can choose arbitrary number of
    arbitrary items from the given list of descriptors, and configure them independently.

    The submission can be data-bound into List&lt;T> where T is the common base type for the describable instances.
    
    <st:attribute name="name" use="required">
      form name that receives an array for all the items in the heterogeneous list.
    </st:attribute>
    <st:attribute name="items" use="required" type="java.util.Collection">
      existing items to be displayed. Something iterable, such as array or collection.
    </st:attribute>
    <st:attribute name="descriptors" use="required">
      all types that the user can add.
    </st:attribute>
    <st:attribute name="addCaption">
      caption of the 'add' button.
    </st:attribute>
    <st:attribute name="deleteCaption">
      caption of the 'delete' button.
    </st:attribute>
    <st:attribute name="targetType">
      the type for which descriptors will be configured. Defaults to ${it.class} (optional)
    </st:attribute>
    <st:attribute name="hasHeader">
      For each item, add a caption from descriptor.getDisplayName().
      This also activates drag&amp;drop (where the header is a grip), and help text support.
    </st:attribute>
    <st:attribute name="isPropertyOverridden">
      if present and true - value is overridden
    </st:attribute>
    <st:attribute name="resetUrl">
      If present, Redo icon will rendered and Reset will be available.
    </st:attribute>
  </st:documentation>
  <d:taglib uri="local">
    <d:tag name="body">
      <table style="width:100%">
        <j:set var="help" value="${descriptor.helpFile}" />
        <j:if test="${hasHeader}">
          <tr>
            <td colspan="3">
              <div class="dd-handle">
                <b>${descriptor.displayName}</b>
              </div>
            </td>
            <j:if test="${help!=null}">
              <td>
                <a href="#" class="help-button" helpURL="${rootURL}${help}"><img src="${imagesURL}/16x16/help.png" alt="[help]"/></a>
              </td>
            </j:if>
          </tr>
          <!-- TODO: help support is unintuitive; people should be able to see help from drop-down menu -->
          <j:if test="${help!=null}">
            <f:helpArea />
          </j:if>
        </j:if>
        <!-- optional added to keep from breaking page rendering when
        a descriptor doesn't have a config.jelly. -->
        <st:include from="${descriptor}"
                    page="${descriptor.configPage}" optional="true" />
        <f:block>
          <div align="right">
            <input type="hidden" name="stapler-class" value="${descriptor.clazz.name}" />
            <f:repeatableDeleteButton value="${attrs.deleteCaption}" />
          </div>
        </f:block>
      </table>
      <input type="hidden" name="kind" value="${descriptor.class.name}" />
    </d:tag>
  </d:taglib>
   <j:if test="${attrs.isPropertyOverridden==null}">
    <j:set target="${attrs}" property="isPropertyOverridden" value="false"/>
  </j:if>
  <j:set var="targetType" value="${attrs.targetType?:it.class}"/>
  <j:if test="${attrs.isPropertyOverridden and !empty(attrs.resetUrl)}">
    <div class="hetero-list-reset">
      <a href="#" class="reset-button" resetURL="${resetUrl}">
        <img src="${imagesURL}/16x16/undo.png" alt="Reset ${title}"/>
      </a>
    </div>
  </j:if>
  <div class="hetero-list-container${hasHeader?' with-drag-drop':''}${attrs.isPropertyOverridden? ' modified' :''}">
    <!-- display existing items -->
    <j:forEach var="i" items="${attrs.items}">
      <j:set var="descriptor" value="${i.descriptor}" />
      <j:set var="instance" value="${i}" />
      <div name="${attrs.name}" class="repeated-chunk">
        <local:body deleteCaption="${attrs.deleteCaption}" />
      </div>
    </j:forEach>

    <div class="repeatable-insertion-point" />
    <div class="prototypes to-be-removed">
      <!-- render one prototype for each type -->
      <j:set var="instance" value="${null}" />
      <j:forEach var="descriptor" items="${attrs.descriptors}" varStatus="loop">
        <div name="${attrs.name}" title="${descriptor.displayName}" tooltip="${descriptor.tooltip}">
          <local:body deleteCaption="${attrs.deleteCaption}" />
        </div>
      </j:forEach>
    </div>

    <div>
      <input type="button" value="${attrs.addCaption?:'%Add'}" class="hetero-list-add" />
    </div>
  </div>
</j:jelly>

Back to the top