mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
finish section edit
This commit is contained in:
@@ -25,8 +25,4 @@ class CreateSection extends CreateRecord
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return static::$resource::getUrl('index');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,4 @@ class EditSection extends EditRecord
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): ?string
|
||||
{
|
||||
return static::$resource::getUrl('index');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,42 +8,15 @@ use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyAudioCodecsRelationManager extends RelationManager
|
||||
class TaxonomyAudioCodecsRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_audio_codecs';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
protected static ?string $torrentField = 'audiocodec';
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,42 +8,15 @@ use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyCodecsRelationManager extends RelationManager
|
||||
class TaxonomyCodecsRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_codecs';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
protected static ?string $torrentField = 'codec';
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,42 +8,15 @@ use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyMediumRelationManager extends RelationManager
|
||||
class TaxonomyMediumRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_medium';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
protected static ?string $torrentField = 'medium';
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,42 +8,15 @@ use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyProcessingRelationManager extends RelationManager
|
||||
class TaxonomyProcessingRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_processing';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
protected static ?string $torrentField = 'processing';
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
|
||||
use App\Filament\Resources\System\SectionResource\TaxonomyTrait;
|
||||
use App\Models\SearchBox;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
@@ -17,9 +19,53 @@ class TaxonomySourcesRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $torrentField = 'source';
|
||||
|
||||
protected static function getModelLabel(): string
|
||||
{
|
||||
static $taxonomies;
|
||||
if (!$taxonomies) {
|
||||
$params = request()->all();
|
||||
$taxonomies = $params['serverMemo']['data']['data']['extra'][SearchBox::EXTRA_TAXONOMY_LABELS] ?? [];
|
||||
if (empty($taxonomies)) {
|
||||
$id = request()->route()->parameter('record');
|
||||
if (!$id) {
|
||||
$id = $params['serverMemo']['dataMeta']['models']['ownerRecord']['id'] ?? null;
|
||||
}
|
||||
do_log("searchBox ID: $id");
|
||||
$searchBox = SearchBox::query()->find($id);
|
||||
if ($searchBox) {
|
||||
$taxonomies = $searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS] ?? [];
|
||||
} else {
|
||||
$taxonomies = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($taxonomies as $taxonomy) {
|
||||
if ($taxonomy['torrent_field'] == static::$torrentField) {
|
||||
return $taxonomy['display_text'];
|
||||
}
|
||||
}
|
||||
$field = static::$torrentField;
|
||||
return __("label.search_box.$field") ?? $field;
|
||||
}
|
||||
|
||||
public static function shouldShowTaxonomy(SearchBox $searchBox): bool
|
||||
{
|
||||
$taxonomies = $searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS] ?? [];
|
||||
foreach ($taxonomies as $taxonomy) {
|
||||
if ($taxonomy['torrent_field'] == static::$torrentField) {
|
||||
do_log("torrent_field: " . static::$torrentField . " should show");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
do_log("torrent_field: " . static::$torrentField . " don't show");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canViewForRecord(Model $ownerRecord): bool
|
||||
{
|
||||
return self::shouldShowTaxonomy($ownerRecord);
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
@@ -41,7 +87,9 @@ class TaxonomySourcesRelationManager extends RelationManager
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.search_box.taxonomy.name')),
|
||||
Tables\Columns\TextColumn::make('sort_index')->label(__('label.search_box.taxonomy.sort_index'))->sortable(),
|
||||
])
|
||||
->defaultSort('sort_index')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
@@ -56,4 +104,5 @@ class TaxonomySourcesRelationManager extends RelationManager
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,40 +10,12 @@ use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyStandardsRelationManager extends RelationManager
|
||||
class TaxonomyStandardsRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_standards';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
protected static ?string $torrentField = 'standard';
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,40 +10,12 @@ use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyTeamsRelationManager extends RelationManager
|
||||
class TaxonomyTeamsRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_teams';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
protected static ?string $torrentField = 'team';
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user