-
Notifications
You must be signed in to change notification settings - Fork 0
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
提出一覧テーブルと汎用テーブルの実装 #87
base: main
Are you sure you want to change the base?
Conversation
あと mock の JSON が壊れていたので修正しました
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
実装ありがとうございます!再利用性が高いコードを作ってくださっていただけたので大変助かります!
いくつかコメントをしたので確認いただければとおもいます。それから,API周りでエラーが出ていたので,その修正をmainに取り込みました。マージしてから作業を続けていただければと思います。
Mockの方の指摘もありがとうございます!別PRでまとめて直そうかなー?
src/views/UserView.vue
Outdated
// TODO: Fetch user data | ||
</script> | ||
|
||
<!-- TODO: Fix the layout on mobile --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mobileのデザインは一旦考慮しないでおいて,このPRでは作業しなくて良いです。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO コメント消しときました
src/views/user/UserSubmissions.vue
Outdated
const response = await new SubmissionsApi().getSubmissionsRaw({ | ||
orderBy: 'submittedAtDesc', | ||
username, | ||
limit: rowPerPage, | ||
offset: page.value * rowPerPage | ||
}) | ||
const summaries: SubmissionSummaries = await response.value() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSubmissions
を用いればまとめられると思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多分もともとレスポンスコード取るために Raw 使ってたんですが、全部 try-catch に丸投げすることに変えて意味が無くなってたので普通のに戻しました
src/views/user/UserSubmissions.vue
Outdated
}) | ||
const summaries: SubmissionSummaries = await response.value() | ||
totalSubmissions.value = summaries.total! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
非nullアサーションするよりnullやundefindedであった時のデフォルト値を明示的にセットする方が良さそう。他の部分も同様です。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-null Assertion をなくしました。それに伴い、Nullish になり得ないけど Non-null Assertion を避けたところには補足を書き残しておきました
<!-- Nullish になり得ない所でも型安全性のため Non-null Assertion はしない --> |
}>() | ||
const emit = defineEmits<{ switch: [page: number] }>() | ||
// previous pages (begin, ..., -32, -16, -8, -4, -3, -2, -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
日本語話者がメインでメンテすることが想定されるのでコメントは日本語でもいいかなー?と思いますが,これは好みの問題なので何方でも良いです!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここは英語のままにしましたが、複雑な箇所や意図を伝えたい箇所では日本語でコメントを書きました
<div> | ||
<h1>User</h1> | ||
<RouterView /> | ||
<div class="flex gap-[max(2rem,calc(25dvw-16rem))] px-[max(2rem,calc(25dvw-16rem))]"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今はデザインが確定していないので全く問題ないですが,将来的にはこのようなArbitrary valueは削除することになることだけよろしくお願いします:man_bowing:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こういう細かな調整は <style>
でやる感じですかね?
仮デザインなのでとりあえずいじらずそのままにしてます
デザインはプロジェクト全体を通して仮であるため、ここだけ TODO コメントで明記する必要はない
Nullish になり得ない所も型安全性のために避ける
非本質な URL クエリは切り分けるべきなので
提出一覧はユーザーページ以外でも使うことが想定されるため
追加で気になったところのリファクタリングもしましたが、修正版できたはずです |
close #67
GitHub Copilot による要約
このプルリクエストには、アプリケーション内のさまざまなコンポーネントの機能とレイアウトを強化するための変更が含まれています。主な変更点は、モック API レスポンスの更新、新しいリスト表示テーブルおよびページ切り替えコンポーネントの追加、ユーティリティ関数の実装、およびビューの改善です。
モック API レスポンス:
src/api/mock/front-back-api-mock.json
内のモック API レスポンスにおいて、languageId
フィールドの修正を行い、適切な JSON フォーマットを確保しました。[1]
[2]
新しいコンポーネント:
ListingTable.vue
コンポーネントを追加し、カスタマイズ可能な列と行を持つ表形式のデータを表示できるようにしました。PageSwitcher.vue
コンポーネントを追加し、前後のページ遷移ロジックを含むページネーションを実装しました。ユーティリティ関数:
src/utils/date.ts
にdateToString
関数を導入し、特定のロケールで日付をフォーマットできるようにしました。ビューの改善:
UserView.vue
を更新し、サイドナビゲーションを追加するとともに、ルートパラメータに基づいてユーザーデータを取得するようにしました。UserSubmissions.vue
を強化し、ユーザーの投稿を表形式で表示し、ページネーションとデータ取得のロジックを組み込みました。補足
ListingTable
コンポーネントを作り、それを使用する感じで実装しました。サイト内の他のテーブルも基本的にこれを使うことを想定しています。セルの中身の指定に
slot
を用いることで、文字列に限らず、リンク、アイコン、コンポーネントなどを自由に指定できるようになっています。現状だと
total
がlimit
と等しくなってしまうため、loadSubmissions
関数のconst summaries: SubmissionSummaries = await response.value()
のすぐ下にsummaries.total = 3141
などを書き加えて複数ページを試すことができます。ListingTable
にその機能を UI 含め実装し、ListingTable
を使う側がその新機能に対応するよう修正するという形を想定しています。