Skip to content

Commit

Permalink
优化产品资源页面和数据处理逻辑
Browse files Browse the repository at this point in the history
- 调整了多个资源页面的创建、编辑和查看逻辑
- 优化了产品资源的查找和解析逻辑
-统一了资源页面的字段和表格列定义
- 移除了冗余的字段和方法
- 调整了部分资源的权限控制逻辑
  • Loading branch information
liushoukun committed Oct 10, 2024
1 parent 4896445 commit 7230057
Show file tree
Hide file tree
Showing 31 changed files with 162 additions and 244 deletions.
3 changes: 3 additions & 0 deletions src/Clusters/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

class Product extends Cluster
{



protected static ?string $navigationIcon = 'heroicon-o-shopping-bag';


Expand Down
5 changes: 4 additions & 1 deletion src/Clusters/Product/Resources/BrandResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource\Pages\CreateBrand;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource\Pages\EditBrand;
Expand Down Expand Up @@ -86,6 +86,8 @@ public static function form(Form $form) : Form
Forms\Components\Radio::make('status')->label(__('red-jasmine-product::brand.fields.status'))
->options(BrandStatusEnum::options())
->inline()->default(BrandStatusEnum::ENABLE->value),

...static::operateFormSchemas()
])->columns(1);
}

Expand All @@ -111,6 +113,7 @@ public static function table(Table $table) : Table
->badge()->formatStateUsing(fn($state) => $state->label())->color(fn($state) => $state->color()),


...static::operateTableColumns()
])
->filters([
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource\Pages;

use Filament\Resources\Pages\CreateRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource;

class CreateBrand extends CreateRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource;

class EditBrand extends EditRecord
Expand Down
2 changes: 1 addition & 1 deletion src/Clusters/Product/Resources/ProductCategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
use RedJasmine\FilamentProduct\Clusters\Product;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductCategoryResource\Pages\CreateProductCategory;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductCategoryResource\Pages\EditProductCategory;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductCategoryResource\Pages\ListProductCategories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductCategoryResource\Pages;

use Filament\Resources\Pages\CreateRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductCategoryResource;

class CreateProductCategory extends CreateRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductCategoryResource;

class EditProductCategory extends EditRecord
Expand Down
32 changes: 7 additions & 25 deletions src/Clusters/Product/Resources/ProductPropertyGroupResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use RedJasmine\FilamentProduct\Clusters\Product;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\Product\Application\Property\Services\ProductPropertyGroupCommandService;
use RedJasmine\Product\Application\Property\Services\ProductPropertyGroupQueryService;
use RedJasmine\Product\Application\Property\UserCases\Commands\ProductPropertyGroupCreateCommand;
Expand Down Expand Up @@ -64,15 +64,9 @@ public static function form(Form $form) : Form
->required()
->default(PropertyStatusEnum::ENABLE)->options(PropertyStatusEnum::options())
->inline()->inlineLabel(false)->required(),
Forms\Components\TextInput::make('creator_type')->label(__('red-jasmine-product::product-property-group.fields.creator_type'))
->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('creator_id')->label(__('red-jasmine-product::product-property-group.fields.creator_id'))
->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('updater_type')->label(__('red-jasmine-product::product-property-group.fields.updater_type'))
->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('updater_id')->label(__('red-jasmine-product::product-property-group.fields.updater_id'))
->readOnly()->visibleOn('view'),
])->columns(1);

...static::operateFormSchemas()
])->columns(1);
}

public static function table(Table $table) : Table
Expand All @@ -90,21 +84,9 @@ public static function table(Table $table) : Table
->sortable(),
Tables\Columns\TextColumn::make('status')->label(__('red-jasmine-product::product-property-group.fields.status'))
->badge()->formatStateUsing(fn($state) => $state->label())->color(fn($state) => $state->color()),
Tables\Columns\TextColumn::make('creator_type')->label(__('red-jasmine-product::product-property-group.fields.creator_type'))
->searchable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('creator_id')->label(__('red-jasmine-product::product-property-group.fields.creator_id'))
->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updater_type')->label(__('red-jasmine-product::product-property-group.fields.updater_type'))
->searchable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updater_id')->label(__('red-jasmine-product::product-property-group.fields.updater_id'))
->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_at')->label(__('red-jasmine-product::product-property-group.fields.created_at'))
->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')->label(__('red-jasmine-product::product-property-group.fields.updated_at'))
->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')->label(__('red-jasmine-product::product-property-group.fields.deleted_at'))
->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),
])

