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

Add batch action to assign tests on a project

Alan Lam 1 год назад
Родитель
Сommit
3c497987ad
2 измененных файлов с 25 добавлено и 2 удалено
  1. 18 1
      controllers/project.php
  2. 7 1
      views/project.php

+ 18 - 1
controllers/project.php

@@ -25,7 +25,8 @@ Core::addScript("public/js/app-project.js");
 Core::addScript("public/js/markerclusterer.js");
 
 $action = http::value("action", "string");
-$target_project_id = http::value("target_project_id");
+$target_project_id = http::value("target_project_id", "int");
+$target_user_id = http::value("target_user_id", "int");
 $test_ids_json = http::value("test_ids_json", "string");
 
 if($action) {
@@ -81,6 +82,22 @@ if($action) {
 			Core::addAlert("success", __("Tests moved successfully."));
 			break;
 
+		case "assign":
+			$tester = User::get($target_user_id);
+			if(!$tester) {
+				throw new RuntimeException("Target user not found.");
+			}
+
+			$tests = Test::query(["id" => $test_ids, "project_id" => $id, "status" => [
+				Test::STATUS_UNASSIGNED,
+				Test::STATUS_ASSIGNED,
+			]]);
+			foreach($tests as $test) {
+				$test->assignTester($tester);
+			}
+
+			break;
+
 		case "unassign":
 			$tests = Test::query(["id" => $test_ids, "project_id" => $id, "status" => Test::STATUS_ASSIGNED]);
 			foreach($tests as $test) {

+ 7 - 1
views/project.php

@@ -279,13 +279,14 @@ if($auto_select_location_id) {
 								<select class="form-control" name="action" id="batch-action" required>
 									<option value=""><?=htmlspecialchars(__("Select Action"))?></option>
 									<option value="move-tests">Move Selected Tests To Another Project</option>
+									<option value="assign">Assign</option>
 									<option value="unassign">Unassign</option>
 								</select>
 							</div>
 
 							<div class="form-group">
 								<label for="target-project-id"><?=htmlspecialchars(__("Target Project"))?></label>
-								<select class="form-control" name="target_project_id" id="target-project-id" required>
+								<select class="form-control" name="target_project_id" id="target-project-id">
 									<option value=""><?=htmlspecialchars(__("Select Project"))?></option>
 									<?php
 									foreach($target_projects as $target_project) {
@@ -299,6 +300,11 @@ if($auto_select_location_id) {
 								</select>
 							</div>
 
+							<div class="form-group">
+								<label for="target-user-id"><?=htmlspecialchars(__("Target User"))?></label>
+								<input class="form-control" type="number" id="target-user-id" name="target_user_id" placeholder="<?=htmlspecialchars(__("Type ID"))?>" />
+							</div>
+
 							<input type="hidden" name="test_ids_json" value="" />
 
 							<button type="submit" class="btn btn-primary">