diff --git a/src/app/dialogs/library/library.dialog.html b/src/app/dialogs/library/library.dialog.html index 580987b8c..4ea7acffe 100644 --- a/src/app/dialogs/library/library.dialog.html +++ b/src/app/dialogs/library/library.dialog.html @@ -9,7 +9,7 @@ placeholder="{{ 'LIBRARY.DIALOG.FORM.NAME' | translate }}" required matInput - [formControl]="form.controls['title']" + formControlName="title" /> {{ 'LIBRARY.HINTS.SITE_TITLE_EXISTS' | translate }} @@ -23,7 +23,7 @@ required placeholder="{{ 'LIBRARY.DIALOG.FORM.SITE_ID' | translate }}" matInput - [formControl]="form.controls['id']" + formControlName="id" /> @@ -40,7 +40,7 @@ matInput placeholder="{{ 'LIBRARY.DIALOG.FORM.DESCRIPTION' | translate }}" rows="3" - [formControl]="form.controls['description']"> + formControlName="description"> {{ 'LIBRARY.ERRORS.DESCRIPTION_TOO_LONG' | translate }} diff --git a/src/app/dialogs/library/library.dialog.ts b/src/app/dialogs/library/library.dialog.ts index 3918d2c98..0f10eaadb 100644 --- a/src/app/dialogs/library/library.dialog.ts +++ b/src/app/dialogs/library/library.dialog.ts @@ -182,13 +182,21 @@ export class LibraryDialogComponent implements OnInit, OnDestroy { private async checkLibraryNameExists(libraryTitle: string) { const { entries } = (await this.findLibraryByTitle(libraryTitle)).list; - this.libraryTitleExists = !!entries.length; + + if (entries.length) { + this.libraryTitleExists = entries[0].entry.title === libraryTitle; + } else { + this.libraryTitleExists = false; + } } private findLibraryByTitle(libraryTitle: string): Promise { return this.alfrescoApiService .getInstance() - .core.queriesApi.findSites(libraryTitle) + .core.queriesApi.findSites(libraryTitle, { + maxItems: 1, + fields: ['title'] + }) .catch(() => ({ list: { entries: [] } })); } }