@@ -74,11 +80,12 @@
-
import Modal from "bootstrap/js/dist/modal";
import LabelAndValue from "./LabelAndValue.vue";
-import ChargingPlanSettings from "./ChargingPlanSettings.vue";
+import ChargingPlansSettings from "./ChargingPlansSettings.vue";
import ChargingPlanArrival from "./ChargingPlanArrival.vue";
import formatter from "../mixins/formatter";
@@ -110,7 +117,7 @@ const ONE_MINUTE = 60 * 1000;
export default {
name: "ChargingPlan",
- components: { LabelAndValue, ChargingPlanSettings, ChargingPlanArrival },
+ components: { LabelAndValue, ChargingPlansSettings, ChargingPlanArrival },
mixins: [formatter, collector],
props: {
currency: String,
@@ -162,12 +169,18 @@ export default {
limitSoc: function () {
return this.vehicle?.limitSoc;
},
- plans: function () {
+ staticPlan: function () {
if (this.socBasedPlanning) {
- return this.vehicle?.plans || [];
+ return this.vehicle?.plan;
}
if (this.planEnergy && this.planTime) {
- return [{ energy: this.planEnergy, time: this.planTime }];
+ return { energy: this.planEnergy, time: this.planTime };
+ }
+ return null;
+ },
+ repeatingPlans: function () {
+ if (this.vehicle?.repeatingPlans.length > 0) {
+ return [...this.vehicle.repeatingPlans];
}
return [];
},
@@ -183,8 +196,8 @@ export default {
arrivalTabActive: function () {
return this.activeTab === "arrival";
},
- chargingPlanSettingsProps: function () {
- return this.collectProps(ChargingPlanSettings);
+ chargingPlansSettingsProps: function () {
+ return this.collectProps(ChargingPlansSettings);
},
chargingPlanArrival: function () {
return this.collectProps(ChargingPlanArrival);
@@ -211,6 +224,11 @@ export default {
effectivePlanTime() {
this.updateTargetTimeLabel();
},
+ "$i18n.locale": {
+ handler() {
+ this.updateTargetTimeLabel();
+ },
+ },
},
mounted() {
this.modal = Modal.getOrCreateInstance(this.$refs.modal);
@@ -263,7 +281,7 @@ export default {
showArrivalTab: function () {
this.activeTab = "arrival";
},
- updatePlan: function ({ soc, time, energy }) {
+ updateStaticPlan: function ({ soc, time, energy }) {
const timeISO = time.toISOString();
if (this.socBasedPlanning) {
api.post(`${this.apiVehicle}plan/soc/${soc}/${timeISO}`);
@@ -271,13 +289,16 @@ export default {
api.post(`${this.apiLoadpoint}plan/energy/${energy}/${timeISO}`);
}
},
- removePlan: function () {
+ removeStaticPlan: function () {
if (this.socBasedPlanning) {
api.delete(`${this.apiVehicle}plan/soc`);
} else {
api.delete(`${this.apiLoadpoint}plan/energy`);
}
},
+ updateRepeatingPlans: function (plans) {
+ api.post(`${this.apiVehicle}plan/repeating`, { plans });
+ },
setMinSoc: function (soc) {
api.post(`${this.apiVehicle}minsoc/${soc}`);
},
diff --git a/assets/js/components/ChargingPlanPreview.test.js b/assets/js/components/ChargingPlanPreview.test.js
index ed719f6ebc..eda5e8b63e 100644
--- a/assets/js/components/ChargingPlanPreview.test.js
+++ b/assets/js/components/ChargingPlanPreview.test.js
@@ -37,8 +37,8 @@ describe("basics", () => {
result = wrapper.vm.slots;
});
- test("should return 42 slots", () => {
- expect(result.length).eq(42);
+ test("should return 39 slots", () => {
+ expect(result.length).eq(39);
});
test("slots should be an hour apart", () => {
diff --git a/assets/js/components/ChargingPlanPreview.vue b/assets/js/components/ChargingPlanPreview.vue
index 660451b464..ee5d60b0c6 100644
--- a/assets/js/components/ChargingPlanPreview.vue
+++ b/assets/js/components/ChargingPlanPreview.vue
@@ -25,7 +25,12 @@