Skip to content

Commit 4a63699

Browse files
committed
fix: adjust location component container
1 parent 657ac41 commit 4a63699

7 files changed

Lines changed: 53 additions & 71 deletions

File tree

app/Filament/Forms/Components/Location.php

Lines changed: 46 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace App\Filament\Forms\Components;
66

7-
use App\Filament\Schemas\Components\Subsection;
87
use App\Models\City;
98
use App\Models\County;
109
use Closure;
@@ -16,14 +15,11 @@
1615
use Filament\Schemas\Components\Grid;
1716
use Filament\Schemas\Components\Utilities\Get;
1817
use Filament\Schemas\Components\Utilities\Set;
19-
use Filament\Support\Concerns\CanBeContained;
20-
use Filament\Support\Icons\Heroicon;
2118

2219
class Location extends Component implements CanEntangleWithSingularRelationships
2320
{
2421
use EntanglesStateWithSingularRelationship;
2522
use CanBeValidated;
26-
use CanBeContained;
2723

2824
protected string $view = 'filament-schemas::components.grid';
2925

@@ -54,65 +50,52 @@ protected function setUp(): void
5450
{
5551
$this->columnSpanFull();
5652

57-
$this->schema(function () {
58-
$components = [
59-
Select::make($this->getCountyField())
60-
->label($this->getCountyLabel())
61-
->placeholder(__('placeholder.county'))
62-
->options(County::cachedList())
63-
->searchable()
64-
->preload()
65-
->live()
66-
->required($this->isRequired())
67-
->afterStateUpdated(function (Set $set) {
68-
if (! $this->hasCity()) {
69-
return;
70-
}
71-
72-
$set($this->getCityField(), null);
73-
})
74-
->when(! $this->hasCity(), fn (Select $component) => $component->columnSpanFull()),
75-
76-
Select::make($this->getCityField())
77-
->label($this->getCityLabel())
78-
->placeholder(__('placeholder.city'))
79-
->allowHtml()
80-
->searchable()
81-
->required($this->isRequired())
82-
->getSearchResultsUsing(function (string $search, Get $get) {
83-
$countyId = (int) $get($this->getCountyField());
84-
85-
if (! $countyId) {
86-
return [];
87-
}
88-
89-
return City::query()
90-
->where('county_id', $countyId)
91-
->search($search)
92-
->limit(50)
93-
->get()
94-
->mapWithKeys(fn (City $city) => [
95-
$city->getKey() => $city->formatted_name,
96-
]);
97-
})
98-
->visible(fn () => $this->hasCity())
99-
->getOptionLabelUsing(fn (int $value) => City::find($value)->formatted_name),
100-
];
101-
102-
if (! $this->isContained()) {
103-
return [
104-
Grid::make()
105-
->components($components),
106-
];
107-
}
108-
109-
return [
110-
Subsection::make()
111-
->icon(Heroicon::OutlinedMapPin)
112-
->columns()
113-
->components($components),
114-
];
115-
});
53+
$this->schema(fn () => [
54+
Grid::make()
55+
->components([
56+
Select::make($this->getCountyField())
57+
->label($this->getCountyLabel())
58+
->placeholder(__('placeholder.county'))
59+
->options(County::cachedList())
60+
->searchable()
61+
->preload()
62+
->live()
63+
->required($this->isRequired())
64+
->afterStateUpdated(function (Set $set) {
65+
if (! $this->hasCity()) {
66+
return;
67+
}
68+
69+
$set($this->getCityField(), null);
70+
})
71+
->when(! $this->hasCity(), fn (Select $component) => $component->columnSpanFull()),
72+
73+
Select::make($this->getCityField())
74+
->label($this->getCityLabel())
75+
->placeholder(__('placeholder.city'))
76+
->allowHtml()
77+
->searchable()
78+
->required($this->isRequired())
79+
->getSearchResultsUsing(function (string $search, Get $get) {
80+
$countyId = (int) $get($this->getCountyField());
81+
82+
if (! $countyId) {
83+
return [];
84+
}
85+
86+
return City::query()
87+
->where('county_id', $countyId)
88+
->search($search)
89+
->limit(50)
90+
->get()
91+
->mapWithKeys(fn (City $city) => [
92+
$city->getKey() => $city->formatted_name,
93+
]);
94+
})
95+
->visible(fn () => $this->hasCity())
96+
->getOptionLabelUsing(fn (int $value) => City::findOrFail($value)->formatted_name),
97+
]),
98+
]);
11699
}
117100

118101
public function getCountyField(): string

app/Filament/Resources/Beneficiaries/Pages/CreateBeneficiary.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function form(Schema $schema): Schema
3535
->columns(1)
3636
->components([
3737
Section::make()
38+
->contained(false)
3839
->components([
3940
Select::make('type')
4041
->label(__('field.beneficiary_type'))

app/Filament/Resources/Beneficiaries/Resources/Catagraphies/Schemas/SummaryInfolist.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private static function vulnerabilities(): Section
5252
EmptyState::make(__('catagraphy.vulnerability.empty.title'))
5353
->description(__('catagraphy.vulnerability.empty.description'))
5454
->icon('icon-empty-state')
55+
->contained(false)
5556
->footer([
5657
Action::make('create')
5758
->label(__('catagraphy.vulnerability.empty.create'))
@@ -108,7 +109,8 @@ private static function recommendations(): Section
108109
return [
109110
EmptyState::make(__('catagraphy.recommendation.empty.title'))
110111
->description(__('catagraphy.recommendation.empty.description'))
111-
->icon('icon-clipboard'),
112+
->icon('icon-clipboard')
113+
->contained(false),
112114
];
113115
}
114116

app/Filament/Resources/Profiles/Schemas/EmployersForm.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ public static function configure(Schema $schema): Schema
8181
}),
8282
]),
8383

84-
Location::make()
85-
->contained(false),
84+
Location::make(),
8685

8786
TextInput::make('email')
8887
->label(__('field.employer_email'))

app/Filament/Resources/Profiles/Schemas/GeneralForm.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public static function configure(Schema $schema): Schema
6060
->icon(Heroicon::OutlinedMapPin)
6161
->columns()
6262
->schema([
63-
Location::make()
64-
->contained(false),
63+
Location::make(),
6564

6665
TextInput::make('email')
6766
->label(__('field.email'))

app/Filament/Resources/Profiles/Schemas/StudiesForm.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public static function configure(Schema $schema): Schema
5858
->maxValue(100)
5959
->nullable(),
6060

61-
Location::make()
62-
->contained(false),
61+
Location::make(),
6362

6463
YearPicker::make('start_year')
6564
->label(__('field.start_year'))

app/Filament/Resources/Users/Schemas/UserForm.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public static function configure(Schema $schema): Schema
6565
->default(Role::NURSE),
6666

6767
Location::make()
68-
->contained(false)
6968
->city(false)
7069
->required()
7170
->visible(fn (Get $get) => Role::COORDINATOR->is($get('role')))

0 commit comments

Comments
 (0)