Skip to content

Commit

Permalink
Merge pull request #97 from lara-zeus/actions
Browse files Browse the repository at this point in the history
better actions for tables and update zeus core
  • Loading branch information
atmonshi authored Jun 6, 2023
2 parents 2cafc25 + c3f4fa0 commit 76179f6
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 105 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Security

If you discover any security related issues, please email wh7r.com@gmail.com instead of using the issue tracker.
If you discover any security related issues, please email info@larazeus.com instead of using the issue tracker.

## Credits

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
"news",
"wordpress laravel",
"wordpress alternative",
"laravel cms"
"laravel cms",
"filamentphp"
],
"homepage": "https://larazeus.com",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "php coder",
"email": "wh7r.com@gmail.com",
"email": "info@larazeus.com",
"role": "Owner"
}
],
Expand Down
150 changes: 78 additions & 72 deletions composer.lock

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions resources/views/filament/columns/page-title.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<a href="{{ route('page',$getRecord()->slug) }}" target="_blank" class="block">
<div class="filament-tables-text-column text-primary-600 transition hover:underline hover:text-primary-500 focus:underline focus:text-primary-500">
@if($getRecord()->password !== null)
<span x-tooltip.raw="{{ __('Password Protected') }}" title="{{ __('Password Protected') }}">
<x-iconpark-lock class="w-4 h-4 inline-flex text-danger-600"/>
</span>
@endif
{{ $getRecord()->title }}
</div>
</a>
<div class="filament-tables-text-column text-primary-600">
@if($getRecord()->password !== null)
<span x-tooltip.raw="{{ __('Password Protected') }}" title="{{ __('Password Protected') }}">
<x-iconpark-lock class="w-4 h-4 inline-flex text-danger-600"/>
</span>
@endif
{{ $getRecord()->title }}
</div>
28 changes: 13 additions & 15 deletions resources/views/filament/columns/post-title.blade.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<a href="{{ route('post',$getRecord()->slug) }}" target="_blank" class="block">
<div class="filament-tables-text-column text-primary-600 transition hover:underline hover:text-primary-500 focus:underline focus:text-primary-500">
@if($getRecord()->password !== null)
<span x-tooltip.raw="{{ __('Password Protected') }}" title="{{ __('Password Protected') }}">
<x-iconpark-lock class="w-4 h-4 inline-flex text-danger-600"/>
</span>
@endif
<div class="filament-tables-text-column text-primary-600">
@if($getRecord()->password !== null)
<span x-tooltip.raw="{{ __('Password Protected') }}" title="{{ __('Password Protected') }}">
<x-iconpark-lock class="w-4 h-4 inline-flex text-danger-600"/>
</span>
@endif

@if($getRecord()->sticky_until !== null)
<span x-tooltip.raw="{{ __('Sticky Until') }} {{ $getRecord()->sticky_until->diffForHumans() }}" title="{{ __('Sticky Until') }} {{ $getRecord()->sticky_until->diffForHumans() }}">
<x-iconpark-pin class="w-4 h-4 inline-flex text-secondary-500"/>
</span>
@endif
@if($getRecord()->sticky_until !== null)
<span x-tooltip.raw="{{ __('Sticky Until') }} {{ $getRecord()->sticky_until->diffForHumans() }}" title="{{ __('Sticky Until') }} {{ $getRecord()->sticky_until->diffForHumans() }}">
<x-iconpark-pin class="w-4 h-4 inline-flex text-secondary-500"/>
</span>
@endif

{{ $getRecord()->title }}
</div>
</a>
{{ $getRecord()->title }}
</div>
10 changes: 10 additions & 0 deletions src/Filament/Resources/FaqResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Filament\Forms\Components\Textarea;
use Filament\Resources\Form;
use Filament\Resources\Table;
use Filament\Tables\Actions\ActionGroup;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use LaraZeus\Sky\Filament\Resources\FaqResource\Pages;
use LaraZeus\Sky\Models\Faq;
Expand Down Expand Up @@ -62,6 +65,13 @@ public static function table(Table $table): Table
return $table
->columns([
TextColumn::make('question'),
])
->actions([
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),
DeleteAction::make('delete')
->label(__('Delete')),
]),
]);
}

Expand Down
17 changes: 17 additions & 0 deletions src/Filament/Resources/FaqResource/Pages/ListFaqs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace LaraZeus\Sky\Filament\Resources\FaqResource\Pages;

