show approval only when not review visible is no

This commit is contained in:
xiaomlove
2022-07-05 15:36:11 +08:00
parent 147cf6db71
commit b7f3ae25e8
3 changed files with 8 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Filament\Resources\Torrent;
use App\Filament\Resources\Torrent\TorrentResource\Pages;
use App\Filament\Resources\Torrent\TorrentResource\RelationManagers;
use App\Models\Setting;
use App\Models\Tag;
use App\Models\Torrent;
use App\Models\TorrentTag;
@@ -52,6 +53,7 @@ class TorrentResource extends Resource
public static function table(Table $table): Table
{
$showApproval = Setting::get('torrent.approval_status_none_visible') == 'no';
return $table
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
@@ -72,6 +74,7 @@ class TorrentResource extends Resource
Tables\Columns\TextColumn::make('leechers')->label(__('label.torrent.leechers')),
// Tables\Columns\TextColumn::make('times_completed')->label(__('label.torrent.times_completed')),
Tables\Columns\BadgeColumn::make('approval_status')
->visible($showApproval)
->label(__('label.torrent.approval_status'))
->colors(array_flip(Torrent::listApprovalStatus(true, 'badge_color')))
->formatStateUsing(fn ($record) => $record->approvalStatusText),
@@ -100,6 +103,7 @@ class TorrentResource extends Resource
// Tables\Actions\EditAction::make(),
Tables\Actions\Action::make('approval')
->label(__('admin.resources.torrent.action_approval'))
->visible($showApproval)
->form([
Forms\Components\Radio::make('approval_status')
->label(__('label.torrent.approval_status'))
@@ -176,6 +180,7 @@ class TorrentResource extends Resource
})
->deselectRecordsAfterCompletion(),
]);
}
public static function getEloquentQuery(): Builder

View File

@@ -156,7 +156,7 @@ if (!$row) {
if (get_user_class() >= $askreseed_class && $row['seeders'] == 0) {
$actions[] = "<a title=\"".$lang_details['title_ask_for_reseed']."\" href=\"takereseed.php?reseedid=$id\"><img class=\"dt_reseed\" src=\"pic/trans.gif\" alt=\"reseed\">&nbsp;<b><font class=\"small\">".$lang_details['text_ask_for_reseed'] ."</font></b></a>";
}
if (get_user_class() >= $torrentmanage_class) {
if (get_user_class() >= $torrentmanage_class && get_setting('torrent.approval_status_none_visible') == 'no') {
$approvalIcon = '<svg t="1655224943277" class="icon" viewBox="0 0 1397 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="45530" width="16" height="16"><path d="M1396.363636 121.018182c0 0-223.418182 74.472727-484.072727 372.363636-242.036364 269.963636-297.890909 381.672727-390.981818 530.618182C512 1014.690909 372.363636 744.727273 0 549.236364l195.490909-186.181818c0 0 176.872727 121.018182 297.890909 344.436364 0 0 307.2-474.763636 902.981818-707.490909L1396.363636 121.018182 1396.363636 121.018182zM1396.363636 121.018182" p-id="45531" fill="#e78d0f"></path></svg>';
$actions[] = sprintf(
'<a href="javascript:;"><b><font id="approval" class="small approval" data-torrent_id="%s">%s&nbsp;%s</font></b></a>',

View File

@@ -811,8 +811,8 @@ $approvalStatusNoneVisible = get_setting('torrent.approval_status_none_visible')
$approvalStatusIconEnabled = get_setting('torrent.approval_status_icon_enabled');
$approvalStatus = null;
$showApprovalStatusFilter = false;
//when enable approval status icon, all user can use this filter, otherwise only staff member can use
if ($approvalStatusIconEnabled == 'yes' || get_user_class() >= $staffmem_class) {
//when enable approval status icon, all user can use this filter, otherwise only staff member and approval none visible is 'no' can use
if ($approvalStatusIconEnabled == 'yes' || (get_user_class() >= $staffmem_class && $approvalStatusNoneVisible == 'no')) {
$showApprovalStatusFilter = true;
}
//when user can use approval status filter, and pass `approval_status` parameter, will affect