<commit_before>import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { ActivatedRoute } from '@angular/router';

import { FormModelParser } from './../../core/services/formModelParser';
import * as appMessage from './../../core/reducers/appMessage';
import * as fromRoot from './../../core/reducers';
import * as {{ $reducer = camel_case($gen->entityName()).'Reducer' }} from './../reducers/{{ camel_case($gen->entityName()) }}.reducer';
import * as {{ $actions = camel_case($gen->entityName()).'Actions' }} from './../actions/{{ camel_case($gen->entityName()) }}.actions';
import { {{ $entitySin = $gen->entityName() }} } from './../models/{{ camel_case($entitySin) }}';

{{ '@' }}Component({
  selector: '{{ str_replace(['.ts', '.'], ['', '-'], $gen->containerFile('details', false, true)) }}',
  templateUrl: './{{ $gen->containerFile('details-html', false, true) }}',
  styleUrls: ['./{{ $gen->containerFile('details-css', false, true) }}']
})
export class {{ $gen->containerClass('details', false, true) }} implements OnInit, OnDestroy {
	
	public {{ $state = camel_case($gen->entityName()).'State$' }}: Observable<{{ $reducer.'.State' }}>;
	public {{ $form = camel_case($gen->entityName()).'Form' }}: FormGroup;
	private formModelSubscription: Subscription;
	public appMessage$: Observable<appMessage.State>;
	public {{ $book = camel_case($gen->entityName()).'$' }}: Observable<{{ $gen->entityName() }}>;
	private {{ $bookSubscription = camel_case($gen->entityName()).'Subscription$' }}: Subscription;
	private id;

  constructor(
  	private store: Store<fromRoot.State>,
  	private formModelParser: FormModelParser,
  	private route: ActivatedRoute
  ) { }

  ngOnInit() {
  	this.{{ $state }} = this.store.select(fromRoot.get{{ $entitySin }}State);
  	this.{{ $book }} = this.store.select(fromRoot.getSelected{{ $entitySin }});
    this.appMessage$ = this.store.select(fromRoot.getAppMessagesState);
    this.store.dispatch(new {{ $actions }}.GetFormModelAction(null));
  	this.store.dispatch(new {{ $actions }}.GetFormDataAction(null));

  	this.{{ $bookSubscription }} = this.{{ $book }}
  		.subscribe(({{ camel_case($gen->entityName()) }}) => {
	      this.route.params.subscribe(params => {
	        this.id = params['id'];
	        if ({{ camel_case($gen->entityName()) }} === null || this.id != {{ camel_case($gen->entityName()) }}.id) {
	        	this.store.dispatch(new {{ $actions }}.GetAction(this.id));
	        } else {
	        	this.{{ $form }}.patchValue(this.get{{ $gen->entityName() }}FormPatchValues({{ camel_case($gen->entityName()) }}));
	        }
	      });
	    });

  	this.formModelSubscription = this.store.select(fromRoot.get{{ $entitySin }}FormModel)
      .subscribe((model) => {
        this.{{ $form }} = this.formModelParser.toFormGroup(model);
      });
  }

  public ngOnDestroy() {
    this.formModelSubscription.unsubscribe();
  }

  private get{{ $gen->entityName() }}FormPatchValues({{ camel_case($gen->entityName()) }}: {{ $entitySin }}) {
  	return {
  		...{{ camel_case($gen->entityName()) }},
@foreach ($fields as $field)
@if ($field->namespace)
			{{ $field->name }}: {{ camel_case($gen->entityName()) }}.{{ $gen->relationNameFromField($field) }}.data.name,
@endif
@if (in_array($field->type, ['timestamp', 'datetime']))
			{{ $field->name }}: {{ camel_case($gen->entityName()) }}.{{ $field->name }} ? {{ camel_case($gen->entityName()) }}.{{ $field->name }}.date : null,
@endif
@endforeach
		};
  }
}<commit_msg>better setup for generated Angular details container component<commit_after>import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { ActivatedRoute } from '@angular/router';

