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

change RepeatableEntry with TableEntry #478

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 @@ -6,9 +6,11 @@

use App\Actions\BackAction;
use App\Filament\Admin\Resources\BenefitResource;
use App\Filament\Admin\Resources\BenefitResource\Widgets\BenefitTypesWidget;
use App\Infolists\Components\TableEntry;
use Filament\Actions\EditAction;
use Filament\Forms\Form;
use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Pages\ViewRecord;
use Illuminate\Contracts\Support\Htmlable;

Expand Down Expand Up @@ -45,15 +47,24 @@ public function getTitle(): string|Htmlable
return $this->record->name;
}

public function form(Form $form): Form
public function infolist(Infolist $infolist): Infolist
{
return $form->schema([]);
}
return $infolist->schema([
Section::make()
->maxWidth('3xl')
->schema([
TableEntry::make('benefitTypes')
->hiddenLabel()
->schema([
TextEntry::make('name')
->label(__('nomenclature.labels.benefit_type_name'))
->hiddenLabel(),

protected function getFooterWidgets(): array
{
return [
BenefitTypesWidget::class,
];
TextEntry::make('status')
->label(__('nomenclature.labels.status'))
->hiddenLabel(),
]),
]),
]);
}
}

This file was deleted.

96 changes: 50 additions & 46 deletions app/Filament/Admin/Resources/ServiceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,54 +71,58 @@ public static function form(Form $form): Form
->options(CounselingSheet::options()),

]),
TableRepeater::make('serviceInterventions')
->relationship('serviceInterventions')
->label(__('nomenclature.headings.service_intervention'))
->columnSpanFull()
->addActionLabel(__('nomenclature.actions.add_intervention'))
->schema([
Placeholder::make('id')
->label(__('nomenclature.labels.nr'))
->content(function () {
static $index = 1;

return $index++;
})
->hiddenLabel(),
TextInput::make('name')
->columnSpanFull()
->hiddenLabel()
->maxLength(200)
->label(__('nomenclature.labels.intervention_name')),

Toggle::make('status')
Section::make()
->schema([
TableRepeater::make('serviceInterventions')
->relationship('serviceInterventions')
->label(__('nomenclature.headings.service_intervention'))
->columnSpanFull()
->live()
->default(true)
->afterStateUpdated(function (bool $state) {
if (! $state) {
dd('Modal cu inactivare de hard confirmation');
}
})
->label(fn (Get $get) => $get('status') ? __('nomenclature.labels.active') : __('nomenclature.labels.inactive')),
])
->deleteAction(
fn (Action $action) => $action
->disabled(function (array $arguments, TableRepeater $component): bool {
$items = $component->getState();
$currentItem = $items[$arguments['item']];

$serviceIntervention = ServiceIntervention::where('id', $currentItem['id'])
->withCount('organizationIntervention')
->first();

if (! $serviceIntervention) {
return false;
}

return $serviceIntervention->organization_intervention_count > 0;
})
),
->addActionLabel(__('nomenclature.actions.add_intervention'))
->schema([
Placeholder::make('id')
->label(__('nomenclature.labels.nr'))
->content(function () {
static $index = 1;

return $index++;
})
->hiddenLabel(),
TextInput::make('name')
->columnSpanFull()
->hiddenLabel()
->maxLength(200)
->label(__('nomenclature.labels.intervention_name')),

Toggle::make('status')
->columnSpanFull()
->live()
->default(true)
->afterStateUpdated(function (bool $state) {
if (! $state) {
dd('Modal cu inactivare de hard confirmation');
}
})
->label(fn (Get $get) => $get('status') ? __('nomenclature.labels.active') : __('nomenclature.labels.inactive')),
])
->deleteAction(
fn (Action $action) => $action
->disabled(function (array $arguments, TableRepeater $component): bool {
$items = $component->getState();
$currentItem = $items[$arguments['item']];

$serviceIntervention = ServiceIntervention::where('id', $currentItem['id'])
->withCount('organizationIntervention')
->first();

if (! $serviceIntervention) {
return false;
}

return $serviceIntervention->organization_intervention_count > 0;
})
),
]),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
use App\Actions\BackAction;
use App\Enums\CounselingSheet;
use App\Filament\Admin\Resources\ServiceResource;
use App\Filament\Admin\Resources\ServiceResource\Widgets\InterventionsWidget;
use App\Filament\Organizations\Resources\InterventionServiceResource\Pages\EditCounselingSheet;
use App\Infolists\Components\Notice;
use App\Infolists\Components\TableEntry;
use Filament\Actions;
use Filament\Actions\StaticAction;
use Filament\Infolists\Components\Actions\Action;
use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Pages\ViewRecord;
use Illuminate\Contracts\Support\Htmlable;
Expand Down Expand Up @@ -87,18 +88,30 @@ public function infolist(Infolist $infolist): Infolist
->link(),
),
]),
]);
}

