Skip to content

Commit 1961661

Browse files
authored
✨ add operator to TripCreationForm (#3069)
1 parent 729fb63 commit 1961661

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

resources/vue/components/TripCreation/TripCreationForm.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import {trans} from "laravel-vue-i18n";
66
export default {
77
name: "TripCreationForm",
88
components: {StationRow},
9+
mounted() {
10+
this.loadOperators();
11+
},
912
data() {
1013
return {
1114
form: {
@@ -39,6 +42,7 @@ export default {
3942
{value: "taxi", text: "taxi"},
4043
{value: "plane", text: "plane"},
4144
],
45+
operators: null,
4246
disallowed: ["fahrrad", "auto", "fuss", "fuß", "foot", "car", "bike"],
4347
showDisallowed: false,
4448
};
@@ -125,6 +129,20 @@ export default {
125129
return this.trainTypeInput.toLowerCase().includes(disallowed);
126130
});
127131
},
132+
loadOperators() {
133+
fetch("/api/v1/operators", {
134+
method: "GET",
135+
headers: {
136+
"Content-Type": "application/json",
137+
},
138+
}).then((data) => {
139+
if (data.ok) {
140+
data.json().then((result) => {
141+
this.operators = result.data;
142+
});
143+
}
144+
});
145+
}
128146
}
129147
}
130148
</script>
@@ -181,12 +199,12 @@ export default {
181199
></StationRow>
182200
</div>
183201
<div class="row g-3 mt-1">
184-
<div class="col-4">
202+
<div class="col-3">
185203
<input type="text" class="form-control mobile-input-fs-16"
186204
:placeholder="trans('trip_creation.form.line')" v-model="trainTypeInput"
187205
@focusout="checkDisallowed">
188206
</div>
189-
<div class="col-4">
207+
<div class="col-3">
190208
<input type="text" class="form-control mobile-input-fs-16"
191209
:placeholder="trans('trip_creation.form.number')" v-model="journeyNumberInput">
192210
</div>
@@ -196,6 +214,12 @@ export default {
196214
<option v-for="category in categories" :value="category.value">{{ category.text }}</option>
197215
</select>
198216
</div>
217+
<div class="col">
218+
<select class="form-select" v-model="form.operatorId">
219+
<option selected>{{ trans("trip_creation.form.operator") }}</option>
220+
<option v-for="operator in operators" :value="operator.id">{{ operator.name }}</option>
221+
</select>
222+
</div>
199223
</div>
200224
<div class="row g-3 mt-1">
201225
<span class="text-danger" v-show="showDisallowed">

0 commit comments

Comments
 (0)