From 7395987236eb444fd5390dab8ed346a84f51e3f2 Mon Sep 17 00:00:00 2001 From: alicia pritchett Date: Tue, 12 Oct 2021 14:28:15 -0400 Subject: [PATCH] Adds a trashcan so you can delete a file reference if you really want but you cannot delete the two important reference files that were already there --- .../reference-files.component.html | 9 +++++++-- .../reference-files.component.scss | 4 ++++ .../reference-files/reference-files.component.ts | 16 ++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/app/reference-files/reference-files.component.html b/src/app/reference-files/reference-files.component.html index e43845e..f8857ad 100644 --- a/src/app/reference-files/reference-files.component.html +++ b/src/app/reference-files/reference-files.component.html @@ -8,13 +8,18 @@
- +

{{refFile.type | getIconCode}} - {{refFile.name}} + {{refFile.name}}

+
+ +
Last Modified: {{refFile.last_modified | date:'medium'}}
diff --git a/src/app/reference-files/reference-files.component.scss b/src/app/reference-files/reference-files.component.scss index 6770ce5..89635af 100644 --- a/src/app/reference-files/reference-files.component.scss +++ b/src/app/reference-files/reference-files.component.scss @@ -9,3 +9,7 @@ mat-card { padding: 2em; border: 1px solid $brand-gray; } + +.trashcan { + color: darkorange; +} diff --git a/src/app/reference-files/reference-files.component.ts b/src/app/reference-files/reference-files.component.ts index 512bc1f..8daabda 100644 --- a/src/app/reference-files/reference-files.component.ts +++ b/src/app/reference-files/reference-files.component.ts @@ -69,19 +69,23 @@ export class ReferenceFilesComponent { dialogRef.afterClosed().subscribe((data: OpenFileDialogData) => { if (data && data.file) { const newFileMeta: FileMeta = { - id: data.fileMetaId, content_type: data.file.type, name: data.file.name, type: getFileType(data.file), is_reference: true, }; - const fileParams = {}; - this.apiService.addFile(fileParams, newFileMeta, data.file).subscribe(refs => { - this.snackBar.open(`Added new file ${fm.name}.`, 'Ok', {duration: 3000}); + this.apiService.addReferenceFile(newFileMeta, data.file).subscribe(refs => { + this.snackBar.open(`Added new file ${newFileMeta.name}.`, 'Ok', {duration: 3000}); this._loadReferenceFiles(); - } - ) + }); } }); } + + deleteFile(id: number, name: string) { + this.apiService.deleteFileMeta(id).subscribe(f => { + this.snackBar.open(`Deleted reference file ${name}.`, 'Ok', {duration: 3000}); + this._loadReferenceFiles(); + }); + } }