Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Apr 27, 2022
1 parent b3e55ed commit a8fbb29
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 34 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"php": "^8.0",
"danharrin/livewire-rate-limiting": "^0.3|^1.0",
"filament/forms": "self.version",
"filament/support": "self.version",
"filament/tables": "self.version",
"illuminate/auth": "^8.6|^9.0",
"illuminate/console": "^8.6|^9.0",
Expand Down
2 changes: 1 addition & 1 deletion dist/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/app.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/app.js": "/app.js?id=ef538782e4228ac56325076f0648420e",
"/app.css": "/app.css?id=ec5e4c45b7b5855a3d04b151178ada04"
"/app.js": "/app.js?id=f98decb96486da63f19555688c591382",
"/app.css": "/app.css?id=79f6a6edefb2ed4a39311213053761b3"
}
8 changes: 8 additions & 0 deletions dist/module.esm.css
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,14 @@ trix-editor .attachment__metadata .attachment__size {
padding-top: 0.5em;
padding-bottom: 0.5em;
}
.filepond--root[data-style-panel-layout=grid] .filepond--item {
width: calc(50% - 0.5em);
}
@media (min-width: 50em) {
.filepond--root[data-style-panel-layout=grid] .filepond--item {
width: calc(33.33% - 0.5em);
}
}

