From 221b10624fadcda6b6bfeff08980c330fa7b7f93 Mon Sep 17 00:00:00 2001 From: Quilin Date: Thu, 14 Jan 2021 18:54:12 +0300 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=B8=20=D0=BA=20=D0=B8=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=20-=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D0=B1=D0=BB=D0=B8=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/models/gaming/index.ts | 11 ++++ .../src/api/requests/gamingApi.ts | 9 ++- DM/Web/DM.Web.Modern/src/router.ts | 11 +++- .../DM.Web.Modern/src/store/gaming/actions.ts | 6 ++ .../src/store/gaming/gamingState.ts | 4 +- .../DM.Web.Modern/src/store/gaming/getters.ts | 1 + .../DM.Web.Modern/src/store/gaming/index.ts | 1 + .../src/store/gaming/mutations.ts | 6 +- .../views/pages/game/comments/GameComment.vue | 16 ++++++ .../pages/game/comments/GameComments.vue | 30 ++++++++++ .../pages/game/comments/GameCommentsList.vue | 55 +++++++++++++++++++ .../game/{ => information}/CharactersList.vue | 2 - .../pages/game/{ => information}/Grid.styl | 0 .../game/{ => information}/Information.vue | 0 .../views/pages/game/{ => menu}/GameMenu.vue | 4 +- 15 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComment.vue create mode 100644 DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComments.vue create mode 100644 DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameCommentsList.vue rename DM/Web/DM.Web.Modern/src/views/pages/game/{ => information}/CharactersList.vue (96%) rename DM/Web/DM.Web.Modern/src/views/pages/game/{ => information}/Grid.styl (100%) rename DM/Web/DM.Web.Modern/src/views/pages/game/{ => information}/Information.vue (100%) rename DM/Web/DM.Web.Modern/src/views/pages/game/{ => menu}/GameMenu.vue (98%) diff --git a/DM/Web/DM.Web.Modern/src/api/models/gaming/index.ts b/DM/Web/DM.Web.Modern/src/api/models/gaming/index.ts index f9078296..0c86e27c 100644 --- a/DM/Web/DM.Web.Modern/src/api/models/gaming/index.ts +++ b/DM/Web/DM.Web.Modern/src/api/models/gaming/index.ts @@ -1,4 +1,15 @@ +import { User } from '@/api/models/community'; + export * from './games'; export * from './attributes'; export * from './characters'; export * from './rooms'; + +export interface Comment { + id: string; + author: User; + created: string; + updated: string | null; + text: string; + likes: User[]; +} diff --git a/DM/Web/DM.Web.Modern/src/api/requests/gamingApi.ts b/DM/Web/DM.Web.Modern/src/api/requests/gamingApi.ts index 4e142b84..016b117d 100644 --- a/DM/Web/DM.Web.Modern/src/api/requests/gamingApi.ts +++ b/DM/Web/DM.Web.Modern/src/api/requests/gamingApi.ts @@ -1,5 +1,5 @@ -import { ApiResult, Envelope, ListEnvelope } from '@/api/models/common'; -import { Game, AttributeSchema, Tag, Character, Room } from '@/api/models/gaming'; +import { ApiResult, Envelope, ListEnvelope, PagingQuery } from '@/api/models/common'; +import { Game, AttributeSchema, Tag, Character, Room, Comment } from '@/api/models/gaming'; import { User } from '@/api/models/community'; import Api from '@/api'; @@ -33,6 +33,11 @@ export default new class { return data!; } + public async getComments(gameId: string, query: PagingQuery): Promise> { + const { data } = await Api.get>(`games/${gameId}/comments`, query); + return data!; + } + public async getSchemas(): Promise> { const { data } = await Api.get>('schemata'); return data!; diff --git a/DM/Web/DM.Web.Modern/src/router.ts b/DM/Web/DM.Web.Modern/src/router.ts index 7bb32c73..a0506ed6 100644 --- a/DM/Web/DM.Web.Modern/src/router.ts +++ b/DM/Web/DM.Web.Modern/src/router.ts @@ -2,7 +2,7 @@ import Vue from 'vue'; import Router from 'vue-router'; import GeneralMenu from './views/layout/GeneralMenu.vue'; -import GameMenu from './views/pages/game/GameMenu.vue'; +import GameMenu from './views/pages/game/menu/GameMenu.vue'; import GeneralSidebar from './views/layout/GeneralSidebar.vue'; Vue.use(Router); @@ -173,10 +173,15 @@ export default new Router({ children: [{ name: 'game', path: '', - component: () => import('./views/pages/game/Information.vue'), + component: () => import('./views/pages/game/information/Information.vue'), }, { - name: 'game-comments', path: 'out-of-session', + component: () => import('./views/pages/game/comments/GameComments.vue'), + children: [{ + name: 'game-comments', + path: ':n?', + component: () => import('./views/pages/game/comments/GameCommentsList.vue'), + }], }, { name: 'create-character', path: 'create-character', diff --git a/DM/Web/DM.Web.Modern/src/store/gaming/actions.ts b/DM/Web/DM.Web.Modern/src/store/gaming/actions.ts index 6d198204..4408d82d 100644 --- a/DM/Web/DM.Web.Modern/src/store/gaming/actions.ts +++ b/DM/Web/DM.Web.Modern/src/store/gaming/actions.ts @@ -3,6 +3,7 @@ import gamingApi from '@/api/requests/gamingApi'; import GamingState from './gamingState'; import RootState from './../rootState'; import { AttributeSchema } from '@/api/models/gaming'; +import { PagingQuery } from '@/api/models/common'; const actions: ActionTree = { async fetchOwnGames({ commit }): Promise { @@ -80,6 +81,11 @@ const actions: ActionTree = { const { resources: readers } = await gamingApi.getReaders(id); commit('updateSelectedGameReaders', readers); }, + async fetchSelectedGameComments({ commit }, { id, n }): Promise { + commit('updateSelectedGameComments', null); + const data = await gamingApi.getComments(id, { number: n } as PagingQuery); + commit('updateSelectedGameComments', data!); + }, async subscribe({ commit, state }, { router }): Promise { const { data, error } = await gamingApi.subscribe(state.selectedGame!.id); diff --git a/DM/Web/DM.Web.Modern/src/store/gaming/gamingState.ts b/DM/Web/DM.Web.Modern/src/store/gaming/gamingState.ts index 21e0cddb..9428e62f 100644 --- a/DM/Web/DM.Web.Modern/src/store/gaming/gamingState.ts +++ b/DM/Web/DM.Web.Modern/src/store/gaming/gamingState.ts @@ -1,5 +1,6 @@ -import {Game, AttributeSchema, Tag, Character, Room} from '@/api/models/gaming'; +import { Game, AttributeSchema, Tag, Character, Room, Comment } from '@/api/models/gaming'; import {User} from '@/api/models/community'; +import { ListEnvelope } from '@/api/models/common'; export default interface GamingState { ownGames: Game[] | null; @@ -12,4 +13,5 @@ export default interface GamingState { selectedGameCharacters: Character[] | null; selectedGameRooms: Room[] | null; selectedGameReaders: User[] | null; + selectedGameComments: ListEnvelope | null; } diff --git a/DM/Web/DM.Web.Modern/src/store/gaming/getters.ts b/DM/Web/DM.Web.Modern/src/store/gaming/getters.ts index a8f8a0e3..5311cac9 100644 --- a/DM/Web/DM.Web.Modern/src/store/gaming/getters.ts +++ b/DM/Web/DM.Web.Modern/src/store/gaming/getters.ts @@ -13,6 +13,7 @@ const getters: GetterTree = { selectedGameCharacters: (state) => state.selectedGameCharacters, selectedGameRooms: (state) => state.selectedGameRooms, selectedGameReaders: (state) => state.selectedGameReaders, + selectedGameComments: (state) => state.selectedGameComments, }; export default getters; diff --git a/DM/Web/DM.Web.Modern/src/store/gaming/index.ts b/DM/Web/DM.Web.Modern/src/store/gaming/index.ts index 60ef122d..1f5fbc40 100644 --- a/DM/Web/DM.Web.Modern/src/store/gaming/index.ts +++ b/DM/Web/DM.Web.Modern/src/store/gaming/index.ts @@ -15,6 +15,7 @@ const state: GamingState = { selectedGameCharacters: null, selectedGameRooms: null, selectedGameReaders: null, + selectedGameComments: null, }; const gaming: Module = { diff --git a/DM/Web/DM.Web.Modern/src/store/gaming/mutations.ts b/DM/Web/DM.Web.Modern/src/store/gaming/mutations.ts index 8ce129a0..0fe7a4fb 100644 --- a/DM/Web/DM.Web.Modern/src/store/gaming/mutations.ts +++ b/DM/Web/DM.Web.Modern/src/store/gaming/mutations.ts @@ -1,7 +1,8 @@ import { MutationTree } from 'vuex'; import GamingState from './gamingState'; -import {Game, AttributeSchema, Tag, Character, Room, GameParticipation} from '@/api/models/gaming'; +import { Game, AttributeSchema, Tag, Character, Room, GameParticipation, Comment } from '@/api/models/gaming'; import {User} from '@/api/models/community'; +import { ListEnvelope } from '@/api/models/common'; const mutations: MutationTree = { updateOwnGames(state, payload: Game[]) { @@ -34,6 +35,9 @@ const mutations: MutationTree = { updateSelectedGameReaders(state, payload: User[]) { state.selectedGameReaders = payload; }, + updateSelectedGameComments(state, payload: ListEnvelope) { + state.selectedGameComments = payload; + }, addReader(state, payload: User) { if (state.selectedGame === null || state.selectedGameReaders === null) return; diff --git a/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComment.vue b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComment.vue new file mode 100644 index 00000000..52212d28 --- /dev/null +++ b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComment.vue @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComments.vue b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComments.vue new file mode 100644 index 00000000..11de573d --- /dev/null +++ b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComments.vue @@ -0,0 +1,30 @@ + + + + + \ No newline at end of file diff --git a/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameCommentsList.vue b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameCommentsList.vue new file mode 100644 index 00000000..f8469561 --- /dev/null +++ b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameCommentsList.vue @@ -0,0 +1,55 @@ + + + + + \ No newline at end of file diff --git a/DM/Web/DM.Web.Modern/src/views/pages/game/CharactersList.vue b/DM/Web/DM.Web.Modern/src/views/pages/game/information/CharactersList.vue similarity index 96% rename from DM/Web/DM.Web.Modern/src/views/pages/game/CharactersList.vue rename to DM/Web/DM.Web.Modern/src/views/pages/game/information/CharactersList.vue index ab95be91..abadc3dc 100644 --- a/DM/Web/DM.Web.Modern/src/views/pages/game/CharactersList.vue +++ b/DM/Web/DM.Web.Modern/src/views/pages/game/information/CharactersList.vue @@ -47,7 +47,6 @@ + + diff --git a/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComments.vue b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComments.vue index 11de573d..0044ea1d 100644 --- a/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComments.vue +++ b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameComments.vue @@ -1,19 +1,20 @@ - \ No newline at end of file + diff --git a/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameCommentsList.vue b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameCommentsList.vue index f8469561..b1f209f7 100644 --- a/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameCommentsList.vue +++ b/DM/Web/DM.Web.Modern/src/views/pages/game/comments/GameCommentsList.vue @@ -1,16 +1,15 @@