Newer
Older
InputElement, OptionElement, PositionedUIElement, UIElement
} from 'common/models/elements/element';
import { ElementComponent } from 'common/directives/element-component.directive';
import { RadioGroupImagesComponent } from 'common/components/input-elements/radio-group-images.component';
import { AnswerScheme, AnswerSchemeValue } from 'common/models/elements/answer-scheme-interfaces';
import { TextImageLabel } from 'common/models/elements/label-interfaces';
import { BasicStyles, PositionProperties } from 'common/models/elements/property-group-interfaces';
export class RadioButtonGroupComplexElement extends InputElement implements PositionedUIElement, OptionElement {
options: TextImageLabel[] = [];
position: PositionProperties;
styling: BasicStyles;
constructor(element: Partial<RadioButtonGroupComplexElement>) {
super({ dimensions: { height: 100 }, ...element });
if (element.options) this.options = [...element.options];
this.itemsPerRow = element.itemsPerRow !== undefined ? element.itemsPerRow : null;
this.position = UIElement.initPositionProps({ marginBottom: { value: 40, unit: 'px' }, ...element.position });
...UIElement.initStylingProps({ backgroundColor: 'transparent', ...element.styling })
hasAnswerScheme(): boolean {
return Boolean(this.getAnswerScheme);
getAnswerScheme(): AnswerScheme {
return {
id: this.id,
type: 'integer',
format: '',
multiple: false,
nullable: !this.value && this.value !== 0,
values: this.getAnswerSchemeValues(),
valuesComplete: true
};
}
private getAnswerSchemeValues(): AnswerSchemeValue[] {
.map((option, index) => ({
value: (index + 1).toString(),
label: InputElement.stripHTML(option.text)
}));
getElementComponent(): Type<ElementComponent> {
getNewOptionLabel(optionText: string): TextImageLabel {
return UIElement.createOptionLabel(optionText, true) as TextImageLabel;