Skip to content

Commit

Permalink
Merge branch 'main' into 441-general-form-edit-mode-remove-enter-as-s…
Browse files Browse the repository at this point in the history
…hortcut-to-form-submission
  • Loading branch information
gheorghelupu17 authored Jan 1, 2025
2 parents d06711d + 2bb6096 commit ca926ab
Show file tree
Hide file tree
Showing 57 changed files with 409 additions and 344 deletions.
7 changes: 6 additions & 1 deletion app/Concerns/HasPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Enums\AdminPermission;
use App\Enums\CasePermission;
use App\Models\Beneficiary;
use App\Models\User;
use Filament\Facades\Filament;

trait HasPermissions
Expand Down Expand Up @@ -53,7 +54,7 @@ public function hasAccessToBeneficiary(Beneficiary $beneficiary): bool
return false;
}

public function hasAccessToStaff(): bool
public function hasAccessToStaff(?User $model = null): bool
{
if ($this->isAdmin()) {
return true;
Expand All @@ -63,6 +64,10 @@ public function hasAccessToStaff(): bool
return true;
}

if ($model && $model->isNgoAdmin()) {
return false;
}

return (bool) $this->permissions?->admin_permissions->contains(AdminPermission::CAN_CHANGE_STAFF);
}

Expand Down
24 changes: 24 additions & 0 deletions app/Enums/AllowancePerson.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Enums;

use App\Concerns\Enums;
use Filament\Support\Contracts\HasLabel;

enum AllowancePerson: string implements HasLabel
{
use Enums\HasLabel;
use Enums\Arrayable;
use Enums\Comparable;

case BENEFICIARY = 'beneficiary';
case OTHER = 'other';
case UNKNOWN = 'unknown';

public function labelKeyPrefix(): ?string
{
return 'enum.allowance_person';
}
}
2 changes: 2 additions & 0 deletions app/Enums/FileDocumentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ enum FileDocumentType: string implements HasLabel
case RENTAL_AGREEMENT = 'rental_agreement';
case SALE_PURCHASE_AGREEMENT = 'sale_purchase_agreement';
case IML_CERTIFICATE = 'iml_certificate';

case COURT_SENTENCES = 'court_sentences';
case OTHER = 'other';

protected function labelKeyPrefix(): ?string
Expand Down
2 changes: 0 additions & 2 deletions app/Enums/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ enum PaymentMethod: string implements HasLabel
use Enums\HasLabel;
use Enums\Arrayable;
use Enums\Comparable;

