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

Fix JS error when searching with no testers in tbody

Alan Lam 3 лет назад
Родитель
Сommit
ad8535af81
1 измененных файлов с 12 добавлено и 6 удалено
  1. 12 6
      public/js/app-project.js

+ 12 - 6
public/js/app-project.js

@@ -36,25 +36,31 @@ $(function() {
 		}
 
 		$(target).children().each(function() {
+			const $tr = $(this);
+			const data = $tr.data();
+
+			if(!data.filterValue) {
+				return;
+			}
 
 			let number = parseInt(value);
 			var show;
 			if(isNaN(number)) {
-				show = $(this).data("filter-value").indexOf(value) != -1;
+				show = data.filterValue.indexOf(value) != -1;
 			}
 			else {
-				let test1 = (number == $(this).data("location-id"));
-				let test2 = (number == $(this).data("internal-id"));
-				let test3 = (number == $(this).data("tester-id"));
+				let test1 = (number == data.locationId);
+				let test2 = (number == data.internalId);
+				let test3 = (number == data.testerId);
 
 				show = test1 || test2 || test3;
 			}
 
 			if(show) {
-				$(this).show();
+				$tr.show();
 			}
 			else {
-				$(this).hide();
+				$tr.hide();
 			}
 		});