Added calculated duration of new timestamps
This commit is contained in:
parent
64ba600a8f
commit
1d5df2a4b1
4 changed files with 48 additions and 16 deletions
|
@ -21,6 +21,7 @@
|
||||||
placeholder="Choose a start date"
|
placeholder="Choose a start date"
|
||||||
:max="times.end.date"
|
:max="times.end.date"
|
||||||
dark
|
dark
|
||||||
|
@input="() => updateCurrentDuration()"
|
||||||
>
|
>
|
||||||
</b-form-datepicker>
|
</b-form-datepicker>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
required
|
required
|
||||||
placeholder="Choose a start time"
|
placeholder="Choose a start time"
|
||||||
dark
|
dark
|
||||||
|
@input="() => updateCurrentDuration()"
|
||||||
>
|
>
|
||||||
</b-form-timepicker>
|
</b-form-timepicker>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
@ -47,6 +49,7 @@
|
||||||
placeholder="Choose an end date"
|
placeholder="Choose an end date"
|
||||||
:min="times.start.date"
|
:min="times.start.date"
|
||||||
dark
|
dark
|
||||||
|
@input="() => updateCurrentDuration()"
|
||||||
>
|
>
|
||||||
</b-form-datepicker>
|
</b-form-datepicker>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
@ -59,6 +62,7 @@
|
||||||
show-seconds
|
show-seconds
|
||||||
placeholder="Choose an end time"
|
placeholder="Choose an end time"
|
||||||
dark
|
dark
|
||||||
|
@input="() => updateCurrentDuration()"
|
||||||
>
|
>
|
||||||
</b-form-timepicker>
|
</b-form-timepicker>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
@ -67,17 +71,30 @@
|
||||||
label="Duration [seconds]"
|
label="Duration [seconds]"
|
||||||
label-for="duration"
|
label-for="duration"
|
||||||
>
|
>
|
||||||
<b-form-input
|
<b-input-group>
|
||||||
id="duration"
|
<b-input-group-prepend
|
||||||
v-model="times.duration"
|
is-text
|
||||||
type="number"
|
:class="{ disabled: !times.finished || !times.editableDuration }"
|
||||||
:required="times.finished"
|
>
|
||||||
:disabled="!times.finished"
|
<b-form-checkbox
|
||||||
placeholder="Choose a duration"
|
class="mr-n2"
|
||||||
min="0"
|
v-model="times.editableDuration"
|
||||||
dark
|
@input="() => updateCurrentDuration()"
|
||||||
>
|
>
|
||||||
</b-form-input>
|
</b-form-checkbox>
|
||||||
|
</b-input-group-prepend>
|
||||||
|
<b-form-input
|
||||||
|
id="duration"
|
||||||
|
v-model="times.duration"
|
||||||
|
type="number"
|
||||||
|
:required="times.finished && !times.editableDuration"
|
||||||
|
:disabled="!times.finished || !times.editableDuration"
|
||||||
|
placeholder="Choose a duration"
|
||||||
|
min="0"
|
||||||
|
dark
|
||||||
|
>
|
||||||
|
</b-form-input>
|
||||||
|
</b-input-group>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
<b-form-invalid-feedback :state="!failed">
|
<b-form-invalid-feedback :state="!failed">
|
||||||
Something went wrong.
|
Something went wrong.
|
||||||
|
@ -117,7 +134,8 @@ export default {
|
||||||
start: { date: undefined, time: undefined },
|
start: { date: undefined, time: undefined },
|
||||||
end: { date: undefined, time: undefined },
|
end: { date: undefined, time: undefined },
|
||||||
finished: false,
|
finished: false,
|
||||||
duration: 0
|
duration: 0,
|
||||||
|
editableDuration: false
|
||||||
},
|
},
|
||||||
selectableProjects: [],
|
selectableProjects: [],
|
||||||
failed: false,
|
failed: false,
|
||||||
|
@ -156,6 +174,12 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
},
|
||||||
|
exactCalcDuration: function() {
|
||||||
|
return helperService.calcDurationInSeconds(
|
||||||
|
this.resultRecord.start_time,
|
||||||
|
this.resultRecord.end_time
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -185,6 +209,11 @@ export default {
|
||||||
},
|
},
|
||||||
deleteRecord: function() {
|
deleteRecord: function() {
|
||||||
store.dispatch("removeRecord", this.record.record_id);
|
store.dispatch("removeRecord", this.record.record_id);
|
||||||
|
},
|
||||||
|
updateCurrentDuration: function() {
|
||||||
|
if (!this.times.editableDuration) {
|
||||||
|
this.times.duration = this.exactCalcDuration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
|
|
|
@ -146,5 +146,9 @@ export const helperService = {
|
||||||
":" +
|
":" +
|
||||||
dateTime.getSeconds()
|
dateTime.getSeconds()
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
calcDurationInSeconds(start, end = new Date()) {
|
||||||
|
return (new Date(end).getTime() - new Date(start).getTime()) / 1000;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,8 +145,7 @@ function processRecords(data) {
|
||||||
rec.running = rec.end_time === null;
|
rec.running = rec.end_time === null;
|
||||||
|
|
||||||
if (rec.running) {
|
if (rec.running) {
|
||||||
rec.duration =
|
rec.duration = helperService.calcDurationInSeconds(rec.start_time);
|
||||||
(new Date().getTime() - new Date(rec.start_time).getTime()) / 1000;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -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)
|
.b-form-datepicker label:not(.text-muted), .b-form-timepicker label:not(.text-muted)
|
||||||
color: $font-primary !important
|
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
|
color: $font-inactive !important
|
||||||
border-color: $background-primary !important
|
border-color: $background-primary !important
|
||||||
|
|
||||||
input
|
input, .input-group-prepend *
|
||||||
color: $font-primary !important
|
color: $font-primary !important
|
||||||
border-color: $grey !important
|
border-color: $grey !important
|
||||||
background-color: $background-primary !important
|
background-color: $background-primary !important
|
||||||
|
|
Loading…
Reference in a new issue