diff --git a/app/Models/ContactTask.php b/app/Models/ContactTask.php index 54bf4f4d8..a60338852 100644 --- a/app/Models/ContactTask.php +++ b/app/Models/ContactTask.php @@ -25,6 +25,7 @@ class ContactTask extends Model 'description', 'completed', 'completed_at', + 'due_at', ]; /** @@ -43,6 +44,7 @@ class ContactTask extends Model */ protected $dates = [ 'completed_at', + 'due_at', ]; /** diff --git a/database/factories/ContactTaskFactory.php b/database/factories/ContactTaskFactory.php index 8a9ab02d2..6d74a8e88 100644 --- a/database/factories/ContactTaskFactory.php +++ b/database/factories/ContactTaskFactory.php @@ -29,6 +29,7 @@ class ContactTaskFactory extends Factory 'author_name' => $this->faker->name, 'label' => $this->faker->sentence(), 'completed' => false, + 'due_at' => $this->faker->dateTimeThisCentury(), ]; } } diff --git a/database/migrations/2022_05_13_201216_create_contact_tasks_table.php b/database/migrations/2022_05_13_201216_create_contact_tasks_table.php index 5aa1e9d47..2b4b24515 100644 --- a/database/migrations/2022_05_13_201216_create_contact_tasks_table.php +++ b/database/migrations/2022_05_13_201216_create_contact_tasks_table.php @@ -22,6 +22,7 @@ return new class() extends Migration $table->text('description')->nullable(); $table->boolean('completed')->default(false); $table->datetime('completed_at')->nullable(); + $table->datetime('due_at')->nullable(); $table->timestamps(); $table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade'); $table->foreign('author_id')->references('id')->on('users')->onDelete('set null'); diff --git a/domains/Contact/ManageTasks/Services/CreateContactTask.php b/domains/Contact/ManageTasks/Services/CreateContactTask.php index 041562d3f..6d4beec43 100644 --- a/domains/Contact/ManageTasks/Services/CreateContactTask.php +++ b/domains/Contact/ManageTasks/Services/CreateContactTask.php @@ -27,7 +27,7 @@ class CreateContactTask extends BaseService implements ServiceInterface 'contact_id' => 'required|integer|exists:contacts,id', 'label' => 'required|string|max:255', 'description' => 'nullable|string|max:65535', - + 'due_at' => 'nullable|date_format:Y-m-d', ]; } @@ -71,6 +71,7 @@ class CreateContactTask extends BaseService implements ServiceInterface 'author_name' => $this->author->name, 'label' => $this->data['label'], 'description' => $this->valueOrNull($this->data, 'description'), + 'due_at' => $this->valueOrNull($this->data, 'due_at'), ]); } diff --git a/domains/Contact/ManageTasks/Services/UpdateContactTask.php b/domains/Contact/ManageTasks/Services/UpdateContactTask.php index c84faf24b..28c41036e 100644 --- a/domains/Contact/ManageTasks/Services/UpdateContactTask.php +++ b/domains/Contact/ManageTasks/Services/UpdateContactTask.php @@ -26,6 +26,7 @@ class UpdateContactTask extends BaseService implements ServiceInterface 'contact_task_id' => 'required|integer|exists:contact_tasks,id', 'label' => 'required|string|max:255', 'description' => 'nullable|string|max:65535', + 'due_at' => 'nullable|date', ]; } @@ -59,6 +60,7 @@ class UpdateContactTask extends BaseService implements ServiceInterface $this->task->label = $data['label']; $this->task->description = $this->valueOrNull($data, 'description'); + $this->task->due_at = $this->valueOrNull($data, 'due_at'); $this->task->save(); $this->contact->last_updated_at = Carbon::now(); diff --git a/domains/Contact/ManageTasks/Web/Controllers/ContactModuleTaskController.php b/domains/Contact/ManageTasks/Web/Controllers/ContactModuleTaskController.php index eb6108e98..e24b43037 100644 --- a/domains/Contact/ManageTasks/Web/Controllers/ContactModuleTaskController.php +++ b/domains/Contact/ManageTasks/Web/Controllers/ContactModuleTaskController.php @@ -9,6 +9,7 @@ use App\Contact\ManageTasks\Services\UpdateContactTask; use App\Contact\ManageTasks\Web\ViewHelpers\ModuleContactTasksViewHelper; use App\Http\Controllers\Controller; use App\Models\Contact; +use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -25,6 +26,11 @@ class ContactModuleTaskController extends Controller public function store(Request $request, int $vaultId, int $contactId) { + $dueAt = ''; + if ($request->input('due_at')) { + $dueAt = Carbon::parse($request->input('due_at'))->format('Y-m-d'); + } + $data = [ 'account_id' => Auth::user()->account_id, 'author_id' => Auth::user()->id, @@ -32,6 +38,7 @@ class ContactModuleTaskController extends Controller 'contact_id' => $contactId, 'label' => $request->input('label'), 'description' => null, + 'due_at' => $dueAt, ]; $task = (new CreateContactTask())->execute($data); @@ -44,6 +51,11 @@ class ContactModuleTaskController extends Controller public function update(Request $request, int $vaultId, int $contactId, int $taskId) { + $dueAt = ''; + if ($request->input('due_at')) { + $dueAt = Carbon::parse($request->input('due_at'))->format('Y-m-d'); + } + $data = [ 'account_id' => Auth::user()->account_id, 'author_id' => Auth::user()->id, @@ -52,6 +64,7 @@ class ContactModuleTaskController extends Controller 'contact_task_id' => $taskId, 'label' => $request->input('label'), 'description' => null, + 'due_at' => $dueAt, ]; $task = (new UpdateContactTask())->execute($data); diff --git a/domains/Contact/ManageTasks/Web/ViewHelpers/ModuleContactTasksViewHelper.php b/domains/Contact/ManageTasks/Web/ViewHelpers/ModuleContactTasksViewHelper.php index ac6a2ee1f..1742aeaba 100644 --- a/domains/Contact/ManageTasks/Web/ViewHelpers/ModuleContactTasksViewHelper.php +++ b/domains/Contact/ManageTasks/Web/ViewHelpers/ModuleContactTasksViewHelper.php @@ -57,6 +57,8 @@ class ModuleContactTasksViewHelper 'description' => $task->description, 'completed' => $task->completed, 'completed_at' => $task->completed_at ? DateHelper::format($task->completed_at, $user) : null, + 'due_at' => $task->due_at ? DateHelper::format($task->due_at, $user) : null, + 'due_at_late' => optional($task->due_at)->isPast() ?? false, 'url' => [ 'update' => route('contact.task.update', [ 'vault' => $contact->vault_id, diff --git a/lang/en/vault.php b/lang/en/vault.php index a407d0879..efb9cd3ed 100644 --- a/lang/en/vault.php +++ b/lang/en/vault.php @@ -61,7 +61,7 @@ return [ 'dashboard_last_updated_contacts_title' => 'Last updated', 'dashboard_reminders_title' => 'Reminders for the next 30 days', - 'dashboard_reminders_blank' => 'No planned reminders.', + 'dashboard_reminders_blank' => 'No upcoming reminders.', 'dashboard_favorites_title' => 'Favorites', /*************************************************************** diff --git a/resources/js/Shared/Modules/Tasks.vue b/resources/js/Shared/Modules/Tasks.vue index d3b505b64..eb51f929b 100644 --- a/resources/js/Shared/Modules/Tasks.vue +++ b/resources/js/Shared/Modules/Tasks.vue @@ -41,6 +41,29 @@ @esc-key-pressed="createTaskModalShown = false" /> + +