Procházet zdrojové kódy

Add "Select All" checkbox

Alan Lam před 7 roky
rodič
revize
32e26dd626

+ 2 - 0
controllers/tests_admin_list.php

@@ -171,5 +171,7 @@ $sorts = [
 	"due" => "Due",
 	"due" => "Due",
 ];
 ];
 
 
+Core::addScript("public/js/app-test-list.js");
+
 View::includeOnce("header", compact("page_title"));
 View::includeOnce("header", compact("page_title"));
 View::include("test_list", compact("tests", "pagination_object", "sort", "sorts", "projects", "customers", "customer_id", "project_id", "location_id", "location_internal_id", "pass", "custom", "test_id", "tester_id", "filter_count", "status", "status_tester_invoice"));
 View::include("test_list", compact("tests", "pagination_object", "sort", "sorts", "projects", "customers", "customer_id", "project_id", "location_id", "location_internal_id", "pass", "custom", "test_id", "tester_id", "filter_count", "status", "status_tester_invoice"));

+ 5 - 2
engine/core.php

@@ -48,8 +48,11 @@ class Core {
 		Core::$breadcrumbs[] = [$url, $name];
 		Core::$breadcrumbs[] = [$url, $name];
 	}
 	}
 
 
-	public static function addScript($path) {
-		Core::$scripts[] = $path; // Path is relative to root directory
+	/**
+	 * @param string $path Path relative to root directory
+	 */
+	public static function addScript(string $path) {
+		Core::$scripts[] = $path;
 	}
 	}
 
 
 	public static function addStylesheet($path) {
 	public static function addStylesheet($path) {

+ 9 - 0
public/js/app-projects.js

@@ -35,4 +35,13 @@ $(function() {
 		}
 		}
 	});
 	});
 
 
+	$("#projects-table-select-all").on("click", function() {
+		let $checkboxes = $(this).parents("table").find("input:checkbox");
+		let count = $checkboxes.length;
+
+		for(let i = 0; i < count; i++) {
+			$checkboxes.get(i).checked = this.checked;
+		}
+	});
+
 });
 });

+ 10 - 0
public/js/app-test-list.js

@@ -0,0 +1,10 @@
+$(function() {
+	$("#tests-table-select-all").on("click", function() {
+		let $checkboxes = $(this).parents("table").find("input:checkbox");
+		let count = $checkboxes.length;
+
+		for(let i = 0; i < count; i++) {
+			$checkboxes.get(i).checked = this.checked;
+		}
+	});
+});

+ 4 - 2
views/project_list.php

@@ -3,7 +3,9 @@
 
 
 	<thead>
 	<thead>
 		<tr>
 		<tr>
-			<th></th>
+			<th class="text-center align-middle">
+                <input id="projects-table-select-all" type="checkbox" />
+            </th>
 			<th class="text-right pr-3">ID</th>
 			<th class="text-right pr-3">ID</th>
 			<th>Name</th>
 			<th>Name</th>
 			<th>Tests</th>
 			<th>Tests</th>
@@ -90,4 +92,4 @@ if(empty($projects)) {
 	</div>
 	</div>
 	<?php
 	<?php
 }
 }
-?>
+?>

+ 3 - 1
views/test_list.php

@@ -249,7 +249,9 @@ $custom_filters = [
 
 
 					<table class="table table-sm table-sm-text table-hover" style="min-width: 1024px;">
 					<table class="table table-sm table-sm-text table-hover" style="min-width: 1024px;">
 						<thead>
 						<thead>
-							<th></th>
+							<th>
+                                <input type="checkbox" id="tests-table-select-all" />
+                            </th>
 							<th>ID</th>
 							<th>ID</th>
 							<th>Location</th>
 							<th>Location</th>
 							<th>Project</th>
 							<th>Project</th>