Introduce group basic federation, event new page and notifications
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
58
js/src/views/Todos/Todo.vue
Normal file
58
js/src/views/Todos/Todo.vue
Normal file
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<section class="section container" v-if="todo">
|
||||
<nav class="breadcrumb" aria-label="breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.GROUP,
|
||||
params: { preferredUsername: todo.todoList.actor.preferredUsername },
|
||||
}"
|
||||
>{{ todo.todoList.actor.preferredUsername }}</router-link
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: RouteName.TODO_LIST, params: { id: todo.todoList.id } }">
|
||||
{{ todo.todoList.title }}
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="is-active">
|
||||
<router-link :to="{ name: RouteName.TODO }" aria-current="page">
|
||||
{{ todo.title }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<full-todo :todo="todo" />
|
||||
</section>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
||||
import { GET_TODO } from "@/graphql/todos";
|
||||
import { ITodo } from "@/types/todos";
|
||||
import FullTodo from "@/components/Todo/FullTodo.vue";
|
||||
import RouteName from "../../router/name";
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
FullTodo,
|
||||
},
|
||||
apollo: {
|
||||
todo: {
|
||||
query: GET_TODO,
|
||||
variables() {
|
||||
return {
|
||||
id: this.$route.params.todoId,
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
export default class Todo extends Vue {
|
||||
@Prop({ type: String, required: true }) todoId!: string;
|
||||
|
||||
todo!: ITodo;
|
||||
|
||||
RouteName = RouteName;
|
||||
}
|
||||
</script>
|
||||
114
js/src/views/Todos/TodoList.vue
Normal file
114
js/src/views/Todos/TodoList.vue
Normal file
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<section class="container section" v-if="todoList">
|
||||
<nav class="breadcrumb" aria-label="breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.GROUP,
|
||||
params: { preferredUsername: todoList.actor.preferredUsername },
|
||||
}"
|
||||
>{{ todoList.actor.preferredUsername }}</router-link
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.TODO_LISTS,
|
||||
params: { preferredUsername: todoList.actor.preferredUsername },
|
||||
}"
|
||||
>{{ $t("Task lists") }}</router-link
|
||||
>
|
||||
</li>
|
||||
<li class="is-active">
|
||||
<router-link :to="{ name: RouteName.TODO_LIST, params: { id: todoList.id } }">
|
||||
{{ todoList.title }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<h2 class="title">{{ todoList.title }}</h2>
|
||||
<div v-for="todo in todoList.todos.elements" :key="todo.id">
|
||||
<compact-todo :todo="todo" />
|
||||
</div>
|
||||
<form class="form box" @submit.prevent="createNewTodo">
|
||||
<b-field>
|
||||
<b-checkbox v-model="newTodo.status" />
|
||||
<b-input expanded v-model="newTodo.title" />
|
||||
</b-field>
|
||||
<b-button native-type="submit">{{ $t("Add a todo") }}</b-button>
|
||||
</form>
|
||||
</section>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
||||
import { ITodo, ITodoList } from "@/types/todos";
|
||||
import { CREATE_TODO, FETCH_TODO_LIST } from "@/graphql/todos";
|
||||
import CompactTodo from "@/components/Todo/CompactTodo.vue";
|
||||
import { CURRENT_ACTOR_CLIENT } from "@/graphql/actor";
|
||||
import { IActor } from "@/types/actor";
|
||||
import RouteName from "../../router/name";
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
CompactTodo,
|
||||
},
|
||||
apollo: {
|
||||
todoList: {
|
||||
query: FETCH_TODO_LIST,
|
||||
variables() {
|
||||
return {
|
||||
id: this.$route.params.id,
|
||||
};
|
||||
},
|
||||
},
|
||||
currentActor: CURRENT_ACTOR_CLIENT,
|
||||
},
|
||||
})
|
||||
export default class TodoList extends Vue {
|
||||
@Prop({ type: String, required: true }) id!: string;
|
||||
|
||||
todoList!: ITodoList;
|
||||
|
||||
currentActor!: IActor;
|
||||
|
||||
newTodo: ITodo = { title: "", status: false };
|
||||
|
||||
RouteName = RouteName;
|
||||
|
||||
async createNewTodo() {
|
||||
await this.$apollo.mutate({
|
||||
mutation: CREATE_TODO,
|
||||
variables: {
|
||||
title: this.newTodo.title,
|
||||
status: this.newTodo.status,
|
||||
todoListId: this.id,
|
||||
},
|
||||
update: (store, { data }) => {
|
||||
if (data == null) return;
|
||||
const cachedData = store.readQuery<{ todoList: ITodoList }>({
|
||||
query: FETCH_TODO_LIST,
|
||||
variables: { id: this.todoList.id },
|
||||
});
|
||||
if (cachedData == null) return;
|
||||
const { todoList } = cachedData;
|
||||
if (todoList === null) {
|
||||
console.error("Cannot update event notes cache, because of null value.");
|
||||
return;
|
||||
}
|
||||
const newTodo: ITodo = data.createTodo;
|
||||
newTodo.creator = this.currentActor;
|
||||
|
||||
todoList.todos.elements = todoList.todos.elements.concat([newTodo]);
|
||||
|
||||
store.writeQuery({
|
||||
query: FETCH_TODO_LIST,
|
||||
variables: { id: this.todoList.id },
|
||||
data: { todoList },
|
||||
});
|
||||
},
|
||||
});
|
||||
this.newTodo = { title: "", status: false };
|
||||
}
|
||||
}
|
||||
</script>
|
||||
100
js/src/views/Todos/TodoLists.vue
Normal file
100
js/src/views/Todos/TodoLists.vue
Normal file
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<div class="container section" v-if="group">
|
||||
<nav class="breadcrumb" aria-label="breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link
|
||||
:to="{ name: RouteName.GROUP, params: { preferredUsername: group.preferredUsername } }"
|
||||
>{{ group.preferredUsername }}</router-link
|
||||
>
|
||||
</li>
|
||||
<li class="is-active">
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.TODO_LISTS,
|
||||
params: { preferredUsername: group.preferredUsername },
|
||||
}"
|
||||
>{{ $t("Task lists") }}</router-link
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<section>
|
||||
<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";
|
||||
import { FETCH_GROUP } from "@/graphql/actor";
|
||||
import { IGroup } from "@/types/actor";
|
||||
import { ITodoList } from "@/types/todos";
|
||||
import { CREATE_TODO_LIST } from "@/graphql/todos";
|
||||
import CompactTodo from "@/components/Todo/CompactTodo.vue";
|
||||
import RouteName from "../../router/name";
|
||||
|
||||
@Component({
|
||||
apollo: {
|
||||
group: {
|
||||
query: FETCH_GROUP,
|
||||
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;
|
||||
|
||||
get todoLists() {
|
||||
return this.group.todoLists.elements;
|
||||
}
|
||||
|
||||
get todoListsCount() {
|
||||
return this.group.todoLists.total;
|
||||
}
|
||||
|
||||
async createNewTodoList() {
|
||||
await this.$apollo.mutate({
|
||||
mutation: CREATE_TODO_LIST,
|
||||
variables: {
|
||||
title: this.newTodoList.title,
|
||||
groupId: this.group.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user