mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ACS-9252] Create Button Not Enabled After Resolving Duplicate Folder Name Warning (#10635)
This commit is contained in:
parent
ddd81d8806
commit
287519ee24
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||
|
||||
@ -316,6 +316,17 @@ describe('FolderDialogComponent', () => {
|
||||
|
||||
component.submit();
|
||||
});
|
||||
|
||||
it('should enable submit button after changing name field when previous value caused error', () => {
|
||||
createFolderNode$.error(throwError('error'));
|
||||
spyOn(component, 'handleError').and.callFake((val) => val);
|
||||
component.form.controls['name'].setValue('');
|
||||
component.submit();
|
||||
expect(component.disableSubmitButton).toBeTrue();
|
||||
|
||||
component.form.controls['name'].setValue('testName');
|
||||
expect(component.disableSubmitButton).toBeFalse();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Component, Inject, OnInit, Optional, EventEmitter, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, EventEmitter, inject, Inject, OnInit, Optional, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { ReactiveFormsModule, UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
@ -29,6 +29,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { AutoFocusDirective } from '../../directives';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-folder-dialog',
|
||||
@ -93,6 +94,8 @@ export class FolderDialogComponent implements OnInit {
|
||||
};
|
||||
}
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private dialog: MatDialogRef<FolderDialogComponent>,
|
||||
@ -132,6 +135,8 @@ export class FolderDialogComponent implements OnInit {
|
||||
title: [title],
|
||||
description: [description]
|
||||
});
|
||||
|
||||
this.form.controls['name'].valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => (this.disableSubmitButton = false));
|
||||
}
|
||||
|
||||
submit() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user