Skip to content

Commit

Permalink
Merge pull request #875 from Ankit-Matth/fixing_workplan_dropdowns
Browse files Browse the repository at this point in the history
Adding Placeholder Text in Workplan Dropdowns (On Workplan by Panel, Priority & Unit Pages)
  • Loading branch information
mozzy11 authored Mar 25, 2024
2 parents dd551cd + 522f0f9 commit a29555e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
6 changes: 4 additions & 2 deletions frontend/src/components/workplan/PanelSelectForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from "react";
import { Column, Grid, Select, SelectItem } from "@carbon/react";
import { FormattedMessage, injectIntl } from "react-intl";
import { FormattedMessage, injectIntl, useIntl } from "react-intl";
import "../Style.css";
import { getFromOpenElisServer } from "../utils/Utils";

Expand All @@ -20,13 +20,15 @@ function PanelSelectForm(props) {
}
};

const intl = useIntl();

useEffect(() => {
mounted.current = true;
let panelId = new URLSearchParams(window.location.search).get("panelId");
panelId = panelId ? panelId : "";
getFromOpenElisServer("/rest/panels", (fetchedPanels) => {
let panel = fetchedPanels.find((panel) => panel.id === panelId);
let panelLabel = panel ? panel.value : "";
let panelLabel = panel ? panel.value : intl.formatMessage({id:"input.placeholder.selectPanel"});
setDefaultPanelId(panelId);
setDefaultPanelLabel(panelLabel);
props.value(panelId, panelLabel);
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/workplan/PrioritySelectForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from "react";
import { Column, Grid, Select, SelectItem } from "@carbon/react";
import { FormattedMessage, injectIntl } from "react-intl";
import { FormattedMessage, injectIntl, useIntl } from "react-intl";
import "../Style.css";
import { getFromOpenElisServer } from "../utils/Utils";

Expand All @@ -20,6 +20,8 @@ function PanelSelectForm(props) {
}
};

const intl = useIntl();

useEffect(() => {
mounted.current = true;
let priorityId = new URLSearchParams(window.location.search).get(
Expand All @@ -30,7 +32,7 @@ function PanelSelectForm(props) {
let priority = fetchedPriorities.find(
(priority) => priority.id === priorityId,
);
let priorityLabel = priority ? priority.value : "";
let priorityLabel = priority ? priority.value : intl.formatMessage({id:"input.placeholder.selectPriority"});
setDefaultPriorityId(priorityId);
setDefaultPriorityLabel(priorityLabel);
props.value(priorityId, priorityLabel);
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/workplan/TestSectionSelectForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from "react";
import { Column, Grid, Select, SelectItem } from "@carbon/react";
import { FormattedMessage, injectIntl } from "react-intl";
import { FormattedMessage, injectIntl, useIntl } from "react-intl";
import "../Style.css";
import { getFromOpenElisServer } from "../utils/Utils";

Expand All @@ -20,6 +20,8 @@ function TestSectionSelectForm(props) {
}
};

const intl = useIntl();

useEffect(() => {
mounted.current = true;
let testSectionId = new URLSearchParams(window.location.search).get(
Expand All @@ -30,7 +32,7 @@ function TestSectionSelectForm(props) {
let testSection = fetchedTestSections.find(
(testSection) => testSection.id === testSectionId,
);
let testSectionLabel = testSection ? testSection.value : "";
let testSectionLabel = testSection ? testSection.value : intl.formatMessage({id:"input.placeholder.selectTestSection"});
setDefaultTestSectionId(testSectionId);
setDefaultTestSectionLabel(testSectionLabel);
props.value(testSectionId, testSectionLabel);
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,5 +765,8 @@
"input.placeholder.providerWorkPhone":"Enter Requester's Phone Number",
"input.placeholder.providerFax":"Enter Requester's Fax Number",
"input.placeholder.providerEmail":"Enter Requester's Email",
"input.placeholder.selectTest":"Select Test Type"
"input.placeholder.selectTest":"Select Test Type",
"input.placeholder.selectPanel":"Select Panel Type",
"input.placeholder.selectPriority":"Select Priority",
"input.placeholder.selectTestSection":"Select Unit Type"
}
5 changes: 4 additions & 1 deletion frontend/src/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -706,5 +706,8 @@
"input.placeholder.providerWorkPhone":"Saisir le numéro de téléphone du demandeur",
"input.placeholder.providerFax":"Saisir le numéro de fax du demandeur",
"input.placeholder.providerEmail":"Saisir l'adresse e-mail du demandeur",
"input.placeholder.selectTest":"Sélectionnez le type de test"
"input.placeholder.selectTest":"Sélectionnez le type de test",
"input.placeholder.selectPanel":"Sélectionnez le type de panneau",
"input.placeholder.selectPriority":"Sélectionnez la priorité",
"input.placeholder.selectTestSection":"Sélectionnez le type d'unité"
}

0 comments on commit a29555e

Please sign in to comment.