Skip to content

Commit

Permalink
Merge pull request #719 from bcgov/olex
Browse files Browse the repository at this point in the history
DSS-365: Platform Details. DSS-884: Edit Platform
  • Loading branch information
larsenle authored Oct 18, 2024
2 parents e3546f4 + 1f7798e commit 97d984d
Show file tree
Hide file tree
Showing 21 changed files with 1,194 additions and 62 deletions.
11 changes: 9 additions & 2 deletions frontend/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { AddNewPlatformComponent } from './features/components/platform-manageme
import { AddSubPlatformComponent } from './features/components/platform-management/add-sub-platform/add-sub-platform.component';
import { EditPlatformComponent } from './features/components/platform-management/edit-platform/edit-platform.component';
import { ViewPlatformComponent } from './features/components/platform-management/view-platform/view-platform.component';
import { EditSubPlatformComponent } from './features/components/platform-management/edit-sub-platform/edit-sub-platform.component';

export const routes: Routes = [
{
Expand Down Expand Up @@ -132,17 +133,23 @@ export const routes: Routes = [
data: { permissions: [platform_write] }
},
{
path: 'add-sub-platform',
path: 'add-sub-platform/:id',
canActivate: [approvedUserGuard, activeUserGuard, hasPermissionsGuard, areTermsAceptedGuard],
component: AddSubPlatformComponent,
data: { permissions: [platform_write] }
},
{
path: 'edit-platform',
path: 'edit-platform/:id',
canActivate: [approvedUserGuard, activeUserGuard, hasPermissionsGuard, areTermsAceptedGuard],
component: EditPlatformComponent,
data: { permissions: [platform_write] }
},
{
path: 'edit-sub-platform/:id',
canActivate: [approvedUserGuard, activeUserGuard, hasPermissionsGuard, areTermsAceptedGuard],
component: EditSubPlatformComponent,
data: { permissions: [platform_write] }
},
{
path: 'platform/:id',
canActivate: [approvedUserGuard, activeUserGuard, hasPermissionsGuard, areTermsAceptedGuard],
Expand Down
42 changes: 40 additions & 2 deletions frontend/src/app/common/models/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,40 @@ export interface Platform {
secondaryNoticeOfTakedownContactEmail: string;
secondaryTakedownRequestContactId: number;
secondaryTakedownRequestContactEmail: string;
subsidiaries: Array<Platform>;
subsidiaries: Array<SubPlatform>;
platformType: string;
}

export interface UpdatePlatform {
organizationNm: string;
updDtm: string;
isActive: boolean;
primaryNoticeOfTakedownContactEmail: string;
primaryTakedownRequestContactEmail: string;
secondaryNoticeOfTakedownContactEmail: string;
secondaryTakedownRequestContactEmail: string;
platformType: string;
}

export interface UpdateSubPlatform {
organizationNm: string;
updDtm: string;
isActive: boolean;
managingOrganizationId: number;
}

export interface SubPlatform {
id?: string;
organizationId: number;
organizationType: string;
organizationCd: string;
organizationNm: string;
updDtm: string;
isActive: boolean;
updUserGuid: string;
managingOrganizationId: number;
}

export interface PlatformCreate {
organizationCd: string;
organizationNm: string;
Expand All @@ -28,4 +58,12 @@ export interface PlatformCreate {
primaryTakedownRequestContactEmail: string;
secondaryNoticeOfTakedownContactEmail: string;
secondaryTakedownRequestContactEmail: string;
}
}

export interface SubPlatformCreate {
organizationCd: string;
organizationNm: string;
managingOrganizationId: number;
isActive: boolean;
updDtm: string;
}
26 changes: 17 additions & 9 deletions frontend/src/app/common/services/organization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DropdownOption } from '../models/dropdown-option';
import { environment } from '../../../environments/environment';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Platform } from '../models/platform';
import { Platform, SubPlatform, SubPlatformCreate, UpdatePlatform, UpdateSubPlatform } from '../models/platform';
import { PagingResponse } from '../models/paging-response';

@Injectable({
Expand Down Expand Up @@ -36,19 +36,27 @@ export class OrganizationService {
return this.httpClient.get<PagingResponse<Platform>>(url);
}

getPlatform(id: number): Observable<Platform> {
return this.httpClient.get<Platform>(`${environment.API_HOST}/organizations/platform/${id}`);
getPlatform(id: number): Observable<Platform | SubPlatform> {
return this.httpClient.get<Platform | SubPlatform>(`${environment.API_HOST}/organizations/platforms/${id}`);
}

addPlatform(platform: Platform): Observable<Platform> {
return this.httpClient.post<Platform>(`${environment.API_HOST}/organizations/platforms`, platform);
addPlatform(platform: Platform): Observable<any> {
return this.httpClient.post<any>(`${environment.API_HOST}/organizations/platforms`, platform);
}

addSubPlatform(platform: Platform, parentId: number): Observable<Platform> {
return this.httpClient.post<Platform>(`${environment.API_HOST}/organizations/platform/${parentId}`, platform);
addSubPlatform(platform: SubPlatformCreate): Observable<any> {
return this.httpClient.post<any>(`${environment.API_HOST}/organizations/platforms/subsidiaries`, platform);
}

editPlatform(platform: Platform): Observable<Platform> {
return this.httpClient.put<Platform>(`${environment.API_HOST}/organizations/platform`, platform);
editPlatform(id: number, platform: UpdatePlatform): Observable<any> {
return this.httpClient.put<any>(`${environment.API_HOST}/organizations/platforms/${id}`, platform);
}

editSubPlatform(id: number, platform: UpdateSubPlatform): Observable<any> {
return this.httpClient.put<any>(`${environment.API_HOST}/organizations/platforms/subsidiaries/${id}`, platform);
}

getPlatformTypes(): Observable<Array<DropdownOption>> {
return this.httpClient.get<Array<DropdownOption>>(`${environment.API_HOST}/organizations/platformTypeDropdown`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2>Detailed Listing Information for</h2>
<ng-template pTemplate="header">
<div class="property-info-container">
<strong class="panel-header-text">Platform Information</strong>
<p-tag class="platform-report-month">
<p-tag class="tag-blue">
<strong class="tag-text">Platform Report Month:</strong>{{listing.latestReportPeriodYm
|date:'YYYY-MM' || '-'}}
</p-tag>
Expand Down Expand Up @@ -263,7 +263,7 @@ <h2>Detailed Listing Information for</h2>
<ng-template pTemplate="header">
<div class="property-info-container">
<strong class="panel-header-text">Business Licence Information</strong>
<p-tag class="last-bl-update-date" *ngIf="blInfo?.updDtm">
<p-tag class="tag-dark-gray" *ngIf="blInfo?.updDtm">
<strong class="tag-text">BL Records Last Uploaded:</strong>{{blInfo.updDtm |date:'yyyy-MM-dd' }}
</p-tag>
</div>
Expand Down Expand Up @@ -596,4 +596,4 @@ <h2>Detailed Listing Information for</h2>
<button pButton name="cancel-dialog-btn" id="cancel-dialog-btn" class="outline-btn"
(click)="onCancelAddressChange()">Cancel</button>
</ng-template>
</p-dialog>
</p-dialog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<div class="header">
<h2>Add New Platform</h2>
<span class="sub-header">All fields are required except where stated</span>
</div>
<div class="content">
<form [formGroup]="myForm">
<div class="row">
<div class="col">
<div class="form-group-row">
<div class="form-group-row-col">
<label for="organizationNm">Platform Name</label>
</div>
<div class="form-group-row-col">
<input placeholder="Enter Value" [ngClass]="'full-width-text-field'" type="text" pInputText
formControlName="organizationNm" id="organizationNm" name="organizationNm" />
</div>
<div class="validation-errors" *ngIf="!organizationNmControl.pristine">

<small id="requiredOrganizationName" *ngIf="organizationNmControl.errors?.['required']">
Platform Name is Required
</small>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group-row">
<div class="form-group-row-col">
<label for="organizationCd">Platform Code</label>
</div>
<div class="form-group-row-col">
<input placeholder="Enter Value" [ngClass]="'full-width-text-field'" type="text" pInputText
formControlName="organizationCd" id="organizationCd" name="organizationCd" />
</div>
<div class="validation-errors" *ngIf="!organizationCdControl.pristine">

<small id="requiredOrganizationCd" *ngIf="organizationCdControl.errors?.['required']">
Platform Code is Required
</small>
</div>
</div>
</div>
</div>
</form>
</div>

<div class="actions" *ngIf="myForm">
<button pButton (click)="onSave()" [disabled]="!myForm.valid">Save</button>
<button pButton class="p-button-transparent" (click)="onCancel()">Cancel</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
:host {
width: 100%;
height: auto;
background-color: white;
overflow: auto;
display: flex;
flex-direction: column;
justify-content: start;
gap: 24px;
padding: 18px;
padding-top: 0;

.header {
width: 100%;

h2 {
margin-bottom: 8px;
}
}

.content {
width: 100%;

form {
width: 100%;
display: flex;
flex-direction: column;
gap: 12px;
}

.row {
display: flex;
width: 100%;
gap: 18px;

.col {
width: 480px;
}

.form-group-row {
.form-group-row-col {
&.radios {
display: flex;
padding-top: 12px;
gap: 24px;
}
}

.validation-errors {
small {
color: red;
}
}
}
}
}

.actions {
display: flex;
gap: 8px;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,85 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { OrganizationService } from '../../../../common/services/organization.service';
import { GlobalLoaderService } from '../../../../common/services/global-loader.service';
import { ErrorHandlingService } from '../../../../common/services/error-handling.service';
import { DropdownOption } from '../../../../common/models/dropdown-option';
import { RadioButtonModule } from 'primeng/radiobutton';
import { ButtonModule } from 'primeng/button';
import { DropdownModule } from 'primeng/dropdown';
import { InputTextModule } from 'primeng/inputtext';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';

@Component({
selector: 'app-add-sub-platform',
standalone: true,
imports: [],
imports: [
CommonModule,
InputTextModule,
DropdownModule,
FormsModule,
ReactiveFormsModule,
ButtonModule,
RadioButtonModule,
],
templateUrl: './add-sub-platform.component.html',
styleUrl: './add-sub-platform.component.scss'
})
export class AddSubPlatformComponent {
export class AddSubPlatformComponent implements OnInit {
myForm!: FormGroup;
id!: any;

constructor(
private fb: FormBuilder,
private messageHandlerService: ErrorHandlingService,
private loaderService: GlobalLoaderService,
private route: ActivatedRoute,
private router: Router,
private orgService: OrganizationService,
) { }

ngOnInit(): void {
this.id = this.route.snapshot.params['id'];

this.initForm();
}

onSave(): void {
const platform = this.myForm.getRawValue();
platform.managingOrganizationId = this.id;

this.loaderService.loadingStart();
this.orgService.addSubPlatform(platform).subscribe({
next: (_) => {
this.messageHandlerService.showSuccess('New subsidiary platform has been added successfully')
this.onCancel();
},
complete: () => {
this.loaderService.loadingEnd();
},
});
}

onCancel(): void {
this.router.navigateByUrl(`/platform/${this.id}`);
}

public get organizationNmControl(): AbstractControl {
return this.myForm.controls['organizationNm'];
}
public get organizationCdControl(): AbstractControl {
return this.myForm.controls['organizationCd'];
}
public get platformStatusControl(): AbstractControl {
return this.myForm.controls['status'];
}

private initForm(): void {
this.myForm = this.fb.group({
organizationNm: ['', [Validators.required]],
organizationCd: ['', [Validators.required]],
status: [{ value: true, disabled: true }, []],
});
}
}
Loading

0 comments on commit 97d984d

Please sign in to comment.