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

Correct Sorting for all types #412

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion FMS.Domain/Dto/Facility/FacilitySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace FMS.Domain.Dto
{
public class FacilitySpec
{
public FacilitySort SortBy { get; set; } = FacilitySort.Name;
public FacilitySort SortBy { get; set; } = FacilitySort.Name;

public bool FirstPass { get; set; } = true;

[Display(Name = "Facility Number")]
public string FacilityNumber { get; set; }
Expand Down Expand Up @@ -115,6 +117,7 @@ public class FacilitySpec
{nameof(PostalCode), PostalCode},
{nameof(State), State},
{nameof(ShowPendingOnly), ShowPendingOnly.ToString()},
{nameof(FirstPass), FirstPass.ToString()},
};
}
}
1 change: 0 additions & 1 deletion FMS.Infrastructure/Repositories/FacilityRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
{
item.Cabinets = cabinets.GetCabinetsForFile(item.FileLabel);
}

}

return items;
Expand Down Expand Up @@ -309,7 +308,7 @@
if (file == null)
throw new ArgumentException($"File Label {facilityUpdates.FileLabel} does not exist.");
facility.File = file;
facility.FileId = file?.Id;

Check warning on line 311 in FMS.Infrastructure/Repositories/FacilityRepository.cs

View workflow job for this annotation

GitHub Actions / Analyze with CodeQL (csharp)

Remove this unnecessary check for null. (https://rules.sonarsource.com/csharp/RSPEC-2589)

Check warning on line 311 in FMS.Infrastructure/Repositories/FacilityRepository.cs

View workflow job for this annotation

GitHub Actions / Run unit tests

Remove this unnecessary check for null. (https://rules.sonarsource.com/csharp/RSPEC-2589)
}
}

Expand Down
1 change: 1 addition & 0 deletions FMS/Pages/Facilities/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<input type="hidden" asp-for="Spec.ShowDeleted" />
<input type="hidden" asp-for="Spec.ShowPendingOnly" />
<input type="hidden" asp-for="Spec.SortBy" />
<input type="hidden" asp-for="Spec.FirstPass" />
<button id="ExportButton" asp-page-handler="ExportButton"
class="btn btn-sm btn-outline-primary mb-1">
Excel Export
Expand Down
16 changes: 12 additions & 4 deletions FMS/Pages/Facilities/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,30 @@ public IndexModel(

public async Task<IActionResult> OnGetAsync()
{
Spec = new FacilitySpec();
// First time through search will sort by name,
// but for pending RNs will sort by ReceivedDate
Spec = new FacilitySpec() { FirstPass = true };
await PopulateSelectsAsync();
return Page();
}

public async Task<IActionResult> OnGetSearchAsync(FacilitySpec spec, [FromQuery] int p = 1)
{
// Get the list of facilities matching the "Spec" criteria.

// Sort by Received Date for Pending Release Notifications
spec.SortBy = spec.ShowPendingOnly ? FacilitySort.RNDateReceived : FacilitySort.Name;
if (spec.ShowPendingOnly && spec.FirstPass)
{
spec.SortBy = FacilitySort.RNDateReceived;
spec.FirstPass = false;
};

// Get the list of facilities matching the "Spec" criteria.
FacilityList = await _repository.GetFacilityPaginatedListAsync(spec, p, GlobalConstants.PageSize);
Spec = spec;

ShowPendingOnlyCheckBox = await _repositoryType.GetFacilityTypeNameAsync(Spec.FacilityTypeId) == "RN";

ShowResults = true;
ShowResults = true;
await PopulateSelectsAsync();
return Page();
}
Expand Down
Loading