Skip to content

Commit

Permalink
Status editing updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alecritson committed Jan 3, 2024
1 parent 3d7faf2 commit d88fdd4
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 14 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"spatie/laravel-blink": "^1.6",
"spatie/laravel-medialibrary": "^10.0.0",
"spatie/laravel-permission": "^5.10",
"technikermathe/blade-lucide-icons": "^v2.24.0"
"technikermathe/blade-lucide-icons": "^v2.24.0",
"awcodes/shout": "2.x-dev"
},
"require-dev": {
"laravel/pint": "1.13.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/admin/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"barryvdh/laravel-dompdf": "^2.0",
"technikermathe/blade-lucide-icons": "^v2.24.0",
"marvinosswald/filament-input-select-affix": "^0.1.0",
"leandrocfe/filament-apex-charts": "^3.0"
"leandrocfe/filament-apex-charts": "^3.0",
"awcodes/shout": "2.x-dev"
},
"extra": {
"laravel": {
Expand Down
27 changes: 27 additions & 0 deletions packages/admin/resources/lang/en/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

'plural_label' => 'Products',

'status' => [
'unpublished' => [
'content' => 'Currently in draft status, this product is concealed across all channels and customer groups.',
],
'availability' => [
'customer_groups' => 'This product is currently unavailable for all customer groups.',
'channels' => 'This product is currently unavailable for all channels.',
],
],

'table' => [
'status' => [
'label' => 'Status',
Expand All @@ -27,6 +37,13 @@
],
],

'actions' => [
'edit_status' => [
'label' => 'Update Status',
'heading' => 'Update Status',
],
],

'form' => [
'name' => [
'label' => 'Name',
Expand All @@ -42,6 +59,16 @@
],
'status' => [
'label' => 'Status',
'options' => [
'published' => [
'label' => 'Published',
'description' => 'This product will be available across all enabled customer groups and channels',
],
'draft' => [
'label' => 'Draft',
'description' => 'This product will be hidden across all channels and customer groups',
],
],
],
'tags' => [
'label' => 'Tags',
Expand Down
31 changes: 19 additions & 12 deletions packages/admin/src/Filament/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lunar\Admin\Filament\Resources;

use Awcodes\Shout\Components\Shout;
use Filament\Forms;
use Filament\Forms\Components\Component;
use Filament\Forms\Form;
Expand Down Expand Up @@ -76,6 +77,24 @@ public static function getDefaultForm(Form $form): Form
{
return $form
->schema([
Shout::make('product-status')
->content(
__('lunarpanel::product.status.unpublished.content')
)->type('danger')->hidden(
fn (Model $record) => $record?->status == 'published'
),
Shout::make('product-customer-groups')
->content(
__('lunarpanel::product.status.availability.customer_groups')
)->type('danger')->hidden(function (Model $record) {
return $record->customerGroups()->where('enabled', true)->count();
}),
Shout::make('product-channels')
->content(
__('lunarpanel::product.status.availability.channels')
)->type('danger')->hidden(function (Model $record) {
return $record->channels()->where('enabled', true)->count();
}),
Forms\Components\Section::make()
->schema(
static::getMainFormComponents(),
Expand All @@ -90,7 +109,6 @@ protected static function getMainFormComponents(): array
return [
static::getBrandFormComponent(),
static::getProductTypeFormComponent(),
static::getStatusFormComponent(),
static::getTagsFormComponent(),
];
}
Expand Down Expand Up @@ -162,17 +180,6 @@ public static function getProductTypeFormComponent(): Component
->required();
}

protected static function getStatusFormComponent(): Component
{
return Forms\Components\Select::make('status')
->label(__('lunarpanel::product.form.status.label'))
->options([
'draft' => 'Draft',
'published' => 'Published',
])
->selectablePlaceholder(false);
}

protected static function getTagsFormComponent(): Component
{
return Forms\Components\TextInput::make('tags')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Lunar\Admin\Filament\Resources\ProductResource\Pages;

use Filament\Actions;
use Filament\Forms;
use Filament\Support\Facades\FilamentIcon;
use Lunar\Admin\Filament\Resources\ProductResource;
use Lunar\Admin\Support\Pages\BaseEditRecord;
Expand All @@ -23,6 +24,25 @@ public static function getNavigationIcon(): ?string
protected function getDefaultHeaderActions(): array
{
return [
Actions\EditAction::make('update_status')
->label(
__('lunarpanel::product.actions.edit_status.label')
)
->modalHeading(
__('lunarpanel::product.actions.edit_status.heading')
)
->record(
$this->record
)->form([
Forms\Components\Radio::make('status')->options([
'published' => __('lunarpanel::product.form.status.options.published.label'),
'draft' => __('lunarpanel::product.form.status.options.draft.label'),
])
->descriptions([
'published' => __('lunarpanel::product.form.status.options.published.description'),
'draft' => __('lunarpanel::product.form.status.options.draft.description'),
])->live(),
]),
Actions\DeleteAction::make(),
];
}
Expand Down

0 comments on commit d88fdd4

Please sign in to comment.