import { Component, Input, OnInit,
    ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core'

import { DataService } from '../../_services/data.service'
import { FullInfo, InfoDataService } from '../info-data.service'

@Component({
    selector: 'gisaf-info-misc',
    templateUrl: './info-misc.component.html',
    styleUrls: ['./info-misc.component.css'],
    providers: [
        DataService,
    ],
    changeDetection: ChangeDetectionStrategy.OnPush,
})
export class InfoMiscComponent implements OnInit {
    @Input() inMap: boolean = false
    @Input() source: FullInfo
    @Input() class: string

    constructor(
        protected dataService: DataService,
        protected infoDataService: InfoDataService,
        private cdr: ChangeDetectorRef,
    ) {
    }

    ngOnInit() {
        this.infoDataService.dataProviderService$.subscribe(
            (fullInfo: FullInfo) => {
                this.source = fullInfo
                this.cdr.markForCheck()
            }
        )
    }

    hasSurveyInfo(): boolean {
        return Object.keys(this.source.featureInfo.surveyInfoItems).length == 0
    }
}
