Skip to content

Commit

Permalink
update tag text after a task has been updated
Browse files Browse the repository at this point in the history
  • Loading branch information
reykjalin committed Oct 24, 2024
1 parent 5326df3 commit be16dc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 9 additions & 3 deletions resources/js/src/entrypoints/Tasks.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { flip } from 'svelte/animate';
import { fade } from 'svelte/transition';
import {
getTasks,
getTags,
Expand Down Expand Up @@ -124,14 +123,21 @@
}
try {
await updateTask(
selectedTask = await updateTask(
selectedTask,
{
description: selectedTaskDescription,
details: selectedTaskDetails,
},
selectedTaskTags.split(', '),
selectedTaskTags
.split(',')
.map((t) => t.trim())
.filter((t) => t !== ''),
);
// The description and details should already be up-to-date, but we might
// have to refresh the tags.
selectedTaskTags = selectedTask.tags?.map((t) => t.name).join(', ') ?? '';
} catch (e) {
console.error(e);
} finally {
Expand Down
5 changes: 4 additions & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@
$task->tags()->save( $tag );
}

return $task;
return Task::with('tags')
->where('user_id', $request->user()->id)
->where('id', $task->id)
->first();
})->middleware('auth:sanctum');

Route::patch('/tasks/move/{id}', function (Request $request, string $id) {
Expand Down

0 comments on commit be16dc0

Please sign in to comment.