Skip to content

Commit

Permalink
Zhylka/fixed keywords in editMode (#2663)
Browse files Browse the repository at this point in the history
* removed comma and added keyWords init

* first load fix
  • Loading branch information
MaxZhylka authored Dec 6, 2024
1 parent c6df068 commit 287da91
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
import {
AfterViewInit,
ChangeDetectionStrategy,
Component,
ElementRef,
EventEmitter,
Input,
OnDestroy,
OnInit,
Output,
ViewChild
} from '@angular/core';
import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { ENTER } from '@angular/cdk/keycodes';
import { CropperConfigurationConstants } from 'shared/constants/constants';
import { MUST_CONTAIN_LETTERS } from 'shared/constants/regex-constants';
import { ValidationConstants } from 'shared/constants/validation';
Expand All @@ -18,7 +29,7 @@ import { Util } from 'shared/utils/utils';
styleUrls: ['./create-description-form.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CreateDescriptionFormComponent implements OnInit, OnDestroy {
export class CreateDescriptionFormComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() public workshop: Workshop;
@Input() public isImagesFeature: boolean;
@Input() public provider: Provider;
Expand Down Expand Up @@ -48,12 +59,11 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy {
public keyWordsCtrl: FormControl = new FormControl('', Validators.required);

public keyWords: string[] = [];
public keyWord: string;

public disabilityOptionRadioBtn: FormControl = new FormControl(false);

public competitiveSelectionRadioBtn: FormControl = new FormControl(false);
public separatorKeysCodes = [COMMA, ENTER];
public separatorKeysCodes = [ENTER];
private destroy$: Subject<boolean> = new Subject<boolean>();

constructor(private formBuilder: FormBuilder) {
Expand Down Expand Up @@ -86,6 +96,10 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy {
this.onCompetitiveSelectionInit();
}

public ngAfterViewInit(): void {
this.updateKeywordsInputState();
}

/**
* This method remove already added keywords from the list of keywords
* @param word
Expand Down Expand Up @@ -180,7 +194,7 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy {
this.DescriptionFormGroup.patchValue(this.workshop, { emitEvent: false });

this.workshop.keywords.forEach((keyWord: string) => {
this.keyWord = keyWord;
this.keyWordsCtrl.setValue(keyWord);
this.onKeyWordsInput(false);
});

Expand Down

0 comments on commit 287da91

Please sign in to comment.