Skip to content

Commit

Permalink
PR Home page fixes
Browse files Browse the repository at this point in the history
* Actually fetch subtasks for home page
* Load card and board so we can redirect properly
* Update home-page from non-Applications to Planning Referrals
* Remove max height on card dialog content so it scrolls nicely
  • Loading branch information
Daniel Haselhan committed Mar 19, 2024
1 parent 0ae77be commit c862444
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h4>Cards Assigned to Me: {{ totalFiles }}</h4>
</section>

<section *ngIf="planningReferrals.length">
<div class="subheading2">Non-Applications</div>
<div class="subheading2">Planning Referrals</div>
<app-assigned-table [assignedFiles]="planningReferrals"></app-assigned-table>
</section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@
[type]="RECON_TYPE_LABEL"
>
</app-application-type-pill>
<app-application-type-pill
[useShortLabel]="true"
*ngIf="element.parentType === 'planning-review'"
[type]="PLANNING_TYPE_LABEL"
>
</app-application-type-pill>
<app-application-type-pill
[useShortLabel]="true"
*ngIf="element.parentType === 'notification'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class SubtaskTableComponent {
@Input() users: AssigneeDto[] = [];

MODIFICATION_TYPE_LABEL = MODIFICATION_TYPE_LABEL;
PLANNING_TYPE_LABEL = PLANNING_TYPE_LABEL;
RECON_TYPE_LABEL = RECON_TYPE_LABEL;
NOTIFICATION_LABEL = NOTIFICATION_LABEL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<h4>{{ subtaskLabel }} Subtasks: {{ totalSubtaskCount }}</h4>

<section *ngIf="noticeOfIntentSubtasks.length && showNoi">
<div class="subheading2">Notice of Intent</div>
<div class="subheading2">Notices of Intent</div>
<app-subtask-table [subtasks]="noticeOfIntentSubtasks" [users]="users"></app-subtask-table>
</section>
<section *ngIf="applicationSubtasks.length && showAppAndNonApp">
<div class="subheading2">Applications</div>
<app-subtask-table [subtasks]="applicationSubtasks" [users]="users"></app-subtask-table>
</section>
<section *ngIf="planningReviewSubtasks.length && showAppAndNonApp">
<div class="subheading2">Non-Applications</div>
<div class="subheading2">Planning Reviews</div>
<app-subtask-table [subtasks]="planningReviewSubtasks" [users]="users"></app-subtask-table>
</section>
<section *ngIf="notificationSubtasks.length">
Expand Down
16 changes: 8 additions & 8 deletions alcs-frontend/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ $alcs-warn: mat.define-palette($mat-custom-warn);
// Create the theme object. A theme consists of configurations for individual
// theming systems such as "color" or "typography".
$alcs-theme: mat.define-light-theme(
(
color: (
primary: $alcs-primary,
accent: $alcs-accent,
warn: $alcs-warn,
),
)
(
color: (
primary: $alcs-primary,
accent: $alcs-accent,
warn: $alcs-warn,
),
)
);

