Skip to content
Open
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
11 changes: 11 additions & 0 deletions src/app/api/models/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
}
}
2 changes: 2 additions & 0 deletions src/app/doubtfire-angular.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -460,6 +461,7 @@ const MY_DATE_FORMAT = {
DiscussionPromptsComponent,
TaskDefinitionDiscussionPromptsComponent,
DiscussionPromptsViewComponent,
DownloadStaffNotesComponent,
],
providers: [
// Services we provide
Expand Down
6 changes: 6 additions & 0 deletions src/app/doubtfire-angularjs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down Expand Up @@ -575,3 +576,8 @@ DoubtfireAngularJSModule.directive(
'fUploadGrades',
downgradeComponent({component: UploadGradesComponent}),
);

DoubtfireAngularJSModule.directive(
'fDownloadStaffNotes',
downgradeComponent({component: DownloadStaffNotesComponent}),
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button (click)="downloadStaffNotesCsv()" class="pr-4">
<i class="fa fa-download"></i> Download Staff Notes CSV
</button>
Original file line number Diff line number Diff line change
@@ -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();
}
}
1 change: 1 addition & 0 deletions src/app/units/states/portfolios/portfolios.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ <h4 class="panel-title">Mark Portfolios</h4>
rotate="false"
></pagination>
<div class="pull-right">
<f-download-staff-notes [unit]="unit"></f-download-staff-notes>
<button
ng-click="downloadPortfolios()"
class="mr-3"
Expand Down