Project

General

Profile

« Previous | Next » 

Revision 62389

View differences:

datasource-create-form.component.ts
41 41
  countries: Country[] = [];
42 42
  datasourceClasses: Map<string, string> = new Map<string, string>();
43 43
  classCodes: string[] = [];
44
  // classCodes: string[] = [];
44 45

  
45 46
  @Input() mode: string;
46 47

  
......
57 58
    softwarePlatform : ['', Validators.required],
58 59
    platformName : '',
59 60
    officialName : ['', Validators.required],
60
    issn : ['', [Validators.pattern('^\\d{4}-\\d{3}[\\dxX]$')] ],
61
    eissn : ['', Validators.pattern('^\\d{4}-\\d{3}[\\dxX]$') ],
62
    lissn : ['', Validators.pattern('^\\d{4}-\\d{3}[\\dxX]$') ],
61
    issn : ['', [Validators.pattern('^(\\d{4}-\\d{3}[\\dxX])|([0-9]{7}[\\dxX]$)')] ],
62
    eissn : ['', Validators.pattern('^(\\d{4}-\\d{3}[\\dxX])|([0-9]{7}[\\dxX]$)') ],
63
    lissn : ['', Validators.pattern('^(\\d{4}-\\d{3}[\\dxX])|([0-9]{7}[\\dxX]$)') ],
63 64
    repoDescription : ['', Validators.required],
64 65
    country : ['', Validators.required],
65 66
    longtitude : ['', [Validators.required, Validators.min(-180), Validators.max(180)] ],
......
110 111
    this.group = this.fb.group(this.groupDefinition);
111 112
    if (this.mode === 'journal') {
112 113
      this.group.get('issn').clearValidators();
113
      this.group.get('issn').setValidators([Validators.required, Validators.pattern('^\\d{4}-\\d{3}[\\dxX]$')]);
114
      this.group.get('issn').setValidators([Validators.required, Validators.pattern('^(\\d{4}-\\d{3}[\\dxX])|([0-9]{7}[\\dxX]$)')]);
114 115
    }
115 116
    this.getTypologies();
116 117
    this.getTimezones();
