- add notes
This commit is contained in:
37
resources/js/Pages/Notes/ConfirmDelete.vue
Normal file
37
resources/js/Pages/Notes/ConfirmDelete.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<script setup>
|
||||
import { router } from '@inertiajs/vue3';
|
||||
|
||||
const props = defineProps({
|
||||
note: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
function confirmDelete() {
|
||||
router.delete(`/dashboard/note/${props.note.id}/delete`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<InertiaHead title="Usuwanie notatki" />
|
||||
<div class="p-4">
|
||||
<header class="pb-4">
|
||||
<h1 class="text-3xl font-roboto font-light">Usuwanie notatki</h1>
|
||||
</header>
|
||||
<div class="max-w-[600px]">
|
||||
<p class="mb-4">Na pewno usunąć notatkę {{ note.title }}?</p>
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
:href="`/dashboard/note/${note.id}`"
|
||||
class="col-span-1 flex justify-center items-center gap-3 w-full px-2 py-1 border-t-4 border-b-4 border-transparent hover:border-b-black"
|
||||
><FontAwesomeIcon :icon="['fas', 'backward']" />Anuluj</InertiaLink>
|
||||
<button
|
||||
@click.prevent="confirmDelete"
|
||||
class="col-span-2 flex justify-center items-center gap-3 w-full px-2 py-1 rounded-md bg-red-600 border-4 border-red-600 text-white text-lg hover:bg-transparent hover:text-red-600"
|
||||
><FontAwesomeIcon :icon="['fas', 'trash']" /><span class="whitespace-nowrap overflow-hidden overflow-ellipsis">Usuń notatkę {{ note.title }}</span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
49
resources/js/Pages/Notes/Create.vue
Normal file
49
resources/js/Pages/Notes/Create.vue
Normal file
@@ -0,0 +1,49 @@
|
||||
<script setup>
|
||||
import { useForm } from '@inertiajs/inertia-vue3';
|
||||
import Input from '../../Share/Components/Input.vue';
|
||||
|
||||
const form = useForm({
|
||||
title: null,
|
||||
note: null,
|
||||
});
|
||||
|
||||
function createNote() {
|
||||
form.post('/dashboard/note');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<InertiaHead title="Nowe dane do CV" />
|
||||
<div class="p-4">
|
||||
<header class="pb-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
href="/dashboard/note"
|
||||
class="px-2 text-xl text-gray-700 hover:text-black"
|
||||
title="Wróć do listy notatek"><FontAwesomeIcon :icon="['fas', 'caret-left']" /></InertiaLink>
|
||||
<h1 class="text-3xl font-roboto font-light">Nowe dane do CV</h1>
|
||||
</div>
|
||||
</header>
|
||||
<div>
|
||||
<form class="flex flex-col gap-4" @submit.prevent="createNote">
|
||||
<Input
|
||||
id="title"
|
||||
label="Tytuł notatki"
|
||||
placeholder="np. Witaj świecie!"
|
||||
v-model="form.title"
|
||||
:error="form.errors.title"
|
||||
/>
|
||||
<Input
|
||||
id="note"
|
||||
type="textarea"
|
||||
label="Treść notatki"
|
||||
placeholder="Treść"
|
||||
v-model="form.note"
|
||||
:error="form.errors.note"
|
||||
/>
|
||||
<button class="px-0.5 py-1 rounded-lg bg-[#436da7] border-4 border-[#436da7] text-white text-lg hover:bg-transparent hover:text-[#436da7]">Utwórz notatkę</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
69
resources/js/Pages/Notes/Edit.vue
Normal file
69
resources/js/Pages/Notes/Edit.vue
Normal file
@@ -0,0 +1,69 @@
|
||||
<script setup>
|
||||
import { useForm } from '@inertiajs/inertia-vue3';
|
||||
import Input from '../../Share/Components/Input.vue';
|
||||
|
||||
const props = defineProps({
|
||||
note: {
|
||||
type: Object,
|
||||
required: true,
|
||||
}
|
||||
});
|
||||
|
||||
const form = useForm({
|
||||
title: props.note.title,
|
||||
note: props.note.note,
|
||||
});
|
||||
|
||||
function updateNote() {
|
||||
form.put(`/dashboard/note/${props.note.id}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<InertiaHead title="Edycja notatki" />
|
||||
<div class="p-4">
|
||||
<header class="flex items-center justify-between pb-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
:href="`/dashboard/note/${note.id}`"
|
||||
class="px-2 text-xl text-gray-700 hover:text-black"
|
||||
title="Wróć do listy notatek"><FontAwesomeIcon :icon="['fas', 'caret-left']" /></InertiaLink>
|
||||
<h1 class="text-3xl font-roboto font-light">Edycja notatki</h1>
|
||||
</div>
|
||||
<InertiaLink
|
||||
as="button"
|
||||
:href="`/dashboard/note/${note.id}/delete`"
|
||||
class="flex items-center gap-2 px-2 py-1 text-red-600 hover:text-white hover:bg-red-600 rounded-md"
|
||||
title="Usuń notatkę"
|
||||
><FontAwesomeIcon :icon="['fas', 'trash']" />Usuń</InertiaLink>
|
||||
</header>
|
||||
<div>
|
||||
<form class="flex flex-col gap-4" @submit.prevent="updateNote">
|
||||
<Input
|
||||
id="title"
|
||||
label="Tytuł notatki"
|
||||
placeholder="np. Witaj świecie!"
|
||||
v-model="form.title"
|
||||
:error="form.errors.title"
|
||||
/>
|
||||
<Input
|
||||
id="note"
|
||||
type="textarea"
|
||||
label="Treść notatki"
|
||||
placeholder="Treść"
|
||||
v-model="form.note"
|
||||
:error="form.errors.note"
|
||||
/>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3 sm:gap-2 items-center">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
:href="`/dashboard/note/${note.id}`"
|
||||
class="col-span-1 flex justify-center items-center gap-3 w-full px-2 py-1 border-t-4 border-b-4 border-transparent hover:border-b-black"
|
||||
><FontAwesomeIcon :icon="['fas', 'backward']" />Anuluj</InertiaLink>
|
||||
<button class="col-span-1 md:col-span-2 px-0.5 py-1 rounded-lg bg-[#436da7] border-4 border-[#436da7] text-white text-lg hover:bg-transparent hover:text-[#436da7]">Edytuj notatkę</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
57
resources/js/Pages/Notes/Index.vue
Normal file
57
resources/js/Pages/Notes/Index.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
<script setup>
|
||||
import EmptyState from '@/Share/Components/EmptyState.vue';
|
||||
|
||||
defineProps({
|
||||
notes: {
|
||||
type: Object,
|
||||
required: true,
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<InertiaHead title="Lista notatek" />
|
||||
<div class="p-4">
|
||||
<header class="flex justify-between items-center pb-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
href="/dashboard"
|
||||
class="px-2 text-xl text-gray-700 hover:text-black"
|
||||
title="Wróc do dashboard"><FontAwesomeIcon :icon="['fas', 'caret-left']" /></InertiaLink>
|
||||
<h1 class="text-3xl font-roboto font-light">Lista notatek</h1>
|
||||
</div>
|
||||
<InertiaLink
|
||||
as="button"
|
||||
href="/dashboard/note/create"
|
||||
class="bg-blue-400 hover:bg-blue-500 text-white px-2.5 py-1 rounded-full"
|
||||
title="Dodaj nowe dane dla CV"
|
||||
><FontAwesomeIcon :icon="['fas', 'plus']" /></InertiaLink>
|
||||
</header>
|
||||
<ul v-if="notes.data.length" class="flex flex-col gap-2">
|
||||
<li
|
||||
v-for="(note, key) in notes.data"
|
||||
:key="key"
|
||||
class="flex items-center justify-between px-3 py-2 bg-white hover:bg-neutral-200"
|
||||
>
|
||||
<InertiaLink :href="`/dashboard/note/${note.id}`">{{ note.title }}</InertiaLink>
|
||||
<div class="flex items-center gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
class="px-2 py-1 text-lime-600 hover:text-lime-800 border-t-2 border-b-2 border-transparent hover:border-b-lime-600"
|
||||
:href="`/dashboard/note/${note.id}`"
|
||||
title="Edytuj notatkę"><FontAwesomeIcon :icon="['fas', 'pen-to-square']" /></InertiaLink>
|
||||
<InertiaLink
|
||||
as="button"
|
||||
class="px-2 py-1 text-red-600 hover:text-red-800"
|
||||
:href="`/dashboard/note/${note.id}/delete`"
|
||||
title="Usuń notatkę z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<EmptyState v-else>
|
||||
<template #title>Nie znaleziono notatek</template>
|
||||
<template #text>Nie dodano jeszcze notatek do listy.</template>
|
||||
</EmptyState>
|
||||
</div>
|
||||
</template>
|
64
resources/js/Pages/Notes/Show.vue
Normal file
64
resources/js/Pages/Notes/Show.vue
Normal file
@@ -0,0 +1,64 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
note: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const noteLines = computed(() => props.note.note.split("\n"));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<InertiaHead title="Szczegóły notatki" />
|
||||
<div class="p-4">
|
||||
<header class="flex justify-between items-center pb-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
href="/dashboard/note"
|
||||
class="px-2 text-xl text-gray-700 hover:text-black"
|
||||
title="Wróć do listy notatek"><FontAwesomeIcon :icon="['fas', 'caret-left']" /></InertiaLink>
|
||||
<h1 class="text-3xl font-roboto font-light">Szczegóły notatki</h1>
|
||||
</div>
|
||||
<div class="flex gap-3 sm:gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
:href="`/dashboard/note/${note.id}/edit`"
|
||||
class="flex items-center gap-2 px-2 py-1 text-lime-600 hover:text-white hover:bg-lime-600 rounded-md"
|
||||
title="Edytuj notatkę"
|
||||
><FontAwesomeIcon :icon="['fas', 'pen-to-square']" /><span class="hidden sm:inline-block">Edytuj</span></InertiaLink>
|
||||
<InertiaLink
|
||||
as="button"
|
||||
:href="`/dashboard/note/${note.id}/delete`"
|
||||
class="flex items-center gap-2 px-2 py-1 text-red-600 hover:text-white hover:bg-red-600 rounded-md"
|
||||
title="Usuń notatkę"
|
||||
><FontAwesomeIcon :icon="['fas', 'trash']" /><span class="hidden sm:inline-block">Usuń</span></InertiaLink>
|
||||
</div>
|
||||
</header>
|
||||
<div class="mb-4">
|
||||
<header>
|
||||
<h2 class="text-2xl font-roboto font-light pb-3">Podstawowe informacje</h2>
|
||||
</header>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div>
|
||||
<div class="text-gray-500 pb-0.5">Tytuł</div>
|
||||
<p
|
||||
class="w-full min-w-full max-w-full px-2.5 py-2 border-b-2 rounded-md bg-white whitespace-nowrap overflow-hidden overflow-ellipsis"
|
||||
>{{ note.title }}</p>
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<div class="text-gray-500 pb-0.5">Notatka</div>
|
||||
<div class="w-full min-w-full max-w-full px-2.5 py-2 border-b-2 rounded-md bg-white">
|
||||
<p
|
||||
v-for="(noteLine, key) in noteLines"
|
||||
:key="key"
|
||||
>{{ noteLine }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
Reference in New Issue
Block a user