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

Add support for selecting projects by clicking on row

Alan Lam 7 лет назад
Родитель
Сommit
97cd5b13b0
4 измененных файлов с 23 добавлено и 7 удалено
  1. 0 0
      public/css/bootstrap.min.css
  2. 15 4
      public/js/app-reports.js
  3. 5 1
      scss/_main.scss
  4. 3 2
      views/reports.php

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
public/css/bootstrap.min.css


+ 15 - 4
public/js/app-reports.js

@@ -4,20 +4,25 @@ $(function() {
 		dom: "tp",
 		data: projectData,
 		paging: false,
-		order: [[0, "desc"]],
+		order: [[1, "desc"]],
 		scrollY: 250,
 		columns: [
 			{
 				data: "id",
 				class: "text-right",
+				orderable: false,
 				render: function(data, type, row) {
 					if(type == "display") {
 						var checked = (selectedProjectIds.indexOf(data) != -1) ? "checked" : ""
-						return "<input type=\"checkbox\" name=\"project_ids[]\" value=\"" + data + "\" " + checked + " />";
+						return "<input type=\"checkbox\" name=\"project_ids[]\" value=\"" + data + "\" " + checked + " /> ";
 					}
 					return data;
 				}
 			},
+			{
+				data: "id",
+				class: "text-right"
+			},
 			{
 				data: "name"
 			},
@@ -41,6 +46,14 @@ $(function() {
 		]
 	});
 
+	$(document).on("click", "#projects-table tbody tr", function(event) {
+		if(!event.target.type || event.target.type != "checkbox") {
+			var checkbox = $(this).find("input[type=checkbox]").get(0);
+			checkbox.checked = !checkbox.checked;
+		}
+
+	});
+
 	$("canvas[data-chart]").each(function() {
 		var object = $(this).data("chart");
 
@@ -55,8 +68,6 @@ $(function() {
 			object.options.plugins.datalabels.formatter = window[object.datalabelFormatterCallback];
 		}
 
-
-
 		if(object.options.datalabelSuffixes) {
 			object.options.plugins.datalabels.formatter = function(value, context) {
 				let suffix = object.options.datalabelSuffixes[context.datasetIndex];

+ 5 - 1
scss/_main.scss

@@ -133,4 +133,8 @@ input[required], select[required], textarea[required] {
 	td, th {
 		font-size: 0.875rem;
 	}
-}
+}
+
+.table-pointer {
+	cursor: pointer;
+}

+ 3 - 2
views/reports.php

@@ -63,12 +63,13 @@ var projectData = <?=json_encode($project_table_data)?>;
 					<label>
 						Projects
 					</label>
-					<table class="table table-sm table-sm-text" id="projects-table">
+					<table class="table table-sm table-sm-text table-hover table-pointer" id="projects-table">
 						<thead>
 							<tr>
+								<th></th>
 								<th>ID</th>
 								<th>Name</th>
-								<th>Time of Day</th>
+								<th><span title="Time of Day" data-toggle="tooltip">TOD</span></th>
 								<th>Tests</th>
 								<th>Report Month</th>
 							</tr>

Некоторые файлы не были показаны из-за большого количества измененных файлов