mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
migrate searchbox to mode related
This commit is contained in:
@@ -10,6 +10,8 @@ class CreateCategoryIcon extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CategoryIconResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.system.category-icon-resource.pages.create-record';
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
return array_filter($data);
|
||||
@@ -19,4 +21,11 @@ class CreateCategoryIcon extends CreateRecord
|
||||
{
|
||||
return static::$resource::getUrl('index');
|
||||
}
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
return [
|
||||
'desc' => nexus_trans('label.icon.desc')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ class EditCategoryIcon extends EditRecord
|
||||
{
|
||||
protected static string $resource = CategoryIconResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.system.category-icon-resource.pages.edit-record';
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -26,4 +28,11 @@ class EditCategoryIcon extends EditRecord
|
||||
{
|
||||
return static::$resource::getUrl('index');
|
||||
}
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
return [
|
||||
'desc' => nexus_trans('label.icon.desc')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,11 @@ class ListCategoryIcons extends PageList
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
return [
|
||||
'desc' => nexus_trans('label.icon.desc')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,10 +79,27 @@ class SectionResource extends Resource
|
||||
,
|
||||
Forms\Components\Toggle::make('showsubcat')->label(__('label.search_box.showsubcat')),
|
||||
Forms\Components\Section::make(__('label.search_box.showsubcat'))->schema([
|
||||
Forms\Components\Repeater::make('extra.' . SearchBox::EXTRA_TAXONOMY_LABELS)->schema([
|
||||
Forms\Components\Select::make('torrent_field')->options(SearchBox::getSubCatOptions())->label(__('label.search_box.torrent_field')),
|
||||
Forms\Components\TextInput::make('display_text')->label(__('label.search_box.taxonomy_display_text')),
|
||||
])->label(__('label.search_box.taxonomies'))->columns(2),
|
||||
Forms\Components\Repeater::make('extra.' . SearchBox::EXTRA_TAXONOMY_LABELS)
|
||||
->schema([
|
||||
Forms\Components\Select::make('torrent_field')->options(SearchBox::getSubCatOptions())->label(__('label.search_box.torrent_field')),
|
||||
Forms\Components\TextInput::make('display_text')->label(__('label.search_box.taxonomy_display_text')),
|
||||
])
|
||||
->label(__('label.search_box.taxonomies'))->columns(2)
|
||||
->rules([
|
||||
function () {
|
||||
return function (string $attribute, $value, \Closure $fail) {
|
||||
$fields = [];
|
||||
foreach ($value as $item) {
|
||||
if (!in_array($item['torrent_field'], $fields)) {
|
||||
$fields[] = $item['torrent_field'];
|
||||
} else {
|
||||
$fail(__('label.search_box.torrent_field_duplicate', ['field' => $item['torrent_field']]));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
])
|
||||
,
|
||||
]),
|
||||
])->columns(3);
|
||||
}
|
||||
|
||||
@@ -13,16 +13,7 @@ class CreateSection extends CreateRecord
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
foreach (SearchBox::$subCatFields as $field) {
|
||||
$data["show{$field}"] = 0;
|
||||
foreach ($data['extra'][SearchBox::EXTRA_TAXONOMY_LABELS] ?? [] as $item) {
|
||||
if ($field == $item['torrent_field']) {
|
||||
$data["show{$field}"] = 1;
|
||||
$data["extra->" . SearchBox::EXTRA_TAXONOMY_LABELS][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
return SearchBox::formatTaxonomyExtra($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,16 +20,7 @@ class EditSection extends EditRecord
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
foreach (SearchBox::$subCatFields as $field) {
|
||||
$data["show{$field}"] = 0;
|
||||
foreach ($data['extra'][SearchBox::EXTRA_TAXONOMY_LABELS] ?? [] as $item) {
|
||||
if ($field == $item['torrent_field']) {
|
||||
$data["show{$field}"] = 1;
|
||||
$data["extra->" . SearchBox::EXTRA_TAXONOMY_LABELS][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
return SearchBox::formatTaxonomyExtra($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user