Skip to content

Commit ebc7e1d

Browse files
authored
Merge pull request #607 from bcgov/oleks
DSS-796: FE: Enhancement to send notice/takedown in aggregated listings
2 parents 2406569 + ed2aa67 commit ebc7e1d

File tree

6 files changed

+110
-16
lines changed

6 files changed

+110
-16
lines changed

frontend/src/app/features/components/bulk-compliance-notice/bulk-compliance-notice.component.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@ <h2>Send Notices of Non-Compliance</h2>
22
<h4>Complete the following fields to send Notices of Non-Compliance to STR Hosts and Platform Representatives.</h4>
33
<h4>All fields are required except where stated.</h4>
44

5-
<p-panel class="table-panel" header="Included Listings">
5+
<p-panel class="table-panel">
6+
<ng-template pTemplate="header" *ngIf="containsDisabledItems">
7+
<div class="header-panel">
8+
<strong>Included Listings</strong>
9+
<div *ngIf="containsDisabledItems" class="some-items-are-inactive-msg"> <i
10+
class="pi pi-info-circle"></i>Notices of Non-Compliance and
11+
Takedown Requests cannot be sent
12+
for inactive listings as they are no longer available on the platform.</div>
13+
</div>
14+
</ng-template>
15+
616
<p-table [value]="extendedListings" [scrollable]="true" scrollDirection="vertical" scrollHeight="425px"
717
styleClass="p-datatable-sm" [(selection)]="selectedListings">
818
<ng-template pTemplate="header">
919
<tr>
1020
<th style="width: 4rem">
11-
<p-tableHeaderCheckbox></p-tableHeaderCheckbox>
21+
<p-checkbox [binary]="true" [disabled]="containsDisabledItems"
22+
(onChange)="onListingSelected($event)"></p-checkbox>
1223
</th>
1324
<th class="sortable-header" id="offeringOrganizationNm_header"
1425
[class.sorted]="this.sort && this.sort.prop === 'offeringOrganizationNm'"
@@ -62,7 +73,7 @@ <h4>All fields are required except where stated.</h4>
6273
<ng-template pTemplate="body" let-listing>
6374
<tr class="small-text">
6475
<td>
65-
<p-tableCheckbox [value]="listing"></p-tableCheckbox>
76+
<p-tableCheckbox [disabled]="listing.listingStatusType === 'I'" [value]="listing"></p-tableCheckbox>
6677
</td>
6778
<td>{{ listing.offeringOrganizationNm }}</td>
6879
<td>

frontend/src/app/features/components/bulk-compliance-notice/bulk-compliance-notice.component.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@
1313
p-panel {
1414
margin-bottom: 24px;
1515
display: block;
16+
17+
.header-panel {
18+
display: flex;
19+
gap: 8px;
20+
align-items: center;
21+
justify-content: space-between;
22+
width: 100%;
23+
24+
strong {
25+
font-size: larger;
26+
}
27+
28+
.some-items-are-inactive-msg {
29+
i {
30+
margin-right: 8px;
31+
font-weight: 600;
32+
}
33+
34+
font-size: medium;
35+
color: #D32F2F;
36+
}
37+
}
1638
}
1739

1840
tr {

frontend/src/app/features/components/bulk-compliance-notice/bulk-compliance-notice.component.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ErrorHandlingService } from '../../../common/services/error-handling.se
1919
import { ComplianceNoticeBulk } from '../../../common/models/compliance-notice';
2020
import { OverlayPanelModule } from 'primeng/overlaypanel';
2121
import { GlobalLoaderService } from '../../../common/services/global-loader.service';
22+
import { ListingTableRow } from '../../../common/models/listing-table-row';
2223

