Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum time spent #208

Merged
merged 5 commits into from
Sep 20, 2022
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
31 changes: 31 additions & 0 deletions src/components/SettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,37 @@
</b-form-radio-group>
</b-input-group>
</div>
<div class="row mb-2">
<b-input-group class="col">
<b-input-group-prepend is-text>
<b-form-checkbox
v-model="vxm.store.settings.useMinimumTime"
class="mr-n2"
/>
</b-input-group-prepend>
<b-input-group-append is-text
>Minimum time of
</b-input-group-append>
<b-form-input
v-model="vxm.store.settings.minimumDailyTime"
type="number"
:number="true"
:disabled="!vxm.store.settings.useMinimumTime"
step="5"
/>
<b-input-group-append is-text>minutes</b-input-group-append>
<b-form-input
v-model="vxm.store.settings.minimumTimeGap"
type="number"
:number="true"
:disabled="!vxm.store.settings.useMinimumTime"
/>
<b-input-group-append is-text>
{{ `day${vxm.store.settings.minimumTimeGap > 1 ? "s" : ""}` }}
after the current day</b-input-group-append
>
</b-input-group>
</div>
<div class="row mb-2">
<b-input-group class="col" prepend="Start time">
<b-form-timepicker
Expand Down
10 changes: 10 additions & 0 deletions src/store/index.vuex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ export class Store extends VuexModule {
completedTimes[i] +
completedEfforts[i] * this.settings.effortWeight +
(this.settings.timeIncludesEvents ? eventTimes[i] : 0);

if (
this.settings.useMinimumTime &&
i > this.settings.minimumTimeGap
) {
combinedDayData[i] = Math.max(
this.settings.minimumDailyTime,
combinedDayData[i]
);
}
}

let dayToAssign = daysUntilDue;
Expand Down
6 changes: 6 additions & 0 deletions src/types/Changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,10 @@ Typing a hotkey in the description field in the task modal could open modals/tri
title: "Bug fix",
description: "Fix bug where tasks didn't load properly from local storage",
},
{
version: "3.8.0",
title: "Add minimum time spent setting",
description:
"Users can have the option to set all days a certain number of days following the current date to have a given minimum time spent",
},
];
10 changes: 10 additions & 0 deletions src/types/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default class Settings {
dayStartTimes: Record<number, string>;
dayEndTimes: Record<number, string>;

useMinimumTime: boolean;
minimumDailyTime: number;
minimumTimeGap: number;

constructor({
effortWeight = 1,
baseStartTime = 930,
Expand All @@ -26,6 +30,9 @@ export default class Settings {
dayEndTimes = {},
timeIncludesEvents = false,
considerCompletedChunksOnAllDays = false,
useMinimumTime = false,
minimumDailyTime = 60,
minimumTimeGap = 1,
}) {
this.effortWeight = effortWeight;
this.baseStartTime = baseStartTime;
Expand All @@ -36,6 +43,9 @@ export default class Settings {
this.dayEndTimes = dayEndTimes;
this.timeIncludesEvents = timeIncludesEvents;
this.considerCompletedChunksOnAllDays = considerCompletedChunksOnAllDays;
this.useMinimumTime = useMinimumTime;
this.minimumDailyTime = minimumDailyTime;
this.minimumTimeGap = minimumTimeGap;
}

stringToTime(str: string): number {
Expand Down