mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-2956] Add event emitter when processDefinition selection changes (for both APS and CLOUD) (#5579)
This commit is contained in:
@@ -29,7 +29,8 @@
|
||||
#auto="matAutocomplete"
|
||||
id="processDefinitionOptions"
|
||||
[displayWith]="displayFn">
|
||||
<mat-option *ngFor="let processDef of filteredProcesses | async" [value]="processDef.name">
|
||||
<mat-option *ngFor="let processDef of filteredProcesses | async" [value]="processDef.name"
|
||||
(click)="processDefinitionSelectionChanged(processDef)">
|
||||
{{ processDef.name }}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { DebugElement, SimpleChange } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ActivitiContentService, AppConfigService, FormService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { of, throwError } from 'rxjs';
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
} from '../../mock';
|
||||
import { StartProcessInstanceComponent } from './start-process.component';
|
||||
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
describe('StartFormComponent', () => {
|
||||
|
||||
@@ -52,6 +53,19 @@ describe('StartFormComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
const selectOptionByName = (name: string) => {
|
||||
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
selectElement.click();
|
||||
fixture.detectChanges();
|
||||
const options: any = fixture.debugElement.queryAll(By.css('.mat-option-text'));
|
||||
const currentOption = options.find( (option: DebugElement) => option.nativeElement.innerHTML.trim() === name );
|
||||
|
||||
if (currentOption) {
|
||||
currentOption.nativeElement.click();
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
appConfig = TestBed.get(AppConfigService);
|
||||
activitiContentService = TestBed.get(ActivitiContentService);
|
||||
@@ -490,6 +504,15 @@ describe('StartFormComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should emit processDefinitionSelection event when a process definition is selected', (done) => {
|
||||
component.processDefinitionSelection.subscribe((processDefinition) => {
|
||||
expect(processDefinition).toEqual(testProcessDef);
|
||||
done();
|
||||
});
|
||||
fixture.detectChanges();
|
||||
selectOptionByName(testProcessDef.name);
|
||||
});
|
||||
|
||||
it('should not emit start event when start the process without select a process and name', () => {
|
||||
component.name = null;
|
||||
component.selectedProcessDef = null;
|
||||
|
@@ -91,6 +91,10 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
@Output()
|
||||
error: EventEmitter<ProcessInstance> = new EventEmitter<ProcessInstance>();
|
||||
|
||||
/** Emitted when process definition selection changes. */
|
||||
@Output()
|
||||
processDefinitionSelection: EventEmitter<ProcessDefinitionRepresentation> = new EventEmitter<ProcessDefinitionRepresentation>();
|
||||
|
||||
@ViewChild('startForm')
|
||||
startForm: StartFormComponent;
|
||||
|
||||
@@ -320,4 +324,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
get nameController(): AbstractControl {
|
||||
return this.processNameInput;
|
||||
}
|
||||
|
||||
processDefinitionSelectionChanged(processDefinition) {
|
||||
this.processDefinitionSelection.emit(processDefinition);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user