Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
u7861723 committed Oct 11, 2024
1 parent 6d4f9f4 commit 2d0ae16
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ <h5 class="modal-title">
<div class="col-12">
<div class="form-group">
<label><b>Name for copied session*</b></label>
<input id="copy-session-name" type="text" class="form-control" [(ngModel)]="newFeedbackSessionName" [maxlength]="FEEDBACK_SESSION_NAME_MAX_LENGTH"
<input id="copy-session-name" type="text" class="form-control" [(ngModel)]="newFeedbackSessionName" (ngModelChange)="onNameChange()" [maxlength]="FEEDBACK_SESSION_NAME_MAX_LENGTH"
required #newSessionName="ngModel">
<div *ngIf="errorMessage" class="text-danger">
{{ errorMessage }}
</div>
<div [hidden]="newSessionName.valid || (newSessionName.pristine && newSessionName.untouched)" class="invalid-field">
<i class="fa fa-exclamation-circle" aria-hidden="true"></i>
The field "Name for copied session" should not be empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,25 @@ export class CopySessionModalComponent {
newFeedbackSessionName: string = '';
copyToCourseSet: Set<string> = new Set<string>();

errorMessage: string = '';

constructor(public activeModal: NgbActiveModal) {}

onNameChange(): void {
this.errorMessage = '';
}

/**
* Fires the copy event.
*/
copy(): void {
if (this.newFeedbackSessionName.trim().length === 0) {
this.errorMessage = "The field \"Name for copied session\" should not be whitespace.";
return;
}

this.errorMessage = '';

this.activeModal.close({
newFeedbackSessionName: this.newFeedbackSessionName,
sessionToCopyCourseId: this.sessionToCopyCourseId,
Expand Down

0 comments on commit 2d0ae16

Please sign in to comment.