From 70911a76fae86ee36fa47b9581123a6f28de6b09 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 | 8 +++++--- src/app/pages/tables/bikes/bikes.component.ts | 12 ++++++++---- 5 files changed, 20 insertions(+), 20 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..d87cdf6 100644 --- a/src/app/pages/tables/bikes/bikes.component.html +++ b/src/app/pages/tables/bikes/bikes.component.html @@ -86,7 +86,8 @@ *ngIf=" !element.isGettingEdited && !element.waitingForEditPermissions && - !element.locked + !element.locked && + !element.saving " > edit @@ -96,7 +97,8 @@ *ngIf=" !element.isGettingEdited && !element.waitingForEditPermissions && - !element.locked + !element.locked && + !element.saving " > delete @@ -104,7 +106,7 @@