diff --git a/app/controllers/projects_controller.ts b/app/controllers/projects_controller.ts deleted file mode 100644 index 21e20df..0000000 --- a/app/controllers/projects_controller.ts +++ /dev/null @@ -1,54 +0,0 @@ -// app/controllers/projects_controller.ts -import Project from '#models/project'; -import type { HttpContext } from '@adonisjs/core/http'; -import { createProjectValidator, updateProjectValidator } from '#validators/project'; - -export default class ProjectsController { - // GET /settings/projects - public async index({ inertia, auth }: HttpContext) { - const projects = await Project.all(); - // return inertia.render('Admin/Project/Index', { projects }); - return inertia.render('Admin/Project/Index', { - projects: projects, - can: { - edit: await auth.user?.can(['settings']), - create: await auth.user?.can(['settings']), - }, - }); - } - - // GET /settings/projects/create - public async create({ inertia }: HttpContext) { - return inertia.render('Admin/Project/Create'); - } - - // POST /settings/projects - public async store({ request, response, session }: HttpContext) { - // Validate the request data - const data = await request.validateUsing(createProjectValidator); - - await Project.create(data); - - session.flash('success', 'Project created successfully'); - return response.redirect().toRoute('settings.project.index'); - } - - // GET /settings/projects/:id/edit - public async edit({ params, inertia }: HttpContext) { - const project = await Project.findOrFail(params.id); - return inertia.render('Admin/Project/Edit', { project }); - } - - // PUT /settings/projects/:id - public async update({ params, request, response, session }: HttpContext) { - const project = await Project.findOrFail(params.id); - - // Validate the request data - const data = await request.validateUsing(updateProjectValidator); - - await project.merge(data).save(); - - session.flash('success', 'Project updated successfully'); - return response.redirect().toRoute('settings.project.index'); - } -} diff --git a/app/validators/project.ts b/app/validators/project.ts deleted file mode 100644 index bad6c7c..0000000 --- a/app/validators/project.ts +++ /dev/null @@ -1,28 +0,0 @@ -// app/validators/project.ts -import vine from '@vinejs/vine'; - -export const createProjectValidator = vine.compile( - vine.object({ - label: vine.string().trim().minLength(1).maxLength(50), - name: vine - .string() - .trim() - .minLength(3) - .maxLength(255) - .regex(/^[a-z0-9-]+$/), - description: vine.string().trim().maxLength(255).minLength(5).optional(), - }), -); - -export const updateProjectValidator = vine.compile( - vine.object({ - // label is NOT included since it's readonly - name: vine - .string() - .trim() - .minLength(3) - .maxLength(255) - .regex(/^[a-z0-9-]+$/), - description: vine.string().trim().maxLength(255).minLength(5).optional(), - }), -); diff --git a/resources/js/Components/TablePersons.vue b/resources/js/Components/TablePersons.vue index c119d8c..3dd6d3b 100644 --- a/resources/js/Components/TablePersons.vue +++ b/resources/js/Components/TablePersons.vue @@ -2,8 +2,8 @@ import { computed, ref, watch } from 'vue'; import { mdiTrashCan } from '@mdi/js'; import { mdiDragVariant, mdiChevronLeft, mdiChevronRight } from '@mdi/js'; -import { mdiAccount, mdiDomain } from '@mdi/js'; import BaseIcon from '@/Components/BaseIcon.vue'; +import BaseButtons from '@/Components/BaseButtons.vue'; import BaseButton from '@/Components/BaseButton.vue'; import { Person } from '@/Dataset'; import Draggable from 'vuedraggable'; @@ -21,6 +21,25 @@ interface Props { canReorder?: boolean; } +// const props = defineProps({ +// checkable: Boolean, +// persons: { +// type: Array, +// default: () => [], +// }, +// relation: { +// type: String, +// required: true, +// }, +// contributortypes: { +// type: Object, +// default: () => ({}), +// }, +// errors: { +// type: Object, +// default: () => ({}), +// }, +// }); const props = withDefaults(defineProps(), { checkable: false, persons: () => [], @@ -44,18 +63,15 @@ const perPage = ref(5); const currentPage = ref(0); const dragEnabled = ref(props.canReorder); -// Name type options -const nameTypeOptions = { - 'Personal': 'Personal', - 'Organizational': 'Org' -}; - // Computed properties const items = computed({ get() { return props.persons; }, + // setter set(value) { + // Note: we are using destructuring assignment syntax here. + props.persons.length = 0; props.persons.push(...value); }, @@ -106,19 +122,19 @@ const pagesList = computed(() => { return pages; }); +// const removeAuthor = (key: number) => { +// items.value.splice(key, 1); +// }; // Methods const removeAuthor = (index: number) => { const actualIndex = perPage.value * currentPage.value + index; const person = items.value[actualIndex]; - const displayName = person.name_type === 'Organizational' - ? person.last_name || person.email - : `${person.first_name || ''} ${person.last_name || person.email}`.trim(); - - if (confirm(`Are you sure you want to remove ${displayName}?`)) { + if (confirm(`Are you sure you want to remove ${person.first_name || ''} ${person.last_name || person.email}?`)) { items.value.splice(actualIndex, 1); emit('remove-person', actualIndex, person); + // Adjust current page if needed if (itemsPaginated.value.length === 0 && currentPage.value > 0) { currentPage.value--; } @@ -128,12 +144,6 @@ const removeAuthor = (index: number) => { const updatePerson = (index: number, field: keyof Person, value: any) => { const actualIndex = perPage.value * currentPage.value + index; const person = items.value[actualIndex]; - - // Handle name_type change - clear first_name if switching to Organizational - if (field === 'name_type' && value === 'Organizational') { - person.first_name = ''; - } - (person as any)[field] = value; emit('person-updated', actualIndex, person); }; @@ -160,6 +170,7 @@ const handleDragEnd = (evt: any) => { watch( () => props.persons.length, () => { + // Reset to first page if current page is out of bounds if (currentPage.value >= numPages.value && numPages.value > 0) { currentPage.value = numPages.value - 1; } @@ -178,16 +189,18 @@ const perPageOptions = [ @@ -558,6 +481,7 @@ const perPageOptions = [ @apply bg-white dark:bg-slate-900 rounded-lg shadow-sm; } +/* Improve table responsiveness */ @media (max-width: 768px) { table { font-size: 0.875rem; @@ -568,4 +492,4 @@ const perPageOptions = [ padding: 0.5rem !important; } } - \ No newline at end of file + diff --git a/resources/js/Layouts/LayoutAuthenticated.vue b/resources/js/Layouts/LayoutAuthenticated.vue index c077c7b..15a117c 100644 --- a/resources/js/Layouts/LayoutAuthenticated.vue +++ b/resources/js/Layouts/LayoutAuthenticated.vue @@ -14,11 +14,11 @@ const props = defineProps({ showAsideMenu: { type: Boolean, default: true // Set default value to true - }, - hasProgressBar: { - type: Boolean, - default: false // New prop to indicate if progress bar is shown } + // user: { + // type: Object, + // default: () => ({}), + // } }); @@ -29,18 +29,9 @@ const props = defineProps({ }">
- + 'xl:pl-60': props.showAsideMenu==true }" + class="pt-14 min-h-screen w-screen transition-position lg:w-auto bg-gray-50 dark:bg-slate-800 dark:text-slate-100"> +