| 
									
										
										
										
											2021-11-26 22:37:06 -09:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <v-data-table | 
					
						
							|  |  |  |     :headers="headers" | 
					
						
							|  |  |  |     :items="items" | 
					
						
							|  |  |  |     item-key="id" | 
					
						
							|  |  |  |     class="elevation-0" | 
					
						
							|  |  |  |     :items-per-page="50" | 
					
						
							|  |  |  |     @click:row="handleRowClick" | 
					
						
							|  |  |  |   > | 
					
						
							|  |  |  |     <template #item.category="{ item }"> | 
					
						
							|  |  |  |       {{ capitalize(item.category) }} | 
					
						
							|  |  |  |     </template> | 
					
						
							|  |  |  |     <template #item.timestamp="{ item }"> | 
					
						
							|  |  |  |       {{ $d(Date.parse(item.timestamp), "long") }} | 
					
						
							|  |  |  |     </template> | 
					
						
							|  |  |  |     <template #item.status="{ item }"> | 
					
						
							|  |  |  |       {{ capitalize(item.status) }} | 
					
						
							|  |  |  |     </template> | 
					
						
							|  |  |  |     <template #item.actions="{ item }"> | 
					
						
							|  |  |  |       <v-btn icon @click.stop="deleteReport(item.id)"> | 
					
						
							|  |  |  |         <v-icon>{{ $globals.icons.delete }}</v-icon> | 
					
						
							|  |  |  |       </v-btn> | 
					
						
							|  |  |  |     </template> | 
					
						
							|  |  |  |   </v-data-table> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  | import { defineComponent, useContext, useRouter } from "@nuxtjs/composition-api"; | 
					
						
							| 
									
										
										
										
											2022-10-22 11:51:07 -08:00
										 |  |  | import { ReportSummary } from "~/lib/api/types/reports"; | 
					
						
							| 
									
										
										
										
											2021-11-26 22:37:06 -09:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default defineComponent({ | 
					
						
							|  |  |  |   props: { | 
					
						
							|  |  |  |     items: { | 
					
						
							|  |  |  |       required: true, | 
					
						
							|  |  |  |       type: Array as () => Array<ReportSummary>, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   setup(_, context) { | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  |     const { i18n } = useContext(); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |     const router = useRouter(); | 
					
						
							| 
									
										
										
										
											2021-11-26 22:37:06 -09:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const headers = [ | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  |       { text: i18n.t("category.category"), value: "category" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.name"), value: "name" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.timestamp"), value: "timestamp" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.status"), value: "status" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.delete"), value: "actions" }, | 
					
						
							| 
									
										
										
										
											2021-11-26 22:37:06 -09:00
										 |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     function handleRowClick(item: ReportSummary) { | 
					
						
							| 
									
										
										
										
											2023-12-07 11:08:47 -06:00
										 |  |  |       if (item.status === "in-progress") { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |       router.push(`/group/reports/${item.id}`); | 
					
						
							| 
									
										
										
										
											2021-11-26 22:37:06 -09:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function capitalize(str: string) { | 
					
						
							|  |  |  |       return str.charAt(0).toUpperCase() + str.slice(1); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function deleteReport(id: string) { | 
					
						
							|  |  |  |       context.emit("delete", id); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       headers, | 
					
						
							|  |  |  |       handleRowClick, | 
					
						
							|  |  |  |       capitalize, | 
					
						
							|  |  |  |       deleteReport, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-09 19:08:48 -08:00
										 |  |  | <style lang="scss" scoped></style> |