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

UI Changes for launch button #447

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions backend/webapi/Data/PidpDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Pidp.Data;
using AppAny.Quartz.EntityFrameworkCore.Migrations;
using AppAny.Quartz.EntityFrameworkCore.Migrations.PostgreSQL;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using NodaTime;
using Pidp.Models;
using Pidp.Models.Lookups;
Expand All @@ -26,9 +27,9 @@ public class PidpDbContext : DbContext
public DbSet<Facility> Facilities { get; set; } = default!;
public DbSet<FutureUserChangeEvent> FutureUserChangeEvents { get; set; } = default!;

public DbSet<Models.HcimAccountTransfer> HcimAccountTransfers { get; set; } = default!;
public DbSet<Models.HcimEnrolment> HcimEnrolments { get; set; } = default!;
public DbSet<Models.DigitalEvidence> DigitalEvidences { get; set; } = default!;
public DbSet<HcimAccountTransfer> HcimAccountTransfers { get; set; } = default!;
public DbSet<HcimEnrolment> HcimEnrolments { get; set; } = default!;
public DbSet<DigitalEvidence> DigitalEvidences { get; set; } = default!;
public DbSet<DigitalEvidenceDisclosure> DigitalEvidenceDisclosures { get; set; } = default!;
public DbSet<Models.DigitalEvidenceDefence> DigitalEvidenceDefences { get; set; } = default!;

Expand Down Expand Up @@ -69,10 +70,18 @@ public override async Task<int> SaveChangesAsync(CancellationToken cancellationT
}



protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<DigitalEvidence>().Property(x => x.AssignedRegions).
HasConversion(
v => JsonConvert.SerializeObject(v, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }),
v => JsonConvert.DeserializeObject<List<AssignedRegion>>(v, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })

);

modelBuilder.Entity<IdempotentConsumer>()
.ToTable("IdempotentConsumers")
.HasKey(x => new { x.MessageId, x.Consumer });
Expand Down
13 changes: 10 additions & 3 deletions workspace/apps/pidp/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { NgModule } from '@angular/core';
import { NgModule, Injector } from '@angular/core';

import { AppRoutingModule } from '@app/app-routing.module';
import { AppComponent } from '@app/app.component';

import { CoreModule } from '@core/core.module';
export let AppInjector: Injector;

