From 56b79b0ed8afe1d7110857ec6553e8463d12efe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Mon, 17 Jun 2024 15:14:42 +0100 Subject: [PATCH 01/20] fix: get temporary url --- app/Models/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 3bb95f52..98e6613f 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -177,7 +177,7 @@ public function reject(?string $reason): void public function getModifiedField(mixed $value): ?string { if ($this->description === 'statute') { - $value = Media::find($value)?->getUrl(); + $value = Media::find($value)?->getTemporaryUrl(now()->addMinutes(5)); } if (\gettype($value) == 'boolean') { From a96bd327900f746a3acba811321ac26d7c954d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Tue, 18 Jun 2024 15:35:06 +0100 Subject: [PATCH 02/20] wip --- resources/js/Components/Navbar.vue | 126 +++++++------- resources/js/Layouts/DashboardLayout.vue | 200 +++++++++++------------ 2 files changed, 163 insertions(+), 163 deletions(-) diff --git a/resources/js/Components/Navbar.vue b/resources/js/Components/Navbar.vue index 158538b8..678b1d04 100644 --- a/resources/js/Components/Navbar.vue +++ b/resources/js/Components/Navbar.vue @@ -220,72 +220,72 @@ diff --git a/resources/js/Layouts/DashboardLayout.vue b/resources/js/Layouts/DashboardLayout.vue index 85c1c623..7727d180 100644 --- a/resources/js/Layouts/DashboardLayout.vue +++ b/resources/js/Layouts/DashboardLayout.vue @@ -67,109 +67,109 @@ From 1e70c4a0c4a663b7619df1b8e740e8315be6ecc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Tue, 18 Jun 2024 15:49:48 +0100 Subject: [PATCH 03/20] fix: issue 1 --- app/Filament/Resources/EditionsResource.php | 2 +- app/Filament/Resources/GalaProjectResource.php | 11 ++++++++++- app/Filament/Resources/ProjectResource.php | 3 ++- database/factories/GalaProjectFactory.php | 13 +++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/EditionsResource.php b/app/Filament/Resources/EditionsResource.php index 218abb7c..3bf29728 100644 --- a/app/Filament/Resources/EditionsResource.php +++ b/app/Filament/Resources/EditionsResource.php @@ -121,7 +121,7 @@ public static function table(Table $table): Table ->searchable() ->sortable(), - Tables\Columns\TextColumn::make('categories') + Tables\Columns\TextColumn::make('editionCategories.name') ->label(__('edition.labels.categories')) ->searchable() ->sortable(), diff --git a/app/Filament/Resources/GalaProjectResource.php b/app/Filament/Resources/GalaProjectResource.php index 851ba60e..5b3d9f9c 100644 --- a/app/Filament/Resources/GalaProjectResource.php +++ b/app/Filament/Resources/GalaProjectResource.php @@ -7,6 +7,7 @@ use App\Enums\OrganizationType; use App\Enums\ProjectArea; use App\Filament\Resources\GalaProjectResource\Pages; +use App\Forms\Components\Link; use App\Models\Edition; use App\Models\GalaProject; use Filament\Forms\Components\DatePicker; @@ -53,6 +54,12 @@ public static function form(Form $form): Form { return $form ->schema([ + Link::make('organizatii') + ->type('organization') + ->label(__('organization.label.singular')) + ->inlineLabel() + ->columnSpanFull(), + Select::make('gala') ->label(__('edition.labels.gala')) ->relationship( @@ -202,14 +209,16 @@ public static function table(Table $table): Table return $table ->columns([ - Tables\Columns\TextColumn::make('title') + Tables\Columns\TextColumn::make('name') ->label(__('edition.project.label.plural')) ->searchable() + ->wrap() ->sortable(), Tables\Columns\TextColumn::make('categories.name') ->label(__('edition.labels.category')) ->searchable() + ->wrap() ->sortable(), Tables\Columns\TextColumn::make('youth') diff --git a/app/Filament/Resources/ProjectResource.php b/app/Filament/Resources/ProjectResource.php index 914c8755..5f246fda 100644 --- a/app/Filament/Resources/ProjectResource.php +++ b/app/Filament/Resources/ProjectResource.php @@ -50,7 +50,8 @@ public static function form(Form $form): Form { return $form ->schema([ - Link::make('organizatii')->type('organization') + Link::make('organizatii') + ->type('organization') ->label(__('organization.labels.administrator')) ->inlineLabel() ->columnSpanFull(), diff --git a/database/factories/GalaProjectFactory.php b/database/factories/GalaProjectFactory.php index 9f7384d0..53fe07e2 100644 --- a/database/factories/GalaProjectFactory.php +++ b/database/factories/GalaProjectFactory.php @@ -5,6 +5,7 @@ namespace Database\Factories; use App\Models\Gala; +use App\Models\GalaProject; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; @@ -56,4 +57,16 @@ public function definition(): array ], ]; } + + public function configure(): static + { + return $this->afterCreating(function (GalaProject $galaProject) { + $galaProject->categories()->attach( + $galaProject->gala->edition->editionCategories + ->shuffle() + ->take(fake()->numberBetween(1, 3)) + ->pluck('id') + ); + }); + } } From 7e59b64d1498a10a7b98e2025e889b905e56dbab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Tue, 18 Jun 2024 16:51:10 +0100 Subject: [PATCH 04/20] fix: issue 3 --- .../Resources/GalaProjectResource.php | 5 +-- .../Pages/CreateGalaProject.php | 13 ------- .../Pages/EditGalaProject.php | 21 ---------- .../Pages/ViewGalaProject.php | 5 +++ .../PrizesRelationManager.php | 38 +++++++++++++++++++ app/Models/GalaProject.php | 5 +++ app/Models/Prize.php | 9 ++++- database/factories/GalaProjectFactory.php | 4 +- database/factories/PrizeFactory.php | 2 +- ...161914_create_gala_project_prize_table.php | 28 ++++++++++++++ database/seeders/DatabaseSeeder.php | 6 ++- 11 files changed, 94 insertions(+), 42 deletions(-) delete mode 100644 app/Filament/Resources/GalaProjectResource/Pages/CreateGalaProject.php delete mode 100644 app/Filament/Resources/GalaProjectResource/Pages/EditGalaProject.php create mode 100644 app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php create mode 100644 database/migrations/2024_06_18_161914_create_gala_project_prize_table.php diff --git a/app/Filament/Resources/GalaProjectResource.php b/app/Filament/Resources/GalaProjectResource.php index 5b3d9f9c..ae61d33a 100644 --- a/app/Filament/Resources/GalaProjectResource.php +++ b/app/Filament/Resources/GalaProjectResource.php @@ -7,6 +7,7 @@ use App\Enums\OrganizationType; use App\Enums\ProjectArea; use App\Filament\Resources\GalaProjectResource\Pages; +use App\Filament\Resources\GalaProjectResource\RelationManagers\PrizesRelationManager; use App\Forms\Components\Link; use App\Models\Edition; use App\Models\GalaProject; @@ -296,7 +297,7 @@ public static function table(Table $table): Table public static function getRelations(): array { return [ - // + PrizesRelationManager::class, ]; } @@ -304,8 +305,6 @@ public static function getPages(): array { return [ 'index' => Pages\ListGalaProjects::route('/'), - 'create' => Pages\CreateGalaProject::route('/create'), - 'edit' => Pages\EditGalaProject::route('/{record}/edit'), 'view' => Pages\ViewGalaProject::route('/{record}'), ]; } diff --git a/app/Filament/Resources/GalaProjectResource/Pages/CreateGalaProject.php b/app/Filament/Resources/GalaProjectResource/Pages/CreateGalaProject.php deleted file mode 100644 index e601abef..00000000 --- a/app/Filament/Resources/GalaProjectResource/Pages/CreateGalaProject.php +++ /dev/null @@ -1,13 +0,0 @@ -hidden(fn () => ! $this->record->short_list), ]; } + + public function hasCombinedRelationManagerTabsWithForm(): bool + { + return true; + } } diff --git a/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php b/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php new file mode 100644 index 00000000..cb5a6681 --- /dev/null +++ b/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php @@ -0,0 +1,38 @@ +columns([ + Tables\Columns\TextColumn::make('name'), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\AttachAction::make() + ->preloadRecordSelect() + ->recordSelectOptionsQuery(function (Builder $query, $livewire) { + $query->where('edition_id', $livewire->getOwnerRecord()->gala->edition_id); + }), + ]) + ->actions([ + Tables\Actions\DetachAction::make(), + ]); + } +} diff --git a/app/Models/GalaProject.php b/app/Models/GalaProject.php index f55830a3..708805c0 100644 --- a/app/Models/GalaProject.php +++ b/app/Models/GalaProject.php @@ -83,6 +83,11 @@ public function categories(): BelongsToMany return $this->belongsToMany(EditionCategories::class, 'edition_categories_gala_project'); } + public function prizes(): BelongsToMany + { + return $this->belongsToMany(Prize::class); + } + public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() diff --git a/app/Models/Prize.php b/app/Models/Prize.php index 4f203b3e..a6484412 100644 --- a/app/Models/Prize.php +++ b/app/Models/Prize.php @@ -7,6 +7,8 @@ use App\Concerns\BelongsToEdition; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Prize extends Model { @@ -18,8 +20,13 @@ class Prize extends Model 'edition_categories_id', ]; - public function editionCategories() + public function editionCategories(): BelongsTo { return $this->belongsTo(EditionCategories::class); } + + public function galaProjects(): BelongsToMany + { + return $this->belongsToMany(GalaProject::class); + } } diff --git a/database/factories/GalaProjectFactory.php b/database/factories/GalaProjectFactory.php index 53fe07e2..f6c14de5 100644 --- a/database/factories/GalaProjectFactory.php +++ b/database/factories/GalaProjectFactory.php @@ -22,10 +22,10 @@ class GalaProjectFactory extends Factory public function definition(): array { $gala = Gala::query() - ->whereHas('edition', fn ($query) => $query->where('active', true)) ->inRandomOrder() ->first(); - $name = fake()->text('200'); + + $name = fake()->text(200); $slug = Str::slug($name); return [ diff --git a/database/factories/PrizeFactory.php b/database/factories/PrizeFactory.php index 735937a2..c84e4407 100644 --- a/database/factories/PrizeFactory.php +++ b/database/factories/PrizeFactory.php @@ -19,7 +19,7 @@ class PrizeFactory extends Factory public function definition(): array { return [ - 'name' => fake()->text(255), + 'name' => fake()->sentence(), ]; } } diff --git a/database/migrations/2024_06_18_161914_create_gala_project_prize_table.php b/database/migrations/2024_06_18_161914_create_gala_project_prize_table.php new file mode 100644 index 00000000..6ca19059 --- /dev/null +++ b/database/migrations/2024_06_18_161914_create_gala_project_prize_table.php @@ -0,0 +1,28 @@ +id(); + $table->foreignIdFor(GalaProject::class) + ->constrained() + ->cascadeOnDelete(); + $table->foreignIdFor(Prize::class) + ->constrained() + ->cascadeOnDelete(); + }); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 5b354e0e..3a7476d9 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -75,6 +75,10 @@ public function run(): void ->count(1) ->create(); + Edition::factory(['active' => false]) + ->count(3) + ->create(); + Organization::factory() ->count(150) ->approved() @@ -107,7 +111,7 @@ private function seedArticleCategories(): void foreach ($articleCategories as $category) { ArticleCategory::factory() ->name($category) - ->hasArticles(4) + ->hasArticles(4) ->create(); } } From 8de1e83a193554a99404500d5dd485b995d0202b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Jun 2024 10:27:34 +0100 Subject: [PATCH 05/20] fix: issues 4 & 5 --- .../Actions/Page/AddToShortListAction.php | 13 +++++++++++-- .../Actions/Page/MarkAsEligibleAction.php | 11 +++++++++-- .../Actions/Page/MarkAsIneligibleAction.php | 11 +++++++++-- .../Actions/Page/RemoveFromShortListAction.php | 13 +++++++++++-- .../Pages/ViewGalaProject.php | 16 ++++------------ database/factories/GalaFactory.php | 2 ++ lang/ro/edition.php | 6 +++--- 7 files changed, 49 insertions(+), 23 deletions(-) diff --git a/app/Filament/Resources/GalaProjectResource/Actions/Page/AddToShortListAction.php b/app/Filament/Resources/GalaProjectResource/Actions/Page/AddToShortListAction.php index fa8c1576..dd6d14b6 100644 --- a/app/Filament/Resources/GalaProjectResource/Actions/Page/AddToShortListAction.php +++ b/app/Filament/Resources/GalaProjectResource/Actions/Page/AddToShortListAction.php @@ -4,6 +4,7 @@ namespace App\Filament\Resources\GalaProjectResource\Actions\Page; +use App\Models\GalaProject; use Filament\Pages\Actions\Action; class AddToShortListAction extends Action @@ -19,8 +20,16 @@ protected function setUp(): void $this->label(__('edition.actions.add-to-short-list')); - $this->action(function () { - $this->getRecord()->addToShortList(); + $this->color('success'); + + $this->icon('heroicon-s-plus-circle'); + + $this->outlined(); + + $this->action(function (GalaProject $record) { + $record->addToShortList(); }); + + $this->hidden(fn (GalaProject $record) => $record->short_list === true); } } diff --git a/app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsEligibleAction.php b/app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsEligibleAction.php index 52873b9b..2a960567 100644 --- a/app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsEligibleAction.php +++ b/app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsEligibleAction.php @@ -4,6 +4,7 @@ namespace App\Filament\Resources\GalaProjectResource\Actions\Page; +use App\Models\GalaProject; use Filament\Pages\Actions\Action; class MarkAsEligibleAction extends Action @@ -19,8 +20,14 @@ protected function setUp(): void $this->label(__('edition.actions.mark-as-eligible')); - $this->action(function () { - $this->getRecord()->markAsEligible(); + $this->color('success'); + + $this->icon('heroicon-o-check-circle'); + + $this->action(function (GalaProject $record) { + $record->markAsEligible(); }); + + $this->hidden(fn (GalaProject $record) => $record->eligible === true); } } diff --git a/app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsIneligibleAction.php b/app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsIneligibleAction.php index 0f2a35b4..44190957 100644 --- a/app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsIneligibleAction.php +++ b/app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsIneligibleAction.php @@ -4,6 +4,7 @@ namespace App\Filament\Resources\GalaProjectResource\Actions\Page; +use App\Models\GalaProject; use Filament\Pages\Actions\Action; class MarkAsIneligibleAction extends Action @@ -19,8 +20,14 @@ protected function setUp(): void $this->label(__('edition.actions.mark-as-ineligible')); - $this->action(function () { - $this->getRecord()->markAsIneligible(); + $this->color('danger'); + + $this->icon('heroicon-o-x-circle'); + + $this->action(function (GalaProject $record) { + $record->markAsIneligible(); }); + + $this->hidden(fn (GalaProject $record) => $record->eligible === false); } } diff --git a/app/Filament/Resources/GalaProjectResource/Actions/Page/RemoveFromShortListAction.php b/app/Filament/Resources/GalaProjectResource/Actions/Page/RemoveFromShortListAction.php index 22271952..9d9d65e4 100644 --- a/app/Filament/Resources/GalaProjectResource/Actions/Page/RemoveFromShortListAction.php +++ b/app/Filament/Resources/GalaProjectResource/Actions/Page/RemoveFromShortListAction.php @@ -4,6 +4,7 @@ namespace App\Filament\Resources\GalaProjectResource\Actions\Page; +use App\Models\GalaProject; use Filament\Pages\Actions\Action; class RemoveFromShortListAction extends Action @@ -19,8 +20,16 @@ protected function setUp(): void $this->label(__('edition.actions.remove-from-short-list')); - $this->action(function () { - $this->getRecord()->removeFromShortList(); + $this->color('danger'); + + $this->icon('heroicon-s-minus-circle'); + + $this->outlined(); + + $this->action(function (GalaProject $record) { + $record->removeFromShortList(); }); + + $this->hidden(fn (GalaProject $record) => $record->short_list === false); } } diff --git a/app/Filament/Resources/GalaProjectResource/Pages/ViewGalaProject.php b/app/Filament/Resources/GalaProjectResource/Pages/ViewGalaProject.php index 5b37a2b7..68c62b0c 100644 --- a/app/Filament/Resources/GalaProjectResource/Pages/ViewGalaProject.php +++ b/app/Filament/Resources/GalaProjectResource/Pages/ViewGalaProject.php @@ -15,24 +15,16 @@ protected function getActions(): array { return [ GalaProjectResource\Actions\Page\MarkAsEligibleAction::make() - ->record($this->record) - ->disabled(fn () => (bool) $this->record->eligible) - ->hidden(fn () => (bool) $this->record->eligible), + ->record($this->getRecord()), GalaProjectResource\Actions\Page\MarkAsIneligibleAction::make() - ->record($this->record) - ->disabled(fn () => ! $this->record->eligible) - ->hidden(fn () => ! $this->record->eligible), + ->record($this->getRecord()), GalaProjectResource\Actions\Page\AddToShortListAction::make() - ->record($this->record) - ->disabled(fn () => (bool) $this->record->short_list) - ->hidden(fn () => (bool) $this->record->short_list), + ->record($this->getRecord()), GalaProjectResource\Actions\Page\RemoveFromShortListAction::make() - ->record($this->record) - ->disabled(fn () => ! $this->record->short_list) - ->hidden(fn () => ! $this->record->short_list), + ->record($this->getRecord()), ]; } diff --git a/database/factories/GalaFactory.php b/database/factories/GalaFactory.php index d8a249be..a7fcfca0 100644 --- a/database/factories/GalaFactory.php +++ b/database/factories/GalaFactory.php @@ -35,6 +35,8 @@ public function definition(): array 'end_evaluation' => $date->addDays(35), 'start_gale' => $date->addDays(42), 'location' => fake()->text(255), + 'eligible' => fake()->boolean(), + 'short_list' => fake()->boolean(), ]; } diff --git a/lang/ro/edition.php b/lang/ro/edition.php index de56f2a5..2c50cf73 100644 --- a/lang/ro/edition.php +++ b/lang/ro/edition.php @@ -89,9 +89,9 @@ ], 'actions' => [ - 'mark-as-eligible' => 'Marchează eligibilitate', - 'mark-as-ineligible' => 'Marchează ca ne-eligibil', - 'add-to-short-list' => 'Adaugă în Shortlist', + 'mark-as-eligible' => 'Marchează ca eligibil', + 'mark-as-ineligible' => 'Marchează ca neeligibil', + 'add-to-short-list' => 'Adaugă în shortlist', 'remove-from-short-list' => 'Scoate din Shortlist', ], ]; From fb154ad0ee06680ceb2d39f65843886bdb5bd7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Jun 2024 10:43:01 +0100 Subject: [PATCH 06/20] fix: issue 7 --- .../PrizesRelationManager.php | 24 +++++++------------ .../PrizesRelationManager.php | 10 +++++++- database/factories/GalaFactory.php | 2 -- database/factories/GalaProjectFactory.php | 2 ++ .../2024_02_12_134919_create_prizes_table.php | 11 +++++++-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/app/Filament/Resources/EditionsResource/RelationManagers/PrizesRelationManager.php b/app/Filament/Resources/EditionsResource/RelationManagers/PrizesRelationManager.php index 08488ac8..63423250 100644 --- a/app/Filament/Resources/EditionsResource/RelationManagers/PrizesRelationManager.php +++ b/app/Filament/Resources/EditionsResource/RelationManagers/PrizesRelationManager.php @@ -4,12 +4,12 @@ namespace App\Filament\Resources\EditionsResource\RelationManagers; -use App\Models\EditionCategories; use Filament\Forms; use Filament\Resources\Form; use Filament\Resources\RelationManagers\RelationManager; use Filament\Resources\Table; use Filament\Tables; +use Illuminate\Database\Eloquent\Builder; class PrizesRelationManager extends RelationManager { @@ -20,22 +20,19 @@ class PrizesRelationManager extends RelationManager public static function form(Form $form): Form { return $form + ->columns(1) ->schema([ Forms\Components\TextInput::make('name') - ->required() + ->label(__('edition.labels.prize_name')) ->maxLength(255) - ->label(__('edition.labels.prize_name')), + ->required(), Forms\Components\Select::make('edition_categories_id') - ->options( - fn (RelationManager $livewire) => EditionCategories::query() - ->whereBelongsTo($livewire->ownerRecord) - ->get() - ->pluck('name', 'id') - ) ->label(__('edition.labels.category')) - ->columnSpanFull() - ->required() + ->relationship('editionCategories', 'name', function (Builder $query, self $livewire) { + $query->whereBelongsTo($livewire->ownerRecord); + }) + ->searchable() ->preload(), ]); } @@ -49,11 +46,8 @@ public static function table(Table $table): Table ->searchable() ->sortable(), - Tables\Columns\TextColumn::make('edition_categories_id') + Tables\Columns\TextColumn::make('editionCategories.name') ->label(__('edition.labels.category')) - ->formatStateUsing( - fn ($state, $record) => $record->editionCategories()->getParent()->name - ) ->searchable() ->sortable(), ]) diff --git a/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php b/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php index cb5a6681..3e0700b8 100644 --- a/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php +++ b/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php @@ -19,7 +19,15 @@ public static function table(Table $table): Table { return $table ->columns([ - Tables\Columns\TextColumn::make('name'), + Tables\Columns\TextColumn::make('name') + ->label(__('edition.labels.prize_name')) + ->searchable() + ->sortable(), + + Tables\Columns\TextColumn::make('editionCategories.name') + ->label(__('edition.labels.category')) + ->searchable() + ->sortable(), ]) ->filters([ // diff --git a/database/factories/GalaFactory.php b/database/factories/GalaFactory.php index a7fcfca0..d8a249be 100644 --- a/database/factories/GalaFactory.php +++ b/database/factories/GalaFactory.php @@ -35,8 +35,6 @@ public function definition(): array 'end_evaluation' => $date->addDays(35), 'start_gale' => $date->addDays(42), 'location' => fake()->text(255), - 'eligible' => fake()->boolean(), - 'short_list' => fake()->boolean(), ]; } diff --git a/database/factories/GalaProjectFactory.php b/database/factories/GalaProjectFactory.php index f6c14de5..0d8b73c2 100644 --- a/database/factories/GalaProjectFactory.php +++ b/database/factories/GalaProjectFactory.php @@ -55,6 +55,8 @@ public function definition(): array 'phone_number' => fake()->phoneNumber(), 'email' => fake()->email(), ], + 'eligible' => fake()->boolean(), + 'short_list' => fake()->boolean(), ]; } diff --git a/database/migrations/2024_02_12_134919_create_prizes_table.php b/database/migrations/2024_02_12_134919_create_prizes_table.php index 305aea8e..8799b601 100644 --- a/database/migrations/2024_02_12_134919_create_prizes_table.php +++ b/database/migrations/2024_02_12_134919_create_prizes_table.php @@ -17,8 +17,15 @@ public function up(): void { Schema::create('prizes', function (Blueprint $table) { $table->id(); - $table->foreignIdFor(Edition::class); - $table->foreignIdFor(EditionCategories::class); + $table->foreignIdFor(Edition::class) + ->constrained() + ->cascadeOnDelete(); + + $table->foreignIdFor(EditionCategories::class) + ->nullable() + ->constrained() + ->nullOnDelete(); + $table->string('name'); $table->timestamps(); }); From f2454bcc91f95b80385e47e6e0c0a2ba9e798f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Jun 2024 10:52:05 +0100 Subject: [PATCH 07/20] fix: issue 9 --- app/Filament/Resources/GalaProjectResource.php | 11 +++++++++++ lang/ro/edition.php | 1 + 2 files changed, 12 insertions(+) diff --git a/app/Filament/Resources/GalaProjectResource.php b/app/Filament/Resources/GalaProjectResource.php index ae61d33a..7230de7c 100644 --- a/app/Filament/Resources/GalaProjectResource.php +++ b/app/Filament/Resources/GalaProjectResource.php @@ -6,6 +6,7 @@ use App\Enums\OrganizationType; use App\Enums\ProjectArea; +use App\Filament\Forms\Components\Value; use App\Filament\Resources\GalaProjectResource\Pages; use App\Filament\Resources\GalaProjectResource\RelationManagers\PrizesRelationManager; use App\Forms\Components\Link; @@ -55,6 +56,11 @@ public static function form(Form $form): Form { return $form ->schema([ + Value::make('created_at') + ->label(__('edition.labels.created_at')) + ->inlineLabel() + ->withTime(), + Link::make('organizatii') ->type('organization') ->label(__('organization.label.singular')) @@ -243,6 +249,11 @@ public static function table(Table $table): Table ->searchable() ->sortable(), + Tables\Columns\TextColumn::make('created_at') + ->label(__('edition.labels.created_at')) + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('eligible') ->label(__('edition.labels.eligible')) ->formatStateUsing(fn ($state) => ! isset($state) ? '-' : ($state ? __('field.boolean.true') : __('field.boolean.false'))) diff --git a/lang/ro/edition.php b/lang/ro/edition.php index 2c50cf73..00e10312 100644 --- a/lang/ro/edition.php +++ b/lang/ro/edition.php @@ -79,6 +79,7 @@ 'national' => 'Național', ], + 'created_at' => 'Data creării', ], 'project' => [ From 29df7edd3a93de61b11bf3f3677deda5f0c1233d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Jun 2024 11:10:06 +0100 Subject: [PATCH 08/20] fix: issue 11 --- app/Filament/Resources/GalaProjectResource.php | 9 ++++++--- lang/ro/edition.php | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/GalaProjectResource.php b/app/Filament/Resources/GalaProjectResource.php index 7230de7c..e77fb7c4 100644 --- a/app/Filament/Resources/GalaProjectResource.php +++ b/app/Filament/Resources/GalaProjectResource.php @@ -216,6 +216,11 @@ public static function table(Table $table): Table return $table ->columns([ + Tables\Columns\TextColumn::make('id') + ->label(__('edition.labels.id')) + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('name') ->label(__('edition.project.label.plural')) ->searchable() @@ -300,9 +305,7 @@ public static function table(Table $table): Table Tables\Actions\DeleteAction::make(), ]), ]) - ->bulkActions([ - Tables\Actions\DeleteBulkAction::make(), - ]); + ->defaultSort('id', 'desc'); } public static function getRelations(): array diff --git a/lang/ro/edition.php b/lang/ro/edition.php index 00e10312..5e7eabe5 100644 --- a/lang/ro/edition.php +++ b/lang/ro/edition.php @@ -80,6 +80,7 @@ ], 'created_at' => 'Data creării', + 'id' => 'ID', ], 'project' => [ From 708fef53060e26198139be2c97d32fd5a5e1f065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Jun 2024 11:26:39 +0100 Subject: [PATCH 09/20] fix: sentry error --- app/Console/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3f462ca2..e69ee986 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -21,7 +21,7 @@ protected function schedule(Schedule $schedule): void $schedule->job(ProcessAuthorizedTransactionsJob::class) ->everyFourHours() ->onOneServer() - ->sentryMonitor(); + ->sentryMonitor('process-authorized-transactions-job'); } /** From 33bcceff12b6a8782c6f5b9b14b4a4daac03e58b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Jun 2024 11:53:25 +0100 Subject: [PATCH 10/20] fix: issue 2 --- .../Resources/GalaProjectResource.php | 30 +++------ app/Models/GalaProject.php | 8 +++ composer.json | 1 + composer.lock | 67 ++++++++++++++++++- database/factories/EditionFactory.php | 2 +- 5 files changed, 86 insertions(+), 22 deletions(-) diff --git a/app/Filament/Resources/GalaProjectResource.php b/app/Filament/Resources/GalaProjectResource.php index e77fb7c4..45de2bf3 100644 --- a/app/Filament/Resources/GalaProjectResource.php +++ b/app/Filament/Resources/GalaProjectResource.php @@ -10,7 +10,6 @@ use App\Filament\Resources\GalaProjectResource\Pages; use App\Filament\Resources\GalaProjectResource\RelationManagers\PrizesRelationManager; use App\Forms\Components\Link; -use App\Models\Edition; use App\Models\GalaProject; use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\Select; @@ -47,10 +46,10 @@ public static function getPluralLabel(): string return __('edition.project.label.plural'); } - public static function getEloquentQuery(): Builder - { - return parent::getEloquentQuery()->with(['gala']); - } + // public static function getEloquentQuery(): Builder + // { + // return parent::getEloquentQuery()->with(['gala']); + // } public static function form(Form $form): Form { @@ -212,8 +211,6 @@ function (Builder $query, GalaProject $record) { public static function table(Table $table): Table { - $editions = Edition::all(); - return $table ->columns([ Tables\Columns\TextColumn::make('id') @@ -230,8 +227,7 @@ public static function table(Table $table): Table Tables\Columns\TextColumn::make('categories.name') ->label(__('edition.labels.category')) ->searchable() - ->wrap() - ->sortable(), + ->wrap(), Tables\Columns\TextColumn::make('youth') ->label(__('edition.labels.youth')) @@ -239,13 +235,9 @@ public static function table(Table $table): Table ->searchable() ->sortable(), - Tables\Columns\TextColumn::make('gala.edition.title') - ->label(__('edition.label.singular')) - ->searchable() - ->sortable(), - Tables\Columns\TextColumn::make('gala.title') ->label(__('edition.labels.gala')) + ->description(fn ($record) => $record->gala->edition->title) ->searchable() ->sortable(), @@ -274,12 +266,7 @@ public static function table(Table $table): Table ->filters([ SelectFilter::make('edition_id') ->label(__('edition.label.singular')) - ->options($editions->pluck('title', 'id')->toArray()) -// ->query( -// function ($query, $values) { -// dd($values); -// } -// ) + ->relationship('edition', 'title') ->multiple(), SelectFilter::make('galas') @@ -305,6 +292,9 @@ public static function table(Table $table): Table Tables\Actions\DeleteAction::make(), ]), ]) + ->bulkActions([ + // + ]) ->defaultSort('id', 'desc'); } diff --git a/app/Models/GalaProject.php b/app/Models/GalaProject.php index 708805c0..38a2be27 100644 --- a/app/Models/GalaProject.php +++ b/app/Models/GalaProject.php @@ -16,6 +16,8 @@ use Spatie\Activitylog\Traits\LogsActivity; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; +use Znck\Eloquent\Relations\BelongsToThrough; +use Znck\Eloquent\Traits\BelongsToThrough as BelongsToThroughTrait; class GalaProject extends Model implements HasMedia { @@ -27,6 +29,7 @@ class GalaProject extends Model implements HasMedia use InteractsWithMedia; use HasProjectStatus; use LogsActivity; + use BelongsToThroughTrait; protected $fillable = [ 'gala_id', @@ -78,6 +81,11 @@ public function gala(): BelongsTo return $this->belongsTo(Gala::class); } + public function edition(): BelongsToThrough + { + return $this->belongsToThrough(Edition::class, Gala::class); + } + public function categories(): BelongsToMany { return $this->belongsToMany(EditionCategories::class, 'edition_categories_gala_project'); diff --git a/composer.json b/composer.json index 38e9ad67..e703ae84 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "spatie/laravel-medialibrary": "^10.11", "spatie/laravel-newsletter": "^5.1", "spatie/laravel-query-builder": "^5.3", + "staudenmeir/belongs-to-through": "^2.15", "staudenmeir/eloquent-has-many-deep": "^1.19", "stevegrunwell/time-constants": "^1.1", "tightenco/ziggy": "^1.8", diff --git a/composer.lock b/composer.lock index 29332d89..ac3b0dbf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ab33858d8c11aad41f7097a25e4130f0", + "content-hash": "769c814a90bba2aae9aa864ad1278d09", "packages": [ { "name": "akaunting/laravel-money", @@ -7995,6 +7995,71 @@ ], "time": "2023-12-25T11:46:58+00:00" }, + { + "name": "staudenmeir/belongs-to-through", + "version": "v2.15.1", + "source": { + "type": "git", + "url": "https://github.com/staudenmeir/belongs-to-through.git", + "reference": "002b2eab60c03a41c0be709710300d22776b07a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/staudenmeir/belongs-to-through/zipball/002b2eab60c03a41c0be709710300d22776b07a5", + "reference": "002b2eab60c03a41c0be709710300d22776b07a5", + "shasum": "" + }, + "require": { + "illuminate/database": "^10.0", + "php": "^8.1" + }, + "require-dev": { + "barryvdh/laravel-ide-helper": "^2.13", + "orchestra/testbench": "^8.17", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.1" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Staudenmeir\\BelongsToThrough\\IdeHelperServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Znck\\Eloquent\\": "src/", + "Staudenmeir\\BelongsToThrough\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rahul Kadyan", + "email": "hi@znck.me" + }, + { + "name": "Jonas Staudenmeir", + "email": "mail@jonas-staudenmeir.de" + } + ], + "description": "Laravel Eloquent BelongsToThrough relationships", + "support": { + "issues": "https://github.com/staudenmeir/belongs-to-through/issues", + "source": "https://github.com/staudenmeir/belongs-to-through/tree/v2.15.1" + }, + "funding": [ + { + "url": "https://paypal.me/JonasStaudenmeir", + "type": "custom" + } + ], + "time": "2023-12-19T11:58:06+00:00" + }, { "name": "staudenmeir/eloquent-has-many-deep", "version": "v1.19.3", diff --git a/database/factories/EditionFactory.php b/database/factories/EditionFactory.php index 0d93c693..2418ecae 100644 --- a/database/factories/EditionFactory.php +++ b/database/factories/EditionFactory.php @@ -38,7 +38,7 @@ public function configure() { return $this->afterCreating(function (Edition $edition) { EditionCategories::factory() - ->count(2) + ->count(5) ->for($edition) ->create(); From a14873fb2255338b872666585123ca26e963089e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Jun 2024 11:59:23 +0100 Subject: [PATCH 11/20] fix: issue 12 --- .../js/Pages/Public/Regional/Regional.vue | 80 ++++++++++--------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/resources/js/Pages/Public/Regional/Regional.vue b/resources/js/Pages/Public/Regional/Regional.vue index 7913e286..ac807061 100644 --- a/resources/js/Pages/Public/Regional/Regional.vue +++ b/resources/js/Pages/Public/Regional/Regional.vue @@ -4,10 +4,12 @@ -
+

@@ -57,22 +59,22 @@

-
+

-
+

@@ -86,10 +88,10 @@

-
+

@@ -103,10 +105,10 @@

-
+

-
+

-
+

@@ -144,7 +146,7 @@

-
+
@@ -153,30 +155,30 @@ From fb9c2e99e7dab835fd8001920dc0efef47ea0550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Jun 2024 14:42:22 +0100 Subject: [PATCH 12/20] Revert "fix: sentry error" This reverts commit 708fef53060e26198139be2c97d32fd5a5e1f065. --- app/Console/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e69ee986..3f462ca2 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -21,7 +21,7 @@ protected function schedule(Schedule $schedule): void $schedule->job(ProcessAuthorizedTransactionsJob::class) ->everyFourHours() ->onOneServer() - ->sentryMonitor('process-authorized-transactions-job'); + ->sentryMonitor(); } /** From 3c643fcd54c604e51746419b2cdb0c869355a3fa Mon Sep 17 00:00:00 2001 From: alexPopaCode4 <156655986+alexPopaCode4@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:05:56 +0300 Subject: [PATCH 13/20] Dev fix prize tab translate (#376) fix prize tab translate --- .../RelationManagers/PrizesRelationManager.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php b/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php index 3e0700b8..dd7faf14 100644 --- a/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php +++ b/app/Filament/Resources/GalaProjectResource/RelationManagers/PrizesRelationManager.php @@ -43,4 +43,9 @@ public static function table(Table $table): Table Tables\Actions\DetachAction::make(), ]); } + + public static function getTitle(): string + { + return __('edition.labels.prizes_tab'); + } } From 07c1f8602c4dd7645c88fa0f845c8a8cfddbb7f8 Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe Date: Mon, 1 Jul 2024 10:35:43 +0300 Subject: [PATCH 14/20] wip --- app/Enums/ProjectArea.php | 1 - ...ntroller.php => GalaProjectController.php} | 8 +- app/Models/GalaProject.php | 4 +- database/factories/GalaFactory.php | 3 +- ...ault_false_short_list_to_gala_projects.php | 28 +++ lang/ro.json | 2 +- resources/js/Components/cards/ProjectCard.vue | 4 +- .../js/Components/cards/RegionalProject.vue | 29 ++- resources/js/Layouts/DashboardLayout.vue | 200 +++++++++--------- .../js/Pages/AdminOng/GalaProjects/Add.vue | 6 +- .../js/Pages/AdminOng/GalaProjects/Edit.vue | 2 +- .../Pages/AdminOng/GalaProjects/Projects.vue | 2 +- .../Pages/AdminOng/Projects/EditProject.vue | 2 +- .../js/Pages/AdminOng/Projects/Projects.vue | 48 ++--- .../js/Pages/Public/Regional/Regional.vue | 54 ++--- routes/dashboard.php | 10 +- 16 files changed, 217 insertions(+), 186 deletions(-) rename app/Http/Controllers/Dashboard/{RegionalProjectController.php => GalaProjectController.php} (93%) create mode 100644 database/migrations/2024_06_28_160124_set_default_false_short_list_to_gala_projects.php diff --git a/app/Enums/ProjectArea.php b/app/Enums/ProjectArea.php index e28cb9cd..ef1f1e36 100644 --- a/app/Enums/ProjectArea.php +++ b/app/Enums/ProjectArea.php @@ -16,7 +16,6 @@ enum ProjectArea: string case LOCAL = 'local'; case REGIONAL = 'regional'; - case NATIONAL = 'national'; public function labelKeyPrefix(): string { diff --git a/app/Http/Controllers/Dashboard/RegionalProjectController.php b/app/Http/Controllers/Dashboard/GalaProjectController.php similarity index 93% rename from app/Http/Controllers/Dashboard/RegionalProjectController.php rename to app/Http/Controllers/Dashboard/GalaProjectController.php index 8932b37d..81a00d85 100644 --- a/app/Http/Controllers/Dashboard/RegionalProjectController.php +++ b/app/Http/Controllers/Dashboard/GalaProjectController.php @@ -19,7 +19,7 @@ use Illuminate\Http\Request; use Inertia\Inertia; -class RegionalProjectController extends Controller +class GalaProjectController extends Controller { /** * Display a listing of the resource. @@ -71,7 +71,7 @@ public function store(StoreRequest $request) }); return redirect() - ->route('dashboard.projects.regional.edit', $project->id) + ->route('dashboard.projects.gala.edit', $project->slug) ->with('success', __('regional_projects.created')); } @@ -100,9 +100,9 @@ public function edit(GalaProject $project) /** * Update the specified resource in storage. */ - public function update(Request $request, RegionalProject $project) + public function update(Request $request, GalaProject $project) { -// $this->authorize('editAsNgo', $project);; + $this->authorize('editAsNgo', $project);; if ($request->has('counties')) { $project->counties()->sync(collect($request->get('counties'))->pluck('id')); } diff --git a/app/Models/GalaProject.php b/app/Models/GalaProject.php index 38a2be27..83ada486 100644 --- a/app/Models/GalaProject.php +++ b/app/Models/GalaProject.php @@ -65,8 +65,8 @@ class GalaProject extends Model implements HasMedia ]; protected $casts = [ - 'start_date' => 'date', - 'end_date' => 'date', + 'start_date' => 'date:Y-m-d', + 'end_date' => 'date:Y-m-d', 'youth' => 'boolean', 'partnership' => 'boolean', 'eligible' => 'boolean', diff --git a/database/factories/GalaFactory.php b/database/factories/GalaFactory.php index d8a249be..7add8c07 100644 --- a/database/factories/GalaFactory.php +++ b/database/factories/GalaFactory.php @@ -7,6 +7,7 @@ use App\Models\County; use App\Models\Gala; use Carbon\Carbon; +use Carbon\CarbonImmutable; use Illuminate\Database\Eloquent\Factories\Factory; /** @@ -21,7 +22,7 @@ class GalaFactory extends Factory */ public function definition(): array { - $date = Carbon::createFromInterface(fake()->dateTimeBetween('-1 week', '5 weeks')); + $date = CarbonImmutable::createFromInterface(fake()->dateTimeBetween('-1 week', '1 week')); return [ 'title' => fake()->text(25), diff --git a/database/migrations/2024_06_28_160124_set_default_false_short_list_to_gala_projects.php b/database/migrations/2024_06_28_160124_set_default_false_short_list_to_gala_projects.php new file mode 100644 index 00000000..68586e5b --- /dev/null +++ b/database/migrations/2024_06_28_160124_set_default_false_short_list_to_gala_projects.php @@ -0,0 +1,28 @@ +boolean('short_list')->default(false)->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('gala_projects', function (Blueprint $table) { + + }); + } +}; diff --git a/lang/ro.json b/lang/ro.json index a421d037..6ba3219c 100644 --- a/lang/ro.json +++ b/lang/ro.json @@ -515,7 +515,7 @@ "regional.project.project_team": "Cum a fost organizată echipa proiectului? Câți oameni ați fost, ce roluri ați avut?*", "regional.project.preview_image": "Încarcă o poză reprezentativă despre proiect* (această informație va fi listată pe site)", "regional.project.gallery": "Dacă doriți să împărtășiți cu noi diverse alte materiale, e momentul să le încărcați aici*.", - "regional.project.contact_info_details": "Linkuri externe. Orice link legat de proiect trebuie să conțină și https://", + "regional.project.contact_info_details": "Detalii de contact", "regional.project.contact_info": "Persoana de contact", "regional.project.contact_info_person": "Nume si prenume persoană de contact*", "regional.project.contact_info_job": "Funcția persoanei de contact în organizație*", diff --git a/resources/js/Components/cards/ProjectCard.vue b/resources/js/Components/cards/ProjectCard.vue index a53a2fca..8ba3e526 100644 --- a/resources/js/Components/cards/ProjectCard.vue +++ b/resources/js/Components/cards/ProjectCard.vue @@ -97,7 +97,7 @@ {{ $t('edit') }} @@ -188,7 +188,7 @@ const form = useForm({ const changeProjectStatus = (id, status, type) => { let tmpRoute = - type === 'regional' ? route('dashboard.projects.regional.status', id) : route('dashboard.projects.status', id); + type === 'regional' ? route('dashboard.projects.gala.status', id) : route('dashboard.projects.status', id); form.status = status; console.log(form); if (confirm(trans('project_change_status_' + status))) { diff --git a/resources/js/Components/cards/RegionalProject.vue b/resources/js/Components/cards/RegionalProject.vue index c9d52faa..2c7e6316 100644 --- a/resources/js/Components/cards/RegionalProject.vue +++ b/resources/js/Components/cards/RegionalProject.vue @@ -41,29 +41,36 @@
-
+
{{ $t('see') }} + + + {{ $t('edit') }} +
diff --git a/resources/js/Layouts/DashboardLayout.vue b/resources/js/Layouts/DashboardLayout.vue index 7727d180..43cfa66b 100644 --- a/resources/js/Layouts/DashboardLayout.vue +++ b/resources/js/Layouts/DashboardLayout.vue @@ -67,109 +67,109 @@ diff --git a/resources/js/Pages/AdminOng/GalaProjects/Add.vue b/resources/js/Pages/AdminOng/GalaProjects/Add.vue index 57380f50..a3e6f2b7 100644 --- a/resources/js/Pages/AdminOng/GalaProjects/Add.vue +++ b/resources/js/Pages/AdminOng/GalaProjects/Add.vue @@ -340,14 +340,10 @@ const form = useForm({ let selectedCounties = []; const props = defineProps(['projectCategories', 'counties', 'galaTitle', 'areas', 'galaId', 'organizationTypes']); -onMounted(() => { - console.log(props.areas); -}); - /** Create project. */ const createProject = (status = 'in_review') => { form.gala_id = props.galaId; - form.post(route('dashboard.projects.regional.store'), { + form.post(route('dashboard.projects.gala.store'), { preserveScroll: true, onError: () => {}, }); diff --git a/resources/js/Pages/AdminOng/GalaProjects/Edit.vue b/resources/js/Pages/AdminOng/GalaProjects/Edit.vue index 24a8751e..bc3421e7 100644 --- a/resources/js/Pages/AdminOng/GalaProjects/Edit.vue +++ b/resources/js/Pages/AdminOng/GalaProjects/Edit.vue @@ -519,6 +519,6 @@ const editField = (field) => { let newForm = useForm({ [field]: form[field], }); - newForm.post(route('dashboard.projects.regional.update', project.value.id)); + newForm.post(route('dashboard.projects.gala.update', project.value.id)); }; diff --git a/resources/js/Pages/AdminOng/GalaProjects/Projects.vue b/resources/js/Pages/AdminOng/GalaProjects/Projects.vue index 808eaac1..e77190cf 100644 --- a/resources/js/Pages/AdminOng/GalaProjects/Projects.vue +++ b/resources/js/Pages/AdminOng/GalaProjects/Projects.vue @@ -17,7 +17,7 @@ >

diff --git a/resources/js/Pages/AdminOng/Projects/EditProject.vue b/resources/js/Pages/AdminOng/Projects/EditProject.vue index dae6fbbe..11fe60b0 100644 --- a/resources/js/Pages/AdminOng/Projects/EditProject.vue +++ b/resources/js/Pages/AdminOng/Projects/EditProject.vue @@ -616,7 +616,7 @@ const hasPendingChanges = (field) => { const changeProjectStatus = (id, status, type) => { let tmpRoute = - type === 'regional' ? route('dashboard.projects.regional.status', id) : route('dashboard.projects.status', id); + type === 'regional' ? route('dashboard.projects.gala.status', id) : route('dashboard.projects.status', id); if (confirm(trans('project_change_status_publish'))) { formChangeStatus.post(tmpRoute, { preserveScroll: true, diff --git a/resources/js/Pages/AdminOng/Projects/Projects.vue b/resources/js/Pages/AdminOng/Projects/Projects.vue index 39596e26..e181f892 100644 --- a/resources/js/Pages/AdminOng/Projects/Projects.vue +++ b/resources/js/Pages/AdminOng/Projects/Projects.vue @@ -13,8 +13,8 @@ @@ -32,26 +32,26 @@ diff --git a/resources/js/Pages/Public/Regional/Regional.vue b/resources/js/Pages/Public/Regional/Regional.vue index ac807061..b6f5dd90 100644 --- a/resources/js/Pages/Public/Regional/Regional.vue +++ b/resources/js/Pages/Public/Regional/Regional.vue @@ -21,7 +21,7 @@ />

@@ -155,30 +155,30 @@ diff --git a/routes/dashboard.php b/routes/dashboard.php index 7b431282..161adb14 100644 --- a/routes/dashboard.php +++ b/routes/dashboard.php @@ -5,7 +5,7 @@ use App\Http\Controllers\Dashboard\DonationController; use App\Http\Controllers\Dashboard\OrganizationController; use App\Http\Controllers\Dashboard\ProjectController; -use App\Http\Controllers\Dashboard\RegionalProjectController; +use App\Http\Controllers\Dashboard\GalaProjectController; use App\Http\Controllers\Dashboard\TicketController; use App\Http\Controllers\Dashboard\UserController; use App\Http\Controllers\Dashboard\VolunteerController; @@ -42,14 +42,14 @@ Route::post('/{project}', 'update')->name('update'); Route::group([ - 'prefix' => 'regional', - 'as' => 'regional.', - 'controller' => RegionalProjectController::class, + 'prefix' => 'gala', + 'as' => 'gala.', + 'controller' => GalaProjectController::class, ], function () { Route::get('/', 'index')->name('index'); Route::get('/{gala}/create', 'create')->name('create'); Route::post('/store', 'store')->name('store'); - Route::get('/{project}/edit', 'edit')->name('edit'); + Route::get('/{project:slug}/edit', 'edit')->name('edit'); Route::post('/{project}/status', 'changeStatus')->name('status'); Route::put('/{project}', 'update')->name('update'); }); From a67406eb67fe32464d8f94df8ad79a49d387477c Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe Date: Mon, 1 Jul 2024 10:48:39 +0300 Subject: [PATCH 15/20] wip --- app/Http/Controllers/Dashboard/GalaProjectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Dashboard/GalaProjectController.php b/app/Http/Controllers/Dashboard/GalaProjectController.php index 81a00d85..92464139 100644 --- a/app/Http/Controllers/Dashboard/GalaProjectController.php +++ b/app/Http/Controllers/Dashboard/GalaProjectController.php @@ -102,7 +102,7 @@ public function edit(GalaProject $project) */ public function update(Request $request, GalaProject $project) { - $this->authorize('editAsNgo', $project);; + $this->authorize('editAsNgo', $project); if ($request->has('counties')) { $project->counties()->sync(collect($request->get('counties'))->pluck('id')); } From 91f59690f7771a7aceea1dda70c88930c0df8c5a Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe Date: Wed, 3 Jul 2024 10:37:13 +0300 Subject: [PATCH 16/20] fix image gala --- app/Filament/Resources/GalaProjectResource.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Filament/Resources/GalaProjectResource.php b/app/Filament/Resources/GalaProjectResource.php index 45de2bf3..7e9deaa2 100644 --- a/app/Filament/Resources/GalaProjectResource.php +++ b/app/Filament/Resources/GalaProjectResource.php @@ -13,6 +13,7 @@ use App\Models\GalaProject; use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\Select; +use Filament\Forms\Components\SpatieMediaLibraryFileUpload; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; @@ -126,6 +127,15 @@ function (Builder $query, GalaProject $record) { ->inlineLabel() ->required(), + SpatieMediaLibraryFileUpload::make('regionalProjectFiles') + ->label(__('project.labels.gallery')) + ->collection('regionalProjectFiles') + ->inlineLabel() + ->disk(config('filesystems.default_public')) + ->image() + ->multiple() + ->maxFiles(20), + Toggle::make('youth') ->label(__('edition.labels.youth_project')) ->inlineLabel() From 5f421c8c47804bf6aad9ec3592075cced23bcaea Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe Date: Thu, 4 Jul 2024 03:55:03 +0300 Subject: [PATCH 17/20] Fix display gala project in organization dashboard page Fix display logic Fix update gala project --- app/Concerns/Enums/Comparable.php | 1 + app/Enums/GalaProjectStatus.php | 24 ++ .../Resources/GalaProjectResource.php | 6 + .../Dashboard/GalaProjectController.php | 27 +- ...ionalController.php => GalaController.php} | 113 +------- ...ntroller.php => GalaProjectController.php} | 2 +- .../Resources/GalaProject/ShowResource.php | 57 ++++ .../Resources/GalaProjectCardResource.php | 10 +- app/Models/GalaProject.php | 11 +- app/Policies/GalaProjectPolicy.php | 38 +++ app/Services/ProjectService.php | 10 + ...add_status_updated_at_to_gala_projects.php | 32 +++ .../js/Components/cards/RegionalProject.vue | 71 +++-- .../js/Pages/AdminOng/GalaProjects/Edit.vue | 17 +- .../js/Pages/AdminOng/GalaProjects/View.vue | 257 ++++++++++++++++++ routes/dashboard.php | 26 +- routes/regional.php | 11 +- 17 files changed, 526 insertions(+), 187 deletions(-) create mode 100644 app/Enums/GalaProjectStatus.php rename app/Http/Controllers/{RegionalController.php => GalaController.php} (61%) rename app/Http/Controllers/{RegionalProjectController.php => GalaProjectController.php} (85%) create mode 100644 app/Http/Resources/GalaProject/ShowResource.php create mode 100644 app/Policies/GalaProjectPolicy.php create mode 100644 database/migrations/2024_07_03_135808_add_default_for_status_add_status_updated_at_to_gala_projects.php create mode 100644 resources/js/Pages/AdminOng/GalaProjects/View.vue diff --git a/app/Concerns/Enums/Comparable.php b/app/Concerns/Enums/Comparable.php index efefc281..1c871899 100644 --- a/app/Concerns/Enums/Comparable.php +++ b/app/Concerns/Enums/Comparable.php @@ -11,6 +11,7 @@ trait Comparable */ public function is(mixed $enum): bool { + if ($enum instanceof static) { return $this->value === $enum->value; } diff --git a/app/Enums/GalaProjectStatus.php b/app/Enums/GalaProjectStatus.php new file mode 100644 index 00000000..b860b388 --- /dev/null +++ b/app/Enums/GalaProjectStatus.php @@ -0,0 +1,24 @@ +where('status', GalaProjectStatus::publish); + } + public static function getPages(): array { return [ diff --git a/app/Http/Controllers/Dashboard/GalaProjectController.php b/app/Http/Controllers/Dashboard/GalaProjectController.php index 92464139..b5d2c5ca 100644 --- a/app/Http/Controllers/Dashboard/GalaProjectController.php +++ b/app/Http/Controllers/Dashboard/GalaProjectController.php @@ -10,7 +10,6 @@ use App\Http\Requests\RegionalProject\StoreRequest; use App\Http\Resources\Edition\EditionShowResource; use App\Http\Resources\GalaProjectCardResource; -use App\Models\County; use App\Models\Edition; use App\Models\Gala; use App\Models\GalaProject; @@ -78,9 +77,14 @@ public function store(StoreRequest $request) /** * Display the specified resource. */ - public function show(string $id) + public function show(GalaProject $project) { - // + $this->authorize('view', $project); + $project->load('media'); + + return Inertia::render('AdminOng/GalaProjects/View', [ + 'project' => $project, + ]); } /** @@ -88,11 +92,12 @@ public function show(string $id) */ public function edit(GalaProject $project) { + $this->authorize('update', $project); $project->load('media'); return Inertia::render('AdminOng/GalaProjects/Edit', [ 'project' => $project, - 'counties' => County::get(['name', 'id']), + 'counties' => $project->gala->counties()->get(['name', 'counties.id']), 'projectCategories' => ProjectCategory::get(['name', 'id']), ]); } @@ -102,7 +107,7 @@ public function edit(GalaProject $project) */ public function update(Request $request, GalaProject $project) { - $this->authorize('editAsNgo', $project); + $this->authorize('update', $project); if ($request->has('counties')) { $project->counties()->sync(collect($request->get('counties'))->pluck('id')); } @@ -112,18 +117,10 @@ public function update(Request $request, GalaProject $project) ->with('success', __('project.project_updated')); } - /** - * Remove the specified resource from storage. - */ - public function destroy(string $id) - { - // - } - - public function changeStatus(Request $request, string $id) + public function changeStatus(Request $request, GalaProject $project) { try { - (new ProjectService(RegionalProject::class))->changeStatus($id, $request->get('status')); + (new ProjectService(GalaProject::class))->changeStatus($project, $request->get('status')); } catch (\Exception $exception) { return redirect()->back() ->with('error', $exception->getMessage()); diff --git a/app/Http/Controllers/RegionalController.php b/app/Http/Controllers/GalaController.php similarity index 61% rename from app/Http/Controllers/RegionalController.php rename to app/Http/Controllers/GalaController.php index ec5c9bdb..f6afb025 100644 --- a/app/Http/Controllers/RegionalController.php +++ b/app/Http/Controllers/GalaController.php @@ -7,14 +7,16 @@ use App\Http\Resources\Articles\ArticleCardResource; use App\Http\Resources\Edition\EditionShowResource; use App\Http\Resources\Edition\GalaShowResource; +use App\Http\Resources\GalaProject\ShowResource; use App\Models\Edition; use App\Models\EditionCategories; use App\Models\Gala; +use App\Models\GalaProject; use App\Models\Project; use Illuminate\Support\Facades\Request; use Inertia\Inertia; -class RegionalController extends Controller +class GalaController extends Controller { public function index() { @@ -133,117 +135,12 @@ public function gala(Gala $gala, Request $request) 'gala' => GalaShowResource::make($gala), 'categories' => $categories, ]); - } - public function project(Project $project) + public function project(GalaProject $project) { - $gallery = [ - [ - 'src' => 'https://youtu.be/f-t2nWVauSE', - 'type' => 'video', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => 'https://youtu.be/f-t2nWVauSE', - 'type' => 'video', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => 'https://youtu.be/f-t2nWVauSE', - 'type' => 'video', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => 'https://youtu.be/f-t2nWVauSE', - 'type' => 'video', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => 'https://youtu.be/f-t2nWVauSE', - 'type' => 'video', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'video', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'video', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'video', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - [ - 'src' => '/images/project_img.png', - 'type' => 'image', - ], - ]; - return Inertia::render('Public/Regional/Project', [ - 'project' => $project, - 'gallery' => $gallery, + 'project' => new ShowResource($project), ]); } diff --git a/app/Http/Controllers/RegionalProjectController.php b/app/Http/Controllers/GalaProjectController.php similarity index 85% rename from app/Http/Controllers/RegionalProjectController.php rename to app/Http/Controllers/GalaProjectController.php index cfadcb0e..3448fcdf 100644 --- a/app/Http/Controllers/RegionalProjectController.php +++ b/app/Http/Controllers/GalaProjectController.php @@ -4,7 +4,7 @@ namespace App\Http\Controllers; -class RegionalProjectController extends Controller +class GalaProjectController extends Controller { /** * Display a listing of the resource. diff --git a/app/Http/Resources/GalaProject/ShowResource.php b/app/Http/Resources/GalaProject/ShowResource.php new file mode 100644 index 00000000..9076199c --- /dev/null +++ b/app/Http/Resources/GalaProject/ShowResource.php @@ -0,0 +1,57 @@ + + */ + public static $wrap = null; + + public function toArray(Request $request): array + { + return [ + + 'organization' => [ + 'name' => $this->organization->name, + 'id' => $this->organization->id, + ], + 'name' => $this->name, + 'slug' => $this->slug, + 'description' => $this->description, + 'start_date' => $this->start_date, + 'end_date' => $this->end_date, + 'areas' => $this->area, + 'youth' => $this->youth ? __('field.boolean.true') : __('field.boolean.false'), + 'organization_type' => $this->organization_type->label(), + 'reason' => $this->reason, + 'solution' => $this->solution, + 'project_details' => $this->project_details, + 'special' => $this->special, + 'is_draft' => $this->isDraft(), + 'results' => $this->results, + 'proud' => $this->proud, + 'partnership' => $this->partnership ? __('field.boolean.true') : __('field.boolean.false'), + 'partnership_details' => $this->partnership_details, + 'budget_details' => $this->budget_details, + 'participants' => $this->participants, + 'team_details' => $this->team_details, + 'contact' => $this->contact, + 'status' => $this->status->label(), + 'eligible' => $this->eligible ? __('field.boolean.true') : __('field.boolean.false'), + 'short_list' => $this->short_list ? __('field.boolean.true') : __('field.boolean.false'), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + + ]; + } + +} diff --git a/app/Http/Resources/GalaProjectCardResource.php b/app/Http/Resources/GalaProjectCardResource.php index 99fa1b69..83791ff7 100644 --- a/app/Http/Resources/GalaProjectCardResource.php +++ b/app/Http/Resources/GalaProjectCardResource.php @@ -14,16 +14,20 @@ public function toArray(Request $request): array { return [ 'id' => $this->id, - 'type' => 'project', + 'type' => 'gala_project', 'name' => $this->name, 'slug' => $this->slug, - 'county' => $this->counties->pluck('name')->join(', '), // $this->county?->name, - 'image' => $this->getFirstMediaUrl('preview'), + 'counties' => $this->counties->pluck('name')->join(', '), // $this->county?->name, + 'counties_count' => $this->counties->count(), + 'image' => $this->getFirstMediaUrl('regionalProjectFiles'), 'organization' => [ 'name' => $this->organization->name, 'slug' => $this->organization->slug, 'id' => $this->organization->id, ], + 'categories' => $this->categories->pluck('name')->join(', '), + 'is_draft' => $this->isDraft(), + ]; } } diff --git a/app/Models/GalaProject.php b/app/Models/GalaProject.php index 83ada486..d6a18843 100644 --- a/app/Models/GalaProject.php +++ b/app/Models/GalaProject.php @@ -7,7 +7,8 @@ use App\Concerns\BelongsToOrganization; use App\Concerns\HasCounties; use App\Concerns\HasSlug; -use App\Traits\HasProjectStatus; +use App\Enums\GalaProjectStatus; +use App\Enums\OrganizationType; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -27,7 +28,6 @@ class GalaProject extends Model implements HasMedia use BelongsToOrganization; use HasCounties; use InteractsWithMedia; - use HasProjectStatus; use LogsActivity; use BelongsToThroughTrait; @@ -72,6 +72,8 @@ class GalaProject extends Model implements HasMedia 'eligible' => 'boolean', 'short_list' => 'boolean', 'contact' => 'array', + 'status' => GalaProjectStatus::class, + 'organization_type' => OrganizationType::class, ]; public string $slugFieldSource = 'name'; @@ -123,4 +125,9 @@ public function removeFromShortList(): bool { return $this->update(['short_list' => 0]); } + + public function isDraft(): bool + { + return $this->status->value === GalaProjectStatus::draft->value; + } } diff --git a/app/Policies/GalaProjectPolicy.php b/app/Policies/GalaProjectPolicy.php new file mode 100644 index 00000000..da013f3b --- /dev/null +++ b/app/Policies/GalaProjectPolicy.php @@ -0,0 +1,38 @@ +isSuperAdmin()) { + return true; + } + + return $user->belongsToOrganization($project->organization); + } + + public function update(User $user, GalaProject $project): bool + { + if ($user->isSuperAdmin()) { + return true; + } + + if (! $project->isDraft()) { + return false; + } + + return $user->belongsToOrganization($project->organization); + } +} diff --git a/app/Services/ProjectService.php b/app/Services/ProjectService.php index 64c5477d..f6d2f72f 100644 --- a/app/Services/ProjectService.php +++ b/app/Services/ProjectService.php @@ -4,6 +4,7 @@ namespace App\Services; +use App\Enums\GalaProjectStatus; use App\Enums\ProjectStatus; use App\Enums\UserRole; use App\Models\GalaProject; @@ -128,6 +129,7 @@ public function changeStatus(Project|GalaProject $project, string $status): void match ($status) { ProjectStatus::pending->value => $this->pending($project), ProjectStatus::archived->value => $this->archive($project), + GalaProjectStatus::publish->value => $this->publish($project), default => Log::error('Invalid status on change project status [# %s ]: %s', $project->id, $status), }; } @@ -166,4 +168,12 @@ private function archive(Project|GalaProject $project): void $this->project->archived_at = now(); $this->project->save(); } + + private function publish(GalaProject|Project $project): void + { + $this->project = $project; + $this->project->status_updated_at = now(); + $this->project->status = GalaProjectStatus::publish; + $this->project->save(); + } } diff --git a/database/migrations/2024_07_03_135808_add_default_for_status_add_status_updated_at_to_gala_projects.php b/database/migrations/2024_07_03_135808_add_default_for_status_add_status_updated_at_to_gala_projects.php new file mode 100644 index 00000000..c8f96676 --- /dev/null +++ b/database/migrations/2024_07_03_135808_add_default_for_status_add_status_updated_at_to_gala_projects.php @@ -0,0 +1,32 @@ +string('status')->default(GalaProjectStatus::draft->value)->change(); + $table->date('status_updated_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('gala_projects', function (Blueprint $table) { + // + }); + } +}; diff --git a/resources/js/Components/cards/RegionalProject.vue b/resources/js/Components/cards/RegionalProject.vue index 2c7e6316..687aa4bd 100644 --- a/resources/js/Components/cards/RegionalProject.vue +++ b/resources/js/Components/cards/RegionalProject.vue @@ -1,12 +1,9 @@ diff --git a/resources/js/Pages/AdminOng/GalaProjects/Edit.vue b/resources/js/Pages/AdminOng/GalaProjects/Edit.vue index bc3421e7..7a61ca57 100644 --- a/resources/js/Pages/AdminOng/GalaProjects/Edit.vue +++ b/resources/js/Pages/AdminOng/GalaProjects/Edit.vue @@ -493,21 +493,6 @@ const props = defineProps({ error_message: String, }); -const impact_areas = [ - { - label: 'Local', - value: 'local', - }, - { - label: 'Judetean', - value: 'judetean', - }, - { - label: 'Regional', - value: 'regional', - }, -]; - let project = ref(props.project); let form = useForm(project.value); @@ -519,6 +504,6 @@ const editField = (field) => { let newForm = useForm({ [field]: form[field], }); - newForm.post(route('dashboard.projects.gala.update', project.value.id)); + newForm.put(route('dashboard.projects.gala.update', project.value.id)); }; diff --git a/resources/js/Pages/AdminOng/GalaProjects/View.vue b/resources/js/Pages/AdminOng/GalaProjects/View.vue new file mode 100644 index 00000000..7960874c --- /dev/null +++ b/resources/js/Pages/AdminOng/GalaProjects/View.vue @@ -0,0 +1,257 @@ +