#726 required validator for radio buttons, bug fixes

- REST service data support, fixes #747
- proper value selection on reload, fixes #746
This commit is contained in:
Denys Vuika
2016-09-14 20:26:21 +01:00
parent 16eb825a51
commit 3878ea29a4
6 changed files with 61 additions and 10 deletions

View File

@@ -15,8 +15,10 @@
* limitations under the License.
*/
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { WidgetComponent } from './../widget.component';
import { FormService } from '../../../services/form.service';
import { FormFieldOption } from './../core/form-field-option';
declare let __moduleName: string;
declare var componentHandler;
@@ -27,6 +29,32 @@ declare var componentHandler;
templateUrl: './radio-buttons.widget.html',
styleUrls: ['./radio-buttons.widget.css']
})
export class RadioButtonsWidget extends WidgetComponent {
export class RadioButtonsWidget extends WidgetComponent implements OnInit {
constructor(private formService: FormService) {
super();
}
ngOnInit() {
if (this.field && this.field.restUrl) {
this.formService
.getRestFieldValues(
this.field.form.taskId,
this.field.id
)
.subscribe(
(result: FormFieldOption[]) => {
let options = [];
this.field.options = result || [];
this.field.updateForm();
},
this.handleError
);
}
}
handleError(error: any) {
console.error(error);
}
}