Project

General

Profile

« Previous | Next » 

Revision 59468

[Trunk | Admin]: Merging branch 'use-UoaAdminToolsLibrary' into trunk for revisions 58405:59467

View differences:

community-form.component.ts
1 1
import {Component, OnInit, Input} from '@angular/core';
2
import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms";
3
import { HelpContentService } from "../../services/help-content.service";
2
import {FormGroup, FormBuilder, Validators} from "@angular/forms";
4 3

  
5 4
@Component({
6 5
    selector: 'community-form',
......
14 13

  
15 14
    public errorMessage: string;
16 15

  
17
    constructor(public _fb: FormBuilder, private _helpContentService: HelpContentService) {}
16
    constructor(public _fb: FormBuilder) {}
18 17

  
19 18
    ngOnInit(): void {}
20 19

  
21 20
    public get form() {
22
        return this._fb.group({
23
            _id : '',
24
            pid: ['', Validators.required],
25
            name : ['', Validators.required]
26
        });
21
      return this._fb.group({
22
        _id: '',
23
        pid: ['', Validators.required],
24
        name: ['', Validators.required],
25
        type: ['', Validators.required]
26
      });
27 27
    }
28 28

  
29 29
    public reset() {
30
        this.myForm.patchValue({
31
            name : '',
32
            _id : '',
33
            pid: ''
34
        });
30
      this.myForm.patchValue({
31
        name : '',
32
        _id : '',
33
        pid: '',
34
        type: ''
35
      });
35 36
    }
36 37

  
37 38
    handleError(message: string, error) {
38
        if(error == null) {
39
            this.reset();
40
        }
41
        this.errorMessage = message + ' (Server responded: ' + error + ')';
39
      if(error == null) {
40
        this.reset();
41
      }
42
      this.errorMessage = message + ' (Server responded: ' + error + ')';
42 43
    }
43 44
}

Also available in: Unified diff