mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
process header loaded event (#5981)
This commit is contained in:
parent
edd172dc9b
commit
58ec56a3b8
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Input, OnChanges, OnInit } from '@angular/core';
|
import { Component, Input, OnChanges, OnInit, OnDestroy, EventEmitter } from '@angular/core';
|
||||||
import { CardViewItem, CardViewTextItemModel, TranslationService, AppConfigService, CardViewDateItemModel, CardViewBaseItemModel } from '@alfresco/adf-core';
|
import { CardViewItem, CardViewTextItemModel, TranslationService, AppConfigService, CardViewDateItemModel, CardViewBaseItemModel } from '@alfresco/adf-core';
|
||||||
import { ProcessInstanceCloud } from '../../start-process/models/process-instance-cloud.model';
|
import { ProcessInstanceCloud } from '../../start-process/models/process-instance-cloud.model';
|
||||||
import { ProcessCloudService } from '../../services/process-cloud.service';
|
import { ProcessCloudService } from '../../services/process-cloud.service';
|
||||||
@ -28,7 +28,7 @@ import { Subject } from 'rxjs';
|
|||||||
styleUrls: ['./process-header-cloud.component.scss']
|
styleUrls: ['./process-header-cloud.component.scss']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class ProcessHeaderCloudComponent implements OnChanges, OnInit {
|
export class ProcessHeaderCloudComponent implements OnChanges, OnInit, OnDestroy {
|
||||||
|
|
||||||
/** (Required) The name of the application. */
|
/** (Required) The name of the application. */
|
||||||
@Input()
|
@Input()
|
||||||
@ -43,23 +43,24 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit {
|
|||||||
dateFormat: string;
|
dateFormat: string;
|
||||||
dateLocale: string;
|
dateLocale: string;
|
||||||
|
|
||||||
|
/** Gets emitted each time a new process instance details are loaded. */
|
||||||
|
loaded = new EventEmitter<ProcessInstanceCloud>();
|
||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private processCloudService: ProcessCloudService,
|
private processCloudService: ProcessCloudService,
|
||||||
private translationService: TranslationService,
|
private translationService: TranslationService,
|
||||||
private appConfig: AppConfigService) {
|
private appConfig: AppConfigService) {
|
||||||
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
|
|
||||||
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
|
||||||
|
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
|
||||||
|
|
||||||
this.processCloudService.dataChangesDetected
|
this.processCloudService.dataChangesDetected
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((processDetails) => {
|
.subscribe((processDetails) => this.onLoaded(processDetails));
|
||||||
this.processInstanceDetails = processDetails;
|
|
||||||
this.refreshData();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
@ -69,11 +70,16 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private loadProcessInstanceDetails(appName: string, processInstanceId: string) {
|
private loadProcessInstanceDetails(appName: string, processInstanceId: string) {
|
||||||
this.processCloudService.getProcessInstanceById(appName, processInstanceId).subscribe(
|
this.processCloudService
|
||||||
(processInstanceDetails) => {
|
.getProcessInstanceById(appName, processInstanceId)
|
||||||
this.processInstanceDetails = processInstanceDetails;
|
.subscribe((result) => this.onLoaded(result));
|
||||||
this.refreshData();
|
}
|
||||||
});
|
|
||||||
|
private onLoaded(processInstanceDetails: ProcessInstanceCloud) {
|
||||||
|
this.processInstanceDetails = processInstanceDetails;
|
||||||
|
this.refreshData();
|
||||||
|
|
||||||
|
this.loaded.emit(processInstanceDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +88,7 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit {
|
|||||||
refreshData() {
|
refreshData() {
|
||||||
if (this.processInstanceDetails) {
|
if (this.processInstanceDetails) {
|
||||||
const defaultProperties = this.initDefaultProperties();
|
const defaultProperties = this.initDefaultProperties();
|
||||||
const filteredProperties: string[] = this.appConfig.get('adf-cloud-process-header.presets.properties');
|
const filteredProperties = this.appConfig.get<string[]>('adf-cloud-process-header.presets.properties');
|
||||||
this.properties = defaultProperties.filter((cardItem) => this.isValidSelection(filteredProperties, cardItem));
|
this.properties = defaultProperties.filter((cardItem) => this.isValidSelection(filteredProperties, cardItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user