Skip to content

Commit

Permalink
Merge pull request #483 from OpenSynergic/submission-review-improvement
Browse files Browse the repository at this point in the history
feat: submission review improvement
  • Loading branch information
rahmanramsi authored Jan 3, 2025
2 parents 965f1af + 9be9622 commit a080698
Show file tree
Hide file tree
Showing 33 changed files with 1,536 additions and 1,183 deletions.
34 changes: 34 additions & 0 deletions app/Actions/Review/ReviewCreateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Actions\Review;

use App\Models\Review;
use App\Models\Submission;
use Illuminate\Support\Facades\DB;
use Lorisleiva\Actions\Concerns\AsAction;

class ReviewCreateAction
{
use AsAction;

public function handle(array $data): Review
{
try {
DB::beginTransaction();

$record = Review::create($data);

if (array_key_exists('meta', $data) && is_array($data['meta'])) {
$record->setManyMeta($data['meta']);
}

DB::commit();
} catch (\Throwable $th) {
DB::rollBack();

throw $th;
}

return $record;
}
}
34 changes: 34 additions & 0 deletions app/Actions/Review/ReviewUpdateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Actions\Review;

use App\Models\Review;
use App\Models\Submission;
use Illuminate\Support\Facades\DB;
use Lorisleiva\Actions\Concerns\AsAction;

class ReviewUpdateAction
{
use AsAction;

public function handle(Review $record, array $data): Review
{
try {
DB::beginTransaction();

$record->update($data);

if (array_key_exists('meta', $data) && is_array($data['meta'])) {
$record->setManyMeta($data['meta']);
}

DB::commit();
} catch (\Throwable $th) {
DB::rollBack();

throw $th;
}

return $record;
}
}
2 changes: 1 addition & 1 deletion app/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

class Application extends LaravelApplication
{
public const APP_VERSION = '1.2.0-beta.2';
public const APP_VERSION = '1.2.0-beta.3';

public const PHP_MIN_VERSION = '8.1';

Expand Down
30 changes: 30 additions & 0 deletions app/Forms/Form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Forms;

use Closure;
use App\Facades\Hook;
use Illuminate\Support\Str;
use Filament\Forms\Components\Concerns\HasId;

class Form extends \Filament\Forms\Form
{
use HasId;

/**
* @param array<Component> | Closure $components
*/
public function components(array | Closure $components): static
{
if($this->getId()){
Hook::call('Forms::Form::components::' . Str::camel($this->getId()), [&$components, $this]);
}

return parent::components($components);
}

public function toHtml(): string
{
return $this->render()->render();
}
}
13 changes: 13 additions & 0 deletions app/Infolists/Components/VerticalTabs/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

namespace App\Infolists\Components\VerticalTabs;

use App\Facades\Hook;
use Closure;
use Filament\Infolists\Components\Tabs\Tab as ComponentsTab;

class Tab extends ComponentsTab
{
protected string $view = 'infolists.components.vertical-tabs.tab';

public function childComponents(array | Closure $components): static
{
$id = $this->id;

Hook::call('VerticalTabs::Tab::childComponents', [$id, &$components, $this]);

$this->childComponents = $components;

return $this;
}
}
13 changes: 13 additions & 0 deletions app/Infolists/Components/VerticalTabs/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Infolists\Components\VerticalTabs;

use Closure;
use App\Facades\Hook;
use Illuminate\Support\Str;
use Filament\Infolists\Components\Tabs as ComponentsTabs;

class Tabs extends ComponentsTabs
Expand Down Expand Up @@ -60,4 +62,15 @@ public function isSticky(): bool
{
return $this->sticky;
}

public function childComponents(array | Closure $components): static
{
$id = Str::slug($this->label);

Hook::call('VerticalTabs::Tabs::childComponents', [$id, &$components, $this]);

$this->childComponents = $components;

return $this;
}
}
25 changes: 25 additions & 0 deletions app/Infolists/Infolist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Infolists;

use App\Facades\Hook;
use Closure;
use Illuminate\Support\Str;
use Filament\Infolists\Components\Concerns\HasId;

class Infolist extends \Filament\Infolists\Infolist
{
use HasId;

/**
* @param array<Component> | Closure $components
*/
public function components(array | Closure $components): static
{
if($this->getId()){
Hook::call('Forms::Form::components::' . Str::camel($this->getId()), [&$components, $this]);
}

return parent::components($components);
}
}
2 changes: 1 addition & 1 deletion app/Mail/Templates/TemplateMailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function getVariables(): array
return array_merge(static::getConferenceViewData(), parent::getVariables());
}

public function buildViewData()
public function buildViewData(): array
{
return array_merge(static::getConferenceViewData(), parent::buildViewData());
}
Expand Down
14 changes: 4 additions & 10 deletions app/Models/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Models;

use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -11,7 +12,7 @@

class Review extends Model implements HasMedia
{
use HasFactory, InteractsWithMedia, Metable;
use HasFactory, InteractsWithMedia, Metable, Cachable;

public const MODE_DOUBLE_ANONYMOUS = 1;

Expand All @@ -33,20 +34,13 @@ class Review extends Model implements HasMedia
'date_assigned',
'date_confirmed',
'date_completed',
'date_acknowledged',
'quality',
'score',
'review_author_editor',
'review_editor',
];

protected static function booted(): void
{
static::saving(function (Model $record) {
if ($record->recommendation) {
$record->date_completed = now();
}
});
}

public function reviewSubmitted(): bool
{
return ! is_null($this->recommendation) && ! is_null($this->date_completed);
Expand Down
1 change: 0 additions & 1 deletion app/Models/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class Submission extends Model implements HasMedia, Sortable
*/
protected static function booted(): void
{

static::creating(function (Submission $submission) {
$submission->user_id ??= Auth::id();
$submission->conference_id ??= app()->getCurrentConferenceId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ class ReviewerFiles extends \Livewire\Component implements HasForms, HasTable

public Review $record;

public bool $viewOnly = false;

public function isViewOnly(): bool
{
return $this->viewOnly;
}

public function table(Table $table): Table
{
return $table
->heading('Reviewer Files')
->headerActions([
Action::make('download_all')
->hidden(
fn (): bool => $this->record->reviewSubmitted()
fn (): bool => $this->isViewOnly()
)
->icon('iconpark-download-o')
->label('Download All Files')
Expand All @@ -44,7 +51,7 @@ public function table(Table $table): Table
Action::make('upload')
->label('Upload Files')
->hidden(
fn (): bool => $this->record->reviewSubmitted()
fn (): bool => $this->isViewOnly()
)
->icon('iconpark-upload')
->form([
Expand All @@ -66,7 +73,7 @@ public function table(Table $table): Table
->actions([
DeleteAction::make()
->hidden(
fn (): bool => $this->record->reviewSubmitted()
fn (): bool => $this->isViewOnly()
),
])
->query(
Expand Down
Loading

0 comments on commit a080698

Please sign in to comment.