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

wfnews-2179 #1910

Merged
merged 4 commits into from
May 15, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class AdminIncidentForm implements OnInit, OnChanges {
currentAdminIncidentCause: IncidentCauseResource;
publishedIncidentType: string;
publishedIncidentDetailGuid: string;
currentEtag: string;
currentIncidentName: string;

constructor(
private readonly formBuilder: UntypedFormBuilder,
Expand Down Expand Up @@ -220,6 +220,7 @@ export class AdminIncidentForm implements OnInit, OnChanges {
.subscribe(
async (incidentResponse) => {
self.currentAdminIncident = incidentResponse.response;
this.currentIncidentName = self.currentAdminIncident.incidentName;
this.publishedIncidentType = self.currentAdminIncident.type;
(self.incident as any).discoveryDate = new Date(
self.currentAdminIncident.discoveryTimestamp,
Expand Down Expand Up @@ -385,22 +386,23 @@ export class AdminIncidentForm implements OnInit, OnChanges {
}

populatePublishedIMFields(result) {
const response = result?.body;
this.currentEtag = result?.headers?.get('ETag')
this.publishedIncidentDetailGuid =
response?.publishedIncidentDetailGuid;

this.incident.cause = 0;
this.incident.causeComments = response?.incidentCauseDetail;
Object.entries(CauseOptionDisclaimer).forEach(
([index, disclaimer]) => {
if (disclaimer === response?.incidentCauseDetail) {
this.incident.cause = Number.parseInt(index, 10);
}
},
);
if (!response?.incidentCauseDetail) {
this.incident.causeComments = CauseOptionDisclaimer[0];
if (result?.body) {
const response = result.body;
this.publishedIncidentDetailGuid =
response?.publishedIncidentDetailGuid;

this.incident.cause = 0;
this.incident.causeComments = response?.incidentCauseDetail;
Object.entries(CauseOptionDisclaimer).forEach(
([index, disclaimer]) => {
if (disclaimer === response?.incidentCauseDetail) {
this.incident.cause = Number.parseInt(index, 10);
}
},
);
if (!response?.incidentCauseDetail) {
this.incident.causeComments = CauseOptionDisclaimer[0];
}
}
}

Expand Down Expand Up @@ -500,6 +502,7 @@ export class AdminIncidentForm implements OnInit, OnChanges {
this.incident.contact.emailAddress =
response.contactEmailAddress;
this.incident.incidentOverview = response.incidentOverview;
this.cdr.detectChanges();
}
}

Expand Down Expand Up @@ -577,8 +580,9 @@ export class AdminIncidentForm implements OnInit, OnChanges {

try {
const doc = await self.publishIncident(publishedIncidentResource);
this.publishedIncidentDetailGuid = doc?.publishedIncidentDetailGuid;

if (doc) {
this.publishedIncidentDetailGuid = doc.publishedIncidentDetailGuid;
}
// Handle evac orders
await this.evacOrdersDetailsPanel.persistEvacOrders();
if (doc) {
Expand All @@ -604,7 +608,6 @@ export class AdminIncidentForm implements OnInit, OnChanges {
}
}
publishIncident(incident): Promise<any> {

if (incident.publishedIncidentDetailGuid == null) {
// If publishedIncidentGuid is null, just save the incident
// let publishedGuid;
Expand All @@ -629,16 +632,19 @@ export class AdminIncidentForm implements OnInit, OnChanges {
}
} else {
// If publishedIncidentGuid is not null, check for updates and then save the incident
return this.publishedIncidentService.getIMPublishedIncident(incident)
return this.publishedIncidentService.fetchIMIncident(this.wildFireYear, this.incidentNumberSequnce)
.toPromise()
.then(data => {
let etag = data.headers.get('ETag')
if (etag != this.currentEtag) {
let name = data.response.incidentName;
if (name != this.currentIncidentName) {
this.snackbarService.open(
'There have been updates on this incident. To retrieve the latest information, please refresh the page. Note that after refreshing, any ongoing edits will be lost',
'Fire Name has changed externally and has been updated on this page. Confirm change and re-publish',
'Ok',
{ duration: 10000, panelClass: 'snackbar-error' },
);
this.currentIncidentName = name;
this.incidentForm.get('fireName').setValue(name);
this.incident.fireName = name;
return;
} else {
const saveResult = this.publishedIncidentService.saveIMPublishedIncident(incident);
Expand Down
Loading