WIP Bikepage

urls
Max Ehrlicher-Schmidt 4 years ago
parent c73d9a7fe5
commit 08124d202f

@ -6,16 +6,18 @@
[disabled]="!editable" [disabled]="!editable"
[ngModel]="value" [ngModel]="value"
(ngModelChange)="change($event)" (ngModelChange)="change($event)"
></mat-checkbox> ><span *ngIf="label">{{label}}</span></mat-checkbox>
</div> </div>
<div #enumInputType *ngIf="htmlInputType === 'enum'"> <div #enumInputType *ngIf="htmlInputType === 'enum'">
<mat-form-field *ngIf="editable; else nonEditableText"> <mat-form-field *ngIf="editable || label; else nonEditableText">
<mat-label *ngIf="label">{{label}}</mat-label>
<mat-select <mat-select
[(ngModel)]="value" [(ngModel)]="value"
(ngModelChange)="change($event)" (ngModelChange)="change($event)"
#input="ngModel" #input="ngModel"
[required]="required" [required]="required"
[disabled]="!editable"
> >
<mat-option *ngFor="let option of enumValues" [value]="option"> <mat-option *ngFor="let option of enumValues" [value]="option">
{{ option }} {{ option }}
@ -31,11 +33,13 @@
#otherInputType #otherInputType
*ngIf="htmlInputType === 'number' || htmlInputType === 'text'" *ngIf="htmlInputType === 'number' || htmlInputType === 'text'"
> >
<mat-form-field *ngIf="editable; else nonEditableText"> <mat-form-field *ngIf="editable || label; else nonEditableText">
<mat-label *ngIf="label">{{label}}</mat-label>
<input <input
#input="ngModel" #input="ngModel"
matInput matInput
[type]="htmlInputType" [type]="htmlInputType"
[disabled]="!editable"
[ngModel]="value" [ngModel]="value"
(ngModelChange)="change($event)" (ngModelChange)="change($event)"
[required]="required" [required]="required"

@ -32,6 +32,8 @@ export class CellComponent {
required: boolean = false; required: boolean = false;
@Input() @Input()
link: string = null; link: string = null;
@Input()
label: string = null;
@Output() validityChange = new EventEmitter<boolean>(); @Output() validityChange = new EventEmitter<boolean>();
isValid: boolean = true; isValid: boolean = true;

@ -11,8 +11,9 @@
<div *ngFor="let prop of propertiesInfo"> <div *ngFor="let prop of propertiesInfo">
<app-cell <app-cell
[editable]="!prop.readonly && data.isLockedByMe" [editable]="data.isLockedByMe && !prop.readonly"
[(value)]="data[prop.name]" [(value)]="data[prop.name]"
[label]="prop.translation || prop.name"
[inputType]="prop.type" [inputType]="prop.type"
></app-cell> ></app-cell>
</div> </div>

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { flatten } from 'src/app/helperFunctions/flattenObject';
import { BikesService } from 'src/app/services/bikes.service'; import { BikesService } from 'src/app/services/bikes.service';
import { SchemaService } from 'src/app/services/schema.service'; import { SchemaService } from 'src/app/services/schema.service';
@ -117,14 +118,13 @@ export class BikeComponent implements OnInit {
private schemaService: SchemaService private schemaService: SchemaService
) { ) {
this.addPropertiesFromGQLSchemaToPropertiesInfo(); this.addPropertiesFromGQLSchemaToPropertiesInfo();
console.log(this.propertiesInfo);
} }
ngOnInit(): void { ngOnInit(): void {
this.id = this.route.snapshot.paramMap.get('id'); this.id = this.route.snapshot.paramMap.get('id');
this.bikesService.loadCargoBike({ id: this.id }); this.bikesService.loadCargoBike({ id: this.id });
this.bikesService.bike.subscribe((data) => { this.bikesService.bike.subscribe((data) => {
this.data = data; this.data = flatten(data);
}); });
this.bikesService.loadingBike.subscribe( this.bikesService.loadingBike.subscribe(
(isLoading) => (this.isLoading = isLoading) (isLoading) => (this.isLoading = isLoading)

@ -10,10 +10,7 @@ import { logArrayInColumnInfoForm } from 'src/app/helperFunctions/logArrayInColu
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort'; import { MatSort } from '@angular/material/sort';
import { import { MatDialog, MatDialogRef } from '@angular/material/dialog';
MatDialog,
MatDialogRef,
} from '@angular/material/dialog';
@Component({ @Component({
selector: 'app-bikes', selector: 'app-bikes',
@ -32,7 +29,14 @@ export class BikesComponent {
type?: string; 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: 'id', header: 'ID', readonly: true },
{ name: 'group', header: 'Gruppe' }, { name: 'group', header: 'Gruppe' },
{ name: 'modelName', header: 'Modell' }, { name: 'modelName', header: 'Modell' },
@ -140,9 +144,7 @@ export class BikesComponent {
private bikesService: BikesService, private bikesService: BikesService,
private schemaService: SchemaService, private schemaService: SchemaService,
public dialog: MatDialog public dialog: MatDialog
) { ) {}
console.log(this.columnInfo[0].link({id: 66}));
}
ngAfterViewInit() { ngAfterViewInit() {
this.addColumnPropertiesFromGQLSchemaToColumnInfo(); this.addColumnPropertiesFromGQLSchemaToColumnInfo();
@ -285,7 +287,7 @@ export class BikesComponent {
addNewObject() { addNewObject() {
this.paginator.firstPage(); this.paginator.firstPage();
this.setFilter({...this.filter, includesString: ""}); this.setFilter({ ...this.filter, includesString: '' });
this.resetSorting(); this.resetSorting();
this.data.data = [ this.data.data = [
{ newObject: true, id: this.getNewId() }, { newObject: true, id: this.getNewId() },
@ -383,7 +385,7 @@ export class BikesComponent {
showOnlyUnsavedElements(value: boolean) { showOnlyUnsavedElements(value: boolean) {
this.filter.onlyUnsaved = value; this.filter.onlyUnsaved = value;
this.filter.includesString = ""; this.filter.includesString = '';
this.applyFilter(); this.applyFilter();
} }

@ -96,7 +96,6 @@ export class BikesService {
} }
createBike(variables: CreateCargoBikeMutationVariables) { createBike(variables: CreateCargoBikeMutationVariables) {
console.log(variables);
this.createCargoBikeGQL this.createCargoBikeGQL
.mutate(variables) .mutate(variables)
.subscribe((result) => { .subscribe((result) => {

Loading…
Cancel
Save