Skip to content

Commit

Permalink
Merge pull request #107 from OpenSynergic/1-submission-workflow
Browse files Browse the repository at this point in the history
Submission Workflow
  • Loading branch information
rahmanramsi authored Dec 7, 2023
2 parents 51463cc + 2cbbef0 commit b79f61c
Show file tree
Hide file tree
Showing 182 changed files with 9,617 additions and 1,427 deletions.
5 changes: 5 additions & 0 deletions app/Actions/Participants/ParticipantCreateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public function handle(array $data)
$participant->setManyMeta(data_get($data, 'meta'));
}

if ($position = data_get($data, 'position')) {
$participant->positions()->detach($position);
$participant->positions()->attach($position);
}

DB::commit();
} catch (\Throwable $th) {
DB::rollBack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Actions\Participants;

use App\Models\Conference;
use App\Models\Enums\UserRole;
use App\Models\ParticipantPosition;
use Illuminate\Support\Facades\DB;
use Lorisleiva\Actions\Concerns\AsAction;
Expand All @@ -16,6 +17,33 @@ public function handle(Conference $conference): void
try {
DB::beginTransaction();

ParticipantPosition::firstOrCreate([
'name' => UserRole::Reviewer->value,
'type' => 'reviewer',
'conference_id' => $conference->getKey(),
]);

foreach ([
UserRole::Editor->value,
] as $authorPosition) {
ParticipantPosition::firstOrCreate([
'name' => $authorPosition,
'type' => 'editor',
'conference_id' => $conference->getKey(),
]);
}

foreach ([
UserRole::Author->value,
'Co Author'
] as $authorPosition) {
ParticipantPosition::firstOrCreate([
'name' => $authorPosition,
'type' => 'author',
'conference_id' => $conference->getKey(),
]);
}

foreach ([
'Keynote Speaker',
'Plenary Speaker',
Expand Down
25 changes: 25 additions & 0 deletions app/Actions/SubmissionFiles/FilesTypePopulateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Actions\SubmissionFiles;

use App\Models\SubmissionFileType;
use Lorisleiva\Actions\Concerns\AsAction;

class FilesTypePopulateAction
{
use AsAction;

public function handle()
{
foreach ([
'Abstract',
'Full Paper',
'Pamflet',
'Poster',
] as $type) {
SubmissionFileType::firstOrCreate([
'name' => $type,
]);
}
}
}
24 changes: 24 additions & 0 deletions app/Actions/SubmissionFiles/UploadSubmissionFileAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Actions\SubmissionFiles;

use App\Models\Media;
use App\Models\Submission;
use App\Models\SubmissionFileType;
use Lorisleiva\Actions\Concerns\AsAction;

class UploadSubmissionFileAction
{
use AsAction;

public function handle(Submission $submission, Media $file, string $category, SubmissionFileType $type)
{
return $submission->submissionFiles()->updateOrCreate([
'media_id' => $file->getKey()
], [
'media_id' => $file->getKey(),
'submission_file_type_id' => $type->getKey(),
'category' => $category
]);
}
}
17 changes: 17 additions & 0 deletions app/Actions/Submissions/AcceptWithdrawalAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Actions\Submissions;

use App\Models\Enums\SubmissionStatus;
use App\Models\Submission;
use Lorisleiva\Actions\Concerns\AsAction;

class AcceptWithdrawalAction
{
use AsAction;

public function handle(Submission $submission)
{
SubmissionUpdateAction::run(['status' => SubmissionStatus::Withdrawn], $submission);
}
}
17 changes: 17 additions & 0 deletions app/Actions/Submissions/CancelWithdrawalAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Actions\Submissions;

use App\Models\Submission;
use Lorisleiva\Actions\Concerns\AsAction;

// This actions is used to reject withdrawal request.
class CancelWithdrawalAction
{
use AsAction;

public function handle(Submission $submission)
{
SubmissionUpdateAction::run(['withdrawn_reason' => null], $submission);
}
}
17 changes: 17 additions & 0 deletions app/Actions/Submissions/RequestWithdrawalAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Actions\Submissions;

use App\Models\Enums\SubmissionStatus;
use App\Models\Submission;
use Lorisleiva\Actions\Concerns\AsAction;

class RequestWithdrawalAction
{
use AsAction;

public function handle(Submission $submission, ?string $reason = null)
{
SubmissionUpdateAction::run(['withdrawn_reason' => $reason], $submission);
}
}
32 changes: 32 additions & 0 deletions app/Actions/Submissions/SubmissionAssignParticipantAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Actions\Submissions;

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

class SubmissionAssignParticipantAction
{
use AsAction;

public function handle(Submission $submission, User $user, Role $role)
{
try {
DB::beginTransaction();
$submissionParticipant = $submission->participants()->updateOrCreate([
'user_id' => $user->getKey(),
], [
'user_id' => $user->getKey(),
'role_id' => $role->getKey(),
]);
DB::commit();
return $submissionParticipant;
} catch (\Throwable $th) {
DB::rollBack();
throw $th;
}
}
}
22 changes: 22 additions & 0 deletions app/Actions/Submissions/UnpublishSubmissionAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Actions\Submissions;

use App\Models\Enums\SubmissionStage;
use App\Models\Enums\SubmissionStatus;
use App\Models\Submission;
use Lorisleiva\Actions\Concerns\AsAction;

class UnpublishSubmissionAction
{
use AsAction;

// When a submission is unpublished, it should be returned to the latest status, which is editing.
public function handle(Submission $submission)
{
SubmissionUpdateAction::run([
'stage' => SubmissionStage::Editing,
'status' => SubmissionStatus::Editing,
], $submission);
}
}
47 changes: 47 additions & 0 deletions app/Actions/User/CreateParticipantFromUserAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Actions\User;

use App\Actions\Participants\ParticipantCreateAction;
use App\Models\Enums\UserRole;
use App\Models\Participant;
use App\Models\ParticipantPosition;
use App\Models\User;
use Lorisleiva\Actions\Concerns\AsAction;

class CreateParticipantFromUserAction
{
use AsAction;

public function handle(User $user)
{
$userData = $user->toArray();

$userData['meta'] = $user->meta()->get()
->mapWithKeys(
fn ($meta) => [$meta->key => $meta->value]
)
->toArray();

$participant = Participant::where('email', $user->email)->first();

if (!$participant) {
$participant = ParticipantCreateAction::run($userData);
}

foreach ($user->getRoleNames() as $userRole) {
// Only for Author, Reviewer and Editor
$shouldCreateParticipant = match ($userRole) {
UserRole::Author->value, UserRole::Reviewer->value, UserRole::Editor->value => true,
default => false,
};
if (!$shouldCreateParticipant) {
continue;
}
$position = ParticipantPosition::where('name', $userRole)->first();
$participant->positions()->detach($position);
$participant->positions()->attach($position);
}
return $participant;
}
}
14 changes: 14 additions & 0 deletions app/Constants/ReviewerStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Constants;

final class ReviewerStatus
{
public const ACCEPTED = 'Accepted';

public const DECLINED = 'Declined';

public const PENDING = 'Pending';

public const CANCELED = 'Canceled';
}
22 changes: 22 additions & 0 deletions app/Constants/SubmissionFileCategory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Constants;

final class SubmissionFileCategory
{
public const ABSTRACT_FILES = 'abstract-files';

public const SUPPLEMENTARY_FILES = 'supplementary-files';

public const PAPER_FILES = 'paper-files';

public const REVIEWER_FILES = 'reviewer-files';

public const REVISION_FILES = 'revision-files';

public const REVIEWER_ASSIGNED_FILES = 'reviewer-assigned-files';

public const EDITING_DRAFT_FILES = 'editing-draft-files';

public const EDITED_FILES = 'edited-files';
}
21 changes: 21 additions & 0 deletions app/Constants/SubmissionStatusRecommendation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Constants;

final class SubmissionStatusRecommendation
{
public const ACCEPT = 'Accept';

public const DECLINE = 'Decline';

public const REVISION_REQUIRED = "Revision Required";

public static function list()
{
return [
static::ACCEPT => static::ACCEPT,
static::DECLINE => static::DECLINE,
static::REVISION_REQUIRED => static::REVISION_REQUIRED
];
}
}
2 changes: 1 addition & 1 deletion app/Infolists/Components/LivewireEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function toHtml(): string
return Blade::render('@livewire($component, $viewData, key($key))', [
'component' => $this->getState(),
'viewData' => $this->viewData,
'key' => 'data',
'key' => $this->getId(),
]);
}

Expand Down
58 changes: 58 additions & 0 deletions app/Mail/Templates/AcceptAbstractMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Mail\Templates;

use App\Mail\Templates\Traits\CanCustomizeTemplate;
use App\Models\Submission;

class AcceptAbstractMail extends TemplateMailable
{
use CanCustomizeTemplate;

public string $title;

public string $author;

public string $loginLink;

public function __construct(Submission $submission)
{
$this->title = $submission->getMeta('title');
$this->author = $submission->user->fullName;
$this->loginLink = route('livewirePageGroup.website.pages.login');
}

public static function getDefaultSubject(): string
{
return 'Abstract Accepted';
}

public static function getDefaultDescription(): string
{
return 'This is an automated notification from System to inform you about a new submission.';
}

public static function getDefaultHtmlTemplate(): string
{

return <<<'HTML'
<p> This is an automated notification from the Leconfe System to inform you about a new submission.</p>
<p>
Submission Details:
</p>
<table>
<tr>
<td style="width:100px;">Title</td>
<td>:</td>
<td>{{ title }}</td>
</tr>
<tr>
<td style="width:100px;">Author</td>
<td>:</td>
<td>{{ author }}</td>
</tr>
</table>
<p>The submission is now available for your review and can be accessed through the System using your login credentials. Please <a href="{{ loginLink }}">log in</a> to the system to proceed with the evaluation process.</p>
HTML;
}
}
Loading

0 comments on commit b79f61c

Please sign in to comment.