Bläddra i källkod

Add "Select All" checkbox to leads table

Alan Lam 3 år sedan
förälder
incheckning
c9d0f6d865
2 ändrade filer med 10 tillägg och 2 borttagningar
  1. 6 0
      public/js/sales.js
  2. 4 2
      views/sales_table.php

+ 6 - 0
public/js/sales.js

@@ -3,4 +3,10 @@ $(() => {
 	$customerDropdown.select2({
 		theme: "bootstrap-5"
 	});
+
+	const $selectAll = $("#sales-table-select-all");
+	$selectAll.on("change", event => {
+		const $table = $(event.currentTarget).closest("table");
+		$table.find("tbody input[type=checkbox]").prop("checked", event.currentTarget.checked);
+	});
 });

+ 4 - 2
views/sales_table.php

@@ -23,7 +23,9 @@ $show_batch_actions ??= false;
 			<?php
 			if($show_batch_actions) {
 				?>
-				<th></th>
+				<th class="text-center">
+					<input type="checkbox" id="sales-table-select-all" />
+				</th>
 				<?php
 			}
 			?>
@@ -47,7 +49,7 @@ $show_batch_actions ??= false;
 				<?php
 				if($show_batch_actions) {
 					?>
-					<td>
+					<td class="text-center">
 						<input type="checkbox" name="sale_ids[]" value="<?=$sale->id?>" />
 					</td>
 					<?php