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

feat: Implementing SR checkbox functionality #239

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
6 changes: 6 additions & 0 deletions backend/src/app/dto/changeAuditEntity.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export class ChangeAuditEntityDTO {

@Field()
srAction: string;

@Field(() => Boolean, { nullable: true })
srValue: boolean;
}

@ObjectType()
Expand All @@ -18,4 +21,7 @@ export class ChangeAuditObjectTypeDTO {

@Field()
srAction: string;

@Field()
srValue: string;
midhun-aot marked this conversation as resolved.
Show resolved Hide resolved
}
53 changes: 50 additions & 3 deletions backend/src/app/dto/landHistory.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { ResponseDto } from './response/response.dto';
import { LandHistories } from '../entities/landHistories.entity';
import { ChangeAuditObjectTypeDTO } from './changeAuditEntity.dto';
import { LandUseCd } from '../entities/landUseCd.entity';
import { Sites } from '../entities/sites.entity';

@ObjectType()
export class LandHistoryResponse extends ResponseDto {
@Field(() => [LandHistories], { defaultValue: [] })
data: LandHistories[];
@Field(() => [LandHistoriesDTO], { defaultValue: [] })
data: LandHistoriesDTO[];
}

@ObjectType()
class LandHistoriesDTO extends ChangeAuditObjectTypeDTO {
@Field()
siteId: string;

@Field()
guid: string;

@Field()
lutCode: string;

@Field({ nullable: true })
note: string | null;

@Field()
whoCreated: string;

@Field({ nullable: true })
whoUpdated: string | null;

@Field()
whenCreated: Date;

@Field({ nullable: true })
whenUpdated: Date | null;

@Field()
rwmFlag: number;

@Field()
rwmNoteFlag: number;

@Field({ nullable: true })
siteProfile: string | null;

@Field({ nullable: true })
profileDateReceived: Date | null;

@Field(() => LandUseCd)
landUse: LandUseCd;

@Field(() => Sites)
site: Sites;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe('AssociatedSiteResolver', () => {
note: 'Note 1',
srAction: 'pending',
userAction: 'pending',
srValue: 'true'
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('DocumentResolver', () => {
filePath: '',
srAction: 'pending',
userAction: 'pending',
srValue: 'false'
},
];
const expectedResult: DocumentResponse = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('LandHistoryResolver', () => {

describe('getLandHistoriesForSite', () => {
it('should return land histories when found', async () => {
const mockLandHistories = [new LandHistories()];
const mockLandHistories = [{...new LandHistories(), srValue: 'true'}];

const showPending = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('NotationResolver', () => {
requirementReceivedDate: new Date('2024-07-10'),
srAction: 'pending',
userAction: 'pending',
srValue: 'false',
notationParticipant: [
{
eventParticId: 'GUID001',
Expand All @@ -84,6 +85,7 @@ describe('NotationResolver', () => {
srAction: 'pending',
userAction: 'pending',
eventId: '',
srValue: 'false',
},
{
eventParticId: 'GUID002',
Expand All @@ -93,6 +95,7 @@ describe('NotationResolver', () => {
srAction: 'pending',
userAction: 'pending',
eventId: '',
srValue: 'false',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('ParticipantResolver', () => {
siteId: '1',
srAction: 'pending',
userAction: 'pending',
srValue: 'false',
},
];
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export class AssociatedSiteService {
siteIdAssociatedWith: assocs.siteIdAssociatedWith,
effectiveDate: assocs.effectiveDate.toISOString(),
note: assocs.note ? assocs.note.trim() : null, // Ensure note is trimmed
srAction:
assocs.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
srValue: assocs.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
srAction: assocs.srAction,
}));

// Convert the transformed objects into DTOs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('LandHistoryService', () => {
srAction: '',
userAction: '',
apiAction: '',
srValue: true,
},
];

Expand Down Expand Up @@ -139,6 +140,7 @@ describe('LandHistoryService', () => {
srAction: '',
userAction: '',
apiAction: '',
srValue: true,
},
];

Expand Down Expand Up @@ -172,6 +174,7 @@ describe('LandHistoryService', () => {
srAction: '',
userAction: '',
apiAction: '',
srValue: true,
},
];

Expand Down
3 changes: 3 additions & 0 deletions backend/src/app/services/landHistory/landHistory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LoggerService } from '../../logger/logger.service';

import { UserActionEnum } from '../../common/userActionEnum';
import { HttpException, HttpStatus } from '@nestjs/common';
import { SRApprovalStatusEnum } from '../../common/srApprovalStatusEnum';

export class LandHistoryService {
constructor(
Expand Down Expand Up @@ -67,6 +68,8 @@ export class LandHistoryService {
const result = (await query.getMany()).map((landHistory) => ({
...landHistory,
guid: v4(),
srValue:
landHistory.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
midhun-aot marked this conversation as resolved.
Show resolved Hide resolved
}));
this.sitesLogger.log('LandHistoryService.getLandHistoriesForSite() end');
this.sitesLogger.debug(
Expand Down
3 changes: 2 additions & 1 deletion backend/src/app/services/notation/notation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ export class NotationService {
psnorgId: partic.psnorgId,
displayName: partic.psnorg.displayName,
userAction: partic.userAction ?? UserActionEnum.DEFAULT,
srAction:
srValue:
partic.srAction === SRApprovalStatusEnum.PUBLIC ? true : false,
srAction: partic.srAction,
})),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ describe('ParcelDescriptionsService', () => {
srAction: 'approved',
userAction: 'approved',
apiAction: 'updated',
srValue: false
};
parcelDescriptionToAdd = {
id: idForAddedParcelDescription,
Expand All @@ -562,6 +563,7 @@ describe('ParcelDescriptionsService', () => {
srAction: 'pending',
userAction: 'pending',
apiAction: 'added',
srValue: false
};
parcelDescriptionToDelete = {
id: idForDeletedParcelDescription,
Expand All @@ -572,6 +574,7 @@ describe('ParcelDescriptionsService', () => {
srAction: 'pending',
userAction: 'pending',
apiAction: 'deleted',
srValue: false
};

siteId = '100';
Expand Down Expand Up @@ -781,6 +784,7 @@ describe('ParcelDescriptionsService', () => {
srAction: 'pending',
userAction: 'pending',
apiAction: 'added',
srValue: false
},
];
userInfo = { givenName: 'test' };
Expand Down Expand Up @@ -1012,6 +1016,7 @@ describe('ParcelDescriptionsService', () => {
srAction: 'approved',
userAction: 'approved',
apiAction: 'updated',
srValue: true
},
];
userInfo = { givenName: 'test' };
Expand Down Expand Up @@ -1307,6 +1312,7 @@ describe('ParcelDescriptionsService', () => {
srAction: 'approved',
userAction: 'approved',
apiAction: 'deleted',
srValue: true
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ export class ParticipantService {
displayName: item.psnorg?.displayName?.trim() || '', // Safely access displayName with default value
prCode: role.prCode.trim(),
description: role.prCode2?.description?.trim() || '', // Safely access description with default value
srAction:
srValue:
item.srAction === SRApprovalStatusEnum.PUBLIC ||
role.srAction === SRApprovalStatusEnum.PUBLIC
? true
: false,
srAction: role.srAction,
})),
);

Expand Down
1 change: 1 addition & 0 deletions backend/src/app/services/site/site.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ describe('SiteService', () => {
apiAction: 'pending',
srAction: 'pending',
notationParticipant: null,
srValue: true
},
],
};
Expand Down
14 changes: 11 additions & 3 deletions backend/src/app/services/site/site.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export class SiteService {
}),
);

query.andWhere('sites.srStatus != :srStatus', { srStatus: 'private' });

if (id) {
query.andWhere('sites.id = :id', { id: id });
}
Expand Down Expand Up @@ -769,6 +771,7 @@ export class SiteService {
apiAction,
particRoleId,
srAction,
srValue,
...siteParticsData
} = participant;

Expand Down Expand Up @@ -962,8 +965,13 @@ export class SiteService {
participants: any[],
) => {
const participantPromises = participants.map(async (partic) => {
const { eventParticId, displayName, apiAction, ...particData } =
partic;
const {
eventParticId,
displayName,
apiAction,
srValue,
...particData
} = partic;
switch (apiAction) {
case UserActionEnum.ADDED:
return {
Expand Down Expand Up @@ -1150,7 +1158,7 @@ export class SiteService {
const deleteSiteAssociates: { id: string }[] = [];

const siteAssociatePromises = siteAccociated.map(async (asscos) => {
const { id, apiAction, ...siteAssocsData } = asscos;
const { id, apiAction, srValue, ...siteAssocsData } = asscos;
const siteAssoc = { ...new SiteAssocs(), ...siteAssocsData };
switch (apiAction) {
case UserActionEnum.ADDED:
Expand Down
2 changes: 1 addition & 1 deletion frontend/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
schema: 'http://host.docker.internal:4007/graphql',
schema: 'http://localhost:4007/graphql',
documents: ['src/**/*.graphql'],
generates: {
'./src/graphql/generated.ts': {
Expand Down
Loading
Loading