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

[#12679] Solved the problem of space detection, and can prompt an error for illegal space input #13178

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, Input } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { StatusMessageService } from '../../../services/status-message.service';
import { Course } from '../../../types/api-output';
import { FEEDBACK_SESSION_NAME_MAX_LENGTH } from '../../../types/field-validator';

Expand All @@ -25,12 +26,23 @@ export class CopySessionModalComponent {
newFeedbackSessionName: string = '';
copyToCourseSet: Set<string> = new Set<string>();

constructor(public activeModal: NgbActiveModal) {}
constructor(public activeModal: NgbActiveModal, private statusMessageService: StatusMessageService) {}

/**
* Fires the copy event.
*/
copy(): void {
if (this.newFeedbackSessionName.trim().length === 0) {
this.statusMessageService.showErrorToast('The field "Name for copied session" should not be whitespace.');
return;
}
if (this.newFeedbackSessionName.length > this.FEEDBACK_SESSION_NAME_MAX_LENGTH) {
this.statusMessageService.showErrorToast(
`The field "Name for copied session" should less than ${this.FEEDBACK_SESSION_NAME_MAX_LENGTH}.`,
);
return;
}

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