Add validation for library name

This commit is contained in:
aditya.chandel
2024-12-30 22:09:50 -07:00
parent 3035124020
commit 0fe9139ddd
2 changed files with 4 additions and 5 deletions
@@ -27,7 +27,7 @@
<app-icon-picker (iconSelected)="onIconSelected($event)"></app-icon-picker> <app-icon-picker (iconSelected)="onIconSelected($event)"></app-icon-picker>
</div> </div>
<div class="flex pt-6 justify-end"> <div class="flex pt-6 justify-end">
<p-button label="Next" icon="pi pi-arrow-right" iconPos="right" [disabled]="!isLibraryDetailsValid()" (onClick)="activateCallback(2)" /> <p-button label="Next" icon="pi pi-arrow-right" iconPos="right" [disabled]="!isLibraryDetailsValid()" (onClick)="validateLibraryNameAndProceed(activateCallback)" />
</div> </div>
</div> </div>
</ng-template> </ng-template>
@@ -10,8 +10,7 @@ import {IconPickerComponent} from '../icon-picker/icon-picker.component';
selector: 'app-library-creator', selector: 'app-library-creator',
standalone: false, standalone: false,
templateUrl: './library-creator.component.html', templateUrl: './library-creator.component.html',
styleUrl: './library-creator.component.scss', styleUrl: './library-creator.component.scss'
providers: [MessageService]
}) })
export class LibraryCreatorComponent { export class LibraryCreatorComponent {
@@ -96,7 +95,7 @@ export class LibraryCreatorComponent {
this.dynamicDialogRef.close(); this.dynamicDialogRef.close();
} }
validateLibraryNameAndProceed(nextCallback: any) { validateLibraryNameAndProceed(activateCallback: Function) {
if (this.libraryName.trim()) { if (this.libraryName.trim()) {
this.libraryService.libraryState$.subscribe( this.libraryService.libraryState$.subscribe(
libraryState => { libraryState => {
@@ -108,7 +107,7 @@ export class LibraryCreatorComponent {
detail: 'This library name is already taken.', detail: 'This library name is already taken.',
}); });
} else { } else {
nextCallback(); activateCallback(2);
} }
} }
) )