From 9c7b416f8bfb23b31ccd848c822c0986801951a5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 Feb 2013 01:45:39 +0100 Subject: [PATCH] Make the hide/unhide actions a checkbox in the project settings Also use proper bootstrap layout for the project settings form. --- src/lib/Hydra/Controller/Project.pm | 29 +------ src/root/edit-project.tt | 115 ++++++++++++++++------------ src/root/topbar.tt | 5 -- 3 files changed, 70 insertions(+), 79 deletions(-) diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index d9f686a3..36cfbe0b 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -60,32 +60,6 @@ sub submit : Chained('project') PathPart Args(0) { } -sub hide : Chained('project') PathPart Args(0) { - my ($self, $c) = @_; - - requireProjectOwner($c, $c->stash->{project}); - - txn_do($c->model('DB')->schema, sub { - $c->stash->{project}->update({ hidden => 1, enabled => 0 }); - }); - - $c->res->redirect($c->uri_for("/")); -} - - -sub unhide : Chained('project') PathPart Args(0) { - my ($self, $c) = @_; - - requireProjectOwner($c, $c->stash->{project}); - - txn_do($c->model('DB')->schema, sub { - $c->stash->{project}->update({ hidden => 0 }); - }); - - $c->res->redirect($c->uri_for("/")); -} - - sub requireMayCreateProjects { my ($c) = @_; @@ -187,7 +161,8 @@ sub updateProject { , displayname => $displayName , description => trim($c->request->params->{description}) , homepage => trim($c->request->params->{homepage}) - , enabled => trim($c->request->params->{enabled}) eq "1" ? 1 : 0 + , enabled => defined $c->request->params->{enabled} ? 1 : 0 + , hidden => defined $c->request->params->{visible} ? 0 : 1 , owner => $owner }); } diff --git a/src/root/edit-project.tt b/src/root/edit-project.tt index 500356bc..56c356ac 100644 --- a/src/root/edit-project.tt +++ b/src/root/edit-project.tt @@ -1,56 +1,77 @@ [% 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 %] -
+ [% IF !create %] + + + [% END %] + + +
diff --git a/src/root/topbar.tt b/src/root/topbar.tt index 7f7c927c..df95e023 100644 --- a/src/root/topbar.tt +++ b/src/root/topbar.tt @@ -52,11 +52,6 @@ [% IF c.user_exists %]
  • [% INCLUDE menuItem uri = c.uri_for('/project' project.name 'edit') title="Edit" %] - [% IF project.hidden %] - [% INCLUDE menuItem uri = c.uri_for('/project' project.name 'unhide') title = "Unhide" %] - [% ELSE %] - [% INCLUDE menuItem uri = c.uri_for('/project' project.name 'hide') title = "Hide" %] - [% END %] [% INCLUDE menuItem uri = c.uri_for(c.controller('Project').action_for('create_jobset'), [project.name]) title = "Create jobset" %] [% END %] [% END %]