From 3d2da413334f81e6fac89dd5b202050a10f54293 Mon Sep 17 00:00:00 2001 From: Matthew Myers Date: Fri, 22 Dec 2023 17:08:22 -0500 Subject: [PATCH 1/5] wip --- .../factories/CalendarEventFactory.php | 2 +- .../database/factories/EventFactory.php | 29 ++++ ...16_134402_create_calendar_events_table.php | 2 +- .../2023_12_22_211834_create_events_table.php | 24 ++++ .../database/seeders/EventSeeder.php | 16 +++ .../pages/list-calendar-events.blade.php | 131 ++++++++++++++++++ .../filament/pages/list-events.blade.php | 11 -- .../Pages/ListCalendarEvents.php | 2 +- .../src/Filament/Resources/EventResource.php | 30 +++- .../EventResource/Pages/CreateEvent.php | 78 +++++++++++ .../EventResource/Pages/EditEvent.php | 88 ++++++++++++ .../EventResource/Pages/ListEvents.php | 105 ++++++++++++++ .../EventResource/Pages/ViewEvent.php | 75 ++++++++++ .../Filament/Widgets/CalendarEventWidget.php | 71 ++++++++++ .../src/Filament/Widgets/CalendarWidget.php | 22 +-- .../meeting-center/src/Models/Event.php | 22 +++ .../MeetingCenterServiceProvider.php | 2 + database/seeders/DatabaseSeeder.php | 2 + 18 files changed, 676 insertions(+), 36 deletions(-) create mode 100644 app-modules/meeting-center/database/factories/EventFactory.php create mode 100644 app-modules/meeting-center/database/migrations/2023_12_22_211834_create_events_table.php create mode 100644 app-modules/meeting-center/database/seeders/EventSeeder.php create mode 100644 app-modules/meeting-center/resources/views/filament/pages/list-calendar-events.blade.php rename app/Filament/Pages/Events.php => app-modules/meeting-center/src/Filament/Resources/EventResource.php (63%) create mode 100644 app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/CreateEvent.php create mode 100644 app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/EditEvent.php create mode 100644 app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ListEvents.php create mode 100644 app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ViewEvent.php create mode 100644 app-modules/meeting-center/src/Filament/Widgets/CalendarEventWidget.php create mode 100644 app-modules/meeting-center/src/Models/Event.php diff --git a/app-modules/meeting-center/database/factories/CalendarEventFactory.php b/app-modules/meeting-center/database/factories/CalendarEventFactory.php index 3b3841bf64..8a96cd56c3 100644 --- a/app-modules/meeting-center/database/factories/CalendarEventFactory.php +++ b/app-modules/meeting-center/database/factories/CalendarEventFactory.php @@ -51,7 +51,7 @@ class CalendarEventFactory extends Factory public function definition(): array { return [ - 'title' => fake()->words(asText: true), + 'title' => fake()->catchPhrase(), 'description' => fake()->optional()->sentence(), 'starts_at' => fake()->dateTimeBetween('+1 hour', '+1 day'), 'ends_at' => fn (array $attributes) => Carbon::parse($attributes['starts_at'])->add('1 hour'), diff --git a/app-modules/meeting-center/database/factories/EventFactory.php b/app-modules/meeting-center/database/factories/EventFactory.php new file mode 100644 index 0000000000..49cd895e95 --- /dev/null +++ b/app-modules/meeting-center/database/factories/EventFactory.php @@ -0,0 +1,29 @@ + + */ +class EventFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'title' => fake()->catchPhrase(), + 'description' => fake()->optional()->paragraphs(asText: true), + 'location' => fake()->address(), + 'capacity' => fake()->numberBetween(1, 5000), + 'starts_at' => fake()->dateTimeBetween('-1 week', '+1 week'), + 'ends_at' => fn (array $attributes) => Carbon::parse($attributes['starts_at'])->add('1 hour'), + ]; + } +} diff --git a/app-modules/meeting-center/database/migrations/2023_10_16_134402_create_calendar_events_table.php b/app-modules/meeting-center/database/migrations/2023_10_16_134402_create_calendar_events_table.php index b74b3e1e14..bfb33a3052 100644 --- a/app-modules/meeting-center/database/migrations/2023_10_16_134402_create_calendar_events_table.php +++ b/app-modules/meeting-center/database/migrations/2023_10_16_134402_create_calendar_events_table.php @@ -45,7 +45,7 @@ public function up(): void $table->uuid('id')->primary(); $table->string('title'); - $table->text('description')->nullable(); + $table->longText('description')->nullable(); $table->json('attendees')->nullable(); $table->string('provider_id')->nullable(); diff --git a/app-modules/meeting-center/database/migrations/2023_12_22_211834_create_events_table.php b/app-modules/meeting-center/database/migrations/2023_12_22_211834_create_events_table.php new file mode 100644 index 0000000000..ef5e06fe80 --- /dev/null +++ b/app-modules/meeting-center/database/migrations/2023_12_22_211834_create_events_table.php @@ -0,0 +1,24 @@ +uuid('id')->primary(); + + $table->string('title'); + $table->text('description')->nullable(); + $table->text('location')->nullable(); + $table->integer('capacity')->nullable(); + + $table->timestamp('starts_at'); + $table->timestamp('ends_at'); + + $table->timestamps(); + }); + } +}; diff --git a/app-modules/meeting-center/database/seeders/EventSeeder.php b/app-modules/meeting-center/database/seeders/EventSeeder.php new file mode 100644 index 0000000000..4757c9957b --- /dev/null +++ b/app-modules/meeting-center/database/seeders/EventSeeder.php @@ -0,0 +1,16 @@ +count(20) + ->create(); + } +} diff --git a/app-modules/meeting-center/resources/views/filament/pages/list-calendar-events.blade.php b/app-modules/meeting-center/resources/views/filament/pages/list-calendar-events.blade.php new file mode 100644 index 0000000000..061f1e35c7 --- /dev/null +++ b/app-modules/meeting-center/resources/views/filament/pages/list-calendar-events.blade.php @@ -0,0 +1,131 @@ +{{-- + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +--}} +@php + use Filament\Support\Facades\FilamentView; + use Filament\Support\Facades\FilamentAsset; + use AdvisingApp\MeetingCenter\Filament\Widgets\CalendarEventWidget; +@endphp +getResource()::getSlug()), +])> + {{-- TODO: Determine the best way to check if calendar is set up --}} + @empty(auth()->user()->calendar?->oauth_token) +
+
+ @endempty + + @if (auth()->user()->calendar?->oauth_token && !auth()->user()->calendar?->provider_id) +
+
+ @endif + +
+
+ + +
+
+ @if ($viewType === 'table') +
+ @if (count($tabs = $this->getTabs())) + + {{ FilamentView::renderHook('panels::resource.pages.list-records.tabs.start', scopes: $this->getRenderHookScopes()) }} + + @foreach ($tabs as $tabKey => $tab) + @php + $activeTab = strval($activeTab); + $tabKey = strval($tabKey); + @endphp + + + {{ $tab->getLabel() ?? $this->generateTabLabel($tabKey) }} + + @endforeach + + {{ FilamentView::renderHook('panels::resource.pages.list-records.tabs.end', scopes: $this->getRenderHookScopes()) }} + + @endif + + {{ FilamentView::renderHook('panels::resource.pages.list-records.table.before', scopes: $this->getRenderHookScopes()) }} + + {{ $this->table }} + + {{ FilamentView::renderHook('panels::resource.pages.list-records.table.after', scopes: $this->getRenderHookScopes()) }} +
+ @elseif($viewType === 'calendar') +
+ @livewire(CalendarEventWidget::class) +
+ @endif +
diff --git a/app-modules/meeting-center/resources/views/filament/pages/list-events.blade.php b/app-modules/meeting-center/resources/views/filament/pages/list-events.blade.php index aa57b4f03c..72884b5b9a 100644 --- a/app-modules/meeting-center/resources/views/filament/pages/list-events.blade.php +++ b/app-modules/meeting-center/resources/views/filament/pages/list-events.blade.php @@ -40,17 +40,6 @@ 'fi-resource-list-records-page', 'fi-resource-' . str_replace('/', '-', $this->getResource()::getSlug()), ])> - {{-- TODO: Determine the best way to check if calendar is set up --}} - @empty(auth()->user()->calendar?->oauth_token) -
-
- @endempty - - @if (auth()->user()->calendar?->oauth_token && !auth()->user()->calendar?->provider_id) -
-
- @endif -
*/ -namespace App\Filament\Pages; +namespace AdvisingApp\MeetingCenter\Filament\Resources; -use Filament\Pages\Page; +use Filament\Resources\Resource; +use AdvisingApp\MeetingCenter\Models\Event; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource\Pages\EditEvent; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource\Pages\ViewEvent; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource\Pages\ListEvents; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource\Pages\CreateEvent; -class Events extends Page +class EventResource extends Resource { - protected static ?string $navigationIcon = 'heroicon-o-document-text'; + protected static ?string $model = Event::class; + + protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; protected static ?string $navigationGroup = 'Meeting Center'; protected static ?int $navigationSort = 20; - protected static string $view = 'filament.pages.coming-soon'; + public static function getRelations(): array + { + return []; + } + + public static function getPages(): array + { + return [ + 'index' => ListEvents::route('/'), + 'create' => CreateEvent::route('/create'), + 'view' => ViewEvent::route('/{record}'), + 'edit' => EditEvent::route('/{record}/edit'), + ]; + } } diff --git a/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/CreateEvent.php b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/CreateEvent.php new file mode 100644 index 0000000000..5fb7b12ea2 --- /dev/null +++ b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/CreateEvent.php @@ -0,0 +1,78 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\MeetingCenter\Filament\Resources\EventResource\Pages; + +use App\Models\User; +use Filament\Forms\Form; +use Filament\Forms\Components\Textarea; +use Filament\Forms\Components\TextInput; +use Filament\Resources\Pages\CreateRecord; +use Filament\Forms\Components\DateTimePicker; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource; + +class CreateEvent extends CreateRecord +{ + protected static string $resource = EventResource::class; + + public function form(Form $form): Form + { + /** @var User $user */ + $user = auth()->user(); + + return $form->schema([ + TextInput::make('title') + ->string() + ->required(), + Textarea::make('description') + ->string() + ->nullable(), + TextInput::make('location') + ->string() + ->nullable(), + TextInput::make('capacity') + ->integer() + ->minValue(1) + ->nullable(), + DateTimePicker::make('starts_at') + ->timezone($user->timezone) + ->required(), + DateTimePicker::make('ends_at') + ->timezone($user->timezone) + ->required(), + ]); + } +} diff --git a/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/EditEvent.php b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/EditEvent.php new file mode 100644 index 0000000000..7a1ac857ca --- /dev/null +++ b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/EditEvent.php @@ -0,0 +1,88 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\MeetingCenter\Filament\Resources\EventResource\Pages; + +use App\Models\User; +use Filament\Forms\Form; +use Filament\Actions\ViewAction; +use Filament\Actions\DeleteAction; +use Filament\Forms\Components\Textarea; +use Filament\Forms\Components\TextInput; +use Filament\Resources\Pages\EditRecord; +use Filament\Forms\Components\DateTimePicker; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource; + +class EditEvent extends EditRecord +{ + protected static string $resource = EventResource::class; + + public function form(Form $form): Form + { + /** @var User $user */ + $user = auth()->user(); + + return $form->schema([ + TextInput::make('title') + ->string() + ->required(), + Textarea::make('description') + ->string() + ->nullable(), + TextInput::make('location') + ->string() + ->nullable(), + TextInput::make('capacity') + ->integer() + ->minValue(1) + ->nullable(), + DateTimePicker::make('starts_at') + ->timezone($user->timezone) + ->required(), + DateTimePicker::make('ends_at') + ->timezone($user->timezone) + ->required(), + ]); + } + + protected function getHeaderActions(): array + { + return [ + ViewAction::make(), + DeleteAction::make(), + ]; + } +} diff --git a/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ListEvents.php b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ListEvents.php new file mode 100644 index 0000000000..a041f59bbe --- /dev/null +++ b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ListEvents.php @@ -0,0 +1,105 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\MeetingCenter\Filament\Resources\EventResource\Pages; + +use Filament\Tables\Table; +use Livewire\Attributes\Url; +use App\Filament\Columns\IdColumn; +use Filament\Actions\CreateAction; +use Filament\Tables\Filters\Filter; +use Filament\Tables\Actions\EditAction; +use Filament\Tables\Actions\ViewAction; +use Filament\Resources\Pages\ListRecords; +use Filament\Tables\Actions\DeleteAction; +use Illuminate\Database\Eloquent\Builder; +use Filament\Tables\Actions\BulkActionGroup; +use Filament\Tables\Actions\DeleteBulkAction; +use App\Filament\Columns\OpenSearch\TextColumn; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource; + +class ListEvents extends ListRecords +{ + protected static string $resource = EventResource::class; + + protected static string $view = 'meeting-center::filament.pages.list-events'; + + #[Url(as: 'view')] + public string $viewType = 'table'; + + public function setViewType(string $viewType): void + { + $this->viewType = $viewType; + } + + public function table(Table $table): Table + { + return $table + ->columns([ + IdColumn::make(), + TextColumn::make('title') + ->sortable(), + TextColumn::make('starts_at') + ->sortable(), + TextColumn::make('ends_at') + ->sortable(), + ]) + ->filters([ + Filter::make('pastEvents') + ->label('Hide Past Events') + ->query(fn (Builder $query): Builder => $query->where('starts_at', '>=', now()->startOfDay())) + ->default(), + ]) + ->actions([ + ViewAction::make(), + EditAction::make(), + DeleteAction::make(), + ]) + ->bulkActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]) + ->defaultSort('starts_at', 'desc'); + } + + protected function getHeaderActions(): array + { + return [ + CreateAction::make(), + ]; + } +} diff --git a/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ViewEvent.php b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ViewEvent.php new file mode 100644 index 0000000000..06d58a2b7f --- /dev/null +++ b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ViewEvent.php @@ -0,0 +1,75 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\MeetingCenter\Filament\Resources\EventResource\Pages; + +use Filament\Actions\EditAction; +use Filament\Infolists\Infolist; +use Filament\Actions\DeleteAction; +use Filament\Resources\Pages\ViewRecord; +use Filament\Infolists\Components\Section; +use Filament\Infolists\Components\TextEntry; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource; + +class ViewEvent extends ViewRecord +{ + protected static string $resource = EventResource::class; + + public function infolist(Infolist $infolist): Infolist + { + return $infolist + ->schema([ + Section::make() + ->schema([ + TextEntry::make('title'), + TextEntry::make('description'), + TextEntry::make('location'), + TextEntry::make('capacity'), + TextEntry::make('starts_at'), + TextEntry::make('ends_at'), + ]) + ->columns(), + ]); + } + + protected function getHeaderActions(): array + { + return [ + EditAction::make(), + DeleteAction::make(), + ]; + } +} diff --git a/app-modules/meeting-center/src/Filament/Widgets/CalendarEventWidget.php b/app-modules/meeting-center/src/Filament/Widgets/CalendarEventWidget.php new file mode 100644 index 0000000000..2ee5e6504e --- /dev/null +++ b/app-modules/meeting-center/src/Filament/Widgets/CalendarEventWidget.php @@ -0,0 +1,71 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\MeetingCenter\Filament\Widgets; + +use App\Models\User; +use Livewire\Attributes\On; +use Saade\FilamentFullCalendar\Data\EventData; +use AdvisingApp\MeetingCenter\Models\CalendarEvent; +use Saade\FilamentFullCalendar\Widgets\FullCalendarWidget; +use AdvisingApp\MeetingCenter\Filament\Resources\CalendarEventResource; + +class CalendarEventWidget extends FullCalendarWidget +{ + public function fetchEvents(array $info): array + { + /** @var User $user */ + $user = auth()->user(); + + return $user->calendar + ->events() + ->get() + ->map(fn (CalendarEvent $event) => EventData::make() + ->id($event->id) + ->title($event->title) + ->start($event->starts_at) + ->end($event->ends_at) + ->url(CalendarEventResource::getUrl('view', ['record' => $event]), true) + ->extendedProps(['shouldOpenInNewTab' => true])) + ->toArray(); + } + + #[On('refresh-events')] + public function refreshEvents(): void + { + $this->refreshRecords(); + } +} diff --git a/app-modules/meeting-center/src/Filament/Widgets/CalendarWidget.php b/app-modules/meeting-center/src/Filament/Widgets/CalendarWidget.php index 204c4f9b23..324468431c 100644 --- a/app-modules/meeting-center/src/Filament/Widgets/CalendarWidget.php +++ b/app-modules/meeting-center/src/Filament/Widgets/CalendarWidget.php @@ -37,35 +37,23 @@ namespace AdvisingApp\MeetingCenter\Filament\Widgets; use App\Models\User; -use Livewire\Attributes\On; +use AdvisingApp\MeetingCenter\Models\Event; use Saade\FilamentFullCalendar\Data\EventData; -use AdvisingApp\MeetingCenter\Models\CalendarEvent; use Saade\FilamentFullCalendar\Widgets\FullCalendarWidget; -use AdvisingApp\MeetingCenter\Filament\Resources\CalendarEventResource; +use AdvisingApp\MeetingCenter\Filament\Resources\EventResource; class CalendarWidget extends FullCalendarWidget { public function fetchEvents(array $info): array { - /** @var User $user */ - $user = auth()->user(); - - return $user->calendar - ->events() - ->get() - ->map(fn (CalendarEvent $event) => EventData::make() + return Event::all() + ->map(fn (Event $event) => EventData::make() ->id($event->id) ->title($event->title) ->start($event->starts_at) ->end($event->ends_at) - ->url(CalendarEventResource::getUrl('view', ['record' => $event]), true) + ->url(EventResource::getUrl('view', ['record' => $event]), true) ->extendedProps(['shouldOpenInNewTab' => true])) ->toArray(); } - - #[On('refresh-events')] - public function refreshEvents(): void - { - $this->refreshRecords(); - } } diff --git a/app-modules/meeting-center/src/Models/Event.php b/app-modules/meeting-center/src/Models/Event.php new file mode 100644 index 0000000000..134610d1f7 --- /dev/null +++ b/app-modules/meeting-center/src/Models/Event.php @@ -0,0 +1,22 @@ + 'datetime', + 'ends_at' => 'datetime', + ]; +} diff --git a/app-modules/meeting-center/src/Providers/MeetingCenterServiceProvider.php b/app-modules/meeting-center/src/Providers/MeetingCenterServiceProvider.php index f1972cec6a..ee94dc3d2b 100644 --- a/app-modules/meeting-center/src/Providers/MeetingCenterServiceProvider.php +++ b/app-modules/meeting-center/src/Providers/MeetingCenterServiceProvider.php @@ -36,6 +36,7 @@ namespace AdvisingApp\MeetingCenter\Providers; +use AdvisingApp\MeetingCenter\Models\Event; use Filament\Panel; use Illuminate\Support\ServiceProvider; use Illuminate\Console\Scheduling\Schedule; @@ -60,6 +61,7 @@ public function boot(): void Relation::morphMap([ 'calendar' => Calendar::class, 'calendar_event' => CalendarEvent::class, + 'event' => Event::class, ]); $this->callAfterResolving(Schedule::class, function (Schedule $schedule) { diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 00cd622205..e5136d3eb5 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -45,6 +45,7 @@ use AdvisingApp\Alert\Database\Seeders\AlertSeeder; use AdvisingApp\Division\Database\Seeders\DivisionSeeder; use AdvisingApp\Prospect\Database\Seeders\ProspectSeeder; +use AdvisingApp\MeetingCenter\Database\Seeders\EventSeeder; use AdvisingApp\Engagement\Database\Seeders\EngagementSeeder; use AdvisingApp\Interaction\Database\Seeders\InteractionSeeder; use AdvisingApp\Prospect\Database\Seeders\ProspectSourceSeeder; @@ -103,6 +104,7 @@ public function run(): void SuperAdminSeeder::class, StudentSeeder::class, ApplicationSubmissionStateSeeder::class, + EventSeeder::class, ]); } } From c635bc90b86ca62bac2f317ac64aeccbf90e4ac5 Mon Sep 17 00:00:00 2001 From: Matthew Myers Date: Fri, 22 Dec 2023 17:10:08 -0500 Subject: [PATCH 2/5] Fix sort direction. --- .../CalendarEventResource/Pages/ListCalendarEvents.php | 2 +- .../src/Filament/Resources/EventResource/Pages/ListEvents.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app-modules/meeting-center/src/Filament/Resources/CalendarEventResource/Pages/ListCalendarEvents.php b/app-modules/meeting-center/src/Filament/Resources/CalendarEventResource/Pages/ListCalendarEvents.php index 06efc609d5..19c5637374 100644 --- a/app-modules/meeting-center/src/Filament/Resources/CalendarEventResource/Pages/ListCalendarEvents.php +++ b/app-modules/meeting-center/src/Filament/Resources/CalendarEventResource/Pages/ListCalendarEvents.php @@ -170,7 +170,7 @@ public function table(Table $table): Table return $query->whereRelation('calendar', 'user_id', $user->id); }) - ->defaultSort('starts_at', 'desc'); + ->defaultSort('starts_at'); } protected function getHeaderActions(): array diff --git a/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ListEvents.php b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ListEvents.php index a041f59bbe..5b66aec1fc 100644 --- a/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ListEvents.php +++ b/app-modules/meeting-center/src/Filament/Resources/EventResource/Pages/ListEvents.php @@ -93,7 +93,7 @@ public function table(Table $table): Table DeleteBulkAction::make(), ]), ]) - ->defaultSort('starts_at', 'desc'); + ->defaultSort('starts_at'); } protected function getHeaderActions(): array From ce6cd2366571d1a1c356547d894318b0ee2ed967 Mon Sep 17 00:00:00 2001 From: Matthew Myers Date: Fri, 22 Dec 2023 17:33:19 -0500 Subject: [PATCH 3/5] Format. --- .../src/Filament/Widgets/CalendarEventWidget.php | 3 +++ .../meeting-center/src/Filament/Widgets/CalendarWidget.php | 4 +++- .../src/Providers/MeetingCenterServiceProvider.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app-modules/meeting-center/src/Filament/Widgets/CalendarEventWidget.php b/app-modules/meeting-center/src/Filament/Widgets/CalendarEventWidget.php index 2ee5e6504e..5361f9a8f0 100644 --- a/app-modules/meeting-center/src/Filament/Widgets/CalendarEventWidget.php +++ b/app-modules/meeting-center/src/Filament/Widgets/CalendarEventWidget.php @@ -50,6 +50,9 @@ public function fetchEvents(array $info): array /** @var User $user */ $user = auth()->user(); + //TODO: We probably want to eventually automatically filter past events + //Maybe reuse the shared filter capability of the kanban view + return $user->calendar ->events() ->get() diff --git a/app-modules/meeting-center/src/Filament/Widgets/CalendarWidget.php b/app-modules/meeting-center/src/Filament/Widgets/CalendarWidget.php index 324468431c..d04e24c506 100644 --- a/app-modules/meeting-center/src/Filament/Widgets/CalendarWidget.php +++ b/app-modules/meeting-center/src/Filament/Widgets/CalendarWidget.php @@ -36,7 +36,6 @@ namespace AdvisingApp\MeetingCenter\Filament\Widgets; -use App\Models\User; use AdvisingApp\MeetingCenter\Models\Event; use Saade\FilamentFullCalendar\Data\EventData; use Saade\FilamentFullCalendar\Widgets\FullCalendarWidget; @@ -46,6 +45,9 @@ class CalendarWidget extends FullCalendarWidget { public function fetchEvents(array $info): array { + //TODO: We probably want to eventually automatically filter past events + //Maybe reuse the shared filter capability of the kanban view + return Event::all() ->map(fn (Event $event) => EventData::make() ->id($event->id) diff --git a/app-modules/meeting-center/src/Providers/MeetingCenterServiceProvider.php b/app-modules/meeting-center/src/Providers/MeetingCenterServiceProvider.php index ee94dc3d2b..4da3cd67f1 100644 --- a/app-modules/meeting-center/src/Providers/MeetingCenterServiceProvider.php +++ b/app-modules/meeting-center/src/Providers/MeetingCenterServiceProvider.php @@ -36,9 +36,9 @@ namespace AdvisingApp\MeetingCenter\Providers; -use AdvisingApp\MeetingCenter\Models\Event; use Filament\Panel; use Illuminate\Support\ServiceProvider; +use AdvisingApp\MeetingCenter\Models\Event; use Illuminate\Console\Scheduling\Schedule; use AdvisingApp\MeetingCenter\Models\Calendar; use AdvisingApp\MeetingCenter\Jobs\SyncCalendars; From 0b0c0681f00add290d919f767362220f376a8351 Mon Sep 17 00:00:00 2001 From: Matthew Myers Date: Fri, 22 Dec 2023 17:40:07 -0500 Subject: [PATCH 4/5] Format. --- .../meeting-center/database/factories/CalendarFactory.php | 3 ++- .../meeting-center/database/factories/EventFactory.php | 5 ++--- .../meeting-center/database/seeders/CalendarEventSeeder.php | 3 --- .../meeting-center/database/seeders/CalendarSeeder.php | 3 --- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app-modules/meeting-center/database/factories/CalendarFactory.php b/app-modules/meeting-center/database/factories/CalendarFactory.php index 0734f10f17..34322aff01 100644 --- a/app-modules/meeting-center/database/factories/CalendarFactory.php +++ b/app-modules/meeting-center/database/factories/CalendarFactory.php @@ -36,10 +36,11 @@ namespace AdvisingApp\MeetingCenter\Database\Factories; +use AdvisingApp\MeetingCenter\Models\Calendar; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\AdvisingApp\MeetingCenter\Models\Calendar> + * @extends Factory */ class CalendarFactory extends Factory { diff --git a/app-modules/meeting-center/database/factories/EventFactory.php b/app-modules/meeting-center/database/factories/EventFactory.php index 49cd895e95..010b7c3068 100644 --- a/app-modules/meeting-center/database/factories/EventFactory.php +++ b/app-modules/meeting-center/database/factories/EventFactory.php @@ -3,16 +3,15 @@ namespace AdvisingApp\MeetingCenter\Database\Factories; use Illuminate\Support\Carbon; +use AdvisingApp\MeetingCenter\Models\Event; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\AdvisingApp\MeetingCenter\Models\Event> + * @extends Factory */ class EventFactory extends Factory { /** - * Define the model's default state. - * * @return array */ public function definition(): array diff --git a/app-modules/meeting-center/database/seeders/CalendarEventSeeder.php b/app-modules/meeting-center/database/seeders/CalendarEventSeeder.php index 80736eeb24..00bf0b72d5 100644 --- a/app-modules/meeting-center/database/seeders/CalendarEventSeeder.php +++ b/app-modules/meeting-center/database/seeders/CalendarEventSeeder.php @@ -40,8 +40,5 @@ class CalendarEventSeeder extends Seeder { - /** - * Run the database seeds. - */ public function run(): void {} } diff --git a/app-modules/meeting-center/database/seeders/CalendarSeeder.php b/app-modules/meeting-center/database/seeders/CalendarSeeder.php index ae8642d1a2..b9bb2464ed 100644 --- a/app-modules/meeting-center/database/seeders/CalendarSeeder.php +++ b/app-modules/meeting-center/database/seeders/CalendarSeeder.php @@ -40,8 +40,5 @@ class CalendarSeeder extends Seeder { - /** - * Run the database seeds. - */ public function run(): void {} } From 6fe2863f592638a6f496f1c9a0bc40e856fb9be3 Mon Sep 17 00:00:00 2001 From: mxm1070 Date: Fri, 22 Dec 2023 22:41:51 +0000 Subject: [PATCH 5/5] chore: fix enforcement of copyright on all files --- .../database/factories/EventFactory.php | 34 +++++++++++++++++++ .../2023_12_22_211834_create_events_table.php | 34 +++++++++++++++++++ .../database/seeders/EventSeeder.php | 34 +++++++++++++++++++ .../meeting-center/src/Models/Event.php | 34 +++++++++++++++++++ 4 files changed, 136 insertions(+) diff --git a/app-modules/meeting-center/database/factories/EventFactory.php b/app-modules/meeting-center/database/factories/EventFactory.php index 010b7c3068..63c23f47b3 100644 --- a/app-modules/meeting-center/database/factories/EventFactory.php +++ b/app-modules/meeting-center/database/factories/EventFactory.php @@ -1,5 +1,39 @@ + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + namespace AdvisingApp\MeetingCenter\Database\Factories; use Illuminate\Support\Carbon; diff --git a/app-modules/meeting-center/database/migrations/2023_12_22_211834_create_events_table.php b/app-modules/meeting-center/database/migrations/2023_12_22_211834_create_events_table.php index ef5e06fe80..4b6c3fbbf4 100644 --- a/app-modules/meeting-center/database/migrations/2023_12_22_211834_create_events_table.php +++ b/app-modules/meeting-center/database/migrations/2023_12_22_211834_create_events_table.php @@ -1,5 +1,39 @@ + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; diff --git a/app-modules/meeting-center/database/seeders/EventSeeder.php b/app-modules/meeting-center/database/seeders/EventSeeder.php index 4757c9957b..c61900a108 100644 --- a/app-modules/meeting-center/database/seeders/EventSeeder.php +++ b/app-modules/meeting-center/database/seeders/EventSeeder.php @@ -1,5 +1,39 @@ + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + namespace AdvisingApp\MeetingCenter\Database\Seeders; use Illuminate\Database\Seeder; diff --git a/app-modules/meeting-center/src/Models/Event.php b/app-modules/meeting-center/src/Models/Event.php index 134610d1f7..401917e9be 100644 --- a/app-modules/meeting-center/src/Models/Event.php +++ b/app-modules/meeting-center/src/Models/Event.php @@ -1,5 +1,39 @@ + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + namespace AdvisingApp\MeetingCenter\Models; use App\Models\BaseModel;