diff --git a/src/web/app/components/question-submission-form/question-submission-form.component.html b/src/web/app/components/question-submission-form/question-submission-form.component.html
index e2d079b9840..66fd3283571 100644
--- a/src/web/app/components/question-submission-form/question-submission-form.component.html
+++ b/src/web/app/components/question-submission-form/question-submission-form.component.html
@@ -70,19 +70,28 @@
Question {{ model.questionNumber }}: {{ mode
{{ getRecipientName(recipientSubmissionFormModel.recipientIdentifier) }} ({{ model.recipientType | recipientTypeName:model.giverType }})
-
+ [attr.aria-label]="'Select recipient input question ' + model.questionNumber + ' index ' + i"
+ placeholder="Type to search..." />
({{ model.recipientType | recipientTypeName: model.giverType }})
+ 0 && dropdownVisible[i]" class="dropdown-menu evaluee-select show">
+
+ {{ getSelectionOptionLabel(recipient) }}
+
+
{
fixture.detectChanges();
expect(component.isSavedForRecipient('recipientId')).toBeTruthy();
});
+
+ it('filterRecipients: should filter recipient list in the dropdown list and update dropdown visibility', () => {
+
+ const value = 'alex';
+ const index = 0;
+
+ component.model.recipientList = [
+ { recipientIdentifier: '0', recipientName: 'Alice Betsy' },
+ { recipientIdentifier: '1', recipientName: 'Benny Charles' },
+ { recipientIdentifier: '2', recipientName: 'Group 2 | Tutorial 13 | Alex Kim' },
+ { recipientIdentifier: '3', recipientName: 'Lecture #1 @ Room A | Jason Doe' },
+ { recipientIdentifier: '4', recipientName: 'Lab Session *10* | Annie K. & John L.' },
+ { recipientIdentifier: '5', recipientName: 'Group 3: Research Team | Dr. Alex Smith' },
+ ];
+
+ component.getSelectionOptionLabel = (recipient: any) => recipient.recipientName;
+ component.filterRecipients(value, index);
+
+ expect(component.filteredRecipients[index].length).toBe(2);
+ expect(component.filteredRecipients[index][0].recipientName).toBe('Group 2 | Tutorial 13 | Alex Kim');
+ expect(component.filteredRecipients[index][1].recipientName).toBe('Group 3: Research Team | Dr. Alex Smith');
+
+ expect(component.dropdownVisible[index]).toBe(true);
+ });
+
+ it('filterRecipients: should filter the list with no results, hiding the dropdown', () => {
+
+ const value = 'alice';
+ const index = 0;
+
+ component.model.recipientList = [
+ { recipientIdentifier: '0', recipientName: 'Matty Betsy' },
+ { recipientIdentifier: '1', recipientName: 'Benny Charles' },
+ ];
+
+ component.getSelectionOptionLabel = (recipient: any) => recipient.recipientName;
+ component.filterRecipients(value, index);
+ expect(component.filteredRecipients[index].length).toBe(0);
+ expect(component.filteredRecipients[index][0]).toBeUndefined();
+
+ expect(component.dropdownVisible[index]).toBe(false);
+ });
+
});
diff --git a/src/web/app/components/question-submission-form/question-submission-form.component.ts b/src/web/app/components/question-submission-form/question-submission-form.component.ts
index 59d83d25227..2633530bc56 100644
--- a/src/web/app/components/question-submission-form/question-submission-form.component.ts
+++ b/src/web/app/components/question-submission-form/question-submission-form.component.ts
@@ -58,6 +58,9 @@ export class QuestionSubmissionFormComponent implements DoCheck {
isMCQDropDownEnabled: boolean = false;
isSaved: boolean = false;
hasResponseChanged: boolean = false;
+ dropdownVisible: boolean[] = [];
+ filteredRecipients: any[][] = [];
+ displayedRecipientName: string[] = [];
@Input()
formMode: QuestionSubmissionFormMode = QuestionSubmissionFormMode.FIXED_RECIPIENT;
@@ -595,4 +598,52 @@ export class QuestionSubmissionFormComponent implements DoCheck {
return false;
}
}
+
+ /**
+ * Filters the recipient list by input value and updates the filtered recipients array at the given index.
+ */
+ filterRecipients(value: string, index: number): void {
+
+ this.filteredRecipients[index] = this.model.recipientList.filter((recipient) =>
+ this.getSelectionOptionLabel(recipient).toLowerCase().includes(value.toLowerCase()),
+ );
+ this.dropdownVisible[index] = this.filteredRecipients[index].length > 0;
+ }
+
+ /**
+ * Sets the dropdown visibility to true for the specified recipient index.
+ */
+ showDropdown(index: number): void {
+ this.dropdownVisible[index] = true;
+ }
+
+ /**
+ * Hides the dropdown for the specified recipient index after a short delay.
+ */
+ hideDropdown(index: number): void {
+ setTimeout(() => {
+ this.dropdownVisible[index] = false;
+ }, 100);
+ }
+
+ /**
+ * Updates the recipient selection in the form model and sets the displayed name for the selected recipient.
+ */
+ selectRecipient(recipient: any, recipientSubmissionFormModel: any, index: number): void {
+ recipientSubmissionFormModel.recipientIdentifier = recipient.recipientIdentifier;
+ this.displayedRecipientName[index] = recipient.recipientName;
+ this.filteredRecipients[index] = [];
+ this.dropdownVisible[index] = false;
+ }
+
+ /**
+ * Gets recipient name in {@code FIXED_RECIPIENT} mode.
+ * Origin from getRecipientName
+ */
+ getRecipientNameForInput(recipientIdentifier: string): string {
+ const recipient: FeedbackResponseRecipient | undefined =
+ this.model.recipientList.find(
+ (r: FeedbackResponseRecipient) => r.recipientIdentifier === recipientIdentifier);
+ return recipient ? recipient.recipientName : '';
+ }
}