All files / src/app/features/jobs/forms/inputs baseinput.component.ts

65.38% Statements 17/26
33.33% Branches 1/3
55.55% Functions 5/9
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 4320x 20x       20x       58x     58x               58x       58x 58x 58x 58x       3x 3x   3x       634x        
import { Directive, inject, Input, OnInit } from "@angular/core";
import { FormBuilder, FormControl, FormGroup } from "@angular/forms";
import { EditorComponent } from "@tinymce/tinymce-angular";
 
@Directive()
export abstract class BaseInputComponent implements OnInit {
    @Input({ required: true }) form!: FormGroup;
    @Input() initialValue: string | undefined;
 
    protected fb = inject(FormBuilder);
 
    // for rich text editors
    init: EditorComponent['init'] = {
        plugins: ['link', 'autolink', 'lists'],
        toolbar: 'undo redo | bold italic | link | bullist',
        promotion: false,
        menubar: 'null',
        statusbar: false
    };
    
    constructor(protected controlName: string){
    }
 
    ngOnInit(): void {
        console.log('BaseInputComponent ngOnInit ?');
        console.log('form', this.form);
        console.log('initial value', this.initialValue);
        this.configure();
    }
 
    updateRichText(event: any) :boolean {
        if(this.control !== null) {
            this.control.setValue(event.editor.getContent());
        }
        return true;
    }
 
    public get control() {
        return this.form?.get(this.controlName) as FormControl;
    }
 
    abstract configure(): void;
}