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
class="checkbox"
[disabled]="!editable"
@ -7,7 +7,7 @@
></mat-checkbox>
</div>
<div #enumInputType *ngIf="inputType.startsWith('Enum//')">
<div #enumInputType *ngIf="htmlInputType === 'enum'">
<mat-form-field *ngIf="editable; else nonEditableText">
<mat-select [(ngModel)]="value" (ngModelChange)="change($event)">
<mat-option *ngFor="let option of enumValues" [value]="option">
@ -20,11 +20,11 @@
</ng-template>
</div>
<div #otherInputType *ngIf="inputType === 'number' || inputType === 'text'">
<div #otherInputType *ngIf="htmlInputType === 'number' || htmlInputType === 'text'">
<mat-form-field *ngIf="editable; else nonEditableText">
<input
matInput
[type]="inputType"
[type]="htmlInputType"
[ngModel]="value"
(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({
selector: 'app-cell',
@ -16,18 +22,30 @@ export class CellComponent {
enumValues = [];
htmlInputType: string = 'string';
ngOnChanges() {
this.getHtmlInputType(this.inputType);
}
getHtmlInputType(type: string) {
if (this.inputType.split('//')[0] === 'Enum') {
this.enumValues = this.inputType.split('//').slice(1);
this.htmlInputType = 'enum';
} else if (this.inputType === 'Int' || this.inputType === 'Float') {
this.inputType = 'number';
this.htmlInputType = 'number';
} else if (this.inputType === 'ID' || this.inputType === 'String') {
this.inputType = 'text';
this.htmlInputType = 'text';
} else if (this.inputType === 'Boolean') {
this.htmlInputType = 'boolean';
}
}
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);
}
}

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

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

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

Loading…
Cancel
Save