Skip to content

Commit

Permalink
CSCEXAM-1256 Fix DI mechanism of DocumentReviewController
Browse files Browse the repository at this point in the history
  • Loading branch information
lupari committed Jun 19, 2024
1 parent ac2c298 commit 0d05a6e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
3 changes: 2 additions & 1 deletion app/controllers/ReviewDocumentsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ import scala.jdk.CollectionConverters.*
import scala.util.Using

class ReviewDocumentsController @Inject() (
val controllerComponents: ControllerComponents,
csvBuilder: CsvBuilder,
fileHandler: FileHandler,
authenticated: AuthenticatedAction,
implicit val ec: AuthExecutionContext
) extends InjectedController
) extends BaseController
with JavaApiHelper
with DbApiHelper
with Logging:
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/enrolment/enrolment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class EnrolmentService {
this.http.get<CollaborativeParticipation[]>('/app/iop/student/finishedExams');

searchExams$ = (searchTerm: string): Observable<CollaborativeExam[]> => {
const paramStr = '?filter=' + (searchTerm && searchTerm.length > 0 ? encodeURIComponent(searchTerm) : '');
const paramStr = '?filter=' + (searchTerm?.length > 0 ? encodeURIComponent(searchTerm) : '');
const path = `/app/iop/enrolment${paramStr}`;
return this.http.get<CollaborativeExam[]>(path);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class CollaborativeExamListingComponent implements OnInit, OnDestroy {
distinctUntilChanged(),
switchMap((text) => this.CollaborativeExam.searchExams$(text)),
tap(() => (this.loader.loading = true)),
map((exams) => this.returnListedCollaborativeExams(exams)),
map((exams) => this.searchExams(exams)),
tap((exams) => (this.exams = exams)),
tap(() => (this.loader.loading = false)),
takeUntil(this.ngUnsubscribe),
Expand All @@ -120,20 +120,6 @@ export class CollaborativeExamListingComponent implements OnInit, OnDestroy {

listAllExams = () => this.filterChanged.next('');

returnListedCollaborativeExams(exams: CollaborativeExam[]): ListedCollaborativeExam[] {
const listedExams: ListedCollaborativeExam[] = exams
.map((e) => {
const ownerAggregate = e.examOwners.map((o) => o.email).join();
const stateTranslation = this.getStateTranslation(e);
const listingView = this.determineListingView(e);

return { ...e, ownerAggregate, stateTranslation, listingView };
})
.filter((e) => e.listingView !== ListingView.OTHER);

return listedExams;
}

determineListingView(exam: CollaborativeExam) {
if (
(exam.state === CollaborativeExamState.PUBLISHED || exam.state === CollaborativeExamState.PRE_PUBLISHED) &&
Expand Down Expand Up @@ -181,4 +167,15 @@ export class CollaborativeExamListingComponent implements OnInit, OnDestroy {
const e = event.target as HTMLInputElement;
return this.filterChanged.next(e.value);
};

private searchExams = (exams: CollaborativeExam[]): ListedCollaborativeExam[] =>
exams
.map((e) => {
const ownerAggregate = e.examOwners.map((o) => o.email).join();
const stateTranslation = this.getStateTranslation(e);
const listingView = this.determineListingView(e);

return { ...e, ownerAggregate, stateTranslation, listingView };
})
.filter((e) => e.listingView !== ListingView.OTHER);
}

0 comments on commit 0d05a6e

Please sign in to comment.