Multicylinders
This commit is contained in:
@@ -14,6 +14,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
import { ArchiveComponent } from './components/archive/archive.component';
|
||||
import { AgLoadingComponent } from '../../shared/ag-grid/components/ag-loading/ag-loading.component';
|
||||
import { map, of } from 'rxjs';
|
||||
import { ICylinder } from '../../model/interface/cylinder.interface';
|
||||
|
||||
@Component({
|
||||
selector: 'app-keys',
|
||||
@@ -40,18 +41,21 @@ export class KeysComponent {
|
||||
|
||||
{ colId: 'name', field: 'name' , headerName: 'Name', flex: 1, editable: true, sort: 'asc', filter: true },
|
||||
{ colId: 'nr', field: 'nr' , headerName: 'Schlüsselnummer', flex: 1, editable: true, filter: true },
|
||||
{ colId: 'cylinder', field: 'cylinder' , headerName: 'Zylinder', flex: 1, editable: true, filter: true, cellRenderer: (data: any) => {return data.value?.name}, cellEditor: 'agSelectCellEditor',
|
||||
cellEditorParams: () => {
|
||||
return {
|
||||
values: this.cylinders,
|
||||
}
|
||||
},
|
||||
valueFormatter: (val) => {
|
||||
return val.value?.name + ` (${val.value?.system?.name})`;
|
||||
},
|
||||
{ colId: 'cylinder', field: 'cylinder' , headerName: 'Zylinder', flex: 1, editable: false, filter: true, cellRenderer: (data: any) => {return data.value?.map((m: ICylinder) => m.name).join(', ')}, cellEditor: 'agSelectCellEditor',
|
||||
// cellEditorParams: () => {
|
||||
// return {
|
||||
// values: this.cylinders,
|
||||
// }
|
||||
// },
|
||||
// valueFormatter: (val) => {
|
||||
// return val.value?.name + ` (${val.value?.system?.name})`;
|
||||
// },
|
||||
cellEditorPopup: false
|
||||
},
|
||||
{ colId: 'system', field: 'cylinder.system' , headerName: 'Schließanlage', flex: 1, editable: false, filter: true, cellRenderer: (data: any) => {return data.value?.name} },
|
||||
{ colId: 'system', field: 'cylinder' , headerName: 'Schließanlage', flex: 1, editable: false, filter: true, cellRenderer: (data: any) => {
|
||||
const s = new Set<string>(data.value?.map((m: ICylinder) => m.system?.name));
|
||||
return [...s].join(', ')
|
||||
} },
|
||||
{ colId: 'customer', field: 'customer' , headerName: 'Kunde', flex: 1, editable: false, filter: true, cellRenderer: (data: any) => {return data.value?.name} },
|
||||
{
|
||||
field: 'createdAt'
|
||||
@@ -92,15 +96,25 @@ export class KeysComponent {
|
||||
this.api.getCylinders().subscribe({
|
||||
next: n => {
|
||||
this.cylinders = n;
|
||||
},
|
||||
error: () => {
|
||||
this.cylinders = [];
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
loadKeys() {
|
||||
this.gridApi.setGridOption("loading", true);
|
||||
this.api.getKeys().subscribe(res => {
|
||||
this.gridApi.setGridOption("rowData", res);
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
this.api.getKeys().subscribe({
|
||||
next: n => {
|
||||
this.gridApi.setGridOption("rowData", n);
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
},
|
||||
error: () => {
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
// set error in grid
|
||||
this.toast.error('Fehler beim Laden der Schlüssel')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -131,7 +145,12 @@ export class KeysComponent {
|
||||
}
|
||||
|
||||
openCreateKey() {
|
||||
this.dialog.open(CreateKeyComponent).afterClosed().subscribe({
|
||||
this.dialog.open(CreateKeyComponent, {
|
||||
maxWidth: "calc(100vw - 24px)",
|
||||
width: "30vw",
|
||||
minWidth: "200px",
|
||||
disableClose: true
|
||||
}).afterClosed().subscribe({
|
||||
next: key => {
|
||||
if (key) {
|
||||
let d = [...this.gridApi.getGridOption("rowData") || [], key];
|
||||
|
||||
Reference in New Issue
Block a user