From 23a9fea26cc3517e8f78163da40aff8ef4b601c2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 25 Sep 2014 16:43:17 +0200 Subject: [PATCH] Remove the ability to add multiple jobset input alternatives Now each jobset input has exactly one value. (Actually, adding multiple values was already broken, so all this does is clean up the UI...) --- src/lib/Hydra/Controller/Jobset.pm | 19 ++++------- src/lib/Hydra/Helper/CatalystUtils.pm | 3 +- src/root/edit-jobset.tt | 47 +++++++++------------------ 3 files changed, 25 insertions(+), 44 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 0c53a1cf..a56af5a8 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -244,25 +244,20 @@ sub updateJobset { foreach my $name (keys %{$c->stash->{params}->{inputs}}) { my $inputData = $c->stash->{params}->{inputs}->{$name}; my $type = $inputData->{type}; - my $values = $inputData->{values}; + my $value = $inputData->{value}; my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0; error($c, "Invalid input name ‘$name’.") unless $name =~ /^[[:alpha:]][\w-]*$/; error($c, "Invalid input type ‘$type’.") unless defined $c->stash->{inputTypes}->{$type}; - my $input = $jobset->jobsetinputs->create({ - name => $name, - type => $type, - emailresponsible => $emailresponsible + my $input = $jobset->jobsetinputs->create( + { name => $name, + type => $type, + emailresponsible => $emailresponsible }); - # Set the values for this input. - my @values = ref($values) eq 'ARRAY' ? @{$values} : ($values); - my $altnr = 0; - foreach my $value (@values) { - $value = checkInputValue($c, $name, $type, $value); - $input->jobsetinputalts->create({altnr => $altnr++, value => $value}); - } + $value = checkInputValue($c, $name, $type, $value); + $input->jobsetinputalts->create({altnr => 0, value => $value}); } } diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index e3ebae80..82fe939c 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -22,7 +22,7 @@ our @EXPORT = qw( sendEmail paramToList backToReferer - $pathCompRE $relPathRE $relNameRE $projectNameRE $jobsetNameRE $jobNameRE $systemRE $userNameRE + $pathCompRE $relPathRE $relNameRE $projectNameRE $jobsetNameRE $jobNameRE $systemRE $userNameRE $inputNameRE @buildListColumns parseJobsetName showJobName @@ -235,6 +235,7 @@ Readonly our $jobsetNameRE => "(?:[A-Za-z_][A-Za-z0-9-_\.]*)"; Readonly our $jobNameRE => "(?:$attrNameRE(?:\\.$attrNameRE)*)"; Readonly our $systemRE => "(?:[a-z0-9_]+-[a-z0-9_]+)"; Readonly our $userNameRE => "(?:[a-z][a-z0-9_\.]*)"; +Readonly our $inputNameRE => "(?:[A-Za-z_][A-Za-z0-9-_]*)"; sub parseJobsetName { diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt index 51775fdf..b860573d 100644 --- a/src/root/edit-jobset.tt +++ b/src/root/edit-jobset.tt @@ -2,28 +2,25 @@ [% PROCESS common.tt %] [% USE format %] -[% BLOCK renderJobsetInputAlt %] - - alt.value, name => name) %]/> -
-[% END %] - [% BLOCK renderJobsetInput %] + + input.name) %]/> [% INCLUDE renderSelection curValue=input.type param="$baseName-type" options=inputTypes %] - - [% FOREACH alt IN input.search_related('jobsetinputalts', {}, { order_by => 'altnr' }) %] - - [% INCLUDE renderJobsetInputAlt alt=alt name="$baseName-values" %] - + + [% alt = input.search_related('jobsetinputalts', {altnr => 0}) %] + alt.value, id => "$baseName-value", name => "$baseName-value") %]/> + [% IF input.jobsetinputalts_rs.count > 1 %] +
Warning: This input had more + than one value. This is no longer supported. The additional + values have been removed.
[% END %] - [% IF edit %][% END %] @@ -34,7 +31,7 @@ [% BLOCK renderJobsetInputs %] - + [% FOREACH input IN jobset.jobsetinputs %] @@ -151,10 +148,6 @@ [% INCLUDE renderJobsetInput input="" extraClass="template" id="input-template" baseName="input-template" %]
Input nameTypeValuesNotify committers
Input nameTypeValueNotify committers
- -