-
Notifications
You must be signed in to change notification settings - Fork 24
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-6865 property management models #3488
Changes from all commits
2818ae2
e7bb597
d5e034d
e5bd7de
d6ade48
7b3cc4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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>(); | ||
} | ||
} | ||
} |
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 | ||
} | ||
} |
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 | ||
} | ||
} |
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 | ||
} | ||
} |
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} | ||
/> | ||
); | ||
}; |
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 */} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asanchezr the management claims are available, can you add those please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are available now - not when I sent the PR originally. Did you add them to the frontend enum as well or do I need to do that? |
||
{setEditMode !== undefined && hasClaim(Claims.PROPERTY_EDIT) && ( | ||
<EditButton | ||
title="Edit property management information" | ||
onClick={() => setEditMode(true)} | ||
/> | ||
)} | ||
</StyledEditWrapper> | ||
</Section> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to confirm that this approach is appropriate given that is requires LeaseView. That means that a user that has management view will get an error unless they also have lease-view when viewing the management summary.
We may need to return just the boolean field against the property calculated on the backend with no lease restrictions instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asanchezr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, as said in the PR description this is the basic model stuff. I can change that in my next PR