-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
95 change genre and subgenre labels to select (#109)
* create select input component * add test on selection change * improved user interface for the select * navigate using the select box * correct ci linter
- Loading branch information
Showing
9 changed files
with
119 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
frontend/src/app/components/select-input/select-input.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<select [(ngModel)]="selectedElement" (change)="onSelectChange()"> | ||
<option value="" disabled selected>{{placeHolder}}</option> | ||
<option *ngFor="let element of elements" [value]="element">{{ element }}</option> | ||
</select> |
5 changes: 5 additions & 0 deletions
5
frontend/src/app/components/select-input/select-input.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
select{ | ||
border-color: var(--borderColor); | ||
background-color: var(--backgroundColor); | ||
color: var(--textColor); | ||
} |
35 changes: 35 additions & 0 deletions
35
frontend/src/app/components/select-input/select-input.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SelectInputComponent } from './select-input.component'; | ||
|
||
describe('SelectInputComponent', () => { | ||
let component: SelectInputComponent; | ||
let fixture: ComponentFixture<SelectInputComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SelectInputComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SelectInputComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should emit petChange when a new pet is selected', () => { | ||
//Arrange | ||
spyOn(component.selectChange, 'emit'); | ||
|
||
//Act | ||
component.selectedElement = 'gabber'; | ||
component.onSelectChange(); | ||
|
||
//Assert | ||
expect(component.selectChange.emit).toHaveBeenCalledWith('gabber'); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
frontend/src/app/components/select-input/select-input.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Component, EventEmitter, Input, Output} from '@angular/core'; | ||
import {FormsModule} from "@angular/forms"; | ||
import {NgForOf} from "@angular/common"; | ||
|
||
@Component({ | ||
selector: 'app-select-input', | ||
standalone: true, | ||
imports: [FormsModule, NgForOf], | ||
templateUrl: './select-input.component.html', | ||
styleUrl: './select-input.component.scss' | ||
}) | ||
export class SelectInputComponent { | ||
@Input() elements: string[] = []; | ||
@Input() selectedElement: string = ""; | ||
@Input() placeHolder: string = ""; | ||
@Output() selectChange = new EventEmitter<string>(); | ||
|
||
onSelectChange() { | ||
this.selectChange.emit(this.selectedElement); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters