wip orientierung
This commit is contained in:
1 parent
0df1017cb7
commit
79c0b14bb5
11 files changed
+284
-12259
No files matched your search
+80
-2
@@ -3,13 +3,22 @@
|
||||
namespace App\Filament\Resources\Projektes\RelationManagers;
|
||||
|
||||
use App\Actions\CreateOrientierungZuAbschlaege;
|
||||
use App\Models\Merkmale;
|
||||
use App\Models\Orientierung;
|
||||
use App\Models\OrientierungZuAbschlaege;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Tables\Columns\CheckboxColumn;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
{
|
||||
@@ -25,19 +34,53 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
$spalten = Merkmale::map($this->ownerRecord->id);
|
||||
|
||||
return $table
|
||||
->recordTitleAttribute('top_nummer')
|
||||
->columns([
|
||||
TextColumn::make('top_nummer')
|
||||
->searchable(),
|
||||
CheckboxColumn::make('nicht_in_orientierung')
|
||||
->label('NiO')
|
||||
->toggleable(),
|
||||
TextInputColumn::make('raumart')
|
||||
->toggleable()
|
||||
->width('2rem')
|
||||
->rules(['required'])
|
||||
->searchable(),
|
||||
SelectColumn::make('orientierung_id')
|
||||
->toggleable()
|
||||
->width('2rem')
|
||||
->label('Orientierung')
|
||||
->selectablePlaceholder(true)
|
||||
->options(Orientierung::pluck('name', 'id'))
|
||||
->disableOptionWhen(fn (string $value): bool => in_array($value, [2, 11, 24, 33, 36]))
|
||||
->preloadOptions(),
|
||||
TextInputColumn::make('a')->label($spalten['a'] ?? '')->hidden(isset($spalten['a']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('b')->label($spalten['b'] ?? '')->hidden(isset($spalten['b']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('c')->label($spalten['c'] ?? '')->hidden(isset($spalten['c']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('d')->label($spalten['d'] ?? '')->hidden(isset($spalten['d']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('e')->label($spalten['e'] ?? '')->hidden(isset($spalten['e']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('f')->label($spalten['f'] ?? '')->hidden(isset($spalten['f']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('g')->label($spalten['g'] ?? '')->hidden(isset($spalten['g']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('h')->label($spalten['h'] ?? '')->hidden(isset($spalten['h']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('i')->label($spalten['i'] ?? '')->hidden(isset($spalten['i']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
TextInputColumn::make('j')->label($spalten['j'] ?? '')->hidden(isset($spalten['j']) ? false : true)->toggleable()->rules(['numeric'])->alignCenter(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Action::make('merkmale')
|
||||
->icon('phosphor-pen')
|
||||
->modalCancelAction(fn (Action $action) => $action->label('Schließen'))
|
||||
->modalSubmitAction(false)
|
||||
->modalHeading('Merkmale')
|
||||
// ->slideOver()
|
||||
->modalWidth(Width::Medium)
|
||||
->modalContent(view('filament.pages.actions.merkmale')),
|
||||
Action::make('erstellen')
|
||||
->action(fn (CreateOrientierungZuAbschlaege $createOrientierungZuAbschlaege) => $createOrientierungZuAbschlaege->create($this->ownerRecord))
|
||||
->requiresConfirmation()
|
||||
@@ -50,7 +93,42 @@ class OrientierungZuAbschlaegesRelationManager extends RelationManager
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
BulkAction::make('raumart')
|
||||
->color('primary')
|
||||
->label('Raumart zuweisen')
|
||||
->schema([
|
||||
TextInput::make('raumart')
|
||||
->prefixIcon('phosphor-house-simple'),
|
||||
])
|
||||
->icon('phosphor-house-simple')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['raumart' => $data['raumart']]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('methode')
|
||||
->color('primary')
|
||||
->label('Orientierung zuweisen')
|
||||
->schema([
|
||||
Select::make('methode_id')
|
||||
->label('Orientierung')
|
||||
->prefixIcon('phosphor-compass')
|
||||
->options(Orientierung::pluck('name', 'id'))
|
||||
->disableOptionWhen(fn (string $value): bool => in_array($value, [2, 11, 24, 33, 36]))
|
||||
->required(),
|
||||
])
|
||||
->icon('phosphor-compass')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
OrientierungZuAbschlaege::where('id', '=', $record->id)
|
||||
->update(
|
||||
['orientierung_id' => $data['methode_id']]
|
||||
);
|
||||
}
|
||||
}),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Projektes\Widgets;
|
||||
|
||||
use App\Models\Merkmale;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WidgetMerkmale extends TableWidget
|
||||
{
|
||||
// protected static ?string $title = 'Merkmale';
|
||||
|
||||
// protected static ?string $navigationLabel = 'Merkmale';
|
||||
|
||||
// protected static ?string $pluralModelLabel = 'Merkmale';
|
||||
|
||||
// protected static ?string $modelLabel = 'Merkmale';
|
||||
|
||||
protected static ?string $title = 'Merkmale';
|
||||
|
||||
public $projekte_id;
|
||||
|
||||
// public function mount(): void
|
||||
// {
|
||||
// dd($this->projekte_id);
|
||||
// // $this->data = $this->ownerRecord;
|
||||
// }
|
||||
|
||||
// $livewire->ownerRecord or $this->ownerRecord
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(fn (): Builder => Merkmale::where('projekte_id', $this->projekte_id))
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
])
|
||||
->paginated(false)
|
||||
->recordActions([
|
||||
EditAction::make()
|
||||
->color('gray')
|
||||
->iconButton()
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]),
|
||||
DeleteAction::make()
|
||||
->color('gray')
|
||||
->iconButton(),
|
||||
])
|
||||
->headerActions([
|
||||
Action::make('name')
|
||||
->icon('phosphor-plus')
|
||||
->label('Merkmal')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->prefixIcon('phosphor-house-simple'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$code = Merkmale::getfreecode($this->projekte_id);
|
||||
if ($code) {
|
||||
$merkmal = new Merkmale;
|
||||
$merkmal->projekte_id = $this->projekte_id;
|
||||
$merkmal->code = $code;
|
||||
$merkmal->name = $data['name'];
|
||||
$merkmal->save();
|
||||
}
|
||||
}),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user