mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-4473] TaskCloud - add priority numeric validation (#4684)
* [ADF-4473] TaskCloud - add priority numeric validation * [ADF-4473] - change validation conditiion * [ADF-4473] - add return type * [ADF-4473] - fix unit test
This commit is contained in:
parent
028e2eb981
commit
ead22d9e3c
@ -507,7 +507,7 @@ describe('EditProcessFilterCloudComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const lastModifiedToControl: AbstractControl = component.editProcessFilterForm.get('lastModifiedTo');
|
const lastModifiedToControl: AbstractControl = component.editProcessFilterForm.get('lastModifiedTo');
|
||||||
lastModifiedToControl.setValue('Tue Apr 09 2019 00:00:00 GMT+0300 (Eastern European Summer Time)');
|
lastModifiedToControl.setValue(new Date().toISOString());
|
||||||
const lastModifiedToFilter = moment(lastModifiedToControl.value);
|
const lastModifiedToFilter = moment(lastModifiedToControl.value);
|
||||||
lastModifiedToFilter.set({
|
lastModifiedToFilter.set({
|
||||||
hour: 23,
|
hour: 23,
|
||||||
|
@ -76,11 +76,6 @@ describe('PeopleCloudComponent', () => {
|
|||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
TestBed.resetTestingModule();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should list the users if the typed result match', async(() => {
|
it('should list the users if the typed result match', async(() => {
|
||||||
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||||
inputHTMLElement.focus();
|
inputHTMLElement.focus();
|
||||||
@ -173,11 +168,6 @@ describe('PeopleCloudComponent', () => {
|
|||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
TestBed.resetTestingModule();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should list users who have access to the app when appName is specified', async(() => {
|
it('should list users who have access to the app when appName is specified', async(() => {
|
||||||
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||||
inputHTMLElement.focus();
|
inputHTMLElement.focus();
|
||||||
@ -314,11 +304,6 @@ describe('PeopleCloudComponent', () => {
|
|||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
TestBed.resetTestingModule();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should filter users if users has any specified role', async(() => {
|
it('should filter users if users has any specified role', async(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||||
@ -378,11 +363,6 @@ describe('PeopleCloudComponent', () => {
|
|||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
TestBed.resetTestingModule();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show chip list when mode=single', async(() => {
|
it('should not show chip list when mode=single', async(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
@ -413,11 +393,6 @@ describe('PeopleCloudComponent', () => {
|
|||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
TestBed.resetTestingModule();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show chip list when mode=single', async(() => {
|
it('should not show chip list when mode=single', async(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
@ -450,11 +425,6 @@ describe('PeopleCloudComponent', () => {
|
|||||||
alfrescoApiService = TestBed.get(AlfrescoApiService);
|
alfrescoApiService = TestBed.get(AlfrescoApiService);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
TestBed.resetTestingModule();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show chip list when mode=multiple', async(() => {
|
it('should show chip list when mode=multiple', async(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
|
@ -403,7 +403,7 @@ describe('EditTaskFilterCloudComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const lastModifiedToControl: AbstractControl = component.editTaskFilterForm.get('lastModifiedTo');
|
const lastModifiedToControl: AbstractControl = component.editTaskFilterForm.get('lastModifiedTo');
|
||||||
lastModifiedToControl.setValue('Tue Apr 09 2019 00:00:00 GMT+0300 (Eastern European Summer Time)');
|
lastModifiedToControl.setValue(new Date().toISOString());
|
||||||
const lastModifiedToFilter = moment(lastModifiedToControl.value);
|
const lastModifiedToFilter = moment(lastModifiedToControl.value);
|
||||||
lastModifiedToFilter.set({
|
lastModifiedToFilter.set({
|
||||||
hour: 23,
|
hour: 23,
|
||||||
|
@ -89,6 +89,29 @@ describe('TaskHeaderCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should display error if priority is not a number', async(() => {
|
||||||
|
component.ngOnInit();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
const edit = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-edit-icon-priority"]'));
|
||||||
|
edit.nativeElement.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const formPriorityEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-editinput-priority"]'));
|
||||||
|
formPriorityEl.nativeElement.value = 'stringValue';
|
||||||
|
formPriorityEl.nativeElement.dispatchEvent(new Event('input'));
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const submitEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-update-priority"]'));
|
||||||
|
submitEl.nativeElement.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const errorMessageEl = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-error-priority"]'));
|
||||||
|
expect(errorMessageEl).not.toBeNull();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should display due date', async(() => {
|
it('should display due date', async(() => {
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@ -30,6 +30,7 @@ import { TaskDetailsCloudModel, TaskStatusEnum } from '../../start-task/models/t
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { TaskCloudService } from '../../services/task-cloud.service';
|
import { TaskCloudService } from '../../services/task-cloud.service';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
import { NumericFieldValidator } from '../../../validators/numeric-field.validator';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-cloud-task-header',
|
selector: 'adf-cloud-task-header',
|
||||||
@ -112,7 +113,8 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy {
|
|||||||
label: 'ADF_CLOUD_TASK_HEADER.PROPERTIES.PRIORITY',
|
label: 'ADF_CLOUD_TASK_HEADER.PROPERTIES.PRIORITY',
|
||||||
value: this.taskDetails.priority,
|
value: this.taskDetails.priority,
|
||||||
key: 'priority',
|
key: 'priority',
|
||||||
editable: true
|
editable: true,
|
||||||
|
validators: [new NumericFieldValidator()]
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
new CardViewDateItemModel(
|
new CardViewDateItemModel(
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { CardViewItemValidator } from '@alfresco/adf-core';
|
||||||
|
|
||||||
|
export class NumericFieldValidator implements CardViewItemValidator {
|
||||||
|
|
||||||
|
message: string = 'ADF_CLOUD_TASK_HEADER.FORM_VALIDATION.INVALID_FIELD';
|
||||||
|
|
||||||
|
isValid(value: any): boolean {
|
||||||
|
if (!value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !isNaN(+value) && !this.whitespaces(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
whitespaces(value: any): boolean {
|
||||||
|
const isWhitespace = (value || '').trim().length === 0;
|
||||||
|
return !(value.length === 0 || !isWhitespace);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user