summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/ModelReportsList.vue133
-rw-r--r--pages/models/_id/index.vue3
2 files changed, 119 insertions, 17 deletions
diff --git a/components/ModelReportsList.vue b/components/ModelReportsList.vue
index a46e6d1..fe52320 100644
--- a/components/ModelReportsList.vue
+++ b/components/ModelReportsList.vue
@@ -1,39 +1,138 @@
<template lang="pug">
.shadow-sm.rounded-lg.bg-white.p-4.w-full.mb-5(v-if="warnings.length")
+ .relative.z-10(aria-labelledby="modal-title", role="dialog", aria-modal="true" v-if="boxToResolve > 0")
+ .fixed.inset-0.bg-gray-900.bg-opacity-90.transition-opacity
+ .fixed.inset-0.z-10.overflow-y-auto
+ .flex.min-h-full.items-end.justify-center.p-4.text-center(class="sm:items-center sm:p-0")
+ .relative.transform.overflow-hidden.rounded-lg.bg-white.text-left.shadow-xl.transition-all(class="sm:my-8 sm:w-full sm:max-w-lg")
+ .bg-white.px-4.pt-5.pb-4(class="sm:p-6 sm:pb-4")
+ label.block.text-sm.font-medium.text-gray-700(for="admin_note") Add a note
+ span.text-gray-300 (Optional)
+ .mt-1
+ textarea#description.mt-1.block.w-full.rounded-md.border-gray-300.border-1.px-2.py-1(
+ name="warning_note" rows="3"
+ class="focus:border-green-500 focus:ring-green-500 sm:text-sm"
+ v-model="form.admin_note"
+ )
+ .bg-gray-50.px-4.py-3(class="sm:flex sm:flex-row-reverse sm:px-6")
+ button.inline-flex.w-full.justify-center.rounded-md.border.border-transparent.bg-green-600.px-4.py-2.text-base.font-medium.text-white.shadow-sm(
+ type="button"
+ :class="{'hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 sm:ml-3 sm:w-auto sm:text-sm': true, 'opacity-25 cursor-default': isLoading}"
+ :disabled="isLoading" :readonly="isLoading"
+ @click="editWarning"
+ )
+ <svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" v-if="isLoading">
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
+ </svg>
+ | Save
+ button.mt-3.inline-flex.w-full.justify-center.rounded-md.border.border-gray-300.bg-white.px-4.py-2.text-base.font-medium.text-gray-700.shadow-sm(
+ type="button"
+ class="hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"
+ @click="boxToResolve = 0"
+ ) Cancel
+
+
h2.text-xl.font-bold(v-if="me && me.is_staff") Reports
h2.text-xl.font-bold(v-else) My reports
- ul.divide-y.divide-gray-200.rounded-md.border.border-gray-200.mt-3(role="list" v-if="me && !me.is_staff")
- li.py-3.pl-3.pr-4.text-sm(v-for="warning in warnings" :key="warning.id")
- h3.flex.leading-6.mb-2.float-right
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 w-6 h-6">
- <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
- </svg>
- | {{ warning.created|moment("DD/MM/YYYY HH:mm") }}
- p {{ warning.note }}
- ul.divide-y.divide-gray-200.rounded-md.border.border-gray-200.mt-3(role="list" v-else-if="me && me.is_staff")
- li.py-3.pl-3.pr-4.text-sm(v-for="warning in warnings" :key="warning.id")
- h3.flex.leading-6.mb-2.float-right
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 w-6 h-6">
- <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
- </svg>
- | {{ warning.created|moment("DD/MM/YYYY HH:mm") }}
- p {{ warning.note }}
-
+ ul(role="list" v-if="me")
+ li.text-sm.rounded-md.border.border-gray-200.mt-3(v-for="warning in warnings" :key="warning.id")
+ .py-3.pl-3.pr-4(v-if="!me.is_staff")
+ h3.flex.leading-6.mb-2.float-right
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 w-6 h-6">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
+ </svg>
+ | {{ warning.created|moment("DD/MM/YYYY HH:mm") }}
+ p {{ warning.note }}
+ .py-3.pl-3.pr-4(v-else)
+ h3.flex.leading-6.mb-2.float-right
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 w-6 h-6">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
+ </svg>
+ | {{ warning.created|moment("DD/MM/YYYY HH:mm") }}
+ .flex
+ .mr-3(style="flex-shrink: 0;")
+ user-avatar(:data="warning.user")
+ p.leading-8
+ a.text-green-800(class="hover:text-green-700" :href="'/user/'+warning.user.id")
+ | @
+ span.underline {{ warning.user.username }}
+ p.leading-8.ml-5 {{ warning.note }}
+ .pr-3
+ button(
+ class="ml-5 cursor-pointer rounded-md border border-green-600 flex bg-green-600 py-2 px-3 text-xs font-medium leading-4 text-white shadow-sm hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2"
+ v-if="!warning.resolved_by"
+ @click="boxToResolve = warning.id"
+ )
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-1 w-4 h-4">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" />
+ </svg>
+ | Resolve
+ .bg-green-50.py-3.pl-3.pr-4(v-if="warning.resolved_by")
+ em Resolved by:
+ h3.flex.leading-6.mb-2.float-right
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mr-2 w-6 h-6">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
+ </svg>
+ | {{ warning.updated|moment("DD/MM/YYYY HH:mm") }}
+ .flex
+ .mr-3(style="flex-shrink: 0;")
+ user-avatar(:data="warning.resolved")
+ p.leading-8
+ a.text-green-800(class="hover:text-green-700" :href="'/user/'+warning.user.id")
+ | @
+ span.underline {{ warning.resolved.username }}
+ p.leading-8.ml-5 {{ warning.admin_note }}
</template>
<script>
+import UserAvatar from "@/components/UserAvatar.vue";
+
import { mapGetters } from "vuex";
export default {
name: "ModelReportsList",
props: ["model"],
+ components: {
+ "user-avatar": UserAvatar,
+ },
+ data() {
+ return {
+ boxToResolve: 0,
+ form: { admin_note: "" },
+ };
+ },
computed: {
+ ...mapGetters(["isLoading"]),
...mapGetters("auth", ["me"]),
...mapGetters("warnings", ["warnings"]),
},
mounted() {
this.$store.dispatch("warnings/filterWarnings", { model_id: this.model });
},
+ methods: {
+ editWarning() {
+ if (this.boxToResolve < 1) return;
+
+ this.$store
+ .dispatch("warnings/editWarning", {
+ id: this.boxToResolve,
+ admin_note: this.form.admin_note,
+ })
+ .then((response) => {
+ if (response.status == 200) {
+ this.$toast.success("Report saved");
+ this.form.admin_note = "";
+ this.boxToResolve = 0;
+ this.$store.dispatch("warnings/filterWarnings", {
+ model_id: this.model,
+ });
+ } else {
+ this.$toast.error(response.data);
+ }
+ });
+ },
+ },
};
</script>
diff --git a/pages/models/_id/index.vue b/pages/models/_id/index.vue
index ee51035..2f90025 100644
--- a/pages/models/_id/index.vue
+++ b/pages/models/_id/index.vue
@@ -274,6 +274,9 @@ export default {
this.$toast.success("Report created, thank you!");
this.report.warning_note = null;
this.boxReport = false;
+ this.$store.dispatch("warnings/filterWarnings", {
+ model_id: this.model.id,
+ });
} else {
this.$toast.error(response.data);
}