Skip to content

Commit

Permalink
Merge pull request #219 from navikt/hurtigknapper-fix
Browse files Browse the repository at this point in the history
Update hot_claimLineTimeInput.js
  • Loading branch information
olsenrasmus authored Jul 9, 2024
2 parents af873e8 + 51cf692 commit bb824e7
Showing 1 changed file with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -946,54 +946,59 @@ export default class Hot_claimLineTimeInput extends LightningElement {
}
addTravelTime(event) {
const index = this.getTimesIndex(event.target.name);
//date

// Date
this.times[index].dateTravelTo = this.times[index].date;
this.times[index].dateTravelToMilliseconds = new Date(this.times[index].date).getTime();

//start
let dateTimeStart = new Date(this.times[index].startTime);
dateTimeStart.setMinutes(dateTimeStart.getMinutes() - event.detail);

// Start Time Travel To (start time of the appointment - travel duration)
let startTime = new Date(this.times[index].startTime);
let dateTimeStart = new Date(startTime.getTime() - event.detail * 60000);
let timeStringStart = this.dateTimeToTimeString(dateTimeStart, false);
this.times[index].startTimeTravelToString = timeStringStart;
this.times[index].startTimeTravelTo = dateTimeStart.getTime();

let startTimeElements = this.template.querySelectorAll('[data-id="startTimeTravelTo"]');
startTimeElements[index].setValue(this.times[index].startTimeTravelToString);

//end
// End Time Travel To (start time of the appointment)
let dateTime = new Date(this.times[index].startTime);
dateTime.setHours(dateTime.getHours());
let timeString = this.dateTimeToTimeString(dateTime, false);
this.times[index].endTimeTravelToString = timeString;
this.times[index].endTimeTravelTo = dateTime.getTime();

let endTimeElements = this.template.querySelectorAll('[data-id="endTimeTravelTo"]');
endTimeElements[index].setValue(this.times[index].endTimeTravelToString);
}

addTravelTimeFrom(event) {
const index = this.getTimesIndex(event.target.name);
//date

// Date
this.times[index].dateTravelFrom = this.times[index].date;
this.times[index].dateTravelFromMilliseconds = new Date(this.times[index].date).getTime();
//end
let dateTime = new Date(this.times[index].endTime);
dateTime.setHours(dateTime.getHours());
let timeString = this.dateTimeToTimeString(dateTime, false);
this.times[index].startTimeTravelFromString = timeString;
this.times[index].startTimeTravelFrom = dateTime.getTime();

// Start Time Travel From (end time of the appointment)
let endTime = new Date(this.times[index].endTime);
let startTimeTravelFromString = this.dateTimeToTimeString(endTime, false);
this.times[index].startTimeTravelFromString = startTimeTravelFromString;
this.times[index].startTimeTravelFrom = endTime.getTime();

let startTimeElements = this.template.querySelectorAll('[data-id="startTimeTravelFrom"]');
startTimeElements[index].setValue(this.times[index].startTimeTravelFromString);
//start

let dateTimeStart = new Date(this.times[index].endTime);
dateTimeStart.setMinutes(dateTimeStart.getMinutes() + event.detail);
// End Time Travel From (start time of travel + travel duration)
let endTimeTravelFrom = new Date(this.times[index].endTime);
endTimeTravelFrom = new Date(endTimeTravelFrom.getTime() + event.detail * 60000);

let timeStringStart = this.dateTimeToTimeString(dateTimeStart, false);
this.times[index].endTimeTravelFromString = timeStringStart;
this.times[index].endTimeTravelFrom = dateTimeStart.getTime();
let endTimeTravelFromString = this.dateTimeToTimeString(endTimeTravelFrom, false);
this.times[index].endTimeTravelFromString = endTimeTravelFromString;
this.times[index].endTimeTravelFrom = endTimeTravelFrom.getTime();

let endTimeElements = this.template.querySelectorAll('[data-id="endTimeTravelFrom"]');
endTimeElements[index].setValue(this.times[index].endTimeTravelFromString);
}

cloneClaimLineItem(event) {
let hasErrors = 0;
hasErrors += this.validateSimpleTimes();
Expand Down

0 comments on commit bb824e7

Please sign in to comment.