From ab2b40239fb187216c830001fecdb9d4ed7f0bcf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 17 Nov 2008 15:31:19 +0000 Subject: [PATCH] --- .../lib/HydraFrontend/Controller/Root.pm | 14 +++ src/HydraFrontend/root/hydra.css | 4 + src/HydraFrontend/root/project.tt | 117 +++++++++++------- 3 files changed, 88 insertions(+), 47 deletions(-) diff --git a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm index 57eb14c8..65c7453f 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm @@ -106,6 +106,8 @@ sub updateProject { $jobset->nixexprinput($nixExprInput); $jobset->update; } + + my %inputNames; # Process the inputs of this jobset. foreach my $param (keys %{$c->request->params}) { @@ -122,8 +124,14 @@ sub updateProject { $inputType eq "svn" || $inputType eq "cvs" || $inputType eq "tarball" || $inputType eq "string" || $inputType eq "path"; + $inputNames{$inputName} = 1; + my $input; 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 $input = ($jobset->jobsetinputs->search({name => $baseName2}))[0]; die unless defined $input; @@ -144,6 +152,12 @@ sub updateProject { $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. diff --git a/src/HydraFrontend/root/hydra.css b/src/HydraFrontend/root/hydra.css index 09db72b7..eb2fdede 100644 --- a/src/HydraFrontend/root/hydra.css +++ b/src/HydraFrontend/root/hydra.css @@ -184,6 +184,10 @@ tr.runningJob { display: none; } +.template { + display: none; +} + div.jobset { border: solid black 1px; -moz-border-radius: 1em; diff --git a/src/HydraFrontend/root/project.tt b/src/HydraFrontend/root/project.tt index 430c7d62..4ac0b3fa 100644 --- a/src/HydraFrontend/root/project.tt +++ b/src/HydraFrontend/root/project.tt @@ -27,9 +27,51 @@ [% END %] +[% BLOCK renderInput %] + + + [% IF edit %] + + [% IF edit %][X][% END -%] + + [% END %] + + [% INCLUDE maybeEditString param="$baseName-name" value=input.name extraClass="shortString" %] + + + [% IF edit %] + + [% ELSE %] + [% INCLUDE renderInputType type=input.type %] + [% END %] + + + [% FOREACH alt IN input.jobsetinputalts -%] + + [% IF input.type == "string" && !edit %] + "[% HTML.escape(alt.value) %]" + [% ELSE %] + [% INCLUDE maybeEditString param="$baseName-values" value=alt.value %] + [% IF edit %][X][% END %] + [% END %] + + [% END %] + [% IF edit %][+][% END %] + + + +[% END %] + + [% BLOCK renderJobset %] -
+

[% IF jobset %]Jobset [% jobset.name %][% ELSE %]New jobset[% END %]

@@ -58,51 +100,16 @@

Inputs

[% IF edit %] -

+

[% END %] [% IF edit %][% END %] - + [% FOREACH input IN jobset.jobsetinputs -%] - - [% IF edit %] - - [% END %] - - - - + [% INCLUDE renderInput input=input baseName="jobset-$baseName-input-$input.name" %] [% END %]
Input nameTypeValues
- [% IF edit %][X][% END -%] - - [% INCLUDE maybeEditString param="jobset-$baseName-input-$input.name-name" value=input.name extraClass="shortString" %] - - [% IF edit %] - - [% ELSE %] - [% INCLUDE renderInputType type=input.type %] - [% END %] - - [% FOREACH alt IN input.jobsetinputalts -%] - - [% IF input.type == "string" && !edit %] - "[% HTML.escape(alt.value) %]" - [% ELSE %] - [% INCLUDE maybeEditString param="jobset-$baseName-input-$input.name-values" value=alt.value %] - [% IF edit %][X][% END %] - [% END %] - - [% END %] - [% IF edit %][+][% END %] -
@@ -160,6 +167,10 @@ [% INCLUDE renderJobset jobset="" baseName="template" %]
+ + [% INCLUDE renderInput input="" extraClass="template" id="input-template" baseName="input-template" %] +
+ [X] @@ -171,17 +182,29 @@ $("#add-jobset").click(function() { var newid = "jobset-" + id++; - $("#jobset-template").clone(true).attr("id", newid).insertAfter($("#jobset-template")).slideDown("fast"); - $("#jobset-template-name", $("#" + newid)).attr("name", newid + "-name"); - $("#jobset-template-description", $("#" + newid)).attr("name", newid + "-description"); - $("#jobset-template-nixexprpath", $("#" + newid)).attr("name", newid + "-nixexprpath"); - $("#jobset-template-nixexprinput", $("#" + newid)).attr("name", newid + "-nixexprinput"); + var x = $("#jobset-template").clone(true).attr("id", newid).insertAfter($("#jobset-template")).slideDown("fast"); + $("#jobset-template", x).attr("id", newid); + $("#jobset-template-name", x).attr("name", newid + "-name"); + $("#jobset-template-description", x).attr("name", newid + "-description"); + $("#jobset-template-nixexprpath", x).attr("name", newid + "-nixexprpath"); + $("#jobset-template-nixexprinput", x).attr("name", newid + "-nixexprinput"); return false; }); - $(".addinputalt").click(function() { - var x = $("#inputalt-template").clone(true).insertBefore($(this)).show(); - $("input", x).attr("name", x.parent(".inputalts").attr("id") + "-values"); + $(".add-input").click(function() { + var jobset = $(this).parents(".jobset"); + 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"); }); });