This commit is contained in:
salam committed 2026-05-14 12:01:20 +02:00
1 parent 48deb69379
commit e34fa82499
16 files changed
+235 -228

No files matched your search

@@ -6,10 +6,10 @@ use App\Actions\Create\CreateProjektMethoden;
use App\Models\Aufstellung;
use App\Models\Methode;
use App\Models\ProjektMethode;
use App\Models\ProjektObjekteImDetail;
use Filament\Actions\Action;
use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
@@ -17,9 +17,7 @@ use Filament\Notifications\Notification;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\SelectColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\TextInputColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
@@ -83,31 +81,8 @@ class ProjektMethodesRelationManager extends RelationManager
->recordTitleAttribute('raumart')
->defaultPaginationPageOption(50)
->columns([
TextColumn::make('methode.name')
->searchable(),
TextColumn::make('aufstellung.name')
->searchable(),
// SelectColumn::make('methode_id')
// ->label('Methoden')
// ->optionsRelationship('methode', 'name')
// ->preloadOptions()
// ->rules(['required'])
// ->afterStateUpdated(function (Component $livewire) {
// $livewire->dispatch('refreshMethods');
// })->validationMessages([
// 'required' => 'Die Eingabe einer Methode ist erforderlich.',
// ]),
// SelectColumn::make('aufstellung_id')
// ->label('Aufstellung')
// ->optionsRelationship('aufstellung', 'name')
// ->preloadOptions()
// ->rules(['required'])
// ->afterStateUpdated(function (Component $livewire) {
// $livewire->dispatch('refreshMethods');
// })->validationMessages([
// 'required' => 'Die Eingabe einer Aufstellung ist erforderlich.',
// ]),
TextColumn::make('methode.name'),
TextColumn::make('aufstellung.name'),
TextColumn::make('raumart')
->searchable(),
TextColumn::make('faktor')
@@ -115,25 +90,20 @@ class ProjektMethodesRelationManager extends RelationManager
->icon('phosphor-function')
->searchable()
->label('Faktor'),
// TextInputColumn::make('faktor')
// ->extraInputAttributes(['onClick' => 'this.select()'])
// ->suffixIcon('phosphor-function')
// ->width('1rem')
// ->rules(['required', 'faktor' => 'decimal:0,2'])
// ->searchable()
// ->afterStateUpdated(function ($record) {
// $objects = ProjektObjekteImDetail::where('projekte_id', $record['projekte_id'])->where('raumart', $record['raumart'])->get();
// foreach ($objects as $value) {
// $nutzwert = round($record['faktor'] * $value->flaeche, 2);
// ProjektObjekteImDetail::where('id', $value->id)->update(['nutzwert' => $nutzwert]);
// }
// })->validationMessages([
// 'required' => 'Die Eingabe eines Faktors ist erforderlich.',
// 'decimal' => 'Für den Faktors sind zwei Dezimalstellen erforderlich.',
// ]),
])
->recordActions([
EditAction::make()->iconButton(),
DeleteAction::make()
->iconButton()
->modalDescription(new HtmlString('Es werden auch alle damit verbundenen <b>Räume im Detail</b> gelöscht.'))
->after(function (Component $livewire) {
$livewire->dispatch('refreshProjektObjekteImDetail');
})->successNotification(
Notification::make()
->success()
->title('Raume Methode gelöscht')
->body('Inclusive aller damit verbundenen Räume im Detail.'),
),
])
->filters([
SelectFilter::make('methodes')
@@ -150,6 +120,19 @@ class ProjektMethodesRelationManager extends RelationManager
])
->headerActions([
Action::make('Wohnnutzfläche')
->tooltip('Setzt alle leeren Felder auf "Normale Wohnnutzfläche"')
->icon('phosphor-arrow-bend-right-down')
->action(function (): void {
ProjektMethode::where('projekte_id', '=', $this->ownerRecord->id)->where('methode_id', '=', 0)->update(['methode_id' => 1]);
})->after(function (Component $livewire) {
$livewire->dispatch('refreshMethods');
Notification::make()
->title('Alle leeren Felder wurden auf "Normale Wohnnutzfläche" gesetzt.')
->success()
->send();
}),
Action::make('methoden')
->icon('phosphor-question')
->modalCancelAction(fn (Action $action) => $action->label('Schließen'))