Project

General

Profile

« Previous | Next » 

Revision 51771

fixed some bugs

View differences:

datasource-interface-form.component.ts
43 43
    baseUrl: ['', Validators.required],
44 44
    selectValidationSet: [''],
45 45
    customValidationSet: [''],
46
    compatibilityLevel: ['', Validators.required]
46
    compatibilityLevel: ['']
47 47
  };
48 48
  baseUrlDesc: Description = baseUrlDesc;
49 49
  existingValSetDesc: Description = existingValSetDesc;
......
58 58

  
59 59
  ngOnInit() {
60 60
    this.currentRepository = <Repository>this.otherData;
61
    this.getCompatibilityClasses();
62 61
    console.log(`other data is: ${JSON.stringify(this.otherData,null,2)}`);
63 62
    if (this.data && this.data.length) {
64 63
      this.currentInterface = this.data[0];
......
80 79
    /* initializes MyGroup parent component and the FormGroup */
81 80
    super.ngOnInit();
82 81
    console.log(this.group, this.parentGroup);
82
    this.getCompatibilityClasses();
83 83

  
84
    if (this.currentInterface) {
85
      console.log(`accessParams is ${JSON.stringify(this.currentInterface.accessParams)}`);
86
      if ( !this.getMyControl('compatibilityLevel').value || !this.classCodes.filter( x => x == this.currentInterface.desiredCompatibilityLevel).length ) {
87
        this.getMyControl('compatibilityLevel').setValue("");
88
        this.existingCompLevel = this.currentInterface.desiredCompatibilityLevel;
89
      } else {
90
        this.getMyControl('compatibilityLevel').setValue(this.compClasses[this.currentInterface.desiredCompatibilityLevel]);
91
      }
92
      if (this.group.valid ) {
93
        if (this.group.valid && ( this.getMyControl('selectValidationSet').value || this.getMyControl('customValidationSet').value ) ) {
94
          this.exportedData = this.currentInterface;
95
        }
96
      }
97
    }
98

  
99 84
    /*  NOT ANYMORE
100 85
    if (this.currentInterface) {
101 86
      this.getMyControl('baseUrl').disable();
......
115 100
      this.getMyControl('selectValidationSet').disable();
116 101
      this.getMyControl('customValidationSet').enable();
117 102
    }
103
    this.checkIfValid();
118 104
  }
119 105

  
120 106
  getInterfaceInfo(baseUrl: string) {
......
144 130
        },
145 131
        () => {
146 132
          if ( this.currentInterface && this.currentInterface.accessParams && this.currentInterface.accessParams['set'] ) {
147
            if ( this.valsetList.filter( x => x === this.currentInterface.accessParams['set']).length ) {
133
            if ( this.valsetList.some( x => x === this.currentInterface.accessParams['set']) ) {
148 134
              this.patchData.next({selectValidationSet:this.currentInterface.accessParams['set']});
149 135
            } else {
150 136
              this.patchData.next({customValidationSet:this.currentInterface.accessParams['set']});
......
169 155
      error => {
170 156
        this.errorMessage = noServiceMessage;
171 157
        console.log(error);
158
      },
159
      () => {
160
        if (this.currentInterface) {
161
          console.log(`accessParams is ${JSON.stringify(this.currentInterface.accessParams)}`);
162
          if ( !this.currentInterface.desiredCompatibilityLevel || !this.classCodes.some( x => x == this.currentInterface.desiredCompatibilityLevel ) ) {
163
            this.patchData.next({compatibilityLevel:''});
164
            this.existingCompLevel = this.currentInterface.desiredCompatibilityLevel;
165
          } else {
166
            this.existingCompLevel = this.compClasses[this.currentInterface.desiredCompatibilityLevel];
167
          }
168
          if (this.group.valid ) {
169
            if ( this.getMyControl('selectValidationSet').value || this.getMyControl('customValidationSet').value ) {
170
              this.exportedData = this.currentInterface;
171
            }
172
          }
173
        }
174

  
172 175
      }
173 176
    );
174 177
  }
......
177 180
    this.groupErrorMessage = '';
178 181
    this.errorMessage = '';
179 182
    this.successMessage = '';
180
    if (this.group.valid && ( this.getMyControl('selectValidationSet').value || this.getMyControl('customValidationSet').value ) ) {
183
    if (this.group.valid && this.checkIfValsetWasChosen() && this.checkIfCompatibilityLevelWasChosen() ) {
181 184
      if (this.identifiedBaseUrl) {
182 185
        let baseUrl = this.getMyControl('baseUrl').value;
183 186
        let valset: string = '';
......
186 189
        } else {
187 190
          valset = this.getMyControl('customValidationSet').value;
188 191
        }
189
        let compLvl = this.getMyControl('compatibilityLevel').value;
192
        let compLvl: string = '';
193
        if (this.getMyControl('compatibilityLevel').value) {
194
          compLvl = this.getMyControl('compatibilityLevel').value;
195
        } else {
196
          compLvl = this.existingCompLevel;
197
        }
190 198

  
199

  
191 200
        if (this.currentInterface) {
192 201
          this.updateCurrent(baseUrl,valset,compLvl);
193 202
        } else {
......
202 211
    }
203 212
  }
204 213

  
214
  checkIfValsetWasChosen() {
215
    return ( ( this.getMyControl('selectValidationSet').enabled && this.getMyControl('selectValidationSet').value !='' ) || ( this.getMyControl('customValidationSet').enabled && this.getMyControl('customValidationSet').value !='' ) );
216
  }
217

  
218
  checkIfCompatibilityLevelWasChosen() {
219
    return ( this.getMyControl('compatibilityLevel').value != '' || (this.existingCompLevel && this.existingCompLevel != '') );
220
  }
221

  
205 222
  checkIfValid() {
223
    console.log(this.existingCompLevel);
206 224
    if (this.inRegister) {
207
      if (this.group.valid && ( this.getMyControl('selectValidationSet').value || this.getMyControl('customValidationSet').value ) ) {
208
        if (this.identifiedBaseUrl) {
225
      if ( this.group.valid && this.checkIfValsetWasChosen() && this.checkIfCompatibilityLevelWasChosen() ) {
226
        if ( this.identifiedBaseUrl ) {
209 227
          let baseUrl = this.getMyControl('baseUrl').value;
228

  
210 229
          let valset: string = '';
211 230
          if (this.getMyControl('selectValidationSet').enabled) {
212 231
            valset = this.getMyControl('selectValidationSet').value;
213 232
          } else {
214 233
            valset = this.getMyControl('customValidationSet').value;
215 234
          }
216
          let compLvl = this.getMyControl('compatibilityLevel').value;
217 235

  
236
          let compLvl: string = '';
237
          if (this.getMyControl('compatibilityLevel').value) {
238
            compLvl = this.getMyControl('compatibilityLevel').value;
239
          } else {
240
            compLvl = this.existingCompLevel;
241
          }
242

  
218 243
          if (this.currentInterface) {
219 244
            this.updateCurrent(baseUrl,valset,compLvl);
220 245
          } else {
221 246
            this.addCurrent(baseUrl,valset,compLvl);
222 247
          }
223 248
        }
249
      } else {
250
        this.exportedData = null;
251
        this.wasSaved = false;
252
        this.successMessage = '';
224 253
      }
225 254
    }
226 255
  }

Also available in: Unified diff