Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ユーザーセッティング画面実装 #80

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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 src/assets/service_icons/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/service_icons/google.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/service_icons/traq.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/status_icons/account.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/status_icons/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/status_icons/profile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/views/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<template>
<div>
<h1>Settings</h1>
<RouterView />
</div>
</template>
Expand Down
169 changes: 165 additions & 4 deletions src/views/settings/SettingsAccount.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,170 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter();
const selectedItem = ref<string>(window.location.pathname.split('/').pop() || 'account');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このページが呼び出されるのは/settings/accountだけなのでわざわざパスからとってこなくても良い気がします。(Profileの方も同様に。)

function selectItem(item: string) {
selectedItem.value = item;
router.push(`/settings/${item}`);
}
Comment on lines +8 to +11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これでも全く問題ないのですが,tOJ-frontの他のコードではarrowを用いた関数式の形式で関数を定義しているので,それに合わせてもらえるとありがたいです:pray:
それぞれ微妙に動作が異なりますが,今回はそのまま書き換えて問題ないと思います。

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Functions/Arrow_functions
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Statements/function

onMounted(() => {
window.addEventListener('popstate', () => {
selectedItem.value = window.location.pathname.split('/').pop() || 'account';
});
});
const username = ref<string>('');
const email = ref<string>('');
const currentPassword = ref<string>('');
const newPassword = ref<string>('');
const confirmPassword = ref<string>('');
interface Service {
name: string;
linked: boolean;
ID: string;
icon: string;
}
import GitHubIcon from '@/assets/service_icons/github.svg';
import GoogleIcon from '@/assets/service_icons/google.svg';
import traQIcon from '@/assets/service_icons/traq.svg';
import checkIcon from '@/assets/status_icons/check.svg';
import profileIcon from '@/assets/status_icons/profile.svg';
import accountIcon from '@/assets/status_icons/account.svg';
Comment on lines +32 to +38
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

importは先頭にまとめてしまった方が読みやすいと思います

const services = ref<Service[]>([
{ name: 'GitHub', linked: false, ID: '', icon: GitHubIcon },
{ name: 'Google', linked: false, ID: '', icon: GoogleIcon },
{ name: 'traQ', linked: false, ID: '@test_user', icon: traQIcon },
]);
Comment on lines +40 to +44
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここの値のlinkedについては,ページのマウント時に/users/meを叩いて,そのときの値を元にlinkされているか決めたいですね。
一旦,GitHubとtraQのlinkedについてはそれぞれ/users/meのレスポンスのgithubIdtraqIdnullかどうかで判定するようにしてみてください。(Googleは連携しているかどうか判定できるプロパティがなかったので別issueに直しておきます。)

参照; https://github.com/traP-jp/traO-Judge-docs/blob/develop/api/backend/frontend-backend.yaml

function toggleLink(service: Service) {
service.linked = !service.linked;
console.log(`TODO: ${service.name} との連携を${service.linked ? '開始' : '解除'}する`);
}
function changeUsername() {
console.log('TODO: ユーザー名の変更を反映する');
}
function changeEmail() {
console.log('TODO: メールアドレスの変更を反映する');
}
function changePassword() {
console.log('TODO: パスワードの変更を反映する');
}
</script>

<template>
<div>
<h2>Settings Account</h2>
<div class="flex gap-12 px-6 py-8" style="font-family: 'Open Sans', 'Noto Sans', sans-serif;">
<aside class="gap-3 p-3" style="min-width: 250px;">
<h2 class="h-10 pb-3 text-xl font-medium">設定</h2>
<ul>
<li class="mb-3">
<a
href="/settings/account"
class="flex rounded px-4 py-1"
style="font-weight: 500; background-color: #FFE5E5; color: #8E3535; gap: 5px;"
@click.prevent="selectItem('account')"
>
<img :src="accountIcon" alt="" width="20" height="20" />
<p>アカウント</p>
</a>
</li>
<li class="mb-3">
<a
href="/settings/profile"
class="flex rounded px-4 py-1"
style="font-weight: 500; background-color: white; color: #5F5F5F; gap: 5px;"
@click.prevent="selectItem('profile')"
>
<img :src="profileIcon" alt="" width="20" height="20" style="filter: invert(33%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(85%);" />
<p>プロフィール</p>
</a>
</li>
</ul>
</aside>
<div class="flex flex-col gap-6 p-3" style="width: 800px;">
Comment on lines +66 to +92
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは僕が周知していなかったのが悪い部分も大きいのですが,ページ左側のメニュー/ボタン/フォームなど多くのページで共通に使われることがわかっているものはすでにコンポーネントとしてcomponents以下に定義されています。このページのメニュー,ボタン,フォームなどもそちらを使って描画していただくようにお願いいたします。少し手戻りが多くなってしまって申し訳ないです:pray_shake:

<div class="flex flex-col gap-3 pb-3">
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">基本情報</h2>
<div class="flex-col">
<label class="text-sm font-medium" for="username">ユーザー名</label>
<div class="flex items-center gap-2">
<input id="username" v-model="username" type="text" class="h-8 w-48 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" />
<button class="h-10 w-20 rounded-lg" style="background-color: #AC004B; color: white;" @click="changeUsername">変更</button>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@/components/Controls/Textbox/PlainTextbox.vueを使って再定義をお願いします:pray:

</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@/components/Controls/PrimaryButton.vueを使って再定義をお願いします:pray:

