This commit is contained in:
Eelco Dolstra 2008-11-17 15:31:19 +00:00
parent 9933dd2f27
commit ab2b40239f
3 changed files with 88 additions and 47 deletions

View file

@ -106,6 +106,8 @@ sub updateProject {
$jobset->nixexprinput($nixExprInput); $jobset->nixexprinput($nixExprInput);
$jobset->update; $jobset->update;
} }
my %inputNames;
# Process the inputs of this jobset. # Process the inputs of this jobset.
foreach my $param (keys %{$c->request->params}) { foreach my $param (keys %{$c->request->params}) {
@ -122,8 +124,14 @@ sub updateProject {
$inputType eq "svn" || $inputType eq "cvs" || $inputType eq "tarball" || $inputType eq "svn" || $inputType eq "cvs" || $inputType eq "tarball" ||
$inputType eq "string" || $inputType eq "path"; $inputType eq "string" || $inputType eq "path";
$inputNames{$inputName} = 1;
my $input; my $input;
if ($baseName2 =~ /^\d+$/) { # numeric base name is auto-generated, i.e. a new entry if ($baseName2 =~ /^\d+$/) { # numeric base name is auto-generated, i.e. a new entry
$input = $jobset->jobsetinputs->create(
{ name => $inputName
, type => $inputType
});
} else { # it's an existing jobset } else { # it's an existing jobset
$input = ($jobset->jobsetinputs->search({name => $baseName2}))[0]; $input = ($jobset->jobsetinputs->search({name => $baseName2}))[0];
die unless defined $input; die unless defined $input;
@ -144,6 +152,12 @@ sub updateProject {
$input->jobsetinputalts->create({altnr => $altnr++, value => $value}); $input->jobsetinputalts->create({altnr => $altnr++, value => $value});
} }
} }
# Get rid of deleted inputs/
my @inputs = $jobset->jobsetinputs->all;
foreach my $input (@inputs) {
$input->delete unless defined $inputNames{$input->name};
}
} }
# Get rid of deleted jobsets, i.e., ones that are no longer submitted in the parameters. # Get rid of deleted jobsets, i.e., ones that are no longer submitted in the parameters.

View file