protected function hasInfolist(): bool
{
return true;
}
Section::make()
->schema([
TableEntry::make('serviceInterventions')
->hiddenLabel()
->schema([
TextEntry::make('name')
->label(__('nomenclature.labels.intervention_name'))
->hiddenLabel(),

protected function getFooterWidgets(): array
{
return [
InterventionsWidget::class,
];
TextEntry::make('institutions_count')
->label(__('nomenclature.labels.institutions'))
->hiddenLabel(),

TextEntry::make('organizations_count')
->label(__('nomenclature.labels.centers'))
->hiddenLabel(),

TextEntry::make('status')
->label(__('nomenclature.labels.status'))
->hiddenLabel(),

]),
]),
]);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Infolists\Components\Actions\Edit;
use App\Infolists\Components\DateEntry;
use App\Infolists\Components\Location;
use App\Infolists\Components\TableEntry;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use Filament\Infolists\Components\Group;
use Filament\Infolists\Components\RepeatableEntry;
Expand Down Expand Up @@ -295,21 +296,25 @@ public function getPartnerSchema(): array
public function getDetailedEvaluationSchema(): array
{
return [
RepeatableEntry::make('detailedEvaluationSpecialists')
TableEntry::make('detailedEvaluationSpecialists')
->columns(4)
->label(__('beneficiary.section.detailed_evaluation.labels.specialists'))
->schema([
TextEntry::make('full_name')
->label(__('beneficiary.section.detailed_evaluation.labels.full_name')),
->label(__('beneficiary.section.detailed_evaluation.labels.full_name'))
->hiddenLabel(),

TextEntry::make('institution')
->label(__('beneficiary.section.detailed_evaluation.labels.institution')),
->label(__('beneficiary.section.detailed_evaluation.labels.institution'))
->hiddenLabel(),

TextEntry::make('relationship')
->label(__('beneficiary.section.detailed_evaluation.labels.relationship')),
->label(__('beneficiary.section.detailed_evaluation.labels.relationship'))
->hiddenLabel(),

DateEntry::make('date')
->label(__('beneficiary.section.detailed_evaluation.labels.contact_date')),
->label(__('beneficiary.section.detailed_evaluation.labels.contact_date'))
->hiddenLabel(),
]),

RepeatableEntry::make('meetings')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
use App\Filament\Organizations\Resources\InterventionServiceResource\Pages\EditCounselingSheet;
use App\Filament\Organizations\Resources\ServiceResource;
use App\Infolists\Components\Notice;
use App\Infolists\Components\TableEntry;
use App\Models\BeneficiaryIntervention;
use Filament\Actions\EditAction;
use Filament\Actions\StaticAction;
use Filament\Infolists\Components\Actions\Action;
use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Pages\ViewRecord;
use Illuminate\Contracts\Support\Htmlable;
Expand Down Expand Up @@ -47,6 +50,12 @@ protected function getHeaderActions(): array

public function infolist(Infolist $infolist): Infolist
{
$this->getRecord()
->load([
'interventions.serviceInterventionWithoutStatusCondition',
'interventions.beneficiaryInterventions.interventionPlan',
]);

return $infolist->schema([
Section::make()
->visible(fn () => $this->getRecord()->serviceWithoutStatusCondition->counseling_sheet)
Expand Down Expand Up @@ -87,18 +96,30 @@ public function infolist(Infolist $infolist): Infolist
->modalAutofocus(false),
),
]),
]);
}

protected function hasInfolist(): bool
{
return true;
}
TableEntry::make('interventions')
->columnSpanFull()
->hiddenLabel()
->schema([
TextEntry::make('serviceInterventionWithoutStatusCondition.name')
->hiddenLabel()
->label(__('service.labels.interventions')),

protected function getHeaderWidgets(): array
{
return [
ServiceResource\Widgets\ListServiceInterventions::class,
];
TextEntry::make('cases')
->hiddenLabel()
->label(__('service.labels.cases'))
->default(
fn ($record) => $record->beneficiaryInterventions
?->map(fn (BeneficiaryIntervention $beneficiaryIntervention) => $beneficiaryIntervention->interventionPlan->beneficiary_id)
->unique()
->count()
),

TextEntry::make('status')
->hiddenLabel()
->label(__('service.labels.status')),
]),

]);
}
}
Loading
Loading