From e9d686a4c108d7e18fd050a50943cda592f9e097 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Mon, 2 Sep 2024 10:48:24 +0200 Subject: [PATCH] =?UTF-8?q?fix(receiver-table):=20Problem=20mit=20automati?= =?UTF-8?q?scher=20Anredezuweisung=20f=C3=BCr=20den=20ersten=20hinzugef?= =?UTF-8?q?=C3=BCgten=20Empf=C3=A4nger=20behoben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Bedingung in der Funktion `receiver_filter` aktualisiert, um den Indexwert korrekt zu überprüfen. --- .../receiver-table/receiver-table.component.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/components/receiver-table/receiver-table.component.ts b/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/components/receiver-table/receiver-table.component.ts index d637f715..2a7671ec 100644 --- a/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/components/receiver-table/receiver-table.component.ts +++ b/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/src/app/components/receiver-table/receiver-table.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core'; +import { Component, OnInit, QueryList, ViewChildren } from '@angular/core'; import { FormsModule, ReactiveFormsModule, FormControl } from '@angular/forms'; import { MatInputModule } from '@angular/material/input'; import { MatTableModule } from '@angular/material/table'; @@ -45,17 +45,19 @@ export class ReceiverTableComponent implements OnInit { receiver_filter: (value: string, options: string[], index?: number) => string[] = (value, options, index) => { const filterValue = value.toLowerCase(); - // set the name if it is used befor + // set the name if it is used before const name = this.last_used_name[value]; - if (name && index) + + if (name && index != null && index != undefined) { this.receiverData.at(index)!.name = name + } // !!! do not allow email duplication !!! var similarMails = this.receiver_mails.filter(m => m.toLocaleLowerCase() === value.toLocaleLowerCase() && m !== value) if (similarMails.length > 0 && index != undefined) { this.receiverInputs[index].text = similarMails[0]; } - console.log(this.receiverInputs.length + " - " + index) + // if added into last row if (value.length > 0 && (this.receiverInputs.at(-1)?.lenght ?? 0) > 0) { this.receiverData.at(-1)!.accessCode = generateAccessCode(); @@ -64,7 +66,7 @@ export class ReceiverTableComponent implements OnInit { } // delete the row with out mail else if (value.length === 0 && this.receiverInputs.length - 1 !== index) { - if ( this.receiverInputs.length > 1 && this.receiverInputs[index!]?.lenght === 0) { + if (this.receiverInputs.length > 1 && this.receiverInputs[index!]?.lenght === 0) { this.receiverData.splice(index!, 1); this.update(); }