From 5126b79a024b0de0d6691879eb0f92be607d571f Mon Sep 17 00:00:00 2001 From: Vincent Auger Date: Mon, 2 Dec 2024 17:03:31 -0400 Subject: [PATCH] revert: reduce max character limit for role title and department name to 50 --- app/Http/Controllers/AuthorEmploymentController.php | 8 ++++---- .../components/AddAuthorEmploymentDialog.vue | 4 ++-- .../components/EditAuthorEmploymentDialog.vue | 4 ++-- tests/Feature/Models/AuthorEmployementTest.php | 7 ++++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/AuthorEmploymentController.php b/app/Http/Controllers/AuthorEmploymentController.php index 086912b3..ce2943d4 100644 --- a/app/Http/Controllers/AuthorEmploymentController.php +++ b/app/Http/Controllers/AuthorEmploymentController.php @@ -33,8 +33,8 @@ public function store(Author $author, Request $request) $validated = $request->validate([ 'organization_id' => 'nullable|exists:organizations,id', - 'role_title' => 'nullable|string|max:125', - 'department_name' => 'nullable|string|max:125', + 'role_title' => 'nullable|string|max:50', + 'department_name' => 'nullable|string|max:50', 'start_date' => 'required|date', 'end_date' => 'nullable|date', ]); @@ -81,8 +81,8 @@ public function update(Author $author, Request $request, AuthorEmployment $autho $this->authorize('update', $authorEmployment); $validated = $request->validate([ - 'role_title' => 'nullable|string|max:125', - 'department_name' => 'nullable|string|max:125', + 'role_title' => 'nullable|string|max:50', + 'department_name' => 'nullable|string|max:50', 'start_date' => 'required|date', 'end_date' => 'nullable|date', ]); diff --git a/resources/src/models/AuthorEmployment/components/AddAuthorEmploymentDialog.vue b/resources/src/models/AuthorEmployment/components/AddAuthorEmploymentDialog.vue index 30f95635..6eb88992 100644 --- a/resources/src/models/AuthorEmployment/components/AddAuthorEmploymentDialog.vue +++ b/resources/src/models/AuthorEmployment/components/AddAuthorEmploymentDialog.vue @@ -65,7 +65,7 @@ async function createAuthorEmployment() { :label="t('orcid-employment-edit.role-title')" outlined :rules="[(val: string|null) => !!val || t('common.required'), - (val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]), + (val: string) => val.length <= 50 || t('common.validation.must-be-less-than-x-characters', [50]), ]" class="q-mb-md" /> @@ -74,7 +74,7 @@ async function createAuthorEmployment() { :label="t('orcid-employment-edit.department-name')" outlined :rules="[(val: string|null) => !!val || t('common.required'), - (val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]), + (val: string) => val.length <= 50 || t('common.validation.must-be-less-than-x-characters', [50]), ]" class="q-mb-md" :hint="t('orcid-employment-edit.department-name-hint')" diff --git a/resources/src/models/AuthorEmployment/components/EditAuthorEmploymentDialog.vue b/resources/src/models/AuthorEmployment/components/EditAuthorEmploymentDialog.vue index 70b2e0cc..d590de36 100644 --- a/resources/src/models/AuthorEmployment/components/EditAuthorEmploymentDialog.vue +++ b/resources/src/models/AuthorEmployment/components/EditAuthorEmploymentDialog.vue @@ -78,7 +78,7 @@ function deleteAuthorEmployment() { :label="t('orcid-employment-edit.role-title')" outlined :rules="[(val: string|null) => !!val || t('common.required'), - (val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]), + (val: string) => val.length <= 50 || t('common.validation.must-be-less-than-x-characters', [50]), ]" class="q-mb-md" /> @@ -87,7 +87,7 @@ function deleteAuthorEmployment() { :label="t('orcid-employment-edit.department-name')" outlined :rules="[(val: string|null) => !!val || t('common.required'), - (val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]), + (val: string) => val.length <= 50 || t('common.validation.must-be-less-than-x-characters', [50]), ]" class="q-mb-md" :hint="t('orcid-employment-edit.department-name-hint')" diff --git a/tests/Feature/Models/AuthorEmployementTest.php b/tests/Feature/Models/AuthorEmployementTest.php index 691f2f04..d0336bb7 100644 --- a/tests/Feature/Models/AuthorEmployementTest.php +++ b/tests/Feature/Models/AuthorEmployementTest.php @@ -3,6 +3,7 @@ use App\Models\AuthorEmployment; use App\Models\Organization; use App\Models\User; +use Illuminate\Support\Facades\Queue; test('a user can list their author profile employements', function () { $user = User::factory()->create(); @@ -120,7 +121,7 @@ }); -test('adding a 125 char role title is valid', function () { +test('adding a 50 char role title is valid', function () { $user = User::factory()->create(); $employment = AuthorEmployment::factory()->create([ 'author_id' => $user->author->id, @@ -132,11 +133,11 @@ 'author_id' => $user->author->id, 'organization_id' => Organization::getDefaultOrganization()->id, 'start_date' => now()->subYear(), - 'role_title' => str_repeat('a', 125), + 'role_title' => str_repeat('a', 50), ])->toArray(); $response = $this->actingAs($user)->putJson("api/authors/{$user->author->id}/employments/{$employment->id}", $data)->assertOk(); - expect($response->json('data.role_title'))->toBe(str_repeat('a', 125)); + expect($response->json('data.role_title'))->toBe(str_repeat('a', 50)); });