Project

General

Profile

« Previous | Next » 

Revision 51581

fixed checking if at least one interface was saved

View differences:

sr-literature.component.ts
10 10
import { FormBuilder, FormGroup } from '@angular/forms';
11 11
import { Description, interfaceFormDesc } from '../../../domain/oa-description';
12 12
import { RepositoryService } from '../../../services/repository.service';
13
import { formInfoLoading, loadingRepoError } from '../../../domain/shared-messages';
13
import {formInfoLoading, loadingRepoError, noInterfacesSaved} from '../../../domain/shared-messages';
14 14
import {ActivatedRoute, Params, Router} from "@angular/router";
15
import {MyArray} from "../../../shared/reusablecomponents/forms/my-array.interface";
15 16

  
16 17
@Component ({
17 18
  selector:'app-sr-literature',
......
45 46
  @ViewChild('updateDatasource')
46 47
  public updateDatasource: DatasourceUpdateFormComponent;
47 48

  
49
  @ViewChild('interfaceFormArray')
50
    public interfaceFormArray: MyArray;
51

  
48 52
  group: FormGroup;
49 53
  interfaceFormDesc: Description = interfaceFormDesc;
50 54
  updateDatasourceInterfaces: Type<any> = DatasourceInterfaceFormComponent;
......
62 66
  }
63 67

  
64 68
  moveAStep(){
69
    this.errorMessage = '';
65 70
    if(this.showRepositories) {
66 71
      if (this.datasourcesByCountry.goToNextStep()) {
67 72
        this.setQueryParam('basicInformation');
......
73 78
    } else if(this.showForm) {
74 79
        this.updateDatasource.updateRepo();
75 80
    } else if(this.showInterfaces) {
81
      if (this.interfaceFormArray.checkIfOneElementExists()) {
76 82
        this.setQueryParam('finish');
77 83
        this.showInterfaces = false;
78 84
        this.showFinish = true;
79 85
        this.step4 = 'active';
86
      } else {
87
        this.errorMessage = noInterfacesSaved;
88
      }
80 89
    }
81 90
  }
82 91

  
......
139 148
  getRepoInterfaces() {
140 149
    this.repoService.getRepositoryInterface(this.datasourceId).subscribe(
141 150
      interfaces => {
142
        this.repoInterfaces = interfaces;
143
        console.log(this.repoInterfaces.length);
151
        this.repoInterfaces = interfaces.sort( function(a,b) {
152
          if(a.id<b.id){
153
            return -1;
154
          } else if(a.id>b.id){
155
            return 1;
156
          } else {
157
            return 0;
158
          }
159
        });
160
        console.log(`the number of interfaces is ${this.repoInterfaces.length}`);
144 161
      },
145 162
      error => console.log(error),
146 163
      () => {

Also available in: Unified diff