pull/4/head
Max Ehrlicher-Schmidt 4 years ago
parent 95a4786e13
commit 65bc305649

@ -1,4 +1,4 @@
<div #booleanInputType *ngIf="inputType == 'Boolean'"> <div #booleanInputType *ngIf="htmlInputType === 'boolean'">
<mat-checkbox <mat-checkbox
class="checkbox" class="checkbox"
[disabled]="!editable" [disabled]="!editable"
@ -7,7 +7,7 @@
></mat-checkbox> ></mat-checkbox>
</div> </div>
<div #enumInputType *ngIf="inputType.startsWith('Enum//')"> <div #enumInputType *ngIf="htmlInputType === 'enum'">
<mat-form-field *ngIf="editable; else nonEditableText"> <mat-form-field *ngIf="editable; else nonEditableText">
<mat-select [(ngModel)]="value" (ngModelChange)="change($event)"> <mat-select [(ngModel)]="value" (ngModelChange)="change($event)">
<mat-option *ngFor="let option of enumValues" [value]="option"> <mat-option *ngFor="let option of enumValues" [value]="option">
@ -20,11 +20,11 @@
</ng-template> </ng-template>
</div> </div>
<div #otherInputType *ngIf="inputType === 'number' || inputType === 'text'"> <div #otherInputType *ngIf="htmlInputType === 'number' || htmlInputType === 'text'">
<mat-form-field *ngIf="editable; else nonEditableText"> <mat-form-field *ngIf="editable; else nonEditableText">
<input <input
matInput matInput
[type]="inputType" [type]="htmlInputType"
[ngModel]="value" [ngModel]="value"
(ngModelChange)="change($event)" (ngModelChange)="change($event)"
/> />

@ -1,4 +1,10 @@
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import {
Component,
Input,
Output,
EventEmitter,
ChangeDetectionStrategy,
} from '@angular/core';
@Component({ @Component({
selector: 'app-cell', selector: 'app-cell',
@ -16,18 +22,30 @@ export class CellComponent {
enumValues = []; enumValues = [];
htmlInputType: string = 'string';
ngOnChanges() { ngOnChanges() {
this.getHtmlInputType(this.inputType);
}
getHtmlInputType(type: string) {
if (this.inputType.split('//')[0] === 'Enum') { if (this.inputType.split('//')[0] === 'Enum') {
this.enumValues = this.inputType.split('//').slice(1); this.enumValues = this.inputType.split('//').slice(1);
this.htmlInputType = 'enum';
} else if (this.inputType === 'Int' || this.inputType === 'Float') { } else if (this.inputType === 'Int' || this.inputType === 'Float') {
this.inputType = 'number'; this.htmlInputType = 'number';
} else if (this.inputType === 'ID' || this.inputType === 'String') { } else if (this.inputType === 'ID' || this.inputType === 'String') {
this.inputType = 'text'; this.htmlInputType = 'text';
} else if (this.inputType === 'Boolean') {
this.htmlInputType = 'boolean';
} }
} }
change(newValue) { change(newValue) {
this.value = this.inputType === 'number' ? +newValue : newValue; if (this.inputType === "Int") {
newValue = newValue.toString().replace('.', '');
}
this.value = this.htmlInputType === 'number' ? +newValue : newValue;
this.valueChange.emit(this.value); this.valueChange.emit(this.value);
} }
} }

@ -1,5 +1,5 @@
query GetCargoBikes { query GetCargoBikes {
cargoBikes(limit: 100, offset: 0) { cargoBikes(limit: 1000, offset: 0) {
...CargoBikeFields ...CargoBikeFields
} }
} }

@ -1,6 +1,5 @@
{ {
"__schema": { "__schema": {
"description": null,
"queryType": { "queryType": {
"name": "Query" "name": "Query"
}, },

@ -2022,7 +2022,7 @@ export const UnlockCargoBikeDocument = gql`
} }
export const GetCargoBikesDocument = gql` export const GetCargoBikesDocument = gql`
query GetCargoBikes { query GetCargoBikes {
cargoBikes(limit: 100, offset: 0) { cargoBikes(limit: 1000, offset: 0) {
...CargoBikeFields ...CargoBikeFields
} }
} }

Loading…
Cancel
Save