2019-09-09 09:31:08 +02:00
|
|
|
<template>
|
2020-06-25 11:36:35 +02:00
|
|
|
<div>
|
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<router-link :to="{ name: RouteName.MODERATION }">{{ $t("Moderation") }}</router-link>
|
|
|
|
</li>
|
|
|
|
<li class="is-active">
|
|
|
|
<router-link :to="{ name: RouteName.REPORTS }">{{ $t("Reports") }}</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<section>
|
|
|
|
<b-field>
|
|
|
|
<b-radio-button v-model="filterReports" :native-value="ReportStatusEnum.OPEN">{{
|
|
|
|
$t("Open")
|
|
|
|
}}</b-radio-button>
|
|
|
|
<b-radio-button v-model="filterReports" :native-value="ReportStatusEnum.RESOLVED">{{
|
|
|
|
$t("Resolved")
|
|
|
|
}}</b-radio-button>
|
|
|
|
<b-radio-button v-model="filterReports" :native-value="ReportStatusEnum.CLOSED">{{
|
|
|
|
$t("Closed")
|
|
|
|
}}</b-radio-button>
|
|
|
|
</b-field>
|
|
|
|
<ul v-if="reports.length > 0">
|
|
|
|
<li v-for="report in reports" :key="report.id">
|
|
|
|
<router-link :to="{ name: RouteName.REPORT, params: { reportId: report.id } }">
|
|
|
|
<report-card :report="report" />
|
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<div v-else>
|
|
|
|
<b-message v-if="filterReports === ReportStatusEnum.OPEN" type="is-info">
|
|
|
|
{{ $t("No open reports yet") }}
|
|
|
|
</b-message>
|
|
|
|
<b-message v-if="filterReports === ReportStatusEnum.RESOLVED" type="is-info">
|
|
|
|
{{ $t("No resolved reports yet") }}
|
|
|
|
</b-message>
|
|
|
|
<b-message v-if="filterReports === ReportStatusEnum.CLOSED" type="is-info">
|
|
|
|
{{ $t("No closed reports yet") }}
|
|
|
|
</b-message>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
2019-09-09 09:31:08 +02:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
|
import { IReport, ReportStatusEnum } from "@/types/report.model";
|
|
|
|
import { REPORTS } from "@/graphql/report";
|
|
|
|
import ReportCard from "@/components/Report/ReportCard.vue";
|
|
|
|
import RouteName from "../../router/name";
|
2019-09-09 09:31:08 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
ReportCard,
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
reports: {
|
|
|
|
query: REPORTS,
|
2020-02-18 08:57:00 +01:00
|
|
|
fetchPolicy: "no-cache",
|
2019-09-09 09:31:08 +02:00
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
status: this.filterReports,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
pollInterval: 120000, // 2 minutes
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class ReportList extends Vue {
|
|
|
|
reports?: IReport[] = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-10-03 12:32:20 +02:00
|
|
|
RouteName = RouteName;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
ReportStatusEnum = ReportStatusEnum;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
filterReports: ReportStatusEnum = ReportStatusEnum.OPEN;
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@Watch("$route.params.filter", { immediate: true })
|
|
|
|
onRouteFilterChanged(val: string) {
|
2019-09-09 09:31:08 +02:00
|
|
|
if (!val) return;
|
|
|
|
const filter = val.toUpperCase();
|
|
|
|
if (filter in ReportStatusEnum) {
|
|
|
|
this.filterReports = filter as ReportStatusEnum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@Watch("filterReports", { immediate: true })
|
|
|
|
async onFilterChanged(val: string) {
|
|
|
|
await this.$router.push({
|
|
|
|
name: RouteName.REPORTS,
|
|
|
|
params: { filter: val.toLowerCase() },
|
|
|
|
});
|
2019-09-09 09:31:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2020-06-18 16:57:11 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
section > ul li > a {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
</style>
|