Skip to content
Permalink
Browse files
Merge branch 'master' into JENKINS-26122
* master:
  Always produce unique element and function names. Avoids a bug when switching between CpsFlowDefinition and CpsScmFlowDefinition.
  Allow the location of the element holding Snippetizer to be passed in.

Originally-Committed-As: a5c5bf6fee6a306371c0b5c87f5e35a356f8fa85
  • Loading branch information
tfennelly committed Mar 7, 2015
2 parents 9f93fe0 + faafbb9 commit f36312e42c21dc4d2aedb08a0e5369ccd28ee630
Showing with 6 additions and 5 deletions.
  1. +6 −5 cps/src/main/resources/org/jenkinsci/plugins/workflow/cps/Snippetizer/block.jelly
@@ -50,20 +50,21 @@ THE SOFTWARE.
</f:dropdownListBlock>
</j:forEach>
</f:dropdownList>
<j:set var="id" value="${h.generateId()}"/>
<f:block>
<input type="button" value="Generate Groovy" onclick="handlePrototype(); return false" class="submit-button primary"/>
<f:textarea id="prototypeText" readonly="true"/>
<input type="button" value="Generate Groovy" onclick="handlePrototype_${id}(); return false" class="submit-button primary"/>
<f:textarea id="prototypeText_${id}" readonly="true"/>
</f:block>
<script>
function handlePrototype() {
function handlePrototype_${id}() {
buildFormTree(document.forms.config);
// TODO JSON.stringify fails in some circumstances: https://gist.github.com/jglick/70ec4b15c1f628fdf2e9 due to Array.prototype.toJSON
var json = Object.toJSON(JSON.parse(document.forms.config.elements.json.value).definition.snippetizer.prototype);
var json = Object.toJSON(JSON.parse(${configFormJS ?: 'document.forms.config'}.elements.json.value).${definitionJS ?: 'definition'}.snippetizer.prototype);
new Ajax.Request('${rootURL}/${it.GENERATE_URL}', {
method: 'POST',
parameters: {json: json},
onSuccess: function(r) {
document.getElementById('prototypeText').value = r.responseText;
document.getElementById('prototypeText_${id}').value = r.responseText;
}
});
}

0 comments on commit f36312e

Please sign in to comment.