@ -184,6 +184,10 @@ tr.runningJob {
display: none; display: none;
} }
.template {
display: none;
}
div.jobset { div.jobset {
border: solid black 1px; border: solid black 1px;
-moz-border-radius: 1em; -moz-border-radius: 1em;

View file

@ -27,9 +27,51 @@
[% END %] [% END %]
[% BLOCK renderInput %]
<tr class="input [% extraClass %]" id="[% id %]">
[% IF edit %]
<td>
[% IF edit %]<a href="javascript:" onclick='$(this).parents(".input").remove()'>[X]</a>[% END -%]
</td>
[% END %]
<td>
<tt>[% INCLUDE maybeEditString param="$baseName-name" value=input.name extraClass="shortString" %]</tt>
</td>
<td>
[% IF edit %]
<select id="[% "$baseName-type" %]" name="[% "$baseName-type" %]">
[% INCLUDE renderInputTypeOption value=input.type type="svn" %]
[% INCLUDE renderInputTypeOption value=input.type type="cvs" %]
[% INCLUDE renderInputTypeOption value=input.type type="tarball" %]
[% INCLUDE renderInputTypeOption value=input.type type="string" %]
[% INCLUDE renderInputTypeOption value=input.type type="path" %]
</select>
[% ELSE %]
[% INCLUDE renderInputType type=input.type %]
[% END %]
</td>
<td class="inputalts" id="[% baseName %]">
[% FOREACH alt IN input.jobsetinputalts -%]
<tt class="inputalt">
[% IF input.type == "string" && !edit %]
"[% HTML.escape(alt.value) %]"
[% ELSE %]
[% INCLUDE maybeEditString param="$baseName-values" value=alt.value %]
[% IF edit %]<a href="javascript:" onclick='$(this).parents(".inputalt").remove()'>[X]</a>[% END %]
[% END %]
</tt>
[% END %]
[% IF edit %]<a href="javascript:" class="add-inputalt">[+]</a>[% END %]
</td>
</tr>
[% END %]
[% BLOCK renderJobset %] [% BLOCK renderJobset %]
<div class="jobset[% IF edit %] jobset-edit[% END %]"> <div class="jobset[% IF edit %] jobset-edit[% END %]" id="[% "jobset-$baseName" %]">
<h3>[% IF jobset %]Jobset <tt>[% jobset.name %]</tt>[% ELSE %]New jobset[% END %]</h3> <h3>[% IF jobset %]Jobset <tt>[% jobset.name %]</tt>[% ELSE %]New jobset[% END %]</h3>
@ -58,51 +100,16 @@
<h4>Inputs</h4> <h4>Inputs</h4>
[% IF edit %] [% IF edit %]
<p><button onclick='$(this).parents(".jobset").remove()'>Add a new input</button></p> <p><button class="add-input">Add a new input</button></p>
[% END %] [% END %]
<table class="tablesorter"> <table class="tablesorter">
<thead> <thead>
<tr>[% IF edit %]<th></th>[% END %]<th>Input name</th><th>Type</th><th>Values</th></tr> <tr>[% IF edit %]<th></th>[% END %]<th>Input name</th><th>Type</th><th>Values</th></tr>
</thead> </thead>
<tbody> <tbody class="inputs">
[% FOREACH input IN jobset.jobsetinputs -%] [% FOREACH input IN jobset.jobsetinputs -%]
<tr class="input"> [% INCLUDE renderInput input=input baseName="jobset-$baseName-input-$input.name" %]
[% IF edit %]
<td>
[% IF edit %]<a href="javascript:" onclick='$(this).parents(".input").remove()'>[X]</a>[% END -%]
</td>
[% END %]
<td>
<tt>[% INCLUDE maybeEditString param="jobset-$baseName-input-$input.name-name" value=input.name extraClass="shortString" %]</tt>
</td>
<td>
[% IF edit %]
<select name="[% "jobset-$baseName-input-$input.name-type" %]">
[% INCLUDE renderInputTypeOption value=input.type type="svn" %]
[% INCLUDE renderInputTypeOption value=input.type type="cvs" %]
[% INCLUDE renderInputTypeOption value=input.type type="tarball" %]
[% INCLUDE renderInputTypeOption value=input.type type="string" %]
[% INCLUDE renderInputTypeOption value=input.type type="path" %]
</select>
[% ELSE %]
[% INCLUDE renderInputType type=input.type %]
[% END %]
</td>
<td class="inputalts" id="[% "jobset-$baseName-input-$input.name" %]">
[% FOREACH alt IN input.jobsetinputalts -%]
<tt class="inputalt">
[% IF input.type == "string" && !edit %]
"[% HTML.escape(alt.value) %]"
[% ELSE %]
[% INCLUDE maybeEditString param="jobset-$baseName-input-$input.name-values" value=alt.value %]
[% IF edit %]<a href="javascript:" onclick='$(this).parents(".inputalt").remove()'>[X]</a>[% END %]
[% END %]
</tt>
[% END %]
[% IF edit %]<a href="javascript:" class="addinputalt">[+]</a>[% END %]
</td>
</tr>
[% END %] [% END %]
</tbody> </tbody>
</table> </table>
@ -160,6 +167,10 @@
[% INCLUDE renderJobset jobset="" baseName="template" %] [% INCLUDE renderJobset jobset="" baseName="template" %]
</div> </div>
<table class="template"> <!-- dummy wrapper needed because “hidden” trs are visible anyway -->
[% INCLUDE renderInput input="" extraClass="template" id="input-template" baseName="input-template" %]
</table>
<tt id="inputalt-template" class="inputalt template"> <tt id="inputalt-template" class="inputalt template">
<input type="text" class="string" /> <input type="text" class="string" />
<a href="javascript:" onclick='$(this).parents(".inputalt").remove()'>[X]</a> <a href="javascript:" onclick='$(this).parents(".inputalt").remove()'>[X]</a>
@ -171,17 +182,29 @@
$("#add-jobset").click(function() { $("#add-jobset").click(function() {
var newid = "jobset-" + id++; var newid = "jobset-" + id++;
$("#jobset-template").clone(true).attr("id", newid).insertAfter($("#jobset-template")).slideDown("fast"); var x = $("#jobset-template").clone(true).attr("id", newid).insertAfter($("#jobset-template")).slideDown("fast");
$("#jobset-template-name", $("#" + newid)).attr("name", newid + "-name"); $("#jobset-template", x).attr("id", newid);
$("#jobset-template-description", $("#" + newid)).attr("name", newid + "-description"); $("#jobset-template-name", x).attr("name", newid + "-name");
$("#jobset-template-nixexprpath", $("#" + newid)).attr("name", newid + "-nixexprpath"); $("#jobset-template-description", x).attr("name", newid + "-description");
$("#jobset-template-nixexprinput", $("#" + newid)).attr("name", newid + "-nixexprinput"); $("#jobset-template-nixexprpath", x).attr("name", newid + "-nixexprpath");
$("#jobset-template-nixexprinput", x).attr("name", newid + "-nixexprinput");
return false; return false;
}); });
$(".addinputalt").click(function() { $(".add-input").click(function() {
var x = $("#inputalt-template").clone(true).insertBefore($(this)).show(); var jobset = $(this).parents(".jobset");
$("input", x).attr("name", x.parent(".inputalts").attr("id") + "-values"); var inputid = jobset.attr("id");
var newid = inputid + "-input-" + id++;
var x = $("#input-template").clone(true).attr("id", "").appendTo($(".inputs", jobset)).show();
$("#input-template-name", x).attr("name", newid + "-name");
$("#input-template-type", x).attr("name", newid + "-type");
$("#input-template", x).attr("id", newid);
return false;
});
$(".add-inputalt").click(function() {
var x = $("#inputalt-template").clone(true).insertBefore($(this)).attr("id", "").show();
$("input", x).attr("name", x.parents(".inputalts").attr("id") + "-values");
}); });
}); });
</script> </script>