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

[#12081] User-friendliness: Fix feedback path dropdown #12207

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ private void selectFeedbackPathDropdownOption(int questionNum, String text) {
WebElement feedbackPathPanel = questionForm.findElement(By.tagName("tm-feedback-path-panel"));
click(feedbackPathPanel.findElement(By.id("btn-feedback-path")));
WebElement dropdown = feedbackPathPanel.findElement(By.id("feedback-path-dropdown"));
List<WebElement> options = dropdown.findElements(By.className("dropdown-item"));
List<WebElement> options = dropdown.findElements(By.className("dropdown-button"));
for (WebElement option : options) {
if (option.getText().equals(text)) {
click(option);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,33 @@
<b class="feedback-path-title">Feedback Path</b> (Who is giving feedback about whom?)
</div>
<div ngbDropdown #mainMenu="ngbDropdown" class="margin-top-15px w-100" autoClose="outside">
<button id="btn-feedback-path" class="btn btn-light white-space-normal mw-100 overflow-scroll d-inline-block" ngbDropdownToggle [disabled]="!model.isEditable || commonFeedbackPaths.size === 1">
<span *ngIf="!model.isUsingOtherFeedbackPath">
<button id="btn-feedback-path" class="btn btn-light white-space-normal mw-100 overflow-scroll d-inline-block" ngbDropdownToggle
[disabled]="!model.isEditable || commonFeedbackPaths.size === 1" (click)="resetMenu()">
<span *ngIf="!model.isUsingOtherFeedbackPath" class="text-wrap">
{{ model.giverType | giverTypeDescription }} will give feedback on <i class="fas fa-arrow-right"></i> {{ model.recipientType | recipientTypeDescription }}
</span>
<span *ngIf="model.isUsingOtherFeedbackPath">Custom feedback path</span>
</button>
<ul id="feedback-path-dropdown" ngbDropdownMenu>
<li class="dropdown-header">Common feedback path combinations</li>
<li class="dropdown-item" *ngFor="let path of commonFeedbackPaths | keyvalue">
<div ngbDropdown #subMenu="ngbDropdown" placement="right" (mouseenter)="subMenu.open()" (mouseleave)="subMenu.close()">
<span ngbDropdownAnchor class="float-end invisible"></span>
{{ path.key | giverTypeDescription }} will give feedback on ... <i class="fas fa-caret-right"></i>
<ul ngbDropdownMenu>
<li class="dropdown-item" *ngFor="let recipient of path.value"
(click)="changeGiverRecipientType(path.key, recipient); mainMenu.close()">{{ recipient | recipientTypeDescription }}</li>
</ul>
<li *ngFor="let path of commonFeedbackPaths | keyvalue" ngbDropdown #subMenu="ngbDropdown">
<div class="text-wrap dropdown-item">
<button class="dropdown-button" (click)="toggleSubMenu(path.key)">
{{ path.key | giverTypeDescription }} will give feedback on ... <i class="fas fa-caret-{{ isSubMenuOpen(path.key) ? 'down' : 'right' }}"></i>
</button>
</div>
<ul *ngIf="isSubMenuOpen(path.key)">
<li class="text-wrap dropdown-item" *ngFor="let recipient of path.value">
<button class="dropdown-button" (click)="changeGiverRecipientType(path.key, recipient); mainMenu.close()">
{{ recipient | recipientTypeDescription }}
</button>
</li>
</ul>
</li>
<li class="dropdown-divider"></li>
<li class="dropdown-item" (click)="triggerCustomFeedbackPath(); mainMenu.close()">Custom feedback path...</li>
<li class="text-wrap dropdown-item">
<button class="dropdown-button" (click)="triggerCustomFeedbackPath(); mainMenu.close()">Custom feedback path...</button>
</li>
</ul>
</div>
<div class="row margin-top-15px" *ngIf="model.isUsingOtherFeedbackPath">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@
.dropdown-item {
cursor: pointer;
}

.dropdown-button {
border: none;
background: none;
width: 100%;
text-align: left;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export class FeedbackPathPanelComponent {
triggerModelChangeBatch: EventEmitter<Partial<QuestionEditFormModel>> =
new EventEmitter<Partial<QuestionEditFormModel>>();

subMenuStatuses: Map<FeedbackParticipantType, boolean> = new Map();

triggerCustomNumberOfEntities(data: number): void {
this.customNumberOfEntitiesToGiveFeedbackTo.emit(data);
}
Expand All @@ -95,6 +97,22 @@ export class FeedbackPathPanelComponent {
this.customFeedbackPath.emit(true);
}

toggleSubMenu(menu: FeedbackParticipantType): void {
this.subMenuStatuses.set(menu, !this.subMenuStatuses.get(menu));
}

resetMenu(): void {
this.subMenuStatuses.forEach((_, key) => this.subMenuStatuses.set(key, false));
}

isSubMenuOpen(menu: FeedbackParticipantType): boolean {
let subMenuState: boolean | undefined = this.subMenuStatuses.get(menu);
if (subMenuState === undefined) {
subMenuState = false;
}
return subMenuState;
}

/**
* Change the {@code giverType} and {@code recipientType} and reset the visibility settings.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ exports[`QuestionEditFormComponent should snap with default view 1`] = `
ngbdropdowntoggle=""
>
<span
class="text-wrap"
style=""
>
Students in this course will give feedback on
Expand All @@ -268,9 +269,13 @@ exports[`QuestionEditFormComponent should snap with default view 1`] = `
class="dropdown-divider"
/>
<li
class="dropdown-item"
class="text-wrap dropdown-item"
>
Custom feedback path...
<button
class="dropdown-button"
>
Custom feedback path...
</button>
</li>
</ul>
</div>
Expand Down
Loading