Make jobset deletion consistent with project deletion

This commit is contained in:
Eelco Dolstra 2013-02-26 17:36:49 +01:00
parent d596b58991
commit 56a62c3d88
4 changed files with 19 additions and 29 deletions

View file

@ -131,6 +131,11 @@ sub submit : Chained('jobset') PathPart Args(0) {
requireProjectOwner($c, $c->stash->{project});
requirePost($c);
if (($c->request->params->{submit} // "") eq "delete") {
$c->stash->{jobset}->delete;
return $c->res->redirect($c->uri_for($c->controller('Project')->action_for("view"), [$c->stash->{project}->name]));
}
txn_do($c->model('DB')->schema, sub {
updateJobset($c, $c->stash->{jobset});
});
@ -140,21 +145,6 @@ sub submit : Chained('jobset') PathPart Args(0) {
}
sub delete : Chained('jobset') PathPart Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
requirePost($c);
txn_do($c->model('DB')->schema, sub {
$c->stash->{jobset}->delete;
});
$c->res->redirect($c->uri_for($c->controller('Project')->action_for("view"),
[$c->stash->{project}->name]));
}
sub nixExprPathFromParams {
my ($c) = @_;

View file

@ -45,9 +45,9 @@ sub submit : Chained('project') PathPart Args(0) {
requireProjectOwner($c, $c->stash->{project});
requirePost($c);
if (($c->request->params->{submit} || "") eq "delete") {
if (($c->request->params->{submit} // "") eq "delete") {
$c->stash->{project}->delete;
$c->res->redirect($c->uri_for("/"));
return $c->res->redirect($c->uri_for("/"));
}
txn_do($c->model('DB')->schema, sub {

View file

@ -109,6 +109,18 @@
<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-jobset" type="submit" class="btn btn-danger" name="submit" value="delete">
<i class="icon-trash icon-white"></i>
Delete this jobset
</button>
<script type="text/javascript">
$("#delete-jobset").click(function() {
return confirm("Are you sure you want to delete this jobset?");
});
</script>
[% END %]
</div>
</fieldset>

View file

@ -82,18 +82,6 @@
[% IF c.user_exists %]
<li class="divider"></li>
[% INCLUDE menuItem uri = c.uri_for('/jobset' project.name jobset.name 'edit') title="Edit" %]
<form id="delete-jobset" method="post" action="[% c.uri_for('/jobset' project.name jobset.name 'delete') %]" class="hidden"></form>
<script>
function confirmDeleteJobset() {
bootbox.confirm(
'Are you sure you want to delete this jobset?',
function(del) { if (del) $('#delete-jobset').submit(); });
return;
};
</script>
[% INCLUDE menuItem title="Delete" uri = "javascript:confirmDeleteJobset()" %]
[% INCLUDE menuItem uri = c.uri_for('/jobset' project.name jobset.name 'clone') title="Clone" %]
<script>