-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PSP-6865 property management models (#3488)
* Add new properties to backend models * Get property leases by property-id * API models and basic edit/view * Fix EF query * Update backend mappings * Model update
- Loading branch information
Showing
15 changed files
with
277 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
source/backend/api/Models/Concepts/Property/PropertyManagementPurposeMap.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Mapster; | ||
using Entity = Pims.Dal.Entities; | ||
|
||
namespace Pims.Api.Models.Concepts | ||
{ | ||
public class PropertyManagementPurposeMap : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) | ||
{ | ||
config.NewConfig<Entity.PimsPropPropPurpose, PropertyManagementPurposeModel>() | ||
.Map(dest => dest.Id, src => src.Internal_Id) | ||
.Map(dest => dest.PropertyId, src => src.PropertyId) | ||
.Map(dest => dest.PropertyPurposeTypeCode, src => src.PropertyPurposeTypeCodeNavigation) | ||
.Inherits<Entity.IBaseAppEntity, BaseAppModel>(); | ||
|
||
config.NewConfig<PropertyManagementPurposeModel, Entity.PimsPropPropPurpose>() | ||
.Map(dest => dest.Internal_Id, src => src.Id) | ||
.Map(dest => dest.PropertyId, src => src.PropertyId) | ||
.Map(dest => dest.PropertyPurposeTypeCode, src => src.PropertyPurposeTypeCode.Id) | ||
.Inherits<BaseAppModel, Entity.IBaseAppEntity>(); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
source/backend/api/Models/Concepts/Property/PropertyManagementPurposeModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Pims.Api.Models.Concepts | ||
{ | ||
public class PropertyManagementPurposeModel : BaseAppModel | ||
{ | ||
#region Properties | ||
|
||
/// <summary> | ||
/// get/set - The relationship id. | ||
/// </summary> | ||
public long Id { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - Parent property id. | ||
/// </summary> | ||
public long PropertyId { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - The property purpose type code. | ||
/// </summary> | ||
public TypeModel<string> PropertyPurposeTypeCode { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace Pims.Dal.Entities | ||
{ | ||
/// <summary> | ||
/// PimsPropPropPurpose class, provides an entity for the datamodel to manage property management purpose types. | ||
/// </summary> | ||
public partial class PimsPropPropPurpose : StandardIdentityBaseAppEntity<long>, IBaseAppEntity | ||
{ | ||
#region Properties | ||
[NotMapped] | ||
public override long Internal_Id { get => this.PropPropPurposeId; set => this.PropPropPurposeId = value; } | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace Pims.Dal.Entities | ||
{ | ||
/// <summary> | ||
/// PimsPropertyPurposeType class, provides an entity for the datamodel to manage a list of property management purposes. | ||
/// </summary> | ||
public partial class PimsPropertyPurposeType : ITypeEntity<string> | ||
{ | ||
#region Properties | ||
|
||
/// <summary> | ||
/// get/set - Primary key to identify property management purpose type. | ||
/// </summary> | ||
[NotMapped] | ||
public string Id { get => PropertyPurposeTypeCode; set => PropertyPurposeTypeCode = value; } | ||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Create a new instance of a PimsPropertyPurposeType class. | ||
/// </summary> | ||
/// <param name="id"></param> | ||
public PimsPropertyPurposeType(string id) | ||
: this() | ||
{ | ||
Id = id; | ||
} | ||
#endregion | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
.../mapSideBar/property/tabs/propertyDetailsManagement/detail/ManagementSummaryContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useCallback, useEffect, useState } from 'react'; | ||
|
||
import { usePimsPropertyRepository } from '@/hooks/repositories/usePimsPropertyRepository'; | ||
import { Api_Property } from '@/models/api/Property'; | ||
import { Api_PropertyLease } from '@/models/api/PropertyLease'; | ||
|
||
import { IManagementSummaryViewProps } from './ManagementSummaryView'; | ||
|
||
interface IManagementSummaryContainerProps { | ||
property: Api_Property; | ||
setEditMode: (isEditing: boolean) => void; | ||
View: React.FC<IManagementSummaryViewProps>; | ||
} | ||
|
||
export const ManagementSummaryContainer: React.FunctionComponent< | ||
IManagementSummaryContainerProps | ||
> = ({ property, setEditMode, View }) => { | ||
const [propertyLeases, setPropertyLeases] = useState<Api_PropertyLease[]>([]); | ||
|
||
const { | ||
getPropertyLeases: { execute: getPropertyLeases, loading }, | ||
} = usePimsPropertyRepository(); | ||
|
||
const fetchPropertyLeases = useCallback(async () => { | ||
if (!property.id) { | ||
return; | ||
} | ||
const propertyLeasesResponse = await getPropertyLeases(property.id); | ||
if (propertyLeasesResponse) { | ||
setPropertyLeases(propertyLeasesResponse); | ||
} | ||
}, [getPropertyLeases, property]); | ||
|
||
useEffect(() => { | ||
fetchPropertyLeases(); | ||
}, [fetchPropertyLeases]); | ||
|
||
return ( | ||
<View | ||
isLoading={loading} | ||
property={property} | ||
propertyLeases={propertyLeases} | ||
setEditMode={setEditMode} | ||
/> | ||
); | ||
}; |
36 changes: 36 additions & 0 deletions
36
...tures/mapSideBar/property/tabs/propertyDetailsManagement/detail/ManagementSummaryView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { EditButton } from '@/components/common/EditButton'; | ||
import { Section } from '@/components/common/Section/Section'; | ||
import { StyledEditWrapper } from '@/components/common/Section/SectionStyles'; | ||
import { Claims } from '@/constants/index'; | ||
import useKeycloakWrapper from '@/hooks/useKeycloakWrapper'; | ||
import { Api_Property } from '@/models/api/Property'; | ||
import { Api_PropertyLease } from '@/models/api/PropertyLease'; | ||
|
||
export interface IManagementSummaryViewProps { | ||
isLoading: boolean; | ||
property: Api_Property; | ||
propertyLeases: Api_PropertyLease[]; | ||
setEditMode: (isEditing: boolean) => void; | ||
} | ||
|
||
export const ManagementSummaryView: React.FunctionComponent<IManagementSummaryViewProps> = ({ | ||
isLoading, | ||
property, | ||
propertyLeases, | ||
setEditMode, | ||
}) => { | ||
const { hasClaim } = useKeycloakWrapper(); | ||
return ( | ||
<Section header="Summary"> | ||
<StyledEditWrapper className="mr-3 my-1"> | ||
{/** TODO: Use MANAGEMENT CLAIMS when available */} | ||
{setEditMode !== undefined && hasClaim(Claims.PROPERTY_EDIT) && ( | ||
<EditButton | ||
title="Edit property management information" | ||
onClick={() => setEditMode(true)} | ||
/> | ||
)} | ||
</StyledEditWrapper> | ||
</Section> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.