From 08124d202f24f2cc6d316fdbb9bb525aa1261f34 Mon Sep 17 00:00:00 2001 From: Max Ehrlicher-Schmidt Date: Thu, 19 Nov 2020 19:45:01 +0100 Subject: [PATCH] WIP Bikepage --- .../tableComponents/cell/cell.component.html | 10 +++++-- .../tableComponents/cell/cell.component.ts | 2 ++ .../pages/dataPages/bike/bike.component.html | 3 +- .../pages/dataPages/bike/bike.component.ts | 4 +-- src/app/pages/tables/bikes/bikes.component.ts | 28 ++++++++++--------- src/app/services/bikes.service.ts | 1 - 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/app/components/tableComponents/cell/cell.component.html b/src/app/components/tableComponents/cell/cell.component.html index b47fdac..e9284ef 100644 --- a/src/app/components/tableComponents/cell/cell.component.html +++ b/src/app/components/tableComponents/cell/cell.component.html @@ -6,16 +6,18 @@ [disabled]="!editable" [ngModel]="value" (ngModelChange)="change($event)" - > + >{{label}}
- + + {{label}} {{ option }} @@ -31,11 +33,13 @@ #otherInputType *ngIf="htmlInputType === 'number' || htmlInputType === 'text'" > - + + {{label}} (); isValid: boolean = true; diff --git a/src/app/pages/dataPages/bike/bike.component.html b/src/app/pages/dataPages/bike/bike.component.html index 8539140..e1df56b 100644 --- a/src/app/pages/dataPages/bike/bike.component.html +++ b/src/app/pages/dataPages/bike/bike.component.html @@ -11,8 +11,9 @@
diff --git a/src/app/pages/dataPages/bike/bike.component.ts b/src/app/pages/dataPages/bike/bike.component.ts index 9c9c22a..711e96f 100644 --- a/src/app/pages/dataPages/bike/bike.component.ts +++ b/src/app/pages/dataPages/bike/bike.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; +import { flatten } from 'src/app/helperFunctions/flattenObject'; import { BikesService } from 'src/app/services/bikes.service'; import { SchemaService } from 'src/app/services/schema.service'; @@ -117,14 +118,13 @@ export class BikeComponent implements OnInit { private schemaService: SchemaService ) { this.addPropertiesFromGQLSchemaToPropertiesInfo(); - console.log(this.propertiesInfo); } ngOnInit(): void { this.id = this.route.snapshot.paramMap.get('id'); this.bikesService.loadCargoBike({ id: this.id }); this.bikesService.bike.subscribe((data) => { - this.data = data; + this.data = flatten(data); }); this.bikesService.loadingBike.subscribe( (isLoading) => (this.isLoading = isLoading) diff --git a/src/app/pages/tables/bikes/bikes.component.ts b/src/app/pages/tables/bikes/bikes.component.ts index fdf8ae6..69ec109 100644 --- a/src/app/pages/tables/bikes/bikes.component.ts +++ b/src/app/pages/tables/bikes/bikes.component.ts @@ -10,10 +10,7 @@ import { logArrayInColumnInfoForm } from 'src/app/helperFunctions/logArrayInColu import { MatTableDataSource } from '@angular/material/table'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; -import { - MatDialog, - MatDialogRef, -} from '@angular/material/dialog'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; @Component({ selector: 'app-bikes', @@ -30,9 +27,16 @@ export class BikesComponent { sticky?: boolean; readonly?: boolean; type?: string; - link?: (row: any)=> string; + link?: (row: any) => string; }[] = [ - { name: 'name', header: 'Name', sticky: true, link: (row: any) => {return "/bike/" + row.id}}, + { + name: 'name', + header: 'Name', + sticky: true, + link: (row: any) => { + return '/bike/' + row.id; + }, + }, { name: 'id', header: 'ID', readonly: true }, { name: 'group', header: 'Gruppe' }, { name: 'modelName', header: 'Modell' }, @@ -140,9 +144,7 @@ export class BikesComponent { private bikesService: BikesService, private schemaService: SchemaService, public dialog: MatDialog - ) { - console.log(this.columnInfo[0].link({id: 66})); - } + ) {} ngAfterViewInit() { this.addColumnPropertiesFromGQLSchemaToColumnInfo(); @@ -285,7 +287,7 @@ export class BikesComponent { addNewObject() { this.paginator.firstPage(); - this.setFilter({...this.filter, includesString: ""}); + this.setFilter({ ...this.filter, includesString: '' }); this.resetSorting(); this.data.data = [ { newObject: true, id: this.getNewId() }, @@ -317,9 +319,9 @@ export class BikesComponent { this.bikesService.lockBike({ id: row.id }); } - countUnsavedRows():number { + countUnsavedRows(): number { let unsavedCount = 0; - for(const row of this.data.data) { + for (const row of this.data.data) { if (row.isLockedByMe || row.newObject) { unsavedCount++; } @@ -383,7 +385,7 @@ export class BikesComponent { showOnlyUnsavedElements(value: boolean) { this.filter.onlyUnsaved = value; - this.filter.includesString = ""; + this.filter.includesString = ''; this.applyFilter(); } diff --git a/src/app/services/bikes.service.ts b/src/app/services/bikes.service.ts index 4eedcb4..83d3a89 100644 --- a/src/app/services/bikes.service.ts +++ b/src/app/services/bikes.service.ts @@ -96,7 +96,6 @@ export class BikesService { } createBike(variables: CreateCargoBikeMutationVariables) { - console.log(variables); this.createCargoBikeGQL .mutate(variables) .subscribe((result) => {