Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into JENKINS-26122
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
tfennelly committed Mar 7, 2015
2 parents a823924 + bb6a526 commit a5c5bf6
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -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;
}
});
}
Expand Down

0 comments on commit a5c5bf6

Please sign in to comment.