ソースを参照

fix(AdvancedTable): Remove updatedPlaceholder column if no updated event

Owen Diffey 3 年 前
コミット
f51fa99be8
1 ファイル変更29 行追加24 行削除
  1. 29 24
      frontend/src/components/AdvancedTable.vue

+ 29 - 24
frontend/src/components/AdvancedTable.vue

@@ -472,7 +472,10 @@
 							<template #item="{ element: column }">
 								<th
 									v-if="
-										shownColumns.indexOf(column.name) !== -1
+										shownColumns.indexOf(column.name) !==
+											-1 &&
+										(column.name !== 'updatedPlaceholder' ||
+											rows.length > 0)
 									"
 									:class="{
 										sortable: column.sortable,
@@ -956,20 +959,27 @@ export default {
 	mounted() {
 		const tableSettings = this.getTableSettings();
 
-		this.orderedColumns = [
+		const columns = [
+			...this.columns.map(column => ({
+				...this.columnDefault,
+				...column
+			})),
 			{
-				name: "updatedPlaceholder",
+				name: "placeholder",
 				displayName: "",
 				properties: [],
 				sortable: false,
 				hidable: false,
 				draggable: false,
 				resizable: false,
-				minWidth: 5,
-				width: 5,
-				maxWidth: 5
-			},
-			{
+				minWidth: "auto",
+				width: "auto",
+				maxWidth: "auto"
+			}
+		];
+
+		if (this.hasCheckboxes)
+			columns.unshift({
 				name: "select",
 				displayName: "",
 				properties: [],
@@ -980,24 +990,23 @@ export default {
 				minWidth: 47,
 				defaultWidth: 47,
 				maxWidth: 47
-			},
-			...this.columns.map(column => ({
-				...this.columnDefault,
-				...column
-			})),
-			{
-				name: "placeholder",
+			});
+
+		if (this.events && this.events.updated)
+			columns.unshift({
+				name: "updatedPlaceholder",
 				displayName: "",
 				properties: [],
 				sortable: false,
 				hidable: false,
 				draggable: false,
 				resizable: false,
-				minWidth: "auto",
-				width: "auto",
-				maxWidth: "auto"
-			}
-		].sort((columnA, columnB) => {
+				minWidth: 5,
+				width: 5,
+				maxWidth: 5
+			});
+
+		this.orderedColumns = columns.sort((columnA, columnB) => {
 			// Always places updatedPlaceholder column in the first position
 			if (columnA.name === "updatedPlaceholder") return -1;
 			// Always places select column in the first position
@@ -2071,10 +2080,6 @@ export default {
 						}
 					}
 
-					&:nth-child(2) {
-						display: none;
-					}
-
 					.resizer {
 						height: 100%;
 						width: 5px;