Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Increases classification level options #12399

Merged
merged 12 commits into from
Jan 7, 2025
3 changes: 1 addition & 2 deletions api/app/Models/Classification.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ protected function displayName(): Attribute
{
/** @disregard P1003 Not using values */
return Attribute::make(
get: fn (mixed $value, array $attributes) => $attributes['group'].'-'.sprintf('%02d', $attributes['level']),

get: fn (mixed $value, array $attributes) => $attributes['group'].'-'.($attributes['level'] < 10 ? '0' : '').$attributes['level'],
);
}

Expand Down
4 changes: 3 additions & 1 deletion api/app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ public function getClassification()

$classification = $this->currentClassification()->first();

return $classification->group.'-0'.$classification->level;
$leadingZero = $classification->level < 10 ? '0' : '';

return $classification->group.'-'.$leadingZero.$classification->level;
}

public function getDepartment()
Expand Down
4 changes: 2 additions & 2 deletions apps/playwright/tests/search-workflows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ test.describe("Talent search", () => {
await expectNoCandidate(appPage.page);

await classificationFilter.selectOption({
value: `${classification.group}-0${classification.level}`,
value: `${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`,
});

const streamFilter = appPage.page.getByRole("combobox", {
Expand Down Expand Up @@ -221,7 +221,7 @@ test.describe("Talent search", () => {
await expect(
appPage.page.getByText(
new RegExp(
`${classification.group}-0${classification.level}: search pool`,
`${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}: search pool`,
"i",
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const GovContent = ({
headingLevel={headingLevel}
>
{classification
? `${classification.group}-0${classification.level}`
? `${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`
: intl.formatMessage(commonMessages.notAvailable)}
</ContentSection>
</div>
Expand Down Expand Up @@ -122,7 +122,7 @@ const GovContent = ({
headingLevel={headingLevel}
>
{classification
? `${classification.group}-0${classification.level}`
? `${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`
: intl.formatMessage(commonMessages.notAvailable)}
</ContentSection>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ const GovFields = ({ labels }: SubExperienceFormProps) => {
.map((iterator) => {
return {
value: iterator.id.toString(), // change the value to id for the query
label: iterator.level.toString(),
label: iterator.level,
};
});
})
.sort((a, b) => a.label - b.label);

/**
* Reset classification level when group changes
Expand Down Expand Up @@ -356,6 +357,7 @@ const GovFields = ({ labels }: SubExperienceFormProps) => {
uiMessages.nullSelectionOptionLevel,
)}
options={levelOptions}
doNotSort
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const PoolCandidateFilterDialog = ({
label={intl.formatMessage(adminMessages.classifications)}
options={classifications.map(({ group, level }) => ({
value: `${group}-${level}`,
label: `${group}-0${level}`,
label: `${group}-${level < 10 ? "0" : ""}${level}`,
}))}
/>
<Combobox
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/PoolCard/PoolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const PoolCard = ({ poolQuery, headingLevel = "h3" }: PoolCardProps) => {

const classificationAbbr = pool.classification
? wrapAbbr(
`${pool.classification.group}-0${pool.classification.level}`,
`${pool.classification.group}-${pool.classification.level < 10 ? "0" : ""}${pool.classification.level}`,
intl,
)
: "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const Display = ({
>
{!!currentClassification?.group && !!currentClassification?.level
? wrapAbbr(
`${currentClassification?.group}-${currentClassification?.level}`,
`${currentClassification?.group}-${currentClassification?.level < 10 ? "0" : ""}${currentClassification?.level}`,
intl,
)
: notProvided}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ const FormFields = ({
]);

const groupOptions = getGroupOptions([...classifications], intl);
const levelOptions = getLevelOptions([...classifications], groupSelection);
const levelOptions = getLevelOptions(
[...classifications],
groupSelection,
).sort((a, b) => a.value - b.value);
const hasPriorityEntitlement = priorityEntitlement === "yes";
const isGovEmployee = govEmployee === "yes";
const isPlaced =
Expand Down Expand Up @@ -272,6 +275,7 @@ const FormFields = ({
uiMessages.nullSelectionOptionLevel,
)}
options={levelOptions}
doNotSort
/>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export const getLevelOptions = (
.filter((x) => x.group === groupSelection)
.map((iterator) => {
return {
value: iterator.level.toString(),
value: iterator.level,
label: iterator.level.toString(),
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@
// else set values if filters prop is of ApplicantFilterInput type
const classificationsFromBrowserHistory = selectedClassifications?.map(
(classification) =>
wrapAbbr(`${classification?.group}-0${classification?.level}`, intl),
wrapAbbr(
`${classification?.group}-${classification && classification?.level < 10 ? "0" : ""}${classification?.level}`,
intl,
),
);

const classifications = applicantFilter?.qualifiedClassifications ?? [];
const classificationsFromApplicantFilter = classifications
.filter(notEmpty)
.map((classification) =>
wrapAbbr(`${classification?.group}-0${classification?.level}`, intl),
wrapAbbr(
`${classification?.group}-${classification?.level < 10 ? "0" : ""}${classification?.level}`,
intl,
),
);

const skills: string[] | undefined = applicantFilter?.skills?.map((skill) => {
Expand Down Expand Up @@ -83,7 +89,7 @@

// eslint-disable-next-line deprecation/deprecation
const educationLevel: string | undefined = hasDiplomaToEducationLevel(
applicantFilter?.hasDiploma,

Check warning on line 92 in apps/web/src/components/SearchRequestFilters/SearchRequestFilters.tsx

View workflow job for this annotation

GitHub Actions / Lint

'hasDiploma' is deprecated. hasDiploma to be replaced
intl,
);

Expand Down Expand Up @@ -270,7 +276,7 @@
const classifications: string[] | undefined =
poolCandidateFilter?.classifications?.map(
(classification) =>
`${classification?.group.toLocaleUpperCase()}-0${classification?.level}`,
`${classification?.group.toLocaleUpperCase()}-${classification && classification?.level < 10 ? "0" : ""}${classification?.level}`,
);

const pools: Pool[] | undefined = poolCandidateFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const SearchRequestFilterDialog = ({
label={intl.formatMessage(adminMessages.classifications)}
options={classifications.map((classification) => ({
value: classification.id,
label: `${classification.group}-0${classification.level}`,
label: `${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`,
}))}
/>
<Combobox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function classificationAccessor(
) {
return classifications
?.filter(notEmpty)
?.map((c) => `${c.group}-0${c.level}`)
?.map((c) => `${c.group}-${c.level < 10 ? "0" : ""}${c.level}`)
?.join(", ");
}

Expand All @@ -34,10 +34,10 @@ export function classificationsCell(
const chipsArray = filteredClassifications.map((classification) => {
return (
<Chip
key={`${classification.group}-0${classification.level}`}
key={`${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`}
color="primary"
>
{`${classification.group}-0${classification.level}`}
{`${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`}
</Chip>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const GovernmentInformationSection = ({
</span>
<span data-h2-font-weight="base(700)">
{wrapAbbr(
`${currentClassification?.group}-${currentClassification?.level}`,
`${currentClassification?.group}-${currentClassification?.level < 10 ? "0" : ""}${currentClassification?.level}`,
intl,
)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@ export const EmployeeInformationFormFields = ({
.filter((x) => x.group === groupSelection)
.map((iterator) => {
return {
value: iterator.level.toString(),
value: iterator.level,
label: iterator.level.toString(),
};
});
})
.sort((a, b) => a.value - b.value);

const isGovEmployee = govEmployee === "yes";

Expand Down Expand Up @@ -345,6 +346,7 @@ export const EmployeeInformationFormFields = ({
uiMessages.nullSelectionOptionLevel,
)}
options={levelOptions}
doNotSort
/>
</div>
</>
Expand Down
14 changes: 3 additions & 11 deletions apps/web/src/pages/Classifications/CreateClassificationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import pageTitles from "~/messages/pageTitles";
import Hero from "~/components/Hero";

import messages from "./messages";
import { getClassificationLevels } from "./helpers";

type FormValues = CreateClassificationInput;

Expand Down Expand Up @@ -168,17 +169,8 @@ export const CreateClassification = () => {
rules={{
required: intl.formatMessage(errorMessages.required),
}}
options={[
{ value: 1, label: "1" },
{ value: 2, label: "2" },
{ value: 3, label: "3" },
{ value: 4, label: "4" },
{ value: 5, label: "5" },
{ value: 6, label: "6" },
{ value: 7, label: "7" },
{ value: 8, label: "8" },
{ value: 9, label: "9" },
]}
options={getClassificationLevels()}
doNotSort
/>
<Input
id="minSalary"
Expand Down
14 changes: 3 additions & 11 deletions apps/web/src/pages/Classifications/UpdateClassificationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { getClassificationName } from "~/utils/poolUtils";
import Hero from "~/components/Hero";

import messages from "./messages";
import { getClassificationLevels } from "./helpers";

export const ClassificationForm_Fragment = graphql(/* GraphQL */ `
fragment ClassificationForm on Classification {
Expand Down Expand Up @@ -231,17 +232,8 @@ export const UpdateClassificationForm = ({
rules={{
required: intl.formatMessage(errorMessages.required),
}}
options={[
{ value: 1, label: "1" },
{ value: 2, label: "2" },
{ value: 3, label: "3" },
{ value: 4, label: "4" },
{ value: 5, label: "5" },
{ value: 6, label: "6" },
{ value: 7, label: "7" },
{ value: 8, label: "8" },
{ value: 9, label: "9" },
]}
options={getClassificationLevels()}
doNotSort
disabled
/>
<Input
Expand Down
13 changes: 13 additions & 0 deletions apps/web/src/pages/Classifications/helpers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function getClassificationLevels(): {
value: number;
label: number;
}[] {
const levels: {
value: number;
label: number;
}[] = [];
for (let i = 1; i <= 19; i++) {
levels.push({ value: i, label: i });
}
return levels;
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function previewMetaData(
metaData.push({
key: classification.id,
type: "chip",
children: `${classification.group}-0${classification.level}`,
children: `${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`,
} satisfies PreviewMetaData);
}

Expand Down Expand Up @@ -356,7 +356,7 @@ const JobPosterTemplatesPage = () => {
.sort((a, b) => a.level - b.level)
.map((classification) => ({
value: classification.id,
label: `${classification.group}-0${classification.level}`,
label: `${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`,
}))}
/>
<Checklist
Expand Down
10 changes: 6 additions & 4 deletions apps/web/src/pages/Pools/CreatePoolPage/CreatePoolPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ export const CreatePoolForm = ({

// recycled from EditPool
const classificationOptions: Option[] = classifications.map(
({ id, group, level, name }) => ({
value: id,
label: `${group}-0${level} (${getLocalizedName(name, intl)})`,
}),
({ id, group, level, name }) => {
return {
value: id,
label: `${group}-${level < 10 ? "0" : ""}${level} (${getLocalizedName(name, intl)})`,
};
},
);

const departmentOptions: Option[] = departments.map(({ id, name }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ const EducationRequirementsSection = ({
});
const classificationGroup = pool.classification?.group;
const classificationAbbr = pool.classification
? wrapAbbr(`${classificationGroup}-0${pool.classification.level}`, intl)
? wrapAbbr(
`${classificationGroup}-${pool.classification.level < 10 ? "0" : ""}${pool.classification.level}`,
intl,
)
: "";

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const getClassificationOptions = (
): Option[] => {
return classifications.filter(notEmpty).map(({ id, group, level, name }) => ({
value: id,
label: `${group}-0${level} (${getLocalizedName(name, intl)})`,
label: `${group}-${level < 10 ? "0" : ""}${level} (${getLocalizedName(name, intl)})`,
}));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const PoolFilterDialog = ({
options={unpackMaybes(data?.classifications).map(
({ group, level }) => ({
value: `${group}-${level}`,
label: `${group}-0${level}`,
label: `${group}-${level < 10 ? "0" : ""}${level}`,
}),
)}
/>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/Pools/IndexPoolPage/components/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
);
}

export function viewTeamLinkCell(

Check warning on line 55 in apps/web/src/pages/Pools/IndexPoolPage/components/helpers.tsx

View workflow job for this annotation

GitHub Actions / Lint

exported declaration 'viewTeamLinkCell' not used within other modules
url: Maybe<string> | undefined,
displayName: Maybe<LocalizedString> | undefined,
intl: IntlShape,
Expand Down Expand Up @@ -88,7 +88,7 @@
classification: Maybe<Pick<Classification, "group" | "level">> | undefined,
) {
return classification
? `${classification.group}-0${classification.level}`
? `${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`
: "";
}

Expand All @@ -99,7 +99,7 @@

return (
<Chip color="primary">
{`${classification.group}-0${classification.level}`}
{`${classification.group}-${classification.level < 10 ? "0" : ""}${classification.level}`}
</Chip>
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/pages/SearchRequests/SearchPage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
labels: Record<string, MessageDescriptor>,
intl: IntlShape,
) => {
const key = `${group}-0${level}`;
const key = `${group}-${level < 10 ? "0" : ""}${level}`;
return !hasKey(labels, key) ? key : intl.formatMessage(labels[key]);
};

Expand Down Expand Up @@ -115,7 +115,7 @@
...(data?.equity?.isVisibleMinority ? ["isVisibleMinority"] : []),
...(data?.equity?.isWoman ? ["isWoman"] : []),
],
educationRequirement: data.hasDiploma ? "has_diploma" : "no_diploma",

Check warning on line 118 in apps/web/src/pages/SearchRequests/SearchPage/utils.ts

View workflow job for this annotation

GitHub Actions / Lint

'hasDiploma' is deprecated. hasDiploma to be replaced
skills: data.skills?.filter(notEmpty).map((s) => s.id) ?? [],
stream: stream?.id ?? "",
locationPreferences: data.locationPreferences?.filter(notEmpty) ?? [],
Expand Down
Loading
Loading