Skip to content

Commit

Permalink
Changes to vacancy view
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Howes committed May 26, 2021
1 parent 6502e3b commit e5a2559
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 20 deletions.
12 changes: 9 additions & 3 deletions src/Provider/Provider.Web/Orchestrators/VacanciesOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,34 @@ public class VacanciesOrchestrator
private readonly IRecruitVacancyClient _recruitVacancyClient;
private readonly ITimeProvider _timeProvider;
private readonly IProviderAlertsViewModelFactory _providerAlertsViewModelFactory;
private readonly IProviderRelationshipsService _providerRelationshipsService;

public VacanciesOrchestrator(
IProviderVacancyClient providerVacancyClient,
IRecruitVacancyClient recruitVacancyClient,
ITimeProvider timeProvider,
IProviderAlertsViewModelFactory providerAlertsViewModelFactory)
IProviderAlertsViewModelFactory providerAlertsViewModelFactory,
IProviderRelationshipsService providerRelationshipsService)
{
_providerVacancyClient = providerVacancyClient;
_recruitVacancyClient = recruitVacancyClient;
_timeProvider = timeProvider;
_providerAlertsViewModelFactory = providerAlertsViewModelFactory;
_providerRelationshipsService = providerRelationshipsService;
}

public async Task<VacanciesViewModel> GetVacanciesViewModelAsync(
VacancyUser user, string filter, int page, string searchTerm)
{
var getDashboardTask = _providerVacancyClient.GetDashboardAsync(user.Ukprn.Value, createIfNonExistent: true);
var getUserDetailsTask = _recruitVacancyClient.GetUsersDetailsAsync(user.UserId);
var providerTask = _providerRelationshipsService.GetLegalEntitiesForProviderAsync(user.Ukprn.Value, OperationType.RecruitmentRequiresReview);

await Task.WhenAll(getDashboardTask, getUserDetailsTask);
await Task.WhenAll(getDashboardTask, getUserDetailsTask, providerTask);

var dashboard = getDashboardTask.Result;
var userDetails = getUserDetailsTask.Result;
var providerPermissions = providerTask.Result;

var alerts = _providerAlertsViewModelFactory.Create(dashboard, userDetails);

Expand Down Expand Up @@ -87,7 +92,8 @@ public async Task<VacanciesViewModel> GetVacanciesViewModelAsync(
Filter = filteringOption,
SearchTerm = searchTerm,
ResultsHeading = VacancyFilterHeadingHelper.GetFilterHeading(Constants.VacancyTerm, filteredVacanciesTotal, filteringOption, searchTerm, UserType.Provider),
Alerts = alerts
Alerts = alerts,
HasEmployerReviewPermission = providerPermissions.Any()
};

return vm;
Expand Down
1 change: 1 addition & 0 deletions src/Provider/Provider.Web/ViewModels/VacanciesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public class VacanciesViewModel
public bool ShowResultsTable => Vacancies.Any();
public FilteringOptions Filter { get; set; }
public string SearchTerm { get; set; }
public bool HasEmployerReviewPermission { get; set; }
}
}
14 changes: 4 additions & 10 deletions src/Provider/Provider.Web/Views/Vacancies/Vacancies.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
return "Edit and resubmit";
case VacancyStatus.Draft:
return "Edit and submit";
case VacancyStatus.Review:
return "View";
}
return "Manage";
}
Expand Down Expand Up @@ -59,7 +57,10 @@
<option value="@FilteringOptions.All">all vacancies</option>
<option value="@FilteringOptions.Live">live vacancies</option>
<option value="@FilteringOptions.Referred">rejected vacancies</option>
<option value="@FilteringOptions.Review">employer review</option>
@if (Model.HasEmployerReviewPermission)
{
<option value="@FilteringOptions.Review">employer review</option>
}
<option value="@FilteringOptions.Submitted">pending review</option>
<option value="@FilteringOptions.Draft">draft vacancies</option>
<option value="@FilteringOptions.Closed">closed vacancies</option>
Expand Down Expand Up @@ -138,15 +139,8 @@
<td class="govuk-table__cell dashboard-closingdate" data-label="Closing date"><span>@vacancy.ClosingDate?.AsGdsDate()</span></td>
<td class="govuk-table__cell dashboard-status" data-label="Status"><span class="tag tag-@vacancy.Status.ToString().ToLower()">@vacancy.Status.GetDisplayName(UserType.Provider)</span></td>
<td class="govuk-table__cell dashboard-action" data-label="Action">
@if(vacancy.Status == VacancyStatus.Review)
{
<a asp-show="@vacancy.Status == VacancyStatus.Review" asp-route="@RouteNames.DisplayFullVacancy_Get" asp-route-vacancyId="@vacancy.Id" class="govuk-link">@GetLinkText(vacancy)</a>
}
else
{
<a asp-show="@vacancy.IsNotSubmittable" asp-route="@RouteNames.VacancyManage_Get" asp-route-vacancyId="@vacancy.Id" class="govuk-link">@GetLinkText(vacancy)</a>
<a asp-show="@vacancy.IsSubmittable" asp-route="@RouteNames.DisplayVacancy_Get" asp-route-vacancyId="@vacancy.Id" class="govuk-link">@GetLinkText(vacancy)</a>
}
</td>
</tr>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Esfa.Recruit.Vacancies.Client.Infrastructure.Client;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.Provider;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.ProviderRelationship;
using FluentAssertions;
using Moq;
using Xunit;
Expand All @@ -20,6 +21,7 @@ public class GetVacanciesViewModelAsyncTests
private User _userDetails;
private Mock<IProviderAlertsViewModelFactory> _providerAlertsViewModelFactoryMock;
private Mock<IRecruitVacancyClient> _recruitVacancyClientMock;
private Mock<IProviderRelationshipsService> _providerRelationshipsServiceMock;

