#28 - holidays management
This commit is contained in:
		
							
								
								
									
										106
									
								
								resources/js/Pages/Holidays/Create.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								resources/js/Pages/Holidays/Create.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,106 @@
 | 
			
		||||
<template>
 | 
			
		||||
    <InertiaHead title="Dodaj dzień wolny" />
 | 
			
		||||
    <div class="bg-white sm:rounded-lg shadow-md">
 | 
			
		||||
        <div class="p-4 sm:px-6">
 | 
			
		||||
            <h2 class="text-lg leading-6 font-medium text-gray-900">
 | 
			
		||||
                Dodaj dzień wolny
 | 
			
		||||
            </h2>
 | 
			
		||||
            <p class="mt-1 text-sm text-gray-500">
 | 
			
		||||
                Użytkownik nie będzie miał możliwości wzięcia urlopu w dzień wolny.
 | 
			
		||||
            </p>
 | 
			
		||||
        </div>
 | 
			
		||||
        <form
 | 
			
		||||
            class="border-t border-gray-200 px-6"
 | 
			
		||||
            @submit.prevent="createHoliday"
 | 
			
		||||
        >
 | 
			
		||||
            <div class="sm:grid sm:grid-cols-3 py-4 items-center">
 | 
			
		||||
                <label
 | 
			
		||||
                    for="name"
 | 
			
		||||
                    class="block text-sm font-medium text-gray-700 sm:mt-px"
 | 
			
		||||
                >
 | 
			
		||||
                    Nazwa
 | 
			
		||||
                </label>
 | 
			
		||||
                <div class="mt-1 sm:mt-0 sm:col-span-2">
 | 
			
		||||
                    <input
 | 
			
		||||
                        id="name"
 | 
			
		||||
                        v-model="form.name"
 | 
			
		||||
                        type="text"
 | 
			
		||||
                        class="block w-full max-w-lg shadow-sm rounded-md sm:text-sm"
 | 
			
		||||
                        :class="{ 'border-red-300 text-red-900 focus:outline-none focus:ring-red-500 focus:border-red-500': form.errors.name, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.name }"
 | 
			
		||||
                    >
 | 
			
		||||
                    <p
 | 
			
		||||
                        v-if="form.errors.name"
 | 
			
		||||
                        class="mt-2 text-sm text-red-600"
 | 
			
		||||
                    >
 | 
			
		||||
                        {{ form.errors.name }}
 | 
			
		||||
                    </p>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="sm:grid sm:grid-cols-3 py-4 items-center">
 | 
			
		||||
                <label
 | 
			
		||||
                    for="date"
 | 
			
		||||
                    class="block text-sm font-medium text-gray-700 sm:mt-px"
 | 
			
		||||
                >
 | 
			
		||||
                    Data
 | 
			
		||||
                </label>
 | 
			
		||||
                <div class="mt-1 sm:mt-0 sm:col-span-2">
 | 
			
		||||
                    <FlatPickr
 | 
			
		||||
                        id="date"
 | 
			
		||||
                        v-model="form.date"
 | 
			
		||||
                        placeholder="Wybierz datę"
 | 
			
		||||
                        class="block w-full max-w-lg shadow-sm rounded-md sm:text-sm"
 | 
			
		||||
                        :class="{ 'border-red-300 text-red-900 focus:outline-none focus:ring-red-500 focus:border-red-500': form.errors.date, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.date }"
 | 
			
		||||
                    />
 | 
			
		||||
                    <p
 | 
			
		||||
                        v-if="form.errors.date"
 | 
			
		||||
                        class="mt-2 text-sm text-red-600"
 | 
			
		||||
                    >
 | 
			
		||||
                        {{ form.errors.date }}
 | 
			
		||||
                    </p>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="flex justify-end py-3">
 | 
			
		||||
                <div class="space-x-3">
 | 
			
		||||
                    <InertiaLink
 | 
			
		||||
                        href="/holidays"
 | 
			
		||||
                        class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
 | 
			
		||||
                    >
 | 
			
		||||
                        Anuluj
 | 
			
		||||
                    </InertiaLink>
 | 
			
		||||
                    <button
 | 
			
		||||
                        type="submit"
 | 
			
		||||
                        :disabled="form.processing"
 | 
			
		||||
                        class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
 | 
			
		||||
                    >
 | 
			
		||||
                        Zapisz
 | 
			
		||||
                    </button>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </form>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { useForm } from '@inertiajs/inertia-vue3';
 | 
			
		||||
