Hi, 

I'm trying to create a plugin with configuration in the jenkins manage 
system. 

When i tried to use global.jelly it always complained, and wanted to have 
config.jelly so i always use config.jelly online now. 

Anyway, basically i want to have a repeatable with add button that has a 
drop down menu for example with set of selections, once a selection is made 
a few other fields should either show up or get invisible, and on save and 
reload for config page it should have the items I've selected earlier to be 
preloaded.


Here is example of the jelly that i've created:

<f:entry title="Optional Fields">
    <f:repeatable var="optionalField" items="${instance.optionalFields}" 
name="optionalFields" varStatus="status">
        <script>
            document.getElementById('selector${status.index}').onchange = 
function() {
                var selectedValue = this.value;
                var repeatableFields = 
document.selectedValue("repeatable-fields_${status.index}");
                for (var i = 0; i &lt; repeatableFields.length; i++) {
                    if (selectedValue !== "" &amp;&amp; 
parseInt(selectedValue) &gt; 1) {
                        repeatableFields[i].style.display = 'block'; // 
Show the repeatable fields
                    } else {
                        repeatableFields[i].style.display = 'none'; // Hide 
the repeatable fields
                    }
                }
            };
        </script>

        <f:entry title="">
          <div align="right">
            <f:repeatableDeleteButton />
          </div>
        </f:entry>
         <f:entry title="Select Option" field="selectedValue">
           <select name="selectedValue" id="myDropdown${status.index + 1}" 
class="jenkins-select__input select">
            <option value="0">Select an option</option>
            <option value="1">Freestyle</option>
            <option value="2">Pipeline</option>
            <option value="3">Multibranch</option>
            <option value="4">Oragnization</option>
          </select>
        </f:entry>
        <div id="repeatable-fields_${status.index}" 
data-option="pipelinejobs" style="display: none;">
          <f:entry title="field1" help="">
            <f:textbox name="field1" value="${optionalField.field1}" 
title="Field 1" />
          </f:entry>
          <f:entry title="field2" help="">
            <f:textbox name="field2"  value="${optionalField.field2}" 
title="Field 2" />
          </f:entry>
          <f:entry title="field3" help="">
            <f:textbox name="field3"  value="${optionalField.field3}" 
title="Field 1"  />
          </f:entry>
          <f:checkbox name="scriptedPipeline" title="Script pipeline 
enabled" class="hidden-checkbox" />
          <f:checkbox name="enableScm" title="Scm enabled" 
class="hidden-checkbox" />
        </div>
        <f:checkbox id="failBuild${status.index + 1}" name="failBuild" 
title="Fail Build" />
    </f:repeatable>


So first of all the varStatus doesn't really change and it is kind of 
sticky to 1 always, also when loading page it gets null. 

Just loading the configuration page gives this 
[image: image1.png]

Trying to add an item would show this 
[image: image2.png]
The selection items are really there however when selecting any nothing 
change. I've tried to also use onChange to use a function in the select tag 
but still was not sending the status correctly. 

Is this the correct way of doing it? Or there is another way. 

Also the reloading of page the previous selected item isn't loaaded again 
even if the selection value was saved on disk correctly.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/dfeeb65e-33fc-4409-89cd-3749633379f0n%40googlegroups.com.

Reply via email to