2324
@Component({
2425
selector: 'app-bulk-compliance-notice',
@@ -41,17 +42,19 @@ import { GlobalLoaderService } from '../../../common/services/global-loader.serv
4142
styleUrl: './bulk-compliance-notice.component.scss'
4243
})
4344
export class BulkComplianceNoticeComponent implements OnInit {
44-
listings!: Array<ListingDetails>;
45+
listings!: Array<ListingDetails | ListingTableRow>;
4546
returnUrl!: string;
4647
myForm!: FormGroup;
47-
extendedListings = new Array<ListingDetailsWithHostCheckboxExtension>();
48+
containsDisabledItems = false;
49+
50+
extendedListings = new Array<ListingDetailsWithHostCheckboxExtension | any>();
4851

4952
previewText = '';
5053
showPreviewDialog = false;
5154

5255
submissionArray!: Array<ComplianceNoticeBulk>;
5356

54-
selectedListings!: Array<ListingDetailsWithHostCheckboxExtension>;
57+
selectedListings!: Array<ListingDetails | ListingTableRow>;
5558
addressWarningScoreLimit = Number.parseInt(environment.ADDRESS_SCORE);
5659
sort!: { prop: string, dir: 'asc' | 'desc' }
5760

@@ -81,9 +84,12 @@ export class BulkComplianceNoticeComponent implements OnInit {
8184
else {
8285
this.returnUrl = param['returnUrl'];
8386
this.listings = [...this.searchStateService.selectedListings];
84-
this.extendedListings = this.listings.map((listing) => ({ ...listing, sendNoticeToHosts: listing.hasAtLeastOneValidHostEmail }));
87+
this.containsDisabledItems = this.listings.some(l => l.listingStatusType !== 'I')
88+
89+
this.extendedListings = this.listings.map((listing) => ({ ...listing, sendNoticeToHosts: (listing as any).hasAtLeastOneValidHostEmail }));
8590
this.searchStateService.selectedListings = new Array<ListingDetailsWithHostCheckboxExtension>();
86-
this.selectedListings = this.extendedListings;
91+
this.selectedListings = this.extendedListings.filter(l => l.listingStatusType !== 'I')
92+
;
8793

8894
this.initForm();
8995
this.cloakParams();
@@ -145,9 +151,18 @@ export class BulkComplianceNoticeComponent implements OnInit {
145151
this.showPreviewDialog = false;
146152
}
147153

154+
onListingSelected(e: any): void {
155+
console.log(e);
156+
if (e.checked) {
157+
this.selectedListings = this.listings.filter(l => l.listingStatusType !== 'I');
158+
} else {
159+
this.selectedListings = [];
160+
}
161+
}
162+
148163
private sendPreview(): void {
149164
const formValues = this.myForm.value;
150-
this.submissionArray = this.selectedListings.map((x: ListingDetailsWithHostCheckboxExtension) => ({
165+
this.submissionArray = this.selectedListings.map((x: ListingDetailsWithHostCheckboxExtension | any) => ({
151166
rentalListingId: x.rentalListingId,
152167
ccList: formValues.ccList.prototype === Array
153168
? formValues

frontend/src/app/features/components/bulk-takedown-request/bulk-takedown-request.component.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,24 @@ <h4>Takedown Requests for each platform are aggregated into a CSV file and sent
55
where stated.</h4>
66
<form *ngIf="myForm" [formGroup]="myForm">
77

8-
<p-panel class="table-panel" header="Included Listings">
8+
<p-panel class="table-panel">
9+
<ng-template pTemplate="header" *ngIf="containsDisabledItems">
10+
<div class="header-panel">
11+
<strong>Included Listings</strong>
12+
<div *ngIf="containsDisabledItems" class="some-items-are-inactive-msg"> <i
13+
class="pi pi-info-circle"></i>Notices of Non-Compliance and
14+
Takedown Requests cannot be sent
15+
for inactive listings as they are no longer available on the platform.</div>
16+
</div>
17+
</ng-template>
18+
919
<p-table [value]="listings" [scrollable]="true" scrollDirection="vertical" scrollHeight="425px"
1020
styleClass="p-datatable-sm" [(selection)]="selectedListings">
1121
<ng-template pTemplate="header">
1222
<tr>
1323
<th style="width: 4rem">
14-
<p-tableHeaderCheckbox></p-tableHeaderCheckbox>
24+
<p-checkbox [binary]="true" [disabled]="containsDisabledItems"
25+
(onChange)="onListingSelected($event)"></p-checkbox>
1526
</th>
1627
<th class="sortable-header" id="status_header"
1728
[class.sorted]="this.sort && this.sort.prop === 'offeringOrganizationNm'"
@@ -54,7 +65,8 @@ <h4>Takedown Requests for each platform are aggregated into a CSV file and sent
5465
<ng-template pTemplate="body" let-listing>
5566
<tr class="small-text">
5667
<td>
57-
<p-tableCheckbox [value]="listing"></p-tableCheckbox>
68+
<p-tableCheckbox [disabled]="listing.listingStatusType === 'I'"
69+
[value]="listing"></p-tableCheckbox>
5870
</td>
5971
<td>{{ listing.offeringOrganizationNm }}</td>
6072
<td>

frontend/src/app/features/components/bulk-takedown-request/bulk-takedown-request.component.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@
1313
p-panel {
1414
margin-bottom: 24px;
1515
display: block;
16+
17+
.header-panel {
18+
display: flex;
19+
gap: 8px;
20+
align-items: center;
21+
justify-content: space-between;
22+
width: 100%;
23+
24+
strong {
25+
font-size: larger;
26+
}
27+
28+
.some-items-are-inactive-msg {
29+
i {
30+
margin-right: 8px;
31+
font-weight: 600;
32+
}
33+
34+
font-size: medium;
35+
color: #D32F2F;
36+
}
37+
}
1638
}
1739

1840
tr {

frontend/src/app/features/components/bulk-takedown-request/bulk-takedown-request.component.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { DelistingService } from '../../../common/services/delisting.service';
1717
import { validateEmailListString } from '../../../common/consts/validators.const';
1818
import { ErrorHandlingService } from '../../../common/services/error-handling.service';
1919
import { GlobalLoaderService } from '../../../common/services/global-loader.service';
20+
import { ListingTableRow } from '../../../common/models/listing-table-row';
2021

2122
@Component({
2223
selector: 'app-bulk-takedown-request',
@@ -37,9 +38,10 @@ import { GlobalLoaderService } from '../../../common/services/global-loader.serv
3738
styleUrl: './bulk-takedown-request.component.scss'
3839
})
3940
export class BulkTakedownRequestComponent implements OnInit {
40-
listings!: Array<ListingDetails>;
41+
listings!: Array<ListingDetails | ListingTableRow>;
4142
returnUrl!: string;
4243
myForm!: FormGroup;
44+
containsDisabledItems = false;
4345

4446
previewText = '';
4547
showPreviewDialog = false;
@@ -51,7 +53,7 @@ export class BulkTakedownRequestComponent implements OnInit {
5153
customDetailTxt: any;
5254
}[]
5355

54-
selectedListings!: Array<ListingDetails>;
56+
selectedListings!: Array<ListingDetails | ListingTableRow>;
5557
addressWarningScoreLimit = Number.parseInt(environment.ADDRESS_SCORE);
5658
sort!: { prop: string, dir: 'asc' | 'desc' }
5759

@@ -85,13 +87,23 @@ export class BulkTakedownRequestComponent implements OnInit {
8587
this.returnUrl = param['returnUrl'];
8688
this.listings = [...this.searchStateService.selectedListings];
8789
this.searchStateService.selectedListings = new Array<ListingDetails>();
88-
this.selectedListings = this.listings;
90+
this.selectedListings = this.listings.filter(l => l.listingStatusType !== 'I');
91+
this.containsDisabledItems = this.listings.some(l => l.listingStatusType !== 'I')
8992
this.initForm();
9093
this.cloakParams();
9194
}
9295
});
9396
}
9497

98+
onListingSelected(e: any): void {
99+
console.log(e);
100+
if (e.checked) {
101+
this.selectedListings = this.listings.filter(l => l.listingStatusType !== 'I');
102+
} else {
103+
this.selectedListings = [];
104+
}
105+
}
106+
95107
onSort(property: keyof ListingDetails): void {
96108
if (this.sort) {
97109
if (this.sort.prop === property) {
@@ -158,7 +170,7 @@ export class BulkTakedownRequestComponent implements OnInit {
158170

159171
private sendPreview(): void {
160172
const formValues = this.myForm.value;
161-
this.submissionArray = this.selectedListings.map((x: ListingDetails) => ({
173+
this.submissionArray = this.selectedListings.map((x: ListingDetails | ListingTableRow) => ({
162174
rentalListingId: x.rentalListingId,
163175
ccList: formValues.ccList.prototype === Array
164176
? formValues

0 commit comments

Comments
 (0)