Revision 51561
Added by Myrto Koukouli about 6 years ago
datasource-update-form.component.ts | ||
---|---|---|
62 | 62 |
|
63 | 63 |
@Input() showButton: boolean; |
64 | 64 |
|
65 |
formSubmitted:boolean = false; |
|
65 | 66 |
updateGroup: FormGroup; |
66 | 67 |
readonly updateGroupDefinition = { |
67 | 68 |
softwarePlatform : '', |
... | ... | |
74 | 75 |
country : ['', Validators.required], |
75 | 76 |
longtitude : ['', [Validators.required, Validators.min(-180), Validators.max(180)] ], |
76 | 77 |
latitude : ['', [Validators.required, Validators.min(-90), Validators.max(90)] ], |
77 |
websiteUrl : ['', [Validators.required] ], |
|
78 |
websiteUrl : ['', [Validators.required, Validators.pattern('^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$')] ],
|
|
78 | 79 |
institutionName : ['', Validators.required], |
79 | 80 |
englishName: ['', Validators.required], |
80 |
logoUrl: [''], |
|
81 |
logoUrl: ['', Validators.pattern('^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$') ],
|
|
81 | 82 |
timezone: ['', Validators.required], |
82 | 83 |
datasourceType: ['', Validators.required], |
83 | 84 |
adminEmail: ['', [Validators.required, Validators.email]] |
... | ... | |
165 | 166 |
this.updateGroup.get('websiteUrl').disable(); |
166 | 167 |
this.updateGroup.get('institutionName').disable(); |
167 | 168 |
if (this.selectedRepo.datasourceType == 'journal') { |
169 |
|
|
170 |
this.updateGroup.get('issn').setValidators([Validators.required, Validators.pattern('^\\d\\d\\d\\d[-]\\d\\d\\d\\d$')]); |
|
171 |
|
|
168 | 172 |
let ssnToShow = this.selectedRepo.issn.slice(0, 4)+ '-' + this.selectedRepo.issn.toString().slice(4); |
169 | 173 |
this.updateGroup.get('issn').setValue(ssnToShow); |
170 |
if (this.selectedRepo.eissn) { |
|
174 |
|
|
175 |
if (this.selectedRepo.eissn.trim().length) { |
|
171 | 176 |
ssnToShow = this.selectedRepo.eissn.slice(0, 4)+ '-' + this.selectedRepo.eissn.toString().slice(4); |
172 | 177 |
this.updateGroup.get('eissn').setValue(ssnToShow); |
173 | 178 |
} |
174 |
if (this.selectedRepo.eissn) { |
|
179 |
|
|
180 |
if (this.selectedRepo.lissn.trim().length) { |
|
175 | 181 |
ssnToShow = this.selectedRepo.lissn.slice(0, 4)+ '-' + this.selectedRepo.lissn.toString().slice(4); |
176 | 182 |
this.updateGroup.get('lissn').setValue(ssnToShow); |
177 | 183 |
} |
184 |
|
|
178 | 185 |
this.updateGroup.get('issn').disable(); |
179 | 186 |
this.updateGroup.get('eissn').disable(); |
180 | 187 |
this.updateGroup.get('lissn').disable(); |
... | ... | |
246 | 253 |
} |
247 | 254 |
|
248 | 255 |
updateRepo() { |
256 |
this.formSubmitted = true; |
|
249 | 257 |
this.errorMessage = ''; |
250 | 258 |
this.successMessage = ''; |
251 | 259 |
|
... | ... | |
343 | 351 |
export function checkPlatform(c: AbstractControl) { |
344 | 352 |
if ( c.get('softwarePlatform').value || c.get('platformName').value ) |
345 | 353 |
return null; |
354 |
markPlatformAsRequired(c); |
|
346 | 355 |
return 'invalid'; |
347 | 356 |
} |
357 |
|
|
358 |
export function markPlatformAsRequired(c: AbstractControl) { |
|
359 |
c.get('platformName').setValidators([Validators.required]); |
|
360 |
} |
Also available in: Unified diff
added inline validation messages to create-update repository forms