From 082778d28f8187d0409108f2bd7bb15aa147217c Mon Sep 17 00:00:00 2001 From: Bogdan Cilibiu Date: Tue, 30 Oct 2018 10:39:19 +0200 Subject: [PATCH 1/2] clean form controls --- src/app/dialogs/library/library.dialog.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/dialogs/library/library.dialog.html b/src/app/dialogs/library/library.dialog.html index 580987b8cd..4ea7acffe9 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 }} From 28dd719ed7812e8d9c8f60089b8fbf0d1d27f957 Mon Sep 17 00:00:00 2001 From: Bogdan Cilibiu Date: Tue, 30 Oct 2018 10:40:14 +0200 Subject: [PATCH 2/2] check found site by title field --- src/app/dialogs/library/library.dialog.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/dialogs/library/library.dialog.ts b/src/app/dialogs/library/library.dialog.ts index 3918d2c980..0f10eaadba 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: [] } })); } }