Skip to content

Commit

Permalink
[Copy] Update work preferences copy (#11444)
Browse files Browse the repository at this point in the history
* update labels, move current location

* update localized constants

* merge work location with preferences

* fix format for display

* update file work preferences

* update order of application csv

* add current location heading

* add operational requirment translations

* fix profile e2e spec

* add icon aria labels

* format common messages

* fix profile workflows spec

* reorder city/region

* fix icon alignment

* add translations

* update to use second person for form
  • Loading branch information
esizer authored Sep 6, 2024
1 parent fa7a0cf commit 8ba30db
Show file tree
Hide file tree
Showing 33 changed files with 531 additions and 636 deletions.
1 change: 0 additions & 1 deletion api/app/Generators/ApplicationDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public function generate(): self
$this->status($section, $user);
$this->languageInfo($section, $user);
$this->governmentInfo($section, $user);
$this->workLocation($section, $user);
$this->workPreferences($section, $user);
$this->dei($section, $user);

Expand Down
8 changes: 4 additions & 4 deletions api/app/Generators/PoolCandidateCsvGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ class PoolCandidateCsvGenerator extends CsvGenerator implements FileGeneratorInt
'current_classification',
'priority_entitlement',
'priority_number',
'location_preferences',
'location_exemptions',
'accept_temporary',
'accepted_operational_requirements',
'location_preferences',
'location_exemptions',
'woman',
'indigenous',
'visible_minority',
Expand Down Expand Up @@ -143,10 +143,10 @@ public function generate(): self
$candidate->user->getClassification(), // Current classification
$this->yesOrNo($candidate->user->has_priority_entitlement), // Priority entitlement
$candidate->user->priority_number ?? '', // Priority number
$this->localizeEnumArray($candidate->user->location_preferences, WorkRegion::class),
$candidate->user->location_exemptions, // Location exemptions
$candidate->user->position_duration ? $this->yesOrNo($candidate->user->wouldAcceptTemporary()) : '', // Accept temporary
$this->localizeEnumArray($preferences['accepted'], OperationalRequirement::class),
$this->localizeEnumArray($candidate->user->location_preferences, WorkRegion::class),
$candidate->user->location_exemptions, // Location exemptions
$this->yesOrNo($candidate->user->is_woman), // Woman
$this->localizeEnumArray($candidate->user->indigenous_communities, IndigenousCommunity::class),
$this->yesOrNo($candidate->user->is_visible_minority), // Visible minority
Expand Down
8 changes: 4 additions & 4 deletions api/app/Generators/UserCsvGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class UserCsvGenerator extends CsvGenerator implements FileGeneratorInterface
'current_classification',
'priority_entitlement',
'priority_number',
'location_preferences',
'location_exemptions',
'accept_temporary',
'accepted_operational_requirements',
'location_preferences',
'location_exemptions',
'woman',
'indigenous',
'visible_minority',
Expand Down Expand Up @@ -107,10 +107,10 @@ public function generate(): self
$user->getClassification(), // Current classification
$this->yesOrNo($user->has_priority_entitlement), // Priority entitlement
$user->priority_number ?? '', // Priority number
$this->localizeEnumArray($user->location_preferences, WorkRegion::class),
$user->location_exemptions, // Location exemptions
$user->position_duration ? $this->yesOrNo($user->wouldAcceptTemporary()) : '', // Accept temporary
$this->localizeEnumArray($preferences['accepted'], OperationalRequirement::class),
$this->localizeEnumArray($user->location_preferences, WorkRegion::class),
$user->location_exemptions, // Location exemptions
$this->yesOrNo($user->is_woman), // Woman
$this->localizeEnumArray($indigenousCommunities, IndigenousCommunity::class),
$this->yesOrNo($user->is_visible_minority), // Visible minority
Expand Down
28 changes: 7 additions & 21 deletions api/app/Traits/Generator/GeneratesUserDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ protected function contactInfo(Section $section, User $user, $headingRank = 3)
$section->addTitle($this->localizeHeading('contact_info'), $headingRank);
$this->addLabelText($section, $this->localizeHeading('email'), $user->email);
$this->addLabelText($section, $this->localizeHeading('phone'), $user->telephone);
$this->addLabelText($section, $this->localizeHeading('current_city'), $this->currentLocation($user));
$this->addLabelText($section, $this->localizeHeading('preferred_communication_language'), $this->localizeEnum($user->preferred_lang, Language::class));
$this->addLabelText($section, $this->localizeHeading('preferred_spoken_interview_language'), $this->localizeEnum($user->preferred_language_for_interview, Language::class));
$this->addLabelText($section, $this->localizeHeading('preferred_written_exam_language'), $this->localizeEnum($user->preferred_language_for_exam, Language::class));
Expand Down Expand Up @@ -161,19 +160,6 @@ protected function governmentInfo(Section $section, User $user, $headingRank = 4
}
}

