Added person selector in webapp.
This commit is contained in:
parent
cd5779a498
commit
51c946243b
@ -0,0 +1,47 @@
|
||||
<div class="loadingWrapper">
|
||||
<div class="loadingOverlay" *ngIf="dataSource.loading$ | async">
|
||||
<mat-spinner class="loadingSpinner"></mat-spinner>
|
||||
</div>
|
||||
<div class="mat-elevation-z2">
|
||||
<table mat-table [dataSource]="dataSource">
|
||||
|
||||
<ng-container matColumnDef="lp">
|
||||
<th mat-header-cell *matHeaderCellDef>L.p.</th>
|
||||
<td mat-cell *matCellDef="let element" class="mat-cell"> {{getElementNumber(element)}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="id">
|
||||
<th mat-header-cell *matHeaderCellDef>Id</th>
|
||||
<td mat-cell *matCellDef="let element" class="mat-cell"> {{element.id}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef>Imię</th>
|
||||
<td mat-cell *matCellDef="let element" class="mat-cell"> {{element.name}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="surname">
|
||||
<th mat-header-cell *matHeaderCellDef>Nazwisko</th>
|
||||
<td mat-cell *matCellDef="let element" class="mat-cell"> {{element.surname}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="index">
|
||||
<th mat-header-cell *matHeaderCellDef>Indeks</th>
|
||||
<td mat-cell *matCellDef="let element" class="mat-cell"> {{element?.student?.index}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="select">
|
||||
<th mat-header-cell *matHeaderCellDef>Wybierz</th>
|
||||
<td mat-cell *matCellDef="let element" class="mat-cell">
|
||||
<button type="button" mat-icon-button (click)="select(element)">
|
||||
<mat-icon>check</mat-icon>
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="getDisplayedColumns()"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: getDisplayedColumns();"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<button mat-button type="button" (click)="dialogRef.close()">Anuluj</button>
|
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PersonSelectorComponent } from './person-selector.component';
|
||||
|
||||
describe('PersonSelectorComponent', () => {
|
||||
let component: PersonSelectorComponent;
|
||||
let fixture: ComponentFixture<PersonSelectorComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ PersonSelectorComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(PersonSelectorComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,36 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {Person} from "../../../model/person";
|
||||
import {MatDialogRef} from "@angular/material/dialog";
|
||||
import {BasicDataSource} from "../../../dataSource/basic-data-source";
|
||||
import {AbstractListComponent} from "../../abstract-list.component";
|
||||
import {PersonService} from "../../../service/person.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-selector',
|
||||
templateUrl: './person-selector.component.html',
|
||||
styleUrls: ['./person-selector.component.sass']
|
||||
})
|
||||
export class PersonSelectorComponent extends AbstractListComponent<Person, number>{
|
||||
|
||||
dataSource: BasicDataSource<Person, number>;
|
||||
displayedColumns: Map<string, boolean> = new Map<string, boolean>([
|
||||
['lp', true],
|
||||
['id', true],
|
||||
['name', true],
|
||||
['surname', true],
|
||||
['index', true],
|
||||
['select', true],
|
||||
]);
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<PersonSelectorComponent>,
|
||||
private personService: PersonService
|
||||
) {
|
||||
super();
|
||||
this.dataSource = new BasicDataSource<Person, number>(personService);
|
||||
}
|
||||
|
||||
select(person: Person) {
|
||||
this.dialogRef.close(person);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user