mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-9374] [ACS-9590] Fix search pop up and infinite loading animation (#4717)
* [ACS-9374] Prevent search popup flicker on Enter key press * feat: WIP - fixing search input errors for draft PR * Add test for mat-error on empty search term and handle loading state properly * Add test for mat-error on empty search term and handle loading state properly * Add whitespace error and fix unit test for checkbox * Fix sonarcloud issue for exception * [ACS-9374] Add validator to aca-shared * [ACS-9374] Simplify HTML by handling error state in TypeScript * [ACS-9374] Fix error validation process * [ACS-9374] Fix sonarcloud issue * [ACS-9374] Prevent library search with search term less than 2 characters * [ACS-9374] Show validation error on checking and unchecking checkbox * [ACS-9374] Provide default value to hasLibrariesConstraint * [ACS-9374] Close dropdown on search submission * [ACS-9374] Close menu on search trigger * [ACS-9374] Remove explicit 0 from setTimeout
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*!
|
||||
* Copyright © 2005-2025 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';
|
||||
import { noWhitespaceValidator } from './no-whitespace.validator';
|
||||
|
||||
describe('noWhitespaceValidator', () => {
|
||||
const validatorFn = noWhitespaceValidator();
|
||||
|
||||
it('should return null for valid non-whitespace input', () => {
|
||||
const control = new FormControl('valid input');
|
||||
expect(validatorFn(control)).toBeNull();
|
||||
});
|
||||
|
||||
it('should return error for input with only spaces', () => {
|
||||
const control = new FormControl(' ');
|
||||
expect(validatorFn(control)).toEqual({ whitespace: true });
|
||||
});
|
||||
|
||||
it('should return error for empty string', () => {
|
||||
const control = new FormControl('');
|
||||
expect(validatorFn(control)).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null for input with leading and trailing spaces but valid content inside', () => {
|
||||
const control = new FormControl(' valid ');
|
||||
expect(validatorFn(control)).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
/*!
|
||||
* Copyright © 2005-2025 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 { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
|
||||
|
||||
export const noWhitespaceValidator = (): ValidatorFn => {
|
||||
return (control: AbstractControl): ValidationErrors | null => {
|
||||
const rawValue = control.value;
|
||||
if (!rawValue) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const trimmedValue = rawValue.toString().trim();
|
||||
return trimmedValue.length === 0 ? { whitespace: true } : null;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user