DataSet detail view

This commit is contained in:
2022-12-21 19:30:24 +01:00
parent 0f28e18ed2
commit 83848f05f3
6 changed files with 122 additions and 21 deletions

View File

@@ -1 +1,50 @@
<p>data-set-detail works!</p>
<div>
<form [formGroup]="form" novalidate>
<mat-card appearance="outlined">
<mat-toolbar color="secondary">
Szczegóły warstwy danych
</mat-toolbar>
<mat-card-content>
<mat-grid-list cols="2" rowHeight="90px">
<mat-grid-tile>
<mat-form-field class="detail-input">
<mat-label>Nazwa</mat-label>
<input matInput formControlName="name">
</mat-form-field>
</mat-grid-tile>
<mat-grid-tile>
<mat-form-field class="detail-input">
<input matInput formControlName="source">
</mat-form-field>
</mat-grid-tile>
</mat-grid-list>
<mat-table #table [dataSource]="dataSource" [trackBy]="trackByUid" matSort class="animate">
<ng-container matColumnDef="code">
<mat-header-cell *matHeaderCellDef mat-sort-header>MPK</mat-header-cell>
<mat-cell *matCellDef="let item">{{item.code}}</mat-cell>
</ng-container>
<ng-container matColumnDef="desc1">
<mat-header-cell *matHeaderCellDef mat-sort-header>Konto</mat-header-cell>
<mat-cell *matCellDef="let item">{{item.desc1}}</mat-cell>
</ng-container>
<ng-container matColumnDef="value">
<mat-header-cell *matHeaderCellDef mat-sort-header>Wartość</mat-header-cell>
<mat-cell *matCellDef="let item" align="right">{{item.value | number:'1.2-2'}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let item; columns: displayedColumns;"></mat-row>
</mat-table>
<mat-paginator #paginator
[pageSize]="50"
[pageSizeOptions]="[5, 10, 20]">
</mat-paginator>
</mat-card-content>
</mat-card>
</form>
</div>

View File

@@ -0,0 +1 @@
@import "../../../main-view/main-view.component.scss";

View File

@@ -1,4 +1,15 @@
import { Component } from '@angular/core';
import { DataSource } from '@angular/cdk/collections';
import { HttpClient } from '@angular/common/http';
import { Component, ViewChild } from '@angular/core';
import { UntypedFormGroup, UntypedFormBuilder } from '@angular/forms';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { Router, ActivatedRoute } from '@angular/router';
import moment from 'moment';
import { AuthService } from 'src/app/auth/auth.service';
import { DataRow } from 'src/app/models/dataRow.model copy';
import { DataSet } from 'src/app/models/dataSet.model';
@Component({
selector: 'app-data-set-detail',
@@ -7,4 +18,36 @@ import { Component } from '@angular/core';
})
export class DataSetDetailComponent {
public form!: UntypedFormGroup;
private document!: DataSet;
displayedColumns = ['code', 'value', 'desc1'];
dataSource!: MatTableDataSource<DataRow>;
@ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort;
constructor(
private fb$: UntypedFormBuilder,
private router$: Router,
private http$: HttpClient,
private route$: ActivatedRoute,
private auth$: AuthService
) { }
async ngOnInit() {
this.form = DataSet.getForm(this.fb$);
this.document = await this.load();
this.dataSource = new MatTableDataSource<DataRow>(this.document.dataRows);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
this.document.fillForm(this.form);
this.form.disable();
}
private async load(): Promise<DataSet> {
return await DataSet.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$);
}
trackByUid(index : number, item : DataRow) {
return item.id;
}
}