Tweak handling of empty list sections

This commit is contained in:
Timothy Warren 2017-09-14 17:33:24 -04:00
parent b0ee397994
commit 04ec5b2fd6
4 changed files with 155 additions and 133 deletions

View File

@ -6,6 +6,12 @@
<h3>There's nothing here!</h3> <h3>There's nothing here!</h3>
<?php else: ?> <?php else: ?>
<?php foreach ($sections as $name => $items): ?> <?php foreach ($sections as $name => $items): ?>
<?php if (empty($items)): ?>
<section class="status">
<h2><?= $escape->html($name) ?></h2>
<h3>There's nothing here!</h3>
</section>
<?php else: ?>
<section class="status"> <section class="status">
<h2><?= $escape->html($name) ?></h2> <h2><?= $escape->html($name) ?></h2>
<section class="media-wrap"> <section class="media-wrap">
@ -88,6 +94,7 @@
<?php endforeach ?> <?php endforeach ?>
</section> </section>
</section> </section>
<?php endif ?>
<?php endforeach ?> <?php endforeach ?>
<?php endif ?> <?php endif ?>
</main> </main>

View File

@ -7,86 +7,90 @@
<?php else: ?> <?php else: ?>
<?php foreach ($sections as $name => $items): ?> <?php foreach ($sections as $name => $items): ?>
<h2><?= $name ?></h2> <h2><?= $name ?></h2>
<table> <?php if (empty($items)): ?>
<thead> <h3>There's nothing here!</h3>
<tr> <?php else: ?>
<?php if($auth->isAuthenticated()): ?> <table>
<td class="no_border">&nbsp;</td> <thead>
<?php endif ?> <tr>
<th>Title</th> <?php if($auth->isAuthenticated()): ?>
<th>Airing Status</th> <td class="no_border">&nbsp;</td>
<th>Score</th>
<th>Type</th>
<th>Progress</th>
<th>Rated</th>
<th colspan="2">Attributes</th>
<th>Notes</th>
<th>Genres</th>
</tr>
</thead>
<tbody>
<?php foreach($items as $item): ?>
<?php if ($item['private'] && ! $auth->isAuthenticated()) continue; ?>
<tr id="a-<?= $item['id'] ?>">
<?php if ($auth->isAuthenticated()): ?>
<td>
<a class="bracketed" href="<?= $url->generate('edit', [
'controller' => 'anime',
'id' => $item['id'],
'status' => $item['watching_status']
]) ?>">Edit</a>
</td>
<?php endif ?>
<td class="justify">
<a href="<?= $url->generate('anime.details', ['id' => $item['anime']['slug']]) ?>">
<?= array_shift($item['anime']['titles']) ?>
</a>
<?php foreach($item['anime']['titles'] as $title): ?>
<br /><?= $title ?>
<?php endforeach ?>
</td>
<td><?= $item['airing']['status'] ?></td>
<td><?= $item['user_rating'] ?> / 10 </td>
<td><?= $item['anime']['type'] ?></td>
<td id="<?= $item['anime']['slug'] ?>">
Episodes: <br />
<span class="completed_number"><?= $item['episodes']['watched'] ?></span>&nbsp;/&nbsp;<span class="total_number"><?= $item['episodes']['total'] ?></span>
</td>
<td><?= $item['anime']['age_rating'] ?></td>
<td>
<ul>
<?php if ($item['rewatched'] > 0): ?>
<li>Rewatched <?= $item['rewatched'] ?> time(s)</li>
<?php endif ?> <?php endif ?>
<?php foreach(['private','rewatching'] as $attr): ?> <th>Title</th>
<?php if($item[$attr]): ?> <th>Airing Status</th>
<li><?= ucfirst($attr); ?></li> <th>Score</th>
<th>Type</th>
<th>Progress</th>
<th>Rated</th>
<th colspan="2">Attributes</th>
<th>Notes</th>
<th>Genres</th>
</tr>
</thead>
<tbody>
<?php foreach($items as $item): ?>
<?php if ($item['private'] && ! $auth->isAuthenticated()) continue; ?>
<tr id="a-<?= $item['id'] ?>">
<?php if ($auth->isAuthenticated()): ?>
<td>
<a class="bracketed" href="<?= $url->generate('edit', [
'controller' => 'anime',
'id' => $item['id'],
'status' => $item['watching_status']
]) ?>">Edit</a>
</td>
<?php endif ?>
<td class="justify">
<a href="<?= $url->generate('anime.details', ['id' => $item['anime']['slug']]) ?>">
<?= array_shift($item['anime']['titles']) ?>
</a>
<?php foreach($item['anime']['titles'] as $title): ?>
<br /><?= $title ?>
<?php endforeach ?>
</td>
<td><?= $item['airing']['status'] ?></td>
<td><?= $item['user_rating'] ?> / 10 </td>
<td><?= $item['anime']['type'] ?></td>
<td id="<?= $item['anime']['slug'] ?>">
Episodes: <br />
<span class="completed_number"><?= $item['episodes']['watched'] ?></span>&nbsp;/&nbsp;<span class="total_number"><?= $item['episodes']['total'] ?></span>
</td>
<td><?= $item['anime']['age_rating'] ?></td>
<td>
<ul>
<?php if ($item['rewatched'] > 0): ?>
<li>Rewatched <?= $item['rewatched'] ?> time(s)</li>
<?php endif ?> <?php endif ?>
<?php endforeach ?> <?php foreach(['private','rewatching'] as $attr): ?>
</ul> <?php if($item[$attr]): ?>
</td> <li><?= ucfirst($attr); ?></li>
<td> <?php endif ?>
<?php foreach($item['anime']['streaming_links'] as $link): ?> <?php endforeach ?>
<?php if ($link['meta']['link'] !== FALSE): ?> </ul>
<a href="<?= $link['link'] ?>" title="Stream '<?= $item['anime']['title'] ?>' on <?= $link['meta']['name'] ?>"> </td>
<td>
<?php foreach($item['anime']['streaming_links'] as $link): ?>
<?php if ($link['meta']['link'] !== FALSE): ?>
<a href="<?= $link['link'] ?>" title="Stream '<?= $item['anime']['title'] ?>' on <?= $link['meta']['name'] ?>">
<img class="streaming-logo" width="50" height="50" src="<?= $urlGenerator->assetUrl('images', $link['meta']['image']) ?>" alt="<?= $link['meta']['name'] ?> logo" />
</a>
<?php else: ?>
<img class="streaming-logo" width="50" height="50" src="<?= $urlGenerator->assetUrl('images', $link['meta']['image']) ?>" alt="<?= $link['meta']['name'] ?> logo" /> <img class="streaming-logo" width="50" height="50" src="<?= $urlGenerator->assetUrl('images', $link['meta']['image']) ?>" alt="<?= $link['meta']['name'] ?> logo" />
</a> <?php endif ?>
<?php else: ?> <?php endforeach ?>
<img class="streaming-logo" width="50" height="50" src="<?= $urlGenerator->assetUrl('images', $link['meta']['image']) ?>" alt="<?= $link['meta']['name'] ?> logo" /> </td>
<?php endif ?> <td>
<?php endforeach ?> <p><?= $escape->html($item['notes']) ?></p>
</td> </td>
<td> <td class="align_left">
<p><?= $escape->html($item['notes']) ?></p> <?php sort($item['anime']['genres']) ?>
</td> <?= implode(', ', $item['anime']['genres']) ?>
<td class="align_left"> </td>
<?php sort($item['anime']['genres']) ?> </tr>
<?= implode(', ', $item['anime']['genres']) ?> <?php endforeach ?>
</td> </tbody>
</tr> </table>
<?php endforeach ?> <?php endif ?>
</tbody>
</table>
<?php endforeach ?> <?php endforeach ?>
<?php endif ?> <?php endif ?>
</main> </main>

