Optimierung 2.4: Kanonische Pre-Submit-Checkliste
presubmitChecks() der vier Editoren in ProvidesPressReleasePresubmitChecks zentralisiert (war 4x dupliziert mit Drift). Kanonische Version uebernimmt die bessere Customer-Variante: Firmenname statt leerer Hinweis in der company-Zeile. Dafuer erhalten die Admin-Editoren ein selectedCompany() (Company::withoutGlobalScopes find), das auch in with() genutzt wird; Customer behaelt seine user-gescopte Aufloesung via CustomerCompanyContext. Tests: volle Suite gruen (794 passed, 1 skipped). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fa995e30a2
commit
b41d34e39f
5 changed files with 86 additions and 192 deletions
|
|
@ -28,6 +28,7 @@ new #[Layout('components.layouts.app'), Title('Neue Pressemitteilung')] class ex
|
|||
use \App\Livewire\Concerns\InteractsWithPressReleaseScheduling;
|
||||
use \App\Livewire\Concerns\InteractsWithPressReleaseTags;
|
||||
use \App\Livewire\Concerns\ProvidesPressReleaseFormRules;
|
||||
use \App\Livewire\Concerns\ProvidesPressReleasePresubmitChecks;
|
||||
|
||||
public string $portal = 'presseecho';
|
||||
|
||||
|
|
@ -414,58 +415,6 @@ new #[Layout('components.layouts.app'), Title('Neue Pressemitteilung')] class ex
|
|||
return $this->tagsArray();
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function presubmitChecks(): array
|
||||
{
|
||||
$titleLen = mb_strlen(trim($this->title));
|
||||
$textLen = app(PressReleaseHtmlSanitizer::class)->plainTextLength($this->text);
|
||||
$tagsCount = count($this->tagsArray());
|
||||
|
||||
return [
|
||||
[
|
||||
'key' => 'title',
|
||||
'status' => $titleLen >= 5 ? 'ok' : 'err',
|
||||
'label' => __('Titel vorhanden'),
|
||||
'sub' => $titleLen > 0
|
||||
? trans_choice('{0}Noch leer|{1}:n Zeichen|[2,*]:n Zeichen', $titleLen, ['n' => $titleLen])
|
||||
: __('Noch leer'),
|
||||
],
|
||||
[
|
||||
'key' => 'text',
|
||||
'status' => $textLen >= 600 ? 'ok' : ($textLen >= 50 ? 'warn' : 'err'),
|
||||
'label' => __('Mindestlänge Fließtext erreicht'),
|
||||
'sub' => __(':n / 600 Zeichen empfohlen', ['n' => number_format($textLen, 0, ',', '.')]),
|
||||
],
|
||||
[
|
||||
'key' => 'company',
|
||||
'status' => $this->companyId ? 'ok' : 'err',
|
||||
'label' => __('Firma zugeordnet'),
|
||||
'sub' => $this->selectedCompany()?->name ?? __('Keine Firma gewählt'),
|
||||
],
|
||||
[
|
||||
'key' => 'category',
|
||||
'status' => $this->categoryId ? 'ok' : 'err',
|
||||
'label' => __('Kategorie gewählt'),
|
||||
'sub' => $this->categoryId ? '' : __('Kategorie ist Pflicht'),
|
||||
],
|
||||
[
|
||||
'key' => 'contact',
|
||||
'status' => $this->contactId ? 'ok' : 'warn',
|
||||
'label' => __('Pressekontakt zugeordnet'),
|
||||
'sub' => $this->contactId ? '' : __('empfohlen — Journalisten greifen direkt zum Hörer'),
|
||||
],
|
||||
[
|
||||
'key' => 'tags',
|
||||
'status' => $tagsCount >= 1 ? 'ok' : 'warn',
|
||||
'label' => __('Themen-Tags vergeben'),
|
||||
'sub' => $tagsCount >= 1
|
||||
? trans_choice('{1}:n Tag|[2,*]:n Tags', $tagsCount, ['n' => $tagsCount])
|
||||
: __('empfohlen für SEO & Auffindbarkeit'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function defaultContactIdFor(int $companyId): ?int
|
||||
{
|
||||
return $this->companyContacts($companyId)->first()?->id;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ new #[Layout('components.layouts.app'), Title('Pressemitteilung bearbeiten')] cl
|
|||
use \App\Livewire\Concerns\InteractsWithPressReleaseScheduling;
|
||||
use \App\Livewire\Concerns\InteractsWithPressReleaseTags;
|
||||
use \App\Livewire\Concerns\ProvidesPressReleaseFormRules;
|
||||
use \App\Livewire\Concerns\ProvidesPressReleasePresubmitChecks;
|
||||
|
||||
#[Locked]
|
||||
public int $id;
|
||||
|
|
@ -397,56 +398,6 @@ new #[Layout('components.layouts.app'), Title('Pressemitteilung bearbeiten')] cl
|
|||
return $this->tagsArray();
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function presubmitChecks(): array
|
||||
{
|
||||
$titleLen = mb_strlen(trim($this->title));
|
||||
$textLen = app(PressReleaseHtmlSanitizer::class)->plainTextLength($this->text);
|
||||
$tagsCount = count($this->tagsArray());
|
||||
|
||||
return [
|
||||
[
|
||||
'key' => 'title',
|
||||
'status' => $titleLen >= 5 ? 'ok' : 'err',
|
||||
'label' => __('Titel vorhanden'),
|
||||
'sub' => $titleLen > 0 ? __(':n Zeichen', ['n' => $titleLen]) : __('Noch leer'),
|
||||
],
|
||||
[
|
||||
'key' => 'text',
|
||||
'status' => $textLen >= 600 ? 'ok' : ($textLen >= 50 ? 'warn' : 'err'),
|
||||
'label' => __('Mindestlänge Fließtext erreicht'),
|
||||
'sub' => __(':n / 600 Zeichen empfohlen', ['n' => number_format($textLen, 0, ',', '.')]),
|
||||
],
|
||||
[
|
||||
'key' => 'company',
|
||||
'status' => $this->companyId ? 'ok' : 'err',
|
||||
'label' => __('Firma zugeordnet'),
|
||||
'sub' => $this->selectedCompany()?->name ?? __('Keine Firma gewählt'),
|
||||
],
|
||||
[
|
||||
'key' => 'category',
|
||||
'status' => $this->categoryId ? 'ok' : 'err',
|
||||
'label' => __('Kategorie gewählt'),
|
||||
'sub' => $this->categoryId ? '' : __('Kategorie ist Pflicht'),
|
||||
],
|
||||
[
|
||||
'key' => 'contact',
|
||||
'status' => $this->contactId ? 'ok' : 'warn',
|
||||
'label' => __('Pressekontakt zugeordnet'),
|
||||
'sub' => $this->contactId ? '' : __('empfohlen — Journalisten greifen direkt zum Hörer'),
|
||||
],
|
||||
[
|
||||
'key' => 'tags',
|
||||
'status' => $tagsCount >= 1 ? 'ok' : 'warn',
|
||||
'label' => __('Themen-Tags vergeben'),
|
||||
'sub' => $tagsCount >= 1
|
||||
? trans_choice('{1}:n Tag|[2,*]:n Tags', $tagsCount, ['n' => $tagsCount])
|
||||
: __('empfohlen für SEO & Auffindbarkeit'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function defaultContactIdFor(int $companyId): ?int
|
||||
{
|
||||
return $this->companyContacts($companyId)->first()?->id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue