diff --git a/app/Domains/Outputs/OutputTypeEnum.php b/app/Domains/Outputs/OutputTypeEnum.php index 3a23de57..b5ae99da 100644 --- a/app/Domains/Outputs/OutputTypeEnum.php +++ b/app/Domains/Outputs/OutputTypeEnum.php @@ -11,6 +11,7 @@ enum OutputTypeEnum: string case WebPage = 'web_page'; case EmailOutput = 'email_output'; + case CalendarOutput = 'calendar_output'; case ApiOutput = 'api_output'; case EmailReplyOutput = 'email_reply_output'; //leave for scripting diff --git a/app/Http/Controllers/CalendarController.php b/app/Http/Controllers/CalendarController.php index eff60de9..cf411327 100644 --- a/app/Http/Controllers/CalendarController.php +++ b/app/Http/Controllers/CalendarController.php @@ -2,17 +2,22 @@ namespace App\Http\Controllers; +use App\Domains\Outputs\OutputTypeEnum; use App\Http\Resources\CollectionResource; use App\Http\Resources\EventResource; use App\Models\Collection; use App\Models\Event; use Carbon\Carbon; -use Illuminate\Http\Request; class CalendarController extends Controller { public function show(Collection $collection) { + //for now if there is no related output we do a 404 + if (! $collection->outputs()->where('type', OutputTypeEnum::CalendarOutput)->first()) { + abort(404); + } + // Parse the date from the query string, or use the current date if not provided $date = request()->input('date') ? Carbon::parse(request()->input('date')) : now(); @@ -26,7 +31,7 @@ public function show(Collection $collection) ->get(); return inertia('Calendar/Show', [ - "collection" => new CollectionResource($collection), + 'collection' => new CollectionResource($collection), 'events' => EventResource::collection($events), 'startDate' => $startOfCalendar->format('Y-m-d'), 'endDate' => $endOfCalendar->format('Y-m-d'), diff --git a/app/Http/Controllers/Outputs/CalendarOutputController.php b/app/Http/Controllers/Outputs/CalendarOutputController.php new file mode 100644 index 00000000..495a7908 --- /dev/null +++ b/app/Http/Controllers/Outputs/CalendarOutputController.php @@ -0,0 +1,21 @@ + + +import {Link} from "@inertiajs/vue3"; +import Settings from "@/Pages/Outputs/Components/Settings.vue"; + +const props = defineProps({ + output: Object +}) + + + + + diff --git a/resources/js/Pages/Outputs/Calendar/Components/Resources.vue b/resources/js/Pages/Outputs/Calendar/Components/Resources.vue new file mode 100644 index 00000000..6d34641f --- /dev/null +++ b/resources/js/Pages/Outputs/Calendar/Components/Resources.vue @@ -0,0 +1,55 @@ + + + diff --git a/resources/js/Pages/Outputs/Calendar/Create.vue b/resources/js/Pages/Outputs/Calendar/Create.vue new file mode 100644 index 00000000..79128d43 --- /dev/null +++ b/resources/js/Pages/Outputs/Calendar/Create.vue @@ -0,0 +1,77 @@ + + + diff --git a/resources/js/Pages/Outputs/Calendar/Edit.vue b/resources/js/Pages/Outputs/Calendar/Edit.vue new file mode 100644 index 00000000..47a02cbe --- /dev/null +++ b/resources/js/Pages/Outputs/Calendar/Edit.vue @@ -0,0 +1,84 @@ + + + diff --git a/resources/js/Pages/Outputs/Calendar/Show.vue b/resources/js/Pages/Outputs/Calendar/Show.vue new file mode 100644 index 00000000..3d9a5e29 --- /dev/null +++ b/resources/js/Pages/Outputs/Calendar/Show.vue @@ -0,0 +1,53 @@ + + + diff --git a/resources/js/Pages/Outputs/Index.vue b/resources/js/Pages/Outputs/Index.vue index 1b5d48f7..29f85c1a 100644 --- a/resources/js/Pages/Outputs/Index.vue +++ b/resources/js/Pages/Outputs/Index.vue @@ -12,6 +12,7 @@ import { useToast } from 'vue-toastification'; import WebCard from "@/Pages/Outputs/WebPage/Components/Card.vue"; import EmailCard from "@/Pages/Outputs/EmailOutput/Components/Card.vue"; import ApiCard from "@/Pages/Outputs/ApiOutput/Components/Card.vue"; +import CalendarCard from "@/Pages/Outputs/Calendar/Components/Card.vue"; import EmailReplyOutput from "@/Pages/Outputs/EmailReplyOutput/Components/Card.vue"; const toast = useToast(); @@ -69,6 +70,7 @@ const props = defineProps({ + diff --git a/routes/web.php b/routes/web.php index 0d74678c..17c44033 100644 --- a/routes/web.php +++ b/routes/web.php @@ -43,7 +43,6 @@ Route::get('/calendar/{collection}', 'show')->name('calendar.show'); }); - Route::get('/auth/google', [\App\Http\Controllers\GoogleController::class, 'redirectToGoogle']) ->name('auth.google'); Route::get('/auth/google/callback', [\App\Http\Controllers\GoogleController::class, 'handleGoogleCallback']) @@ -248,6 +247,19 @@ function () { } ); + Route::controller(\App\Http\Controllers\Outputs\CalendarOutputController::class)->group( + function () { + Route::get('/collections/{collection}/outputs/calendar/create', 'create') + ->name('collections.outputs.calendar_output.create'); + Route::get('/collections/{collection}/outputs/calendar/{output:id}/edit', 'edit') + ->name('collections.outputs.calendar_output.edit'); + Route::post('/collections/{collection}/outputs/calendar', 'store') + ->name('collections.outputs.calendar_output.store'); + Route::put('/collections/{collection}/outputs/calendar/{output:id}/update', 'update') + ->name('collections.outputs.calendar_output.update'); + } + ); + Route::controller(\App\Http\Controllers\EmailOutputController::class)->group( function () { Route::get('/collections/{collection}/outputs/email_output/create', 'create') diff --git a/tests/Feature/Http/Controllers/CalendarControllerTest.php b/tests/Feature/Http/Controllers/CalendarControllerTest.php index 1eb34c7b..b973caeb 100644 --- a/tests/Feature/Http/Controllers/CalendarControllerTest.php +++ b/tests/Feature/Http/Controllers/CalendarControllerTest.php @@ -2,8 +2,9 @@ namespace Tests\Feature\Http\Controllers; -use Illuminate\Foundation\Testing\RefreshDatabase; -use Illuminate\Foundation\Testing\WithFaker; +use App\Models\Collection; +use App\Models\Output; +use App\Models\User; use Tests\TestCase; class CalendarControllerTest extends TestCase @@ -11,10 +12,17 @@ class CalendarControllerTest extends TestCase /** * A basic feature test example. */ - public function test_example(): void + public function test_success(): void { - $response = $this->get('/'); + $collection = Collection::factory()->create(); - $response->assertStatus(200); + Output::factory()->create([ + 'collection_id' => $collection->id, + 'type' => \App\Domains\Outputs\OutputTypeEnum::CalendarOutput, + ]); + + $this->actingAs(User::factory()->create())->get(route('calendar.show', [ + 'collection' => $collection->id, + ]))->assertStatus(200); } }