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-6829 : Management activity - list view #3526

Merged
merged 8 commits into from
Oct 20, 2023
Merged

Conversation

eddherrera
Copy link
Collaborator

image

@eddherrera eddherrera added the enhancement New feature or request label Oct 19, 2023
@eddherrera eddherrera self-assigned this Oct 19, 2023
@github-actions
Copy link
Contributor

✅ No secrets were detected in the code.

@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

Merging #3526 (e32cdf5) into dev (23eb48e) will increase coverage by 0.02%.
The diff coverage is 75.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #3526      +/-   ##
==========================================
+ Coverage   70.62%   70.65%   +0.02%     
==========================================
  Files        1338     1344       +6     
  Lines       32126    32306     +180     
  Branches     6006     6030      +24     
==========================================
+ Hits        22690    22826     +136     
- Misses       9189     9231      +42     
- Partials      247      249       +2     
Flag Coverage Δ
unittests 70.65% <75.55%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...pi/Models/Concepts/Property/PropertyActivityMap.cs 100.00% <100.00%> (ø)
...Concepts/Property/PropertyManagementActivityMap.cs 100.00% <100.00%> (ø)
...ilsManagement/detail/PropertyManagementTabView.tsx 66.66% <ø> (ø)
...detail/activitiesList/ManagementActivitiesList.tsx 100.00% <100.00%> (ø)
...etail/activitiesList/models/PropertyActivityRow.ts 100.00% <100.00%> (ø)
...end/src/hooks/pims-api/useApiPropertyManagement.ts 75.00% <75.00%> (ø)
...ks/repositories/usePropertyManagementRepository.ts 81.81% <75.00%> (-3.90%) ⬇️
source/backend/api/Services/PropertyService.cs 60.58% <89.47%> (+4.65%) ⬆️
...tivitiesList/ManagementActivitiesListContainer.tsx 88.46% <88.46%> (ø)
...operty/Controllers/PropertyManagementController.cs 0.00% <0.00%> (ø)
... and 2 more

var propertyManagementActivity = _propertyRepository.GetManagementActivityById(managementActivityId);
if(propertyManagementActivity.PropertyId != propertyId)
{
throw new BadRequestException($"PropertyManagementActivity with Id: {managementActivityId} and PropertyId {propertyId} doesn't exists");
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should be "doesn't exist" (with no s)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

var sucess = _propertyRepository.TryDeletePropertyActivity(managementActivityId);
_propertyRepository.CommitTransaction();

return sucess;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: success

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

@@ -5,6 +5,7 @@
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic;
Copy link
Collaborator

Choose a reason for hiding this comment

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

que?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed, no idea how it got there.

@@ -464,6 +465,74 @@ public HashSet<long> GetMatchingIds(PropertyFilterCriteria filter)
return query.Select(p => p.PropertyId).ToHashSet();
}

/// <summary>
/// Return a summary List of Management activities for a especific property.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: especific

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated


return Context.PimsPropPropActivities
.AsNoTracking()
.Include(x => x.PimsPropertyActivity)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need the includes on the code navigation properties as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I needed it for the Service to check that the activity status is 'not started'.

}

/// <summary>
/// TryDelete the Activity asscociated with the property and if no property associated to activity delete the activicy as well.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: associated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated


if (deletedEntity is not null)
{
if (Context.PimsPropPropActivities.Count(x => x.PimsPropertyActivityId == deletedEntity.PimsPropertyActivityId) > 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you explain what you are trying to do here? it seems like you are manually implement a cascade here but I believe we already have a db cascade in place for PimsPropertyActivity and PimsPropPropActivity. This top if statement also appears to be only removing the many-to-many, that seems odd if the caller requested that an activity by deleted by an activity id, as the activity will still be in the system, just not the first many-to-many with a matching id.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As discussed, updated method name and added comments for clarity.

}

[Fact]
public void Delete_PropertyManagementActivity_BadRequest_Activity_STARTED()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: naming convention -> STARTED

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

return (
<Table<PropertyActivityRow>
name="PropertyManagementActivitiesTable"
manualSortBy={false}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should probably be true since you are passing your own sort methods, but I will confirm.

Copy link
Collaborator Author

@eddherrera eddherrera Oct 20, 2023

Choose a reason for hiding this comment

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

not sure if it should. As it is it works properly.

}) => {
const [sort, setSort] = React.useState<TableSort<Api_PropertyManagementActivity>>({});

const mapSortField = (sortField: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

huh, was the display order not a viable option here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

negative, display order is not a property on the activity. Such property was removed from the model.


return (
<Section isCollapsable initiallyExpanded header="Activities List">
<LoadingBackdrop show={isLoading} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need this? there should already be a spinner on the table right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I followed the patter as the Contact list, but you are correct. this was updated to pass the flag to the table.

@github-actions
Copy link
Contributor

✅ No secrets were detected in the code.

@github-actions
Copy link
Contributor

✅ No secrets were detected in the code.

@eddherrera eddherrera merged commit 88a0024 into bcgov:dev Oct 20, 2023
8 of 9 checks passed
@eddherrera eddherrera deleted the psp-6829 branch October 21, 2023 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants