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

Add template column to project list

Alan Lam 8 лет назад
Родитель
Сommit
bd935219ae
3 измененных файлов с 11 добавлено и 0 удалено
  1. 1 0
      controllers/projects.php
  2. 4 0
      engine/template.php
  3. 6 0
      views/project_list.php

+ 1 - 0
controllers/projects.php

@@ -19,6 +19,7 @@ if($id) $nvp["id"] = $id;
 if($name) $nvp["name"] = (new Constraint("CONTAINS"))->setValues($name);
 
 $projects = Project::query($nvp, ["sort" => "dts_deadline", "order" => "desc"]);
+$templates = Template::load(array_column($projects, "template_id"));
 
 $filter_count = count($nvp) - 1;
 

+ 4 - 0
engine/template.php

@@ -23,6 +23,10 @@ class Template extends Model {
 		return $file_path;
 	}
 
+	public function getURL() {
+		return "/account/templates/" . $this->id;
+	}
+
 	public function renderBeforeTestForm() {
 
 		$json = json_decode($this->json);

+ 6 - 0
views/project_list.php

@@ -3,6 +3,7 @@
 		<tr>
 			<th class="text-right pr-3">ID</th>
 			<th>Name</th>
+			<th>Template</th>
 			<th>Deadline</th>
 			<th>Report Month</th>
 			<th></th>
@@ -22,6 +23,8 @@
 		$time_of_day_icon = $project->getTimeOfDayIcon();
 		$time_of_day_text = $project->getTimeOfDayText();
 
+		$template = $project->getTemplate();
+
 		?>
 		<tr>
 			<td class="text-right pr-3 align-middle">
@@ -31,6 +34,9 @@
 				<a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
 				<i class="fal fa-<?=$time_of_day_icon?>" data-toggle="tooltip" data-title="<?=$time_of_day_text?> Tests"></i>
 			</td>
+			<td class="align-middle">
+				<a href="<?=htmlspecialchars($template->getURL())?>"><?=htmlspecialchars($template->name)?></a>
+			</td>
 			<td class="align-middle">
 				<?=$date_deadline?>
 			</td>