feat(frontend): add highlighting for tasks

This commit is contained in:
DCsunset 2020-07-15 19:59:01 -07:00
parent 099543c0e1
commit 92dd18fbe0
3 changed files with 48 additions and 23 deletions

View file

@ -45,7 +45,7 @@
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
<v-btn @click="closeDialog"> <v-btn text @click="closeDialog">
Cancel Cancel
</v-btn> </v-btn>
<v-btn @click="reset"> <v-btn @click="reset">

View file

@ -40,6 +40,7 @@
:headers="headers" :headers="headers"
show-select show-select
item-key="uuid" item-key="uuid"
:item-class="rowClass"
v-model="selected" v-model="selected"
class="elevation-1" class="elevation-1"
> >
@ -109,23 +110,6 @@
</v-row> </v-row>
</template> </template>
<template v-slot:item.type="{ item }">
<v-tooltip
top
v-if="item.mask"
>
<template v-slot:activator="{ on, attrs }">
<span
v-bind="attrs"
v-on="on"
>
<v-badge style="margin-bottom: 1px" inline content="R" />
</span>
</template>
<span>Recurring template</span>
</v-tooltip>
</template>
<template v-if="status === 'waiting'" v-slot:item.wait="{ item }"> <template v-if="status === 'waiting'" v-slot:item.wait="{ item }">
{{ displayDate(item.wait) }} {{ displayDate(item.wait) }}
</template> </template>
@ -206,6 +190,27 @@ function displayDate(str?: string) {
return date.format('YYYY-MM-DD'); return date.format('YYYY-MM-DD');
} }
function urgentDate(str?: string) {
if (!str)
return false;
const date = moment(str);
const diff = moment.duration(date.diff(moment()));
const days = diff.asDays();
if (days > 0 && days < 1)
return true;
return false;
}
function expiredDate(str?: string) {
if (!str)
return false;
const date = moment(str);
return date.isBefore(moment());
}
interface Props { interface Props {
[key: string]: unknown, [key: string]: unknown,
tasks: Task[] tasks: Task[]
@ -231,9 +236,6 @@ export default defineComponent({
recurring: 'mdi-restart' recurring: 'mdi-restart'
}; };
const headers = computed(() => [ const headers = computed(() => [
...(status.value === 'deleted'
? [{ text: 'Type', value: 'type', width: '1px', sortable: false }]
: []),
{ text: 'Project', value: 'project' }, { text: 'Project', value: 'project' },
{ text: 'Description', value: 'description' }, { text: 'Description', value: 'description' },
{ text: 'Priority', value: 'priority' }, { text: 'Priority', value: 'priority' },
@ -322,6 +324,16 @@ export default defineComponent({
showConfirmationDialog.value = true; showConfirmationDialog.value = true;
}; };
const rowClass = (item: Task) => {
if (item.mask)
return 'recur-task';
else if (status.value !== 'completed' && urgentDate(item.due))
return 'urgent-task';
else if (status.value !== 'completed' && expiredDate(item.due))
return 'expired-task';
return undefined;
};
return { return {
refresh, refresh,
headers, headers,
@ -340,6 +352,7 @@ export default defineComponent({
showConfirmationDialog, showConfirmationDialog,
confirmation, confirmation,
displayDate, displayDate,
rowClass,
TaskDialog, TaskDialog,
ConfirmationDialog ConfirmationDialog
@ -347,3 +360,17 @@ export default defineComponent({
} }
}); });
</script> </script>
<style>
.v-application tr.recur-task {
background-color: #2196F333;
}
.v-application tr.urgent-task {
background-color: #F4433633;
}
.v-application tr.expired-task {
background-color: #79554844;
}
</style>

View file

@ -43,13 +43,11 @@ export default defineComponent({
let interval: NodeJS.Timeout | null = null; let interval: NodeJS.Timeout | null = null;
const setAutoRefresh = () => { const setAutoRefresh = () => {
console.log('Setting inverval');
if (interval) if (interval)
clearInterval(interval); clearInterval(interval);
const freq = +context.root.$store.state.settings.autoRefresh; const freq = +context.root.$store.state.settings.autoRefresh;
if (freq > 0) { if (freq > 0) {
interval = setInterval(() => { interval = setInterval(() => {
console.log('Refreshing...');
context.root.$store.dispatch('fetchTasks'); context.root.$store.dispatch('fetchTasks');
}, +context.root.$store.state.settings.autoRefresh * 60000); }, +context.root.$store.state.settings.autoRefresh * 60000);
} }