Skip to content

Commit

Permalink
WIP15
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgriff committed Oct 21, 2024
1 parent fd9690e commit ae5923a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion GenderPayGap.WebUI/Models/Search/SearchApiResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace GenderPayGap.WebUI.Models.Search
public class SearchApiResult
{

public Dictionary<string, string> Sectors { get; set; } = new Dictionary<string, string> {{"A", "Hello"}};
public Dictionary<string, string> Sectors { get; set; }
public SearchPageViewModel SearchParameters { get; set; }
public List<SearchApiResultEmployer> Employers { get; set; }

Expand Down
1 change: 1 addition & 0 deletions GenderPayGap.WebUI/Search/ViewingSearchServiceNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public SearchApiResult Search(SearchPageViewModel searchParams)

return new SearchApiResult
{
Sectors = sectorsDictionary,
SearchParameters = searchParams,
Employers = rankedOrganisations.Select(ConvertRankedOrgsToSearchApiResultEmployer).ToList()
};
Expand Down
45 changes: 38 additions & 7 deletions GenderPayGap.WebUI/Views/Search/SearchPage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,41 @@

<p class="govuk-body" id="gpg-search-page--results-info" style="display: none;">
<span id="gpg-search-page--results--number-of-results" class="govuk-!-font-size-48 govuk-!-font-weight-bold"></span>
employers
<span id="gpg-search-page--results--employer-employers"></span>
<span id="gpg-search-page--results--containing">
containing
<span class="govuk-!-font-weight-bold" id="gpg-search-page--results--containing-search-term"></span>
</span>
</p>
<div id="gpg-search-page--results-info--no-results">
<p class="govuk-body">
Try searching again. Check:
</p>
<ul class="govuk-list govuk-list--bullet">
<li>
your spelling
</li>
<li>
the employer name (sometimes the commonly known employer name is different to their registered name)
</li>
</ul>
<p class="govuk-body">
You may not find the data you are looking for because:
</p>
<ul class="govuk-list govuk-list--bullet">
<li>
only employers with a headcount of 250 or more on their snapshot date are required to submit their gender pay gap information
</li>
<li>
the employer may have reported their gender pay gap information under a different registered name
</li>
<li>
the employer may not have submitted their gender pay gap information yet.
Most public authority employers have a reporting deadline of 30 March, and
private, voluntary and all other public authority employers have a reporting deadline of 4 April.
</li>
</ul>
</div>

<div id="gpg-search-page--results"></div>
</div>
Expand Down Expand Up @@ -372,8 +401,8 @@
try {
const response = await fetch(`${searchApiPath}${urlQuery}`);
if (response.ok) {
const json = await response.json();
if (searchResultsIdGenerator.isCurrentId(searchResultsId)) {
const json = await response.json();
displaySearchResults(json);
}
}
Expand All @@ -387,11 +416,13 @@
function displaySearchResults(json) {
document.getElementById('gpg-search-page--results--number-of-results').innerText = json.Employers.length.toLocaleString();
document.getElementById('gpg-search-page--results--employer-employers').innerText = json.Employers.length === 1 ? 'employer' : 'employers';
document.getElementById('gpg-search-page--results--containing-search-term').innerText = json.SearchParameters.EmployerName;
document.getElementById('gpg-search-page--results--containing').style.display = json.SearchParameters.EmployerName ? 'inline' : 'none';
document.getElementById('gpg-search-page--results-info').style.display = 'block';
document.getElementById('gpg-search-page--results-info--no-results').style.display = json.Employers.length > 0 ? 'none' : 'block';
document.getElementById('gpg-search-page--results').innerHTML = '';
Expand Down Expand Up @@ -429,13 +460,13 @@
link.innerText = employerName;
th.appendChild(link);
}
function createTdWithTextAndAddToTr(tr, td_text) {
function createTdWithTextAndAddToTr(tr, td_text, textIfEmpty) {
const td = document.createElement('td');
if (td_text) {
td.innerText = td_text;
}
else {
td.innerText = 'No previous name';
td.innerText = textIfEmpty;
td.classList.add('gpg-search-results--empty-cell')
}
tr.appendChild(td);
Expand Down Expand Up @@ -489,10 +520,10 @@
employersInThisBlock.forEach((employer) => {
const results_new_tbody_tr = document.createElement('tr');
createThWithLinkToEmployerAndAddToTr(results_new_tbody_tr, employer.Id, employer.Name);
createTdWithTextAndAddToTr(results_new_tbody_tr, employer.PreviousName);
createTdWithTextAndAddToTr(results_new_tbody_tr, employer.Address);
createTdWithTextAndAddToTr(results_new_tbody_tr, employer.PreviousName, 'No previous name');
createTdWithTextAndAddToTr(results_new_tbody_tr, employer.Address, 'No address');
const sectorsNames = employer.Sectors.map(sectorId => json.Sectors[sectorId]).join('; ').replaceAll('\n','').replaceAll('\r','');
createTdWithTextAndAddToTr(results_new_tbody_tr, sectorsNames);
createTdWithTextAndAddToTr(results_new_tbody_tr, sectorsNames, 'No sector');
createTdWithCompareButton(results_new_tbody_tr, employer.EncId, employer.Name);
results_new_tbody.appendChild(results_new_tbody_tr);
});
Expand Down
4 changes: 4 additions & 0 deletions GenderPayGap.WebUI/wwwroot/styles/pages/_search-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
td:nth-of-type(3) /* Sectors */ {
@extend .govuk-body-s;
margin-bottom: 5px;

&.gpg-search-results--empty-cell {
@extend .govuk-visually-hidden;
}
}

td:nth-of-type(4) /* The "Action2 column which contains the Add/Remove button */ {
Expand Down

0 comments on commit ae5923a

Please sign in to comment.