diff --git a/app/Domains/Vault/ManageJournals/Services/DestroyJournal.php b/app/Domains/Vault/ManageJournals/Services/DestroyJournal.php index 054af224c79..adf76e695f3 100644 --- a/app/Domains/Vault/ManageJournals/Services/DestroyJournal.php +++ b/app/Domains/Vault/ManageJournals/Services/DestroyJournal.php @@ -37,9 +37,6 @@ public function permissions(): array ]; } - /** - * Delete a journal. - */ public function execute(array $data): void { $this->data = $data; diff --git a/app/Domains/Vault/ManageJournals/Web/Controllers/JournalController.php b/app/Domains/Vault/ManageJournals/Web/Controllers/JournalController.php index fa8e46c27ee..afcf116f915 100644 --- a/app/Domains/Vault/ManageJournals/Web/Controllers/JournalController.php +++ b/app/Domains/Vault/ManageJournals/Web/Controllers/JournalController.php @@ -3,7 +3,10 @@ namespace App\Domains\Vault\ManageJournals\Web\Controllers; use App\Domains\Vault\ManageJournals\Services\CreateJournal; +use App\Domains\Vault\ManageJournals\Services\DestroyJournal; +use App\Domains\Vault\ManageJournals\Services\UpdateJournal; use App\Domains\Vault\ManageJournals\Web\ViewHelpers\JournalCreateViewHelper; +use App\Domains\Vault\ManageJournals\Web\ViewHelpers\JournalEditViewHelper; use App\Domains\Vault\ManageJournals\Web\ViewHelpers\JournalIndexViewHelper; use App\Domains\Vault\ManageJournals\Web\ViewHelpers\JournalShowViewHelper; use App\Domains\Vault\ManageVault\Web\ViewHelpers\VaultIndexViewHelper; @@ -77,4 +80,50 @@ public function year(Request $request, int $vaultId, int $journalId, int $year) 'data' => JournalShowViewHelper::data($journal, $year, Auth::user()), ]); } + + public function edit(Request $request, int $vaultId, int $journalId) + { + $vault = Vault::findOrFail($vaultId); + $journal = Journal::findOrFail($journalId); + + return Inertia::render('Vault/Journal/Edit', [ + 'layoutData' => VaultIndexViewHelper::layoutData($vault), + 'data' => JournalEditViewHelper::data($vault, $journal), + ]); + } + + public function update(Request $request, int $vaultId, int $journalId) + { + $data = [ + 'account_id' => Auth::user()->account_id, + 'author_id' => Auth::id(), + 'vault_id' => $vaultId, + 'journal_id' => $journalId, + 'name' => $request->input('name'), + 'description' => $request->input('description'), + ]; + + $journal = (new UpdateJournal())->execute($data); + + return Redirect::route('journal.show', [ + 'vault' => $vaultId, + 'journal' => $journal, + ]); + } + + public function destroy(Request $request, int $vaultId, int $journalId) + { + $data = [ + 'account_id' => Auth::user()->account_id, + 'author_id' => Auth::id(), + 'vault_id' => $vaultId, + 'journal_id' => $journalId, + ]; + + (new DestroyJournal())->execute($data); + + return Redirect::route('journal.index', [ + 'vault' => $vaultId, + ]); + } } diff --git a/app/Domains/Vault/ManageJournals/Web/ViewHelpers/JournalEditViewHelper.php b/app/Domains/Vault/ManageJournals/Web/ViewHelpers/JournalEditViewHelper.php new file mode 100644 index 00000000000..0565b43b0a3 --- /dev/null +++ b/app/Domains/Vault/ManageJournals/Web/ViewHelpers/JournalEditViewHelper.php @@ -0,0 +1,28 @@ + $journal->id, + 'name' => $journal->name, + 'description' => $journal->description, + 'url' => [ + 'update' => route('journal.update', [ + 'vault' => $vault->id, + 'journal' => $journal->id, + ]), + 'back' => route('journal.show', [ + 'vault' => $vault->id, + 'journal' => $journal->id, + ]), + ], + ]; + } +} diff --git a/app/Domains/Vault/ManageJournals/Web/ViewHelpers/JournalShowViewHelper.php b/app/Domains/Vault/ManageJournals/Web/ViewHelpers/JournalShowViewHelper.php index 382d4cb89c8..d91a657c209 100644 --- a/app/Domains/Vault/ManageJournals/Web/ViewHelpers/JournalShowViewHelper.php +++ b/app/Domains/Vault/ManageJournals/Web/ViewHelpers/JournalShowViewHelper.php @@ -30,6 +30,14 @@ public static function data(Journal $journal, int $year, User $user): array 'tags' => self::tags($journal), 'slices' => self::slices($journal), 'url' => [ + 'edit' => route('journal.edit', [ + 'vault' => $journal->vault_id, + 'journal' => $journal->id, + ]), + 'destroy' => route('journal.destroy', [ + 'vault' => $journal->vault_id, + 'journal' => $journal->id, + ]), 'create' => route('post.create', [ 'vault' => $journal->vault_id, 'journal' => $journal->id, diff --git a/lang/en/vault.php b/lang/en/vault.php index 33c861a0f94..3f55b4c0a8d 100644 --- a/lang/en/vault.php +++ b/lang/en/vault.php @@ -119,7 +119,6 @@ 'journal_show_years' => 'Years', 'journal_show_tags' => 'All tags', 'journal_show_contacts' => 'Contacts in this post', - 'journal_show_options' => 'Options', 'journal_show_blank' => 'The journal lets you document your life with your own words.', 'journal_post_edit_tags' => 'Tags', 'journal_show_mood' => 'Your mood that you logged at this date', diff --git a/public/img/journal_blank_index.svg b/public/img/journal_blank_index.svg new file mode 100644 index 00000000000..d17d98f3953 --- /dev/null +++ b/public/img/journal_blank_index.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/js/Pages/Vault/Journal/Create.vue b/resources/js/Pages/Vault/Journal/Create.vue index 95c3d7d36e4..1cd23aa0e56 100644 --- a/resources/js/Pages/Vault/Journal/Create.vue +++ b/resources/js/Pages/Vault/Journal/Create.vue @@ -6,6 +6,7 @@ import PrettyButton from '@/Shared/Form/PrettyButton.vue'; import TextInput from '@/Shared/Form/TextInput.vue'; import TextArea from '@/Shared/Form/TextArea.vue'; import Errors from '@/Shared/Form/Errors.vue'; +import { onMounted, nextTick, ref } from 'vue'; const props = defineProps({ layoutData: Object, @@ -17,6 +18,14 @@ const form = useForm({ description: '', }); +const nameField = ref(null); + +onMounted(() => { + nextTick(() => { + nameField.value.focus(); + }); +}); + const submit = () => { form.post(props.data.url.store, { onFinish: () => {}, @@ -72,6 +81,7 @@ const submit = () => { {
- +
diff --git a/resources/js/Pages/Vault/Journal/Edit.vue b/resources/js/Pages/Vault/Journal/Edit.vue new file mode 100644 index 00000000000..ff337f2fb10 --- /dev/null +++ b/resources/js/Pages/Vault/Journal/Edit.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/resources/js/Pages/Vault/Journal/Post/Show.vue b/resources/js/Pages/Vault/Journal/Post/Show.vue index 1531d6f0ea7..3d47add407a 100644 --- a/resources/js/Pages/Vault/Journal/Post/Show.vue +++ b/resources/js/Pages/Vault/Journal/Post/Show.vue @@ -192,7 +192,6 @@ defineProps({ -

{{ $t('vault.journal_show_options') }}