Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lectures: Improve lecture attachment validation #9893

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add visual indicator if fileInput is invalid
florian-glombik committed Nov 28, 2024
commit 7268f38a6cdc4902718c0535fd4ccfdaf9d070c1
Original file line number Diff line number Diff line change
@@ -164,6 +164,8 @@ <h4 jhiTranslate="artemisApp.lecture.attachments.editAttachment"></h4>
[accept]="acceptedFileExtensionsFileBrowser"
[placeholder]="'artemisApp.lecture.attachments.chooseFile' | artemisTranslate"
(change)="setLectureAttachment($event)"
[class.ng-invalid]="!isFileSelectionValid()"
[class.invalid-file-input-margin]="!isFileSelectionValid()"
aria-describedby="fileHelp"
/>
</div>
Original file line number Diff line number Diff line change
@@ -21,3 +21,7 @@
pointer-events: none;
cursor: default;
}

.invalid-file-input-margin {
padding-left: 0.5em;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ElementRef, OnDestroy, ViewChild, effect, inject, input, signal } from '@angular/core';
import { Component, ElementRef, OnDestroy, ViewChild, computed, effect, inject, input, signal } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { Lecture } from 'app/entities/lecture.model';
@@ -53,6 +53,10 @@ export class LectureAttachmentsComponent implements OnDestroy {

private routeDataSubscription?: Subscription;

isFileSelectionValid = computed(() => {
return this.attachmentFile() || this.attachmentToBeUpdatedOrCreated()?.link;
});

constructor() {
effect(
() => {