diff --git a/app/Http/Controllers/JournalController.php b/app/Http/Controllers/JournalController.php index ccd03e930eb..dbf92389e50 100644 --- a/app/Http/Controllers/JournalController.php +++ b/app/Http/Controllers/JournalController.php @@ -188,6 +188,24 @@ public function edit(Entry $entry) return view('journal.edit') ->withEntry($entry); } + + /** + * Method updateDay + * + * @param Request $request + * @param Day $day + * + */ + public function updateDay(Request $request, Day $day) + { + $validatedData = $request->validate([ + 'comment' => 'required|string', + ]); + + $day->update($validatedData); + + return response()->json(['message' => 'Day updated successfully']); + } /** * Update a journal entry. diff --git a/resources/js/components/journal/partials/JournalContentRate.vue b/resources/js/components/journal/partials/JournalContentRate.vue index 74631551103..0d5a6e79211 100644 --- a/resources/js/components/journal/partials/JournalContentRate.vue +++ b/resources/js/components/journal/partials/JournalContentRate.vue @@ -19,8 +19,24 @@ +
+ +
+
+ +
+
+
+
-

+

{{ day.comment }}

@@ -95,6 +111,11 @@

  • {{ $t('journal.journal_entry_rate') }}
  • +
  • + + {{ $t('app.edit') }} + +
  • {{ $t('app.delete') }} @@ -121,6 +142,8 @@ export default { data() { return { day: [], + isEditingComment: false, + }; }, @@ -138,6 +161,17 @@ export default { prepareComponent() { this.day = this.journalEntry.object; }, + editingComment() { + this.isEditingComment = !this.isEditingComment; + }, + saveComment() { + axios.put('journal/day/' + this.day.id + '/update', { + comment: this.day.comment, + }) + .then(response => { + this.editingComment(); + }); + }, destroy() { axios.delete('journal/day/' + this.day.id) diff --git a/routes/web.php b/routes/web.php index cc8c4ee4984..487727a4697 100644 --- a/routes/web.php +++ b/routes/web.php @@ -209,6 +209,7 @@ Route::get('/journal/hasRated', 'JournalController@hasRated'); Route::post('/journal/day', 'JournalController@storeDay'); Route::delete('/journal/day/{day}', 'JournalController@trashDay'); + Route::put('/journal/day/{day}/update', 'JournalController@updateDay'); Route::get('/journal/add', 'JournalController@create')->name('create'); Route::post('/journal/create', 'JournalController@save')->name('save');