-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #866 from bcgov/feature/ALCS-802
Add Steps 2,3,4,7
- Loading branch information
Showing
23 changed files
with
1,856 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
portal-frontend/src/app/features/notice-of-intents/edit-submission/files-step.partial.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { MatDialog } from '@angular/material/dialog'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { NoticeOfIntentDocumentDto } from '../../../services/notice-of-intent-document/notice-of-intent-document.dto'; | ||
import { NoticeOfIntentDocumentService } from '../../../services/notice-of-intent-document/notice-of-intent-document.service'; | ||
import { DOCUMENT_TYPE } from '../../../shared/dto/document.dto'; | ||
import { FileHandle } from '../../../shared/file-drag-drop/drag-drop.directive'; | ||
import { RemoveFileConfirmationDialogComponent } from '../../applications/alcs-edit-submission/remove-file-confirmation-dialog/remove-file-confirmation-dialog.component'; | ||
import { StepComponent } from './step.partial'; | ||
|
||
@Component({ | ||
selector: 'app-file-step', | ||
template: '<p></p>', | ||
styleUrls: [], | ||
}) | ||
export abstract class FilesStepComponent extends StepComponent { | ||
@Input() $noiDocuments!: BehaviorSubject<NoticeOfIntentDocumentDto[]>; | ||
|
||
DOCUMENT_TYPE = DOCUMENT_TYPE; | ||
|
||
protected fileId = ''; | ||
|
||
protected abstract save(): Promise<void>; | ||
|
||
protected constructor( | ||
protected noticeOfIntentDocumentService: NoticeOfIntentDocumentService, | ||
protected dialog: MatDialog | ||
) { | ||
super(); | ||
} | ||
|
||
async attachFile(file: FileHandle, documentType: DOCUMENT_TYPE | null) { | ||
if (this.fileId) { | ||
await this.save(); | ||
const mappedFiles = file.file; | ||
await this.noticeOfIntentDocumentService.attachExternalFile(this.fileId, mappedFiles, documentType); | ||
const documents = await this.noticeOfIntentDocumentService.getByFileId(this.fileId); | ||
if (documents) { | ||
this.$noiDocuments.next(documents); | ||
} | ||
} | ||
} | ||
|
||
async onDeleteFile($event: NoticeOfIntentDocumentDto) { | ||
if (this.draftMode) { | ||
this.dialog | ||
.open(RemoveFileConfirmationDialogComponent) | ||
.beforeClosed() | ||
.subscribe(async (didConfirm) => { | ||
if (didConfirm) { | ||
this.deleteFile($event); | ||
} | ||
}); | ||
} else { | ||
await this.deleteFile($event); | ||
} | ||
} | ||
|
||
private async deleteFile($event: NoticeOfIntentDocumentDto) { | ||
await this.noticeOfIntentDocumentService.deleteExternalFile($event.uuid); | ||
if (this.fileId) { | ||
const documents = await this.noticeOfIntentDocumentService.getByFileId(this.fileId); | ||
if (documents) { | ||
this.$noiDocuments.next(documents); | ||
} | ||
} | ||
} | ||
|
||
async openFile(uuid: string) { | ||
const res = await this.noticeOfIntentDocumentService.openFile(uuid); | ||
if (res) { | ||
window.open(res.url, '_blank'); | ||
} | ||
} | ||
} |
Oops, something went wrong.