Skip to content

Commit

Permalink
CSCEXAM-000 Split large components to smaller ones
Browse files Browse the repository at this point in the history
  • Loading branch information
lupari committed Aug 20, 2024
1 parent 5e5bcbe commit d76da86
Show file tree
Hide file tree
Showing 14 changed files with 667 additions and 705 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name := "exam"

version := "6.3.0"

licenses += "EUPL 1.1" -> url("https://joinup.ec.europa.eu/software/page/eupl/licence-eupl")
licenses += "EUPL 1.2" -> url("https://joinup.ec.europa.eu/software/page/eupl/licence-eupl")

scalaVersion := "3.4.0"

Expand Down
88 changes: 1 addition & 87 deletions ui/src/app/enrolment/active/active-enrolment.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,93 +267,7 @@ <h2>
</div>
}
@if (reservation && enrolment().optionalSections.length > 0) {
<div class="row mt-2 enrollment-card-dropdown">
<div class="col col-md-12">
<button
class="btn btn-outline-secondary"
(click)="showMaterials.set(!showMaterials())"
(keydown.enter)="showMaterials.set(!showMaterials())"
[attr.aria-expanded]="showMaterials()"
>
{{ 'i18n_selected_sections' | translate }}
<img class="arrow_icon" [hidden]="showMaterials()" alt="" src="/assets/images/arrow_right.png" />
<img class="arrow_icon" [hidden]="!showMaterials()" alt="" src="/assets/images/arrow_down.png" />
</button>
@if (reservation && enrolment().optionalSections.length > 0) {
<div class="pt-2" [hidden]="!showMaterials">
@for (section of exam.examSections; track section) {
<div class="mb-3">
@if (section.optional === false) {
<div class="row">
<div class="col">
<strong
>{{ 'i18n_exam_section' | translate }}
<small class="text text-danger"
>({{ 'i18n_required' | translate | lowercase }})</small
>:</strong
>
{{ section.name }}
</div>
</div>
<div class="row">
<div class="col">
{{ section.description }}
</div>
</div>
}
</div>
}
@for (section of enrolment().optionalSections; track section) {
<div class="mb-3">
<div class="row">
<div class="col">
<strong
>{{ 'i18n_exam_section' | translate }}
<small class="text text-success"
>({{ 'i18n_optional' | translate | lowercase }})</small
>:</strong
>
{{ section.name }}
</div>
</div>
<div class="row">
<div class="col">
{{ section.description }}
</div>
</div>
@if (section.examMaterials.length > 0) {
<div>
<div class="row">
<div class="col">
<strong>{{ 'i18n_exam_materials' | translate }}</strong>
</div>
</div>
@for (material of section.examMaterials; track material) {
<div>
<div class="row">
<span class="col">
{{ 'i18n_name' | translate | uppercase }}: {{ material.name }}
@if (material.author) {
<span>
{{ 'i18n_author' | translate | uppercase }}:
{{ material.author }}
</span>
}
@if (material.isbn) {
<span> ISBN: {{ material.isbn }} </span>
}
</span>
</div>
</div>
}
</div>
}
</div>
}
</div>
}
</div>
</div>
<xm-optional-sections [selectedSections]="enrolment().optionalSections" [allSections]="exam.examSections" />
}
<div class="row mb-3 mt-2">
<div class="col">
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/enrolment/active/active-enrolment.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: EUPL-1.2

import { DatePipe, LowerCasePipe, SlicePipe, UpperCasePipe } from '@angular/common';
import { DatePipe, SlicePipe, UpperCasePipe } from '@angular/common';
import { Component, input, output, signal } from '@angular/core';
import { RouterLink } from '@angular/router';
import { NgbCollapse } from '@ng-bootstrap/ng-bootstrap';
Expand All @@ -16,6 +16,7 @@ import { MathJaxDirective } from 'src/app/shared/math/math-jax.directive';
import { CourseCodeComponent } from 'src/app/shared/miscellaneous/course-code.component';
import { TeacherListComponent } from 'src/app/shared/user/teacher-list.component';
import { ActiveEnrolmentMenuComponent } from './helpers/active-enrolment-menu.component';
import { OptionalSectionsComponent } from './helpers/optional-sections.component';

