|
|
@ -4,10 +4,11 @@ import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
|
|
|
import { BikesService, CargoBikeResult } from 'src/app/services/bikes.service';
|
|
|
|
import { BikesService, CargoBikeResult } from 'src/app/services/bikes.service';
|
|
|
|
import { deepCopy } from 'src/app/helperFunctions/deepCopy';
|
|
|
|
import { deepCopy } from 'src/app/helperFunctions/deepCopy';
|
|
|
|
import { filter } from 'graphql-anywhere';
|
|
|
|
import { filter } from 'graphql-anywhere';
|
|
|
|
import {CargoBikeFieldsMutableFragmentDoc} from 'src/generated/graphql';
|
|
|
|
import {CargoBikeFieldsMutableFragmentDoc, CargoBikeUpdateInput} from 'src/generated/graphql';
|
|
|
|
|
|
|
|
|
|
|
|
type CargoBikeDataRow = CargoBikeResult & {
|
|
|
|
type CargoBikeDataRow = CargoBikeResult & {
|
|
|
|
waitingForEditPermissions: boolean;
|
|
|
|
waitingForEditPermissions: boolean;
|
|
|
|
|
|
|
|
saving: boolean;
|
|
|
|
isGettingEdited: boolean;
|
|
|
|
isGettingEdited: boolean;
|
|
|
|
locked: boolean;
|
|
|
|
locked: boolean;
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -37,6 +38,7 @@ export class BikesComponent {
|
|
|
|
waitingForEditPermissions: false,
|
|
|
|
waitingForEditPermissions: false,
|
|
|
|
isGettingEdited: false,
|
|
|
|
isGettingEdited: false,
|
|
|
|
locked: false,
|
|
|
|
locked: false,
|
|
|
|
|
|
|
|
saving: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (this.bikes.length > 6) {
|
|
|
|
if (this.bikes.length > 6) {
|
|
|
@ -56,15 +58,17 @@ export class BikesComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
save(row: CargoBikeDataRow) {
|
|
|
|
save(row: CargoBikeDataRow) {
|
|
|
|
//remove lock
|
|
|
|
//TODO: remove lock
|
|
|
|
this.bikesService.updateBike({bike: filter(CargoBikeFieldsMutableFragmentDoc, row)})
|
|
|
|
row.saving = true;
|
|
|
|
|
|
|
|
row.isGettingEdited = false;
|
|
|
|
|
|
|
|
const bike: CargoBikeUpdateInput = filter(CargoBikeFieldsMutableFragmentDoc, row)
|
|
|
|
|
|
|
|
this.bikesService.updateBike({bike})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cancel(row: CargoBikeDataRow) {
|
|
|
|
cancel(row: CargoBikeDataRow) {
|
|
|
|
//fetch it again
|
|
|
|
//fetch it again
|
|
|
|
//TODO: remove lock
|
|
|
|
//TODO: remove lock
|
|
|
|
this.bikesService.reloadBike({ id: row.id });
|
|
|
|
this.bikesService.reloadBike({ id: row.id });
|
|
|
|
console.log('cancel');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
drop(event: CdkDragDrop<string[]>) {
|
|
|
|
drop(event: CdkDragDrop<string[]>) {
|
|
|
|