From d9f6e662d8b9167abac6ae2852f631235e8570fa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 Feb 2013 01:12:57 +0100 Subject: [PATCH] Split viewing and editing a project --- src/lib/Hydra/Controller/Project.pm | 4 +- src/root/common.tt | 9 + src/root/edit-project.tt | 57 ++++++ src/root/jobset.tt | 6 +- src/root/project.tt | 292 ++++++++++++---------------- 5 files changed, 191 insertions(+), 177 deletions(-) create mode 100644 src/root/edit-project.tt diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index 36556054..8cdd912b 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -34,7 +34,7 @@ sub edit : Chained('project') PathPart Args(0) { requireProjectOwner($c, $c->stash->{project}); - $c->stash->{template} = 'project.tt'; + $c->stash->{template} = 'edit-project.tt'; $c->stash->{edit} = 1; } @@ -99,7 +99,7 @@ sub create : Path('/create-project') { requireMayCreateProjects($c); - $c->stash->{template} = 'project.tt'; + $c->stash->{template} = 'edit-project.tt'; $c->stash->{create} = 1; $c->stash->{edit} = 1; } diff --git a/src/root/common.tt b/src/root/common.tt index 542a03c3..1e60cd01 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -236,6 +236,15 @@ BLOCK maybeEditString; END; +BLOCK editString; + IF edit %] + param, name => param, value => value) %] /> + [% ELSE; + HTML.escape(value); + END; +END; + + BLOCK renderFullBuildLink; INCLUDE renderFullJobNameOfBuild build=build %] build [% build.id %][% END; diff --git a/src/root/edit-project.tt b/src/root/edit-project.tt new file mode 100644 index 00000000..d87cd457 --- /dev/null +++ b/src/root/edit-project.tt @@ -0,0 +1,57 @@ +[% WRAPPER layout.tt title=(create ? "New Project" : "Editing project $project.name") %] +[% PROCESS common.tt %] + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Identifier:[% INCLUDE editString param="name" value=project.name %]
Display name:[% INCLUDE editString param="displayname" value=project.displayname %]
Description:[% INCLUDE editString param="description" value=project.description %]
Homepage: + [% INCLUDE editString param="homepage" value=project.homepage %] +
Owner:[% INCLUDE editString param="owner" value=(project.owner.username || c.user.username) %]
Enabled: + [% INCLUDE renderSelection param="enabled" curValue=project.enabled radiobuttons=1 options={"1" = "Yes", "0" = "No"} %] +
+ +
+ + [% IF !create %] + + + [% END %] +
+ +
+ +[% END %] diff --git a/src/root/jobset.tt b/src/root/jobset.tt index 7662f9b9..d7ff8118 100644 --- a/src/root/jobset.tt +++ b/src/root/jobset.tt @@ -22,7 +22,7 @@ [% IF edit %][% END %] - [% INCLUDE maybeEditString param="$baseName-name" value=input.name extraClass="shortString" %] + [% INCLUDE maybeEditString param="$baseName-name" value=input.name %] [% INCLUDE renderSelection curValue=input.type param="$baseName-type" options=inputTypes %] @@ -143,8 +143,8 @@ Nix expression: - [% INCLUDE maybeEditString param="nixexprpath" value=jobset.nixexprpath extraClass="shortString" %] in input - [% INCLUDE maybeEditString param="nixexprinput" value=jobset.nixexprinput extraClass="shortString" %] + [% INCLUDE maybeEditString param="nixexprpath" value=jobset.nixexprpath %] in input + [% INCLUDE maybeEditString param="nixexprinput" value=jobset.nixexprinput %] diff --git a/src/root/project.tt b/src/root/project.tt index df49609b..4dd8fcae 100644 --- a/src/root/project.tt +++ b/src/root/project.tt @@ -1,192 +1,140 @@ -[% WRAPPER layout.tt title=(edit ? (create ? "New Project" : "Editing project $project.name") : "Project $project.name") %] +[% WRAPPER layout.tt title="Project $project.name" %] [% PROCESS common.tt %] -