Add group and projectAllowance to bikepage

master
Max 4 years ago
parent 54a6eef2e4
commit d29fd0e64c

@ -128,6 +128,14 @@ export class DataPageComponent implements OnInit, OnDestroy {
this.pageDataGQLType, this.pageDataGQLType,
prop.dataPath prop.dataPath
).type; ).type;
if (!prop.type) {
console.error(
"Didn't found type for: " +
prop.dataPath +
' on ' +
this.pageDataGQLType
);
}
prop.referenceIds = []; prop.referenceIds = [];
} else { } else {
const typeInformation = this.schemaService.getTypeInformation( const typeInformation = this.schemaService.getTypeInformation(
@ -135,6 +143,13 @@ export class DataPageComponent implements OnInit, OnDestroy {
prop.dataPath prop.dataPath
); );
prop.type = prop.type || typeInformation.type; prop.type = prop.type || typeInformation.type;
if (!prop.type) {
console.error(
"Didn't found type for: " +
prop.dataPath +
' on ' +
this.pageDataGQLType
);}
prop.required = prop.required =
prop.required != null ? prop.required : typeInformation.isRequired; prop.required != null ? prop.required : typeInformation.isRequired;

@ -20,6 +20,9 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
export class CellComponent implements AfterViewInit { export class CellComponent implements AfterViewInit {
@Input() @Input()
set value(value: any) { set value(value: any) {
if (this.inputType === 'Money') {
value = value.toString().replace('$', '');
}
this._value = value; this._value = value;
setTimeout(() => { setTimeout(() => {
this.checkIfValid(); this.checkIfValid();
@ -86,7 +89,7 @@ export class CellComponent implements AfterViewInit {
constructor(private cdr: ChangeDetectorRef, public datepipe: DatePipe) {} constructor(private cdr: ChangeDetectorRef, public datepipe: DatePipe) {}
ngOnInit() { ngOnInit() {
if(this.htmlInputType === "date") { if (this.htmlInputType === 'date') {
this.dateGroup = new FormGroup({ this.dateGroup = new FormGroup({
dateControl: new FormControl(), dateControl: new FormControl(),
}); });
@ -106,7 +109,6 @@ export class CellComponent implements AfterViewInit {
this.change(false); this.change(false);
}); });
} }
} }
} }
@ -114,7 +116,7 @@ export class CellComponent implements AfterViewInit {
if (type.split('//')[0] === 'Enum') { if (type.split('//')[0] === 'Enum') {
this.enumValues = type.split('//').slice(1); this.enumValues = type.split('//').slice(1);
this.htmlInputType = 'enum'; this.htmlInputType = 'enum';
} else if (type === 'Int' || type === 'Float') { } else if (type === 'Int' || type === 'Float' || type === 'Money') {
this.htmlInputType = 'number'; this.htmlInputType = 'number';
} else if (type === 'ID' || type === 'String') { } else if (type === 'ID' || type === 'String') {
this.htmlInputType = 'text'; this.htmlInputType = 'text';
@ -138,6 +140,9 @@ export class CellComponent implements AfterViewInit {
} }
change(newValue): void { change(newValue): void {
if (this.inputType === 'Money') {
newValue = newValue.toString().replace('$', '');
}
if (this.inputType === 'Int') { if (this.inputType === 'Int') {
newValue = newValue.toString().replace('.', ''); newValue = newValue.toString().replace('.', '');
} }
@ -179,13 +184,18 @@ export class CellComponent implements AfterViewInit {
if (!this.value && this.isList) { if (!this.value && this.isList) {
this.value = []; this.value = [];
this.valueChange.emit([]); this.valueChange.emit([]);
} else if (this.editable && } else if (
this.required && this.htmlInputType === "date") { this.editable &&
this.required &&
this.htmlInputType === 'date'
) {
const dateIsEmpty = !this.value; const dateIsEmpty = !this.value;
this.isValid = !dateIsEmpty; this.isValid = !dateIsEmpty;
this.validityChange.emit(this.isValid); this.validityChange.emit(this.isValid);
if (dateIsEmpty) { if (dateIsEmpty) {
this.dateGroup.controls['dateControl'].setErrors({ rangeError: true }); this.dateGroup.controls['dateControl'].setErrors({
rangeError: true,
});
} else { } else {
this.dateGroup.controls['dateControl'].setErrors(null); this.dateGroup.controls['dateControl'].setErrors(null);
} }
@ -202,7 +212,7 @@ export class CellComponent implements AfterViewInit {
} }
dateChange(event) { dateChange(event) {
this.value = this.transformDate(event.value) this.value = this.transformDate(event.value);
this.valueChange.emit(this.value); this.valueChange.emit(this.value);
this.checkIfValid(); this.checkIfValid();
} }

@ -15,7 +15,7 @@ export class BikeComponent implements OnInit {
title: 'Allgemein', title: 'Allgemein',
properties: [ properties: [
{ dataPath: 'name', translation: 'Name' }, { dataPath: 'name', translation: 'Name' },
{ dataPath: 'Group', translation: 'Gruppe' }, { dataPath: 'group', translation: 'Gruppe' },
{ dataPath: 'modelName', translation: 'Modell' }, { dataPath: 'modelName', translation: 'Modell' },
{ dataPath: 'state', translation: 'Status' }, { dataPath: 'state', translation: 'Status' },
], ],

Loading…
Cancel
Save