- add methods for releasing datasets from submitter
All checks were successful
CI Pipeline / japa-tests (push) Successful in 54s

- npm updates
- side menu with child items
- flash messages via HttpContext response (extended via macro)
This commit is contained in:
Kaimbacher 2023-06-27 18:23:18 +02:00
parent e0ff71b117
commit f403c3109f
37 changed files with 1020 additions and 482 deletions

View file

@ -3,14 +3,14 @@
import { useForm } from '@inertiajs/vue3';
// import { reactive } from 'vue';
import {
mdiAccount,
mdiAccountCircle,
mdiLock,
mdiMail,
mdiAsterisk,
mdiFormTextboxPassword,
mdiArrowLeftBoldOutline,
// mdiAlertBoxOutline,
mdiAccount,
mdiAccountCircle,
mdiLock,
mdiMail,
mdiAsterisk,
mdiFormTextboxPassword,
mdiArrowLeftBoldOutline,
// mdiAlertBoxOutline,
} from '@mdi/js';
import SectionMain from '@/Components/SectionMain.vue';
import CardBox from '@/Components/CardBox.vue';
@ -26,29 +26,29 @@ import { stardust } from '@eidellev/adonis-stardust/client';
// import { Inertia } from '@inertiajs/inertia';
const props = defineProps({
// user will be returned from controller action
user: {
type: Object,
default: () => ({}),
},
errors: {
type: Object,
default: () => ({}),
},
// user will be returned from controller action
user: {
type: Object,
default: () => ({}),
},
errors: {
type: Object,
default: () => ({}),
},
});
const profileForm = useForm({
login: props.user.login,
email: props.user.email,
login: props.user.login,
email: props.user.email,
});
const profileSubmit = async () => {
await profileForm.post(stardust.route('admin.account.info.store', [props.user.id]));
};
const passwordForm = useForm({
old_password: "",
new_password: "",
confirm_password: "",
old_password: '',
new_password: '',
confirm_password: '',
});
const passwordSubmit = async () => {
await passwordForm.post(stardust.route('admin.account.info.store'), {
@ -56,97 +56,128 @@ const passwordSubmit = async () => {
onSuccess: (resp) => {
console.log(resp);
passwordForm.reset();
}
},
});
};
</script>
<template>
<LayoutAuthenticated>
<SectionMain>
<SectionTitleLineWithButton :icon="mdiAccount" title="Profile" main>
<BaseButton :route-name="stardust.route('dashboard')" :icon="mdiArrowLeftBoldOutline" label="Back" color="white"
rounded-full small />
</SectionTitleLineWithButton>
<LayoutAuthenticated>
<SectionMain>
<SectionTitleLineWithButton :icon="mdiAccount" title="Profile" main>
<BaseButton
:route-name="stardust.route('dashboard')"
:icon="mdiArrowLeftBoldOutline"
label="Back"
color="white"
rounded-full
small
/>
</SectionTitleLineWithButton>
<!-- <NotificationBar v-if="$page.props.flash.message" color="success" :icon="mdiAlertBoxOutline">
<!-- <NotificationBar v-if="$page.props.flash.message" color="success" :icon="mdiAlertBoxOutline">
{{ $page.props.flash.message }}
</NotificationBar> -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- password form -->
<!-- <CardBox title="Edit Profile" :icon="mdiAccountCircle" form @submit.prevent="profileForm.post(route('admin.account.info.store'))"> -->
<CardBox title="Edit Profile" :icon="mdiAccountCircle" form @submit.prevent="profileSubmit()">
<FormField label="Login" help="Required. Your login name" :class="{ 'text-red-400': errors.login }">
<FormControl v-model="profileForm.login" v-bind:icon="mdiAccount" name="login" required :error="errors.login">
<div class="text-red-400 text-sm" v-if="errors.login">
{{ errors.login }}
</div>
</FormControl>
</FormField>
<FormField label="Email" help="Required. Your e-mail" :class="{ 'text-red-400': errors.email }">
<FormControl v-model="profileForm.email" :icon="mdiMail" type="email" name="email" required :error="errors.email">
<div class="text-red-400 text-sm" v-if="errors.email">
{{ errors.email }}
</div>
</FormControl>
</FormField>
<!-- password form -->
<!-- <CardBox title="Edit Profile" :icon="mdiAccountCircle" form @submit.prevent="profileForm.post(route('admin.account.info.store'))"> -->
<CardBox title="Edit Profile" :icon="mdiAccountCircle" form @submit.prevent="profileSubmit()">
<FormField label="Login" help="Required. Your login name" :class="{ 'text-red-400': errors.login }">
<FormControl v-model="profileForm.login" v-bind:icon="mdiAccount" name="login" required :error="errors.login">
<div class="text-red-400 text-sm" v-if="errors.login">
{{ errors.login }}
</div>
</FormControl>
</FormField>
<FormField label="Email" help="Required. Your e-mail" :class="{ 'text-red-400': errors.email }">
<FormControl v-model="profileForm.email" :icon="mdiMail" type="email" name="email" required
:error="errors.email">
<div class="text-red-400 text-sm" v-if="errors.email">
{{ errors.email }}
</div>
</FormControl>
</FormField>
<template #footer>
<BaseButtons>
<BaseButton color="info" type="submit" label="Submit" />
</BaseButtons>
</template>
</CardBox>
<template #footer>
<BaseButtons>
<BaseButton color="info" type="submit" label="Submit" />
</BaseButtons>
</template>
</CardBox>
<!-- password form -->
<!-- <CardBox title="Change Password" :icon="mdiLock" form @submit.prevent="passwordForm.post(route('admin.account.password.store'), {
<!-- password form -->
<!-- <CardBox title="Change Password" :icon="mdiLock" form @submit.prevent="passwordForm.post(route('admin.account.password.store'), {
preserveScroll: true,
onSuccess: () => passwordForm.reset(),
})
"> -->
<CardBox title="Change Password" :icon="mdiLock" form @submit.prevent="passwordSubmit()">
<FormField label="Current password" help="Required. Your current password"
:class="{ 'text-red-400': passwordForm.errors.old_password }">
<FormControl v-model="passwordForm.old_password" :icon="mdiAsterisk" name="old_password" type="password"
required :error="passwordForm.errors.old_password">
<div class="text-red-400 text-sm" v-if="passwordForm.errors.old_password">
{{ passwordForm.errors.old_password }}
</div>
</FormControl>
</FormField>
<CardBox title="Change Password" :icon="mdiLock" form @submit.prevent="passwordSubmit()">
<FormField
label="Current password"
help="Required. Your current password"
:class="{ 'text-red-400': passwordForm.errors.old_password }"
>
<FormControl
v-model="passwordForm.old_password"
:icon="mdiAsterisk"
name="old_password"
type="password"
required
:error="passwordForm.errors.old_password"
>
<div class="text-red-400 text-sm" v-if="passwordForm.errors.old_password">
{{ passwordForm.errors.old_password }}
</div>
</FormControl>
</FormField>
<BaseDivider />
<BaseDivider />
<FormField label="New password" help="Required. New password" :class="{ 'text-red-400': passwordForm.errors.new_password }">
<FormControl v-model="passwordForm.new_password" :icon="mdiFormTextboxPassword" name="new_password"
type="password" required :error="passwordForm.errors.new_password">
<div class="text-red-400 text-sm" v-if="passwordForm.errors.new_password">
{{ passwordForm.errors.new_password }}
</div>
</FormControl>
</FormField>
<FormField
label="New password"
help="Required. New password"
:class="{ 'text-red-400': passwordForm.errors.new_password }"
>
<FormControl
v-model="passwordForm.new_password"
:icon="mdiFormTextboxPassword"
name="new_password"
type="password"
required
:error="passwordForm.errors.new_password"
>
<div class="text-red-400 text-sm" v-if="passwordForm.errors.new_password">
{{ passwordForm.errors.new_password }}
</div>
</FormControl>
</FormField>
<FormField label="Confirm password" help="Required. New password one more time"
:class="{ 'text-red-400': passwordForm.errors.confirm_password }">
<FormControl v-model="passwordForm.confirm_password" :icon="mdiFormTextboxPassword" name="confirm_password"
type="password" required :error="passwordForm.errors.confirm_password">
<div class="text-red-400 text-sm" v-if="passwordForm.errors.confirm_password">
{{ passwordForm.errors.confirm_password }}
</div>
</FormControl>
</FormField>
<FormField
label="Confirm password"
help="Required. New password one more time"
:class="{ 'text-red-400': passwordForm.errors.confirm_password }"
>
<FormControl
v-model="passwordForm.confirm_password"
:icon="mdiFormTextboxPassword"
name="confirm_password"
type="password"
required
:error="passwordForm.errors.confirm_password"
>
<div class="text-red-400 text-sm" v-if="passwordForm.errors.confirm_password">
{{ passwordForm.errors.confirm_password }}
</div>
</FormControl>
</FormField>
<template #footer>
<BaseButtons>
<BaseButton type="submit" color="info" label="Submit" />
</BaseButtons>
</template>
</CardBox>
</div>
</SectionMain>
</LayoutAuthenticated>
<template #footer>
<BaseButtons>
<BaseButton type="submit" color="info" label="Submit" />
</BaseButtons>
</template>
</CardBox>
</div>
</SectionMain>
</LayoutAuthenticated>
</template>

