/**
 * @since Wed Dec 06 2017
 * @author Charles Gouldmann - Klean
 */


import { Component, OnInit, Input } from '@angular/core';
import { PageBlockService } from '@k-services/svc.pageblock';

@Component({
	moduleId: module.id+'',
	selector: 'form-band',
	templateUrl: 'tpl.form-band.pug',
	styleUrls: ['./sty.form-band.scss']
})
export class FormBandComponent implements OnInit {

	constructor(private _pageBlockService: PageBlockService) { }

	// Vars
	blockContent
	buttonPlacement: string
	@Input('showTitle') showTitle : boolean
	@Input('getBlock') getBlock : string

	ngOnInit() {
		console.log('this.getBlock:')
		console.log(this.getBlock)

		if(!!this.getBlock){
			this.getBlockContent(this.getBlock);
		}
	}


	/**
	 * Get pageblock content containing block content and attached forms
	 * @param identifier
	 */
	getBlockContent(identifier: string) {
		// Get page content
		this._pageBlockService.getBlockContent(identifier)
			.then((content) => {
					this.blockContent = content;
					this.buttonPlacement = 'right'; // TODO: Change to value from request
			});
	}


}