use Filament\Pages\Actions\Action;
use Filament\Pages\Actions\CreateAction;
use Filament\Pages\Actions\LocaleSwitcher;
use Filament\Resources\Pages\ListRecords;
use LaraZeus\Sky\Filament\Resources\FaqResource;

Expand All @@ -10,4 +13,18 @@ class ListFaqs extends ListRecords
use ListRecords\Concerns\Translatable;

protected static string $resource = FaqResource::class;

protected function getActions(): array
{
return [
CreateAction::make(),
Action::make('Open')
->color('warning')
->icon('heroicon-o-external-link')
->label(__('Open'))
->url(fn (): string => route('faq'))
->openUrlInNewTab(),
LocaleSwitcher::make(),
];
}
}
17 changes: 17 additions & 0 deletions src/Filament/Resources/LibraryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
use Filament\Forms\Components\TextInput;
use Filament\Resources\Form;
use Filament\Resources\Table;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\ActionGroup;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\SpatieTagsColumn;
use Filament\Tables\Columns\TextColumn;
use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -115,6 +119,19 @@ public static function table(Table $table): Table
->label(__('Library Tags'))
->type('library'),
])
->actions([
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),
Action::make('Open')
->color('warning')
->icon('heroicon-o-external-link')
->label(__('Open'))
->url(fn (Model $record): string => route('library.item', ['slug' => $record->slug]))
->openUrlInNewTab(),
DeleteAction::make('delete')
->label(__('Delete')),
]),
])
->defaultSort('id', 'desc');
}

Expand Down
22 changes: 19 additions & 3 deletions src/Filament/Resources/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@
use Filament\Forms\Components\TextInput;
use Filament\Resources\Form;
use Filament\Resources\Table;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\ActionGroup;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\ViewColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use LaraZeus\Sky\Filament\Resources\PageResource\Pages;
use LaraZeus\Sky\Models\Post;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;

class PageResource extends SkyResource
{
public static function getModel(): string
{
return config('zeus-sky.models.post') ?? Post::class;
return config('zeus-sky.models.post');
}

protected static ?string $slug = 'pages';
Expand Down Expand Up @@ -143,9 +146,22 @@ public static function table(Table $table): Table
->sortable(['status'])
->searchable(['status'])
->view('zeus-sky::filament.columns.status-desc')
->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')),
->tooltip(fn (Model $record): string => $record->published_at->format('Y/m/d | H:i A')),
])
->defaultSort('id', 'desc')
->actions([
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),
Action::make('Open')
->color('warning')
->icon('heroicon-o-external-link')
->label(__('Open'))
->url(fn (Model $record): string => route('page', ['slug' => $record]))
->openUrlInNewTab(),
DeleteAction::make('delete')
->label(__('Delete')),
]),
])
->filters([
SelectFilter::make('status')
->multiple()
Expand Down
20 changes: 18 additions & 2 deletions src/Filament/Resources/PostResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
use Filament\Forms\Components\TextInput;
use Filament\Resources\Form;
use Filament\Resources\Table;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\ActionGroup;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\SpatieTagsColumn;
use Filament\Tables\Columns\ViewColumn;
use Filament\Tables\Filters\Filter;
Expand All @@ -24,7 +28,6 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use LaraZeus\Sky\Filament\Resources\PostResource\Pages;
use LaraZeus\Sky\Models\Post;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;

class PostResource extends SkyResource
Expand Down Expand Up @@ -176,7 +179,7 @@ public static function table(Table $table): Table
->sortable(['status'])
->searchable(['status'])
->view('zeus-sky::filament.columns.status-desc')
->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')),
->tooltip(fn (Model $record): string => $record->published_at->format('Y/m/d | H:i A')),

SpatieTagsColumn::make('tags')
->label(__('Post Tags'))
Expand All @@ -187,6 +190,19 @@ public static function table(Table $table): Table
->type('category'),
])
->defaultSort('id', 'desc')
->actions([
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),
Action::make('Open')
->color('warning')
->icon('heroicon-o-external-link')
->label(__('Open'))
->url(fn (Model $record): string => route('post', ['slug' => $record]))
->openUrlInNewTab(),
DeleteAction::make('delete')
->label(__('Delete')),
]),
])
->filters([
SelectFilter::make('status')
->multiple()
Expand Down

0 comments on commit 76179f6

Please sign in to comment.