import { FormModelParser } from './../../core/services/formModelParser';
import * as appMessage from './../../core/reducers/appMessage';
import * as fromRoot from './../../core/reducers';
import * as {{ $reducer = camel_case($gen->entityName()).'Reducer' }} from './../reducers/{{ camel_case($gen->entityName()) }}.reducer';
import * as {{ $actions = camel_case($gen->entityName()).'Actions' }} from './../actions/{{ camel_case($gen->entityName()) }}.actions';
import { {{ $entitySin = $gen->entityName() }} } from './../models/{{ camel_case($entitySin) }}';

{{ '@' }}Component({
  selector: '{{ str_replace(['.ts', '.'], ['', '-'], $gen->containerFile('details', false, true)) }}',
  templateUrl: './{{ $gen->containerFile('details-html', false, true) }}',
  styleUrls: ['./{{ $gen->containerFile('details-css', false, true) }}']
})
export class {{ $gen->containerClass('details', false, true) }} implements OnInit, OnDestroy {
	
	public {{ $state = camel_case($gen->entityName()).'State$' }}: Observable<{{ $reducer.'.State' }}>;
	public {{ $form = camel_case($gen->entityName()).'Form' }}: FormGroup;
	private formModelSubscription: Subscription;
	public appMessage$: Observable<appMessage.State>;
	public {{ $book = camel_case($gen->entityName()).'$' }}: Observable<{{ $gen->entityName() }}>;
	private {{ $bookSubscription = camel_case($gen->entityName()).'Subscription$' }}: Subscription;
	private id;

  constructor(
  	private store: Store<fromRoot.State>,
  	private formModelParser: FormModelParser,
  	private route: ActivatedRoute
  ) { }

  ngOnInit() {
  	this.{{ $state }} = this.store.select(fromRoot.get{{ $entitySin }}State);
  	this.{{ $book }} = this.store.select(fromRoot.getSelected{{ $entitySin }});
    this.appMessage$ = this.store.select(fromRoot.getAppMessagesState);
    this.store.dispatch(new {{ $actions }}.GetFormModelAction(null));
  	this.store.dispatch(new {{ $actions }}.GetFormDataAction(null));

  	this.formModelSubscription = this.store.select(fromRoot.get{{ $entitySin }}FormModel)
      .subscribe((model) => {
        this.{{ $form }} = this.formModelParser.toFormGroup(model);
        this.setupformData();
      });
  }

  public ngOnDestroy() {
    this.formModelSubscription.unsubscribe();
  }

  private setupformData() {
  	this.{{ $bookSubscription }} = this.{{ $book }}
  		.subscribe(({{ camel_case($gen->entityName()) }}) => {
	      this.route.params.subscribe(params => {
	        this.id = params['id'];
	        if ({{ camel_case($gen->entityName()) }} === null || this.id != {{ camel_case($gen->entityName()) }}.id) {
	        	this.store.dispatch(new {{ $actions }}.GetAction(this.id));
	        } else {
	        	this.{{ $form }}.patchValue(this.get{{ $gen->entityName() }}FormPatchValues({{ camel_case($gen->entityName()) }}));
	        }
	      });
	    });
  }

  private get{{ $gen->entityName() }}FormPatchValues({{ camel_case($gen->entityName()) }}: {{ $entitySin }}) {
  	return {
  		...{{ camel_case($gen->entityName()) }},
@foreach ($fields as $field)
@if ($field->namespace)
			{{ $field->name }}: {{ camel_case($gen->entityName()) }}.{{ $gen->relationNameFromField($field) }} ? {{ camel_case($gen->entityName()) }}.{{ $gen->relationNameFromField($field) }}.data.name : null,
@endif
@if (in_array($field->type, ['timestamp', 'datetime']))
			{{ $field->name }}: {{ camel_case($gen->entityName()) }}.{{ $field->name }} ? {{ camel_case($gen->entityName()) }}.{{ $field->name }}.date : null,
@endif
@endforeach
		};
  }
}
{'fraction_non_alphanumeric': 0.22520963662984161, 'fraction_numerical': 0.0, 'mean_word_length': 4.386379928315412, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6650104', 'n_tokens_mistral': 2437, 'n_tokens_neox': 2346, 'n_words': 425}