...static::operateTableColumns()
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
Expand Down
21 changes: 7 additions & 14 deletions src/Clusters/Product/Resources/ProductPropertyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use RedJasmine\FilamentProduct\Clusters\Product;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\Product\Application\Property\Services\ProductPropertyCommandService;
use RedJasmine\Product\Application\Property\Services\ProductPropertyQueryService;
use RedJasmine\Product\Application\Property\UserCases\Commands\ProductPropertyCreateCommand;
Expand Down Expand Up @@ -88,11 +88,9 @@ public static function form(Form $form) : Form
->required()
->default(PropertyStatusEnum::ENABLE)->options(PropertyStatusEnum::options())
->inline()->inlineLabel(false)->required(),
Forms\Components\TextInput::make('creator_type')->label(__('red-jasmine-product::product-property.fields.creator_type'))->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('creator_id')->label(__('red-jasmine-product::product-property.fields.creator_id'))->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('updater_type')->label(__('red-jasmine-product::product-property.fields.updater_type'))->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('updater_id')->label(__('red-jasmine-product::product-property.fields.updater_id'))->readOnly()->visibleOn('view'),
]);

...static::operateFormSchemas()
]);
}

public static function table(Table $table) : Table
Expand All @@ -111,14 +109,9 @@ public static function table(Table $table) : Table
Tables\Columns\IconColumn::make('is_allow_alias')->label(__('red-jasmine-product::product-property.fields.is_allow_alias'))->boolean(),
Tables\Columns\TextColumn::make('sort')->label(__('red-jasmine-product::product-property.fields.sort'))->sortable(),
Tables\Columns\TextColumn::make('status')->label(__('red-jasmine-product::product-property.fields.status'))->badge()->formatStateUsing(fn($state) => $state->label())->color(fn($state) => $state->color()),
Tables\Columns\TextColumn::make('creator_type')->label(__('red-jasmine-product::product-property.fields.creator_type'))->searchable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('creator_id')->label(__('red-jasmine-product::product-property.fields.creator_id'))->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updater_type')->searchable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updater_id')->label(__('red-jasmine-product::product-property.fields.updater_id'))->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_at')->label(__('red-jasmine-product::product-property.fields.created_at'))->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')->label(__('red-jasmine-product::product-property.fields.updated_at'))->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')->label(__('red-jasmine-product::product-property.fields.deleted_at'))->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),
])

...static::operateTableColumns()
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductPropertyResource\Pages;

use Filament\Resources\Pages\CreateRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductPropertyResource;

class CreateProductProperty extends CreateRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductPropertyResource;

class EditProductProperty extends EditRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductPropertyResource;

class ViewProductProperty extends ViewRecord
Expand Down
16 changes: 4 additions & 12 deletions src/Clusters/Product/Resources/ProductPropertyValueResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use RedJasmine\FilamentProduct\Clusters\Product;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\Product\Application\Property\Services\ProductPropertyValueCommandService;
use RedJasmine\Product\Application\Property\Services\ProductPropertyValueQueryService;
use RedJasmine\Product\Application\Property\UserCases\Commands\ProductPropertyValueCreateCommand;
Expand Down Expand Up @@ -81,10 +81,7 @@ public static function form(Form $form) : Form
->default(PropertyStatusEnum::ENABLE)
->useEnum(PropertyStatusEnum::class),

Forms\Components\TextInput::make('creator_type')->label(__('red-jasmine-product::product-property-value.fields.creator_type'))->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('creator_id')->label(__('red-jasmine-product::product-property-value.fields.creator_id'))->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('updater_type')->label(__('red-jasmine-product::product-property-value.fields.updater_type'))->readOnly()->visibleOn('view'),
Forms\Components\TextInput::make('updater_id')->label(__('red-jasmine-product::product-property-value.fields.updater_id'))->readOnly()->visibleOn('view'),
...static::operateFormSchemas()
]);
}

Expand All @@ -106,13 +103,8 @@ public static function table(Table $table) : Table
Tables\Columns\TextColumn::make('group.name')->label(__('red-jasmine-product::product-property-value.fields.group.name')),
Tables\Columns\TextColumn::make('sort')->label(__('red-jasmine-product::product-property-value.fields.sort'))->sortable(),
Tables\Columns\TextColumn::make('status')->label(__('red-jasmine-product::product-property-value.fields.status'))->enum(),
Tables\Columns\TextColumn::make('creator_type')->label(__('red-jasmine-product::product-property-value.fields.creator_type'))->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('creator_id')->label(__('red-jasmine-product::product-property-value.fields.creator_id'))->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updater_type')->label(__('red-jasmine-product::product-property-value.fields.updater_type'))->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updater_id')->label(__('red-jasmine-product::product-property-value.fields.updater_id'))->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_at')->label(__('red-jasmine-product::product-property-value.fields.created_at'))->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')->label(__('red-jasmine-product::product-property-value.fields.updated_at'))->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')->label(__('red-jasmine-product::product-property-value.fields.deleted_at'))->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true),

...static::operateTableColumns()
])
->filters([
Tables\Filters\TrashedFilter::make(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductPropertyValueResource\Pages;

use Filament\Resources\Pages\CreateRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductPropertyValueResource;

class CreateProductPropertyValue extends CreateRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductPropertyValueResource;

class EditProductPropertyValue extends EditRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductPropertyValueResource;

class ViewProductPropertyValue extends ViewRecord
Expand Down
Loading

0 comments on commit 7230057

Please sign in to comment.