Skip to content

Commit

Permalink
Update tables actions icons (#312)
Browse files Browse the repository at this point in the history
* feat: reorder and change table actions icons

* fix: phpstan types
  • Loading branch information
mckenziearts authored Dec 7, 2024
1 parent fa043a7 commit 46a61ae
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="filament-icon-picker-icon-column px-4 py-3">
@if ($icon = $getState())
<x-icon class="size-6" name="{{$icon}}" />
<x-icon class="size-6" :name="$icon" aria-hidden="true" />
@endif
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
@endphp

<div>
@if ($discount->type === \Shopper\Core\Enum\DiscountType::Percentage->value)
@if ($discount->type === \Shopper\Core\Enum\DiscountType::Percentage)
{{ $discount->value . '%' }}
@else
{{ shopper_money_format(amount: $discount->value * 100, currency: $discount->zone?->currency_code) }}
{{ shopper_money_format(amount: $discount->value, currency: $discount->zone?->currency_code) }}
@endif
</div>
7 changes: 0 additions & 7 deletions packages/admin/src/Livewire/Pages/Attribute/Browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,22 @@ public function table(Table $table): Table
->columns([
IconColumn::make('icon')
->label(__('shopper::forms.label.icon')),

Tables\Columns\TextColumn::make('name')
->label(__('shopper::forms.label.name'))
->searchable(),

Tables\Columns\TextColumn::make('type')
->label(__('shopper::forms.label.type'))
->formatStateUsing(fn (Attribute $record) => $record->type_formatted)
->searchable(),

Tables\Columns\IconColumn::make('is_enabled')
->label(__('shopper::words.is_enabled'))
->boolean(),

Tables\Columns\IconColumn::make('is_searchable')
->label(__('shopper::forms.label.is_searchable'))
->boolean(),

Tables\Columns\IconColumn::make('is_filterable')
->label(__('shopper::forms.label.is_filterable'))
->boolean(),

Tables\Columns\TextColumn::make('updated_at')
->label(__('shopper::forms.label.updated_at'))
->date()
Expand All @@ -78,7 +72,6 @@ public function table(Table $table): Table

Tables\Actions\Action::make('edit')
->label(__('shopper::forms.actions.edit'))
->color('gray')
->icon('untitledui-edit-04')
->action(
fn (Attribute $record) => $this->dispatch(
Expand Down
35 changes: 18 additions & 17 deletions packages/admin/src/Livewire/Pages/Brand/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function table(Table $table): Table
Tables\Columns\SpatieMediaLibraryImageColumn::make('Logo')
->collection(config('shopper.media.storage.thumbnail_collection'))
->circular()
->defaultImageUrl(shopper_fallback_url())
->grow(false),
Tables\Columns\TextColumn::make('name')
->label(__('shopper::forms.label.name'))
Expand All @@ -60,6 +59,7 @@ public function table(Table $table): Table
->actions([
Tables\Actions\Action::make('edit')
->label(__('shopper::forms.actions.edit'))
->icon('untitledui-edit-04')
->action(
fn ($record) => $this->dispatch(
'openPanel',
Expand All @@ -70,22 +70,6 @@ public function table(Table $table): Table
->visible(Shopper::auth()->user()->can('edit_brands')),
])
->groupedBulkActions([
Tables\Actions\DeleteBulkAction::make()
->label(__('shopper::forms.actions.delete'))
->requiresConfirmation()
->action(function (Collection $records): void {
$records->each->delete();

Notification::make()
->title(
__('shopper::notifications.delete', [
'item' => __('shopper::pages/brands.single'),
])
)
->success()
->send();
})
->deselectRecordsAfterCompletion(),
Tables\Actions\BulkAction::make('enabled')
->label(__('shopper::forms.actions.enable'))
->icon('untitledui-check-verified')
Expand Down Expand Up @@ -119,6 +103,23 @@ public function table(Table $table): Table
->send();
})
->deselectRecordsAfterCompletion(),
Tables\Actions\DeleteBulkAction::make()
->label(__('shopper::forms.actions.delete'))
->icon('untitledui-trash-03')
->requiresConfirmation()
->action(function (Collection $records): void {
$records->each->delete();

Notification::make()
->title(
__('shopper::notifications.delete', [
'item' => __('shopper::pages/brands.single'),
])
)
->success()
->send();
})
->deselectRecordsAfterCompletion(),
])
->filters([
Tables\Filters\TernaryFilter::make('is_enabled'),
Expand Down
36 changes: 19 additions & 17 deletions packages/admin/src/Livewire/Pages/Category/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public function table(Table $table): Table
(new CategoryRepository)
->with('parent:id,name')
->query()
->latest()
)
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('image')
->collection(config('shopper.media.storage.thumbnail_collection'))
->circular()
->defaultImageUrl(shopper_fallback_url())
->grow(false),
Tables\Columns\TextColumn::make('name')
->label(__('shopper::forms.label.name'))
Expand Down Expand Up @@ -71,6 +71,7 @@ public function table(Table $table): Table
->actions([
Tables\Actions\Action::make('edit')
->label(__('shopper::forms.actions.edit'))
->icon('untitledui-edit-04')
->action(
fn ($record) => $this->dispatch(
'openPanel',
Expand All @@ -81,54 +82,55 @@ public function table(Table $table): Table
->visible($this->getUser()->can('edit_categories')),
])
->groupedBulkActions([
Tables\Actions\DeleteBulkAction::make()
->label(__('shopper::forms.actions.delete'))
->requiresConfirmation()
Tables\Actions\BulkAction::make('enabled')
->label(__('shopper::forms.actions.enable'))
->icon('untitledui-check-verified')
->action(function (Collection $records): void {
$records->each->delete();
$records->each->updateStatus(); // @phpstan-ignore-line

Notification::make()
->title(
__('shopper::notifications.delete', [
__('shopper::notifications.enabled', [
'item' => __('shopper::pages/categories.single'),
])
)
->success()
->send();
})
->visible($this->getUser()->can('delete_categories'))
->deselectRecordsAfterCompletion(),
Tables\Actions\BulkAction::make('enabled')
->label(__('shopper::forms.actions.enable'))
->icon('untitledui-check-verified')
Tables\Actions\BulkAction::make('disabled')
->label(__('shopper::forms.actions.disable'))
->icon('untitledui-slash-circle-01')
->action(function (Collection $records): void {
$records->each->updateStatus(); // @phpstan-ignore-line
$records->each->updateStatus(status: false); // @phpstan-ignore-line

Notification::make()
->title(
__('shopper::notifications.enabled', [
__('shopper::notifications.disabled', [
'item' => __('shopper::pages/categories.single'),
])
)
->success()
->send();
})
->deselectRecordsAfterCompletion(),
Tables\Actions\BulkAction::make('disabled')
->label(__('shopper::forms.actions.disable'))
->icon('untitledui-slash-circle-01')
Tables\Actions\DeleteBulkAction::make()
->label(__('shopper::forms.actions.delete'))
->icon('untitledui-trash-03')
->requiresConfirmation()
->action(function (Collection $records): void {
$records->each->updateStatus(status: false); // @phpstan-ignore-line
$records->each->delete();

Notification::make()
->title(
__('shopper::notifications.disabled', [
__('shopper::notifications.delete', [
'item' => __('shopper::pages/categories.single'),
])
)
->success()
->send();
})
->visible($this->getUser()->can('delete_categories'))
->deselectRecordsAfterCompletion(),
])
->persistFiltersInSession()
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Livewire/Pages/Collection/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function form(Form $form): Form
->label(__('shopper::forms.label.image_preview'))
->collection(config('shopper.media.storage.thumbnail_collection'))
->image()
->maxSize(1024),
->maxSize(config('shopper.media.max_size.thumbnail')),

Forms\Components\DateTimePicker::make('published_at')
->label(__('shopper::forms.label.availability'))
Expand Down
22 changes: 14 additions & 8 deletions packages/admin/src/Livewire/Pages/Customers/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function table(Table $table): Table
->with(['roles', 'addresses'])
->query()
->scopes('customers')
->latest()
)
->columns([
Tables\Columns\ViewColumn::make('first_name')
Expand All @@ -51,19 +52,29 @@ public function table(Table $table): Table
Tables\Columns\TextColumn::make('country')
->label(__('shopper::forms.label.country'))
->getStateUsing(
fn ($record): ?string => Country::find($record->addresses->first()?->country_id)?->name ?? null
fn ($record): ?string => Country::query()->find($record->addresses->first()?->country_id)?->name ?? null
)
->sortable(),
Tables\Columns\TextColumn::make('orders_count')
->counts([
'orders' => fn (Builder $query) => $query->where('status', OrderStatus::Pending->value),
'orders' => fn (Builder $query) => $query->where('status', OrderStatus::Paid()),
])
->label(__('shopper::pages/customers.orders.placed')),
Tables\Columns\TextColumn::make('created_at')
->label(__('shopper::forms.label.registered_at'))
->date()
->sortable(),
])
->actions([
Tables\Actions\Action::make('view')
->label(__('shopper::forms.actions.view'))
->icon('untitledui-eye')
->action(fn ($record) => $this->redirectRoute(
name: 'shopper.customers.show',
parameters: ['user' => $record],
navigate: true
)),
])
->filters([
Tables\Filters\TernaryFilter::make('email_verified_at')
->label(__('shopper::forms.label.email_verified'))
Expand All @@ -87,12 +98,7 @@ public function table(Table $table): Table
);
}),
])
->persistFiltersInSession()
->actions([
Tables\Actions\Action::make('view')
->label(__('shopper::forms.actions.view'))
->url(fn ($record): string => route('shopper.customers.show', $record)),
]);
->persistFiltersInSession();
}

public function render(): View
Expand Down
2 changes: 2 additions & 0 deletions packages/admin/src/Livewire/Pages/Discount/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function table(Table $table): Table
->actions([
Tables\Actions\Action::make('edit')
->label(__('shopper::forms.actions.edit'))
->icon('untitledui-edit-04')
->action(
fn (Discount $record) => $this->dispatch(
'openPanel',
Expand All @@ -98,6 +99,7 @@ public function table(Table $table): Table
->groupedBulkActions([
Tables\Actions\DeleteBulkAction::make()
->label(__('shopper::forms.actions.delete'))
->icon('untitledui-trash-03')
->requiresConfirmation()
->action(function (Collection $records): void {
$records->each->delete();
Expand Down
15 changes: 8 additions & 7 deletions packages/admin/src/Livewire/Pages/Product/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Filament\Tables\Filters\QueryBuilder\Constraints\TextConstraint;
use Filament\Tables\Table;
use Illuminate\Contracts\View\View;
use Shopper\Core\Models\Product;
use Shopper\Core\Repositories\ProductRepository;
use Shopper\Feature;
use Shopper\Livewire\Pages\AbstractPageComponent;
Expand All @@ -37,10 +36,11 @@ public function table(Table $table): Table
return $table
->query(
(new ProductRepository)
->with(['brand', 'variants'])
->query()
->with(['brand', 'variants'])
->withCount(['variants'])
->where('parent_id', null)
->latest()
)
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('thumbnail')
Expand All @@ -52,12 +52,12 @@ public function table(Table $table): Table
->searchable()
->toggleable()
->sortable(),
Tables\Columns\TextColumn::make('price_amount')
Tables\Columns\TextColumn::make('price_amount') // @phpstan-ignore-line
->label(__('shopper::forms.label.price'))
->money(currency: shopper_currency())
->currency(currency: shopper_currency())
->sortable(),
Tables\Columns\IconColumn::make('is_visible')
->label(__('shopper::forms.label.availability'))
->label(__('shopper::forms.label.visibility'))
->sortable()
->toggleable(),
Tables\Columns\TextColumn::make('brand.name')
Expand Down Expand Up @@ -89,7 +89,8 @@ public function table(Table $table): Table
Tables\Actions\Action::make('edit')
->label(__('shopper::forms.actions.edit'))
->icon('untitledui-edit-04')
->action(fn (Product $record) => $this->redirectRoute(
->color('primary')
->action(fn ($record) => $this->redirectRoute(
name: 'shopper.products.edit',
parameters: ['product' => $record],
navigate: true
Expand All @@ -99,7 +100,7 @@ public function table(Table $table): Table
->modalIcon('untitledui-trash-03')
->color('danger')
->requiresConfirmation()
->action(fn (Product $record) => $record->delete()),
->action(fn ($record) => $record->delete()),
])
->tooltip('Actions'),
])
Expand Down
3 changes: 2 additions & 1 deletion packages/admin/src/Livewire/Pages/Settings/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public function store(): void
{
$this->saveSettings($this->form->getState());

Cache::forget('shopper-setting-default_currency_id');
Cache::forget('shopper-setting.default_currency_id');
Cache::forget('shopper-setting.default_currency');

Notification::make()
->title(__('shopper::notifications.store_info'))
Expand Down
Loading

0 comments on commit 46a61ae

Please sign in to comment.