Project

General

Profile

1
import { Component } from '@angular/core';
2
import { MyGroup } from '../../shared/reusablecomponents/forms/my-group.interface';
3
import { Validators } from '@angular/forms';
4
import { formErrorRequiredFields, formSuccessAddedInterface } from '../../domain/shared-messages';
5

    
6
@Component ({
7
  selector: 'update-datasource-interface-form',
8
  templateUrl: 'update-datasource-interface-form.component.html'
9
})
10

    
11
export class UpdateDatasourceInterfaceFormComponent extends MyGroup {
12

    
13
  successMessage: string;
14
  errorMessage: string;
15
  existingValSet: boolean;
16

    
17
  readonly groupDefinition = {
18
    baseUrl: ['', Validators.required],
19
    selectValidationSet: [''],
20
    customValidationSet: [''],
21
    compatibilityLevel: ['', Validators.required],
22
  };
23

    
24

    
25
  ngOnInit(){
26

    
27
    super.ngOnInit();
28
    console.log(this.group,this.parentGroup);
29

    
30
    if (this.data.length) {
31
/*
32
      this.group.patchValue({
33
        baseUrl : this.data[0].baseUrl,
34
        selectValidationSet : this.data[0].accessSet,
35
        compatibilityLevel : this.data[0].desiredCompatibilityLevel
36
      });
37
*/
38
      this.patchData.next({
39
        baseUrl : this.data[0].baseUrl,
40
        selectValidationSet : this.data[0].accessSet,
41
        compatibilityLevel : this.data[0].desiredCompatibilityLevel
42
      });
43
      this.data.splice(0,1);
44
    }
45

    
46
    this.existingValSet = true;
47
    this.getMyControl('customValidationSet').disable();
48
  }
49

    
50

    
51
  chooseValSet(existingValSet: boolean) {
52
     if(existingValSet) {
53
       this.existingValSet = true;
54
       this.getMyControl('selectValidationSet').enable();
55
       this.getMyControl('customValidationSet').disable();
56
     }  else {
57
       this.existingValSet = false;
58
       this.getMyControl('selectValidationSet').disable();
59
       this.getMyControl('customValidationSet').enable();
60
     }
61
  }
62

    
63
  saveInterface() {
64
    if(this.group.valid) {
65
      this.successMessage = formSuccessAddedInterface;
66
      this.errorMessage = '';
67
    } else {
68
      this.errorMessage = formErrorRequiredFields;
69
      this.successMessage = '';
70
    }
71
  }
72

    
73
}
(12-12/12)