case REPRESENTATIVE = 'representative';
case POSTAL_OFFICE = 'postal_office';
case BANK_ACCOUNT = 'bank_account';
case OTHER = 'other';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use App\Filament\Admin\Resources\InstitutionResource;
use App\Filament\Admin\Resources\InstitutionResource\Actions\ActivateInstitution;
use App\Filament\Admin\Resources\InstitutionResource\Actions\InactivateInstitution;
use App\Infolists\Components\Actions\EditAction;
use App\Infolists\Components\DocumentPreview;
use App\Infolists\Components\Location;
use Filament\Infolists\Components\Actions\Action;
use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
Expand Down Expand Up @@ -51,10 +51,7 @@ public function infolist(Infolist $infolist): Infolist
return $infolist->schema([
Section::make(__('institution.headings.institution_details'))
->headerActions([
Action::make('edit')
->label(__('general.action.edit'))
->icon('heroicon-o-pencil')
->link()
EditAction::make()
->url(self::$resource::getUrl('edit_institution_details', ['record' => $this->getRecord()])),
])
->maxWidth('3xl')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\InstitutionResource;
use App\Infolists\Components\Actions\EditAction;
use App\Infolists\Components\DocumentPreview;
use App\Infolists\Components\SectionHeader;
use App\Models\Institution;
use Filament\Facades\Filament;
use Filament\Infolists\Components\Actions\Action;
use Filament\Infolists\Components\RepeatableEntry;
use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\TextEntry;
Expand Down Expand Up @@ -40,10 +40,7 @@ public function infolist(Infolist $infolist): Infolist
SectionHeader::make('center_details')
->state(__('institution.headings.center_details'))
->action(
Action::make('edit_centers')
->label(__('general.action.edit'))
->icon('heroicon-o-pencil')
->link()
EditAction::make('edit_centers')
->url(InstitutionResource::getUrl('edit_institution_centers', ['record' => $this->getOwnerRecord()]))
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Filament\Admin\Resources\OrganizationResource\RelationManagers;

use App\Tables\Actions\EditAction;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
Expand Down Expand Up @@ -52,7 +53,7 @@ public function table(Table $table): Table
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Expand Down
5 changes: 2 additions & 3 deletions app/Filament/Admin/Resources/ResultResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use App\Enums\GeneralStatus;
use App\Filament\Admin\Resources\ResultResource\Pages;
use App\Models\Result;
use App\Tables\Actions\EditAction;
use App\Tables\Filters\SelectFilter;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
Expand Down Expand Up @@ -66,8 +66,7 @@ public static function table(Table $table): Table
->options(GeneralStatus::options()),
])
->actions([
Tables\Actions\EditAction::make()
->label(__('general.action.change')),
EditAction::make(),
])
->emptyStateHeading(__('nomenclature.headings.empty_state_results_table'))
->emptyStateDescription(null)
Expand Down
5 changes: 2 additions & 3 deletions app/Filament/Admin/Resources/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
use App\Filament\Admin\Resources\RoleResource\Pages;
use App\Forms\Components\Spacer;
use App\Models\Role;
use App\Tables\Actions\EditAction;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
Expand Down Expand Up @@ -106,8 +106,7 @@ public static function table(Table $table): Table
->options(GeneralStatus::options()),
])
->actions([
Tables\Actions\EditAction::make()
->label(__('nomenclature.actions.edit')),
EditAction::make(),
])
->emptyStateHeading(__('nomenclature.labels.empty_state_role_table'))
->emptyStateDescription(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
use App\Filament\Admin\Resources\UserInstitutionResource\Actions\ActivateUserAction;
use App\Filament\Admin\Resources\UserInstitutionResource\Actions\DeactivateUserAction;
use App\Filament\Admin\Resources\UserInstitutionResource\Actions\ResendInvitationAction;
use App\Infolists\Components\Actions\EditAction;
use App\Infolists\Components\DateTimeEntry;
use App\Infolists\Components\SectionHeader;
use Filament\Infolists\Components\Actions\Action;
use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
Expand Down Expand Up @@ -85,9 +85,7 @@ public function infolist(Infolist $infolist): Infolist
SectionHeader::make('edit_user')
->state(__('user.heading.specialist_details'))
->action(
Action::make('edit')
->label(__('general.action.edit'))
->link()
EditAction::make()
->url(self::getParentResource()::getUrl('user.edit', [
'parent' => $this->parent,
'record' => $this->getRecord(),
Expand Down
3 changes: 2 additions & 1 deletion app/Filament/Admin/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Filament\Admin\Resources\UserResource\Pages;
use App\Forms\Components\Select;
use App\Models\User;
use App\Tables\Actions\EditAction;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
Expand Down Expand Up @@ -126,7 +127,7 @@ public static function table(Table $table): Table
->multiple(),
])
->actions([
Tables\Actions\EditAction::make(),
EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Organizations/Pages/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Dashboard extends BaseDashboard
public function getHeading(): string | Htmlable
{
return __('dashboard.welcome', [
'name' => auth()->user()->first_name,
'name' => auth()->user()->last_name,
]);
}

Expand Down
59 changes: 16 additions & 43 deletions app/Filament/Organizations/Pages/ReportsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
use Filament\Pages\Page;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\HtmlString;
use function Filament\Support\get_color_css_variables;

class ReportsPage extends Page implements Forms\Contracts\HasForms, HasInfolists
{
Expand Down Expand Up @@ -82,70 +78,47 @@ protected function getFormSchema(): array
{
return [
Forms\Components\Section::make()
->columns(4)
->columns(12)
->schema([
Select::make('report_type')
->key('report_type')
->label(__('report.labels.report_type'))
->columnSpan(2)
->columnSpan(6)
->options(ReportType::options())
->searchable(),

DatePicker::make('start_date')
->label(__('report.labels.start_date'))
->default(now()->startOfMonth())
->columnSpan(3)
->maxDate(fn (Get $get) => $get('end_date') ? $get('end_date') : now())
->live(),

DatePicker::make('end_date')
->label(__('report.labels.end_date'))
->default(now())
->columnSpan(3)
->minDate(fn (Get $get) => $get('start_date') ?? null)
->maxDate(now())
->live(),

Checkbox::make('add_cases_in_monitoring')
->label(function () {
$icon = 'heroicon-o-information-circle';

$iconClasses = Arr::toCssClasses([
'fi-in-text-item-icon h-5 w-5 shrink-0',
'text-custom-500',
]);

$iconColor = 'grey';
$iconStyles = Arr::toCssStyles([
get_color_css_variables($iconColor, shades: [500]) => $iconColor !== 'gray',
]);

$label = Blade::render('
<div class="flex items-center gap-3">
<div class="flex-1 text-sm">
<span title="{{ $helper }}">{{ $label }}</span>
</div>
<span title="{{ $helper }}">
<x-filament::icon
:icon="$icon"
:class="$iconClasses"
:style="$iconStyles"
/>
</span>
</div>', [
'helper' => __('report.helpers.add_cases_in_monitoring'),
'label' => __('report.labels.add_cases_in_monitoring'),
'icon' => $icon,
'iconClasses' => $iconClasses,
'iconStyles' => $iconStyles,
]);

return new HtmlString($label);
})
->columnSpan(2),
->hintIcon('heroicon-o-information-circle', __('report.helpers.add_cases_in_monitoring'))
->hintColor('black')
->columnSpan(2)
->extraAttributes([
'class' => 'justify-start',
])
->label(__('report.labels.add_cases_in_monitoring'))
->default(true),

Checkbox::make('show_missing_values')
->label(__('report.labels.show_missing_values'))
->default(true)
->columnSpan(2),
->extraAttributes([
'class' => 'ml-16'
])
->columnSpan(4),
]),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
use App\Concerns\HasParentResource;
use App\Enums\ActivityDescription;
use App\Filament\Organizations\Resources\BeneficiaryHistoryResource;
use App\Filters\DateFilter;
use App\Models\Activity;
use App\Models\Beneficiary;
use App\Models\User;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use App\Tables\Columns\DateColumn;
use App\Tables\Filters\SelectFilter;
use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -51,8 +53,8 @@ public function getTitle(): string|Htmlable
public function table(Table $table): Table
{
return $table
->query(
fn () => Activity::whereMorphedTo('subject', $this->parent)
->modifyQueryUsing(
fn (Builder $query) => $query->whereMorphedTo('subject', $this->parent)
->when(
! auth()->user()->hasAccessToAllCases() && ! auth()->user()->isNgoAdmin(),
fn (Builder $query) => $query->whereHasMorph(
Expand Down Expand Up @@ -108,11 +110,14 @@ public function table(Table $table): Table
? $query->where('description', $state['value'])
: $query
),
]);
}

protected function applyFiltersToTableQuery(Builder $query): Builder
{
return $query;
SelectFilter::make('causer_id')
->label(__('beneficiary.section.history.labels.user'))
->options(User::getTenantOrganizationUsers()),

DateFilter::make('created_at')
->label(__('beneficiary.section.history.labels.date')),

]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Models\BeneficiaryIntervention;
use App\Models\InterventionService;
use App\Models\OrganizationServiceIntervention;
use App\Tables\Actions\EditAction;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Group;
use Filament\Forms\Components\Section;
Expand Down Expand Up @@ -127,7 +128,7 @@ public static function table(Table $table): Table
//
])
->actions([
Tables\Actions\EditAction::make(),
EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Expand Down
Loading

0 comments on commit ca926ab

Please sign in to comment.