-
Notifications
You must be signed in to change notification settings - Fork 44
/
ShowReviews.vue
82 lines (73 loc) · 2.49 KB
/
ShowReviews.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<template>
<v-container>
<p v-if="reviews.length === 0" style="text-align: center; color: lightgrey"> No reviews available </p>
<v-container v-for="review in reviews" :key="review.id" class="review">
<p>
{{ review.creationDate + ': ' }}
<v-chip small :color="getStatusColor(review.status)">
<span>{{ reviewStatus(review.status) }}</span>
</v-chip>
{{ ' by ' + review.name }}
</p>
<p>
{{ "'" + review.justification + "'" }}
</p>
<hr />
</v-container>
</v-container>
</template>
<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator';
import Review from '@/models/management/Review';
import Submission from '@/models/management/Submission';
import RemoteServices from '@/services/RemoteServices';
@Component
export default class ShowReviews extends Vue {
@Prop({ type: Submission, required: true }) readonly submission!: Submission;
reviews: Review[] = [];
async created() {
await this.getReviews();
}
async getReviews() {
await this.$store.dispatch('loading');
try {
[this.reviews] = await Promise.all([
RemoteServices.getSubmissionReviews(this.submission.id!)
]);
this.reviews.sort((a, b) => this.sortNewestFirst(a, b));
} catch (error) {
await this.$store.dispatch('error', error);
}
await this.$store.dispatch('clearLoading');
}
reviewStatus(status: string) {
console.log(status);
if (status === 'AVAILABLE' || status === 'DISABLED') {
return 'APPROVED';
} else if (status === 'REJECTED') {
return status;
} else if (status === 'SUBMITTED') {
return 'CHANGES REQUESTED';
} else if (status === 'IN_REVIEW') {
return 'FURTHER REVIEW REQUESTED';
}
}
sortNewestFirst(a: Review, b: Review) {
if (a.creationDate && b.creationDate)
return a.creationDate < b.creationDate ? 1 : -1;
else return 0;
}
getStatusColor(status: string) {
if (status === 'AVAILABLE' || status === 'DISABLED') return 'green';
else if (status === 'REJECTED') return 'red';
else if (status === 'SUBMITTED') return 'yellow';
else if (status === 'IN_REVIEW') return 'blue';
}
}
</script>
<style lang="scss" scoped>
.review {
border-left: solid;
border-color: dodgerblue;
}
</style>