/* packages/forms/resources/css/components/rich-editor.css */
.dark .trix-button {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Alpine.store('sidebar', {
collapsedGroups: Alpine.$persist([]).as('collapsedGroups'),

groupIsCollapsed(group) {
return this.collapsedGroups.includes(group) && this.isOpen
return this.collapsedGroups.includes(group)
},

toggleCollapsedGroup(group) {
Expand Down
18 changes: 11 additions & 7 deletions resources/views/components/layouts/app/sidebar/group.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@props([
'label' => null,
'collapsible' => true,
'label' => null,
])

<li x-data="{ label: @js($label) }" class="filament-sidebar-group">
@if ($label)
<button
@if($collapsible)
@if ($collapsible)
x-on:click.prevent="$store.sidebar.toggleCollapsedGroup(label)"
@endif
@if (config('filament.layout.sidebar.is_collapsible_on_desktop'))
Expand All @@ -21,7 +21,7 @@ class="flex items-center justify-between w-full"
{{ $label }}
</p>

@if($collapsible)
@if ($collapsible)
<x-heroicon-o-chevron-down :class="\Illuminate\Support\Arr::toCssClasses([
'w-3 h-3 text-gray-600',
'dark:text-gray-300' => config('filament.dark_mode'),
Expand All @@ -35,10 +35,14 @@ class="flex items-center justify-between w-full"
</button>
@endif

<ul x-show="! $store.sidebar.groupIsCollapsed(label)" x-collapse.duration.200ms @class([
'text-sm space-y-1 -mx-3',
'mt-2' => $label,
])>
<ul
x-show="! ($store.sidebar.groupIsCollapsed(label) && {{ config('filament.layout.sidebar.is_collapsible_on_desktop') ? '$store.sidebar.isOpen' : 'true' }})"
x-collapse.duration.200ms
@class([
'text-sm space-y-1 -mx-3',
'mt-2' => $label,
])
>
{{ $slot }}
</ul>
</li>
4 changes: 2 additions & 2 deletions resources/views/components/modal/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class="fixed inset-0 w-full h-full bg-black/50 focus:outline-none filament-modal
x-transition:leave-start="translate-y-0"
x-transition:leave-end="translate-y-8"
x-cloak
{{ $attributes->class(['relative w-full mt-auto md:mb-auto cursor-pointer']) }}
{{ $attributes->class(['relative w-full mt-auto md:mb-auto cursor-pointer pointer-events-none']) }}
>
<div
@class([
'w-full mx-auto p-2 space-y-2 bg-white rounded-xl cursor-default filament-modal-window',
'w-full mx-auto p-2 space-y-2 bg-white rounded-xl cursor-default pointer-events-auto filament-modal-window',
'dark:bg-gray-800' => config('filament.dark_mode'),
'max-w-xs' => $width === 'xs',
'max-w-sm' => $width === 'sm',
Expand Down
5 changes: 5 additions & 0 deletions src/Pages/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Filament\Pages\Actions;

use Closure;
use Filament\Support\Concerns\Configurable;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Traits\Conditionable;
Expand All @@ -26,6 +27,7 @@ class Action extends Component implements Htmlable
use Concerns\HasName;
use Concerns\HasView;
use Conditionable;
use Configurable;
use Macroable;
use Tappable;

Expand All @@ -44,6 +46,9 @@ public static function make(string $name): static

protected function setUp(): void
{
$this->button();

$this->configure();
}

public function call(array $data = [])
Expand Down
21 changes: 21 additions & 0 deletions src/Pages/Actions/Concerns/HasView.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ public function view(string $view): static
return $this;
}

public function button(): static
{
$this->view('filament::pages.actions.button-action');

return $this;
}

public function link(): static
{
$this->view('filament::pages.actions.link-action');

return $this;
}

public function iconButton(): static
{
$this->view('filament::pages.actions.icon-button-action');

return $this;
}

public function getView(): string
{
return $this->view;
Expand Down
5 changes: 5 additions & 0 deletions src/Pages/Actions/Modal/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Filament\Pages\Actions\Modal\Actions;

use Filament\Support\Concerns\Configurable;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Traits\Conditionable;
Expand All @@ -19,6 +20,7 @@ class Action extends Component implements Htmlable
use Concerns\HasName;
use Concerns\HasView;
use Conditionable;
use Configurable;
use Macroable;
use Tappable;

Expand All @@ -37,6 +39,9 @@ public static function make(string $name): static

protected function setUp(): void
{
$this->button();

$this->configure();
}

public function toHtml(): string
Expand Down
7 changes: 7 additions & 0 deletions src/Pages/Actions/Modal/Actions/Concerns/HasView.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public function view(string $view): static
return $this;
}

public function button(): static
{
$this->view('filament::pages.actions.modal.actions.button-action');

return $this;
}

public function getView(): string
{
return $this->view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected static function getAssociateFormRecordSelect(): Select
return Select::make('recordId')
->label(__('filament::resources/relation-managers/associate.action.modal.fields.record_id.label'))
->searchable()
->getSearchResultsUsing(function (Select $component, RelationManager $livewire, string $searchQuery): array {
->getSearchResultsUsing(static function (Select $component, RelationManager $livewire, string $searchQuery): array {
$relationship = $livewire->getRelationship();

$displayColumnName = static::getRecordTitleAttribute();
Expand Down Expand Up @@ -101,7 +101,7 @@ protected static function getAssociateFormRecordSelect(): Select
->pluck($displayColumnName, $relationship->getRelated()->getKeyName())
->toArray();
})
->getOptionLabelUsing(fn (RelationManager $livewire, $value): ?string => static::getRecordTitle($livewire->getRelationship()->getRelated()->query()->find($value)))
->getOptionLabelUsing(static fn (RelationManager $livewire, $value): ?string => static::getRecordTitle($livewire->getRelationship()->getRelated()->query()->find($value)))
->disableLabel();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Resources/RelationManagers/Concerns/CanAttachRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected static function getAttachFormRecordSelect(): Select
return Select::make('recordId')
->label(__('filament::resources/relation-managers/attach.action.modal.fields.record_id.label'))
->searchable()
->getSearchResultsUsing(function (Select $component, RelationManager $livewire, string $searchQuery): array {
->getSearchResultsUsing(static function (Select $component, RelationManager $livewire, string $searchQuery): array {
$relationship = $livewire->getRelationship();

$displayColumnName = static::getRecordTitleAttribute();
Expand Down Expand Up @@ -96,7 +96,7 @@ protected static function getAttachFormRecordSelect(): Select
->pluck($displayColumnName, $relationship->getRelated()->getKeyName())
->toArray();
})
->getOptionLabelUsing(fn (RelationManager $livewire, $value): ?string => static::getRecordTitle($livewire->getRelationship()->getRelated()->query()->find($value)))
->getOptionLabelUsing(static fn (RelationManager $livewire, $value): ?string => static::getRecordTitle($livewire->getRelationship()->getRelated()->query()->find($value)))
->options(function (RelationManager $livewire): array {
if (! static::$shouldPreloadAttachFormRecordSelectOptions) {
return [];
Expand Down
19 changes: 5 additions & 14 deletions src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,9 @@ public static function table(Table $table): Table

public static function resolveRecordRouteBinding($key): ?Model
{
if (static::shouldUseRecordRouteKeyName()) {
return static::getEloquentQuery()
->where(static::getRecordRouteKeyName(), $key)
->first();
}

return app(static::getModel())->resolveRouteBinding($key);
return app(static::getModel())
->resolveRouteBindingQuery(static::getEloquentQuery(), $key, static::getRecordRouteKeyName())
->first();
}

public static function can(string $action, ?Model $record = null): bool
Expand Down Expand Up @@ -269,14 +265,9 @@ public static function getRouteBaseName(): string
return "filament.resources.{$slug}";
}

public static function shouldUseRecordRouteKeyName(): bool
{
return filled(static::$recordRouteKeyName);
}

public static function getRecordRouteKeyName(): string
public static function getRecordRouteKeyName(): ?string
{
return static::$recordRouteKeyName ?? app(static::getModel())->getRouteKeyName();
return static::$recordRouteKeyName;
}

public static function getRoutes(): Closure
Expand Down

0 comments on commit a8fbb29

Please sign in to comment.