[Fact]
public async Task WhenHaveOver25Vacancies_ShouldShowPager()
Expand All @@ -45,7 +47,8 @@ public async Task WhenHaveOver25Vacancies_ShouldShowPager()
providerClientMock.Object,
_recruitVacancyClientMock.Object,
timeProviderMock.Object,
_providerAlertsViewModelFactoryMock.Object);
_providerAlertsViewModelFactoryMock.Object,
_providerRelationshipsServiceMock.Object);

var vm = await orch.GetVacanciesViewModelAsync(_user, "Submitted", 2, string.Empty);

Expand Down Expand Up @@ -81,7 +84,8 @@ public async Task WhenHave25OrUnderVacancies_ShouldNotShowPager()
providerClientMock.Object,
_recruitVacancyClientMock.Object,
timeProviderMock.Object,
_providerAlertsViewModelFactoryMock.Object);
_providerAlertsViewModelFactoryMock.Object,
_providerRelationshipsServiceMock.Object);

var vm = await orch.GetVacanciesViewModelAsync(_user, "Submitted", 2, string.Empty);

Expand Down Expand Up @@ -116,6 +120,7 @@ public GetVacanciesViewModelAsyncTests()
.ReturnsAsync(_userDetails);

_providerAlertsViewModelFactoryMock = new Mock<IProviderAlertsViewModelFactory>();
_providerRelationshipsServiceMock = new Mock<IProviderRelationshipsService>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Esfa.Recruit.Vacancies.Client.Infrastructure.Client;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.Provider;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.ProviderRelationship;
using FluentAssertions;
using Moq;
using Xunit;
Expand All @@ -20,6 +21,7 @@ public class GivenSearchTerm
private User _userDetails;
private Mock<IRecruitVacancyClient> _recruitVacancyClientMock;
private Mock<IProviderAlertsViewModelFactory> _providerAlertsViewModelFactoryMock;
private Mock<IProviderRelationshipsService> _providerRelationshipsServiceMock;

private VacancySummary[] _testVacancies = new[]
{
Expand Down Expand Up @@ -74,7 +76,8 @@ private VacanciesOrchestrator GetSut()
providerClientMock.Object,
_recruitVacancyClientMock.Object,
timeProviderMock.Object,
_providerAlertsViewModelFactoryMock.Object);
_providerAlertsViewModelFactoryMock.Object,
_providerRelationshipsServiceMock.Object);
}

public GivenSearchTerm()
Expand All @@ -101,6 +104,7 @@ public GivenSearchTerm()
.ReturnsAsync(_userDetails);

_providerAlertsViewModelFactoryMock = new Mock<IProviderAlertsViewModelFactory>();
_providerRelationshipsServiceMock = new Mock<IProviderRelationshipsService>();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Esfa.Recruit.Vacancies.Client.Infrastructure.Client;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.Provider;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.ProviderRelationship;
using Moq;

namespace Esfa.Recruit.UnitTests.Provider.Web.Orchestrators.Vacancies.SearchResultHeaderTest
Expand All @@ -18,6 +19,7 @@ public class SearchResultHeaderTestBase
protected User UserDetails;
protected Mock<IRecruitVacancyClient> RecruitVacancyClientMock;
protected Mock<IProviderAlertsViewModelFactory> ProviderAlertsViewModelFactoryMock;
private Mock<IProviderRelationshipsService> ProviderRelationshipsServiceMock;
protected Mock<ITimeProvider> TimeProvider;
protected const int ClosingSoonDays = 5;

Expand All @@ -33,7 +35,8 @@ protected VacanciesOrchestrator GetSut(IEnumerable<VacancySummary> vacancySummar
clientMock.Object,
RecruitVacancyClientMock.Object,
TimeProvider.Object,
ProviderAlertsViewModelFactoryMock.Object);
ProviderAlertsViewModelFactoryMock.Object,
ProviderRelationshipsServiceMock.Object);
}

protected IEnumerable<VacancySummary> GenerateVacancySummaries(int count, string legalEntityName, string term, VacancyStatus status)
Expand Down Expand Up @@ -76,6 +79,7 @@ public SearchResultHeaderTestBase()
.ReturnsAsync(UserDetails);

ProviderAlertsViewModelFactoryMock = new Mock<IProviderAlertsViewModelFactory>();
ProviderRelationshipsServiceMock = new Mock<IProviderRelationshipsService>();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class VacancySummaryViewModel
public bool IsLive => Status == VacancyStatus.Live;
public bool IsNotLive => !IsLive;

public bool IsSubmittable => Status == VacancyStatus.Draft || Status == VacancyStatus.Referred || Status == VacancyStatus.Review || Status == VacancyStatus.Rejected;
public bool IsSubmittable => Status == VacancyStatus.Draft || Status == VacancyStatus.Referred || Status == VacancyStatus.Rejected;
public bool IsNotSubmittable => !IsSubmittable;
public int NoOfApplications => NoOfNewApplications + NoOfSuccessfulApplications + NoOfUnsuccessfulApplications;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ public class Vacancy
public string ClosureExplanation { get; set; }
public TransferInfo TransferInfo { get; set; }
public bool CanClose => Status == VacancyStatus.Live;
public bool CanClone => Status ==
VacancyStatus.Live || Status == VacancyStatus.Closed || Status == VacancyStatus.Submitted;
public bool CanClone => (Status == VacancyStatus.Live ||
Status == VacancyStatus.Closed ||
Status == VacancyStatus.Submitted ||
Status == VacancyStatus.Review);
/// <summary>
/// We can only delete draft vacancies that have not been deleted
/// </summary>
Expand Down

0 comments on commit e5a2559

Please sign in to comment.