@NgModule({
declarations: [AppComponent],
imports: [AppRoutingModule, CoreModule],
bootstrap: [AppComponent],
bootstrap: [AppComponent]

})
export class AppModule {}
export class AppModule {
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
constructor(private injector: Injector) {
AppInjector = this.injector;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export class BasePortalSection {
public GetOrder(profileStatus: Section): number {
return profileStatus.order;
}

}
2 changes: 2 additions & 0 deletions workspace/apps/pidp/src/app/features/portal/portal.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ <h2>Hello {{ firstName | titlecase }},</h2>
</ui-page-section-subheader>

<ui-card-summary *ngFor="let section of (state$ | async)?.access" [heading]="section.heading"
[launchString]="section.launch?.label" [launchURL]="section.launch?.url"
[launchHidden]="section.launch?.hidden" [launchDisabled]="section.launch?.disabled"
[statusType]="section.statusType" [status]="section.status" [actionLabel]="section.action.label"
[order]="section.order" [actionDisabled]="section.action.disabled" (action)="onCardAction(section)">
<ng-container uiCardSummaryHint>{{ section.hint }}</ng-container>
Expand Down
2 changes: 1 addition & 1 deletion workspace/apps/pidp/src/app/features/portal/portal.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { PortalState } from './state/portal-state.builder';
@Component({
selector: 'app-portal',
templateUrl: './portal.page.html',
styleUrls: ['./portal.page.scss'],
styleUrls: ['./portal.page.scss']
})
export class PortalPage implements OnInit {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ import { ProfileStatus } from '../../models/profile-status.model';
import { PortalSectionAction } from '../portal-section-action.model';
import { PortalSectionKey } from '../portal-section-key.type';
import { IPortalSection } from '../portal-section.model';
import { PortalSectionLaunchAction } from '../portal-section-launch-action.model';
import { AppInjector } from '@app/app.module';
import { APP_CONFIG } from '@app/app.config';

export class DigitalEvidencePortalSection
extends BasePortalSection
implements IPortalSection {

public readonly key: PortalSectionKey;
public heading: string;
public description: string;
public order: number;


public constructor(
private profileStatus: ProfileStatus,
private router: Router,
Expand All @@ -32,8 +37,6 @@ export class DigitalEvidencePortalSection
this.heading = 'Digital Evidence and Disclosure Management System (DEMS)';
this.description = this.getDescription();
this.order = this.GetOrder(this.profileStatus.status.digitalEvidence);


}

public get hint(): string {
Expand Down Expand Up @@ -77,6 +80,21 @@ export class DigitalEvidencePortalSection
};
}

public get launch(): PortalSectionLaunchAction {

const config = AppInjector.get(APP_CONFIG);

const label = this.getOrgName() === "Justice Sector" ? "Launch BCPS DEMS" : this.getOrgName() === "BC Law Society" ? "Launch Disclosure Portal" : this.isSubAgency() ? "Launch Agency Upload Portal" : undefined;
const url = this.getOrgName() === "BC Law Society" ? config.urls.bcLawDiscPortalUrl : this.getOrgName() === "Justice Sector" ? config.urls.bcpsDemsPortalUrl : config.urls.subAgencyAufPortalUrl;
return {
hidden: false,
label: label,
newWindow: true,
url: url,
disabled: this.getStatusCode() !== StatusCode.COMPLETED
}
}

public getDescription(): string {
return this.getStatusCode() === StatusCode.COMPLETED
? 'Your enrolment is complete. You can view the terms of enrolment by clicking the View button'
Expand Down Expand Up @@ -147,4 +165,13 @@ export class DigitalEvidencePortalSection
private getStatusCode(): StatusCode {
return this.profileStatus.status.digitalEvidence.statusCode;
}

private getOrgName(): string {
return this.profileStatus.status.organizationDetails.orgName;
}

private isSubAgency(): boolean {
return this.profileStatus.status.organizationDetails.submittingAgency;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @description
* Properties of a portal section launch action.
*/
export interface PortalSectionLaunchAction {
/**
* Label of the action, such as Update,
* View, or Request.
*/
label?: string;
/**
* @description
* Route the action will navigate to
* when invoked.
*/
url?: string;

newWindow: boolean;
/**
* @description
* Whether the action is enable or disabled
* typically based on state.
*/
disabled: boolean;

/**
* @description
* Whether the action is hidden
* typically based on state.
*/
hidden?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AlertType } from '@bcgov/shared/ui';
import { PortalSectionAction } from './portal-section-action.model';
import { PortalSectionKey } from './portal-section-key.type';
import { PortalSectionProperty } from './portal-section-property.model';
import { PortalSectionLaunchAction } from './portal-section-launch-action.model';

/**
* @description
Expand Down Expand Up @@ -33,6 +34,13 @@ export interface IPortalSection {
*/
description: string;

/**
* @description
* A url for launching an app once a request is complete
*/
launch?: PortalSectionLaunchAction;


/**
* Order in which processing is required
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import { CollegeCertificationPortalSection } from './profile/college-certificati
import { DemographicsPortalSection } from './profile/demographics-portal-section.class';
import { UserAccessAgreementPortalSection } from './profile/user-access-agreement-portal-section.class';
import { ComplianceTrainingPortalSection } from './training/compliance-training-portal-section.class';
import { AuthorizedUserService } from '@app/features/auth/services/authorized-user.service';
import { Inject } from '@angular/core';
import { APP_CONFIG, AppConfig } from '@app/app.config';

/**
* @description
Expand Down
3 changes: 3 additions & 0 deletions workspace/apps/pidp/src/environments/environment.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ export interface AppEnvironment extends EnvironmentConfig {
bcscMobileSetup: string;
specialAuthority: string;
doctorsTechnologyOffice: string;
bcLawDiscPortalUrl: string;
subAgencyAufPortalUrl: string;
bcpsDemsPortalUrl: string;
};
}
5 changes: 4 additions & 1 deletion workspace/apps/pidp/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { AppEnvironment, EnvironmentName } from './environment.model';
export const environment: AppEnvironment = {
production: true,
apiEndpoint: 'http://localhost:5050',
configEndpoint: 'http://localhost:8080',
configEndpoint: 'http://localhost:5259',
authEndpoint: 'https://dev.common-sso.justice.gov.bc.ca',
authRealm: 'BCPS',
caseManagement: {
Expand Down Expand Up @@ -58,6 +58,9 @@ export const environment: AppEnvironment = {
bcscMobileSetup: 'https://id.gov.bc.ca/account',
specialAuthority: specialAuthorityUrl,
doctorsTechnologyOffice: doctorsTechnologyOfficeUrl,
bcLawDiscPortalUrl: 'https://dev.disclosure.bcprosecution.gov.bc.ca/',
bcpsDemsPortalUrl: 'https://dems.dev.jag.gov.bc.ca/',
subAgencyAufPortalUrl: 'https://auf.dev.justice.gov.bc.ca/'
},
keycloakConfig: {
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@
<ng-container uiCardContent>
<ng-content select="[uiCardSummaryContent]"></ng-content>
</ng-container>
<ng-container uiCardActions *ngIf="hasActions()">
<span>
<button *ngIf="actionLabel" mat-stroked-button type="button" color="primary" [disabled]="actionDisabled"
(click)="onAction()">
{{ actionLabel }}
</button>
</span>

<ng-container uiCardActions>
<div class="d-flex">
<div class="col-md-6 col-sm-12" *ngIf="launchString">
<button mat-stroked-button type="button" color="primary" [disabled]="launchDisabled" *ngIf="!launchHidden"
(click)="onLaunch()">
{{ launchString }}&nbsp;<mat-icon>launch_outline</mat-icon>
</button>
</div>
<div [ngClass]="launchString ? 'col-md-6' : 'col-md-12'" class="text-md-end" *ngIf="hasActions()">
<button *ngIf="actionLabel" mat-stroked-button type="button" color="primary" [disabled]="actionDisabled"
(click)="onAction()">
{{ actionLabel }}
</button>
</div>
</div>
</ng-container>
</ui-card>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ export class CardSummaryComponent {
@Input() public icon?: string;
@Input() public heading!: string;
@Input() public order?: number;

@Input() public statusType?: AlertType;
@Input() public child?: boolean;

@Input() public status?: string;
@Input() public actionLabel?: string;
@Input() public actionDisabled?: boolean;
@Input() public panelHidden?: boolean;
@Input() public launchURL?: string;
@Input() public launchString?: string;
@Input() public launchDisabled?: boolean;
@Input() public launchHidden?: boolean;

@Output() public action: EventEmitter<void>;

Expand All @@ -37,11 +39,20 @@ export class CardSummaryComponent {
return (this.actionLabel && this.actionLabel?.length > 0) || false;
}

public hasLaunchAction(): boolean {
return (this.launchURL && this.launchURL?.length > 0) || false;

}

public getStatusTypeClass(): string {
const isChild = (this.order && this.order % 1 !== 0) || 0;
return isChild ? this.statusType + ' indent' : '' + this.statusType;
}

public onLaunch(): void {
window.open(this.launchURL, "_blank");
}

public onAction(): void {
this.action.emit();
}
Expand Down
Loading