Skip to content

Commit 3448c73

Browse files
Lectures: Replace guided mode with status bar edit and create view (#9655)
1 parent e3f72f1 commit 3448c73

36 files changed

+524
-972
lines changed

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ module.exports = {
105105
coverageThreshold: {
106106
global: {
107107
// TODO: in the future, the following values should increase to at least 90%
108-
statements: 87.78,
109-
branches: 73.93,
110-
functions: 82.47,
111-
lines: 87.83,
108+
statements: 87.81,
109+
branches: 73.97,
110+
functions: 82.50,
111+
lines: 87.86,
112112
},
113113
},
114114
coverageReporters: ['clover', 'json', 'lcov', 'text-summary'],

src/main/webapp/app/entities/attachment.model.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,4 @@ export class Attachment implements BaseEntity {
2020
lecture?: Lecture;
2121
exercise?: Exercise;
2222
attachmentUnit?: AttachmentUnit;
23-
24-
constructor() {}
2523
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ <h4 class="modal-title" jhiTranslate="artemisApp.lecture.dismissChangesModal.tit
1313
<ul>
1414
@if (hasUnsavedChangesInTitleSection) {
1515
<li>
16-
<span jhiTranslate="artemisApp.lecture.wizardMode.steps.titleStepTitle"></span>
16+
<span jhiTranslate="artemisApp.lecture.sections.title"></span>
1717
</li>
1818
}
1919
@if (hasUnsavedChangesInPeriodSection) {
2020
<li>
21-
<span jhiTranslate="artemisApp.lecture.wizardMode.steps.periodStepTitle"></span>
21+
<span jhiTranslate="artemisApp.lecture.sections.period"></span>
2222
</li>
2323
}
2424
</ul>

src/main/webapp/app/lecture/hasLectureUnsavedChanges.guard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { CanDeactivateFn } from '@angular/router';
33
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
44
import { LectureUpdateComponent } from 'app/lecture/lecture-update.component';
55
import { Observable, from, of } from 'rxjs';
6-
import { CloseEditLectureModalComponent } from 'app/lecture/close-edit-lecture-dialog/close-edit-lecture-modal.component';
6+
import { CloseEditLectureModalComponent } from 'app/lecture/close-edit-lecture-modal/close-edit-lecture-modal.component';
77

88
export const hasLectureUnsavedChangesGuard: CanDeactivateFn<LectureUpdateComponent> = (component: LectureUpdateComponent): Observable<boolean> => {
9-
if (!component.shouldDisplayDismissWarning || component.isShowingWizardMode) {
9+
if (!component.shouldDisplayDismissWarning) {
1010
return of(true);
1111
}
1212

src/main/webapp/app/lecture/lecture-attachments.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ export class LectureAttachmentsComponent implements OnDestroy {
7878
});
7979

8080
private readonly statusChanges = toSignal(this.form.statusChanges ?? 'INVALID');
81-
isFormValid = computed(() => this.statusChanges() === 'VALID' && this.isFileSelectionValid() && this.datePickerComponent()?.isValid());
81+
isFormValid = computed(
82+
() => !this.attachmentToBeUpdatedOrCreated() || (this.statusChanges() === 'VALID' && this.isFileSelectionValid() && this.datePickerComponent()?.isValid()),
83+
);
8284

8385
constructor() {
8486
effect(

src/main/webapp/app/lecture/lecture-period/lecture-period.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
2-
<h2 id="artemisApp.lecture.wizardMode.steps.periodStepTitle"><span jhiTranslate="artemisApp.lecture.wizardMode.steps.periodStepTitle"></span></h2>
3-
<p><span jhiTranslate="artemisApp.lecture.wizardMode.steps.periodStepMessage"></span></p>
2+
<h3 id="artemisApp.lecture.sections.period"><span jhiTranslate="artemisApp.lecture.sections.period"></span></h3>
3+
<p><span jhiTranslate="artemisApp.lecture.sections.periodDescription"></span></p>
44
<div class="d-flex">
55
<div class="form-group flex-grow-1">
66
<jhi-date-time-picker

src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/lecture-unit-management.component.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
1+
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, inject } from '@angular/core';
22
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
33
import { Lecture } from 'app/entities/lecture.model';
44
import { LectureService } from 'app/lecture/lecture.service';
@@ -24,6 +24,25 @@ import { IrisSettingsService } from 'app/iris/settings/shared/iris-settings.serv
2424
styleUrls: ['./lecture-unit-management.component.scss'],
2525
})
2626
export class LectureUnitManagementComponent implements OnInit, OnDestroy {
27+
protected readonly faTrash = faTrash;
28+
protected readonly faPencilAlt = faPencilAlt;
29+
protected readonly faEye = faEye;
30+
protected readonly faFileExport = faFileExport;
31+
protected readonly faRepeat = faRepeat;
32+
protected readonly faCheckCircle = faCheckCircle;
33+
protected readonly faSpinner = faSpinner;
34+
35+
protected readonly LectureUnitType = LectureUnitType;
36+
protected readonly ActionType = ActionType;
37+
38+
private readonly activatedRoute = inject(ActivatedRoute);
39+
private readonly router = inject(Router);
40+
private readonly lectureService = inject(LectureService);
41+
private readonly alertService = inject(AlertService);
42+
private readonly profileService = inject(ProfileService);
43+
private readonly irisSettingsService = inject(IrisSettingsService);
44+
protected readonly lectureUnitService = inject(LectureUnitService);
45+
2746
@Input() showCreationCard = true;
2847
@Input() showCompetencies = true;
2948
@Input() emitEditEvents = false;
@@ -39,14 +58,13 @@ export class LectureUnitManagementComponent implements OnInit, OnDestroy {
3958
updateOrderSubject: Subject<any>;
4059
viewButtonAvailable: Record<number, boolean> = {};
4160

42-
updateOrderSubjectSubscription: Subscription;
43-
navigationEndSubscription: Subscription;
61+
private updateOrderSubjectSubscription: Subscription;
62+
private navigationEndSubscription: Subscription;
63+
private activatedRouteSubscription?: Subscription;
64+
private profileInfoSubscription: Subscription;
4465

45-
readonly LectureUnitType = LectureUnitType;
46-
readonly ActionType = ActionType;
4766
private dialogErrorSource = new Subject<string>();
4867
dialogError$ = this.dialogErrorSource.asObservable();
49-
private profileInfoSubscription: Subscription;
5068
irisEnabled = false;
5169
lectureIngestionEnabled = false;
5270
routerEditLinksBase: { [key: string]: string } = {
@@ -56,40 +74,13 @@ export class LectureUnitManagementComponent implements OnInit, OnDestroy {
5674
[LectureUnitType.ONLINE]: 'online-units',
5775
};
5876

59-
// Icons
60-
readonly faTrash = faTrash;
61-
readonly faPencilAlt = faPencilAlt;
62-
readonly faEye = faEye;
63-
readonly faFileExport = faFileExport;
64-
readonly faRepeat = faRepeat;
65-
readonly faCheckCircle = faCheckCircle;
66-
readonly faSpinner = faSpinner;
67-
68-
constructor(
69-
private activatedRoute: ActivatedRoute,
70-
private router: Router,
71-
private lectureService: LectureService,
72-
private alertService: AlertService,
73-
public lectureUnitService: LectureUnitService,
74-
private profileService: ProfileService,
75-
private irisSettingsService: IrisSettingsService,
76-
) {}
77-
78-
ngOnDestroy(): void {
79-
this.updateOrder();
80-
this.updateOrderSubjectSubscription.unsubscribe();
81-
this.dialogErrorSource.unsubscribe();
82-
this.navigationEndSubscription.unsubscribe();
83-
this.profileInfoSubscription?.unsubscribe();
84-
}
85-
8677
ngOnInit(): void {
8778
this.navigationEndSubscription = this.router.events.pipe(filter((value) => value instanceof NavigationEnd)).subscribe(() => {
8879
this.loadData();
8980
});
9081

9182
this.updateOrderSubject = new Subject();
92-
this.activatedRoute.parent!.params.subscribe((params) => {
83+
this.activatedRouteSubscription = this.activatedRoute?.parent?.params.subscribe((params) => {
9384
this.lectureId ??= +params['lectureId'];
9485
if (this.lectureId) {
9586
// TODO: the lecture (without units) is already available through the lecture.route.ts resolver, it's not really good that we load it twice
@@ -103,6 +94,15 @@ export class LectureUnitManagementComponent implements OnInit, OnDestroy {
10394
});
10495
}
10596

97+
ngOnDestroy(): void {
98+
this.updateOrder();
99+
this.updateOrderSubjectSubscription.unsubscribe();
100+
this.dialogErrorSource.unsubscribe();
101+
this.navigationEndSubscription.unsubscribe();
102+
this.profileInfoSubscription?.unsubscribe();
103+
this.activatedRouteSubscription?.unsubscribe();
104+
}
105+
106106
loadData() {
107107
this.isLoading = true;
108108
// TODO: we actually would like to have the lecture with all units! Posts and competencies are not required here

src/main/webapp/app/lecture/wizard-mode/lecture-wizard-units.component.html renamed to src/main/webapp/app/lecture/lecture-units/lecture-units.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
2-
<h2><span jhiTranslate="artemisApp.lecture.wizardMode.steps.unitsStepTitle"></span></h2>
3-
<p><span jhiTranslate="artemisApp.lecture.wizardMode.steps.unitsStepMessage"></span></p>
2+
<h3><span jhiTranslate="artemisApp.lecture.sections.units"></span></h3>
3+
<p><span jhiTranslate="artemisApp.lecture.sections.unitsDescription"></span></p>
44
<jhi-lecture-unit-management
55
[lectureId]="this.lecture.id"
66
[emitEditEvents]="true"
@@ -15,9 +15,9 @@ <h2><span jhiTranslate="artemisApp.lecture.wizardMode.steps.unitsStepTitle"></sp
1515
} @else {
1616
<div class="form-group">
1717
@if (!isEditingLectureUnit) {
18-
<h4><span jhiTranslate="artemisApp.lecture.wizardMode.newLectureUnit"></span></h4>
18+
<h4><span jhiTranslate="artemisApp.lecture.newLectureUnit"></span></h4>
1919
} @else {
20-
<h4><span jhiTranslate="artemisApp.lecture.wizardMode.editLectureUnit"></span></h4>
20+
<h4><span jhiTranslate="artemisApp.lecture.editLectureUnit"></span></h4>
2121
}
2222
@if (isTextUnitFormOpen()) {
2323
<jhi-text-unit-form

src/main/webapp/app/lecture/wizard-mode/lecture-wizard-units.component.ts renamed to src/main/webapp/app/lecture/lecture-units/lecture-units.component.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { Component, Input, OnInit, ViewChild, computed, signal } from '@angular/core';
1+
import { Component, Input, OnInit, ViewChild, computed, signal, viewChild } from '@angular/core';
22
import { Lecture } from 'app/entities/lecture.model';
33
import { TextUnit } from 'app/entities/lecture-unit/textUnit.model';
44
import { VideoUnit } from 'app/entities/lecture-unit/videoUnit.model';
55
import { OnlineUnit } from 'app/entities/lecture-unit/onlineUnit.model';
66
import { AttachmentUnit } from 'app/entities/lecture-unit/attachmentUnit.model';
7-
import { TextUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/text-unit-form/text-unit-form.component';
8-
import { VideoUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component';
9-
import { OnlineUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/online-unit-form/online-unit-form.component';
10-
import { AttachmentUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component';
7+
import { TextUnitFormComponent, TextUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/text-unit-form/text-unit-form.component';
8+
import { VideoUnitFormComponent, VideoUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/video-unit-form/video-unit-form.component';
9+
import { OnlineUnitFormComponent, OnlineUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/online-unit-form/online-unit-form.component';
10+
import { AttachmentUnitFormComponent, AttachmentUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component';
1111
import { LectureUnit, LectureUnitType } from 'app/entities/lecture-unit/lectureUnit.model';
1212
import { onError } from 'app/shared/util/global.utils';
1313
import { Attachment, AttachmentType } from 'app/entities/attachment.model';
@@ -23,15 +23,27 @@ import dayjs from 'dayjs/esm';
2323
import { ActivatedRoute } from '@angular/router';
2424

2525
@Component({
26-
selector: 'jhi-lecture-update-wizard-units',
27-
templateUrl: './lecture-wizard-units.component.html',
26+
selector: 'jhi-lecture-update-units',
27+
templateUrl: './lecture-units.component.html',
2828
})
29-
export class LectureUpdateWizardUnitsComponent implements OnInit {
30-
@Input() currentStep: number;
29+
export class LectureUpdateUnitsComponent implements OnInit {
3130
@Input() lecture: Lecture;
3231

3332
@ViewChild(LectureUnitManagementComponent, { static: false }) unitManagementComponent: LectureUnitManagementComponent;
3433

34+
textUnitForm = viewChild(TextUnitFormComponent);
35+
videoUnitForm = viewChild(VideoUnitFormComponent);
36+
onlineUnitForm = viewChild(OnlineUnitFormComponent);
37+
attachmentUnitForm = viewChild(AttachmentUnitFormComponent);
38+
isUnitConfigurationValid = computed(() => {
39+
return (
40+
(this.textUnitForm()?.isFormValid() || !this.isTextUnitFormOpen()) &&
41+
(this.videoUnitForm()?.isFormValid() || !this.isVideoUnitFormOpen()) &&
42+
(this.onlineUnitForm()?.isFormValid() || !this.isOnlineUnitFormOpen()) &&
43+
(this.attachmentUnitForm()?.isFormValid() || !this.isAttachmentUnitFormOpen())
44+
);
45+
});
46+
3547
isEditingLectureUnit: boolean;
3648
isTextUnitFormOpen = signal<boolean>(false);
3749
isExerciseUnitFormOpen = signal<boolean>(false);

0 commit comments

Comments
 (0)