/**
* Generate information about a users work location
*
* @param Section $section The section to add info to
* @param User $user The user being generated
*/
protected function workLocation(Section $section, User $user, $headingRank = 4)
{
$section->addTitle($this->localizeHeading('work_location'), $headingRank);
$this->addLabelText($section, $this->localizeHeading('work_location'), $this->localizeEnumArray($user->location_preferences, WorkRegion::class));
$this->addLabelText($section, $this->localizeHeading('location_exemptions'), $user->location_exemptions ?? '');
}

/**
* Generate information about a users work preferences
*
Expand All @@ -183,6 +169,8 @@ protected function workLocation(Section $section, User $user, $headingRank = 4)
protected function workPreferences(Section $section, User $user, $headingRank = 4)
{
$section->addTitle($this->localizeHeading('work_preferences'), $headingRank);

$section->addText($this->localizeHeading('contract_duration'), $this->strong);
foreach ($user?->position_duration ?? [] as $duration) {
$section->addListItem($this->localizeEnum($duration, PositionDuration::class));
}
Expand All @@ -196,13 +184,12 @@ protected function workPreferences(Section $section, User $user, $headingRank =
}
}

if (count($preferences['not_accepted']) > 0) {
$section->addText($this->localizeHeading('rejected_operational_requirements'), $this->strong);
$section->addText($this->localizeHeading('current_location'), $this->strong);
$this->addLabelText($section, $this->localizeHeading('current_city'), $this->currentLocation($user));

foreach ($preferences['not_accepted'] as $preference) {
$section->addListItem($this->localizeEnum($preference, OperationalRequirement::class, 'long'));
}
}
$section->addText($this->localizeHeading('location_preferences'), $this->strong);
$this->addLabelText($section, $this->localizeHeading('work_location'), $this->localizeEnumArray($user->location_preferences, WorkRegion::class));
$this->addLabelText($section, $this->localizeHeading('location_exemptions'), $user->location_exemptions ?? '');
}

/**
Expand Down Expand Up @@ -374,7 +361,6 @@ protected function generateUser(Section $section, User $user, $headingRank = 2)
$this->status($section, $user, $headingRank + 2);
$this->languageInfo($section, $user, $headingRank + 2);
$this->governmentInfo($section, $user, $headingRank + 2);
$this->workLocation($section, $user, $headingRank + 2);
$this->workPreferences($section, $user, $headingRank + 2);
$this->dei($section, $user, $headingRank + 2);

Expand Down
6 changes: 4 additions & 2 deletions api/lang/en/headings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'notes' => 'Notes',
'current_province' => 'Province',
'current_city' => 'City',
'current_location' => 'Current location',
'date_received' => 'Date received',
'expiry_date' => 'Expiry date',
'archival_date' => 'Archival date',
Expand Down Expand Up @@ -36,10 +37,11 @@
'priority_entitlement' => 'Priority entitlement',
'priority_number' => 'Priority number',
'work_location' => 'Work location',
'location_preferences' => 'Location preferences',
'location_preferences' => 'Work location preferences',
'location_exemptions' => 'Location exemptions',
'contract_duration' => 'Contract duration preference',
'accept_temporary' => 'Accept temporary',
'accepted_operational_requirements' => 'Would consider accepting a job that: ',
'accepted_operational_requirements' => 'Acceptable job requirements',
'rejected_operational_requirements' => 'Would not consider a job that requires: ',
'woman' => 'Woman',
'indigenous' => 'Indigenous',
Expand Down
4 changes: 3 additions & 1 deletion api/lang/fr/headings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'notes' => 'Notes',
'current_province' => 'Province actuelle',
'current_city' => 'Ville',
'current_location' => 'Emplacement actuel',
'date_received' => 'Date de réception',
'expiry_date' => 'Date d\'expiration',
'archival_date' => 'Date d\'archivage',
Expand Down Expand Up @@ -36,8 +37,9 @@
'priority_entitlement' => 'Droit de priorité',
'priority_number' => 'Numéro de priorité',
'work_location' => 'Lieu de travail',
'location_preferences' => 'Préférences de lieux',
'location_preferences' => 'Préférences pour le lieu de travail',
'location_exemptions' => 'Exemptions de lieux',
'contract_duration' => 'Préférence pour la durée du contrat',
'accept_temporary' => 'Accepter les temporaires',
'accepted_operational_requirements' => 'Envisagerait d\'accepter un emploi qui : ',
'rejected_operational_requirements' => 'N\'envisagerait pas d\'accepter un emploi qui : ',
Expand Down
6 changes: 3 additions & 3 deletions apps/playwright/tests/applicant/profile-workflows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ test.describe("User Profile", () => {
"PersonalInformationFormOptions",
);
await applicantPage.page
.getByRole("textbox", { name: /current city/i })
.fill("Test city");
.getByRole("textbox", { name: /telephone/i })
.fill("123-456-7890");
await applicantPage.page
.getByRole("button", { name: /save changes/i })
.click();
await applicantPage.waitForGraphqlResponse("UpdateUserAsUser");
await expect(applicantPage.page.getByRole("alert").last()).toContainText(
/information updated successfully/i,
);
await expect(applicantPage.page.getByText(/test city/i)).toBeVisible();
await expect(applicantPage.page.getByText("123-456-7890")).toBeVisible();

// Edit work preferences
await applicantPage.page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ type PartialUser = Pick<
| "preferredLang"
| "preferredLanguageForInterview"
| "preferredLanguageForExam"
| "currentCity"
| "currentProvince"
| "citizenship"
| "armedForcesStatus"
>;
Expand All @@ -58,8 +56,6 @@ const Display = ({
preferredLang,
preferredLanguageForInterview,
preferredLanguageForExam,
currentCity,
currentProvince,
citizenship,
armedForcesStatus,
},
Expand Down Expand Up @@ -186,28 +182,6 @@ const Display = ({
notProvided
)}
</FieldDisplay>
<FieldDisplay
hasError={!currentCity}
label={intl.formatMessage({
defaultMessage: "Current city",
id: "de/Vcy",
description: "Label for current city field in About Me form",
})}
>
{currentCity || notProvided}
</FieldDisplay>
<FieldDisplay
hasError={!currentProvince}
label={intl.formatMessage({
defaultMessage: "Province or territory",
id: "yzgwjd",
description: "Label for current province or territory field",
})}
>
{currentProvince?.label
? getLocalizedName(currentProvince.label, intl)
: notProvided}
</FieldDisplay>
<FieldDisplay
hasError={!preferredLang}
label={intl.formatMessage({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useQuery } from "urql";
import {
Input,
RadioGroup,
Select,
localizedEnumToOptions,
} from "@gc-digital-talent/forms";
import {
Expand All @@ -28,15 +27,6 @@ const PersonalInformationFormOptions_Query = graphql(/* GraphQL */ `
fr
}
}
provinceOrTerritories: localizedEnumStrings(
enumName: "ProvinceOrTerritory"
) {
value
label {
en
fr
}
}
}
`);

