diff --git a/src/app/components/table/table.component.ts b/src/app/components/table/table.component.ts
index 8024f8d..2f157af 100644
--- a/src/app/components/table/table.component.ts
+++ b/src/app/components/table/table.component.ts
@@ -24,7 +24,7 @@ import { MatDialog, MatDialogRef } from '@angular/material/dialog';
})
export class TableComponent {
@Input()
- headline: string = "Keine Überschrift";
+ headline: string = null;
/** this array defines the columns and translations of the table and the order they are displayed */
@Input()
columnInfo: {
diff --git a/src/app/helperFunctions/deepenObject.ts b/src/app/helperFunctions/deepenObject.ts
index 7286923..dfafd83 100644
--- a/src/app/helperFunctions/deepenObject.ts
+++ b/src/app/helperFunctions/deepenObject.ts
@@ -1,21 +1,24 @@
export function deepen(object: Object): any {
- let newObject = {};
- for (const prop in object) {
- if (prop.includes('.')) {
- const splittedProp = prop.split('.');
- const outerProp = splittedProp[0];
- const innerProp = splittedProp.slice(1).join('.');
- if (!newObject[outerProp]) {
- newObject[outerProp] = {};
- }
- newObject[outerProp][innerProp] = object[prop];
- } else {
- newObject[prop] = object[prop];
+ let newObject;
+ if (Array.isArray(object)) {
+ newObject = new Array();
+ } else newObject = new Object();
+ for (const prop in object) {
+ if (prop.includes('.')) {
+ const splittedProp = prop.split('.');
+ const outerProp = splittedProp[0];
+ const innerProp = splittedProp.slice(1).join('.');
+ if (!newObject[outerProp]) {
+ newObject[outerProp] = {};
}
+ newObject[outerProp][innerProp] = object[prop];
+ } else {
+ newObject[prop] = object[prop];
}
- for (const prop in newObject) {
- if (typeof newObject[prop] === 'object' && newObject[prop] !== null)
- newObject[prop] = deepen(newObject[prop]);
- }
- return newObject;
- }
\ No newline at end of file
+ }
+ for (const prop in newObject) {
+ if (typeof newObject[prop] === 'object' && newObject[prop] !== null)
+ newObject[prop] = deepen(newObject[prop]);
+ }
+ return newObject;
+}
diff --git a/src/app/helperFunctions/flattenObject.ts b/src/app/helperFunctions/flattenObject.ts
index 1edae54..cb54d92 100644
--- a/src/app/helperFunctions/flattenObject.ts
+++ b/src/app/helperFunctions/flattenObject.ts
@@ -1,16 +1,20 @@
export function flatten(object: Object, prefix: string = ''): any {
- let newObject = {};
- for (const prop in object) {
- let propName = prefix + prop;
- if (typeof object[prop] === 'object' && object[prop] !== null) {
- const flattenedObject = flatten(object[prop], propName + '.');
- for (const flattenedProperty in flattenedObject) {
- newObject[flattenedProperty] =
- flattenedObject[flattenedProperty];
- }
- } else {
- newObject[propName] = object[prop];
+ let newObject = {};
+ for (const prop in object) {
+ let propName = prefix + prop;
+ if (Array.isArray(object[prop])) {
+ newObject[propName] = [];
+ for (const arrayElement of object[prop]) {
+ newObject[propName].push(flatten(arrayElement));
}
+ } else if (typeof object[prop] === 'object' && object[prop] !== null) {
+ const flattenedObject = flatten(object[prop], propName + '.');
+ for (const flattenedProperty in flattenedObject) {
+ newObject[flattenedProperty] = flattenedObject[flattenedProperty];
+ }
+ } else {
+ newObject[propName] = object[prop];
}
- return newObject;
- }
\ No newline at end of file
+ }
+ return newObject;
+}
diff --git a/src/app/pages/dataPages/bike/bike.component.html b/src/app/pages/dataPages/bike/bike.component.html
index f84bcad..b5b5773 100644
--- a/src/app/pages/dataPages/bike/bike.component.html
+++ b/src/app/pages/dataPages/bike/bike.component.html
@@ -4,6 +4,7 @@
[headlineDataPath]="headlineDataPath"
[pageDataGQLType]="pageDataGQLType"
[pageDataGQLUpdateInputType]="pageDataGQLUpdateInputType"
+ [propertyNameOfUpdateInput]="propertyNameOfUpdateInput"
(lockEvent)="lock($event)"
(saveEvent)="save($event)"
(cancelEvent)="cancel($event)"
diff --git a/src/app/pages/dataPages/bike/bike.component.ts b/src/app/pages/dataPages/bike/bike.component.ts
index b1a6bae..6355668 100644
--- a/src/app/pages/dataPages/bike/bike.component.ts
+++ b/src/app/pages/dataPages/bike/bike.component.ts
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { BikesService } from 'src/app/services/bikes.service';
+import { EquipmentTypeService } from 'src/app/services/equipmentType.service';
@Component({
selector: 'app-bike',
@@ -9,17 +10,17 @@ import { BikesService } from 'src/app/services/bikes.service';
export class BikeComponent implements OnInit {
propertiesInfo = [
{
- isGroup: true,
+ type: 'Group',
title: 'Allgemein',
properties: [
{ name: 'name', translation: 'Name' },
{ name: 'id', translation: 'ID', readonly: true },
- { name: 'group', translation: 'Gruppe' },
+ { name: 'Group', translation: 'Gruppe' },
{ name: 'modelName', translation: 'Modell' },
],
},
{
- isGroup: true,
+ type: 'Group',
title: 'Versicherungsdaten',
properties: [
{
@@ -51,7 +52,7 @@ export class BikeComponent implements OnInit {
],
},
{
- isGroup: true,
+ type: 'Group',
title: 'Maße und Ladungen',
properties: [
{ name: 'dimensionsAndLoad.bikeLength', translation: 'Länge' },
@@ -85,7 +86,7 @@ export class BikeComponent implements OnInit {
],
},
{
- isGroup: true,
+ type: 'Group',
title: 'Sicherheitsinformationen',
properties: [
{ name: 'security.frameNumber', translation: 'Rahmennummer' },
@@ -102,7 +103,7 @@ export class BikeComponent implements OnInit {
],
},
{
- isGroup: true,
+ type: 'Group',
title: 'Ausstattung',
properties: [
{ name: 'technicalEquipment.bicycleShift', translation: 'Schaltung' },
@@ -118,7 +119,7 @@ export class BikeComponent implements OnInit {
],
},
{
- isGroup: true,
+ type: 'Group',
title: 'Sonstiges',
properties: [
{ name: 'stickerBikeNameState', translation: 'Aufkleber Status' },
@@ -131,7 +132,7 @@ export class BikeComponent implements OnInit {
],
},
{
- isGroup: true,
+ type: 'Group',
title: 'provider',
properties: [
{ name: 'provider.id', translation: '' },
@@ -147,7 +148,7 @@ export class BikeComponent implements OnInit {
],
},
{
- isGroup: true,
+ type: 'Group',
title: 'lendingstation',
properties: [
{ name: 'lendingStation.id', translation: '' },
@@ -157,6 +158,15 @@ export class BikeComponent implements OnInit {
{ name: 'lendingStation.address.zip', translation: '' },
],
},
+ {
+ type: 'ReferenceTable',
+ title: 'Equipmenttypen',
+ name: 'equipmentType',
+ dataService: null,
+ columnInfo: [{name: 'name', translation: "Name"}, {name: 'description', translation: "Beschreibung"}],
+ nameToShowInSelection: (element) => {return element.name},
+ propertyNameOfUpdateInput: "equipmentTypeIds"
+ },
];
headlineDataPath = 'name';
@@ -165,7 +175,14 @@ export class BikeComponent implements OnInit {
dataService: any;
- constructor(private bikesService: BikesService) {}
+ constructor(
+ private bikesService: BikesService,
+ private equipmentTypeService: EquipmentTypeService
+ ) {
+ this.propertiesInfo.find(
+ (prop) => prop.name === 'equipmentType'
+ ).dataService = this.equipmentTypeService;
+ }
ngOnInit(): void {
this.dataService = this.bikesService;
diff --git a/src/app/pages/table-overview/table-overview.component.html b/src/app/pages/table-overview/table-overview.component.html
index 161fcdd..0fee1ae 100644
--- a/src/app/pages/table-overview/table-overview.component.html
+++ b/src/app/pages/table-overview/table-overview.component.html
@@ -9,7 +9,7 @@
- Tabelle 5
+ Equipmenttypen
Tabelle 7
Tabelle 8
Tabelle 9
diff --git a/src/app/pages/table-overview/table-overview.component.scss b/src/app/pages/table-overview/table-overview.component.scss
index 40613c0..c42a930 100644
--- a/src/app/pages/table-overview/table-overview.component.scss
+++ b/src/app/pages/table-overview/table-overview.component.scss
@@ -1,5 +1,6 @@
mat-grid-tile {
background: gray;
+ cursor: pointer;
}
.grid-list-spacer{
diff --git a/src/app/pages/table-overview/table-overview.component.spec.ts b/src/app/pages/table-overview/table-overview.component.spec.ts
deleted file mode 100644
index 999cc86..0000000
--- a/src/app/pages/table-overview/table-overview.component.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
-import { TableOverviewComponent } from './table-overview.component';
-
-describe('TableOverviewComponent', () => {
- let component: TableOverviewComponent;
- let fixture: ComponentFixture;
-
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- declarations: [ TableOverviewComponent ]
- })
- .compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(TableOverviewComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/src/app/services/bikes.service.ts b/src/app/services/bikes.service.ts
index 3211dff..c613cc3 100644
--- a/src/app/services/bikes.service.ts
+++ b/src/app/services/bikes.service.ts
@@ -63,7 +63,7 @@ export class BikesService {
loadTableData() {
this.tableData.next(null);
this.getCargoBikesGQL.fetch().subscribe((result) => {
- this.tableData.next(result.data.cargoBikes);
+ this.tableData.next(result.data?.cargoBikes);
});
}
@@ -85,7 +85,7 @@ export class BikesService {
this.reloadCargoBikeByIdGQL
.fetch(variables)
.subscribe((result) => {
- this.updateDataRowFromResponse(result.data.cargoBikeById)
+ this.updateDataRowFromResponse(result.data.cargoBikeById);
})
.add(() => {
this.removeLoadingRowId(variables.id);
@@ -153,11 +153,13 @@ export class BikesService {
}
private updateDataRowFromResponse(rowFromResponse: any) {
- const newTableData = this.tableData.value.map((row) =>
- rowFromResponse.id === row.id ? rowFromResponse : row
- );
- this.tableData.next(newTableData);
- if ((rowFromResponse.id === this.pageData?.value?.id)) {
+ if (this.tableData.value) {
+ const newTableData = this.tableData.value.map((row) =>
+ rowFromResponse.id === row.id ? rowFromResponse : row
+ );
+ this.tableData.next(newTableData);
+ }
+ if (rowFromResponse.id === this.pageData?.value?.id) {
this.pageData.next(rowFromResponse);
}
}
diff --git a/src/app/services/equipmentType.service.ts b/src/app/services/equipmentType.service.ts
index 30a0dcc..a595930 100644
--- a/src/app/services/equipmentType.service.ts
+++ b/src/app/services/equipmentType.service.ts
@@ -32,7 +32,7 @@ export class EquipmentTypeService {
private updateEquipmentTypeGQL: UpdateEquipmentTypeGQL,
private lockEquipmentTypeGQL: LockEquipmentTypeGQL,
private unlockEquipmentTypeGQL: UnlockEquipmentTypeGQL,
- private deleteEquipmentTypeGQL: DeleteEquipmentTypeGQL,
+ private deleteEquipmentTypeGQL: DeleteEquipmentTypeGQL
) {}
addLoadingRowId(id: string) {
@@ -116,9 +116,11 @@ export class EquipmentTypeService {
}
private updateDataRowFromResponse(rowFromResponse: any) {
- const newTableData = this.tableData.value.map((row) =>
- rowFromResponse.id === row.id ? rowFromResponse : row
- );
- this.tableData.next(newTableData);
+ if (this.tableData.value) {
+ const newTableData = this.tableData.value.map((row) =>
+ rowFromResponse.id === row.id ? rowFromResponse : row
+ );
+ this.tableData.next(newTableData);
+ }
}
}
diff --git a/src/app/services/schema.service.ts b/src/app/services/schema.service.ts
index 90d383c..82d9159 100644
--- a/src/app/services/schema.service.ts
+++ b/src/app/services/schema.service.ts
@@ -95,7 +95,12 @@ export class SchemaService {
}
filterObject(graphQLTypeName: string, object: object): any {
- const filteredObject = {};
+ let filteredObject;
+ if (Array.isArray(object)) {
+ return object;
+ //TODO: check if array consists of objects?
+ } else filteredObject = new Object();
+
for (const prop in object) {
if (typeof object[prop] === 'object' && object[prop] !== null) {
const info = this.getTypeInformation(graphQLTypeName, prop);