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

Highlight user currently assigned.

Alan Lam 8 лет назад
Родитель
Сommit
273d1c74a0
2 измененных файлов с 18 добавлено и 6 удалено
  1. 7 4
      controllers/project_ajax.php
  2. 11 2
      public/js/app-project.js

+ 7 - 4
controllers/project_ajax.php

@@ -37,6 +37,7 @@ if($submit) {
 					$test = $location_tests[$location->id] ?? false;
 
 					$test_id = null;
+					$tester_id = null;
 					$status = 0;
 					$status_text = "";
 
@@ -47,11 +48,12 @@ if($submit) {
 
 					$class = "secondary";
 					if($test) {
-						$test_id = $test->id;
+						$test_id = (int) $test->id;
+						$tester_id = (int) $test->tester_id;
 						$class = $test->getStatusClass();
 						$status = $test->status;
 						$status_text = $test->getStatusText();
-						$pass = $test->pass;
+						$pass = (int) $test->pass;
 						$pass_class = $test->getPassClass();
 						$pass_text = $test->getPassText();
 						$pass_icon = $test->getPassIcon();
@@ -60,13 +62,14 @@ if($submit) {
 					$output[] = (object) [
 						"id" => (int) $location->id,
 						"internalId" => $location->internal_id,
-						"testId" => (int) $test_id,
+						"testId" => $test_id,
+						"testerId" => $tester_id,
 						"name" => $location->name,
 						"address" => $location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]),
 						"address1" => $location->address_1,
 						"status" => $status,
 						"statusText" => $status_text,
-						"pass" => (int) $pass,
+						"pass" => $pass,
 						"passClass" => $pass_class,
 						"passText" => $pass_text,
 						"passIcon" => $pass_icon,

+ 11 - 2
public/js/app-project.js

@@ -130,7 +130,7 @@ function initialiseLocations() {
 			var filterValue = filterValueParts.join("").toLowerCase();
 
 			// Populate table
-			var tr = $("<tr data-location-id=\"" + location.id + "\" data-internal-id=\"" + location.internalId + "\" data-latitude=\"" + location.latitude + "\" data-longitude=\"" + location.longitude + "\" data-filter-value=\"" + filterValue + "\"></tr>");
+			var tr = $("<tr data-location-id=\"" + location.id + "\" data-internal-id=\"" + location.internalId + "\" data-tester-id=\"" + location.testerId + "\" data-latitude=\"" + location.latitude + "\" data-longitude=\"" + location.longitude + "\" data-filter-value=\"" + filterValue + "\"></tr>");
 
 			var td = $("<td class=\"text-right\"></td>");
 			td.append(location.id);
@@ -194,11 +194,13 @@ function handleFindTestersButtonClick() {
 	var container = $(this).closest("[data-location-id]");
 
 	var locationId = parseInt($(container).attr("data-location-id"));
+	var testerId = parseInt($(container).attr("data-tester-id"));
 	var lat = parseFloat($(container).attr("data-latitude"));
 	var lng = parseFloat($(container).attr("data-longitude"));
 
 	selectedLocation = {
 		id: locationId,
+		testerId: testerId,
 		lat: lat,
 		lng: lng
 	};
@@ -217,7 +219,8 @@ function handleFindTestersButtonClick() {
 function handleLocationClick() {
 
 	selectedLocation = {
-		id: this.location.id
+		id: this.location.id,
+		testerId: this.location.testerId
 	};
 
 	map.panTo(this.getPosition());
@@ -241,12 +244,14 @@ function clearTesters() {
 function initialiseTesters() {
 
 	let highlightClass = "table-warning";
+	let testerId = selectedLocation.testerId;
 
 	$("#tests-tbody tr").removeClass(highlightClass);
 	$("#tests-tbody tr[data-location-id=" + selectedLocation.id + "]").addClass(highlightClass);
 
 	map = maps["map"];
 
+
 	$("#tester-list-loading-container").text("Loading available testers...");
 
 	$.post("/account/projects/" + projectID + "/get-testers", {
@@ -292,6 +297,10 @@ function initialiseTesters() {
 
 			var tr = $("<tr data-tester-id=\"" + tester.id + "\" data-address-id=\"" + tester.addressId + "\" data-filter-value=\"" + filterValue + "\"></tr>");
 
+			if(tester.id == testerId) {
+				$(tr).addClass(highlightClass);
+			}
+
 			var td = $("<td class=\"text-right\"></td>");
 			td.append(tester.id);
 			tr.append(td);