argos/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.componen...

46 lines
1.2 KiB
TypeScript
Raw Normal View History

import { DataModel } from '../../entities/DataModel';
import { GroupBase } from './group-base';
2017-10-06 16:33:08 +02:00
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, Validators } from '@angular/forms';
import { NgForm } from '@angular/forms';
@Component({
selector: 'df-group',
templateUrl: './dynamic-form-group.component.html',
styleUrls: ['./dynamic-form-group.component.css']
})
export class DynamicFormGroupComponent implements OnInit {
@Input() dataModel: DataModel;
@Input() group: GroupBase<any>;
@Input() form: FormGroup;
2017-10-06 16:33:08 +02:00
@Input() customStyle: {};
@Input() classFromJson: string ;
constructor() {
}
ngOnInit() {
2017-10-06 16:33:08 +02:00
let st = this.group.style == "any" ? "" : this.group.style;
this.classFromJson = this.group.class == "" ? "" : this.group.class;
this.customStyle = {};
if (st != "") {
st.replace(/"/g, '\\"');
var attributes = st.split(';');
for (var i = 0; i < attributes.length; i++) {
var entry = attributes[i].split(':');
entry[1].replace(/["]/g, " ");
//this.customStyle[entry[0]] = '2px solid #c1baba';
var a = entry[0];
this.customStyle[a] = entry[1];
}
}
}
}