Expand Down Expand Up @@ -92,30 +82,6 @@ const FormFields = ({ labels }: FormFieldProps) => {
required: intl.formatMessage(errorMessages.required),
}}
/>
<Input
id="currentCity"
name="currentCity"
type="text"
label={labels.currentCity}
rules={{
required: intl.formatMessage(errorMessages.required),
}}
/>
<Select
id="currentProvince"
name="currentProvince"
label={labels.currentProvince}
nullSelection={intl.formatMessage({
defaultMessage: "Select a province or territory",
id: "H1wLfA",
description:
"Placeholder displayed on the About Me form province or territory field.",
})}
options={localizedEnumToOptions(data?.provinceOrTerritories, intl)}
rules={{
required: intl.formatMessage(errorMessages.required),
}}
/>
</div>
<div
data-h2-display="base(grid)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
CitizenshipStatus,
Language,
Maybe,
ProvinceOrTerritory,
} from "@gc-digital-talent/graphql";

export interface FormValues {
Expand All @@ -12,8 +11,6 @@ export interface FormValues {
preferredLang?: Maybe<Language>;
preferredLanguageForInterview?: Maybe<Language>;
preferredLanguageForExam?: Maybe<Language>;
currentProvince?: Maybe<ProvinceOrTerritory>;
currentCity?: Maybe<string>;
telephone?: Maybe<string>;
firstName?: Maybe<string>;
lastName?: Maybe<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ export const getLabels = (intl: IntlShape) => ({
id: "boPmF+",
description: "Legend text for written exam language preference for exams",
}),
currentProvince: intl.formatMessage({
defaultMessage: "Province or territory",
id: "yzgwjd",
description: "Label for current province or territory field",
}),
currentCity: intl.formatMessage({
defaultMessage: "Current city",
id: "de/Vcy",
description: "Label for current city field in About Me form",
}),
telephone: intl.formatMessage(commonMessages.telephone),
firstName: intl.formatMessage({
defaultMessage: "Given name",
Expand All @@ -67,8 +57,6 @@ export const dataToFormValues = (
preferredLang: data?.preferredLang?.value,
preferredLanguageForInterview: data?.preferredLanguageForInterview?.value,
preferredLanguageForExam: data?.preferredLanguageForExam?.value,
currentProvince: data?.currentProvince?.value,
currentCity: data?.currentCity,
telephone: data?.telephone,
firstName: data?.firstName,
lastName: data?.lastName,
Expand Down
Loading

0 comments on commit 8ba30db

Please sign in to comment.