-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ethical: Add new ethical report uri field to frontend (disableable fr…
…om the backend)
- Loading branch information
1 parent
51a7cc9
commit e8cd598
Showing
19 changed files
with
107 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 17 additions & 3 deletions
20
...src/lib/components/dmp/legal-ethical-aspects/ethical-aspects/ethical-aspects.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { UntypedFormGroup } from '@angular/forms'; | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-ethical-aspects', | ||
templateUrl: './ethical-aspects.component.html', | ||
styleUrls: ['./ethical-aspects.component.css'], | ||
}) | ||
export class EthicalAspectsComponent { | ||
export class EthicalAspectsComponent implements OnInit { | ||
@Input() legalEthicalStep: UntypedFormGroup; | ||
@Input() ethicalReportUriEnabled: boolean; | ||
|
||
get ethicalReportUrl(): UntypedFormControl { | ||
return this.legalEthicalStep.get('ethicalReportUrl') as UntypedFormControl; | ||
} | ||
|
||
ngOnInit(): void { | ||
this.legalEthicalStep | ||
.get('committeeReviewed') | ||
.valueChanges.subscribe(value => { | ||
// Set ethical Report URL to "" | ||
this.ethicalReportUrl.setValue(null); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,5 +403,6 @@ describe('SummaryService', () => { | |
structure: '', | ||
targetAudience: '', | ||
tools: '', | ||
ethicalReportUrl: '', | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms'; | ||
import { Observable, of } from 'rxjs'; | ||
|
||
/** | ||
* Validates whether a given string is a valid URI based on RFC 3986. | ||
* @param uri The string to validate. | ||
* @returns True if the string is a valid URI, false otherwise. | ||
*/ | ||
function isValidURI(uri: string): boolean { | ||
// Regular expression to match a general URI pattern based on RFC 3986. | ||
const uriRegex = /^[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]*$/; | ||
return uriRegex.test(uri); | ||
} | ||
|
||
/** | ||
* A custom validator for validating URIs. | ||
* @returns Validator function for Angular forms. | ||
*/ | ||
export function uriValidator(): ValidatorFn { | ||
return (control: AbstractControl): Observable<ValidationErrors | null> => { | ||
const uri = control.value; | ||
const isValid = !uri || isValidURI(uri); | ||
return of(isValid ? null : { uri: true }); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms'; | ||
import validator from 'validator'; | ||
import { Observable, of } from 'rxjs'; | ||
|
||
export function urlValidator(): ValidatorFn { | ||
return (control: AbstractControl): Observable<ValidationErrors | null> => { | ||
const url = control.value; | ||
const isValid = | ||
!url || | ||
validator.isURL(url, { | ||
protocols: ['http', 'https'], | ||
require_protocol: false, | ||
require_valid_protocol: true, | ||
allow_underscores: false, | ||
allow_trailing_dot: false, | ||
allow_protocol_relative_urls: false, | ||
}); | ||
return of(isValid ? null : { url: true }); | ||
}; | ||
} |