diff --git a/src/components/forms/FormRecordDetails.vue b/src/components/forms/FormRecordDetails.vue
index 9b35773..1869a1d 100644
--- a/src/components/forms/FormRecordDetails.vue
+++ b/src/components/forms/FormRecordDetails.vue
@@ -21,6 +21,7 @@
placeholder="Choose a start date"
:max="times.end.date"
dark
+ @input="() => updateCurrentDuration()"
>
@@ -32,6 +33,7 @@
required
placeholder="Choose a start time"
dark
+ @input="() => updateCurrentDuration()"
>
@@ -47,6 +49,7 @@
placeholder="Choose an end date"
:min="times.start.date"
dark
+ @input="() => updateCurrentDuration()"
>
@@ -59,6 +62,7 @@
show-seconds
placeholder="Choose an end time"
dark
+ @input="() => updateCurrentDuration()"
>
@@ -67,17 +71,30 @@
label="Duration [seconds]"
label-for="duration"
>
-
-
+
+
+ updateCurrentDuration()"
+ >
+
+
+
+
+
Something went wrong.
@@ -117,7 +134,8 @@ export default {
start: { date: undefined, time: undefined },
end: { date: undefined, time: undefined },
finished: false,
- duration: 0
+ duration: 0,
+ editableDuration: false
},
selectableProjects: [],
failed: false,
@@ -156,6 +174,12 @@ export default {
}
return result;
+ },
+ exactCalcDuration: function() {
+ return helperService.calcDurationInSeconds(
+ this.resultRecord.start_time,
+ this.resultRecord.end_time
+ );
}
},
methods: {
@@ -185,6 +209,11 @@ export default {
},
deleteRecord: function() {
store.dispatch("removeRecord", this.record.record_id);
+ },
+ updateCurrentDuration: function() {
+ if (!this.times.editableDuration) {
+ this.times.duration = this.exactCalcDuration;
+ }
}
},
created: function() {
diff --git a/src/services/helper.service.js b/src/services/helper.service.js
index d122de4..7c1be4f 100644
--- a/src/services/helper.service.js
+++ b/src/services/helper.service.js
@@ -146,5 +146,9 @@ export const helperService = {
":" +
dateTime.getSeconds()
);
+ },
+
+ calcDurationInSeconds(start, end = new Date()) {
+ return (new Date(end).getTime() - new Date(start).getTime()) / 1000;
}
};
diff --git a/src/services/juggl.service.js b/src/services/juggl.service.js
index d6b915d..a3114fb 100644
--- a/src/services/juggl.service.js
+++ b/src/services/juggl.service.js
@@ -145,8 +145,7 @@ function processRecords(data) {
rec.running = rec.end_time === null;
if (rec.running) {
- rec.duration =
- (new Date().getTime() - new Date(rec.start_time).getTime()) / 1000;
+ rec.duration = helperService.calcDurationInSeconds(rec.start_time);
}
});
return data;
diff --git a/src/style/theme.sass b/src/style/theme.sass
index 3f4600e..adae8a3 100644
--- a/src/style/theme.sass
+++ b/src/style/theme.sass
@@ -114,11 +114,11 @@ header.b-calendar-grid-caption, .b-calendar-grid-weekdays *, header.b-calendar-h
.b-form-datepicker label:not(.text-muted), .b-form-timepicker label:not(.text-muted)
color: $font-primary !important
-input:disabled, .b-form-timepicker[aria-disabled=true], .b-form-datepicker[aria-disabled=true]
+input:disabled, .b-form-timepicker[aria-disabled=true], .b-form-datepicker[aria-disabled=true], .input-group-prepend.disabled *
color: $font-inactive !important
border-color: $background-primary !important
-input
+input, .input-group-prepend *
color: $font-primary !important
border-color: $grey !important
background-color: $background-primary !important