Mercurial > gemma
changeset 5666:37c2354a6024 clickable-links
Render links only to known bottlenecks
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 05 Dec 2023 15:34:31 +0100 |
parents | 8fc26cc61ba8 |
children | 57af2b37a37e |
files | client/src/components/importoverview/LogItem.vue |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importoverview/LogItem.vue Tue Dec 05 12:22:39 2023 +0100 +++ b/client/src/components/importoverview/LogItem.vue Tue Dec 05 15:34:31 2023 +0100 @@ -32,7 +32,9 @@ } ]" ><template v-for="part in line_message"> - <template v-if="/\w+_Bottleneck_?\d+/.test(part)"> + <template + v-if="/\w+_Bottleneck_?\d+/.test(part) && bottlenecksLookup[part]" + > <a @click="showBottleneck(part)" href="#" :key="part">{{ part }}</a> </template> <template v-else> @@ -64,6 +66,14 @@ props: ["height", "line", "index"], computed: { ...mapGetters("bottlenecks", ["bottlenecksForDisplay"]), + bottlenecksLookup: { + get() { + return this.bottlenecksForDisplay.reduce((o, bn) => { + o[bn.properties.bottleneck_id] = bn; + return o; + }, {}); + } + }, line_message: { get() { const search = /(\w+_Bottleneck_?\d+)/g; @@ -73,9 +83,7 @@ }, methods: { showBottleneck(bottleneck_id) { - const bottleneck = this.bottlenecksForDisplay.filter(bottlenecks => { - return bottlenecks.properties.bottleneck_id === bottleneck_id; - })[0]; + const bottleneck = this.bottlenecksLookup[bottleneck_id]; this.$store .dispatch( "bottlenecks/setSelectedBottleneck",