import { ChangeDetectionStrategy , Component , Input } from '@angular/core' ; import { FormGroup } from '@angular/forms' ; import { CmdbMode } from '../../../modes.enum' ; import { RenderResult } from '../../../models/cmdb-render' ; import { CmdbType } from '../../../models/cmdb-type' ; @ Component ( { selector : 'cmdb-object-bulk-change-preview' , templateUrl : './object-bulk-change-preview.component.html' , styleUrls : [ './object-bulk-change-preview.component.scss' ] , changeDetection : ChangeDetectionStrategy . Default } ) export class ObjectBulkChangePreviewComponent { /**
     * Render form mode.
     */ public readonly mode : CmdbMode = CmdbMode . Simple ; /**
     * Changed data.
     */ @ Input ( ) public changeForm : FormGroup ; /**
     * Object types of bulk change.
     */ @ Input ( ) public type : CmdbType ; private private objectState : boolean ; @ Input ( ) public set activeState ( value ) { this . objectState = value ; } public get activeState ( ) : boolean { return this . objectState ; } /**
     * List of original results.
     */ public originals : Array < RenderResult > = [ ] ; /**
     * List of results.
     */ public results : Array < RenderResult > = [ ] ; @ Input ( 'results' ) public set Results ( renderResults ) { this . results = renderResults ; this . originals = JSON . parse ( JSON . stringify ( renderResults ) ) ; } /**
     * List of paginated items.
     */ public displayedItems : Array < RenderResult > = [ ] ; param name public getField ( name ) { const f = this . type . fields . find ( field => field . name === name ) ; f . value = this . changeForm . get ( name ) . value ; return f ; } param index param name public getOriginal ( index , name ) { return this . displayedItems [ index ] . fields . find ( field => field . name === name ) ; } param items public onChangePage ( items ) { this . displayedItems = items ; } param name public getChangedValue ( name ) { return this . changeForm . get ( name ) . value ; } param index param item public track ( index , item ) { return item . value . value ; } }