Project

General

Profile

« Previous | Next » 

Revision 50469

continued with compatibility validate

View differences:

journal-info-form.component.ts
3 3
*/
4 4

  
5 5
import { Component, OnInit } from '@angular/core';
6
import { formErrorRequiredFields, formSuccessRegisteredDatasource, noServiceMessage } from '../../../domain/shared-messages';
6
import {
7
  formErrorInvalidFields, formErrorRequiredFields, formSuccessRegisteredDatasource,
8
  noServiceMessage
9
} from '../../../domain/shared-messages';
7 10
import { RepositoryService } from "../../../services/repository.service";
8 11
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
9 12
import { Country, Repository } from '../../../domain/typeScriptClasses';
......
29 32
  journalTypeDesc,
30 33
  adminEmailDesc
31 34
} from '../../../domain/oa-description';
35
import { ValidatorService } from '../../../services/validator.service';
32 36

  
33 37
@Component ({
34 38
  selector: 'journal-info-form',
......
85 89

  
86 90
  constructor(
87 91
    private fb: FormBuilder,
88
    private repoService: RepositoryService
92
    private repoService: RepositoryService,
93
    private valService: ValidatorService
89 94
  ) {}
90 95

  
91 96
  ngOnInit() {
......
113 118

  
114 119
  registerDatasource(): boolean {
115 120
    if(this.group.valid){
116
      this.successMessage = formSuccessRegisteredDatasource;
117
      this.errorMessage = '';
118
      return true;
121
      let response: boolean;
122
      this.valService.identifyRepository(this.group.get('websiteUrl').value).subscribe(
123
        res => response = res,
124
        error => console.log(error)
125
      );
126
      if (response) {
127
        this.successMessage = formSuccessRegisteredDatasource;
128
        this.errorMessage = '';
129
        return true;
130
      } else {
131
        this.errorMessage = formErrorInvalidFields;
132
      }
119 133
    } else {
120 134
      this.errorMessage = formErrorRequiredFields;
121
      this.successMessage = '';
122 135
      return false;
123 136
    }
124 137
  }

Also available in: Unified diff