{
+ this.checkIfValid();
+ });
+ } // number | string | boolean | { start: string; end: string; };
+ get value(): any {
+ return this._value;
+ }
+ _value: any;
+
+ rangeForm: FormGroup;
minValue: number;
maxValue: number;
@@ -52,6 +64,8 @@ export class CellComponent implements AfterViewInit {
constructor(private cdr: ChangeDetectorRef, public datepipe: DatePipe) {}
+ ngOnInit() {}
+
ngAfterViewInit(): void {
if (this.required) {
this.input?.control?.markAsTouched();
@@ -93,6 +107,12 @@ export class CellComponent implements AfterViewInit {
) {
this.value = { min: null, max: null };
}
+ this.rangeForm = new FormGroup({
+ minValue: new FormControl(),
+ maxValue: new FormControl(),
+ });
+ this.rangeForm.controls['minValue'].markAsTouched();
+ this.rangeForm.controls['maxValue'].markAsTouched();
}
}
@@ -125,16 +145,38 @@ export class CellComponent implements AfterViewInit {
}
minValueChange(event) {
- this.value.min = this.toNumber(event.target.value);
+ this.value.min = Math.abs(this.toNumber(event.target.value));
this.valueChange.emit(this.value);
- console.log(this.value);
+ this.checkIfRangeIsValid();
}
maxValueChange(event) {
- this.value.max = this.toNumber(event.target.value);
+ this.value.max = Math.abs(this.toNumber(event.target.value));
this.valueChange.emit(this.value);
- console.log(this.value);
+ this.checkIfRangeIsValid();
+ }
+ checkIfRangeIsValid() {
+ if (this.value.min === null || this.value.max === null) {
+ this.setRangeError(false);
+ return;
+ }
+ if (this.value.min <= this.value.max) {
+ this.setRangeError(false);
+ return;
+ }
+ this.setRangeError(true);
+ }
+
+ setRangeError(error: boolean): void {
+ this.validityChange.emit(!error);
+ if (error) {
+ this.rangeForm.controls['minValue'].setErrors({ rangeError: true });
+ this.rangeForm.controls['maxValue'].setErrors({ rangeError: true });
+ } else {
+ this.rangeForm.controls['minValue'].setErrors(null);
+ this.rangeForm.controls['maxValue'].setErrors(null);
+ }
}
transformDate(date) {
diff --git a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.html b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.html
new file mode 100644
index 0000000..a1b96fb
--- /dev/null
+++ b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.html
@@ -0,0 +1 @@
+
date-range-cell works!
diff --git a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.scss b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/components/tableComponents/date-range-cell/date-range-cell.component.ts b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.ts
new file mode 100644
index 0000000..82be446
--- /dev/null
+++ b/src/app/components/tableComponents/date-range-cell/date-range-cell.component.ts
@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'app-date-range-cell',
+ templateUrl: './date-range-cell.component.html',
+ styleUrls: ['./date-range-cell.component.scss']
+})
+export class DateRangeCellComponent implements OnInit {
+
+ constructor() { }
+
+ ngOnInit(): void {
+ }
+
+}
diff --git a/src/app/components/tableComponents/number-range-cell/number-range-cell.component.html b/src/app/components/tableComponents/number-range-cell/number-range-cell.component.html
new file mode 100644
index 0000000..d4ebae0
--- /dev/null
+++ b/src/app/components/tableComponents/number-range-cell/number-range-cell.component.html
@@ -0,0 +1,28 @@
+
+
+ {{ label }} min
+
+
+ -
+
+ {{ label }} max
+
+
+
+
+ {{ min }} - {{ max }}
+
diff --git a/src/app/components/tableComponents/number-range-cell/number-range-cell.component.scss b/src/app/components/tableComponents/number-range-cell/number-range-cell.component.scss
new file mode 100644
index 0000000..478572b
--- /dev/null
+++ b/src/app/components/tableComponents/number-range-cell/number-range-cell.component.scss
@@ -0,0 +1,8 @@
+.number-range-wrapper {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ .range-spacer {
+ margin: 0 0.5em;
+ }
+}
diff --git a/src/app/components/tableComponents/number-range-cell/number-range-cell.component.ts b/src/app/components/tableComponents/number-range-cell/number-range-cell.component.ts
new file mode 100644
index 0000000..1e376c7
--- /dev/null
+++ b/src/app/components/tableComponents/number-range-cell/number-range-cell.component.ts
@@ -0,0 +1,123 @@
+import { DatePipe } from '@angular/common';
+import {
+ Component,
+ Input,
+ Output,
+ EventEmitter,
+ ChangeDetectorRef,
+ OnInit,
+} from '@angular/core';
+import { FormControl, FormGroup, Validators } from '@angular/forms';
+
+@Component({
+ selector: 'app-number-range-cell',
+ templateUrl: './number-range-cell.component.html',
+ styleUrls: ['./number-range-cell.component.scss'],
+})
+export class NumberRangeCellComponent implements OnInit {
+ @Input()
+ set min(value: number) {
+ this._min = value;
+ this.rangeForm?.controls['minValue'].setValue(value);
+ }
+ get min() {
+ return this._min;
+ }
+ _min: number;
+
+ @Input()
+ set max(value: number) {
+ this._max = value;
+ this.rangeForm?.controls['maxValue'].setValue(value);
+ }
+ get max() {
+ return this._max;
+ }
+ _max: number;
+
+ rangeForm: FormGroup;
+
+ @Output() minChange = new EventEmitter
();
+ @Output() maxChange = new EventEmitter();
+
+ @Input()
+ set editable(value) {
+ this._editable = value;
+ if (value) {
+ this.rangeForm?.controls['minValue'].enable();
+ this.rangeForm?.controls['maxValue'].enable();
+ } else {
+ this.rangeForm?.controls['minValue'].disable();
+ this.rangeForm?.controls['maxValue'].disable();
+ }
+ }
+ _editable = false;
+ get editable() {
+ return this._editable;
+ }
+ @Input()
+ required = false;
+ @Input()
+ label: string = null;
+ @Output() validityChange = new EventEmitter();
+ isValid = true;
+
+ constructor(private cdr: ChangeDetectorRef, public datepipe: DatePipe) {}
+
+ ngOnInit() {
+ this.rangeForm = new FormGroup({
+ minValue: new FormControl(),
+ maxValue: new FormControl(),
+ });
+ this.rangeForm.controls['minValue'].markAsTouched();
+ this.rangeForm.controls['maxValue'].markAsTouched();
+ this.rangeForm?.controls['minValue'].setValue(this.min);
+ this.rangeForm?.controls['maxValue'].setValue(this.max);
+ }
+
+ minValueChange(event) {
+ this.min = this.toPositiveNumber(event.target.value);
+ this.minChange.emit(this.min);
+ this.checkIfRangeIsValid();
+ }
+
+ maxValueChange(event) {
+ this.max = this.toPositiveNumber(event.target.value);
+ this.maxChange.emit(this.max);
+ this.checkIfRangeIsValid();
+ }
+
+ checkIfRangeIsValid() {
+ if (this.min == null || this.max == null) {
+ this.setRangeError(false);
+ return;
+ }
+ if (this.min <= this.max) {
+ this.setRangeError(false);
+ return;
+ }
+ this.setRangeError(true);
+ }
+
+ setRangeError(error: boolean): void {
+ this.validityChange.emit(!error);
+ if (error) {
+ this.rangeForm.controls['minValue'].setErrors({ rangeError: true });
+ this.rangeForm.controls['maxValue'].setErrors({ rangeError: true });
+ } else {
+ this.rangeForm.controls['minValue'].setErrors(null);
+ this.rangeForm.controls['maxValue'].setErrors(null);
+ }
+ }
+
+ toPositiveNumber(str: string): number {
+ if (str === '') {
+ return null;
+ }
+ const number = +str;
+ if (number < 0) {
+ return Math.abs(number);
+ }
+ return number;
+ }
+}
diff --git a/src/app/pages/dataPages/bike/bike.component.ts b/src/app/pages/dataPages/bike/bike.component.ts
index f30155c..946f70b 100644
--- a/src/app/pages/dataPages/bike/bike.component.ts
+++ b/src/app/pages/dataPages/bike/bike.component.ts
@@ -60,7 +60,7 @@ export class BikeComponent implements OnInit {
},
{
type: 'Group',
- title: 'Maße und Ladungen',
+ title: 'Maße und Ladung',
properties: [
{ dataPath: 'dimensionsAndLoad.bikeLength', translation: 'Länge' },
{ dataPath: 'dimensionsAndLoad.bikeWeight', translation: 'Gewicht' },
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 1e77194..d2b673a 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -4,8 +4,8 @@
export const environment = {
production: false,
- apiUrl: "https://flotte.duckdns.org", // without /graphql !!!
- authUrl: "https://flotte.duckdns.org/user-management"
+ apiUrl: "http://173.212.197.169:4000", // without /graphql !!!
+ authUrl: "http://173.212.197.169:8080"
};
/*