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

[ADVAPP-124]: Creating and Scheduling Events #400

Merged
merged 5 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Calendar>
*/
class CalendarFactory extends Factory
{
Expand Down
62 changes: 62 additions & 0 deletions app-modules/meeting-center/database/factories/EventFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/*
<COPYRIGHT>

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.

</COPYRIGHT>
*/

namespace AdvisingApp\MeetingCenter\Database\Factories;

use Illuminate\Support\Carbon;
use AdvisingApp\MeetingCenter\Models\Event;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends Factory<Event>
*/
class EventFactory extends Factory
{
/**
* @return array<string, mixed>
*/
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'),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
<COPYRIGHT>

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.

</COPYRIGHT>
*/

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class () extends Migration {
public function up(): void
{
Schema::create('events', function (Blueprint $table) {
$table->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();
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@

class CalendarEventSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@

class CalendarSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
</COPYRIGHT>
*/

namespace App\Filament\Pages;
namespace AdvisingApp\MeetingCenter\Database\Seeders;

use Filament\Pages\Page;
use Illuminate\Database\Seeder;
use AdvisingApp\MeetingCenter\Models\Event;

class Events extends Page
class EventSeeder extends Seeder
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static ?string $navigationGroup = 'Meeting Center';

protected static ?int $navigationSort = 20;

protected static string $view = 'filament.pages.coming-soon';
public function run(): void
{
Event::factory()
->count(20)
->create();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{{--
<COPYRIGHT>

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.

</COPYRIGHT>
--}}
@php
use Filament\Support\Facades\FilamentView;
use Filament\Support\Facades\FilamentAsset;
use AdvisingApp\MeetingCenter\Filament\Widgets\CalendarEventWidget;
@endphp
<x-filament-panels::page @class([
'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)
<div wire:init="mountAction('setupCalendarProviderAction')">
</div>
@endempty

@if (auth()->user()->calendar?->oauth_token && !auth()->user()->calendar?->provider_id)
<div wire:init="mountAction('selectCalendarAction')">
</div>
@endif

<div class="flex w-full justify-start">
<div
class="grid max-w-xs grid-cols-2 gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"
role="group"
>
<button
type="button"
@class([
'px-5 py-1.5 text-xs font-medium rounded-lg',
'text-white bg-gray-900 dark:bg-gray-300 dark:text-gray-900' =>
$viewType === 'table',
'text-gray-900 hover:bg-gray-200 dark:text-white dark:hover:bg-gray-700' =>
$viewType !== 'table',
])
wire:click="setViewType('table')"
>
<x-filament::icon
class="h-6 w-6"
icon="heroicon-m-table-cells"
/>
</button>
<button
type="button"
@class([
'px-5 py-1.5 text-xs font-medium rounded-lg',
'text-white bg-gray-900 dark:bg-gray-300 dark:text-gray-900' =>
$viewType === 'calendar',
'text-gray-900 hover:bg-gray-200 dark:text-white dark:hover:bg-gray-700' =>
$viewType !== 'calendar',
])
wire:click="setViewType('calendar')"
>
<x-filament::icon
class="h-6 w-6"
icon="heroicon-m-calendar-days"
/>
</button>
</div>
</div>
@if ($viewType === 'table')
<div class="flex flex-col gap-y-6">
@if (count($tabs = $this->getTabs()))
<x-filament::tabs>
{{ 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

<x-filament::tabs.item
:active="$activeTab === $tabKey"
:badge="$tab->getBadge()"
:icon="$tab->getIcon()"
:icon-position="$tab->getIconPosition()"
:wire:click="'$set(\'activeTab\', ' . (filled($tabKey) ? ('\'' . $tabKey . '\'') : 'null') . ')'"
>
{{ $tab->getLabel() ?? $this->generateTabLabel($tabKey) }}
</x-filament::tabs.item>
@endforeach

{{ FilamentView::renderHook('panels::resource.pages.list-records.tabs.end', scopes: $this->getRenderHookScopes()) }}
</x-filament::tabs>
@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()) }}
</div>
@elseif($viewType === 'calendar')
<div>
@livewire(CalendarEventWidget::class)
</div>
@endif
</x-filament-panels::page>
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<div wire:init="mountAction('setupCalendarProviderAction')">
</div>
@endempty

@if (auth()->user()->calendar?->oauth_token && !auth()->user()->calendar?->provider_id)
<div wire:init="mountAction('selectCalendarAction')">
</div>
@endif

<div class="flex w-full justify-start">
<div
class="grid max-w-xs grid-cols-2 gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ListCalendarEvents extends ListRecords

protected ?string $heading = 'Schedule';

protected static string $view = 'meeting-center::filament.pages.list-events';
protected static string $view = 'meeting-center::filament.pages.list-calendar-events';

#[Url(as: 'view')]
public string $viewType = 'table';
Expand Down Expand Up @@ -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
Expand Down
Loading