From be51eccc410e26909a0dde7c92c7b68b5f335f6e Mon Sep 17 00:00:00 2001 From: Max Ehrlicher-Schmidt Date: Wed, 23 Sep 2020 18:29:07 +0200 Subject: [PATCH] Fix table editing --- codegen.yml | 2 +- .../string-cell/string-cell.component.ts | 5 +++-- src/app/graphql.module.ts | 13 +++---------- src/app/pages/tables/bikes/bikes.component.html | 11 ++++++----- src/app/pages/tables/bikes/bikes.component.ts | 12 ++++++++---- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/codegen.yml b/codegen.yml index 6266518..dfbd037 100644 --- a/codegen.yml +++ b/codegen.yml @@ -1,6 +1,6 @@ overwrite: true schema: "http://localhost:4000/graphql" -documents: "src/app/graphqlOperations/**/*" +documents: "src/app/graphqlOperations/**/*.graphql" generates: src/generated/graphql.ts: plugins: diff --git a/src/app/components/tableComponents/string-cell/string-cell.component.ts b/src/app/components/tableComponents/string-cell/string-cell.component.ts index 6cab8a0..1e1948f 100644 --- a/src/app/components/tableComponents/string-cell/string-cell.component.ts +++ b/src/app/components/tableComponents/string-cell/string-cell.component.ts @@ -1,4 +1,5 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { catchError } from 'rxjs/operators'; @Component({ selector: 'app-string-cell', @@ -15,7 +16,7 @@ export class StringCellComponent { inputType = 'text'; change(newValue) { - this.value = newValue; - this.valueChange.emit(newValue); + this.value = this.inputType === 'number' ? +newValue : newValue; + this.valueChange.emit(this.value); } } diff --git a/src/app/graphql.module.ts b/src/app/graphql.module.ts index badafbb..eaee8ab 100644 --- a/src/app/graphql.module.ts +++ b/src/app/graphql.module.ts @@ -11,15 +11,8 @@ import { environment } from '../environments/environment'; const uri = environment.apiUrl + '/graphql'; // <-- add the URL of the GraphQL server here -const cleanTypeName = new ApolloLink((operation, forward) => { - if (operation.variables) { - const omitTypename = (key: string, value: any) => - key === '__typename' ? undefined : value; - operation.variables = JSON.parse( - JSON.stringify(operation.variables), - omitTypename - ); - } +const authMiddleware = new ApolloLink((operation, forward) => { + //Add token here <------------------------------------------------------- return forward(operation).map((data) => { return data; }); @@ -27,7 +20,7 @@ const cleanTypeName = new ApolloLink((operation, forward) => { export function createApollo(httpLink: HttpLink): ApolloClientOptions { return { - link: concat(cleanTypeName, httpLink.create({ uri })), + link: concat(authMiddleware, httpLink.create({ uri })), cache: new InMemoryCache({}), }; } diff --git a/src/app/pages/tables/bikes/bikes.component.html b/src/app/pages/tables/bikes/bikes.component.html index 136ceb7..f14e5b5 100644 --- a/src/app/pages/tables/bikes/bikes.component.html +++ b/src/app/pages/tables/bikes/bikes.component.html @@ -1,7 +1,6 @@
- - +
edit @@ -96,7 +96,8 @@ *ngIf=" !element.isGettingEdited && !element.waitingForEditPermissions && - !element.locked + !element.locked && + !element.saving " > delete @@ -104,7 +105,7 @@