mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
[ACA-1957] Create Library - check existent site title by field (#765)
* clean form controls * check found site by title field
This commit is contained in:
parent
0b65ff46a0
commit
fd692b6b8c
@ -9,7 +9,7 @@
|
||||
placeholder="{{ 'LIBRARY.DIALOG.FORM.NAME' | translate }}"
|
||||
required
|
||||
matInput
|
||||
[formControl]="form.controls['title']"
|
||||
formControlName="title"
|
||||
/>
|
||||
|
||||
<mat-hint *ngIf="libraryTitleExists">{{ 'LIBRARY.HINTS.SITE_TITLE_EXISTS' | translate }}</mat-hint>
|
||||
@ -23,7 +23,7 @@
|
||||
required
|
||||
placeholder="{{ 'LIBRARY.DIALOG.FORM.SITE_ID' | translate }}"
|
||||
matInput
|
||||
[formControl]="form.controls['id']"
|
||||
formControlName="id"
|
||||
/>
|
||||
|
||||
<mat-error *ngIf="form.controls['id'].errors?.message">
|
||||
@ -40,7 +40,7 @@
|
||||
matInput
|
||||
placeholder="{{ 'LIBRARY.DIALOG.FORM.DESCRIPTION' | translate }}"
|
||||
rows="3"
|
||||
[formControl]="form.controls['description']"></textarea>
|
||||
formControlName="description"></textarea>
|
||||
|
||||
<mat-error *ngIf="form.controls['description'].hasError('maxlength')">
|
||||
{{ 'LIBRARY.ERRORS.DESCRIPTION_TOO_LONG' | translate }}
|
||||
|
@ -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<SitePaging> {
|
||||
return this.alfrescoApiService
|
||||
.getInstance()
|
||||
.core.queriesApi.findSites(libraryTitle)
|
||||
.core.queriesApi.findSites(libraryTitle, {
|
||||
maxItems: 1,
|
||||
fields: ['title']
|
||||
})
|
||||
.catch(() => ({ list: { entries: [] } }));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user