import { AbstractControl } from '@angular/forms'; import { buildTitleMap } from '../../shared'; import { Component, Input, OnInit } from '@angular/core'; import { JsonSchemaFormService } from '../../json-schema-form.service'; @Component({ // tslint:disable-next-line:component-selector selector: 'material-button-group-widget', template: `
`, styles: [` mat-error { font-size: 75%; } `], }) export class MaterialButtonGroupComponent implements OnInit { formControl: AbstractControl; controlName: string; controlValue: any; controlDisabled = false; boundControl = false; options: any; radiosList: any[] = []; vertical = false; @Input() layoutNode: any; @Input() layoutIndex: number[]; @Input() dataIndex: number[]; constructor( private jsf: JsonSchemaFormService ) { } ngOnInit() { this.options = this.layoutNode.options || {}; this.radiosList = buildTitleMap( this.options.titleMap || this.options.enumNames, this.options.enum, true ); this.jsf.initializeControl(this); } updateValue(value) { this.options.showErrors = true; this.jsf.updateValue(this, value); } }