This commit is contained in:
salam committed 2025-11-14 12:33:19 +01:00
1 parent a20893d527
commit 4b79874100
31 files changed
+549 -1535

No files matched your search

@@ -3,7 +3,6 @@
namespace App\Filament\Resources\Projektes\RelationManagers;
use App\Models\ProjektObjekteImDetail;
use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
@@ -20,7 +19,6 @@ use Filament\Tables\Columns\TextInputColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\HtmlString;
use Livewire\Component;
@@ -44,17 +42,14 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
Select::make('projekt_objekte_id')
->relationship('top_nummer', 'top_nummer', fn (Builder $query) => $query->where('projekte_id', $this->getOwnerRecord()->id))
->required()
->searchable()
->columnSpan(3),
->searchable(),
TextInput::make('raumart')
->required()
->maxLength(255)
->columnSpan(3),
->maxLength(255),
TextInput::make('geschoss')
->required()
->maxLength(255)
->suffixIcon('phosphor-building')
->columnSpan(2),
->suffixIcon('phosphor-building'),
TextInput::make('flaeche')
->suffix(new HtmlString(' m²'))
->rules(['required'])
@@ -65,18 +60,8 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
])
->afterStateUpdated(function (Component $livewire) {
$livewire->dispatch('refreshProjektAllgemeinflaechen');
})
->columnSpan(2),
TextInput::make('faktor')
->suffixIcon('phosphor-function')
->afterStateUpdated(function (Component $livewire) {
$livewire->dispatch('refreshProjektObjekteImDetail');
})->validationMessages([
'required' => 'Die Eingabe eines Faktors ist erforderlich.',
'decimal' => 'Für den Faktors sind zwei Dezimalstellen erforderlich.',
])
->columnSpan(2),
])->columns(6);
}),
]);
}
public function table(Table $table): Table
@@ -87,29 +72,16 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
->recordTitleAttribute('top_nummer')
->columns([
TextColumn::make('top_nummer.top_nummer')
->sortable()
->extraAttributes(['pointer-events' => 'none'])
->searchable()
->label('Top'),
TextColumn::make('geschoss')->searchable(),
TextColumn::make('raumart')->searchable(),
TextInputColumn::make('faktor')
->extraInputAttributes(['onClick' => 'this.select()'])
->suffixIcon('phosphor-function')
->width('1rem')
->rules(['required'])
TextColumn::make('raumart')->searchable()->sortable(),
TextColumn::make('methode.faktor')
->icon('phosphor-function')
->searchable()
->afterStateUpdated(function ($record, Component $livewire) {
$object = ProjektObjekteImDetail::find($record['id']);
$object->nutzwert = round($object->faktor * $object->flaeche, 2);
$object->save();
$livewire->dispatch('refreshProjektObjekteImDetail');
})->validationMessages([
'required' => 'Die Eingabe eines Faktors ist erforderlich.',
'decimal' => 'Für den Faktors sind zwei Dezimalstellen erforderlich.',
]),
->label('Faktor'),
TextInputColumn::make('flaeche')
->extraInputAttributes(['onClick' => 'this.select()'])
->summarize(Sum::make()->label('Gesammt')->numeric(
@@ -122,9 +94,8 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
->label('Fläche')
->searchable()
->afterStateUpdated(function ($record, Component $livewire) {
$object = ProjektObjekteImDetail::find($record['id']);
$object->nutzwert = round($object->faktor * $object->flaeche, 2);
$object->nutzwert = round($record->methode->faktor * $object->flaeche, 2);
$object->save();
$livewire->dispatch('refreshProjektObjekteImDetail');
@@ -176,30 +147,6 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
])
->toolbarActions([
BulkActionGroup::make([
BulkAction::make('faktor')
->color('primary')
->label('Faktor zuweisen')
->schema([
TextInput::make('faktor')
->prefixIcon('phosphor-calculator')
->numeric()
->required(),
])
->icon('phosphor-calculator')
->action(function (Collection $records, array $data): void {
foreach ($records as $record) {
$nutzwert = round($data['faktor'] * $record->flaeche);
ProjektObjekteImDetail::where('id', '=', $record->id)
->update(
[
'faktor' => $data['faktor'],
'nutzwert' => $nutzwert,
]
);
}
})->after(function (Component $livewire) {
$livewire->dispatch('refreshProjektObjekteImDetail');
}),
DeleteBulkAction::make()->after(function (Component $livewire) {
$livewire->dispatch('refreshProjektObjekteImDetail');
}),