tethys.backend/resources/js/Pages/Editor/Dataset/Index.vue

190 lines
7.3 KiB
Vue
Raw Normal View History

<script setup lang="ts">
// import { Head, Link, useForm, usePage } from '@inertiajs/inertia-vue3';
import { Head, usePage } from '@inertiajs/vue3';
import { ComputedRef } from 'vue';
import { mdiSquareEditOutline, mdiTrashCan, mdiAlertBoxOutline, mdiLockOpen } from '@mdi/js';
import { computed } from 'vue';
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
import SectionMain from '@/Components/SectionMain.vue';
import BaseButton from '@/Components/BaseButton.vue';
import CardBox from '@/Components/CardBox.vue';
import BaseButtons from '@/Components/BaseButtons.vue';
import NotificationBar from '@/Components/NotificationBar.vue';
import Pagination from '@/Components/Admin/Pagination.vue';
import { stardust } from '@eidellev/adonis-stardust/client';
const props = defineProps({
datasets: {
type: Object,
default: () => ({}),
},
filters: {
type: Object,
default: () => ({}),
},
can: {
type: Object,
default: () => ({}),
},
// user: {
// type: Object,
// default: () => ({}),
// }
});
const flash: ComputedRef<any> = computed(() => {
// let test = usePage();
// console.log(test);
return usePage().props.flash;
});
const validStates = ['inprogress', 'rejected_editor'];
const getRowClass = (dataset) => {
// (props.options ? 'select' : props.type)
let rowclass = '';
if (dataset.server_state == 'editor_accepted') {
rowclass = 'editor_accepted';
} else if (dataset.server_state == 'rejected_reviewer') {
rowclass = 'rejected_reviewer';
} else if (dataset.server_state == 'reviewed') {
rowclass = 'reviewed';
} else if (dataset.server_state == 'released') {
rowclass = 'released';
} else if (dataset.server_state == 'published') {
rowclass = 'released';
} else {
rowclass = '';
}
return rowclass;
};
</script>
<template>
<LayoutAuthenticated>
<Head title="Dataset List" />
<SectionMain>
<!-- <FormValidationErrors v-bind:errors="errors" /> -->
<NotificationBar v-if="flash.message" color="success" :icon="mdiAlertBoxOutline">
{{ flash.message }}
</NotificationBar>
<NotificationBar v-if="flash.warning" color="warning" :icon="mdiAlertBoxOutline">
{{ flash.warning }}
</NotificationBar>
<!-- table -->
<CardBox class="mb-6" has-table>
<table class="pure-table">
<thead>
<tr>
<th>
<!-- <Sort label="Dataset Title" attribute="title" :search="form.search" /> -->
Dataset Title
</th>
<th>Submitter</th>
<th>
<!-- <Sort label="Email" attribute="email" :search="form.search" /> -->
<th>Server State</th>
</th>
<th>Editor</th>
<th>Date of last modification</th>
<th v-if="can.edit || can.delete">Actions</th>
</tr>
</thead>
<!-- <th>Dataset Title</th>
<th>ID</th>
<th>Server State</th>
<th>Editor</th>
<th>Date of last modification</th>
<th></th> -->
<tbody>
<tr v-for="dataset in props.datasets.data" :key="dataset.id" :class="getRowClass(dataset)">
<td data-label="Login">
<!-- <Link v-bind:href="stardust.route('user.show', [user.id])"
class="no-underline hover:underline text-cyan-600 dark:text-cyan-400">
{{ user.login }}
</Link> -->
<!-- {{ user.id }} -->
{{ dataset.main_title }}
</td>
<td> {{ dataset.user.login }} </td>
<td>
{{ dataset.server_state }}
</td>
<td v-if="dataset.server_state === 'released'">
<small class="text-gray-500 dark:text-slate-400" :title="dataset.server_date_modified">
Preferred reviewer: {{ dataset.preferred_reviewer }}
</small>
</td>
<td
v-else-if="dataset.server_state === 'editor_accepted' || dataset.server_state === 'rejected_reviewer'">
<small class="text-gray-500 dark:text-slate-400" :title="dataset.server_date_modified">
In approval by: {{ dataset.editor?.login }}
</small>
</td>
<td v-else>
{{ dataset.editor?.login }}
</td>
<td data-label="Created" class="lg:w-1 whitespace-nowrap">
<small class="text-gray-500 dark:text-slate-400" :title="dataset.server_date_modified">
{{ dataset.server_date_modified }}
</small>
</td>
<td class="before:hidden lg:w-1 whitespace-nowrap">
<BaseButtons type="justify-start lg:justify-end" no-wrap>
<BaseButton
v-if="can.receive && (dataset.server_state == 'released')"
:route-name="stardust.route('editor.dataset.receive', [dataset.id])" color="info"
:icon="mdiSquareEditOutline" :label="'Receive task'" small />
<!-- <BaseButton
v-if="can.edit && (dataset.server_state == 'editor_accepted' || dataset.server_state == 'rejected_reviewer')"
:route-name="stardust.route('editor.dataset.edit', [dataset.id])" color="info"
:icon="mdiSquareEditOutline" :label="'Edit'" small /> -->
</BaseButtons>
</td>
</tr>
</tbody>
</table>
<div class="py-4">
<Pagination v-bind:data="datasets.meta" />
</div>
</CardBox>
</SectionMain>
</LayoutAuthenticated>
</template>
<style scoped>
.pure-table tr.released {
background-color: greenyellow;
color: gray;
}
.pure-table tr.editor_accepted {
padding: 0.8em;
background-color: lightblue;
color: gray;
}
.pure-table tr.rejected_reviewer {
padding: 0.8em;
background-color: orange;
color: gray;
}
.pure-table tr.reviewed {
/* padding: 0.8em; */
background-color: yellow;
color: gray;
}
</style>