Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-60866] Extract inline JS for optional blocks in configuration #6852

Merged
merged 3 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" />
daniel-beck marked this conversation as resolved.
Show resolved Hide resolved
<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
2 changes: 1 addition & 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,7 @@ 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)"
<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
6 changes: 6 additions & 0 deletions war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,12 @@ function rowvgStartEachRow(recursive,f) {
};
});

Behaviour.specify("INPUT.optional-block-event-item", "input-optional-block-event-item", ++p, function(e) {
e.addEventListener('click', function() {
updateOptionalBlock(e, true);
});
});

Behaviour.specify("TR.row-set-end,DIV.tr.row-set-end", "tr-row-set-end-div-tr-row-set-end", ++p, function(e) { // see rowSet.jelly and optionalBlock.jelly
// figure out the corresponding start block
e = $(e);
Expand Down