diff --git a/src/app/api/models/unit.ts b/src/app/api/models/unit.ts index 0caa668085..c2c7c8268a 100644 --- a/src/app/api/models/unit.ts +++ b/src/app/api/models/unit.ts @@ -721,4 +721,15 @@ export class Unit extends Entity { }), ); } + + public get staffNotesCsvDownloadUrl(): string { + return `${AppInjector.get(DoubtfireConstants).API_URL}/csv/units/${this.id}/staff_notes`; + } + + public downloadStaffNotesCsv(): void { + AppInjector.get(FileDownloaderService).downloadFile( + `${AppInjector.get(DoubtfireConstants).API_URL}/csv/units/${this.id}/staff_notes`, + `${this.name}-StaffNotes.csv`, + ); + } } diff --git a/src/app/doubtfire-angular.module.ts b/src/app/doubtfire-angular.module.ts index 7938a4e274..9b1330ca2b 100644 --- a/src/app/doubtfire-angular.module.ts +++ b/src/app/doubtfire-angular.module.ts @@ -301,6 +301,7 @@ import {DiscussionPromptService} from './api/services/discussion-prompt.service' import {DiscussionPromptsComponent} from './projects/states/discussion-prompts/discussion-prompts.component'; import {TaskDefinitionDiscussionPromptsComponent} from './units/states/edit/directives/unit-tasks-editor/task-definition-editor/task-definition-discussion-prompts/task-definition-discussion-prompts.component'; import {DiscussionPromptsViewComponent} from './projects/states/dashboard/directives/task-dashboard/directives/discussion-prompts-view/discussion-prompts-view.component'; +import {DownloadStaffNotesComponent} from './units/states/portfolios/download-staff-notes/download-staff-notes.component'; // See https://stackoverflow.com/questions/55721254/how-to-change-mat-datepicker-date-format-to-dd-mm-yyyy-in-simplest-way/58189036#58189036 const MY_DATE_FORMAT = { @@ -460,6 +461,7 @@ const MY_DATE_FORMAT = { DiscussionPromptsComponent, TaskDefinitionDiscussionPromptsComponent, DiscussionPromptsViewComponent, + DownloadStaffNotesComponent, ], providers: [ // Services we provide diff --git a/src/app/doubtfire-angularjs.module.ts b/src/app/doubtfire-angularjs.module.ts index 8187457400..69fa3516b1 100644 --- a/src/app/doubtfire-angularjs.module.ts +++ b/src/app/doubtfire-angularjs.module.ts @@ -233,6 +233,7 @@ import {PortfolioGradeSelectStepComponent} from './projects/states/portfolio/dir import {PortfolioIncludedTasksComponent} from './projects/states/portfolio/directives/portfolio-review-step/portfolio-included-tasks/portfolio-included-tasks.component'; import {TaskSimilarityViewComponent} from './projects/states/dashboard/directives/task-dashboard/directives/task-similarity-view/task-similarity-view.component'; import {UploadGradesComponent} from './units/states/portfolios/upload-grades/upload-grades.component'; +import {DownloadStaffNotesComponent} from './units/states/portfolios/download-staff-notes/download-staff-notes.component'; export const DoubtfireAngularJSModule = angular .module('doubtfire', [ @@ -575,3 +576,8 @@ DoubtfireAngularJSModule.directive( 'fUploadGrades', downgradeComponent({component: UploadGradesComponent}), ); + +DoubtfireAngularJSModule.directive( + 'fDownloadStaffNotes', + downgradeComponent({component: DownloadStaffNotesComponent}), +); diff --git a/src/app/units/states/portfolios/download-staff-notes/download-staff-notes.component.html b/src/app/units/states/portfolios/download-staff-notes/download-staff-notes.component.html new file mode 100644 index 0000000000..529708f97c --- /dev/null +++ b/src/app/units/states/portfolios/download-staff-notes/download-staff-notes.component.html @@ -0,0 +1,3 @@ + diff --git a/src/app/units/states/portfolios/download-staff-notes/download-staff-notes.component.scss b/src/app/units/states/portfolios/download-staff-notes/download-staff-notes.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/units/states/portfolios/download-staff-notes/download-staff-notes.component.ts b/src/app/units/states/portfolios/download-staff-notes/download-staff-notes.component.ts new file mode 100644 index 0000000000..eb3e1501bd --- /dev/null +++ b/src/app/units/states/portfolios/download-staff-notes/download-staff-notes.component.ts @@ -0,0 +1,24 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {Unit} from 'src/app/api/models/unit'; +import {AlertService} from 'src/app/common/services/alert.service'; + +@Component({ + selector: 'f-download-staff-notes', + templateUrl: 'download-staff-notes.component.html', + styleUrl: 'download-staff-notes.component.scss', +}) +export class DownloadStaffNotesComponent implements OnInit { + @Input() unit: Unit; + + constructor(private alertService: AlertService) {} + + public ngOnInit(): void { + if (!this.unit) { + return console.error(`Invalid unit`); + } + } + + public downloadStaffNotesCsv() { + this.unit.downloadStaffNotesCsv(); + } +} diff --git a/src/app/units/states/portfolios/portfolios.tpl.html b/src/app/units/states/portfolios/portfolios.tpl.html index 34d00d5d7f..eaff240d73 100644 --- a/src/app/units/states/portfolios/portfolios.tpl.html +++ b/src/app/units/states/portfolios/portfolios.tpl.html @@ -236,6 +236,7 @@

Mark Portfolios

rotate="false" >
+