Also hide disabled projects on the overview page by default

This commit is contained in:
Eelco Dolstra 2016-11-01 13:13:59 +01:00
parent 9072adece8
commit 07decd6915
3 changed files with 29 additions and 5 deletions

View file

@ -91,7 +91,7 @@ sub deserialize :ActionClass('Deserialize') { }
sub index :Path :Args(0) { sub index :Path :Args(0) {
my ($self, $c) = @_; my ($self, $c) = @_;
$c->stash->{template} = 'overview.tt'; $c->stash->{template} = 'overview.tt';
$c->stash->{projects} = [$c->model('DB::Projects')->search(isAdmin($c) ? {} : {hidden => 0}, {order_by => 'name'})]; $c->stash->{projects} = [$c->model('DB::Projects')->search({}, {order_by => 'name'})];
$c->stash->{newsItems} = [$c->model('DB::NewsItems')->search({}, { order_by => ['createtime DESC'], rows => 5 })]; $c->stash->{newsItems} = [$c->model('DB::NewsItems')->search({}, { order_by => ['createtime DESC'], rows => 5 })];
$self->status_ok($c, $self->status_ok($c,
entity => $c->stash->{projects} entity => $c->stash->{projects}

View file

@ -17,7 +17,31 @@
[% IF projects.size != 0 %] [% IF projects.size != 0 %]
<p>The following projects are hosted on this server:</p> <script type="text/javascript">
function showProjects() {
var showDisabled = $('#show-disabled').hasClass('active');
$('tr.project').map(function() {
var hide =
($(this).hasClass('disabled-project') && !showDisabled);
if (hide) $(this).hide(); else $(this).show();
});
return false;
};
$(document).ready(function() {
$('#show-disabled').on('click', function(e) {
$(this).toggleClass('active');
showProjects();
return false;
});
showProjects();
});
</script>
<p>The following projects are hosted on this server:
<label id="show-disabled" class="btn btn-small pull-right" data-toggle="button">Show disabled projects</label>
</p>
<table class="table table-condensed table-striped clickable-rows"> <table class="table table-condensed table-striped clickable-rows">
<thead> <thead>
@ -29,7 +53,7 @@
</thead> </thead>
<tbody> <tbody>
[% FOREACH p IN projects %] [% FOREACH p IN projects %]
<tr> <tr class="project [% IF !p.enabled %]disabled-project[% END %]">
<td><span class="[% IF !p.enabled %]disabled-project[% END %] [%+ IF p.hidden %]hidden-project[% END %]">[% INCLUDE renderProjectName project=p.name inRow=1 %]</span></td> <td><span class="[% IF !p.enabled %]disabled-project[% END %] [%+ IF p.hidden %]hidden-project[% END %]">[% INCLUDE renderProjectName project=p.name inRow=1 %]</span></td>
<td>[% HTML.escape(p.displayname) %]</td> <td>[% HTML.escape(p.displayname) %]</td>
<td>[% WRAPPER maybeLink uri=p.homepage %][% HTML.escape(p.description) %][% END %]</td> <td>[% WRAPPER maybeLink uri=p.homepage %][% HTML.escape(p.description) %][% END %]</td>

View file

@ -53,9 +53,9 @@
<div id="tabs-project" class="tab-pane active"> <div id="tabs-project" class="tab-pane active">
[% IF project.jobsets %] [% IF project.jobsets %]
<p>This project has the following jobsets: <p>This project has the following jobsets:
<button id="show-disabled" type="button" class="btn btn-small pull-right active" data-toggle="button">Show disabled jobsets</button> <label id="show-disabled" class="btn btn-small pull-right active" data-toggle="button">Show disabled jobsets</label>
[% IF isProjectOwner %] [% IF isProjectOwner %]
<button id="show-hidden" type="button" class="btn btn-small pull-right" data-toggle="button">Show hidden jobsets</button> <label id="show-hidden" class="btn btn-small pull-right" data-toggle="button">Show hidden jobsets</label>
[% END %] [% END %]
</p> </p>
[% INCLUDE renderJobsetOverview %] [% INCLUDE renderJobsetOverview %]