</div>
<div class="flex-col">
<label class="text-sm font-medium" for="email">メールアドレス</label>
<div class="flex items-center gap-2">
<input id="email" v-model="email" type="email" class="h-8 w-96 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" />
<button class="h-10 w-20 rounded-lg" style="background-color: #AC004B; color: white;" @click="changeEmail">変更</button>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@/components/Controls/Textbox/EmailTextbox.vueを使って再定義をお願いします:pray:

</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@/components/Controls/PrimaryButton.vueを使って再定義をお願いします:pray:

</div>
</div>
<div class="flex flex-col gap-3 pb-3">
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">パスワードの変更</h2>
<div class="flex flex-col gap-2">
<div class="flex-col">
<label class="text-sm font-medium" for="current-password">現在のパスワード</label>
<div class="flex items-center ">
<input id="current-password" v-model="currentPassword" type="password" class="h-8 w-72 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" />
</div>
</div>
<div class="flex-col">
<label class="text-sm font-medium" for="new-password">新しいパスワード</label>
<div class="flex items-center ">
<input id="new-password" v-model="newPassword" type="password" class="h-8 w-72 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" />
</div>
</div>
<div class="flex-col">
<label class="text-sm font-medium" for="confirm-password">新しいパスワード (確認)</label>
<div class="flex items-center ">
<input id="confirm-password" v-model="confirmPassword" type="password" class="h-8 w-72 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" />
</div>
</div>
<div>
<button class="h-10 w-20 rounded-lg" style="background-color: #AC004B; color: white;" @click="changePassword">
変更
</button>
</div>
</div>
</div>
Comment on lines +112 to +137
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@/components/Controls/Textbox/PasswordTextbox.vue@/components/Controls/PrimaryButton.vueを使って再定義をお願いします:pray:

<div class="flex flex-col gap-3 pb-3">
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">外部サービスとの連携</h2>
<div>
<div v-for="service in services" :key="service.name" class="flex-col border-b-2" style="border-color: #D8D8D8B2;">
<div class="flex h-12 items-center gap-2.5">
<div class="flex items-center gap-2">
<img :src="service.icon" alt="" width="20" height="20" />
<label class="w-32">
{{ service.name }}
</label>
</div>
<span :style="[service.linked ? 'color: #16B179;' : 'color: #5F5F5F;']" class="flex w-32 gap-1">
{{ service.linked ? '連携済' : '未連携' }}
<img v-if="service.linked" :src="checkIcon" alt="" width="16" height="16" />
</span>
<span class="h-12 min-w-72 content-around text-base font-normal" style="color: #5F5F5F;">
{{ service.ID }}
</span>
<button class="mr-10 h-8 rounded border px-4 py-1 text-sm" style="border-color: #D8D8D8; color: #5F5F5F;" @click="toggleLink(service)">
{{ service.linked ? '連携解除' : '連携' }}
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</template>

<style scoped></style>
<style scoped>
</style>
76 changes: 72 additions & 4 deletions src/views/settings/SettingsProfile.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,77 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();
const selectedItem = ref<string>(window.location.pathname.split('/').pop() || 'profile');

function selectItem(item: string) {
selectedItem.value = item;
router.push(`/settings/${item}`);
}

onMounted(() => {
window.addEventListener('popstate', () => {
selectedItem.value = window.location.pathname.split('/').pop() || 'profile';
});
});

const words = ref<string>('');

function changeWords() {
console.log('TODO: ひとことの変更を反映する');
}

import profileIcon from '@/assets/status_icons/profile.svg';
import accountIcon from '@/assets/status_icons/account.svg';
</script>

<template>
<div>
<h2>Settings Profile</h2>
<div class="flex gap-12 px-6 py-8" style="font-family: 'Open Sans', 'Noto Sans', sans-serif;">
<aside class="gap-3 p-3" style="min-width: 250px;">
<h2 class="pb-3 text-xl font-medium">設定</h2>
<ul>
<li class="mb-3">
<a
href="/settings/account"
class="flex rounded px-4 py-1"
style="font-weight: 500; background-color: white; color: #5F5F5F; gap: 5px;"
@click.prevent="selectItem('account')"
>
<img :src="accountIcon" alt="" width="20" height="20" style="filter: invert(33%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(85%);" />
<p>アカウント</p>
</a>
</li>
<li class="mb-3">
<a
href="/settings/profile"
class="flex rounded px-4 py-1"
style="font-weight: 500; background-color: #FFE5E5; color: #8E3535; gap: 5px;"
@click.prevent="selectItem('profile')"
>
<img :src="profileIcon" alt="" width="20" height="20" />
<p>プロフィール</p>
</a>
</li>
</ul>
</aside>
<div class="flex flex-col gap-3 p-3" style="width: 800px;">
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">プロフィール</h2>
<div class="mb-3 flex-col">
<label class="text-sm font-medium" for="word">ひとこと</label>
<div class="flex flex-col gap-3">
<textarea id="word" v-model="words" class="rounded border px-3 py-1" style="height: 256px; width: 600px;"></textarea>
<button class="h-10 w-20 rounded-lg" style="background-color: #AC004B; color: white;" @click="changeWords">保存</button>
</div>
</div>
</div>
</div>
</template>

<style scoped></style>
<style scoped>
hr {
border-top: 1px solid #D8D8D8;
margin-top: 12px;
margin-bottom: 12px;
}
</style>
Loading