Skip to content

Commit 046d8e8

Browse files
authored
🐛 Fix category icon for manual checkins (#3597)
1 parent 096f19e commit 046d8e8

File tree

4 files changed

+41
-42
lines changed

4 files changed

+41
-42
lines changed

resources/views/includes/status.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ class="like {{ auth()->user() && $status->likes->where('user_id', auth()->user()
293293
'start' => $status->checkin->originStopover->station->id,
294294
'destination' => $status->checkin->destinationStopover->station->id,
295295
'departure' => $status->checkin->originStopover->departure_planned->toIso8601String(),
296-
'idType' => 'trwl'
296+
'idType' => 'trwl',
297+
'category' => $status->checkin->trip->category->value,
297298
]) }}" class="dropdown-item">
298299
<div class="dropdown-icon-suspense">
299300
<i class="fas fa-user-plus" aria-hidden="true"></i>
Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
1-
<script>
2-
export default {
3-
name: "ProductIcon",
4-
props: {
5-
product: {
6-
type: String,
7-
required: true
8-
}
9-
},
10-
data() {
11-
return {
12-
iconPaths: {
13-
tram: "/img/tram.svg",
14-
bus: "/img/bus.svg",
15-
subway: "/img/subway.svg",
16-
suburban: "/img/suburban.svg",
17-
}
18-
};
19-
},
20-
computed: {
21-
productExists() {
22-
return this.iconPaths.hasOwnProperty(this.$props.product);
23-
},
24-
fontAwesomeIcon() {
25-
if (this.$props.product === 'taxi') {
26-
return 'fa-taxi';
27-
}
28-
if (this.$props.product === 'ferry') {
29-
return 'fa-ship';
30-
}
31-
return 'fa-train';
32-
}
33-
}
34-
}
1+
<script lang="ts" setup>
2+
defineProps({
3+
product: {
4+
type: String,
5+
default: '',
6+
required: true
7+
}
8+
});
9+
10+
const iconForProduct = (product) => {
11+
if (['tram', 'bus', 'subway', 'suburban'].includes(product)) {
12+
return `/img/${product}.svg`;
13+
}
14+
15+
return null;
16+
};
17+
18+
const fontAwesomeIcon = (product) => {
19+
switch (product) {
20+
case 'taxi':
21+
return 'fa-taxi';
22+
case 'plane':
23+
return 'fa-plane';
24+
case 'ferry':
25+
return 'fa-ship';
26+
default:
27+
return 'fa-train';
28+
}
29+
};
3530
</script>
3631

3732
<template>
38-
<img v-if="productExists"
39-
:alt="this.$props.product"
40-
:src="this.iconPaths[this.$props.product]"
41-
class="product-icon">
42-
<i v-else class="fas" :class="fontAwesomeIcon"></i>
33+
<img v-if="iconForProduct(this.product)"
34+
:alt="this.product"
35+
:src="iconForProduct(this.product)"
36+
class="product-icon">
37+
<i v-else class="fas" :class="fontAwesomeIcon(this.product)"></i>
4338
</template>

resources/vue/components/Stationboard.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default {
4747
lineName: selectedItem.line.name,
4848
start: this.useInternalIdentifiers ? this.selectedTrain.stop.id : this.meta.station.ibnr,
4949
departure: selectedItem.when,
50+
category: selectedItem.line.product,
5051
});
5152
5253
this.pushHistory(data);
@@ -136,7 +137,8 @@ export default {
136137
this.selectedTrain = {
137138
tripId: urlParams.get('tripId'),
138139
line: {
139-
name: urlParams.get('lineName')
140+
name: urlParams.get('lineName'),
141+
product: urlParams.get('category') || null
140142
},
141143
stop: {
142144
id: urlParams.get('start')

resources/vue/components/TripCreation/TripCreationForm.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ export default {
192192
lineName: result.lineName,
193193
start: result.origin.id,
194194
departure: this.form.originDeparturePlanned,
195-
idType: 'trwl'
195+
idType: 'trwl',
196+
category: result.category,
196197
};
197198
198199
window.location.href = `/stationboard?${new URLSearchParams(query).toString()}`;

0 commit comments

Comments
 (0)