View file

@ -0,0 +1,141 @@
<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 } from '@mdi/js';
import { computed } from 'vue';
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
import SectionMain from '@/Components/SectionMain.vue';
// import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.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 Sort from '@/Components/Admin/Sort.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 search = computed(() => {
// return props.filters.search;
// });
const flash: ComputedRef<any> = computed(() => {
// let test = usePage();
// console.log(test);
return usePage().props.flash;
});
// const form = useForm({
// search: props.filters.search,
// });
// const formDelete = useForm({});
// async function destroy(id) {
// const destroy = async (id) => {
// // if (confirm('Are you sure you want to delete?')) {
// // await formDelete.delete(stardust.route('dataset.destroy', [id]));
// // }
// };
</script>
<template>
<LayoutAuthenticated>
<Head title="Submit Dataset" />
<SectionMain>
<NotificationBar v-if="flash.message" color="success" :icon="mdiAlertBoxOutline">
{{ flash.message }}
</NotificationBar>
<!-- table -->
<CardBox class="mb-6" has-table>
<table>
<thead>
<tr>
<th>
<!-- <Sort label="Dataset Title" attribute="title" :search="form.search" /> -->
Dataset Title
</th>
<th>
<!-- <Sort label="Email" attribute="email" :search="form.search" /> -->
<th>Server State</th>
</th>
<th>Date of last modification</th>
<th v-if="can.edit || can.delete">Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="dataset in props.datasets.data" :key="dataset.id">
<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.server_state }}
</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.updated_at }}</small>
</td>
<td v-if="can.edit || can.delete" class="before:hidden lg:w-1 whitespace-nowrap">
<BaseButtons type="justify-start lg:justify-end" no-wrap>
<!-- release created dataset -->
<BaseButton
v-if="can.delete && (dataset.server_state === 'inprogress' || dataset.server_state === 'rejected_editor')"
:route-name="stardust.route('dataset.release', [dataset.id])"
color="info"
:icon="mdiSquareEditOutline"
:label="'Release'"
small
/>
<!-- @click="destroy(dataset.id)" -->
<BaseButton v-if="can.delete" color="danger" :icon="mdiTrashCan" small />
</BaseButtons>
</td>
</tr>
</tbody>
</table>
<div class="py-4">
<Pagination v-bind:data="datasets.meta" />
<!-- <ul>
<li>
<a href="{{ users.page == 1 ? '#' : '?page=' + (users.page - 1) }}">Previous</a>
</li>
@each(page in ???)
<li>
<a href="?page={{ page }}">{{ page }}</a>
</li>
@endeach
<li>
<a href="{{ users.lastPage == users.page ? '#' : '?page=' + (users.page + 1) }}">Next</a>
</li>
</ul> -->
</div>
</CardBox>
</SectionMain>
</LayoutAuthenticated>
</template>