// Include theme styles for core and each component used in your app.
Expand Down Expand Up @@ -176,7 +176,7 @@ body {
mat-dialog-content,
div[mat-dialog-content] {
flex-grow: 1;
max-height: 80vh;
max-height: unset;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AutoMap } from 'automapper-classes';
import { IsOptional, IsUUID } from 'class-validator';
import { ApplicationTypeDto } from '../../code/application-code/application-type/application-type.dto';
import { AssigneeDto } from '../../../user/user.dto';
import { PlanningReviewTypeDto } from '../../planning-review/planning-review.dto';
import { CardDto } from '../card.dto';

export enum PARENT_TYPE {
Expand Down Expand Up @@ -58,7 +59,7 @@ export class CardSubtaskDto {
export class HomepageSubtaskDTO extends CardSubtaskDto {
card: CardDto;
title: string;
appType?: ApplicationTypeDto;
appType?: PlanningReviewTypeDto;
parentType: PARENT_TYPE;
activeDays?: number;
paused: boolean;
Expand Down
13 changes: 13 additions & 0 deletions services/apps/alcs/src/alcs/home/home.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { NoticeOfIntent } from '../notice-of-intent/notice-of-intent.entity';
import { NoticeOfIntentService } from '../notice-of-intent/notice-of-intent.service';
import { Notification } from '../notification/notification.entity';
import { NotificationService } from '../notification/notification.service';
import { PlanningReferral } from '../planning-review/planning-referral/planning-referral.entity';
import { PlanningReferralService } from '../planning-review/planning-referral/planning-referral.service';
import { HomeController } from './home.controller';

describe('HomeController', () => {
Expand All @@ -42,6 +44,7 @@ describe('HomeController', () => {
let mockNoticeOfIntentService: DeepMocked<NoticeOfIntentService>;
let mockNoticeOfIntentModificationService: DeepMocked<NoticeOfIntentModificationService>;
let mockNotificationService: DeepMocked<NotificationService>;
let mockPlanningReferralService: DeepMocked<PlanningReferralService>;

beforeEach(async () => {
mockApplicationService = createMock();
Expand All @@ -52,6 +55,7 @@ describe('HomeController', () => {
mockNoticeOfIntentService = createMock();
mockNoticeOfIntentModificationService = createMock();
mockNotificationService = createMock();
mockPlanningReferralService = createMock();

const module: TestingModule = await Test.createTestingModule({
imports: [
Expand Down Expand Up @@ -101,6 +105,10 @@ describe('HomeController', () => {
provide: NotificationService,
useValue: mockNotificationService,
},
{
provide: PlanningReferralService,
useValue: mockPlanningReferralService,
},
ApplicationProfile,
ApplicationSubtaskProfile,
UserProfile,
Expand All @@ -124,6 +132,8 @@ describe('HomeController', () => {
mockNoticeOfIntentModificationService.mapToDtos.mockResolvedValue([]);
mockNotificationService.getBy.mockResolvedValue([]);
mockNotificationService.mapToDtos.mockResolvedValue([]);
mockPlanningReferralService.getBy.mockResolvedValue([]);
mockPlanningReferralService.mapToDtos.mockResolvedValue([]);

mockNoticeOfIntentService.getTimes.mockResolvedValue(new Map());
mockApplicationTimeTrackingService.fetchActiveTimes.mockResolvedValue(
Expand All @@ -149,6 +159,9 @@ describe('HomeController', () => {
mockNotificationService.getWithIncompleteSubtaskByType.mockResolvedValue(
[],
);
mockPlanningReferralService.getWithIncompleteSubtaskByType.mockResolvedValue(
[],
);
});

it('should be defined', () => {
Expand Down
64 changes: 34 additions & 30 deletions services/apps/alcs/src/alcs/home/home.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ import { NoticeOfIntentService } from '../notice-of-intent/notice-of-intent.serv
import { NotificationDto } from '../notification/notification.dto';
import { Notification } from '../notification/notification.entity';
import { NotificationService } from '../notification/notification.service';
import { PlanningReviewDto } from '../planning-review/planning-review.dto';
import { PlanningReview } from '../planning-review/planning-review.entity';
import { PlanningReferral } from '../planning-review/planning-referral/planning-referral.entity';
import { PlanningReferralService } from '../planning-review/planning-referral/planning-referral.service';
import { PlanningReferralDto } from '../planning-review/planning-review.dto';

const HIDDEN_CARD_STATUSES = [
CARD_STATUS.CANCELLED,
Expand All @@ -57,6 +58,7 @@ export class HomeController {
private noticeOfIntentService: NoticeOfIntentService,
private noticeOfIntentModificationService: NoticeOfIntentModificationService,
private notificationService: NotificationService,
private planningReferralService: PlanningReferralService,
) {}

@Get('/assigned')
Expand All @@ -66,7 +68,7 @@ export class HomeController {
noticeOfIntentModifications: NoticeOfIntentModificationDto[];
applications: ApplicationDto[];
reconsiderations: ApplicationReconsiderationDto[];
planningReferrals: PlanningReviewDto[];
planningReferrals: PlanningReferralDto[];
modifications: ApplicationModificationDto[];
notifications: NotificationDto[];
}> {
Expand All @@ -86,8 +88,8 @@ export class HomeController {
const reconsiderations =
await this.reconsiderationService.getBy(assignedFindOptions);

// const planningReviews =
// await this.planningReviewService.getBy(assignedFindOptions);
const planningReviews =
await this.planningReferralService.getBy(assignedFindOptions);

const modifications =
await this.modificationService.getBy(assignedFindOptions);
Expand All @@ -111,7 +113,8 @@ export class HomeController {
applications: await this.applicationService.mapToDtos(applications),
reconsiderations:
await this.reconsiderationService.mapToDtos(reconsiderations),
planningReferrals: [],
planningReferrals:
await this.planningReferralService.mapToDtos(planningReviews),
modifications: await this.modificationService.mapToDtos(modifications),
notifications: await this.notificationService.mapToDtos(notifications),
};
Expand Down Expand Up @@ -145,13 +148,13 @@ export class HomeController {
);
const reconSubtasks = this.mapReconToDto(reconsiderationWithSubtasks);

// const planningReviewsWithSubtasks =
// await this.planningReviewService.getWithIncompleteSubtaskByType(
// subtaskType,
// );
// const planningReviewSubtasks = this.mapPlanningReviewsToDtos(
// planningReviewsWithSubtasks,
// );
const planningReferralsWithSubtasks =
await this.planningReferralService.getWithIncompleteSubtaskByType(
subtaskType,
);
const planningReferralSubtasks = this.mapPlanningReferralsToDtos(
planningReferralsWithSubtasks,
);

const modificationsWithSubtasks =
await this.modificationService.getWithIncompleteSubtaskByType(
Expand Down Expand Up @@ -191,6 +194,7 @@ export class HomeController {
...reconSubtasks,
...modificationSubtasks,
...noiModificationsSubtasks,
...planningReferralSubtasks,
...notificationSubtasks,
];
}
Expand Down Expand Up @@ -251,24 +255,24 @@ export class HomeController {
return result;
}

private mapPlanningReviewsToDtos(planingReviews: PlanningReview[]) {
private mapPlanningReferralsToDtos(planningReferrals: PlanningReferral[]) {
const result: HomepageSubtaskDTO[] = [];
// TODO
// for (const planningReview of planingReviews) {
// for (const subtask of planningReview.card.subtasks) {
// result.push({
// type: subtask.type,
// createdAt: subtask.createdAt.getTime(),
// assignee: this.mapper.map(subtask.assignee, User, AssigneeDto),
// uuid: subtask.uuid,
// card: this.mapper.map(planningReview.card, Card, CardDto),
// completedAt: subtask.completedAt?.getTime(),
// paused: false,
// title: `${planningReview.fileNumber} (${planningReview.type})`,
// parentType: PARENT_TYPE.PLANNING_REVIEW,
// });
// }
// }
for (const planningReferral of planningReferrals) {
for (const subtask of planningReferral.card.subtasks) {
result.push({
type: subtask.type,
createdAt: subtask.createdAt.getTime(),
assignee: this.mapper.map(subtask.assignee, User, AssigneeDto),
uuid: subtask.uuid,
card: this.mapper.map(planningReferral.card, Card, CardDto),
completedAt: subtask.completedAt?.getTime(),
paused: false,
title: `${planningReferral.planningReview.fileNumber} (${planningReferral.planningReview.documentName})`,
parentType: PARENT_TYPE.PLANNING_REVIEW,
appType: planningReferral.planningReview.type,
});
}
}
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Mapper } from 'automapper-core';
import { InjectMapper } from 'automapper-nestjs';
import { FindOptionsRelations, IsNull, Not, Repository } from 'typeorm';
import {
FindOptions,
FindOptionsRelations,
FindOptionsWhere,
IsNull,
Not,
Repository,
} from 'typeorm';
import { formatIncomingDate } from '../../../utils/incoming-date.formatter';
import { filterUndefined } from '../../../utils/undefined';
import { Board } from '../../board/board.entity';
import { CARD_SUBTASK_TYPE } from '../../card/card-subtask/card-subtask.dto';
import { CARD_TYPE } from '../../card/card-type/card-type.entity';
import { CardService } from '../../card/card.service';
import {
Expand Down Expand Up @@ -33,6 +41,7 @@ export class PlanningReferralService {
type: true,
status: true,
board: true,
assignee: true,
},
planningReview: {
localGovernment: true,
Expand Down Expand Up @@ -150,4 +159,38 @@ export class PlanningReferralService {

await this.referralRepository.softRemove(existingReferral);
}

async getBy(assignedFindOptions: FindOptionsWhere<PlanningReferral>) {
return this.referralRepository.find({
where: assignedFindOptions,
relations: this.DEFAULT_RELATIONS,
});
}

async getWithIncompleteSubtaskByType(subtaskType: CARD_SUBTASK_TYPE) {
return this.referralRepository.find({
where: {
card: {
subtasks: {
completedAt: IsNull(),
type: {
code: subtaskType,
},
},
},
},
relations: {
planningReview: {
type: true,
localGovernment: true,
},
card: {
status: true,
board: true,
type: true,
subtasks: { type: true, assignee: true },
},
},
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ export class PlanningReviewService {
},
relations: {
...this.DEFAULT_RELATIONS,
referrals: true,
referrals: {
card: {
board: true,
type: true,
},
},
},
order: {
referrals: {
Expand Down

0 comments on commit c862444

Please sign in to comment.