refreshAllgemeinflaechen dispatch

This commit is contained in:
salam committed 2025-10-20 15:58:20 +02:00
1 parent 261fb0916d
commit d473bdc2b3
12 files changed
+157 -126

No files matched your search

@@ -15,7 +15,7 @@ class KontoTextblockForm
->components([
TextInput::make('name')
->required(),
Textarea::make('beschreibung'),
// Textarea::make('beschreibung'),
RichEditor::make('textblock')
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
->toolbarButtons([
@@ -24,6 +24,9 @@ class KontoTextblocksTable
return new HtmlString($record->textblock);
})
->html(),
TextColumn::make('created_at')
->label('Erstellt')
->dateTime('M j, Y'),
])
->recordActions([
EditAction::make()->iconButton(),
@@ -11,11 +11,15 @@ use Filament\Actions\ActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
use Livewire\Attributes\On;
class EditProjekte extends EditRecord
{
protected static string $resource = ProjekteResource::class;
#[On('refreshAllgemeinflaechen')]
public function refresh(): void {}
protected function getHeaderActions(): array
{
return [
@@ -18,6 +18,7 @@ use Filament\Tables\Columns\TextInputColumn;
use Filament\Tables\Table;
use Illuminate\Support\HtmlString;
use Illuminate\Validation\Rules\File;
use Livewire\Component;
class AllgemeinflaechensRelationManager extends RelationManager
{
@@ -45,8 +46,11 @@ class AllgemeinflaechensRelationManager extends RelationManager
->suffix(new HtmlString(' m²'))
->numeric()
->label('Fläche')
->required()
->maxLength(255),
->rules(['required', 'flaeche' => 'decimal:2'])
->validationMessages([
'required' => 'Die Eingabe einer Fläche ist erforderlich.',
'decimal' => 'Für die Fläche sind zwei Dezimalstellen erforderlich.',
]),
])->columns(3);
}
@@ -64,11 +68,17 @@ class AllgemeinflaechensRelationManager extends RelationManager
)->suffix(new HtmlString(' m²')))
->suffix(new HtmlString(' m²'))
->width('2rem')
->rules(['required', 'price' => 'decimal:2'])
->rules(['required', 'flaeche' => 'decimal:2'])
->alignment('right')
// ->formatStateUsing(fn ($state) => "{$state} m²")
->label('Fläche')
->searchable(),
->searchable()
->validationMessages([
'required' => 'Die Eingabe einer Fläche ist erforderlich.',
'decimal' => 'Für die Fläche sind zwei Dezimalstellen erforderlich.',
])
->afterStateUpdated(function (Component $livewire) {
$livewire->dispatch('refreshAllgemeinflaechen');
}),
])
->filters([
//
@@ -92,12 +102,20 @@ class AllgemeinflaechensRelationManager extends RelationManager
]),
])
->recordActions([
EditAction::make()->iconButton(),
DeleteAction::make()->iconButton(),
EditAction::make()->iconButton()
->after(function (Component $livewire) {
$livewire->dispatch('refreshAllgemeinflaechen');
}),
DeleteAction::make()->iconButton()->after(function (Component $livewire) {
$livewire->dispatch('refreshAllgemeinflaechen');
}),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
DeleteBulkAction::make()
->after(function (Component $livewire) {
$livewire->dispatch('refreshAllgemeinflaechen');
}),
]),
]);
}
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\Projektes\RelationManagers;
use App\Actions\Create\CreateProjektInhaltsverzeichnis;
use App\Models\KontoTextblock;
use App\Models\ProjektInhaltsverzeichnis;
use Filament\Actions\Action;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\CreateAction;
@@ -11,7 +12,6 @@ use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\RichEditor\RichContentRenderer;
use Filament\Forms\Components\Select;
@@ -79,6 +79,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
Grid::make()
->columns(6)
->schema([
TextInput::make('konto_textblock_id')->hidden(),
RichEditor::make('textblock')
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
->columnSpan(5)
@@ -89,15 +90,31 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
Fieldset::make('')
->contained(false)
->schema([
Action::make('textblock_sichern')
Action::make('sichern')
->iconButton()
->tooltip('Änderungen in der Vorlage speichern')
->icon('phosphor-floppy-disk')
->schema([
Hidden::make('konto_id')->default(auth()->user()->konto_id),
RichEditor::make('textblock')
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
->hidden()
TextInput::make('name')->required()
->label('Ändern sie gegebeben Falls den Namen')
->default(function ($record) {
return $record['textblock'];
return KontoTextblock::where('id', $record['konto_textblock_id'])->pluck('name')->first();
}),
])
->hidden(function ($record) {
return (bool) ! $record['konto_textblock_id'];
})
->action(function (array $mountedActions, array $data) {
$record = $mountedActions[0]->getRawData();
KontoTextblock::where('id', $record['konto_textblock_id'])
->update(['name' => $data['name'], 'textblock' => RichContentRenderer::make($record['textblock'])->toHtml()]);
}),
Action::make('neu')
->iconButton()
->icon('phosphor-file-plus')
->schema([
TextInput::make('name')->required()
->label('Geben sie der Vorlage einen eindeutigen Namen')
->default(function ($record) {
@@ -105,41 +122,40 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
}),
])
->modalSubmitActionLabel('Sichern')
->iconButton()
->icon('phosphor-floppy-disk')
->tooltip('Als persönliche Vorlage speichern')
->action(function (array $mountedActions, $data) {
->tooltip('Neue Vorlage erstellen')
->action(function (array $mountedActions, array $data) {
$record = $mountedActions[0]->getRawData();
KontoTextblock::updateOrCreate(
[
'konto_id' => auth()->user()->konto_id,
'name' => $data['name'],
], [
'textblock' => RichContentRenderer::make($record['textblock'])->toHtml(),
]);
$block = new KontoTextblock;
$block->konto_id = auth()->user()->konto_id;
$block->name = $data['name'];
$block->textblock = RichContentRenderer::make($record['textblock'])->toHtml();
$block->save();
ProjektInhaltsverzeichnis::where('id', $record['id'])->update(['konto_textblock_id' => $block->id]);
}),
Action::make('textblock_laden')
Action::make('laden')
->iconButton()
->icon('phosphor-article')
->schema([
Select::make('konto_textblock_id')
->hiddenLabel()
->searchable()
->options(function ($record) {
return KontoTextblock::where('konto_id', auth()->user()->konto_id)->pluck('name', 'id')->toArray();
})->belowLabel([
->options(KontoTextblock::where('konto_id', auth()->user()->konto_id)->pluck('name', 'id'))
->belowLabel([
'Bitte eine Vorlage auswählen',
]),
])
->icon('phosphor-article')
->iconButton()
->modalSubmitActionLabel('Einsetzen')
->tooltip('Persönliche Vorlage laden.')
->action(function (Set $set, array $data) {
$set('textblock', KontoTextblock::query()->pluck('textblock')->first());
->tooltip('Vorlage laden.')
->action(function (Set $set, array $mountedActions, array $data) {
$record = $mountedActions[0]->getRawData();
ProjektInhaltsverzeichnis::where('id', $record['id'])->update(['konto_textblock_id' => $data['konto_textblock_id']]);
$set('konto_textblock_id', $data['konto_textblock_id']);
$set('textblock', KontoTextblock::where('id', $data['konto_textblock_id'])->pluck('textblock')->first());
}),
])
->columns(1),
])->columns(1),
]),
]),
])->columnSpanFull(),
+9
View File
@@ -12,4 +12,13 @@ class Allgemeinflaechen extends Model
'raumart',
'flaeche',
];
public static function boot()
{
parent::boot();
self::updated(function ($model) {
Projekte::where('id', $model['projekte_id'])->update(['evaluation' => false]);
});
}
}
-20
View File
@@ -1,20 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
public function boot()
{
VerifyEmail::toMailUsing(function ($notifiable, $url) {
return (new MailMessage)
->subject('Verify Email Address')
->line('Click the button below to verify your email address.')
->action('Verify Email Address', $url);
});
}
}