import { ChangeDetectionStrategy , ChangeDetectorRef , Component , forwardRef , Input , OnInit } from '@angular/core' ; import { ControlValueAccessor , NG_VALUE_ACCESSOR } from '@angular/forms' ; import { Subject } from 'rxjs' ; import { ContentMessageRef } from '../../../../../main/src/app/content/meta' ; import { DataService } from '../../data.service' ; import { VersionComponent } from '../../version/version/version.component' ; @ Component ( { selector : 'app-message' , templateUrl : './message.component.html' , styleUrls : [ './message.component.scss' ] , changeDetection : ChangeDetectionStrategy . OnPush , providers : [ { provide : NG_VALUE_ACCESSOR , useExisting : forwardRef ( ( ) => MessageComponent ) , multi : true , } , ] , } ) export class MessageComponent implements OnInit , ControlValueAccessor { /**
     * Context for new messages.
     */ @ Input ( ) context : string ; state ? : ContentMessageRef ; disabled = false ; displayModal = false ; private stateChanges = new Subject < ContentMessageRef > ( ) ; private touches = new Subject < void > ( ) ; constructor ( private versionComponent , private cdr , private data ) { } ngOnInit ( ) { } get message ( ) { return this . state ; } save ( value ) { this . stateChanges . next ( value ) ; } registerOnChange ( fn ) { this . stateChanges . subscribe ( fn ) ; } registerOnTouched ( fn ) { this . touches . subscribe ( fn ) ; } setDisabledState ( isDisabled ) { this . disabled = isDisabled ; } writeValue ( rawValue ) { this . state = rawValue ; this . cdr . detectChanges ( ) ; } }