Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/DM.Web.Modern.Temp/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ onMounted(fetchUser);

.content-body
display: flex
line-height: Variables.$grid-step * 5
padding-bottom: Layout.$footer-height + Variables.$big

.content-menu
Expand Down
8 changes: 6 additions & 2 deletions frontend/DM.Web.Modern.Temp/src/api/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ type IfEquals<X, Y, A, B> =
export type Id<T> = Served<T>;

export type Post<T> = {
[P in keyof T as IfEquals<T[P], Served<T[P]>, never, P>]: T[P];
[P in keyof T as IfEquals<T[P], Served<T[P]>, never, P>]: T[P] extends Array<
infer U
>
? Array<Post<U>>
: T[P];
};

export type Patch<T> = {
[P in keyof T as IfEquals<T[P], Served<T[P]>, never, P>]?: T[P];
[P in keyof T as IfEquals<T[P], Served<T[P]>, never, P>]?: Patch<T[P]>;
};
1 change: 0 additions & 1 deletion frontend/DM.Web.Modern.Temp/src/assets/styles/Reset.sass
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ html, body, #app, #application
body
font-family: "PT Sans", sans-serif
font-size: Variables.$font-size
line-height: 1.3
word-wrap: break-word
+Themes.theme(color, Themes.$text)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<script setup lang="ts">
import { IconType } from "@/components/ui-kit/iconType";

defineProps<{ icon: IconType; loading?: boolean }>();
defineProps<{
icon: IconType;
loading?: boolean;
type?: "reset" | "submit" | "button";
}>();
</script>

<template>
<button :class="['icon-button', loading && 'loading']">
<button
:type="type ?? 'button'"
:class="['icon-button', loading && 'loading']"
>
<dm-icon :font="icon" />
</button>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useForumStore } from "@/stores";

import type { Topic } from "@/api/models/forum";
import type { Post } from "@/api/models";
import DmDialog from "@/components/ui-kit/DmDialog.vue";

const { createTopic, selectedForum } = useForumStore();

Expand Down Expand Up @@ -36,14 +35,14 @@ const tryCreateTopic = async () => {
<dm-form @submit="tryCreateTopic">
<dm-field>
<dm-input
id="title"
id="topic-title"
v-model="topic.title"
placeholder="Название темы"
/>
</dm-field>
<dm-field>
<dm-text
id="description"
id="topic-description"
v-model="topic.description"
placeholder="Описание"
/>
Expand Down
67 changes: 67 additions & 0 deletions frontend/DM.Web.Modern.Temp/src/views/pages/polls/CreatePoll.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<script setup lang="ts">
import { ref } from "vue";
import type { Poll } from "@/api/models/community";
import type { Post } from "@/api/models";
import { IconType } from "@/components/ui-kit/iconType";
import communityApi from "@/api/requests/communityApi";

const pollToCreate = ref<Post<Poll>>({
title: "",
ends: new Date().toISOString(),
options: [{ text: "" }],
});
const addOption = () => {
pollToCreate.value.options.push({ text: "" });
};

const loading = ref(false);
const tryCreatePoll = async () => {
loading.value = true;
await communityApi.postPoll(pollToCreate.value);
loading.value = false;
};
</script>

<template>
<dm-dialog :with-form="true">
<page-title>Новый опрос</page-title>
<dm-form @submit="tryCreatePoll">
<dm-field>
<dm-input
id="poll-title"
v-model="pollToCreate.title"
placeholder="Вопрос"
/>
</dm-field>
<dm-field>
<dm-input
id="poll-ends"
v-model="pollToCreate.ends"
placeholder="Дата окончания"
/>
</dm-field>
<secondary-text>Ответы</secondary-text>
<div class="create_poll-options">
<dm-field v-for="(option, i) in pollToCreate.options" :key="i">
<dm-input
:id="`poll-option-${i}`"
v-model="option.text"
:placeholder="`Ответ #${i + 1}`"
/>
</dm-field>
<dm-icon-button :icon="IconType.Add" @click="addOption" />
</div>
<template #controls>
<dm-button label="Создать" :loading="loading" type="submit" />
<a @click="$emit('cancelled')">Отмена</a>
</template>
</dm-form>
</dm-dialog>
</template>

<style scoped lang="sass">
@use "@/assets/styles/Variables"

.create_poll-options
margin-left: Variables.$small
</style>
29 changes: 27 additions & 2 deletions frontend/DM.Web.Modern.Temp/src/views/pages/polls/PollsPage.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<script setup lang="ts">
import PageTitle from "@/components/layout/PageTitle.vue";
import { useFetchData } from "@/composables/useFetchData";
import { usePollsStore } from "@/stores/polls";
import { extractNumberParam } from "@/router";
import router, { extractNumberParam } from "@/router";
import { useRoute } from "vue-router";
import { IconType } from "@/components/ui-kit/iconType";
import { useModal } from "vue-final-modal";
import { computed } from "vue";
import { storeToRefs } from "pinia";
import { useUserStore } from "@/stores";
import { userIsHighAuthority } from "@/api/models/community/helpers";
import CreatePoll from "@/views/pages/polls/CreatePoll.vue";

const route = useRoute();
const { fetchPolls } = usePollsStore();
const { user } = storeToRefs(useUserStore());

useFetchData(
() => fetchPolls(extractNumberParam(route.params.n), false),
Expand All @@ -17,9 +24,27 @@ useFetchData(
},
],
);

const canCreatePoll = computed(() => userIsHighAuthority(user.value));
const { open: openCreatePoll, close: closeCreatePoll } = useModal({
component: CreatePoll,
attrs: {
onCancelled: () => closeCreatePoll(),
onCreated: () => {
closeCreatePoll();
router.push({ name: "polls" });
},
},
});
</script>

<template>
<page-title>Опросы</page-title>
<dm-button
label="Новый опрос"
:icon="IconType.Add"
v-if="canCreatePoll"
@click="openCreatePoll"
/>
<router-view />
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useUserStore } from "@/stores";
import { useFetchData } from "@/composables/useFetchData";
import DmPictureUpload from "@/components/ui-kit/DmPictureUpload.vue";
import communityApi from "@/api/requests/communityApi";
import SecondaryText from "@/components/layout/SecondaryText.vue";

const route = useRoute();
const { user: currentUser } = storeToRefs(useUserStore());
Expand Down Expand Up @@ -76,7 +77,10 @@ const uploadPicture = async (data: FormData) => {
/>
</div>

<div>В сети: <user-online :user="user" :detailed="true" /></div>
<div>
<secondary-text>В сети</secondary-text>&nbsp;
<user-online :user="user" :detailed="true" />
</div>
<profile-stat
title="Статус"
empty="Не указан"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import type { Patch } from "@/api/models";
import type { User } from "@/api/models/community";
import { computed, ref } from "vue";
import useEditMode from "@/composables/useEditMode";
import DmIconButton from "@/components/ui-kit/DmIconButton.vue";
import { IconType } from "@/components/ui-kit/iconType";
import DmForm from "@/components/ui-kit/DmForm.vue";
import DmInput from "@/components/ui-kit/DmInput.vue";
import communityApi from "@/api/requests/communityApi";

const { user: currentUser } = storeToRefs(useUserStore());
Expand Down