diff --git a/src/app/api-connector/applications.service.ts b/src/app/api-connector/applications.service.ts index 876e3fed58..606a0e9da9 100644 --- a/src/app/api-connector/applications.service.ts +++ b/src/app/api-connector/applications.service.ts @@ -337,9 +337,14 @@ export class ApplicationsService { }) } - checkForTakenShortname(shortname: string): Observable { + checkForTakenShortname(shortname: string,exclude_project_id?:string|number): Observable { + + let params:any={ shortname: shortname } + if (exclude_project_id){ + params={ shortname: shortname ,exclude_project_id:exclude_project_id} + } return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/shortname/`, { - params: { shortname: shortname }, + params: params, withCredentials: true }); diff --git a/src/app/applications/application-formular/application-formular.component.html b/src/app/applications/application-formular/application-formular.component.html index 692b9fa040..d39356fbf6 100644 --- a/src/app/applications/application-formular/application-formular.component.html +++ b/src/app/applications/application-formular/application-formular.component.html @@ -147,7 +147,10 @@
General Information
- Please choose another shortname + Warning: This shortname is already in use. A unique suffix will be automatically appended upon + submission.
General Information #shortname (keyup)="checkShortname(shortname.value)" class="form-control" - maxlength="15" + min="5" + [maxlength]="shortNameMaxLength" + (ngModelChange)="setDefaulShortnameLength()" [(ngModel)]="application.project_application_shortname" minlength="5" placeholder="e.g. ThalianaBench" pattern="[a-zA-Z0-9]+" [ngClass]="{ 'is-invalid': - (form.controls.project_application_shortname?.invalid || shortNameTaken) && + form.controls.project_application_shortname?.invalid && (form.controls.project_application_shortname?.dirty || - form.controls.project_application_shortname?.touched) - , + form.controls.project_application_shortname?.touched), 'is-valid': - form.controls.project_application_shortname?.valid && !shortNameTaken && + form.controls.project_application_shortname?.valid && (form.controls.project_application_shortname?.dirty || form.controls.project_application_shortname?.touched), }" /> Enter a short name (between 5 and 15 characters). - @@ -1799,7 +1802,6 @@
Platforms
data-test-id="submit_application_btn" [disabled]=" submitting || - shortNameTaken || form.invalid || (!unknownPiAffiliationsConfirmation && !valid_pi_affiliations && diff --git a/src/app/applications/application-formular/application-formular.component.ts b/src/app/applications/application-formular/application-formular.component.ts index a1f2ae3525..2e4b25d457 100644 --- a/src/app/applications/application-formular/application-formular.component.ts +++ b/src/app/applications/application-formular/application-formular.component.ts @@ -54,6 +54,8 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent @Input() application: Application @Input() is_validation: boolean = false @Input() hash: string + DEFAULT_SHORTNAME_MAX_LENGTH:number=15 + shortNameMaxLength:number=15 userinfo: Userinfo valid_pi_affiliations @@ -145,14 +147,19 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent } } + setDefaulShortnameLength():void{ + this.shortNameMaxLength=this.DEFAULT_SHORTNAME_MAX_LENGTH + } + checkIfNameIsTaken(shortname: string): void { this.shortnameChecking = true; - this.applicationsService.checkForTakenShortname(shortname).subscribe((result: boolean): void => { + + this.applicationsService.checkForTakenShortname(shortname,this.application?.project_application_id).subscribe((result: boolean): void => { let nameExists: boolean = result['exists']; this.shortnameChecking = false; this.shortNameTaken = nameExists; }); - + } checkValidityComment(): boolean { @@ -190,6 +197,10 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent if (this.application && !this.initiated_validation && this.is_validation) { this.openstack_project = this.application.project_application_openstack_project + if(this.application.project_application_shortname.length > 15){ + this.shortNameMaxLength=this.application.project_application_shortname.length + } + this.simple_vm_project = !this.openstack_project this.application.project_application_pi = new User() @@ -259,7 +270,7 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent this.shortnameChecking = true; this.nameCheckPipe.next(shortname); } - + } public checkLongname(longname: string): void { diff --git a/src/app/shared/shared_modules/public-key/public-key.component.html b/src/app/shared/shared_modules/public-key/public-key.component.html index 26783b83b5..a2ca53fbbf 100644 --- a/src/app/shared/shared_modules/public-key/public-key.component.html +++ b/src/app/shared/shared_modules/public-key/public-key.component.html @@ -293,7 +293,7 @@ - L +