......
124 125

  
125 126
  setupForm() {
126 127
    if (this.selectedRepo) {
127
      console.log(`my datasource type is: ${this.selectedRepo.datasourceType}`);
128
      console.log(`my datasource type is: ${this?.selectedRepo?.eoscDatasourceType}`);
128 129

  
129 130
      this.group.setValue({
130
        softwarePlatform: this.selectedRepo.typology,
131
        softwarePlatform: this.selectedRepo.platform,
131 132
        platformName: '',
132
        officialName: this.selectedRepo.officialName,
133
        officialName: this.selectedRepo.officialname,
133 134
        issn: '',
134 135
        eissn: '',
135 136
        lissn: '',
136 137
        repoDescription: this.selectedRepo.description,
137
        country: this.selectedRepo.countryCode,
138
        country: this.selectedRepo.organizations[0].country, // countryCode
138 139
        longtitude: this.selectedRepo.longitude,
139 140
        latitude: this.selectedRepo.latitude,
140
        websiteUrl: this.selectedRepo.websiteUrl,
141
        institutionName: this.selectedRepo.organization,
142
        englishName: this.selectedRepo.englishName,
143
        logoUrl: this.selectedRepo.logoUrl,
141
        websiteUrl: this.selectedRepo.websiteurl,
142
        institutionName: this.selectedRepo.organizations[0].legalname,
143
        englishName: this.selectedRepo.englishname,
144
        logoUrl: this.selectedRepo.logourl,
144 145
        timezone: this.selectedRepo.timezone,
145
        datasourceType: this.selectedRepo.datasourceClass,
146
        adminEmail: this.selectedRepo.contactEmail
146
        datasourceType: this.selectedRepo.eoscDatasourceType, // TODO: still needed?
147
        adminEmail: this.selectedRepo.contactemail
147 148
      });
148 149

  
149
      if (this.selectedRepo.datasourceType === 'journal') {
150
      if (this.selectedRepo.eoscDatasourceType === 'Journal archive') {
150 151

  
151 152
        let ssnToShow = this.selectedRepo.issn.slice(0, 4) + '-' + this.selectedRepo.issn.toString().slice(4);
152 153
        this.group.get('issn').setValue(ssnToShow);
......
185 186

  
186 187
  getDatasourceClasses() {
187 188
    this.repoService.getDatasourceClasses(this.mode).subscribe(
188
      classes => this.datasourceClasses = classes,
189
      classes => {
190
        for (const [key, value] of Object.entries(classes)) {
191
          this.datasourceClasses.set(key, value);
192
        }
193
      },
189 194
      error => {
190 195
        this.errorMessage = noServiceMessage;
191 196
        console.log(error);
192 197
      },
193 198
      () => {
194
        for (const key of Object.keys(this.datasourceClasses)) {
195
          this.classCodes.push(key);
196
        }
199
        this.classCodes = Array.from(this.datasourceClasses.keys());
197 200
      }
198 201
    );
199 202
  }
......
227 230
  }
228 231

  
229 232
  createNewRepository(): Repository {
230
    const newRepo: Repository = new Repository();
231
    newRepo.officialName = this.group.get('officialName').value.toString();
232
    newRepo.englishName = this.group.get('englishName').value.toString();
233
    newRepo.websiteUrl = this.group.get('websiteUrl').value;
234
    newRepo.logoUrl = this.group.get('logoUrl').value;
235
    newRepo.contactEmail = this.group.get('adminEmail').value;
236
    newRepo.countryName = this.countries.filter(x => x.code === this.group.get('country').value)[0].name;
237
    newRepo.countryCode = this.group.get('country').value;
238
    newRepo.organization = this.group.get('institutionName').value.toString();
233
    const newRepo = new Repository();
234
    newRepo.officialname = this.group.get('officialName').value.toString();
235
    newRepo.englishname = this.group.get('englishName').value.toString();
236
    newRepo.websiteurl = this.group.get('websiteUrl').value;
237
    newRepo.logourl = this.group.get('logoUrl').value;
238
    newRepo.contactemail = this.group.get('adminEmail').value;
239
    newRepo.organizations.push({
240
      legalshortname: null,
241
      legalname: this.group.get('institutionName').value.toString(),
242
      websiteurl: null,
243
      logourl: null,
244
      country: this.group.get('country').value
245
    });
239 246
    newRepo.latitude = this.group.get('latitude').value;
240 247
    newRepo.longitude = this.group.get('longtitude').value;
241 248
    newRepo.timezone = this.group.get('timezone').value;
242
    newRepo.datasourceClass = this.group.get('datasourceType').value;
243
    if (this.group.get('softwarePlatform').value ) {
244
      newRepo.typology = this.group.get('softwarePlatform').value;
249
    if (this.group.get('softwarePlatform').value !== '') {
250
      console.log('1//', this.group.get('softwarePlatform').value);
251
      newRepo.platform = this.group.get('softwarePlatform').value;
245 252
    } else if (this.group.get('platformName').value) {
246
      newRepo.typology = this.group.get('platformName').value;
253
      newRepo.platform = this.group.get('platformName').value;
254
      console.log('2//', this.group.get('platformName').value);
247 255
    }
248
    // newRepo.typology = this.group.get('softwarePlatform').value;
256
    newRepo.typology = this.group.get('datasourceType').value;
257
    // newRepo.eoscDatasourceType = this.datasourceClasses.get(this.group.get('datasourceType').value);
258
    // console.warn(newRepo.eoscDatasourceType);
249 259
    newRepo.description = this.group.get('repoDescription').value.toString();
250 260
    newRepo.issn = '';
251 261
    newRepo.eissn = '';
......
267 277
      }
268 278
    }
269 279

  
270
    newRepo.registeredBy = this.authService.getUserEmail();
280
    newRepo.registeredby = this.authService.getUserEmail();
271 281

  
272 282
    /* THE BELOW FIELDS ARE NOT SET IN GWT CODE*/
273
    newRepo.datasourceType = this.mode;
274
    newRepo.dateOfCreation = new Date(Date.now()); // NOT NEEDED ??
275
    newRepo.registered = true;
276
    newRepo.registrationDate = new Date(Date.now()); // NOT NEEDED ??
283
    newRepo.eoscDatasourceType = this.mode; // TODO: delete this?
284
    console.warn(newRepo.eoscDatasourceType);
285
    newRepo.managed = true;
277 286

  
287
    const now = new Date(Date.now());
288
    newRepo.consentTermsOfUseDate = now;
289
    newRepo.lastConsentTermsOfUseDate = now;
290
    newRepo.registrationdate = now;
278 291
    return newRepo;
279 292
  }
280 293

  

Also available in: Unified diff