fixes
This commit is contained in:
@@ -12,6 +12,12 @@
|
||||
}
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input type="text" matInput formControlName="description" maxlength="255">
|
||||
<mat-hint>Zylinderlänge und co.</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Schließanlage</mat-label>
|
||||
<mat-select formControlName="system">
|
||||
|
||||
@@ -25,11 +25,12 @@ export class CreateCylinderComponent {
|
||||
|
||||
createForm = new FormGroup({
|
||||
name: new FormControl<string | null>(null, Validators.required),
|
||||
system: new FormControl<any>(null, Validators.required)
|
||||
system: new FormControl<any>(null, Validators.required),
|
||||
description: new FormControl<string | null>(null)
|
||||
});
|
||||
|
||||
ngOnInit() {
|
||||
this.api.getSystems().subscribe({
|
||||
this.api.systems.asObservable().subscribe({
|
||||
next: systems => {
|
||||
this.systems = systems;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { HELPER } from '../../shared/helper.service';
|
||||
import { GridApi, GridOptions, GridReadyEvent } from 'ag-grid-community';
|
||||
import { CellEditingStoppedEvent, GridApi, GridOptions, GridReadyEvent } from 'ag-grid-community';
|
||||
import { AgGridAngular } from 'ag-grid-angular';
|
||||
import { ApiService } from '../../shared/api.service';
|
||||
import { DatePipe } from '@angular/common';
|
||||
@@ -11,6 +11,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { AgGridContainerComponent } from '../../shared/ag-grid/components/ag-grid-container/ag-grid-container.component';
|
||||
import { CylinderArchiveComponent } from './components/cylinder-archive/cylinder-archive.component';
|
||||
import { ICylinder } from '../../model/interface/cylinder.interface';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cylinder',
|
||||
@@ -33,7 +34,8 @@ export class CylinderComponent extends AgGridContainerComponent {
|
||||
super();
|
||||
|
||||
this.gridOptions.columnDefs = [
|
||||
{ field: 'name', headerName: 'Name', sort: 'asc', flex: 1, filter: true },
|
||||
{ field: 'name', headerName: 'Name', sort: 'asc', flex: 1, filter: true, editable: true },
|
||||
{ field: 'description', headerName: 'Beschreibung', flex: 1, filter: true, editable: true },
|
||||
{ field: 'system.name', headerName: 'System', flex: 1, filter: true },
|
||||
{ field: 'keyCount', headerName: 'Anzahl Schlüssel', flex: 0, type: 'number' },
|
||||
{ field: 'createdAt', headerName: 'Angelegt', cellRenderer: (data: any) => data.value ? this.datePipe.transform(new Date(data.value)) : '-' },
|
||||
@@ -54,6 +56,7 @@ export class CylinderComponent extends AgGridContainerComponent {
|
||||
|
||||
onGridReady(params: GridReadyEvent) {
|
||||
this.gridApi = params.api;
|
||||
this.gridApi.addEventListener("cellEditingStopped", evt => this.cellEditEnd(evt));
|
||||
this.loadCylinders();
|
||||
this.api.cylinders.asObservable().subscribe({
|
||||
next: (data) => {
|
||||
@@ -63,6 +66,15 @@ export class CylinderComponent extends AgGridContainerComponent {
|
||||
})
|
||||
}
|
||||
|
||||
private async cellEditEnd(event: CellEditingStoppedEvent) {
|
||||
const cylinder: ICylinder = event.data;
|
||||
|
||||
if (!event.valueChanged || event.newValue == event.oldValue) { return; }
|
||||
|
||||
await this.api.updateCylinder(cylinder)
|
||||
|
||||
}
|
||||
|
||||
openCreateCylinder() {
|
||||
this.dialog.open(CreateCylinderComponent, {
|
||||
maxWidth: "calc(100vw - 24px)",
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
style="width: 100%; height: 100%;"
|
||||
(gridReady)="onGridReady($event)"
|
||||
[gridOptions]="gridOptions!"
|
||||
[theme]="myTheme"
|
||||
/>
|
||||
</div>
|
||||
</mat-dialog-content>
|
||||
|
||||
@@ -25,6 +25,7 @@ import { GridApi, GridOptions, GridReadyEvent } from 'ag-grid-community';
|
||||
import { AG_GRID_LOCALE_DE } from '@ag-grid-community/locale';
|
||||
import { AgGridAngular } from 'ag-grid-angular';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { AgGridContainerComponent } from '../../../../shared/ag-grid/components/ag-grid-container/ag-grid-container.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-handover-dialog',
|
||||
@@ -38,7 +39,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
templateUrl: './handover-dialog.component.html',
|
||||
styleUrl: './handover-dialog.component.scss'
|
||||
})
|
||||
export class HandoverDialogComponent {
|
||||
export class HandoverDialogComponent extends AgGridContainerComponent {
|
||||
|
||||
private api: ApiService = inject(ApiService);
|
||||
readonly dialogRef = inject(MatDialogRef<HandoverDialogComponent>);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
style="width: 100%; height: 100%;"
|
||||
(gridReady)="onGridReady($event)"
|
||||
[gridOptions]="gridOptions!"
|
||||
[theme]="myTheme"
|
||||
/>
|
||||
|
||||
</mat-dialog-content>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { GridApi, GridOptions, GridReadyEvent } from 'ag-grid-community';
|
||||
import { AG_GRID_LOCALE_DE } from '@ag-grid-community/locale';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { AgGridContainerComponent } from '../../../../shared/ag-grid/components/ag-grid-container/ag-grid-container.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-select-key-cylinder',
|
||||
@@ -14,7 +15,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
templateUrl: './select-key-cylinder.component.html',
|
||||
styleUrl: './select-key-cylinder.component.scss'
|
||||
})
|
||||
export class SelectKeyCylinderComponent {
|
||||
export class SelectKeyCylinderComponent extends AgGridContainerComponent {
|
||||
private toast: HotToastService = inject(HotToastService);
|
||||
readonly dialogRef = inject(MatDialogRef<SelectKeyCylinderComponent>);
|
||||
readonly cylinders = inject<ICylinder[]>(MAT_DIALOG_DATA);
|
||||
|
||||
@@ -149,7 +149,6 @@ export class KeysComponent extends AgGridContainerComponent {
|
||||
this.gridApi.addEventListener("cellEditingStopped", evt => this.cellEditEnd(evt));
|
||||
this.api.keys.asObservable().subscribe({
|
||||
next: keys => {
|
||||
console.log(keys)
|
||||
this.gridApi.setGridOption("rowData", keys);
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export class SystemComponent extends AgGridContainerComponent {
|
||||
super();
|
||||
this.gridOptions.columnDefs = [
|
||||
{ colId: 'name', field: 'name', headerName: 'Name', sort: 'asc', flex: 1},
|
||||
{ colId: 'cylinderCount', field: 'cylinders', headerName: 'Zylinderanzahl', flex: 0, cellRenderer: (data: any) => data.value.length},
|
||||
{ colId: 'cylinderCount', field: 'cylinders', headerName: 'Zylinderanzahl', flex: 0, cellRenderer: (data: any) => data.value?.length || 0},
|
||||
{ field: 'createdAt', headerName: 'Angelegt', cellRenderer: (data: any) => data.value ? this.datePipe.transform(new Date(data.value)) : '-' },
|
||||
{ field: 'updatedAt', headerName: 'Upgedated', cellRenderer: (data: any) => data.value ? this.datePipe.transform(new Date(data.value)) : '-' },
|
||||
{
|
||||
@@ -43,17 +43,20 @@ export class SystemComponent extends AgGridContainerComponent {
|
||||
];
|
||||
}
|
||||
|
||||
loadSystems() {
|
||||
this.api.getSystems().subscribe({
|
||||
next: n => {
|
||||
this.gridApi.setGridOption("rowData", n);
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
}
|
||||
})
|
||||
async loadSystems() {
|
||||
this.gridApi.setGridOption("loading", true);
|
||||
await this.api.refreshSystems();
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
}
|
||||
|
||||
onGridReady(params: GridReadyEvent) {
|
||||
this.gridApi = params.api;
|
||||
this.api.systems.asObservable().subscribe({
|
||||
next: systems => {
|
||||
this.gridApi.setGridOption("rowData", systems);
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
}
|
||||
})
|
||||
this.loadSystems();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user