View file

@ -0,0 +1,131 @@
<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 { Inertia } from '@inertiajs/inertia';
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, mdiLockOpen } from '@mdi/js';
import FormValidationErrors from '@/Components/FormValidationErrors.vue';
const props = defineProps({
dataset: {
type: Object,
default: () => ({}),
},
});
const flash: Ref<any> = computed(() => {
return usePage().props.flash;
});
const errors: Ref<any> = computed(() => {
return usePage().props.errors;
});
const form = useForm({
preferred_reviewer: '',
preferred_reviewer_email: '',
preferation: 'yes_preferation',
// preferation: '',
// isPreferationRequired: false,
});
// const preferation = ref('yes_preferation');
// const isPreferationRequired = ref(false);
const isPreferationRequired = computed(() => form.preferation === 'yes_preferation');
const handleSubmit = async (e) => {
e.preventDefault();
await form.put(stardust.route('dataset.releaseUpdate', [props.dataset.id]));
};
</script>
<template>
<LayoutAuthenticated>
<Head title="Release saved datasets" />
<SectionMain>
<SectionTitleLineWithButton :icon="mdiLockOpen" title="Release your dataset for Editor" main>
<BaseButton
:route-name="stardust.route('dataset.list')"
:icon="mdiArrowLeftBoldOutline"
label="Back"
color="white"
rounded-full
small
/>
</SectionTitleLineWithButton>
<CardBox form @submit.prevent="handleSubmit">
<FormValidationErrors v-bind:errors="errors" />
<div class="lex flex-col md:flex-row mb-3">
<label for="elevation-option-one" class="pure-radio">
<input id="elevation-option-one" type="radio" v-model="form.preferation" value="yes_preferation" />
preferred reviewer
</label>
<label for="elevation-option-two" class="pure-radio">
<input id="elevation-option-two" type="radio" v-model="form.preferation" value="no_preferation" />
no preferred reviewer
</label>
</div>
<div v-if="isPreferationRequired == true">
<FormField label="preferred reviewer" :class="{ 'text-red-400': form.errors.preferred_reviewer }">
<FormControl
v-model="form.preferred_reviewer"
type="text"
placeholder="-- enter name of preferred reviewer --"
required
:error="form.errors.preferred_reviewer"
>
<div class="text-red-400 text-sm" v-if="form.errors.preferred_reviewer">
{{ form.errors.preferred_reviewer }}
</div>
</FormControl>
</FormField>
<FormField label="reviewer email" :class="{ 'text-red-400': form.errors.preferred_reviewer_email }">
<FormControl
v-model="form.preferred_reviewer_email"
type="text"
placeholder="-- enter email of reviewer --"
required
:error="form.errors.preferred_reviewer_email"
>
<div class="text-red-400 text-sm" v-if="form.errors.preferred_reviewer_email">
{{ form.errors.preferred_reviewer_email }}
</div>
</FormControl>
</FormField>
</div>
<!-- <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.message" 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.message }}</p>
</div>
</div>
<template #footer>
<BaseButtons>
<BaseButton
type="submit"
color="info"
label="Release"
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
/>
</BaseButtons>
</template>
</CardBox>
</SectionMain>
</LayoutAuthenticated>
</template>