ExerciseRecords.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <v-card outlined flat>
  3. <v-simple-table>
  4. <caption class="title pa-4">
  5. {{
  6. $t('learning.exercise.record.title')
  7. }}
  8. </caption>
  9. <thead>
  10. <tr>
  11. <th>
  12. <strong class="body-1">{{ $t('learning.exercise.record.commitDate') }}</strong>
  13. </th>
  14. <th>
  15. <strong class="body-1">{{ $t('learning.exercise.record.score') }}</strong>
  16. </th>
  17. <th />
  18. </tr>
  19. </thead>
  20. <tbody>
  21. <tr v-if="commitTime === 0">
  22. <td colspan="3" class="text-center body-1 grey--text">
  23. {{ $t('learning.exercise.record.noCommitMsg') }}
  24. </td>
  25. </tr>
  26. <tr v-for="r in records" :key="r.id">
  27. <td>{{ r.commitDate }}</td>
  28. <td>{{ r.score }}</td>
  29. <td>
  30. <!-- link to detail page of which the route is 'learning/:chapter/:level/exercise/detail?recordId=id' -->
  31. <v-btn
  32. text
  33. :to="{ path: 'record-detail', query: { recordId: r.id } }"
  34. nuxt
  35. append
  36. color="primary"
  37. >
  38. {{ $t('learning.exercise.record.seeDetail') }}
  39. </v-btn>
  40. </td>
  41. </tr>
  42. </tbody>
  43. </v-simple-table>
  44. <v-divider />
  45. <div class="pa-4 body-1 primary--text">
  46. {{
  47. $t('learning.exercise.record.commitTime', { commitTime: commitTime, total: commitLimit })
  48. }}
  49. </div>
  50. </v-card>
  51. </template>
  52. <script lang="ts">
  53. import Vue, { PropOptions } from 'vue'
  54. import { CommitRecord } from './types'
  55. export default Vue.extend({
  56. props: {
  57. records: {
  58. type: Array,
  59. default: [] as CommitRecord[]
  60. } as PropOptions<CommitRecord[]>,
  61. commitLimit: {
  62. type: Number,
  63. default: 0
  64. }
  65. },
  66. computed: {
  67. commitTime(): number {
  68. return this.records.length || 0
  69. }
  70. }
  71. })
  72. </script>
  73. <style scoped></style>