@Component({
selector: 'xm-active-enrolment',
Expand All @@ -26,10 +27,10 @@ import { ActiveEnrolmentMenuComponent } from './helpers/active-enrolment-menu.co
ActiveEnrolmentMenuComponent,
CourseCodeComponent,
TeacherListComponent,
OptionalSectionsComponent,
NgbCollapse,
MathJaxDirective,
UpperCasePipe,
LowerCasePipe,
SlicePipe,
DatePipe,
TranslateModule,
Expand All @@ -43,7 +44,6 @@ export class ActiveEnrolmentComponent {

showGuide = signal(false);
showInstructions = signal(false);
showMaterials = signal(false);

constructor(
private translate: TranslateService,
Expand Down
105 changes: 105 additions & 0 deletions ui/src/app/enrolment/active/helpers/optional-sections.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// SPDX-FileCopyrightText: 2024 The members of the EXAM Consortium
//
// SPDX-License-Identifier: EUPL-1.2

import { LowerCasePipe, UpperCasePipe } from '@angular/common';
import { Component, input, signal } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { ExamSection } from 'src/app/exam/exam.model';

@Component({
selector: 'xm-optional-sections',
standalone: true,
imports: [TranslateModule, LowerCasePipe, UpperCasePipe],
template: `<div class="row mt-2 enrollment-card-dropdown">
<div class="col col-md-12">
<button
class="btn btn-outline-secondary"
(click)="showSections.set(!showSections())"
(keydown.enter)="showSections.set(!showSections())"
[attr.aria-expanded]="showSections()"
>
{{ 'i18n_selected_sections' | translate }}
<img class="arrow_icon" [hidden]="showSections()" alt="" src="/assets/images/arrow_right.png" />
<img class="arrow_icon" [hidden]="!showSections()" alt="" src="/assets/images/arrow_down.png" />
</button>
<div class="pt-2" [hidden]="!showSections">
@for (section of allSections(); track section.id) {
<div class="mb-3">
@if (section.optional === false) {
<div class="row">
<div class="col">
<strong
>{{ 'i18n_exam_section' | translate }}
<small class="text text-danger"
>({{ 'i18n_required' | translate | lowercase }})</small
>:</strong
>
{{ section.name }}
</div>
</div>
<div class="row">
<div class="col">
{{ section.description }}
</div>
</div>
}
</div>
}
@for (section of selectedSections(); track section.id) {
<div class="mb-3">
<div class="row">
<div class="col">
<strong
>{{ 'i18n_exam_section' | translate }}
<small class="text text-success"
>({{ 'i18n_optional' | translate | lowercase }})</small
>:</strong
>
{{ section.name }}
</div>
</div>
<div class="row">
<div class="col">
{{ section.description }}
</div>
</div>
@if (section.examMaterials.length > 0) {
<div>
<div class="row">
<div class="col">
<strong>{{ 'i18n_exam_materials' | translate }}</strong>
</div>
</div>
@for (material of section.examMaterials; track material.id) {
<div>
<div class="row">
<span class="col">
{{ 'i18n_name' | translate | uppercase }}: {{ material.name }}
@if (material.author) {
<span>
{{ 'i18n_author' | translate | uppercase }}:
{{ material.author }}
</span>
}
@if (material.isbn) {
<span> ISBN: {{ material.isbn }} </span>
}
</span>
</div>
</div>
}
</div>
}
</div>
}
</div>
</div>
</div>`,
})
export class OptionalSectionsComponent {
allSections = input.required<ExamSection[]>();
selectedSections = input.required<ExamSection[]>();
showSections = signal(false);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Component, input, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
import { Exam } from 'src/app/exam/exam.model';
import { CollaborativeExamOwnerSelectorComponent } from './collaborative-exam-owner-picker.component';
import { ExamParticipantSelectorComponent } from './exam-participant-picker.component';
import { ExamPreParticipantSelectorComponent } from './exam-pre-participant-picker.component';
import { OrganisationSelectorComponent } from './organisation-picker.component';

@Component({
standalone: true,
imports: [
FormsModule,
NgbPopoverModule,
TranslateModule,
ExamParticipantSelectorComponent,
ExamPreParticipantSelectorComponent,
CollaborativeExamOwnerSelectorComponent,
OrganisationSelectorComponent,
],
selector: 'xm-exam-publication-participants',
template: `
@if (!collaborative()) {
<div class="row mt-2">
<div class="col-md-3">
{{ 'i18n_exam_add_participants_title' | translate }}
</div>
<div class="col-md-9 participant-selector-toggle">
<label>
<input
type="radio"
[ngModel]="visibleParticipantSelector()"
(ngModelChange)="visibleParticipantSelector.set($event)"
value="participant"
/>
{{ 'i18n_exam_participant_selector_label' | translate }}
<sup
ngbPopover="{{ 'i18n_exam_participants_description' | translate }}"
popoverTitle="{{ 'i18n_instructions' | translate }}"
triggers="mouseenter:mouseleave"
><img src="/assets/images/icon_tooltip.svg" alt=""
/></sup>
</label>
<label class="ms-2">
<input
type="radio"
[ngModel]="visibleParticipantSelector()"
(ngModelChange)="visibleParticipantSelector.set($event)"
value="pre-participant"
/>
{{ 'i18n_exam_pre_participant_selector_label' | translate }}
<sup
ngbPopover="{{ 'i18n_exam_pre_participants_description' | translate }}"
popoverTitle="{{ 'i18n_instructions' | translate }}"
triggers="mouseenter:mouseleave"
><img src="/assets/images/icon_tooltip.svg" alt=""
/></sup>
</label>
</div>
</div>
}
<!-- Exam participants -->
@if (visibleParticipantSelector() === 'participant') {
<xm-exam-participant-selector [exam]="exam()"></xm-exam-participant-selector>
}
<!-- Exam pre-participants -->
@if (visibleParticipantSelector() === 'pre-participant') {
<xm-exam-pre-participant-selector [exam]="exam()"></xm-exam-pre-participant-selector>
}
@if (collaborative()) {
<xm-collaborative-exam-owner-selector [exam]="exam()"> </xm-collaborative-exam-owner-selector>
<xm-exam-organisation-selector [exam]="exam()"></xm-exam-organisation-selector>
}
`,
})
export class ExamPublicationParticipantsComponent {
collaborative = input(false);
exam = input.required<Exam>();
visibleParticipantSelector = signal('participant');
}
Loading

0 comments on commit d76da86

Please sign in to comment.