Skip to content

Commit

Permalink
[JENKINS-68934] Extract inline JS for optional blocks in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed Jul 15, 2022
1 parent 85a48d0 commit 889df35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/main/resources/lib/form/checkbox.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ THE SOFTWARE.
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="onclick" deprecated="true" />
<st:attribute name="class" />
<st:attribute name="negative" />
<st:attribute name="readonly">
<st:attribute name="readonly" deprecated="true">
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:
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/resources/lib/form/optional-block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('input.optional-block-event-item').forEach(function(el) {
el.addEventListener('click', function(e) {
updateOptionalBlock(el, true);
});
});
});
3 changes: 2 additions & 1 deletion core/src/main/resources/lib/form/optionalBlock.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ THE SOFTWARE.
<div class="optionalBlock-container jenkins-form-item">
<div class="help-sibling tr optional-block-start row-group-start ${attrs.inline?'':'row-set-start'}" hasHelp="${attrs.help!=null}"><!-- this ID marks the beginning -->
<div class="jenkins-checkbox-help-wrapper">
<f:checkbox name="${attrs.name}" class="optional-block-control block-control" onclick="javascript:updateOptionalBlock(this,true)"
<st:adjunct includes="lib.form.optional-block"/>
<f:checkbox name="${attrs.name}" class="optional-block-control block-control optional-block-event-item"
negative="${attrs.negative}" checked="${attrs.checked}" field="${attrs.field}" title="${title}" />
<f:helpLink url="${attrs.help}" featureName="${title}"/>
</div>
Expand Down

0 comments on commit 889df35

Please sign in to comment.