Skip to content

Commit 99db7f8

Browse files
authored
Merge pull request #628 from MartinRinas/feature-fixed-hour-tariff
Make input fields required and update price handling
2 parents 7c122f3 + ae9f5ae commit 99db7f8

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

Diff for: src/components/electricity_tariffs/fixed_hours/TimeTable.vue

+17-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<select
4343
v-model="time[0]"
4444
class="form-control"
45+
required
46+
@change="updateEndOptions(index)"
4547
>
4648
<option
4749
value=""
@@ -62,6 +64,7 @@
6264
<select
6365
v-model="time[1]"
6466
class="form-control"
67+
required
6568
>
6669
<option
6770
value=""
@@ -70,7 +73,7 @@
7073
-- Bitte auswählen --
7174
</option>
7275
<option
73-
v-for="option in generateTimeOptions('01:00', '24:00')"
76+
v-for="option in endOptions[index]"
7477
:key="option.value"
7578
:value="option.value"
7679
>
@@ -122,7 +125,9 @@ export default {
122125
},
123126
emits: ["update:modelValue"],
124127
data() {
125-
return {};
128+
return {
129+
endOptions: this.modelValue.map(() => this.generateTimeOptions("01:00", "24:00")),
130+
};
126131
},
127132
computed: {
128133
value: {
@@ -152,6 +157,16 @@ export default {
152157
removeTime(timeIndex) {
153158
this.value.splice(timeIndex, 1);
154159
},
160+
updateEndOptions(index) {
161+
const startTime = this.value[index][0];
162+
if (startTime) {
163+
const startHour = parseInt(startTime.split(":")[0], 10) + 1;
164+
const startString = startHour.toString().padStart(2, "0") + ":00";
165+
this.endOptions[index] = this.generateTimeOptions(startString, "24:00");
166+
} else {
167+
this.endOptions[index] = this.generateTimeOptions("01:00", "24:00");
168+
}
169+
},
155170
},
156171
};
157172
</script>

Diff for: src/components/electricity_tariffs/fixed_hours/electricity_tariff.vue

+11-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
:precision="3"
1111
required
1212
unit="ct/kWh"
13-
:model-value="electricityTariff.configuration.default_price"
14-
@update:model-value="updateConfiguration(parseFloat($event.toFixed(3)), 'configuration.default_price')"
13+
:model-value="electricityTariff.configuration.default_price * 100"
14+
@update:model-value="updateConfiguration(parseFloat(($event / 100).toFixed(3)), 'configuration.default_price')"
1515
>
1616
<template #help> Standardpreis sofern kein anderer Tarif aktiv ist. </template>
1717
</openwb-base-number-input>
@@ -34,7 +34,8 @@
3434
v-if="electricityTariff.configuration.tariffs.length === 0"
3535
subtype="info"
3636
>
37-
Es wurde noch kein Tarif konfiguriert.
37+
Es wurde noch kein Tarif konfiguriert. Klicken Sie auf das Plus-Symbol um einen neuen Tarif hinzuzufügen.<br />
38+
Tarife ermöglichen es unterschiedliche Preise für unterschiedliche Zeiten zu definieren.
3839
</openwb-base-alert>
3940
<openwb-base-card
4041
v-for="(tariff, index) in electricityTariff.configuration.tariffs"
@@ -68,19 +69,20 @@
6869
:precision="3"
6970
required
7071
unit="ct/kWh"
71-
:model-value="tariff.price"
72-
@update:model-value="updateTariff(parseFloat($event.toFixed(3)), index, 'price')"
72+
:model-value="tariff.price * 100"
73+
@update:model-value="updateTariff(parseFloat(($event / 100).toFixed(3)), index, 'price')"
7374
/>
7475
<openwb-base-select-input
7576
title="Quartale"
7677
:options="[
77-
{ value: '1', text: '1. Quartal' },
78-
{ value: '2', text: '2. Quartal' },
79-
{ value: '3', text: '3. Quartal' },
80-
{ value: '4', text: '4. Quartal' },
78+
{ value: 1, text: '1. Quartal' },
79+
{ value: 2, text: '2. Quartal' },
80+
{ value: 3, text: '3. Quartal' },
81+
{ value: 4, text: '4. Quartal' },
8182
]"
8283
:model-value="tariff.active_times.quarters"
8384
multiple
85+
required
8486
@update:model-value="updateQuarters($event, index)"
8587
/>
8688
<time-table

0 commit comments

Comments
 (0)