Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAE-4379] i18n fixes #6515

Merged
merged 18 commits into from
Jan 11, 2021
36 changes: 33 additions & 3 deletions lib/process-services-cloud/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,47 @@
"ADF_CLOUD_TASK_FILTERS": {
"MY_TASKS": "My Tasks",
"QUEUED_TASKS": "Queued Tasks",
"COMPLETED_TASKS": "Completed Tasks"
"COMPLETED_TASKS": "Completed Tasks",
"STATUS": {
"ALL": "All",
"CREATED": "Created",
"ASSIGNED": "Assigned",
"SUSPENDED": "Suspended",
"CANCELLED": "Cancelled",
"COMPLETED": "Completed"
},
"DIRECTION": {
"ASCENDING": "Ascending",
"DESCENDING": "Descending"
}
},
"ADF_CLOUD_SERVICE_TASK_FILTERS": {
"ALL_SERVICE_TASKS": "All Service Tasks",
"ERRORED_TASKS": "Errored Tasks",
"COMPLETED_TASKS": "Completed Tasks"
"COMPLETED_TASKS": "Completed Tasks",
"STATUS": {
"ALL": "All",
"STARTED": "Started",
"COMPLETED": "Completed",
"CANCELLED": "Cancelled",
"ERROR": "Error"
}
},
"ADF_CLOUD_PROCESS_FILTERS": {
"ALL_PROCESSES": "All",
"RUNNING_PROCESSES": "Running",
"COMPLETED_PROCESSES": "Completed"
"COMPLETED_PROCESSES": "Completed",
"STATUS": {
"ALL": "All",
"RUNNING": "Running",
"SUSPENDED": "Suspended",
"CANCELLED": "Cancelled",
"COMPLETED": "Completed"
},
"DIRECTION": {
"ASCENDING": "Ascending",
"DESCENDING": "Descending"
}
},
"ADF_CLOUD_START_TASK": {
"ERROR": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ describe('EditProcessFilterCloudComponent', () => {
expect(stateElement).toBeDefined();
expect(sortElement).toBeDefined();
expect(orderElement).toBeDefined();
expect(stateElement.innerText.trim()).toEqual('RUNNING');
expect(stateElement.innerText.trim()).toEqual('ADF_CLOUD_PROCESS_FILTERS.STATUS.RUNNING');
expect(sortElement.innerText.trim()).toEqual('ADF_CLOUD_EDIT_PROCESS_FILTER.LABEL.ID');
expect(orderElement.innerText.trim()).toEqual('ASC');
expect(orderElement.innerText.trim()).toEqual('ADF_CLOUD_PROCESS_FILTERS.DIRECTION.ASCENDING');
});
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import { ProcessCloudService } from '../../services/process-cloud.service';
import { DateCloudFilterType, DateRangeFilter } from '../../../models/date-cloud-filter.model';
import { ApplicationVersionModel } from '../../../models/application-version.model';

export interface DropdownOption {
value: string;
label: string;
}

@Component({
selector: 'adf-cloud-edit-process-filter',
templateUrl: './edit-process-filter-cloud.component.html',
Expand Down Expand Up @@ -94,21 +99,14 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
processFilter: ProcessFilterCloudModel;
changedProcessFilter: ProcessFilterCloudModel;

status = [
{ label: 'ALL', value: '' },
{ label: 'RUNNING', value: 'RUNNING' },
{ label: 'SUSPENDED', value: 'SUSPENDED' },
{ label: 'CANCELLED', value: 'CANCELLED' },
{ label: 'COMPLETED', value: 'COMPLETED' }
];

directions = [{ label: 'ASC', value: 'ASC' }, { label: 'DESC', value: 'DESC' }];
status: Array<DropdownOption> = [];
directions: Array<DropdownOption> = [];
actionDisabledForDefault = [
EditProcessFilterCloudComponent.ACTION_SAVE,
EditProcessFilterCloudComponent.ACTION_DELETE
];
applicationNames: any[] = [];
allProcessDefinitionNamesOption = { label: 'All', value: '' };
allProcessDefinitionNamesOption: DropdownOption;
processDefinitionNames: any[] = [];
formHasBeenChanged = false;
editProcessFilterForm: FormGroup;
Expand All @@ -132,6 +130,24 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
}

ngOnInit() {
this.status = [
{ value: '', label: 'ADF_CLOUD_PROCESS_FILTERS.STATUS.ALL' },
{ value: 'RUNNING', label: 'ADF_CLOUD_PROCESS_FILTERS.STATUS.RUNNING' },
{ value: 'SUSPENDED', label: 'ADF_CLOUD_PROCESS_FILTERS.STATUS.SUSPENDED' },
{ value: 'CANCELLED', label: 'ADF_CLOUD_PROCESS_FILTERS.STATUS.CANCELLED' },
{ value: 'COMPLETED', label: 'ADF_CLOUD_PROCESS_FILTERS.STATUS.COMPLETED' }
];

this.directions = [
{ value: 'ASC', label: 'ADF_CLOUD_PROCESS_FILTERS.DIRECTION.ASCENDING' },
{ value: 'DESC', label: 'ADF_CLOUD_PROCESS_FILTERS.DIRECTION.DESCENDING' }
];

this.allProcessDefinitionNamesOption = {
label: 'ADF_CLOUD_PROCESS_FILTERS.STATUS.ALL',
value: ''
};

this.userPreferencesService
.select(UserPreferenceValues.Locale)
.pipe(takeUntil(this.onDestroy$))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import { IdentityGroupModel, IdentityUserModel, TranslationService, UserPreferen
import { TaskFilterDialogCloudComponent } from '../task-filter-dialog/task-filter-dialog-cloud.component';
import { MatDialog } from '@angular/material/dialog';

export interface DropdownOption {
value: string;
label: string;
}

@Directive()
// tslint:disable-next-line: directive-class-suffix
export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnChanges, OnDestroy {
Expand All @@ -44,10 +49,6 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
public static ORDER: string = 'order';
public static DEFAULT_ACTIONS = ['save', 'saveAs', 'delete'];
public static FORMAT_DATE: string = 'DD/MM/YYYY';
public static DIRECTIONS = [
{ label: 'ASC', value: 'ASC' },
{ label: 'DESC', value: 'DESC' }
];
public static ACTIONS_DISABLED_BY_DEFAULT = [
BaseEditTaskFilterCloudComponent.ACTION_SAVE,
BaseEditTaskFilterCloudComponent.ACTION_DELETE
Expand Down Expand Up @@ -93,14 +94,16 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
@Output()
action = new EventEmitter<TaskFilterAction>();

protected applicationNames: any[] = [];
protected processDefinitionNames: any[] = [];
protected applicationNames: DropdownOption[] = [];
protected processDefinitionNames: DropdownOption[] = [];
protected formHasBeenChanged = false;

editTaskFilterForm: FormGroup;
taskFilterProperties: TaskFilterProperties[] = [];
taskFilterActions: TaskFilterAction[] = [];
toggleFilterActions: boolean = false;
allProcessDefinitionNamesOption = { label: 'All', value: '' };
sortDirections: DropdownOption[] = [];
allProcessDefinitionNamesOption: DropdownOption;

taskFilter: T;
changedTaskFilter: T;
Expand All @@ -123,6 +126,16 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
}

ngOnInit() {
this.sortDirections = [
{ value: 'ASC', label: 'ADF_CLOUD_TASK_FILTERS.DIRECTION.ASCENDING' },
{ value: 'DESC', label: 'ADF_CLOUD_TASK_FILTERS.DIRECTION.DESCENDING' }
];

this.allProcessDefinitionNamesOption = {
value: '',
label: 'ADF_CLOUD_TASK_FILTERS.STATUS.ALL'
};

this.userPreferencesService
.select(UserPreferenceValues.Locale)
.pipe(takeUntil(this.onDestroy$))
Expand Down Expand Up @@ -314,7 +327,7 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
this.checkMandatorySortProperties();

return this.sortProperties.map((property: string) => {
return { label: property.charAt(0).toUpperCase() + property.slice(1), value: property };
return { label: property, value: property };
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,13 @@ describe('EditServiceTaskFilterCloudComponent', () => {
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-order"]');
expect(assigneeElement).toBeDefined();
expect(stateElement.textContent.trim()).toBe('COMPLETED');
expect(sortElement.textContent.trim()).toBe('Id');
expect(orderElement.textContent.trim()).toBe('ASC');
expect(stateElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.COMPLETED');
expect(sortElement.textContent.trim()).toBe('id');
expect(orderElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.DIRECTION.ASCENDING');
});
}));

it('should display all the statuses that are defined in the task filter', async(() => {

const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
expansionPanel.click();
fixture.detectChanges();
Expand All @@ -399,11 +398,11 @@ describe('EditServiceTaskFilterCloudComponent', () => {

const statusOptions = fixture.debugElement.queryAll(By.css('[data-automation-id="adf-cloud-edit-task-property-options-status"]'));

expect(statusOptions[0].nativeElement.textContent.trim()).toBe('ALL');
expect(statusOptions[1].nativeElement.textContent.trim()).toBe('STARTED');
expect(statusOptions[2].nativeElement.textContent.trim()).toBe('COMPLETED');
expect(statusOptions[3].nativeElement.textContent.trim()).toBe('CANCELLED');
expect(statusOptions[4].nativeElement.textContent.trim()).toBe('ERROR');
expect(statusOptions[0].nativeElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.ALL');
expect(statusOptions[1].nativeElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.STARTED');
expect(statusOptions[2].nativeElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.COMPLETED');
expect(statusOptions[3].nativeElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.CANCELLED');
expect(statusOptions[4].nativeElement.textContent.trim()).toBe('ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.ERROR');
}));

it('should display sort drop down', async(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { TranslationService, UserPreferencesService } from '@alfresco/adf-core';
import { AppsProcessCloudService } from '../../../../app/services/apps-process-cloud.service';
import { TaskCloudService } from '../../../services/task-cloud.service';
import { ServiceTaskFilterCloudService } from '../../services/service-task-filter-cloud.service';
import { BaseEditTaskFilterCloudComponent } from './base-edit-task-filter-cloud.component';
import { BaseEditTaskFilterCloudComponent, DropdownOption } from './base-edit-task-filter-cloud.component';

@Component({
selector: 'adf-cloud-edit-service-task-filter',
Expand Down Expand Up @@ -91,17 +91,19 @@ export class EditServiceTaskFilterCloudComponent extends BaseEditTaskFilterCloud
return this.serviceTaskFilterCloudService.getTaskListFilters(this.appName);
}

private getDefaultProperties() {
private getStatusOptions(): DropdownOption[] {
return [
{ label: 'ALL', value: '' },
{ label: 'STARTED', value: 'STARTED' },
{ label: 'COMPLETED', value: 'COMPLETED' },
{ label: 'CANCELLED', value: 'CANCELLED' },
{ label: 'ERROR', value: 'ERROR' }
{ value: '', label: 'ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.ALL' },
{ value: 'STARTED', label: 'ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.STARTED' },
{ value: 'COMPLETED', label: 'ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.COMPLETED' },
{ value: 'CANCELLED', label: 'ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.CANCELLED' },
{ value: 'ERROR', label: 'ADF_CLOUD_SERVICE_TASK_FILTERS.STATUS.ERROR' }
];
}

createTaskFilterProperties(): TaskFilterProperties[] {
const statusOptions = this.getStatusOptions();

return [
{
label: 'ADF_CLOUD_EDIT_SERVICE_TASK_FILTER.LABEL.APP_NAME',
Expand Down Expand Up @@ -145,15 +147,15 @@ export class EditServiceTaskFilterCloudComponent extends BaseEditTaskFilterCloud
label: 'ADF_CLOUD_EDIT_SERVICE_TASK_FILTER.LABEL.DIRECTION',
type: 'select',
key: 'order',
value: this.taskFilter.order || EditServiceTaskFilterCloudComponent.DIRECTIONS[0].value,
options: EditServiceTaskFilterCloudComponent.DIRECTIONS
value: this.taskFilter.order || this.sortDirections[0].value,
options: [...this.sortDirections]
},
{
label: 'ADF_CLOUD_EDIT_SERVICE_TASK_FILTER.LABEL.STATUS',
type: 'select',
key: 'status',
value: this.taskFilter.status || this.getDefaultProperties()[0].value,
options: this.getDefaultProperties()
value: this.taskFilter.status || statusOptions[0].value,
options: statusOptions
},
{
label: 'ADF_CLOUD_EDIT_SERVICE_TASK_FILTER.LABEL.STARTED_DATE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ describe('EditTaskFilterCloudComponent', () => {
const sortElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-sort"]');
const orderElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-task-property-order"]');
expect(assigneeElement).toBeDefined();
expect(stateElement.textContent.trim()).toBe('CREATED');
expect(sortElement.textContent.trim()).toBe('Id');
expect(orderElement.textContent.trim()).toBe('ASC');
expect(stateElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.CREATED');
expect(sortElement.textContent.trim()).toBe('id');
expect(orderElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.DIRECTION.ASCENDING');
});
}));

Expand All @@ -414,12 +414,12 @@ describe('EditTaskFilterCloudComponent', () => {

const statusOptions = fixture.debugElement.queryAll(By.css('[data-automation-id="adf-cloud-edit-task-property-options-status"]'));

expect(statusOptions[0].nativeElement.textContent.trim()).toBe('ALL');
expect(statusOptions[1].nativeElement.textContent.trim()).toBe('CREATED');
expect(statusOptions[2].nativeElement.textContent.trim()).toBe('ASSIGNED');
expect(statusOptions[3].nativeElement.textContent.trim()).toBe('SUSPENDED');
expect(statusOptions[4].nativeElement.textContent.trim()).toBe('CANCELLED');
expect(statusOptions[5].nativeElement.textContent.trim()).toBe('COMPLETED');
expect(statusOptions[0].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.ALL');
expect(statusOptions[1].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.CREATED');
expect(statusOptions[2].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.ASSIGNED');
expect(statusOptions[3].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.SUSPENDED');
expect(statusOptions[4].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.CANCELLED');
expect(statusOptions[5].nativeElement.textContent.trim()).toBe('ADF_CLOUD_TASK_FILTERS.STATUS.COMPLETED');
}));

it('should display sort drop down', async(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { TranslationService, UserPreferencesService } from '@alfresco/adf-core';
import { AppsProcessCloudService } from '../../../../app/services/apps-process-cloud.service';
import { DateCloudFilterType } from '../../../../models/date-cloud-filter.model';
import { TaskCloudService } from '../../../services/task-cloud.service';
import { BaseEditTaskFilterCloudComponent } from './base-edit-task-filter-cloud.component';
import { BaseEditTaskFilterCloudComponent, DropdownOption } from './base-edit-task-filter-cloud.component';

@Component({
selector: 'adf-cloud-edit-task-filter',
Expand Down Expand Up @@ -140,18 +140,21 @@ export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudCompone
];
}

private getDefaultProperties() {
private getStatusOptions(): DropdownOption[] {
return [
{ label: 'ALL', value: '' },
{ label: 'CREATED', value: 'CREATED' },
{ label: 'ASSIGNED', value: 'ASSIGNED' },
{ label: 'SUSPENDED', value: 'SUSPENDED' },
{ label: 'CANCELLED', value: 'CANCELLED' },
{ label: 'COMPLETED', value: 'COMPLETED' }
{ value: '', label: 'ADF_CLOUD_TASK_FILTERS.STATUS.ALL' },
{ value: 'CREATED', label: 'ADF_CLOUD_TASK_FILTERS.STATUS.CREATED' },
{ value: 'ASSIGNED', label: 'ADF_CLOUD_TASK_FILTERS.STATUS.ASSIGNED' },
{ value: 'SUSPENDED', label: 'ADF_CLOUD_TASK_FILTERS.STATUS.SUSPENDED' },
{ value: 'CANCELLED', label: 'ADF_CLOUD_TASK_FILTERS.STATUS.CANCELLED' },
{ value: 'COMPLETED', label: 'ADF_CLOUD_TASK_FILTERS.STATUS.COMPLETED' }
];
}

createTaskFilterProperties(): TaskFilterProperties[] {
const statusOptions = this.getStatusOptions();
const sortProperties = this.createSortProperties;

return [
{
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.APP_NAME',
Expand All @@ -170,8 +173,8 @@ export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudCompone
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.STATUS',
type: 'select',
key: 'status',
value: this.taskFilter.status || this.getDefaultProperties()[0].value,
options: this.getDefaultProperties()
value: this.taskFilter.status || statusOptions[0].value,
options: statusOptions
},
{
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.ASSIGNMENT',
Expand Down Expand Up @@ -233,15 +236,15 @@ export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudCompone
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.SORT',
type: 'select',
key: 'sort',
value: this.taskFilter.sort || this.createSortProperties[0].value,
options: this.createSortProperties
value: this.taskFilter.sort || sortProperties[0].value,
options: sortProperties
},
{
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.DIRECTION',
type: 'select',
key: 'order',
value: this.taskFilter.order || EditTaskFilterCloudComponent.DIRECTIONS[0].value,
options: EditTaskFilterCloudComponent.DIRECTIONS
value: this.taskFilter.order || this.sortDirections[0].value,
options: [...this.sortDirections]
},
{
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.STAND_ALONE',
Expand Down