View File

@ -6,6 +6,12 @@
<h3>There's nothing here!</h3> <h3>There's nothing here!</h3>
<?php else: ?> <?php else: ?>
<?php foreach ($sections as $name => $items): ?> <?php foreach ($sections as $name => $items): ?>
<?php if (empty($items)): ?>
<section class="status">
<h2><?= $escape->html($name) ?></h2>
<h3>There's nothing here!</h3>
</section>
<?php else: ?>
<section class="status"> <section class="status">
<h2><?= $escape->html($name) ?></h2> <h2><?= $escape->html($name) ?></h2>
<section class="media-wrap"> <section class="media-wrap">
@ -78,6 +84,7 @@
<?php endforeach ?> <?php endforeach ?>
</section> </section>
</section> </section>
<?php endif ?>
<?php endforeach ?> <?php endforeach ?>
<?php endif ?> <?php endif ?>
</main> </main>

View File

@ -7,64 +7,68 @@
<?php else: ?> <?php else: ?>
<?php foreach ($sections as $name => $items): ?> <?php foreach ($sections as $name => $items): ?>
<h2><?= $name ?></h2> <h2><?= $name ?></h2>
<table> <?php if (empty($items)): ?>
<thead> <h3>There's nothing here!</h3>
<tr> <?php else: ?>
<?php if ($auth->isAuthenticated()): ?> <table>
<th>&nbsp;</th> <thead>
<?php endif ?> <tr>
<th>Title</th> <?php if ($auth->isAuthenticated()): ?>
<th>Rating</th> <th>&nbsp;</th>
<th>Completed Chapters</th>
<th># of Volumes</th>
<th>Attributes</th>
<th>Type</th>
<th>Genres</th>
</tr>
</thead>
<tbody>
<?php foreach($items as $item): ?>
<tr id="manga-<?= $item['id'] ?>">
<?php if($auth->isAuthenticated()): ?>
<td>
<a class="bracketed" href="<?= $url->generate('edit', [
'controller' => 'manga',
'id' => $item['id'],
'status' => $name
]) ?>">Edit</a>
</td>
<?php endif ?>
<td class="align_left">
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
<?= array_shift($item['manga']['titles']) ?>
</a>
<?php foreach($item['manga']['titles'] as $title): ?>
<br /><?= $title ?>
<?php endforeach ?>
</td>
<td><?= $item['user_rating'] ?> / 10</td>
<td><?= $item['chapters']['read'] ?> / <?= $item['chapters']['total'] ?></td>
<td><?= $item['volumes']['total'] ?></td>
<td>
<ul>
<?php if ($item['reread'] > 0): ?>
<li>Reread <?= $item['reread'] ?> time(s)</li>
<?php endif ?> <?php endif ?>
<?php foreach(['rereading'] as $attr): ?> <th>Title</th>
<?php if($item[$attr]): ?> <th>Rating</th>
<li><?= ucfirst($attr); ?></li> <th>Completed Chapters</th>
<th># of Volumes</th>
<th>Attributes</th>
<th>Type</th>
<th>Genres</th>
</tr>
</thead>
<tbody>
<?php foreach($items as $item): ?>
<tr id="manga-<?= $item['id'] ?>">
<?php if($auth->isAuthenticated()): ?>
<td>
<a class="bracketed" href="<?= $url->generate('edit', [
'controller' => 'manga',
'id' => $item['id'],
'status' => $name
]) ?>">Edit</a>
</td>
<?php endif ?>
<td class="align_left">
<a href="<?= $url->generate('manga.details', ['id' => $item['manga']['slug']]) ?>">
<?= array_shift($item['manga']['titles']) ?>
</a>
<?php foreach($item['manga']['titles'] as $title): ?>
<br /><?= $title ?>
<?php endforeach ?>
</td>
<td><?= $item['user_rating'] ?> / 10</td>
<td><?= $item['chapters']['read'] ?> / <?= $item['chapters']['total'] ?></td>
<td><?= $item['volumes']['total'] ?></td>
<td>
<ul>
<?php if ($item['reread'] > 0): ?>
<li>Reread <?= $item['reread'] ?> time(s)</li>
<?php endif ?> <?php endif ?>
<?php endforeach ?> <?php foreach(['rereading'] as $attr): ?>
</ul> <?php if($item[$attr]): ?>
</td> <li><?= ucfirst($attr); ?></li>
<td><?= $item['manga']['type'] ?></td> <?php endif ?>
<td class="align_left"> <?php endforeach ?>
<?= implode(', ', $item['manga']['genres']) ?> </ul>
</td> </td>
</tr> <td><?= $item['manga']['type'] ?></td>
<?php endforeach ?> <td class="align_left">
</tbody> <?= implode(', ', $item['manga']['genres']) ?>
</table> </td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
<?php endforeach ?> <?php endforeach ?>
<?php endif ?> <?php endif ?>
</main> </main>