import FlatPickr from 'vue-flatpickr-component';
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'HolidayCreate',
 | 
			
		||||
    components: {
 | 
			
		||||
        FlatPickr,
 | 
			
		||||
    },
 | 
			
		||||
    setup() {
 | 
			
		||||
        const form = useForm({
 | 
			
		||||
            name: null,
 | 
			
		||||
            date: new Date(),
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        return { form };
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        createHoliday() {
 | 
			
		||||
            this.form.post('/holidays');
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
							
								
								
									
										112
									
								
								resources/js/Pages/Holidays/Edit.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								resources/js/Pages/Holidays/Edit.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,112 @@
 | 
			
		||||
<template>
 | 
			
		||||
    <InertiaHead title="Edytuj dzień wolny" />
 | 
			
		||||
    <div class="bg-white sm:rounded-lg shadow-md">
 | 
			
		||||
        <div class="p-4 sm:px-6">
 | 
			
		||||
            <h2 class="text-lg leading-6 font-medium text-gray-900">
 | 
			
		||||
                Edytuj dzień wolny
 | 
			
		||||
            </h2>
 | 
			
		||||
            <p class="mt-1 text-sm text-gray-500">
 | 
			
		||||
                Użytkownik nie będzie miał możliwości wzięcia urlopu w dzień wolny.
 | 
			
		||||
            </p>
 | 
			
		||||
        </div>
 | 
			
		||||
        <form
 | 
			
		||||
            class="border-t border-gray-200 px-6"
 | 
			
		||||
            @submit.prevent="editHoliday"
 | 
			
		||||
        >
 | 
			
		||||
            <div class="sm:grid sm:grid-cols-3 py-4 items-center">
 | 
			
		||||
                <label
 | 
			
		||||
                    for="name"
 | 
			
		||||
                    class="block text-sm font-medium text-gray-700 sm:mt-px"
 | 
			
		||||
                >
 | 
			
		||||
                    Nazwa
 | 
			
		||||
                </label>
 | 
			
		||||
                <div class="mt-1 sm:mt-0 sm:col-span-2">
 | 
			
		||||
                    <input
 | 
			
		||||
                        id="name"
 | 
			
		||||
                        v-model="form.name"
 | 
			
		||||
                        type="text"
 | 
			
		||||
                        class="block w-full max-w-lg shadow-sm rounded-md sm:text-sm"
 | 
			
		||||
                        :class="{ 'border-red-300 text-red-900 focus:outline-none focus:ring-red-500 focus:border-red-500': form.errors.name, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.name }"
 | 
			
		||||
                    >
 | 
			
		||||
                    <p
 | 
			
		||||
                        v-if="form.errors.name"
 | 
			
		||||
                        class="mt-2 text-sm text-red-600"
 | 
			
		||||
                    >
 | 
			
		||||
                        {{ form.errors.name }}
 | 
			
		||||
                    </p>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="sm:grid sm:grid-cols-3 py-4 items-center">
 | 
			
		||||
                <label
 | 
			
		||||
                    for="date"
 | 
			
		||||
                    class="block text-sm font-medium text-gray-700 sm:mt-px"
 | 
			
		||||
                >
 | 
			
		||||
                    Data
 | 
			
		||||
                </label>
 | 
			
		||||
                <div class="mt-1 sm:mt-0 sm:col-span-2">
 | 
			
		||||
                    <FlatPickr
 | 
			
		||||
                        id="date"
 | 
			
		||||
                        v-model="form.date"
 | 
			
		||||
                        placeholder="Wybierz datę"
 | 
			
		||||
                        class="block w-full max-w-lg shadow-sm rounded-md sm:text-sm"
 | 
			
		||||
                        :class="{ 'border-red-300 text-red-900 focus:outline-none focus:ring-red-500 focus:border-red-500': form.errors.date, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.date }"
 | 
			
		||||
                    />
 | 
			
		||||
                    <p
 | 
			
		||||
                        v-if="form.errors.date"
 | 
			
		||||
                        class="mt-2 text-sm text-red-600"
 | 
			
		||||
                    >
 | 
			
		||||
                        {{ form.errors.date }}
 | 
			
		||||
                    </p>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="flex justify-end py-3">
 | 
			
		||||
                <div class="space-x-3">
 | 
			
		||||
                    <InertiaLink
 | 
			
		||||
                        href="/holidays"
 | 
			
		||||
                        class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
 | 
			
		||||
                    >
 | 
			
		||||
                        Anuluj
 | 
			
		||||
                    </InertiaLink>
 | 
			
		||||
                    <button
 | 
			
		||||
                        type="submit"
 | 
			
		||||
                        :disabled="form.processing"
 | 
			
		||||
                        class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
 | 
			
		||||
                    >
 | 
			
		||||
                        Zapisz
 | 
			
		||||
                    </button>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </form>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { useForm } from '@inertiajs/inertia-vue3';
 | 
			
		||||
import FlatPickr from 'vue-flatpickr-component';
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'HolidayCreate',
 | 
			
		||||
    components: {
 | 
			
		||||
        FlatPickr,
 | 
			
		||||
    },
 | 
			
		||||
    props: {
 | 
			
		||||
        holiday: {
 | 
			
		||||
            type: Object,
 | 
			
		||||
            default: () => null,
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    setup(props) {
 | 
			
		||||
        const form = useForm({
 | 
			
		||||
            name: props.holiday.name,
 | 
			
		||||
            date: new Date(props.holiday.date),
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        return { form };
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        editHoliday() {
 | 
			
		||||
            this.form.put(`/holidays/${this.holiday.id}`);
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
							
								
								
									
										167
									
								
								resources/js/Pages/Holidays/Index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										167
									
								
								resources/js/Pages/Holidays/Index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,167 @@
 | 
			
		||||
<template>
 | 
			
		||||
    <InertiaHead title="Dni wolne od pracy" />
 | 
			
		||||
    <div class="bg-white sm:rounded-lg shadow-md">
 | 
			
		||||
        <div class="flex justify-between items-center p-4 sm:px-6">
 | 
			
		||||
            <div>
 | 
			
		||||
                <h2 class="text-lg leading-6 font-medium text-gray-900">
 | 
			
		||||
                    Dni wolne od pracy
 | 
			
		||||
                </h2>
 | 
			
		||||
                <p class="mt-1 text-sm text-gray-500">
 | 
			
		||||
                    Lista dni wolnych od pracy w danym roku
 | 
			
		||||
                </p>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div>
 | 
			
		||||
                <InertiaLink
 | 
			
		||||
                    href="holidays/create"
 | 
			
		||||
                    class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
 | 
			
		||||
                >
 | 
			
		||||
                    Dodaj dzień wolny
 | 
			
		||||
                </InertiaLink>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="border-t border-gray-200">
 | 
			
		||||
            <div class="overflow-x-auto xl:overflow-x-visible overflow-y-auto xl:overflow-y-visible">
 | 
			
		||||
                <table class="min-w-full divide-y divide-gray-200">
 | 
			
		||||
                    <thead class="bg-gray-100">
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <th
 | 
			
		||||
                                scope="col"
 | 
			
		||||
                                class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
 | 
			
		||||
                            >
 | 
			
		||||
                                Nazwa
 | 
			
		||||
                            </th>
 | 
			
		||||
                            <th
 | 
			
		||||
                                scope="col"
 | 
			
		||||
                                class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
 | 
			
		||||
                            >
 | 
			
		||||
                                Data
 | 
			
		||||
                            </th>
 | 
			
		||||
                            <th
 | 
			
		||||
                                scope="col"
 | 
			
		||||
                                class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
 | 
			
		||||
                            >
 | 
			
		||||
                                Dzień tygodnia
 | 
			
		||||
                            </th>
 | 
			
		||||
                            <th
 | 
			
		||||
                                scope="col"
 | 
			
		||||
                                class="px-6 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
 | 
			
		||||
                            />
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    </thead>
 | 
			
		||||
                    <tbody class="bg-white divide-y divide-gray-100">
 | 
			
		||||
                        <tr
 | 
			
		||||
                            v-for="holiday in holidays.data"
 | 
			
		||||
                            :key="holiday.id"
 | 
			
		||||
                            class="hover:bg-blumilk-25"
 | 
			
		||||
                        >
 | 
			
		||||
                            <td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500 font-semibold capitalize">
 | 
			
		||||
                                {{ holiday.name }}
 | 
			
		||||
                            </td>
 | 
			
		||||
                            <td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
 | 
			
		||||
                                {{ holiday.displayDate }}
 | 
			
		||||
                            </td>
 | 
			
		||||
                            <td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
 | 
			
		||||
                                {{ holiday.dayOfWeek }}
 | 
			
		||||
                            </td>
 | 
			
		||||
                            <td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500 text-right">
 | 
			
		||||
                                <Menu
 | 
			
		||||
                                    as="div"
 | 
			
		||||
                                    class="relative inline-block text-left"
 | 
			
		||||
                                >
 | 
			
		||||
                                    <MenuButton class="rounded-full flex items-center text-gray-400 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-blumilk-500">
 | 
			
		||||
                                        <DotsVerticalIcon
 | 
			
		||||
                                            class="h-5 w-5"
 | 
			
		||||
                                            aria-hidden="true"
 | 
			
		||||
                                        />
 | 
			
		||||
                                    </MenuButton>
 | 
			
		||||
 | 
			
		||||
                                    <transition
 | 
			
		||||
                                        enter-active-class="transition ease-out duration-100"
 | 
			
		||||
                                        enter-from-class="transform opacity-0 scale-95"
 | 
			
		||||
                                        enter-to-class="transform opacity-100 scale-100"
 | 
			
		||||
                                        leave-active-class="transition ease-in duration-75"
 | 
			
		||||
                                        leave-from-class="transform opacity-100 scale-100"
 | 
			
		||||
                                        leave-to-class="transform opacity-0 scale-95"
 | 
			
		||||
                                    >
 | 
			
		||||
                                        <MenuItems class="origin-top-right absolute right-0 mt-2 w-56 z-10 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none">
 | 
			
		||||
                                            <div class="py-1">
 | 
			
		||||
                                                <MenuItem
 | 
			
		||||
                                                    v-slot="{ active }"
 | 
			
		||||
                                                    class="flex"
 | 
			
		||||
                                                >
 | 
			
		||||
                                                    <InertiaLink
 | 
			
		||||
                                                        :href="`/holidays/${holiday.id}/edit`"
 | 
			
		||||
                                                        :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'font-medium block px-4 py-2 text-sm']"
 | 
			
		||||
                                                    >
 | 
			
		||||
                                                        <PencilIcon
 | 
			
		||||
                                                            class="mr-2 h-5 w-5 text-blue-500"
 | 
			
		||||
                                                            aria-hidden="true"
 | 
			
		||||
                                                        /> Edytuj
 | 
			
		||||
                                                    </InertiaLink>
 | 
			
		||||
                                                </MenuItem>
 | 
			
		||||
                                                <MenuItem
 | 
			
		||||
                                                    v-slot="{ active }"
 | 
			
		||||
                                                    class="flex"
 | 
			
		||||
                                                >
 | 
			
		||||
                                                    <InertiaLink
 | 
			
		||||
                                                        as="button"
 | 
			
		||||
                                                        method="delete"
 | 
			
		||||
                                                        :preserve-scroll="true"
 | 
			
		||||
                                                        :href="`/holidays/${holiday.id}`"
 | 
			
		||||
                                                        :class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'block w-full text-left font-medium px-4 py-2 text-sm']"
 | 
			
		||||
                                                    >
 | 
			
		||||
                                                        <TrashIcon
 | 
			
		||||
                                                            class="mr-2 h-5 w-5 text-red-500"
 | 
			
		||||
                                                            aria-hidden="true"
 | 
			
		||||
                                                        /> Usuń
 | 
			
		||||
                                                    </InertiaLink>
 | 
			
		||||
                                                </MenuItem>
 | 
			
		||||
                                            </div>
 | 
			
		||||
                                        </MenuItems>
 | 
			
		||||
                                    </transition>
 | 
			
		||||
                                </Menu>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr
 | 
			
		||||
                            v-if="!holidays.data.length"
 | 
			
		||||
                        >
 | 
			
		||||
                            <td
 | 
			
		||||
                                colspan="100%"
 | 
			
		||||
                                class="text-center py-4 text-xl leading-5 text-gray-700"
 | 
			
		||||
                            >
 | 
			
		||||
                                Brak danych
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    </tbody>
 | 
			
		||||
                </table>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { DotsVerticalIcon, PencilIcon, TrashIcon } from '@heroicons/vue/solid';
 | 
			
		||||
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue';
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'HolidayINdex',
 | 
			
		||||
    components: {
 | 
			
		||||
        DotsVerticalIcon,
 | 
			
		||||
        PencilIcon,
 | 
			
		||||
        TrashIcon,
 | 
			
		||||
        Menu,
 | 
			
		||||
        MenuButton,
 | 
			
		||||
        MenuItem,
 | 
			
		||||
        MenuItems,
 | 
			
		||||
    },
 | 
			
		||||
    props: {
 | 
			
		||||
        holidays: {
 | 
			
		||||
            type: Object,
 | 
			
		||||
            default: () => null,
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    setup() {
 | 
			
		||||
        return {};
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
		Reference in New Issue
	
	Block a user