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,
prop.dataPath
).type;
if (!prop.type) {
console.error(
"Didn't found type for: " +
prop.dataPath +
' on ' +
this.pageDataGQLType
);
}
prop.referenceIds = [];
} else {
const typeInformation = this.schemaService.getTypeInformation(
@ -135,6 +143,13 @@ export class DataPageComponent implements OnInit, OnDestroy {
prop.dataPath
);
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 != null ? prop.required : typeInformation.isRequired;
@ -208,7 +223,7 @@ export class DataPageComponent implements OnInit, OnDestroy {
this.data[object.propertyNameOfReferenceId] = null;
for (const prop in this.data) {
if (prop.startsWith(object.propertyPrefixToOverwrite)) {
this.data[prop] = null;
this.data[prop] = null;
}
}
}

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

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

Loading…
Cancel
Save