Revision 62388
Added by Andreas Mantas over 1 year ago
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: '', |
... | ... | |
137 | 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 |
websiteUrl: this.selectedRepo.websiteurl,
|
|
141 | 142 |
institutionName: this.selectedRepo.organizations[0].legalname, |
142 |
englishName: this.selectedRepo.englishName,
|
|
143 |
logoUrl: this.selectedRepo.logoUrl,
|
|
143 |
englishName: this.selectedRepo.englishname,
|
|
144 |
logoUrl: this.selectedRepo.logourl,
|
|
144 | 145 |
timezone: this.selectedRepo.timezone, |
145 |
datasourceType: this.selectedRepo.eoscDatasourceType, |
|
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 |
} |
... | ... | |
228 | 231 |
|
229 | 232 |
createNewRepository(): Repository { |
230 | 233 |
const newRepo = 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;
|
|
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;
|
|
236 | 239 |
newRepo.organizations.push({ |
237 | 240 |
legalshortname: null, |
238 | 241 |
legalname: this.group.get('institutionName').value.toString(), |
... | ... | |
243 | 246 |
newRepo.latitude = this.group.get('latitude').value; |
244 | 247 |
newRepo.longitude = this.group.get('longtitude').value; |
245 | 248 |
newRepo.timezone = this.group.get('timezone').value; |
246 |
newRepo.eoscDatasourceType = this.group.get('datasourceType').value;
|
|
247 |
if (this.group.get('softwarePlatform').value ) {
|
|
248 |
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;
|
|
249 | 252 |
} else if (this.group.get('platformName').value) { |
250 |
newRepo.typology = this.group.get('platformName').value; |
|
253 |
newRepo.platform = this.group.get('platformName').value; |
|
254 |
console.log('2//', this.group.get('platformName').value); |
|
251 | 255 |
} |
252 |
// 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); |
|
253 | 259 |
newRepo.description = this.group.get('repoDescription').value.toString(); |
254 | 260 |
newRepo.issn = ''; |
255 | 261 |
newRepo.eissn = ''; |
... | ... | |
271 | 277 |
} |
272 | 278 |
} |
273 | 279 |
|
274 |
newRepo.registeredBy = this.authService.getUserEmail();
|
|
280 |
newRepo.registeredby = this.authService.getUserEmail();
|
|
275 | 281 |
|
276 | 282 |
/* THE BELOW FIELDS ARE NOT SET IN GWT CODE*/ |
277 |
newRepo.datasourceType = this.mode; |
|
283 |
newRepo.eoscDatasourceType = this.mode; // TODO: delete this? |
|
284 |
console.warn(newRepo.eoscDatasourceType); |
|
278 | 285 |
newRepo.managed = true; |
279 | 286 |
|
280 | 287 |
const now = new Date(Date.now()); |
Also available in: Unified diff
refactor. fix getDatasourceClasses and corresponding dropdown. fix issn fields