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

psp-7598 | Properties list view filter by ownership #3781

Merged
merged 7 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Pims.Api.Helpers.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Models.Base;
using Pims.Api.Models.Concepts.Property;
using Pims.Api.Policies;
using Pims.Dal.Entities.Models;
using Pims.Dal.Repositories;
Expand Down Expand Up @@ -57,7 +58,7 @@ public SearchController(IPropertyRepository propertyRepository, IMapper mapper)
[HttpGet]
[HasPermission(Permissions.PropertyView)]
[Produces("application/json")]
[ProducesResponseType(typeof(PageModel<Models.Search.PropertyModel>), 200)]
[ProducesResponseType(typeof(PageModel<PropertyModel>), 200)]
[SwaggerOperation(Tags = new[] { "property" })]
public IActionResult GetProperties()
{
Expand All @@ -74,7 +75,7 @@ public IActionResult GetProperties()
[HttpPost("filter")]
[HasPermission(Permissions.PropertyView)]
[Produces("application/json")]
[ProducesResponseType(typeof(PageModel<Models.Search.PropertyModel>), 200)]
[ProducesResponseType(typeof(PageModel<PropertyModel>), 200)]
[SwaggerOperation(Tags = new[] { "property" })]
public IActionResult GetProperties([FromBody] PropertyFilterModel filter)
{
Expand All @@ -85,7 +86,7 @@ public IActionResult GetProperties([FromBody] PropertyFilterModel filter)
}

var page = _propertyRepository.GetPage((PropertyFilter)filter);
var result = _mapper.Map<PageModel<Models.Search.PropertyModel>>(page);
var result = _mapper.Map<PageModel<PropertyModel>>(page);
return new JsonResult(result);
}

Expand Down
29 changes: 0 additions & 29 deletions source/backend/api/Areas/Property/Mapping/Search/AddressMap.cs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little nervous about these map deletions since mapping errors only show up at runtime. Since this is a release sprint, are you 100% confident these deletions are safe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, given that the model it was mapping was deleted I have confidence it was not being used anywhere else, and therefore, not mapped

This file was deleted.

49 changes: 0 additions & 49 deletions source/backend/api/Areas/Property/Mapping/Search/PropertyMap.cs

This file was deleted.

96 changes: 0 additions & 96 deletions source/backend/api/Areas/Property/Models/Search/AddressModel.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Pims.Core.Extensions;
using Pims.Dal.Entities.Models;

Expand Down Expand Up @@ -27,6 +28,11 @@ public class PropertyFilterModel : PageFilter
/// </summary>
public string PlanNumber { get; set; }

/// <summary>
/// get/set - The property ownership status.
/// </summary>
public IList<string> Ownership { get; set; }

#endregion

#region Constructors
Expand All @@ -49,10 +55,32 @@ public PropertyFilterModel(Dictionary<string, Microsoft.Extensions.Primitives.St
var filter = new Dictionary<string, Microsoft.Extensions.Primitives.StringValues>(query, StringComparer.OrdinalIgnoreCase);

this.Sort = filter.GetStringArrayValue(nameof(this.Sort));
var tempSort = this.Sort.ToList();

// Convert sort to db format
for (int i = 0; i < this.Sort.Length; i++)
{
if (tempSort[i].StartsWith("Location"))
{
tempSort[i] = tempSort[i].Replace("Location", "Address.MunicipalityName");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't check the story, but are we sure location maps to municipality (I know we also have a general location field in the db)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that is mapped on the frontend columns.

image

}
if (tempSort[i].StartsWith("Ownership"))
{
// The order will affect the display in the frontend. For now in alphabetical order.
// i.e. [Core Inventory, Disposed, Other Interest, Property of Interest]
var direction = this.Sort[i].Split(' ')[1];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this safe (ie. we always have a direction of asc or desc)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the sort expects a direction to be able to be process later

tempSort[i] = this.Sort[i].Replace("Ownership", "IsOwned");
tempSort.Add($"IsDisposed {direction}");
tempSort.Add($"IsOtherInterest {direction}");
tempSort.Add($"IsPropertyOfInterest {direction}");
}
}
this.Sort = tempSort.ToArray();

this.PinOrPid = filter.GetStringValue(nameof(this.PinOrPid));
this.Address = filter.GetStringValue(nameof(this.Address));
this.PlanNumber = filter.GetStringValue(nameof(this.PlanNumber));
this.Ownership = filter.GetStringArrayValue(nameof(this.Ownership));
}
#endregion

Expand All @@ -73,6 +101,7 @@ public static explicit operator PropertyFilter(PropertyFilterModel model)
PinOrPid = model.PinOrPid,
Address = model.Address,
PlanNumber = model.PlanNumber,
Ownership = model.Ownership,
};

return filter;
Expand Down
Loading
Loading