forked from lix-project/hydra
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:
parent
3924780eac
commit
9c7b416f8b
|
@ -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
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,56 +1,77 @@
|
|||
[% WRAPPER layout.tt title=(create ? "New project" : "Editing project $project.name") %]
|
||||
[% 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">
|
||||
<tr>
|
||||
<th>Identifier:</th>
|
||||
<td><tt>[% INCLUDE editString param="name" value=project.name %]</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Display name:</th>
|
||||
<td>[% INCLUDE editString param="displayname" value=project.displayname %]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Description:</th>
|
||||
<td>[% INCLUDE editString param="description" value=project.description %]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Homepage:</th>
|
||||
<td>
|
||||
[% INCLUDE editString param="homepage" value=project.homepage %]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Owner:</th>
|
||||
<td><tt>[% INCLUDE editString param="owner" value=(project.owner.username || c.user.username) %]</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Enabled:</th>
|
||||
<td>
|
||||
[% INCLUDE renderSelection param="enabled" curValue=project.enabled radiobuttons=1 options={"1" = "Yes", "0" = "No"} %]
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<fieldset>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="icon-ok icon-white"></i>
|
||||
[%IF create %]Create[% ELSE %]Apply changes[% END %]
|
||||
</button>
|
||||
[% IF !create %]
|
||||
<button id="delete-project" type="submit" class="btn btn-danger" name="submit" value="delete">
|
||||
<i class="icon-trash icon-white"></i>
|
||||
Delete this project
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="enabled" value="enabled" [% IF project.enabled; 'checked="checked"'; END %]></input>Enabled
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="visible" value="visible" [% IF !project.hidden; 'checked="checked"'; END %]></input>Visible in the list of projects
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Identifier</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span3" name="name" [% HTML.attributes(value => project.name) %]></input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Display name</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span3" name="displayname" [% HTML.attributes(value => project.displayname) %]></input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="icon-ok icon-white"></i>
|
||||
[%IF create %]Create[% ELSE %]Apply changes[% END %]
|
||||
</button>
|
||||
<script type="text/javascript">
|
||||
$("#delete-project").click(function() {
|
||||
return confirm("Are you sure you want to delete this project?");
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
</div>
|
||||
[% IF !create %]
|
||||
<button id="delete-project" type="submit" class="btn btn-danger" name="submit" value="delete">
|
||||
<i class="icon-trash icon-white"></i>
|
||||
Delete this project
|
||||
</button>
|
||||
<script type="text/javascript">
|
||||
$("#delete-project").click(function() {
|
||||
return confirm("Are you sure you want to delete this project?");
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@
|
|||
[% IF c.user_exists %]
|
||||
<li class="divider"></li>
|
||||
[% 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 %]
|
||||
|
|
Loading…
Reference in a new issue