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

Communication: Add FAQ search bar #9423

Merged
merged 13 commits into from
Oct 12, 2024
Merged
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div>
<div class="input-group mb-2 rounded-3 p-2 me-2 module-bg" style="display: flex; justify-content: end">
<div class="me-2" aria-label="Filter Dropdown" ngbDropdown>
<div class="input-group mb-2 rounded-3 p-2 me-2 module-bg d-flex justify-content-between">
<jhi-search class="flex-grow-1" (newSearchEvent)="setSearchValue($event)" />
cremertim marked this conversation as resolved.
Show resolved Hide resolved
<div class="ms-2 me-2" aria-label="Filter Dropdown" ngbDropdown>
cremertim marked this conversation as resolved.
Show resolved Hide resolved
<button class="btn" [ngClass]="{ 'btn-secondary': activeFilters.size === 0, 'btn-success': activeFilters.size > 0 }" ngbDropdownToggle id="filter-dropdown-button">
<fa-icon [icon]="faFilter" />
<span class="d-s-none d-md-inline" jhiTranslate="artemisApp.courseOverview.exerciseList.filter" [translateValues]="{ num: activeFilters.size }"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { map } from 'rxjs/operators';
import { Subject, Subscription } from 'rxjs';
import { faFilter } from '@fortawesome/free-solid-svg-icons';
import { ButtonType } from 'app/shared/components/button.component';
import { SidebarData } from 'app/types/sidebar';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { CourseFaqAccordionComponent } from 'app/overview/course-faq/course-faq-accordion-component';
Expand All @@ -16,14 +15,15 @@ import { FaqCategory } from 'app/entities/faq-category.model';
import { loadCourseFaqCategories } from 'app/faq/faq.utils';
import { CustomExerciseCategoryBadgeComponent } from 'app/shared/exercise-categories/custom-exercise-category-badge/custom-exercise-category-badge.component';
import { onError } from 'app/shared/util/global.utils';
import { SearchComponent } from 'app/shared/search/search.component';

@Component({
selector: 'jhi-course-faq',
templateUrl: './course-faq.component.html',
styleUrls: ['../course-overview.scss', 'course-faq.component.scss'],
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [ArtemisSharedComponentModule, ArtemisSharedModule, CourseFaqAccordionComponent, CustomExerciseCategoryBadgeComponent],
imports: [ArtemisSharedComponentModule, ArtemisSharedModule, CourseFaqAccordionComponent, CustomExerciseCategoryBadgeComponent, SearchComponent],
})
export class CourseFaqComponent implements OnInit, OnDestroy {
private ngUnsubscribe = new Subject<void>();
Expand All @@ -36,10 +36,11 @@ export class CourseFaqComponent implements OnInit, OnDestroy {
existingCategories: FaqCategory[];
activeFilters = new Set<string>();

sidebarData: SidebarData;
hasCategories = false;
isCollapsed = false;

searchValue = '';

readonly ButtonType = ButtonType;

// Icons
Expand Down Expand Up @@ -92,4 +93,8 @@ export class CourseFaqComponent implements OnInit, OnDestroy {
private applyFilters(): void {
this.filteredFaqs = this.faqService.applyFilters(this.activeFilters, this.faqs);
}

setSearchValue(searchValue: string) {
this.searchValue = searchValue;
}
cremertim marked this conversation as resolved.
Show resolved Hide resolved
}
19 changes: 19 additions & 0 deletions src/main/webapp/app/shared/search/search.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<form [formGroup]="filterForm">
<div class="input-group rounded-3">
<input
id="search"
type="text"
class="form-control rounded-3 border"
formControlName="searchFilter"
placeholder="{{ 'artemisApp.course.exercise.search.searchPlaceholder' | artemisTranslate }}"
aria-label="Search Field"
aria-describedby="search-field"
(keyup)="setSearchValue(filterForm.value.searchFilter)"
/>
cremertim marked this conversation as resolved.
Show resolved Hide resolved
<div class="position-relative my-auto mn-icon-field">
<button class="btn btn-primary btn-md ms-3" (click)="applySearch(this.searchValue)">
<fa-icon [icon]="faMagnifyingGlass" />
</button>
</div>
</div>
</form>
cremertim marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions src/main/webapp/app/shared/search/search.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.mn-icon-field {
margin-left: -3.5rem !important;
z-index: 10;
}
31 changes: 31 additions & 0 deletions src/main/webapp/app/shared/search/search.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Component, output } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { faMagnifyingGlass, faTimes } from '@fortawesome/free-solid-svg-icons';
cremertim marked this conversation as resolved.
Show resolved Hide resolved

@Component({
selector: 'jhi-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.scss'],
standalone: true,
imports: [ReactiveFormsModule, ArtemisSharedModule],
})
export class SearchComponent {
faMagnifyingGlass = faMagnifyingGlass;
faTimes = faTimes;

searchValue: string;
newSearchEvent = output<string>();
cremertim marked this conversation as resolved.
Show resolved Hide resolved

filterForm: FormGroup = new FormGroup({
searchFilter: new FormControl<string>(''),
});

setSearchValue(searchValue: string) {
this.searchValue = searchValue;
}
cremertim marked this conversation as resolved.
Show resolved Hide resolved

applySearch(searchValue: string) {
this.newSearchEvent.emit(searchValue);
}
cremertim marked this conversation as resolved.
Show resolved Hide resolved
}
Loading