2024-09-16 15:59:46 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
|
|
|
|
import SectionMain from '@/Components/SectionMain.vue';
|
|
|
|
import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.vue';
|
|
|
|
import { useForm, Head, usePage } from '@inertiajs/vue3';
|
|
|
|
import { computed, Ref } from 'vue';
|
|
|
|
import CardBox from '@/Components/CardBox.vue';
|
|
|
|
import FormField from '@/Components/FormField.vue';
|
|
|
|
import FormControl from '@/Components/FormControl.vue';
|
|
|
|
import BaseButton from '@/Components/BaseButton.vue';
|
|
|
|
import BaseButtons from '@/Components/BaseButtons.vue';
|
|
|
|
import { stardust } from '@eidellev/adonis-stardust/client';
|
|
|
|
import { mdiArrowLeftBoldOutline, mdiReiterate } from '@mdi/js';
|
|
|
|
import FormValidationErrors from '@/Components/FormValidationErrors.vue';
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
dataset: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Define the computed property for the label
|
|
|
|
const computedLabel = computed(() => {
|
2024-09-26 11:51:35 +00:00
|
|
|
return `Reject to submitter: ${props.dataset.user?.login || 'Unknown User'}`;
|
2024-09-16 15:59:46 +00:00
|
|
|
});
|
2024-09-26 11:51:35 +00:00
|
|
|
const computedEmailLabel = computed(() => {
|
|
|
|
return props.dataset.user?.email || '';
|
|
|
|
});
|
|
|
|
|
2024-09-16 15:59:46 +00:00
|
|
|
|
|
|
|
const flash: Ref<any> = computed(() => {
|
|
|
|
return usePage().props.flash;
|
|
|
|
});
|
|
|
|
const errors: Ref<any> = computed(() => {
|
|
|
|
return usePage().props.errors;
|
|
|
|
});
|
|
|
|
|
|
|
|
const form = useForm({
|
|
|
|
server_state: 'rejected_editor',
|
|
|
|
reject_editor_note: '',
|
2024-09-26 11:51:35 +00:00
|
|
|
send_email: false,
|
2024-09-16 15:59:46 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const handleSubmit = async (e: SubmitEvent) => {
|
|
|
|
e.preventDefault();
|
|
|
|
await form.put(stardust.route('editor.dataset.rejectUpdate', [props.dataset.id]));
|
|
|
|
// await form.put(stardust.route('editor.dataset.update', [props.dataset.id]));
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<LayoutAuthenticated>
|
|
|
|
|
|
|
|
<Head title="Reject submitted dataset" />
|
|
|
|
<SectionMain>
|
|
|
|
<SectionTitleLineWithButton :icon="mdiReiterate" title="Reject submitted dataset" main>
|
|
|
|
<BaseButton :route-name="stardust.route('editor.dataset.list')" :icon="mdiArrowLeftBoldOutline"
|
|
|
|
label="Back" color="white" rounded-full small />
|
|
|
|
</SectionTitleLineWithButton>
|
|
|
|
|
|
|
|
<CardBox form @submit.prevent="handleSubmit">
|
|
|
|
<FormValidationErrors v-bind:errors="errors" />
|
|
|
|
|
|
|
|
|
|
|
|
<FormField label="server state" :class="{ 'text-red-400': form.errors.server_state }">
|
|
|
|
<FormControl v-model="form.server_state" type="text" placeholder="-- server state --"
|
|
|
|
:is-read-only="true" :error="form.errors.server_state">
|
|
|
|
<div class="text-red-400 text-sm" v-if="form.errors.server_state">
|
|
|
|
{{ form.errors.server_state }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
|
|
|
</FormField>
|
|
|
|
<FormField label="reject note" :class="{ 'text-red-400': form.errors.reject_editor_note }">
|
|
|
|
<FormControl v-model="form.reject_editor_note" type="textarea"
|
|
|
|
placeholder="-- reject note for submitter --" :error="form.errors.reject_editor_note">
|
|
|
|
<div class="text-red-400 text-sm" v-if="form.errors.reject_editor_note">
|
|
|
|
{{ form.errors.reject_editor_note }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
|
|
|
</FormField>
|
2024-09-26 11:51:35 +00:00
|
|
|
|
|
|
|
<!-- <FormControl
|
|
|
|
type="checkbox"
|
|
|
|
v-model="form.send_email"
|
|
|
|
:error="form.errors.send_email">
|
|
|
|
</FormControl> -->
|
|
|
|
|
|
|
|
<FormField label="Email Notification">
|
|
|
|
<label for="send_email" class="flex items-center mr-6 mb-3">
|
|
|
|
<input type="checkbox" id="send_email" v-model="form.send_email" class="mr-2" />
|
|
|
|
<span class="check"></span>
|
|
|
|
<a class="pl-2 " target="_blank">send email to
|
|
|
|
<span class="text-blue-600 hover:underline">
|
|
|
|
{{ computedEmailLabel }}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</label>
|
|
|
|
</FormField>
|
2024-09-16 15:59:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- <NotificationBar v-if="flash && flash.message" color="warning" :icon="mdiAlertBoxOutline">
|
|
|
|
{{ flash.message }}
|
|
|
|
class="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4"
|
|
|
|
</NotificationBar> -->
|
|
|
|
<div v-if="flash && flash.warning" class="flex flex-col mt-6 animate-fade-in">
|
|
|
|
<div class="bg-yellow-500 border-l-4 border-orange-400 text-white p-4" role="alert">
|
|
|
|
<p class="font-bold">Be Warned</p>
|
|
|
|
<p>{{ flash.warning }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
<BaseButtons>
|
|
|
|
<BaseButton type="submit" color="info" :label="computedLabel"
|
|
|
|
:class="{ 'opacity-25': form.processing }" :disabled="form.processing" />
|
|
|
|
</BaseButtons>
|
|
|
|
</template>
|
|
|
|
</CardBox>
|
|
|
|
</SectionMain>
|
|
|
|
</LayoutAuthenticated>
|
|
|
|
</template>
|