Make the hide/unhide actions a checkbox in the project settings

Also use proper bootstrap layout for the project settings form.
This commit is contained in:
Eelco Dolstra 2013-02-21 01:45:39 +01:00
parent 3924780eac
commit 9c7b416f8b
3 changed files with 70 additions and 79 deletions

View File

@ -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 { sub requireMayCreateProjects {
my ($c) = @_; my ($c) = @_;
@ -187,7 +161,8 @@ sub updateProject {
, displayname => $displayName , displayname => $displayName
, description => trim($c->request->params->{description}) , description => trim($c->request->params->{description})
, homepage => trim($c->request->params->{homepage}) , 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 , owner => $owner
}); });
} }

View File

@ -1,38 +1,57 @@
[% WRAPPER layout.tt title=(create ? "New project" : "Editing project $project.name") %] [% WRAPPER layout.tt title=(create ? "New project" : "Editing project $project.name") %]
[% PROCESS common.tt %] [% PROCESS common.tt %]
<form action="[% IF create %][% c.uri_for('/create-project/submit') %][% ELSE %][% c.uri_for('/project' project.name 'submit') %][% END %]" method="post"> <form class="form-horizontal" action="[% IF create %][% c.uri_for('/create-project/submit') %][% ELSE %][% c.uri_for('/project' project.name 'submit') %][% END %]" method="post">
<table class="layoutTable"> <fieldset>
<tr>
<th>Identifier:</th> <div class="control-group">
<td><tt>[% INCLUDE editString param="name" value=project.name %]</tt></td> <div class="controls">
</tr> <label class="checkbox">
<tr> <input type="checkbox" name="enabled" value="enabled" [% IF project.enabled; 'checked="checked"'; END %]></input>Enabled
<th>Display name:</th> </label>
<td>[% INCLUDE editString param="displayname" value=project.displayname %]</td> </div>
</tr> <div class="controls">
<tr> <label class="checkbox">
<th>Description:</th> <input type="checkbox" name="visible" value="visible" [% IF !project.hidden; 'checked="checked"'; END %]></input>Visible in the list of projects
<td>[% INCLUDE editString param="description" value=project.description %]</td> </label>
</tr> </div>
<tr> </div>
<th>Homepage:</th>
<td> <div class="control-group">
[% INCLUDE editString param="homepage" value=project.homepage %] <label class="control-label">Identifier</label>
</td> <div class="controls">
</tr> <input type="text" class="span3" name="name" [% HTML.attributes(value => project.name) %]></input>
<tr> </div>
<th>Owner:</th> </div>
<td><tt>[% INCLUDE editString param="owner" value=(project.owner.username || c.user.username) %]</tt></td>
</tr> <div class="control-group">
<tr> <label class="control-label">Display name</label>
<th>Enabled:</th> <div class="controls">
<td> <input type="text" class="span3" name="displayname" [% HTML.attributes(value => project.displayname) %]></input>
[% INCLUDE renderSelection param="enabled" curValue=project.enabled radiobuttons=1 options={"1" = "Yes", "0" = "No"} %] </div>
</td> </div>
</tr>
</table> <div class="control-group">
<label class="control-label">Description</label>
<div class="controls">
<input type="text" class="span3" name="description" [% HTML.attributes(value => project.description) %]></input>
</div>
</div>
<div class="control-group">
<label class="control-label">Homepage</label>
<div class="controls">
<input type="text" class="span3" name="homepage" [% HTML.attributes(value => project.homepage) %]></input>
</div>
</div>
<div class="control-group">
<label class="control-label">Owner</label>
<div class="controls">
<input type="text" class="span3" name="owner" [% HTML.attributes(value => project.owner.username || c.user.username) %]></input>
</div>
</div>
<div class="form-actions"> <div class="form-actions">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
@ -52,6 +71,8 @@
[% END %] [% END %]
</div> </div>
</fieldset>
</form> </form>
[% END %] [% END %]

View File

@ -52,11 +52,6 @@
[% IF c.user_exists %] [% IF c.user_exists %]
<li class="divider"></li> <li class="divider"></li>
[% INCLUDE menuItem uri = c.uri_for('/project' project.name 'edit') title="Edit" %] [% 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" %] [% INCLUDE menuItem uri = c.uri_for(c.controller('Project').action_for('create_jobset'), [project.name]) title = "Create jobset" %]
[% END %] [% END %]
[% END %] [% END %]