|
|
@ -9,12 +9,6 @@ import {
|
|
|
|
CargoBikeUpdateInput,
|
|
|
|
CargoBikeUpdateInput,
|
|
|
|
} from 'src/generated/graphql';
|
|
|
|
} from 'src/generated/graphql';
|
|
|
|
|
|
|
|
|
|
|
|
type CargoBikeDataRow = CargoBikeResult & {
|
|
|
|
|
|
|
|
waitingForEditPermissions: boolean;
|
|
|
|
|
|
|
|
saving: boolean;
|
|
|
|
|
|
|
|
unlocking: boolean;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'app-bikes',
|
|
|
|
selector: 'app-bikes',
|
|
|
|
templateUrl: './bikes.component.html',
|
|
|
|
templateUrl: './bikes.component.html',
|
|
|
@ -40,8 +34,10 @@ export class BikesComponent {
|
|
|
|
additionalColumnsBack: string[] = ['buttons'];
|
|
|
|
additionalColumnsBack: string[] = ['buttons'];
|
|
|
|
displayedColumns: string[] = [];
|
|
|
|
displayedColumns: string[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadingRowIds: string[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
bikes = <Array<any>>[];
|
|
|
|
bikes = <Array<any>>[];
|
|
|
|
selection = new SelectionModel<CargoBikeDataRow>(true, []);
|
|
|
|
selection = new SelectionModel<CargoBikeResult>(true, []);
|
|
|
|
|
|
|
|
|
|
|
|
reloadingTable = false;
|
|
|
|
reloadingTable = false;
|
|
|
|
|
|
|
|
|
|
|
@ -58,15 +54,14 @@ export class BikesComponent {
|
|
|
|
).enumValues = groupEnum;
|
|
|
|
).enumValues = groupEnum;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bikesService.loadingRowIds.subscribe(rowIds => {
|
|
|
|
|
|
|
|
this.loadingRowIds = rowIds;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
bikesService.bikes.subscribe((bikes) => {
|
|
|
|
bikesService.bikes.subscribe((bikes) => {
|
|
|
|
this.reloadingTable = false;
|
|
|
|
this.reloadingTable = false;
|
|
|
|
this.bikes = bikes.map((bike) => {
|
|
|
|
|
|
|
|
return <any>Object.assign({}, deepCopy(bike), {
|
|
|
|
this.bikes = bikes;
|
|
|
|
waitingForEditPermissions: false,
|
|
|
|
|
|
|
|
saving: false,
|
|
|
|
|
|
|
|
unlocking: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (bikes[0]) {
|
|
|
|
if (bikes[0]) {
|
|
|
|
this.displayedColumns = [];
|
|
|
|
this.displayedColumns = [];
|
|
|
|
this.dataColumns = [];
|
|
|
|
this.dataColumns = [];
|
|
|
@ -109,9 +104,7 @@ export class BikesComponent {
|
|
|
|
addColumnsFromObject(prefix: string, object: Object) {
|
|
|
|
addColumnsFromObject(prefix: string, object: Object) {
|
|
|
|
for (const prop in object) {
|
|
|
|
for (const prop in object) {
|
|
|
|
let propName = prefix + prop;
|
|
|
|
let propName = prefix + prop;
|
|
|
|
console.log(typeof object[prop]);
|
|
|
|
|
|
|
|
if (typeof object[prop] === 'object') {
|
|
|
|
if (typeof object[prop] === 'object') {
|
|
|
|
console.log(object);
|
|
|
|
|
|
|
|
this.addColumnsFromObject(prefix + prop + '.', object[prop]);
|
|
|
|
this.addColumnsFromObject(prefix + prop + '.', object[prop]);
|
|
|
|
} else if (!this.blacklistedColumns.includes(propName)) {
|
|
|
|
} else if (!this.blacklistedColumns.includes(propName)) {
|
|
|
|
this.dataColumns.push(propName);
|
|
|
|
this.dataColumns.push(propName);
|
|
|
@ -119,6 +112,10 @@ export class BikesComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flatten(object: Object) {
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getHeader(propertyName: string) {
|
|
|
|
getHeader(propertyName: string) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.header ||
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.header ||
|
|
|
@ -135,8 +132,8 @@ export class BikesComponent {
|
|
|
|
|
|
|
|
|
|
|
|
isReadonly(propertyName: string) {
|
|
|
|
isReadonly(propertyName: string) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.readonly ||
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)
|
|
|
|
false
|
|
|
|
?.readonly || false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -149,23 +146,25 @@ export class BikesComponent {
|
|
|
|
|
|
|
|
|
|
|
|
getEnumValues(propertyName: string) {
|
|
|
|
getEnumValues(propertyName: string) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.enumValues ||
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)
|
|
|
|
[]
|
|
|
|
?.enumValues || []
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isLoading(id: string) {
|
|
|
|
|
|
|
|
return this.loadingRowIds.includes(id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
reloadTable() {
|
|
|
|
reloadTable() {
|
|
|
|
this.reloadingTable = true;
|
|
|
|
this.reloadingTable = true;
|
|
|
|
this.bikesService.loadBikes();
|
|
|
|
this.bikesService.loadBikes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
edit(row: CargoBikeDataRow) {
|
|
|
|
edit(row: CargoBikeResult) {
|
|
|
|
row.waitingForEditPermissions = true;
|
|
|
|
|
|
|
|
this.bikesService.lockBike({ id: row.id });
|
|
|
|
this.bikesService.lockBike({ id: row.id });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
save(row: CargoBikeDataRow) {
|
|
|
|
save(row: CargoBikeResult) {
|
|
|
|
row.saving = true;
|
|
|
|
|
|
|
|
const bike: CargoBikeUpdateInput = filter(
|
|
|
|
const bike: CargoBikeUpdateInput = filter(
|
|
|
|
CargoBikeFieldsMutableFragmentDoc,
|
|
|
|
CargoBikeFieldsMutableFragmentDoc,
|
|
|
|
row
|
|
|
|
row
|
|
|
@ -173,8 +172,7 @@ export class BikesComponent {
|
|
|
|
this.bikesService.updateBike({ bike });
|
|
|
|
this.bikesService.updateBike({ bike });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cancel(row: CargoBikeDataRow) {
|
|
|
|
cancel(row: CargoBikeResult) {
|
|
|
|
row.unlocking = true;
|
|
|
|
|
|
|
|
this.bikesService.unlockBike({ id: row.id });
|
|
|
|
this.bikesService.unlockBike({ id: row.id });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|