- now authenticated user can change password with check of old password and password confirmination
Some checks failed
CI Pipeline / japa-tests (push) Failing after 52s

- cchanged route app.dashboard to apps.dashboard
- add editor and reviewer relation to Dataset.ts
- added personal menu in asideMenu
- added Approve.vue for editor
- show warning in Index.vue  (editor), if no dataset is loaded
- user Receive.vue without inertia helper form
- npm updates
- added routes in routes.ts
This commit is contained in:
Kaimbacher 2023-12-12 15:22:25 +01:00
parent 0d51002903
commit ae0c471e93
14 changed files with 733 additions and 408 deletions

View file

@ -3,5 +3,5 @@ import FormControl from '@/Components/FormControl.vue';
</script>
<template>
<FormControl ref="root" placeholder="Search (ctrl+k)" ctrl-k-focus transparent borderless />
<FormControl id="searchInput" ref="root" placeholder="Search (ctrl+k)" ctrl-k-focus transparent borderless />
</template>

View file

@ -44,6 +44,7 @@ export interface Dataset {
authors: Array<Person>;
contributors: Array<Person>;
project_id?: number;
reviewer_id?: number;
embargo_date?: string;
coverage: Coverage;
errors?: IErrorMessage;

View file

@ -4,9 +4,9 @@ import { useForm } from '@inertiajs/vue3';
// import { reactive } from 'vue';
import {
mdiAccount,
mdiAccountCircle,
// mdiAccountCircle,
mdiLock,
mdiMail,
// mdiMail,
mdiAsterisk,
mdiFormTextboxPassword,
mdiArrowLeftBoldOutline,
@ -24,8 +24,12 @@ import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.vue';
import { stardust } from '@eidellev/adonis-stardust/client';
// import { Inertia } from '@inertiajs/inertia';
import { computed, Ref } from 'vue';
import { usePage } from '@inertiajs/vue3';
import FormValidationErrors from '@/Components/FormValidationErrors.vue';
const props = defineProps({
defineProps({
// user will be returned from controller action
user: {
type: Object,
@ -37,13 +41,13 @@ const props = defineProps({
},
});
const profileForm = useForm({
login: props.user.login,
email: props.user.email,
});
const profileSubmit = async () => {
await profileForm.post(stardust.route('admin.account.info.store', [props.user.id]));
};
// const profileForm = useForm({
// 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: '',
@ -51,38 +55,38 @@ const passwordForm = useForm({
confirm_password: '',
});
const passwordSubmit = async () => {
await passwordForm.post(stardust.route('admin.account.info.store'), {
await passwordForm.post(stardust.route('account.info.store'), {
preserveScroll: true,
onSuccess: (resp) => {
console.log(resp);
onSuccess: () => {
// console.log(resp);
passwordForm.reset();
},
});
};
const flash: Ref<any> = computed(() => {
return usePage().props.flash;
});
</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
/>
<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">
{{ $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"> -->
<div class="grid grid-cols-1 lg:grid-cols-1 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()">
<!-- <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">
@ -103,77 +107,59 @@ const passwordSubmit = async () => {
<BaseButton color="info" type="submit" label="Submit" />
</BaseButtons>
</template>
</CardBox>
</CardBox> -->
<!-- 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"
>
}) "> -->
<CardBox id="passwordForm" title="Change Password" :icon="mdiLock" form @submit.prevent="passwordSubmit()">
<FormValidationErrors v-bind:errors="errors" />
<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 />
<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"
>
<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"
>
<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>
<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>
<BaseDivider />
<template #footer>
<BaseButtons>
<BaseButton type="submit" color="info" label="Submit" />
<BaseButton type="submit" color="info" label="Change password" />
</BaseButtons>
</template>
</CardBox>

View file

@ -0,0 +1,120 @@
<script setup lang="ts">
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
import SectionMain from '@/Components/SectionMain.vue';
import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.vue';
import { Head, usePage, useForm } from '@inertiajs/vue3';
import { computed, Ref } from 'vue';
import CardBox from '@/Components/CardBox.vue';
import BaseButton from '@/Components/BaseButton.vue';
import BaseButtons from '@/Components/BaseButtons.vue';
import { stardust } from '@eidellev/adonis-stardust/client';
import { mdiArrowLeftBoldOutline, mdiShareVariant } from '@mdi/js';
import FormValidationErrors from '@/Components/FormValidationErrors.vue';
// import { Dataset } from '@/Dataset';
import FormField from '@/Components/FormField.vue';
import FormControl from '@/Components/FormControl.vue';
const props = defineProps({
errors: {
type: Object,
default: () => ({}),
},
dataset: {
type: Object,
default: () => ({}),
},
reviewers: {
type: Object,
default: () => ({}),
},
});
// const isButtonDisabled = computed(() => {
// return form.processing || form.reviewer_id != undefined;
// });
const isButtonDisabled = computed(() => {
return form.processing || form.reviewer_id === undefined;
});
const flash: Ref<any> = computed(() => {
return usePage().props.flash;
});
// const errors: Ref<any> = computed(() => {
// return usePage().props.errors;
// });
const form = useForm({
reviewer_id: undefined,
});
// let form = useForm<Dataset>(props.dataset as Dataset);
// const isPreferationRequired = computed(() => form.preferation === 'yes_preferation');
const handleSubmit = async (e) => {
e.preventDefault();
await form.put(stardust.route('editor.dataset.approveUpdate', [props.dataset.id]));
};
</script>
<template>
<LayoutAuthenticated>
<Head title="Approve dataset" />
<SectionMain>
<SectionTitleLineWithButton :icon="mdiShareVariant" title="Approve corrected dataset" main>
<BaseButton :route-name="stardust.route('editor.dataset.list')" :icon="mdiArrowLeftBoldOutline" label="Back"
color="white" rounded-full small />
</SectionTitleLineWithButton>
<CardBox :form="true" @submit.prevent="handleSubmit" id="approveForm">
<FormValidationErrors v-bind:errors="errors" />
<div class="mb-4">
<div class="w-full">
<div class="block font-bold mb-2" for="owner">Preferred Reviewer:</div>
<div id="owner" class="w-full p-2 rounded-md">{{ dataset.preferred_reviewer }}</div>
</div>
<div class="w-full">
<div class="block font-bold mb-2" for="owner2">Preferred Reviewer Email:</div>
<div id="owner2" class="w-full p-2 rounded-md">{{ dataset.preferred_reviewer_email }}</div>
</div>
<FormField label="Reviewer" help="reviewer is required" label-for="selectReviewer"
:class="{ 'text-red-400': form.errors.reviewer_id }" class="w-full mx-2 flex-1">
<FormControl id="selectReviewer" v-model="form.reviewer_id" :type="'select'" placeholder="-- select reviewer --"
:errors="form.errors.reviewer_id" :options="reviewers">
<div class="text-red-400 text-sm" v-if="form.errors.reviewer_id">
{{ form.errors.reviewer_id }}
</div>
</FormControl>
</FormField>
</div>
<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="Set Approved"
:class="{ 'opacity-25': form.processing }"
:disabled="isButtonDisabled" :icon="mdiShareVariant"
small />
<!-- <button :disabled="errors.any()" type="submit" class="pure-button">
<i class="fa fa-share"></i>
<span>Set Approved</span>
</button> -->
</BaseButtons>
</template>
</CardBox>
</SectionMain>
</LayoutAuthenticated>
</template>

View file

@ -2,7 +2,7 @@
// import { Head, Link, useForm, usePage } from '@inertiajs/inertia-vue3';
import { Head, usePage } from '@inertiajs/vue3';
import { ComputedRef } from 'vue';
import { mdiSquareEditOutline, mdiAlertBoxOutline } from '@mdi/js';
import { mdiSquareEditOutline, mdiAlertBoxOutline, mdiShareVariant } from '@mdi/js';
import { computed } from 'vue';
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
import SectionMain from '@/Components/SectionMain.vue';
@ -76,81 +76,96 @@ const getRowClass = (dataset) => {
<!-- table -->
<CardBox class="mb-6" has-table>
<table class="pure-table">
<thead>
<tr>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
<!-- <Sort label="Dataset Title" attribute="title" :search="form.search" /> -->
Title
</th>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
Submitter
</th>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
<!-- <Sort label="Email" attribute="email" :search="form.search" /> -->
State
</th>
<div v-if="props.datasets && props.datasets.length > 0">
<table class="pure-table">
<thead>
<tr>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
<!-- <Sort label="Dataset Title" attribute="title" :search="form.search" /> -->
Title
</th>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
Submitter
</th>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
<!-- <Sort label="Email" attribute="email" :search="form.search" /> -->
State
</th>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
Editor
</th>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
Date of last modification
</th>
<th scope="col" class="relative px-6 py-3" v-if="can.edit || can.delete">
<span class="sr-only">Actions</span>
</th>
</tr>
</thead>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
Editor
</th>
<th scope="col" class="py-3 text-left text-xs font-medium uppercase tracking-wider">
Date of last modification
</th>
<th scope="col" class="relative px-6 py-3" v-if="can.edit || can.delete">
<span class="sr-only">Actions</span>
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr v-for="dataset in props.datasets.data" :key="dataset.id"
:class="[getRowClass(dataset)]">
<td data-label="Login" class="py-4 whitespace-nowrap text-gray-700 dark:text-white">
<!-- <Link v-bind:href="stardust.route('user.show', [user.id])"
<tbody class="bg-white divide-y divide-gray-200">
<tr v-for="dataset in props.datasets.data" :key="dataset.id" :class="[getRowClass(dataset)]">
<td data-label="Login" class="py-4 whitespace-nowrap text-gray-700 dark:text-white">
<!-- <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> -->
<div class="text-sm font-medium">{{ dataset.main_title }}</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white">
<div class="text-sm">{{ dataset.user.login }}</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white">
<div class="text-sm">{{ dataset.server_state }}</div>
</td>
<div class="text-sm font-medium">{{ dataset.main_title }}</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white">
<div class="text-sm">{{ dataset.user.login }}</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white">
<div class="text-sm">{{ dataset.server_state }}</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white"
v-if="dataset.server_state === 'released'">
<div class="text-sm" :title="dataset.server_date_modified">
Preferred reviewer: {{ dataset.preferred_reviewer }}
</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white"
v-else-if="dataset.server_state === 'editor_accepted' || dataset.server_state === 'rejected_reviewer'">
<div class="text-sm" :title="dataset.server_date_modified">
In approval by: {{ dataset.editor?.login }}
</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white" v-else>
<div class="text-sm">{{ dataset.editor?.login }}</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white"
v-if="dataset.server_state === 'released'">
<div class="text-sm" :title="dataset.server_date_modified">
Preferred reviewer: {{ dataset.preferred_reviewer }}
</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white"
v-else-if="dataset.server_state === 'editor_accepted' || dataset.server_state === 'rejected_reviewer'">
<div class="text-sm" :title="dataset.server_date_modified">
In approval by: {{ dataset.editor?.login }}
</div>
</td>
<td class="py-4 whitespace-nowrap text-gray-700 dark:text-white" v-else>
<div class="text-sm">{{ dataset.editor?.login }}</div>
</td>
<td data-label="modified" class="py-4 whitespace-nowrap text-gray-700 dark:text-white">
<div class="text-sm" :title="dataset.server_date_modified">
{{ dataset.server_date_modified }}
</div>
</td>
<td
class="py-4 whitespace-nowrap text-right text-sm font-medium text-gray-700 dark:text-white">
<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 edit task'" small />
<BaseButton
v-if="can.approve && (dataset.server_state == 'editor_accepted' || dataset.server_state == 'rejected_reviewer')"
:route-name="stardust.route('editor.dataset.approve', [dataset.id])"
color="info" :icon="mdiShareVariant" :label="'Approve'" small />
</BaseButtons>
</td>
</tr>
</tbody>
</table>
</div>
<div v-else>
<!-- Show warning message if datasets are not defined or empty -->
<div class="bg-yellow-200 text-yellow-800 rounded-md p-4">
<p>No datasets defined.</p>
<!-- You can add more descriptive text here -->
</div>
</div>
<td data-label="modified" class="py-4 whitespace-nowrap text-gray-700 dark:text-white">
<div class="text-sm" :title="dataset.server_date_modified">
{{ dataset.server_date_modified }}
</div>
</td>
<td class="py-4 whitespace-nowrap text-right text-sm font-medium text-gray-700 dark:text-white">
<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 />
</BaseButtons>
</td>
</tr>
</tbody>
</table>
<!-- <BaseButton
v-if="can.edit && (dataset.server_state == 'editor_accepted' || dataset.server_state == 'rejected_reviewer')"

View file

@ -2,7 +2,7 @@
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 { router, Head, usePage } from '@inertiajs/vue3';
import { computed, Ref } from 'vue';
import CardBox from '@/Components/CardBox.vue';
import BaseButton from '@/Components/BaseButton.vue';
@ -11,7 +11,7 @@ import { stardust } from '@eidellev/adonis-stardust/client';
import { mdiArrowLeftBoldOutline, mdiLockOpen } from '@mdi/js';
import FormValidationErrors from '@/Components/FormValidationErrors.vue';
defineProps({
const props = defineProps({
dataset: {
type: Object,
default: () => ({}),
@ -25,14 +25,14 @@ const errors: Ref<any> = computed(() => {
return usePage().props.errors;
});
const form = useForm({
preferred_reviewer: '',
preferred_reviewer_email: '',
preferation: 'yes_preferation',
// const form = useForm({
// preferred_reviewer: '',
// preferred_reviewer_email: '',
// preferation: 'yes_preferation',
// preferation: '',
// isPreferationRequired: false,
});
// // preferation: '',
// // isPreferationRequired: false,
// });
// const isPreferationRequired = computed(() => form.preferation === 'yes_preferation');
@ -40,6 +40,7 @@ const form = useForm({
const handleSubmit = async (e) => {
e.preventDefault();
await router.put(stardust.route('editor.dataset.receiveUpdate', [props.dataset.id]));
// await form.put(stardust.route('dataset.releaseUpdate', [props.dataset.id]));
// // await form.put(stardust.route('editor.dataset.update', [props.dataset.id]));
};
@ -96,7 +97,8 @@ const handleSubmit = async (e) => {
<template #footer>
<BaseButtons>
<!-- <BaseButton type="submit" color="info" label="Receive"
:class="{ 'opacity-25': form.processing }" :disabled="form.processing" /> -->
:class="{ 'opacity-25': router.processing }" :disabled="form.processing" /> -->
<BaseButton type="submit" color="info" label="Receive"/>
</BaseButtons>
</template>
</CardBox>

View file

@ -7,11 +7,31 @@ import {
mdiPublish,
mdiAccountArrowUp,
mdiFormatListNumbered,
mdiLock
} from '@mdi/js';
export default [
{
route: 'app.dashboard',
// route: 'dataset.create',
icon: mdiAccountArrowUp,
label: 'Personal',
// roles: ['submitter'],
isOpen: true,
children: [
{
route: 'settings.user',
icon: mdiLock,
label: 'Security',
},
// {
// route: 'dataset.create',
// icon: mdiPublish,
// label: 'Create Dataset',
// },
],
},
{
route: 'apps.dashboard',
icon: mdiMonitor,
label: 'Dashboard',
},