Просмотр исходного кода

Add test count column and update cell layouts

Alan Lam 7 лет назад
Родитель
Сommit
f7816794a6
3 измененных файлов с 21 добавлено и 8 удалено
  1. 0 0
      public/css/bootstrap.min.css
  2. 6 0
      scss/_main.scss
  3. 15 8
      views/project_list.php

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
public/css/bootstrap.min.css


+ 6 - 0
scss/_main.scss

@@ -127,4 +127,10 @@ input[required], select[required], textarea[required] {
 
 .grecaptcha-badge {
 	display: none;
+}
+
+.table-sm-text {
+	td, th {
+		font-size: 0.875rem;
+	}
 }

+ 15 - 8
views/project_list.php

@@ -1,17 +1,19 @@
-<table class="table table-sm table-hover">
+<table class="table table-sm table-sm-text table-hover">
 	<thead>
 		<tr>
 			<th class="text-right pr-3">ID</th>
 			<th>Name</th>
-			<th>Template</th>
+			<th>Tests</th>
 			<th>Period</th>
-			<th>Year</th>
 			<th>Report Month</th>
 			<th></th>
 		</tr>
 	</thead>
 	<tbody>
 	<?php
+	$project_ids = array_column($projects, "id");
+	$tests = Test::query(["project_id" => $project_ids]);
+
 	foreach($projects as $project) {
 
 		$year = date("Y", strtotime($project->dts_start));
@@ -30,12 +32,18 @@
 
 		$template = $project->getTemplate();
 
+		$completed_tests = array_filter($tests, function($test) use ($project) {
+			return ($project->id == $test->project_id) && ($test->status == Test::STATUS_COMPLETED);
+		});
+		$completed_test_count = count($completed_tests);
+
 		?>
 		<tr>
 			<td class="text-right pr-3 align-middle">
 				<?=$project->id?>
 			</td>
 			<td class="align-middle">
+				<small><strong><a href="<?=htmlspecialchars($template->getURL())?>"><?=htmlspecialchars($template->name)?></a></strong></small><br />
 				<a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
 				<?php
 				if($time_of_day_icon) {
@@ -46,20 +54,19 @@
 				?>
 			</td>
 			<td class="align-middle">
-				<a href="<?=htmlspecialchars($template->getURL())?>"><?=htmlspecialchars($template->name)?></a>
+				<small><strong>Completed</strong></small><br />
+				<?=$completed_test_count?> / <?=$project->test_count?>
 			</td>
 			<td class="align-middle">
+				<small><strong><?=$year?></strong></small><br />
 				<?=$date_start?> -
 				<?=$date_deadline?>
 			</td>
-			<td class="align-middle">
-				<?=$year?>
-			</td>
 			<td class="align-middle">
 				<?=$report_month?>
 			</td>
 			<td class="text-right align-middle">
-				<a class="btn btn-outline-primary" href="/account/projects/<?=$project->id?>/edit">Edit</a>
+				<a class="btn btn-sm btn-outline-primary" href="/account/projects/<?=$project->id?>/edit">Edit</a>
 			</td>
 		</tr>
 		<?php

Некоторые файлы не были показаны из-за большого количества измененных файлов