2020-02-18 07:57:00 +00:00
|
|
|
<template>
|
|
|
|
<div class="container section" v-if="group">
|
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<router-link
|
2020-08-31 10:40:30 +00:00
|
|
|
:to="{
|
|
|
|
name: RouteName.GROUP,
|
|
|
|
params: { preferredUsername: usernameWithDomain(group) },
|
|
|
|
}"
|
2020-09-29 07:53:48 +00:00
|
|
|
>{{ group.name }}</router-link
|
2020-02-18 07:57:00 +00:00
|
|
|
>
|
|
|
|
</li>
|
|
|
|
<li class="is-active">
|
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
name: RouteName.TODO_LISTS,
|
2020-08-31 10:40:30 +00:00
|
|
|
params: { preferredUsername: usernameWithDomain(group) },
|
2020-02-18 07:57:00 +00:00
|
|
|
}"
|
|
|
|
>{{ $t("Task lists") }}</router-link
|
|
|
|
>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<section>
|
2020-08-31 10:40:30 +00:00
|
|
|
<p>
|
|
|
|
{{
|
|
|
|
$t("Create to-do lists for all the tasks you need to do, assign them and set due dates.")
|
|
|
|
}}
|
|
|
|
</p>
|
2020-02-18 07:57:00 +00:00
|
|
|
<form class="form" @submit.prevent="createNewTodoList">
|
|
|
|
<b-field :label="$t('List title')">
|
|
|
|
<b-input v-model="newTodoList.title" />
|
|
|
|
</b-field>
|
|
|
|
<b-button native-type="submit">{{ $t("Create a new list") }}</b-button>
|
|
|
|
</form>
|
|
|
|
<div v-for="todoList in todoLists" :key="todoList.id">
|
|
|
|
<router-link :to="{ name: RouteName.TODO_LIST, params: { id: todoList.id } }">
|
|
|
|
<h3 class="is-size-3">
|
|
|
|
{{
|
|
|
|
$tc("{title} ({count} todos)", todoList.todos.total, {
|
|
|
|
count: todoList.todos.total,
|
|
|
|
title: todoList.title,
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</h3>
|
|
|
|
</router-link>
|
|
|
|
<compact-todo :todo="todo" v-for="todo in todoList.todos.elements" :key="todo.id" />
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
2020-08-14 09:32:23 +00:00
|
|
|
import { FETCH_GROUP } from "@/graphql/group";
|
2020-08-31 10:40:30 +00:00
|
|
|
import { IGroup, usernameWithDomain } from "@/types/actor";
|
2020-02-18 07:57:00 +00:00
|
|
|
import { CREATE_TODO_LIST } from "@/graphql/todos";
|
|
|
|
import CompactTodo from "@/components/Todo/CompactTodo.vue";
|
2020-11-27 18:27:44 +00:00
|
|
|
import { ITodoList } from "@/types/todolist";
|
2020-02-18 07:57:00 +00:00
|
|
|
import RouteName from "../../router/name";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
group: {
|
|
|
|
query: FETCH_GROUP,
|
2020-08-27 09:53:24 +00:00
|
|
|
fetchPolicy: "cache-and-network",
|
2020-02-18 07:57:00 +00:00
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
name: this.$route.params.preferredUsername,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
CompactTodo,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class TodoLists extends Vue {
|
|
|
|
@Prop({ type: String, required: true }) preferredUsername!: string;
|
|
|
|
|
|
|
|
group!: IGroup;
|
|
|
|
|
|
|
|
newTodoList: ITodoList = {
|
|
|
|
title: "",
|
|
|
|
id: "",
|
|
|
|
todos: { elements: [], total: 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
RouteName = RouteName;
|
|
|
|
|
2020-08-31 10:40:30 +00:00
|
|
|
usernameWithDomain = usernameWithDomain;
|
|
|
|
|
|
|
|
get todoLists(): ITodoList[] {
|
2020-02-18 07:57:00 +00:00
|
|
|
return this.group.todoLists.elements;
|
|
|
|
}
|
|
|
|
|
2020-08-31 10:40:30 +00:00
|
|
|
get todoListsCount(): number {
|
2020-02-18 07:57:00 +00:00
|
|
|
return this.group.todoLists.total;
|
|
|
|
}
|
|
|
|
|
2020-08-31 10:40:30 +00:00
|
|
|
async createNewTodoList(): Promise<void> {
|
2020-02-18 07:57:00 +00:00
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: CREATE_TODO_LIST,
|
|
|
|
variables: {
|
|
|
|
title: this.newTodoList.title,
|
|
|
|
groupId: this.group.id,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|