mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
[ACS-9008] Proper form initialization for Saved Searches (#4243)
* [ACS-9008] Proper form initialization * [ACS-9008] Add saved search form interface, fix other dialog
This commit is contained in:
parent
baaa8ca37b
commit
90cb0d4db0
@ -31,6 +31,7 @@ import { Store } from '@ngrx/store';
|
|||||||
import { CoreModule } from '@alfresco/adf-core';
|
import { CoreModule } from '@alfresco/adf-core';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { UniqueSearchNameValidator } from '../unique-search-name-validator';
|
import { UniqueSearchNameValidator } from '../unique-search-name-validator';
|
||||||
|
import { SavedSearchForm } from '../saved-search-form.interface';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@ -42,15 +43,7 @@ import { UniqueSearchNameValidator } from '../unique-search-name-validator';
|
|||||||
host: { class: 'aca-saved-search-edit-dialog' }
|
host: { class: 'aca-saved-search-edit-dialog' }
|
||||||
})
|
})
|
||||||
export class SavedSearchEditDialogComponent {
|
export class SavedSearchEditDialogComponent {
|
||||||
form = new FormGroup({
|
form: FormGroup<SavedSearchForm>;
|
||||||
name: new FormControl('', {
|
|
||||||
validators: [Validators.required, forbidOnlySpaces],
|
|
||||||
asyncValidators: [this.uniqueSearchNameValidator.validate.bind(this.uniqueSearchNameValidator)],
|
|
||||||
updateOn: 'blur'
|
|
||||||
}),
|
|
||||||
description: new FormControl('')
|
|
||||||
});
|
|
||||||
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -60,6 +53,15 @@ export class SavedSearchEditDialogComponent {
|
|||||||
private readonly uniqueSearchNameValidator: UniqueSearchNameValidator,
|
private readonly uniqueSearchNameValidator: UniqueSearchNameValidator,
|
||||||
@Inject(MAT_DIALOG_DATA) private readonly data: SavedSearch
|
@Inject(MAT_DIALOG_DATA) private readonly data: SavedSearch
|
||||||
) {
|
) {
|
||||||
|
this.form = new FormGroup({
|
||||||
|
name: new FormControl('', {
|
||||||
|
validators: [Validators.required, forbidOnlySpaces],
|
||||||
|
asyncValidators: [this.uniqueSearchNameValidator.validate.bind(this.uniqueSearchNameValidator)],
|
||||||
|
updateOn: 'change'
|
||||||
|
}),
|
||||||
|
description: new FormControl('')
|
||||||
|
});
|
||||||
|
|
||||||
this.form.patchValue({
|
this.form.patchValue({
|
||||||
name: this.data.name,
|
name: this.data.name,
|
||||||
description: this.data.description
|
description: this.data.description
|
||||||
|
@ -41,6 +41,7 @@ import { take } from 'rxjs/operators';
|
|||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppStore, SnackbarErrorAction, SnackbarInfoAction } from '@alfresco/aca-shared/store';
|
import { AppStore, SnackbarErrorAction, SnackbarInfoAction } from '@alfresco/aca-shared/store';
|
||||||
import { UniqueSearchNameValidator } from './unique-search-name-validator';
|
import { UniqueSearchNameValidator } from './unique-search-name-validator';
|
||||||
|
import { SavedSearchForm } from './saved-search-form.interface';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@ -66,15 +67,7 @@ import { UniqueSearchNameValidator } from './unique-search-name-validator';
|
|||||||
host: { class: 'aca-save-search-dialog' }
|
host: { class: 'aca-save-search-dialog' }
|
||||||
})
|
})
|
||||||
export class SaveSearchDialogComponent {
|
export class SaveSearchDialogComponent {
|
||||||
form = new FormGroup({
|
form: FormGroup<SavedSearchForm>;
|
||||||
name: new FormControl('', {
|
|
||||||
validators: [Validators.required, forbidOnlySpaces],
|
|
||||||
asyncValidators: [this.uniqueSearchNameValidator.validate.bind(this.uniqueSearchNameValidator)],
|
|
||||||
updateOn: 'blur'
|
|
||||||
}),
|
|
||||||
description: new FormControl('')
|
|
||||||
});
|
|
||||||
|
|
||||||
disableSubmitButton = false;
|
disableSubmitButton = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -83,7 +76,16 @@ export class SaveSearchDialogComponent {
|
|||||||
private readonly savedSearchesService: SavedSearchesService,
|
private readonly savedSearchesService: SavedSearchesService,
|
||||||
private readonly uniqueSearchNameValidator: UniqueSearchNameValidator,
|
private readonly uniqueSearchNameValidator: UniqueSearchNameValidator,
|
||||||
@Inject(MAT_DIALOG_DATA) private readonly data: { searchUrl: string }
|
@Inject(MAT_DIALOG_DATA) private readonly data: { searchUrl: string }
|
||||||
) {}
|
) {
|
||||||
|
this.form = new FormGroup({
|
||||||
|
name: new FormControl('', {
|
||||||
|
validators: [Validators.required, forbidOnlySpaces],
|
||||||
|
asyncValidators: [this.uniqueSearchNameValidator.validate.bind(this.uniqueSearchNameValidator)],
|
||||||
|
updateOn: 'change'
|
||||||
|
}),
|
||||||
|
description: new FormControl('')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
if (this.form.invalid || this.disableSubmitButton) {
|
if (this.form.invalid || this.disableSubmitButton) {
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*!
|
||||||
|
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
|
* Alfresco Example Content Application
|
||||||
|
*
|
||||||
|
* This file is part of the Alfresco Example Content Application.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { FormControl } from '@angular/forms';
|
||||||
|
|
||||||
|
export interface SavedSearchForm {
|
||||||
|
name: FormControl<string>;
|
||||||
|
description: FormControl<string>;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user