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

Updated public comment periods to redirect to external URLs when present #649

Merged
merged 2 commits into from
Sep 13, 2023
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
31 changes: 26 additions & 5 deletions src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h5>
5-10 minute survey to help us design a better online platform for
hearing what you think about projects under review.
</p>
<a class="survey-link" href="{{ surveyUrl }}" target="_blank"
<a class="survey-link" href="{{ surveyUrl }}" rel="noopener" target="_blank"
>Share your thoughts</a
>
</div>
Expand Down Expand Up @@ -107,10 +107,29 @@ <h3 class="title-container__title">
Project Info
</a>
<a
*ngIf="item?.pcp && item?.type === 'Public Comment Period'"
*ngIf="
item.pcp &&
item.type === 'Public Comment Period' &&
(!item.pcp.isMet || !item.pcp.metURL)
"
class="btn btn-sm content-btn-alt"
title="View this Public Comment Period"
[routerLink]="['/p', item.project?._id, 'cp', item.pcp]"
[routerLink]="['/p', item.project?._id, 'cp', item.pcp._id]"
>
Submit/ View Comments
</a>
<a
*ngIf="
item.pcp &&
item.type === 'Public Comment Period' &&
item.pcp.isMet &&
item.pcp.metURL
"
class="btn btn-sm content-btn-alt"
href="{{ item.pcp.metURL }}"
rel="noopener"
target="_blank"
title="View this Public Comment Period"
>
Submit/ View Comments
</a>
Expand All @@ -121,9 +140,10 @@ <h3 class="title-container__title">
!item?.notificationName
"
class="btn btn-sm content-btn-alt"
title="View more information"
href="{{ item.documentUrl }}"
rel="noopener"
target="_blank"
title="View more information"
>
View Document(s)
</a>
Expand All @@ -135,9 +155,10 @@ <h3 class="title-container__title">
'Project Notification Public Comment Period'
"
class="btn btn-sm content-btn-alt"
title="View more information"
href="{{ item.documentUrl }}"
rel="noopener"
target="_blank"
title="View more information"
>
View Project Notification Public Comment Period
</a>
Expand Down
4 changes: 4 additions & 0 deletions src/app/models/commentperiod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export class CommentPeriod {
informationLabel: String;
instructions: String;
isClassified: Boolean;
isMet: boolean;
isPublished: Boolean;
isResolved: Boolean;
isVetted: String;
metURL: string;
milestone: String;
openCommentPeriod: String;
openHouses: String;
Expand Down Expand Up @@ -76,10 +78,12 @@ export class CommentPeriod {
this.downloadRoles = obj && obj.downloadRoles || null;
this.informationLabel = obj && obj.informationLabel || null;
this.instructions = obj && obj.instructions || null;
this.isMet = obj && obj.isMet || null;
this.isClassified = obj && obj.isClassified || null;
this.isPublished = obj && obj.isPublished || null;
this.isResolved = obj && obj.isResolved || null;
this.isVetted = obj && obj.isVetted || null;
this.metURL = obj && obj.metURL || null;
this.milestone = obj && obj.milestone || null;
this.openHouses = obj && obj.openHouses || null;
this.periodType = obj && obj.periodType || null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export class NewsListTableRowsComponent extends TableRowComponent {


goToCP(activity) {
this.router.navigate(['p', activity.project._id, 'cp', activity.pcp]);
if (activity.pcp.isMet && activity.pcp.metURL) {
window.open(activity.pcp.metURL, '_blank');
} else {
this.router.navigate(['p', activity.project._id, 'cp', activity.pcp._id]);
}
}

isSingleDoc(item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,53 @@
<h4>{{(rowData.name.toUpperCase() || '-')}}</h4>
</div>
<div class="col-md-12 col-lg-6 text-lg-right">
<a *ngIf="rowData.commentPeriod?.commentPeriodStatus === 'Open'"
<a *ngIf="
rowData.commentPeriod?.commentPeriodStatus === 'Open' &&
(!rowData.commentPeriod?.isMet || !rowData.commentPeriod?.metURL)
"
class="btn btn-primary view-pcp-btn"
title="View this Public Comment Period"
[routerLink]="['/pn', rowData._id, 'cp', rowData.commentPeriod?._id]">
[routerLink]="['/pn', rowData._id, 'cp', rowData.commentPeriod?._id]"
>
<div class="pcp-indicator pcp-indicator-active"></div>
Open Comment Period - View/Submit
</a>
<a *ngIf="rowData.commentPeriod?.commentPeriodStatus === 'Closed'"
<a *ngIf="
rowData.commentPeriod?.commentPeriodStatus === 'Open' &&
rowData.commentPeriod?.isMet &&
!rowData.commentPeriod?.metURL
"
class="btn btn-primary view-pcp-btn"
href="{{ rowData.commentPeriod.metURL }}"
rel="noopener"
target="_blank"
title="View this Public Comment Period"
[routerLink]="['/pn', rowData._id, 'cp', rowData.commentPeriod?._id]">
>
<div class="pcp-indicator pcp-indicator-active"></div>
Open Comment Period - View/Submit
</a>
<a *ngIf="
rowData.commentPeriod?.commentPeriodStatus === 'Closed' &&
(!rowData.commentPeriod?.isMet || !rowData.commentPeriod?.metURL)
"
class="btn btn-primary view-pcp-btn"
title="View this Public Comment Period"
[routerLink]="['/pn', rowData._id, 'cp', rowData.commentPeriod?._id]"
>
<div class="pcp-indicator pcp-indicator-inactive"></div>
View Completed Comment Period
</a>
<a *ngIf="
rowData.commentPeriod?.commentPeriodStatus === 'Closed' &&
rowData.commentPeriod?.isMet &&
!rowData.commentPeriod?.metURL
"
class="btn btn-primary view-pcp-btn"
href="{{ rowData.commentPeriod.metURL }}"
rel="noopener"
target="_blank"
title="View this Public Comment Period"
>
<div class="pcp-indicator pcp-indicator-inactive"></div>
View Completed Comment Period
</a>
Expand Down Expand Up @@ -86,4 +122,4 @@ <h4>{{(rowData.name.toUpperCase() || '-')}}</h4>
<p class="value">{{getTrigger(rowData) || "-" }}</p>
</div>
</div>
</div>
</div>
6 changes: 5 additions & 1 deletion src/app/project/commenting-tab/commenting-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export class CommentingTabComponent implements OnInit, OnDestroy {
}

goToCP(commentPeriod) {
this.router.navigate(['p', this.currentProject._id, 'cp', commentPeriod._id]);
if (commentPeriod.isMet && commentPeriod.metURL) {
window.open(commentPeriod.metURL, '_blank');
} else {
this.router.navigate(['p', this.currentProject._id, 'cp', commentPeriod._id]);
}
}

getCommentPeriods(projectId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
</a>
<button *ngIf="rowData?.pcp"
class="btn content-btn-alt"
(click)="goToItem(rowData)">
(click)="goToCP(rowData)">
<span>Submit/ View Comment(s)</span>
</button>
</div>
</td>
<td scope="row"
data-label="Date"
class="col-2"
tabindex="0">{{rowData.dateAdded | date:'longDate'}}</td>
tabindex="0">{{rowData.dateAdded | date:'longDate'}}</td>
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ export class ActivitiesListTableRowsComponent extends TableRowComponent {
super();
}

goToItem(item) {
this.router.navigate(['p', item.project._id, 'cp', item.pcp]);
goToCP(activity) {
if (activity.pcp.isMet && activity.pcp.metURL) {
window.open(activity.pcp.metURL, '_blank');
} else {
this.router.navigate(['p', activity.project._id, 'cp', activity.pcp._id]);
}
}

isSingleDoc(item) {
Expand Down
6 changes: 5 additions & 1 deletion src/app/project/project.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,11 @@ export class ProjectComponent implements OnInit, OnDestroy, AfterViewInit {
}

public goToViewComments() {
this.router.navigate(['/p', this.project._id, 'cp', this.project.commentPeriodForBanner._id, 'details']);
if (this.project.commentPeriodForBanner.isMet && this.project.commentPeriodForBanner.metURL) {
window.open(this.project.commentPeriodForBanner.metURL, '_blank');
} else {
this.router.navigate(['/p', this.project._id, 'cp', this.project.commentPeriodForBanner._id, 'details']);
}
}

public handleSidebarToggle(event) {
Expand Down
46 changes: 20 additions & 26 deletions src/app/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ApiService {
) {
// const currentUser = JSON.parse(window.localStorage.getItem('currentUser'));
// this.token = currentUser && currentUser.token;
this.isMS = window.navigator.msSaveOrOpenBlob ? true : false;
this.isMS = !!window.navigator.msSaveOrOpenBlob;

// The following items are loaded by a file that is only present on cluster builds.
// Locally, this will be empty and local defaults will be used.
Expand All @@ -49,7 +49,7 @@ export class ApiService {
this.env = (_.isEmpty(deployment_env)) ? 'local' : deployment_env;
this.bannerColour = (_.isEmpty(banner_colour)) ? 'red' : banner_colour;
this.surveyUrl = (_.isEmpty(survey_url) || survey_url === null || survey_url === 'null') ? null : survey_url;
this.showSurveyBanner = (_.isEmpty(show_survey_banner) || show_survey_banner === null || show_survey_banner === 'null') ? false : true;
this.showSurveyBanner = !_.isEmpty(show_survey_banner) && !!show_survey_banner && show_survey_banner !== 'null';
}

handleError(error: any): Observable<any> {
Expand Down Expand Up @@ -138,26 +138,22 @@ export class ApiService {
if (sortBy !== null) { queryString += `&sortBy=${sortBy}`; }
if (secondarySort !== null) { queryString += `&sortBy=${secondarySort}`; }
if (populate !== null) { queryString += `&populate=${populate}`; }
if (queryModifier !== {}) {
Object.keys(queryModifier).forEach(key => {
queryModifier[key].split(',').forEach(item => {
queryString += `&and[${key}]=${item}`;
});
Object.keys(queryModifier).forEach(key => {
queryModifier[key].split(',').forEach(item => {
queryString += `&and[${key}]=${item}`;
});
}
if (filter !== {}) {
let safeItem;
Object.keys(filter).map(key => {
filter[key].split(',').map(item => {
if (item.includes('&')) {
safeItem = this.utils.encodeString(item, true);
} else {
safeItem = item;
}
queryString += `&and[${key}]=${safeItem}`;
});
});
let safeItem;
Object.keys(filter).map(key => {
filter[key].split(',').map(item => {
if (item.includes('&')) {
safeItem = this.utils.encodeString(item, true);
} else {
safeItem = item;
}
queryString += `&and[${key}]=${safeItem}`;
});
}
});
queryString += `&fields=${this.buildValues(fields)}`;
queryString += '&fuzzy=' + fuzzy;
return this.http.get<SearchResults[]>(`${this.apiPath}/${queryString}`, {});
Expand Down Expand Up @@ -468,13 +464,11 @@ export class ApiService {
'project',
'dateStarted',
'dateCompleted',
'instructions'
'instructions',
'isMet',
'metURL',
];
// TODO: May want to pass this as a parameter in the future.
const sort = '&sortBy=-dateStarted';

let queryString = 'commentperiod?project=' + projId + '&fields=' + this.buildValues(fields) + '&';
if (sort !== null) { queryString += `sortBy=${sort}&`; }
const queryString = `commentperiod?project=${projId}&sortBy=-dateStarted&fields=${this.buildValues(fields)}`;
return this.http.get<Object>(`${this.apiPath}/${queryString}`, {});
}

Expand Down
Loading