2020-02-18 08:57:00 +01:00
|
|
|
<template>
|
|
|
|
<div class="card" v-if="todo">
|
|
|
|
<div class="card-content">
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-checkbox v-model="status" />
|
2020-11-30 10:24:11 +01:00
|
|
|
<router-link
|
|
|
|
:to="{ name: RouteName.TODO, params: { todoId: todo.id } }"
|
|
|
|
>{{ todo.title }}</router-link
|
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<span class="">
|
|
|
|
<span v-if="todo.dueDate" class="">
|
|
|
|
<o-icon icon="calendar" />
|
|
|
|
{{ formatDateString(todo.dueDate) }}
|
2020-02-18 08:57:00 +01:00
|
|
|
</span>
|
2022-07-12 10:55:28 +02:00
|
|
|
<span v-if="todo.assignedTo" class="">
|
|
|
|
<Account />
|
|
|
|
<o-icon icon="account" />
|
2020-02-18 08:57:00 +01:00
|
|
|
{{ `@${todo.assignedTo.preferredUsername}` }}
|
2020-11-30 10:24:11 +01:00
|
|
|
<span v-if="todo.assignedTo.domain">{{
|
|
|
|
`@${todo.assignedTo.domain}`
|
|
|
|
}}</span>
|
2020-02-18 08:57:00 +01:00
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
// import { SnackbarProgrammatic as Snackbar } from "buefy";
|
2020-02-18 08:57:00 +01:00
|
|
|
import { ITodo } from "../../types/todos";
|
|
|
|
import RouteName from "../../router/name";
|
|
|
|
import { UPDATE_TODO } from "../../graphql/todos";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { computed, ref } from "vue";
|
|
|
|
import { useMutation } from "@vue/apollo-composable";
|
|
|
|
import Account from "vue-material-design-icons/Account.vue";
|
|
|
|
import { formatDateString } from "@/filters/datetime";
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const props = defineProps<{ todo: ITodo }>();
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const editMode = ref(false);
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const status = computed({
|
|
|
|
get() {
|
|
|
|
return props.todo.status;
|
|
|
|
},
|
|
|
|
set(status: boolean) {
|
|
|
|
updateTodo({ status, id: props.todo.id });
|
|
|
|
},
|
|
|
|
});
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const { mutate: updateTodo, onDone, onError } = useMutation(UPDATE_TODO);
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
onDone(() => {
|
|
|
|
editMode.value = false;
|
|
|
|
});
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
onError((e) => {
|
|
|
|
// Snackbar.open({
|
|
|
|
// message: e.message,
|
2022-08-26 16:08:58 +02:00
|
|
|
// variant: "danger",
|
|
|
|
// position: "bottom",
|
2022-07-12 10:55:28 +02:00
|
|
|
// });
|
|
|
|
});
|
2020-02-18 08:57:00 +01:00
|
|
|
</script>
|