Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/src/components/schedule-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ export default class ScheduleItem extends Vue {
async setLevel() {
this.localSchedule.level = this.levelSlider;
this.levelMenu = false;
await this.save();
if (!this.newSchedule) {
await this.save();
}
Comment on lines 188 to +193

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep displayed level in sync with submitted value

For new schedules, setLevel now only mutates localSchedule and addSchedule submits that local state, but the template still renders {{ schedule.level }} from the prop, which is never updated for new items. This creates a mismatch where the UI shows the old percentage while the submitted schedule uses the new one, so users can unknowingly submit a different level than they see. Consider binding the display to localSchedule.level or syncing newSchedule when edits happen.

Useful? React with 👍 / 👎.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex update this branch with edits

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Testing

  • ⚠️ Not run (not requested).

Screenshot

  • Not captured (app not run).

View task →

}
get directLevel(): number {
const settings = getVehicleLocationSettings(this.vehicle);
Expand All @@ -203,14 +205,14 @@ export default class ScheduleItem extends Vue {
} else {
this.localSchedule.time = datetime.toJSDate().toISOString();
}
if (this.localSchedule.time !== was) {
if (this.localSchedule.time !== was && !this.newSchedule) {
await this.save();
}
}

async addSchedule() {
this.isSaving = true;
this.$emit(`add`, () => {
this.$emit(`add`, this.localSchedule, () => {
this.isSaving = false;
});
}
Expand Down
18 changes: 10 additions & 8 deletions app/src/components/vehicle-schedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ export default class VehicleSchedule extends Vue {
if (f.type === GQLScheduleType.Trip) return true;
if (f.type === GQLScheduleType.Manual) return true;
if (f.type === GQLScheduleType.AI) {
this.guideDateTime = DateTime.fromMillis(
Math.ceil(new Date(f.time).getTime() / 60e4) * 60e4
);
const aiTime = Math.ceil(new Date(f.time).getTime() / 60e4) * 60e4;
// Only use AI schedule time if it's in the future
if (aiTime > Date.now()) {
this.guideDateTime = DateTime.fromMillis(aiTime);
}
}
return false;
});
Expand All @@ -87,16 +89,16 @@ export default class VehicleSchedule extends Vue {
};
}

async addSchedule(callback: any) {
if (this.newSchedule && this.newSchedule.type) {
const lvl = this.newSchedule.level || null;
async addSchedule(localSchedule: Partial<GQLSchedule>, callback: any) {
if (localSchedule && localSchedule.type) {
const lvl = localSchedule.level || null;
const time =
(this.newSchedule.time && new Date(this.newSchedule.time)) || null;
(localSchedule.time && new Date(localSchedule.time)) || null;

await this.$scClient.updateSchedule(
undefined,
this.vehicle.id,
this.newSchedule.type,
localSchedule.type,
lvl,
time
);
Expand Down
Loading