Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: edit Option For Daily Journal #6759

Merged
merged 8 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/Http/Controllers/JournalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
asbiin marked this conversation as resolved.
Show resolved Hide resolved
'comment' => 'required|string',
]);

$day->update($validatedData);

return response()->json(['message' => 'Day updated successfully']);
}

/**
* Update a journal entry.
Expand Down
36 changes: 35 additions & 1 deletion resources/js/components/journal/partials/JournalContentRate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,24 @@
</div>

<!-- Log content -->
<div v-if="isEditingComment" class="pt2 w-100 pr-4">
<form-textarea
:id="'comment'"
v-model="day.comment"
:required="false"
:rows="4"
/>
<div class="pv3">
<div class="flex-ns justify-between">
<button v-cy-name="'save-entry-button'" class="btn btn-primary w-auto-ns w-100 mb2 pb0-ns" @click="saveComment()">
{{ $t('app.save') }}
</button>
</div>
</div>
</div>

<div class="flex-auto flex items-center">
<p v-if="day.comment" class="mb2">
<p v-if="!isEditingComment && day.comment" class="mb2">
{{ day.comment }}
</p>
<p v-if="!day.comment" class="mb2">
Expand Down Expand Up @@ -95,6 +111,11 @@
<li class="di">
{{ $t('journal.journal_entry_rate') }}
</li>
<li class="di">
<a v-cy-name="'entry-edit-button-' + journalEntry.id" class="pointer" :href="'journal/day/' + journalEntry.id + '/edit'" @click.prevent="editingComment">
{{ $t('app.edit') }}
</a>
</li>
<li class="di">
<a v-cy-name="'entry-delete-button-' + journalEntry.id" class="pointer" href="" @click.prevent="destroy()">
{{ $t('app.delete') }}
Expand All @@ -121,6 +142,8 @@ export default {
data() {
return {
day: [],
isEditingComment: false,

};
},

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down