diff --git a/app/Panel/ScheduledConference/Livewire/Submissions/Components/ReviewerList.php b/app/Panel/ScheduledConference/Livewire/Submissions/Components/ReviewerList.php index 62656529..b5cc3f04 100644 --- a/app/Panel/ScheduledConference/Livewire/Submissions/Components/ReviewerList.php +++ b/app/Panel/ScheduledConference/Livewire/Submissions/Components/ReviewerList.php @@ -77,15 +77,29 @@ public function form(Form $form): Form ->label(__('general.reviewer')) ->placeholder(__('general.select_reviewer')) ->allowHtml() - ->hidden(fn ($record) => $record) + ->hidden(fn($record) => $record) ->preload() ->required() ->searchable() + ->options(function () { + return User::with('roles') + ->whereHas( + 'roles', + fn(Builder $query) => $query->where('name', UserRole::Reviewer->value) + ) + ->whereNotIn('id', $this->record->reviews->pluck('user_id')) + ->limit(10) + ->lazy() + ->mapWithKeys( + fn(User $user) => [$user->getKey() => static::renderSelectParticipant($user)] + ) + ->toArray(); + }) ->getSearchResultsUsing(function (Get $get, string $search) { return User::with('roles') ->whereHas( 'roles', - fn (Builder $query) => $query->whereName(UserRole::Reviewer->value) + fn(Builder $query) => $query->whereName(UserRole::Reviewer->value) ) ->whereNotIn('id', $this->record->reviews->pluck('user_id')) ->where(function (Builder $query) use ($search) { @@ -96,7 +110,7 @@ public function form(Form $form): Form ->limit(10) ->lazy() ->mapWithKeys( - fn (User $user) => [$user->getKey() => static::renderSelectParticipant($user)] + fn(User $user) => [$user->getKey() => static::renderSelectParticipant($user)] ) ->toArray(); }), @@ -116,7 +130,7 @@ public function form(Form $form): Form $paper->getKey() => new HtmlString( Action::make($paper->media->file_name) ->label($paper->media->file_name) - ->url(fn () => $paper->media->getTemporaryUrl(now()->addMinutes(5))) + ->url(fn() => $paper->media->getTemporaryUrl(now()->addMinutes(5))) ->link() ->toHtml() ), @@ -134,7 +148,7 @@ public function form(Form $form): Form }), Fieldset::make('Notification') ->label(__('general.notification')) - ->hidden(fn ($record) => $record) + ->hidden(fn($record) => $record) ->schema([ TextInput::make('subject') ->label(__('general.subject')) @@ -171,10 +185,10 @@ public function table(Table $table): Table { return $table ->query( - fn (): Builder => $this->record->reviews()->getQuery() + fn(): Builder => $this->record->reviews()->getQuery() ->when( $this->record->isParticipantAuthor(auth()->user()), - fn ($query) => $query->whereMeta('review_mode', Review::MODE_OPEN) + fn($query) => $query->whereMeta('review_mode', Review::MODE_OPEN) ->where('status', ReviewerStatus::ACCEPTED) ) ) @@ -188,7 +202,7 @@ public function table(Table $table): Table ->width(50) ->height(50) ->defaultImageUrl( - fn (Review $record): string => $record->user->getFilamentAvatarUrl() + fn(Review $record): string => $record->user->getFilamentAvatarUrl() ) ->extraCellAttributes([ 'style' => 'width: 1px', @@ -198,10 +212,10 @@ public function table(Table $table): Table TextColumn::make('user.fullName') ->label(__('general.full_name')) ->color( - fn (Review $record): string => $record->status == ReviewerStatus::CANCELED ? 'danger' : 'primary' + fn(Review $record): string => $record->status == ReviewerStatus::CANCELED ? 'danger' : 'primary' ) ->description( - fn (Review $record): string => $record->user->email + fn(Review $record): string => $record->user->email ), TextColumn::make('status') ->extraAttributes(['class' => 'mt-2']) @@ -223,10 +237,10 @@ public function table(Table $table): Table return ''; } - return __('general.recommend').$state; + return __('general.recommend') . $state; }) ->color( - fn (Review $record): string => match ($record->recommendation) { + fn(Review $record): string => match ($record->recommendation) { SubmissionStatusRecommendation::ACCEPT => 'primary', SubmissionStatusRecommendation::DECLINE => 'danger', default => 'warning' @@ -237,10 +251,10 @@ public function table(Table $table): Table ]) ->actions([ Action::make('read-review') - ->visible(fn (Review $record): bool => $record->reviewSubmitted()) + ->visible(fn(Review $record): bool => $record->reviewSubmitted()) ->modalWidth('2xl') ->modalSubmitActionLabel('Confirm') - ->modalHeading(fn () => 'Review: '.$this->record->getMeta('title')) + ->modalHeading(fn() => 'Review: ' . $this->record->getMeta('title')) ->icon('lineawesome-eye') ->mountUsing(function (Review $record, Form $form) { $form->fill([ @@ -275,33 +289,33 @@ public function table(Table $table): Table ->extraAttributes(['class' => 'text-gray-500']) ->content('Once this review has been read, press "Confirm" to indicate that the review process may proceed. If the reviewer has submitted their review elsewhere, you may upload the file below and then press "Confirm" to proceed.'), Shout::make('completed') - ->content(fn (Review $record) => 'Completed : '.$record->date_completed), + ->content(fn(Review $record) => 'Completed : ' . $record->date_completed), Shout::make('recommendation') ->color( - fn (): string => match ($record->recommendation) { + fn(): string => match ($record->recommendation) { SubmissionStatusRecommendation::ACCEPT => 'success', SubmissionStatusRecommendation::DECLINE => 'danger', default => 'warning' } ) - ->content(fn (Review $record) => 'Recommendation : '.$record->recommendation), + ->content(fn(Review $record) => 'Recommendation : ' . $record->recommendation), Placeholder::make('reviewer') - ->content(fn (Review $record) => $record->user->fullName.' ('.$record->user->email.')'), + ->content(fn(Review $record) => $record->user->fullName . ' (' . $record->user->email . ')'), Placeholder::make('score') ->label('Paper Score') - ->hidden(fn (Review $record) => ! $record->score) - ->content(fn (Review $record) => $record->score), + ->hidden(fn(Review $record) => ! $record->score) + ->content(fn(Review $record) => $record->score), Section::make('Reviewer Comments') ->schema([ Placeholder::make('for_author_and_editor') ->label('For Author and Editor') ->extraAttributes(['class' => 'prose']) - ->content(fn ($record) => $record->getMeta('review_for_author_editor') ? new HtmlString($record->getMeta('review_for_author_editor')) : '-'), + ->content(fn($record) => $record->getMeta('review_for_author_editor') ? new HtmlString($record->getMeta('review_for_author_editor')) : '-'), Placeholder::make('for_editor') ->label('For Editor') ->extraAttributes(['class' => 'prose']) - ->content(fn ($record) => $record->getMeta('review_for_editor') ? new HtmlString($record->getMeta('review_for_editor')) : '-'), + ->content(fn($record) => $record->getMeta('review_for_editor') ? new HtmlString($record->getMeta('review_for_editor')) : '-'), ]), Livewire::make(ReviewerFiles::class, [ 'record' => $record, @@ -318,7 +332,7 @@ public function table(Table $table): Table ->helperText('Rate the quality of the review provided. This rating is not shared with the reviewer.') ->options( collect([1, 2, 3, 4, 5]) - ->mapWithKeys(fn ($count) => [$count => view('components.star', ['count' => $count])->render()]) + ->mapWithKeys(fn($count) => [$count => view('components.star', ['count' => $count])->render()]) ->prepend('No Rating', 0) ->toArray() @@ -328,11 +342,11 @@ public function table(Table $table): Table }), ActionGroup::make([ Action::make('edit-reviewer') - ->hidden(fn (Model $record) => in_array($record->status, [ReviewerStatus::DECLINED, ReviewerStatus::CANCELED])) + ->hidden(fn(Model $record) => in_array($record->status, [ReviewerStatus::DECLINED, ReviewerStatus::CANCELED])) ->visible( - fn ($record): bool => $this->record->status == SubmissionStatus::OnReview && ! $record->recommendation + fn($record): bool => $this->record->status == SubmissionStatus::OnReview && ! $record->recommendation ) - ->authorize(fn () => auth()->user()->can('editReviewer', $this->record)) + ->authorize(fn() => auth()->user()->can('editReviewer', $this->record)) ->modalWidth('2xl') ->icon('iconpark-edit') ->label(__('general.edit')) @@ -345,11 +359,11 @@ public function table(Table $table): Table 'meta' => $record->getAllMeta(), ]); }) - ->form(fn ($form) => $this->form($form)) + ->form(fn($form) => $this->form($form)) ->successNotificationTitle(__('general.reviewer_updated')) ->action(function (Action $action, Review $record, array $data) { $record->assignedFiles()->get()->each( - fn (ReviewerAssignedFile $file) => $file->delete() + fn(ReviewerAssignedFile $file) => $file->delete() ); if (array_key_exists('meta', $data) && is_array($data['meta'])) { @@ -367,7 +381,7 @@ public function table(Table $table): Table $action->success(); }), Action::make('email-reviewer') - ->authorize(fn () => auth()->user()->can('emailReviewer', $this->record)) + ->authorize(fn() => auth()->user()->can('emailReviewer', $this->record)) ->label(__('general.email_reviewer')) ->icon('iconpark-sendemail') ->modalSubmitActionLabel(__('general.send')) @@ -401,11 +415,11 @@ public function table(Table $table): Table }), Action::make('cancel-reviewer') ->color('danger') - ->authorize(fn () => auth()->user()->can('cancelReviewer', $this->record)) + ->authorize(fn() => auth()->user()->can('cancelReviewer', $this->record)) ->icon('iconpark-deletethree-o') ->label(__('general.cancel_reviewer')) ->hidden( - fn (Review $record) => $record->status == ReviewerStatus::CANCELED || $record->confirmed() + fn(Review $record) => $record->status == ReviewerStatus::CANCELED || $record->confirmed() ) ->successNotificationTitle(__('general.reviewer_canceled')) ->modalWidth('2xl') @@ -425,18 +439,18 @@ public function table(Table $table): Table TextInput::make('email') ->label(__('general.email')) ->disabled() - ->hidden(fn (Get $get) => $get('do-not-notify-cancelation')) + ->hidden(fn(Get $get) => $get('do-not-notify-cancelation')) ->dehydrated(), TextInput::make('subject') ->label(__('general.subject')) - ->hidden(fn (Get $get) => $get('do-not-notify-cancelation')) + ->hidden(fn(Get $get) => $get('do-not-notify-cancelation')) ->required() ->columnSpanFull(), TinyEditor::make('message') ->label(__('general.message')) ->minHeight(300) ->profile('email') - ->hidden(fn (Get $get) => $get('do-not-notify-cancelation')) + ->hidden(fn(Get $get) => $get('do-not-notify-cancelation')) ->columnSpanFull(), Checkbox::make('do-not-notify-cancelation') ->reactive() @@ -467,11 +481,11 @@ public function table(Table $table): Table }), Action::make('reinstate-reviewer') ->color('primary') - ->authorize(fn () => auth()->user()->can('reinstateReviewer', $this->record)) + ->authorize(fn() => auth()->user()->can('reinstateReviewer', $this->record)) ->modalWidth('2xl') ->icon('iconpark-deletethree-o') ->hidden( - fn (Review $record) => $record->status != ReviewerStatus::CANCELED + fn(Review $record) => $record->status != ReviewerStatus::CANCELED ) ->label(__('general.reinstate_reviewer')) ->successNotificationTitle(__('general.reviewer_reinstated')) @@ -493,9 +507,9 @@ public function table(Table $table): Table }), Impersonate::make() ->grouped() - ->hidden(fn (Model $record) => in_array($record->status, [ReviewerStatus::DECLINED, ReviewerStatus::CANCELED])) + ->hidden(fn(Model $record) => in_array($record->status, [ReviewerStatus::DECLINED, ReviewerStatus::CANCELED])) ->visible( - fn (Model $record): bool => $record->user->email !== auth()->user()->email && auth()->user()->canImpersonate() + fn(Model $record): bool => $record->user->email !== auth()->user()->email && auth()->user()->canImpersonate() ) ->label(__('general.login_as')) ->icon('iconpark-login') @@ -535,8 +549,8 @@ public function table(Table $table): Table ->label(__('general.reviewer')) ->modalHeading(__('general.assign_reviewer')) ->modalWidth('2xl') - ->authorize(fn () => auth()->user()->can('assignReviewer', $this->record)) - ->form(fn ($form) => $this->form($form)) + ->authorize(fn() => auth()->user()->can('assignReviewer', $this->record)) + ->form(fn($form) => $this->form($form)) ->action(function (Action $action, array $data) { if ($this->record->reviews()->where('user_id', $data['user_id'])->exists()) { $action->failureNotificationTitle(__('general.reviewer_already_assigned'));