-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from code4romania/178-ngo-admin-acasa-impleme…
…nt-the-fa-primii-pasi-in-utilizarea-aplicatiei-sunrise-component Config progress
- Loading branch information
Showing
8 changed files
with
196 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Organizations\Widgets; | ||
|
||
use App\Filament\Organizations\Pages\Dashboard; | ||
use App\Filament\Organizations\Resources\CommunityProfileResource; | ||
use App\Filament\Organizations\Resources\ServiceResource; | ||
use App\Filament\Organizations\Resources\UserResource; | ||
use App\Infolists\Components\SectionHeader; | ||
use App\Models\OrganizationService; | ||
use App\Models\User; | ||
use App\Widgets\InfolistWidget; | ||
use Filament\Facades\Filament; | ||
use Filament\Infolists\Components\Actions\Action; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class ConfigProgress extends InfolistWidget | ||
{ | ||
protected static string $view = 'filament.organizations.widgets.config-progress'; | ||
|
||
protected Model | null $record = null; | ||
|
||
protected int | string | array $columnSpan = 2; | ||
|
||
protected static bool | null $organizationServices = null; | ||
|
||
protected static bool | null $specialistsStatus = null; | ||
|
||
public static function canView(): bool | ||
{ | ||
if (! auth()->user()->isNgoAdmin() || auth()->user()->config_process) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function getProgressData(): array | ||
{ | ||
return [ | ||
[ | ||
'label' => __('dashboard.labels.accept_invitation'), | ||
'link' => Dashboard::getUrl(), | ||
'completed' => true, | ||
], | ||
[ | ||
'label' => __('dashboard.labels.config_services_nomenclature'), | ||
'link' => ServiceResource::getUrl(), | ||
'completed' => self::getOrganizationServiceStatus(), | ||
], | ||
[ | ||
'label' => __('dashboard.labels.config_specialists'), | ||
'link' => UserResource::getUrl(), | ||
'completed' => self::getSpecialistsStatus(), | ||
], | ||
[ | ||
'label' => __('dashboard.labels.config_organization_profile'), | ||
'link' => CommunityProfileResource::getUrl(), | ||
// TODO change this after implement community profile | ||
'completed' => false, | ||
], | ||
]; | ||
} | ||
|
||
public function getInfolistSchema(): array | ||
{ | ||
return [ | ||
SectionHeader::make('header') | ||
->state(fn () => $this->getWidgetTitle()) | ||
->action( | ||
Action::make('close_action') | ||
->icon('heroicon-o-x-mark') | ||
->iconButton() | ||
->url(Dashboard::getUrl(['close_config_progress' => true])) | ||
// TODO add community profile | ||
->visible(fn () => self::getOrganizationServiceStatus() && self::getSpecialistsStatus()) | ||
), | ||
]; | ||
} | ||
|
||
public function getWidgetTitle(): string | ||
{ | ||
return __('dashboard.headings.config_progress'); | ||
} | ||
|
||
protected static function getOrganizationServiceStatus(): bool | ||
{ | ||
if (self::$organizationServices !== null) { | ||
return self::$organizationServices; | ||
} | ||
|
||
self::$organizationServices = (bool) OrganizationService::count(); | ||
|
||
return self::$organizationServices; | ||
} | ||
|
||
public function getSpecialistsStatus(): bool | ||
{ | ||
if (self::$specialistsStatus !== null) { | ||
return self::$specialistsStatus; | ||
} | ||
|
||
self::$specialistsStatus = (bool) Filament::getTenant() | ||
->users | ||
->filter(fn (User $user) => ! $user->isNgoAdmin()) | ||
->count(); | ||
|
||
return self::$specialistsStatus; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
database/migrations/2025_01_13_174720_add_config_process_falg_in_users_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->boolean('config_process')->default(false); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
|
||
|
||
|
||
@if (count($actions)) | ||
@if (count($actions)) | ||
<div | ||
class="flex items-center gap-3 shrink-0"> | ||
|
||
|
44 changes: 44 additions & 0 deletions
44
resources/views/filament/organizations/widgets/config-progress.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<x-filament-widgets::widget> | ||
<x-filament::section> | ||
<div class="space-y-4"> | ||
{{ $this->getWidgetInfolist() }} | ||
<div class="flex items-center space-x-2 gap-2"> | ||
@php | ||
$firstIncompleteItem = false; | ||
@endphp | ||
@foreach ($this->getProgressData() as $step) | ||
<div class="flex flex-col items-center group w-32 text-center"> | ||
<a href="{{ $step['link'] }}" class=" items-center space-x-2 group" | ||
title="{{ $step['label'] }}"> | ||
<div class="items-center"> | ||
@if ($step['completed']) | ||
<svg xmlns="http://www.w3.org/2000/svg" class="w-32 h-8 text-primary-500" fill="currentColor" viewBox="0 0 20 20"> | ||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm-1.707-6.293a1 1 0 011.414 0L14 7.414l-1.293-1.293-3.293 3.293L8 7.414l-1.293 1.293a1 1 0 010 1.414l2.586 2.586z" clip-rule="evenodd" /> | ||
</svg> | ||
@elseif (!$firstIncompleteItem) | ||
@php | ||
$firstIncompleteItem = true; | ||
@endphp | ||
<svg xmlns="http://www.w3.org/2000/svg" class="w-32 h-8 text-primary-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"> | ||
<circle cx="12" cy="12" r="10" /> | ||
</svg> | ||
@else | ||
<svg xmlns="http://www.w3.org/2000/svg" class="w-32 h-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"> | ||
<circle cx="12" cy="12" r="10" /> | ||
</svg> | ||
@endif | ||
</div> | ||
<span class="w-32 text-sm mt-1 text-center break-normal text-balance group-hover:underline"> | ||
{{ $step['label'] }} | ||
</span> | ||
</a> | ||
</div> | ||
|
||
@if (!$loop->last) | ||
<div class="flex-1 h-1 space-x-2 {{ $step['completed'] ? 'bg-primary-500' : 'bg-gray-400' }}"></div> | ||
@endif | ||
@endforeach | ||
</div> | ||
</div> | ||
</x-filament::section> | ||
</x-filament-widgets::widget> |