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(); }