2023-03-24 10:41:52 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed, ref } from 'vue';
|
|
|
|
// import { MainService } from '@/Stores/main';
|
2024-04-23 17:36:45 +00:00
|
|
|
import { StyleService } from '@/Stores/style.service';
|
2023-03-24 10:41:52 +00:00
|
|
|
import { mdiTrashCan } from '@mdi/js';
|
2023-09-05 16:18:42 +00:00
|
|
|
import { mdiDragVariant } from '@mdi/js';
|
|
|
|
import BaseIcon from '@/Components/BaseIcon.vue';
|
2023-03-24 10:41:52 +00:00
|
|
|
// import CardBoxModal from '@/Components/CardBoxModal.vue';
|
|
|
|
// import TableCheckboxCell from '@/Components/TableCheckboxCell.vue';
|
2023-09-12 14:09:04 +00:00
|
|
|
// import BaseLevel from '@/Components/BaseLevel.vue';
|
2023-03-24 10:41:52 +00:00
|
|
|
import BaseButtons from '@/Components/BaseButtons.vue';
|
|
|
|
import BaseButton from '@/Components/BaseButton.vue';
|
|
|
|
import UserAvatar from '@/Components/UserAvatar.vue';
|
|
|
|
// import Person from 'App/Models/Person';
|
|
|
|
import { Person } from '@/Stores/main';
|
2023-06-16 14:44:28 +00:00
|
|
|
import Draggable from 'vuedraggable';
|
2023-09-12 14:09:04 +00:00
|
|
|
import FormControl from '@/Components/FormControl.vue';
|
2023-03-24 10:41:52 +00:00
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
checkable: Boolean,
|
|
|
|
persons: {
|
|
|
|
type: Array<Person>,
|
|
|
|
default: () => [],
|
|
|
|
},
|
2024-06-14 10:38:04 +00:00
|
|
|
relation: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2023-09-12 14:09:04 +00:00
|
|
|
contributortypes: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
errors: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
2023-03-24 10:41:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const styleService = StyleService();
|
|
|
|
// const mainService = MainService();
|
2023-06-16 14:44:28 +00:00
|
|
|
// const items = computed(() => props.persons);
|
|
|
|
|
|
|
|
const items = computed({
|
|
|
|
get() {
|
|
|
|
return props.persons;
|
|
|
|
},
|
|
|
|
// setter
|
|
|
|
set(value) {
|
|
|
|
// Note: we are using destructuring assignment syntax here.
|
2023-06-27 16:23:18 +00:00
|
|
|
|
|
|
|
props.persons.length = 0;
|
|
|
|
props.persons.push(...value);
|
2023-06-16 14:44:28 +00:00
|
|
|
},
|
|
|
|
});
|
2023-03-24 10:41:52 +00:00
|
|
|
|
|
|
|
// const isModalActive = ref(false);
|
|
|
|
// const isModalDangerActive = ref(false);
|
|
|
|
const perPage = ref(5);
|
|
|
|
const currentPage = ref(0);
|
|
|
|
// const checkedRows = ref([]);
|
|
|
|
|
2023-06-16 14:44:28 +00:00
|
|
|
const itemsPaginated = computed({
|
|
|
|
get() {
|
|
|
|
return items.value.slice(perPage.value * currentPage.value, perPage.value * (currentPage.value + 1));
|
|
|
|
},
|
|
|
|
// setter
|
|
|
|
set(value) {
|
|
|
|
// Note: we are using destructuring assignment syntax here.
|
2023-06-27 16:23:18 +00:00
|
|
|
|
|
|
|
props.persons.length = 0;
|
|
|
|
props.persons.push(...value);
|
2023-06-16 14:44:28 +00:00
|
|
|
},
|
|
|
|
});
|
2023-03-24 10:41:52 +00:00
|
|
|
|
|
|
|
const numPages = computed(() => Math.ceil(items.value.length / perPage.value));
|
|
|
|
|
|
|
|
const currentPageHuman = computed(() => currentPage.value + 1);
|
|
|
|
|
|
|
|
const pagesList = computed(() => {
|
|
|
|
const pagesList: Array<number> = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < numPages.value; i++) {
|
|
|
|
pagesList.push(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pagesList;
|
|
|
|
});
|
|
|
|
|
2024-06-14 10:38:04 +00:00
|
|
|
const removeAuthor = (key: number) => {
|
2023-03-24 10:41:52 +00:00
|
|
|
items.value.splice(key, 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
// const remove = (arr, cb) => {
|
|
|
|
// const newArr = [];
|
|
|
|
|
|
|
|
// arr.forEach((item) => {
|
|
|
|
// if (!cb(item)) {
|
|
|
|
// newArr.push(item);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
// return newArr;
|
|
|
|
// };
|
|
|
|
|
|
|
|
// const checked = (isChecked, client) => {
|
|
|
|
// if (isChecked) {
|
|
|
|
// checkedRows.value.push(client);
|
|
|
|
// } else {
|
|
|
|
// checkedRows.value = remove(checkedRows.value, (row) => row.id === client.id);
|
|
|
|
// }
|
|
|
|
// };
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<!-- <CardBoxModal v-model="isModalActive" title="Sample modal">
|
|
|
|
<p>Lorem ipsum dolor sit amet <b>adipiscing elit</b></p>
|
|
|
|
<p>This is sample modal</p>
|
|
|
|
</CardBoxModal>
|
|
|
|
|
|
|
|
<CardBoxModal v-model="isModalDangerActive" large-title="Please confirm" button="danger" has-cancel>
|
|
|
|
<p>Lorem ipsum dolor sit amet <b>adipiscing elit</b></p>
|
|
|
|
<p>This is sample modal</p>
|
|
|
|
</CardBoxModal> -->
|
|
|
|
|
|
|
|
<!-- <div v-if="checkedRows.length" class="p-3 bg-gray-100/50 dark:bg-slate-800">
|
|
|
|
<span v-for="checkedRow in checkedRows" :key="checkedRow.id"
|
|
|
|
class="inline-block px-2 py-1 rounded-sm mr-2 text-sm bg-gray-100 dark:bg-slate-700">
|
|
|
|
{{ checkedRow.name }}
|
|
|
|
</span>
|
|
|
|
</div> -->
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<!-- <th v-if="checkable" /> -->
|
2023-09-12 14:09:04 +00:00
|
|
|
<th />
|
2023-06-27 16:23:18 +00:00
|
|
|
<th scope="col">Sort</th>
|
2024-06-14 10:38:04 +00:00
|
|
|
<th scope="col">Id</th>
|
|
|
|
<!-- <th class="hidden lg:table-cell"></th> -->
|
|
|
|
<th>First Name</th>
|
|
|
|
<th>Last Name</th>
|
2023-03-24 10:41:52 +00:00
|
|
|
<th>Email</th>
|
2023-09-12 14:09:04 +00:00
|
|
|
<th scope="col" v-if="Object.keys(contributortypes).length">
|
|
|
|
<span>Type</span>
|
|
|
|
</th>
|
|
|
|
|
2023-03-24 10:41:52 +00:00
|
|
|
<!-- <th>Name Type</th> -->
|
|
|
|
<!-- <th>Progress</th> -->
|
2023-06-27 16:23:18 +00:00
|
|
|
<!-- <th>Created</th> -->
|
2023-03-24 10:41:52 +00:00
|
|
|
<th />
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2023-06-16 14:44:28 +00:00
|
|
|
<!-- <tbody> -->
|
|
|
|
<!-- <tr v-for="(client, index) in itemsPaginated" :key="client.id"> -->
|
|
|
|
<draggable id="galliwasery" tag="tbody" v-model="items" item-key="id">
|
|
|
|
<template #item="{ index, element }">
|
|
|
|
<tr>
|
2023-09-12 14:09:04 +00:00
|
|
|
<td class="drag-icon">
|
|
|
|
<BaseIcon :path="mdiDragVariant" />
|
|
|
|
</td>
|
2023-06-16 14:44:28 +00:00
|
|
|
<td scope="row">{{ index + 1 }}</td>
|
2024-06-14 10:38:04 +00:00
|
|
|
<td data-label="Id">{{ element.id }}</td>
|
2023-06-16 14:44:28 +00:00
|
|
|
<!-- <TableCheckboxCell v-if="checkable" @checked="checked($event, client)" /> -->
|
2024-06-14 10:38:04 +00:00
|
|
|
<!-- <td v-if="element.name" class="border-b-0 lg:w-6 before:hidden hidden lg:table-cell">
|
2023-06-16 14:44:28 +00:00
|
|
|
<UserAvatar :username="element.name" class="w-24 h-24 mx-auto lg:w-6 lg:h-6" />
|
2024-06-14 10:38:04 +00:00
|
|
|
</td> -->
|
|
|
|
<td data-label="First Name">
|
|
|
|
<!-- {{ element.first_name }} -->
|
|
|
|
<FormControl
|
|
|
|
required
|
|
|
|
v-model="element.first_name"
|
|
|
|
type="text" :is-read-only="element.status==true"
|
|
|
|
placeholder="[FIRST NAME]"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="text-red-400 text-sm"
|
|
|
|
v-if="errors && Array.isArray(errors[`${relation}.${index}.first_name`])"
|
|
|
|
>
|
|
|
|
{{ errors[`${relation}.${index}.first_name`].join(', ') }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
2023-06-16 14:44:28 +00:00
|
|
|
</td>
|
2024-06-14 10:38:04 +00:00
|
|
|
<td data-label="Last Name">
|
|
|
|
<FormControl
|
|
|
|
required
|
|
|
|
v-model="element.last_name"
|
|
|
|
type="text" :is-read-only="element.status==true"
|
|
|
|
placeholder="[LAST NAME]"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="text-red-400 text-sm"
|
|
|
|
v-if="errors && Array.isArray(errors[`${relation}.${index}.last_name`])"
|
|
|
|
>
|
|
|
|
{{ errors[`${relation}.${index}.last_name`].join(', ') }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
2023-06-16 14:44:28 +00:00
|
|
|
</td>
|
2024-06-14 10:38:04 +00:00
|
|
|
<td data-label="Email">
|
|
|
|
<FormControl
|
|
|
|
required
|
|
|
|
v-model="element.email"
|
|
|
|
type="text" :is-read-only="element.status==true"
|
|
|
|
placeholder="[EMAIL]"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="text-red-400 text-sm"
|
|
|
|
v-if="errors && Array.isArray(errors[`${relation}.${index}.email`])"
|
|
|
|
>
|
|
|
|
{{ errors[`${relation}.${index}.email`].join(', ') }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
2023-06-16 14:44:28 +00:00
|
|
|
</td>
|
2023-09-12 14:09:04 +00:00
|
|
|
<td v-if="Object.keys(contributortypes).length">
|
|
|
|
<!-- <select type="text" v-model="element.pivot.contributor_type">
|
|
|
|
<option v-for="(option, i) in contributortypes" :value="option" :key="i">
|
|
|
|
{{ option }}
|
|
|
|
</option>
|
|
|
|
</select> -->
|
2023-10-31 14:38:43 +00:00
|
|
|
<FormControl
|
|
|
|
required
|
|
|
|
v-model="element.pivot_contributor_type"
|
|
|
|
type="select"
|
2024-06-14 10:38:04 +00:00
|
|
|
:options="contributortypes"
|
2023-10-31 14:38:43 +00:00
|
|
|
placeholder="[relation type]"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="text-red-400 text-sm"
|
2024-06-14 10:38:04 +00:00
|
|
|
v-if="errors && Array.isArray(errors[`${relation}.${index}.pivot_contributor_type`])"
|
2023-10-31 14:38:43 +00:00
|
|
|
>
|
2024-06-14 10:38:04 +00:00
|
|
|
{{ errors[`${relation}.${index}.pivot_contributor_type`].join(', ') }}
|
2023-09-12 14:09:04 +00:00
|
|
|
</div>
|
|
|
|
</FormControl>
|
|
|
|
</td>
|
2023-06-16 14:44:28 +00:00
|
|
|
<!-- <td data-label="Name Type">
|
2023-03-24 10:41:52 +00:00
|
|
|
{{ client.name_type }}
|
|
|
|
</td> -->
|
2023-06-16 14:44:28 +00:00
|
|
|
<!-- <td data-label="Orcid">
|
2023-03-24 10:41:52 +00:00
|
|
|
{{ client.identifier_orcid }}
|
|
|
|
</td> -->
|
2023-06-16 14:44:28 +00:00
|
|
|
<!-- <td data-label="Progress" class="lg:w-32">
|
2023-03-24 10:41:52 +00:00
|
|
|
<progress class="flex w-2/5 self-center lg:w-full" max="100" v-bind:value="client.progress">
|
|
|
|
{{ client.progress }}
|
|
|
|
</progress>
|
|
|
|
</td> -->
|
2023-06-16 14:44:28 +00:00
|
|
|
<td class="before:hidden lg:w-1 whitespace-nowrap">
|
|
|
|
<BaseButtons type="justify-start lg:justify-end" no-wrap>
|
|
|
|
<!-- <BaseButton color="info" :icon="mdiEye" small @click="isModalActive = true" /> -->
|
|
|
|
<BaseButton color="danger" :icon="mdiTrashCan" small @click.prevent="removeAuthor(index)" />
|
|
|
|
</BaseButtons>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</draggable>
|
|
|
|
<!-- </tbody> -->
|
2023-03-24 10:41:52 +00:00
|
|
|
</table>
|
|
|
|
<!-- :class="[ pagesList.length > 1 ? 'block' : 'hidden']" -->
|
2023-06-16 14:44:28 +00:00
|
|
|
<div class="p-3 lg:px-6 border-t border-gray-100 dark:border-slate-800">
|
|
|
|
<!-- <BaseLevel>
|
2023-03-24 10:41:52 +00:00
|
|
|
<BaseButtons>
|
|
|
|
<BaseButton
|
|
|
|
v-for="page in pagesList"
|
|
|
|
:key="page"
|
|
|
|
:active="page === currentPage"
|
|
|
|
:label="page + 1"
|
|
|
|
small
|
|
|
|
:outline="styleService.darkMode"
|
|
|
|
@click="currentPage = page"
|
|
|
|
/>
|
|
|
|
</BaseButtons>
|
|
|
|
<small>Page {{ currentPageHuman }} of {{ numPages }}</small>
|
2023-06-16 14:44:28 +00:00
|
|
|
</BaseLevel> -->
|
2023-03-24 10:41:52 +00:00
|
|
|
</div>
|
2024-04-23 17:36:45 +00:00
|
|
|
</template>
|