From e6d12cd305d03c8e6669b51a1d88eafe27af7f9d Mon Sep 17 00:00:00 2001 From: Vincent Auger Date: Thu, 14 Nov 2024 16:40:17 -0400 Subject: [PATCH 1/2] feat: add OGL question to DFO pub MRF --- .../ManuscriptRecordController.php | 7 +- .../Resources/ManuscriptRecordResource.php | 4 +- app/Models/ManuscriptRecord.php | 5 +- .../factories/ManuscriptRecordFactory.php | 2 +- ...l_question_to_manuscript_records_table.php | 21 +++++ resources/src/components/QuestionEditor.vue | 5 +- resources/src/locales/en.json | 7 +- resources/src/locales/fr.json | 7 +- .../ManuscriptRecord/ManuscriptRecord.ts | 44 ++++----- .../views/ManuscriptRecordFormView.vue | 89 ++++++++++++++----- tests/Feature/Models/ManuscriptRecordTest.php | 17 ++++ 11 files changed, 156 insertions(+), 52 deletions(-) create mode 100644 database/migrations/2024_11_14_184759_add_ogl_question_to_manuscript_records_table.php diff --git a/app/Http/Controllers/ManuscriptRecordController.php b/app/Http/Controllers/ManuscriptRecordController.php index df16d5e8..7e04659f 100644 --- a/app/Http/Controllers/ManuscriptRecordController.php +++ b/app/Http/Controllers/ManuscriptRecordController.php @@ -19,6 +19,7 @@ use Gate; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; +use Illuminate\Support\Facades\Auth; use Illuminate\Validation\Rule; use Illuminate\Validation\Rules\Enum; @@ -40,7 +41,7 @@ public function store(Request $request): JsonResource $manuscriptRecord = new ManuscriptRecord($validated); $manuscriptRecord->status = ManuscriptRecordStatus::DRAFT; - $manuscriptRecord->user_id = auth()->id(); + $manuscriptRecord->user_id = Auth::id(); $manuscriptRecord->save(); $manuscriptRecord->refresh(); @@ -72,8 +73,10 @@ public function update(Request $request, ManuscriptRecord $manuscriptRecord): Js 'abstract' => 'nullable|string', 'pls' => 'nullable|string', 'relevant_to' => 'nullable|string', - 'additional_information' => 'nullable|string', + 'public_interest_information' => 'nullable|string', 'potential_public_interest' => 'boolean', + 'do_not_apply_ogl' => 'boolean', + 'no_ogl_explanation' => 'nullable|string', ]); $manuscriptRecord->update($validated); diff --git a/app/Http/Resources/ManuscriptRecordResource.php b/app/Http/Resources/ManuscriptRecordResource.php index 06a20946..14bc29d6 100644 --- a/app/Http/Resources/ManuscriptRecordResource.php +++ b/app/Http/Resources/ManuscriptRecordResource.php @@ -31,8 +31,10 @@ public function toArray($request) 'abstract' => $this->abstract ?? '', 'pls' => $this->pls ?? '', 'relevant_to' => $this->relevant_to ?? '', - 'additional_information' => $this->additional_information ?? '', 'potential_public_interest' => $this->potential_public_interest, + 'public_interest_information' => $this->public_interest_information ?? '', + 'do_not_apply_ogl' => $this->do_not_apply_ogl, + 'no_ogl_explanation' => $this->no_ogl_explanation ?? '', // dates and times 'created_at' => $this->created_at, diff --git a/app/Models/ManuscriptRecord.php b/app/Models/ManuscriptRecord.php index 446bce40..b21f90b9 100644 --- a/app/Models/ManuscriptRecord.php +++ b/app/Models/ManuscriptRecord.php @@ -51,6 +51,7 @@ class ManuscriptRecord extends Model implements Fundable, HasMedia 'type' => ManuscriptRecordType::class, 'status' => ManuscriptRecordStatus::class, 'potential_public_interest' => 'boolean', + 'do_not_apply_ogl' => 'boolean', ]; // default values for optional fields @@ -58,7 +59,8 @@ class ManuscriptRecord extends Model implements Fundable, HasMedia 'abstract' => '', 'pls' => '', 'relevant_to' => '', - 'additional_information' => '', + 'public_interest_information' => '', + 'no_ogl_explanation' => '', ]; // logging options @@ -233,6 +235,7 @@ public function validateIsFilled(bool $noExceptions = false): bool 'region_id' => 'required|exists:regions,id', 'functional_area_id' => 'required|exists:functional_areas,id', 'relevant_to' => 'required', + 'no_ogl_explanation' => 'required_if:do_not_apply_ogl,true', ]); $validator->after(function ($validator) { diff --git a/database/factories/ManuscriptRecordFactory.php b/database/factories/ManuscriptRecordFactory.php index 69c75f56..9c5e8325 100644 --- a/database/factories/ManuscriptRecordFactory.php +++ b/database/factories/ManuscriptRecordFactory.php @@ -44,7 +44,7 @@ public function filled() 'pls' => $this->faker->paragraph(), 'relevant_to' => $this->faker->paragraph(), 'potential_public_interest' => $this->faker->boolean(), - 'additional_information' => $this->faker->paragraph(), + 'public_interest_information' => $this->faker->paragraph(), 'functional_area_id' => FunctionalArea::factory()->create()->id, ])->afterCreating(function ($manuscript) { $manuscript->manuscriptAuthors()->save(ManuscriptAuthor::factory()->make(['is_corresponding_author' => true])); // create a corresponding author diff --git a/database/migrations/2024_11_14_184759_add_ogl_question_to_manuscript_records_table.php b/database/migrations/2024_11_14_184759_add_ogl_question_to_manuscript_records_table.php new file mode 100644 index 00000000..c2233561 --- /dev/null +++ b/database/migrations/2024_11_14_184759_add_ogl_question_to_manuscript_records_table.php @@ -0,0 +1,21 @@ +boolean('do_not_apply_ogl')->default(false); + $table->text('no_ogl_explanation')->nullable(); + $table->renameColumn('additional_information', 'public_interest_information'); + }); + } + +}; diff --git a/resources/src/components/QuestionEditor.vue b/resources/src/components/QuestionEditor.vue index 84b3dac7..e517a86e 100644 --- a/resources/src/components/QuestionEditor.vue +++ b/resources/src/components/QuestionEditor.vue @@ -1,6 +1,6 @@