Skip to content

Commit

Permalink
Merge branch '3.x' into support-dark-mode-brand-logo
Browse files Browse the repository at this point in the history
  • Loading branch information
zepfietje committed Oct 11, 2023
2 parents f648020 + deac23f commit f68e0da
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/actions/src/Concerns/InteractsWithRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ public function getCustomRecordTitleAttribute(): ?string
return $this->evaluate($this->recordTitleAttribute);
}

public function hasCustomRecordTitle(): bool
{
return $this->recordTitle !== null;
}

public function hasCustomRecordTitleAttribute(): bool
{
return $this->recordTitleAttribute !== null;
}

public function getModel(): ?string
{
$model = $this->getCustomModel();
Expand Down
2 changes: 1 addition & 1 deletion packages/panels/docs/03-resources/07-relation-managers.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ From a UX perspective, this solution is only suitable if your related model only

> These are compatible with `BelongsTo`, `HasOne` and `MorphOne` relationships.
All layout form components ([Grid](../../forms/layout/grid#grid-component), [Section](../../forms/layout/section), [Fieldset](../../forms/layout/fieldset), [Section](../../forms/layout/section), etc.) have a `relationship()` method. When you use this, all fields within that layout are saved to the related model instead of the owner's model:
All layout form components ([Grid](../../forms/layout/grid#grid-component), [Section](../../forms/layout/section), [Fieldset](../../forms/layout/fieldset), etc.) have a `relationship()` method. When you use this, all fields within that layout are saved to the related model instead of the owner's model:

```php
use Filament\Forms\Components\Fieldset;
Expand Down
2 changes: 1 addition & 1 deletion packages/panels/resources/views/components/logo.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@php
$brandName = filament()->getBrandName();
$brandLogo = filament()->getBrandLogo();
$brandLogoHeight = filament()->getBrandLogoHeight() ?? '1.25rem';
$brandLogoHeight = filament()->getBrandLogoHeight() ?? '1.5rem';
$darkModeBrandLogo = filament()->getDarkModeBrandLogo();
$hasDarkModeBrandLogo = filled($darkModeBrandLogo);
Expand Down
2 changes: 2 additions & 0 deletions packages/support/resources/views/components/link.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
</div>
@endif
</a>
@trim
@elseif ($tag === 'button')
<button
@if ($keyBindings || $hasTooltip)
Expand Down Expand Up @@ -222,4 +223,5 @@
</div>
@endif
</button>
@trim
@endif
4 changes: 4 additions & 0 deletions packages/support/src/SupportServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public function packageBooted(): void
return "<?php echo \Filament\Support\Facades\FilamentAsset::renderStyles({$expression}) ?>";
});

Blade::extend(function ($view) {
return preg_replace('/\s*@trim\s*/m', '', $view);
});

Str::macro('sanitizeHtml', function (string $html): string {
return app(HtmlSanitizerInterface::class)->sanitize($html);
});
Expand Down
6 changes: 5 additions & 1 deletion packages/tables/src/Actions/AssociateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ public function getRecordSelect(): Select
);
});

if (filled($titleAttribute)) {
if (
filled($titleAttribute) &&
(! $this->hasCustomRecordTitle()) &&
($this->hasCustomRecordTitleAttribute() || (! $this->getTable()->hasCustomRecordTitle()))
) {
if (empty($relationshipQuery->getQuery()->orders)) {
$relationshipQuery->orderBy($titleAttribute);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/tables/src/Actions/AttachAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ public function getRecordSelect(): Select
),
);

if (filled($titleAttribute)) {
if (
filled($titleAttribute) &&
(! $this->hasCustomRecordTitle()) &&
($this->hasCustomRecordTitleAttribute() || (! $this->getTable()->hasCustomRecordTitle()))
) {
if (empty($relationshipQuery->getQuery()->orders)) {
$relationshipQuery->orderBy($titleAttribute);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/tables/src/Table/Concerns/HasRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public function getRecordTitle(Model $record): string
return $record->getAttributeValue($titleAttribute) ?? $this->getModelLabel();
}

public function hasCustomRecordTitle(): bool
{
return $this->recordTitle !== null;
}

public function getRecordTitleAttribute(): ?string
{
return $this->evaluate($this->recordTitleAttribute);
Expand Down

0 comments on commit f68e0da

Please sign in to comment.