Skip to content

Commit

Permalink
* Fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sivakumar414ram committed May 18, 2020
1 parent 83e53d5 commit 1c590a0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/process-services/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
"FORM": {
"TITLE": "Start Process",
"LABEL": {
"APPLICATIONS": "Select Application",
"SELECT_APPLICATION": "Select Application",
"TYPE": "Select Process",
"NAME": "Process Name"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="adf-start-process-definition-container">
<mat-form-field *ngIf="showSelectApplicationDropdown" [floatLabel]="'always'" class="adf-start-process-app-list">
<mat-select
placeholder="{{'ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.APPLICATIONS' | translate}}"
placeholder="{{'ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.SELECT_APPLICATION' | translate}}"
(selectionChange)="onAppSelectionChange($event)"
[(ngModel)]="selectedApplication"
data-automation-id="adf-start-process-apps-drop-down">
Expand All @@ -33,7 +33,7 @@
#auto="matAutocomplete"
id="processDefinitionOptions"
[displayWith]="displayFn">
<mat-option *ngFor="let processDef of filteredProcesses | async" [value]="processDef.name"
<mat-option *ngFor="let processDef of filteredProcessesDefinitions$ | async" [value]="processDef.name"
(click)="processDefinitionSelectionChanged(processDef)">
{{ processDef.name }}
</mat-option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ describe('StartFormComponent', () => {

describe('Select applications', () => {

const mockAppId = 3;

beforeEach(() => {
fixture.detectChanges();
component.name = 'My new process';
Expand All @@ -606,7 +608,7 @@ describe('StartFormComponent', () => {
const lableElement = fixture.nativeElement.querySelector('.adf-start-process-app-list .mat-form-field-label');

expect(appsSelector).not.toBeNull();
expect(lableElement.innerText).toEqual('ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.APPLICATIONS');
expect(lableElement.innerText).toEqual('ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.SELECT_APPLICATION');

expect(getDeployedApplicationsSpy).toHaveBeenCalled();
expect(component.applications.length).toBe(6);
Expand All @@ -615,22 +617,24 @@ describe('StartFormComponent', () => {
expect(component.selectedApplication.id).toEqual(component.appId);
expect(component.selectedApplication.name).toEqual('App3');

expect(getDefinitionsSpy).toHaveBeenCalled();
expect(getDefinitionsSpy).toHaveBeenCalledWith(mockAppId);
expect(component.processDefinitions.length).toEqual(2);
expect(component.processDefinitions[0].name).toEqual('My Process 1');
expect(component.processDefinitions[1].name).toEqual('My Process 2');
});

it('Should able to list process-definition based on selected application', () => {
it('Should be able to list process-definition based on selected application', () => {
fixture.detectChanges();
expect(component.appId).toBe(component.selectedApplication.id);
expect(component.selectedApplication).toEqual(deployedApps[2]);
expect(component.selectedApplication.name).toEqual('App3');

expect(getDefinitionsSpy).toHaveBeenCalledWith(mockAppId);
expect(component.processDefinitions.length).toEqual(2);
expect(component.processDefinitions[0].name).toEqual('My Process 1');
expect(component.processDefinitions[1].name).toEqual('My Process 2');

const changedAppId = 2;
getDefinitionsSpy.and.returnValue(of([ { id: 'my:process 3', name: 'My Process 3', hasStartForm: true } ]));
fixture.detectChanges();

Expand All @@ -641,6 +645,7 @@ describe('StartFormComponent', () => {
expect(component.selectedApplication).toEqual(deployedApps[1]);
expect(component.selectedApplication.name).toEqual('App2');

expect(getDefinitionsSpy).toHaveBeenCalledWith(changedAppId);
expect(component.processDefinitions.length).toEqual(1);
expect(component.processDefinitions[0].name).toEqual('My Process 3');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
errorMessageId: string = '';
processNameInput: FormControl;
processDefinitionInput: FormControl;
filteredProcesses: Observable<ProcessDefinitionRepresentation[]>;
filteredProcessesDefinitions$: Observable<ProcessDefinitionRepresentation[]>;
maxProcessNameLength: number = this.MAX_LENGTH;
alfrescoRepositoryName: string;
applications: AppDefinitionRepresentationModel[] = [];
Expand All @@ -141,7 +141,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
.pipe(takeUntil(this.onDestroy$))
.subscribe(name => this.name = name);

this.filteredProcesses = this.processDefinitionInput.valueChanges
this.filteredProcessesDefinitions$ = this.processDefinitionInput.valueChanges
.pipe(
map((value) => this._filter(value)),
takeUntil(this.onDestroy$)
Expand Down Expand Up @@ -222,6 +222,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
}
}

this.processDefinitionSelection.emit(this.selectedProcessDef);
this.processDefinitionInput.setValue(this.selectedProcessDef.name);
}
},
Expand All @@ -234,19 +235,9 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
this.appsProcessService
.getDeployedApplications()
.pipe(map((response: AppDefinitionRepresentationModel[]) => {
let currentApplication: AppDefinitionRepresentationModel;
let applications: AppDefinitionRepresentationModel[] = [];

applications = this.removeDefaultApps(response);

if (applications && applications.length > 0) {
currentApplication = applications[0];
if (this.appId) {
const filteredApp = applications.find( app => app.id === +this.appId );
currentApplication = filteredApp ? filteredApp : applications[0];
}
}

const applications = this.removeDefaultApps(response);
const filteredApp = applications.find( app => app.id === +this.appId );
const currentApplication = filteredApp ? filteredApp : applications[0];
return { currentApplication, applications };
})
)
Expand All @@ -264,7 +255,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr

onAppSelectionChange(selectedApplication: any) {
this.selectedApplication = selectedApplication.value;
this.loadStartProcess(this.selectedApplication.id);
this.appId = this.selectedApplication.id;
this.loadStartProcess(this.appId);
}

private removeDefaultApps(apps: AppDefinitionRepresentationModel []): AppDefinitionRepresentationModel[] {
Expand Down

0 comments on commit 1c590a0

Please sign in to comment.