forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00eac4f
commit 5baf1be
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
|
||
<?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"> | ||
<st:documentation> | ||
<input type="checkbox"> tag that takes true/false for @checked, which is more Jelly friendly. | ||
|
||
<st:attribute name="name" /> | ||
<st:attribute name="checked" /> | ||
<st:attribute name="value" /> | ||
<st:attribute name="json"> | ||
Normally, the submitted JSON will be boolean indicating whether the checkbox was checked or not. | ||
This is sometimes inconvenient if you have a UI that lets user select a subset of a set. | ||
If this attribute is present, the submitted JSON will have this as a string value if the checkbox is checked, | ||
and none otherwise, making the subset selection easier. | ||
</st:attribute> | ||
<st:attribute name="default"> | ||
The default value of the check box, in case both @checked and @instance are null. | ||
If this attribute is unspecified or null, it defaults to unchecked, otherwise checked. | ||
</st:attribute> | ||
<st:attribute name="id" /> | ||
<st:attribute name="onclick" /> | ||
<st:attribute name="class" /> | ||
<st:attribute name="negative" /> | ||
<st:attribute name="readonly"> | ||
If set to true, this will take precedence over the onclick attribute and prevent the state of the checkbox from being changed. | ||
|
||
Note: if you want an actual read only checkbox then add: | ||
<j:set var="readOnlyMode" value="true"/> inside your entry tag | ||
See https://www.jenkins.io/doc/developer/views/read-only/#enabling-read-only-view-support | ||
</st:attribute> | ||
<st:attribute name="field"> | ||
Used for databinding. TBD. | ||
</st:attribute> | ||
<st:attribute name="title"> | ||
If specified, this human readable text will follow the checkbox, and clicking this text also | ||
toggles the checkbox. | ||
</st:attribute> | ||
<st:attribute name="tooltip"> | ||
Used as tooltip of the checkbox, and, if a title is specified, of the title | ||
</st:attribute> | ||
</st:documentation> | ||
<f:prepareDatabinding /> | ||
<j:set var="name" value="${attrs.name ?: '_.'+attrs.field}"/> | ||
<j:set var="default" value="${attrs.default ?: false}"/> | ||
<j:set var="value" value="${attrs.checked ?: instance[attrs.field] ?: default}"/> | ||
|
||
<span class="jenkins-toggle-switch"> | ||
<input type="checkbox" | ||
name="${name}" | ||
value="${attrs.value}" | ||
title="${attrs.tooltip}" | ||
onclick="${attrs.readonly=='true' ? 'return false;' : attrs.onclick}" | ||
id="${attrs.id}" | ||
class="${attrs.class} ${attrs.negative!=null ? 'negative' : null} ${attrs.checkUrl!=null?'validated':''}" | ||
checkUrl="${attrs.checkUrl}" | ||
checkDependsOn="${attrs.checkDependsOn}" json="${attrs.json}" | ||
disabled="${readOnlyMode ? 'true' : null}" | ||
checked="${value ? 'true' : null}"/> | ||
<label class="attach-previous">${attrs.title}</label> | ||
<j:if test="${attrs.description != null and !attrs.description.trim().isEmpty()}"> | ||
<span class="jenkins-toggle-switch__description">${attrs.description}</span> | ||
</j:if> | ||
</span> | ||
</j:jelly> |