[affected:*][ci:force] - Rebased and added an extra fix for after

This commit is contained in:
Vito Albano 2024-04-05 12:07:09 +01:00 committed by VitoAlbano
parent 8475e8bfec
commit ce3881af4f

View File

@ -15,8 +15,15 @@
* limitations under the License. * limitations under the License.
*/ */
import { Component, Input, OnChanges, OnInit, OnDestroy, EventEmitter, ViewEncapsulation } from '@angular/core'; import { Component, Input, OnChanges, OnInit, OnDestroy, EventEmitter, ViewEncapsulation, Output } 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';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
@ -30,7 +37,6 @@ import { Subject } from 'rxjs';
host: { class: 'adf-cloud-process-header' } host: { class: 'adf-cloud-process-header' }
}) })
export class ProcessHeaderCloudComponent implements OnChanges, OnInit, OnDestroy { export class ProcessHeaderCloudComponent implements OnChanges, OnInit, OnDestroy {
/** (Required) The name of the application. */ /** (Required) The name of the application. */
@Input() @Input()
appName: string = ''; appName: string = '';
@ -39,29 +45,28 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit, OnDestroy
@Input() @Input()
processInstanceId: string; processInstanceId: string;
/** Gets emitted each time a new process instance details are loaded. */
@Output()
loaded = new EventEmitter<ProcessInstanceCloud>();
processInstanceDetails: ProcessInstanceCloud; processInstanceDetails: ProcessInstanceCloud;
properties: CardViewItem[]; properties: CardViewItem[];
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
} ) {}
ngOnInit() { ngOnInit() {
this.dateFormat = this.appConfig.get('adf-cloud-process-header.defaultDateFormat'); this.dateFormat = this.appConfig.get('adf-cloud-process-header.defaultDateFormat');
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale'); this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
this.processCloudService.dataChangesDetected this.processCloudService.dataChangesDetected.pipe(takeUntil(this.onDestroy$)).subscribe((processDetails) => this.onLoaded(processDetails));
.pipe(takeUntil(this.onDestroy$))
.subscribe((processDetails) => this.onLoaded(processDetails));
} }
ngOnChanges() { ngOnChanges() {
@ -71,9 +76,7 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit, OnDestroy
} }
private loadProcessInstanceDetails(appName: string, processInstanceId: string) { private loadProcessInstanceDetails(appName: string, processInstanceId: string) {
this.processCloudService this.processCloudService.getProcessInstanceById(appName, processInstanceId).subscribe((result) => this.onLoaded(result));
.getProcessInstanceById(appName, processInstanceId)
.subscribe((result) => this.onLoaded(result));
} }
private onLoaded(processInstanceDetails: ProcessInstanceCloud) { private onLoaded(processInstanceDetails: ProcessInstanceCloud) {
@ -96,56 +99,48 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit, OnDestroy
private initDefaultProperties(): any[] { private initDefaultProperties(): any[] {
return [ return [
new CardViewTextItemModel( new CardViewTextItemModel({
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.ID', label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.ID',
value: this.processInstanceDetails.id, value: this.processInstanceDetails.id,
key: 'id' key: 'id'
}), }),
new CardViewTextItemModel( new CardViewTextItemModel({
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME', label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME',
value: this.processInstanceDetails.name, value: this.processInstanceDetails.name,
key: 'name', key: 'name',
default: this.translationService.instant('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME_DEFAULT') default: this.translationService.instant('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME_DEFAULT')
}), }),
new CardViewTextItemModel( new CardViewTextItemModel({
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.STATUS', label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.STATUS',
value: this.processInstanceDetails.status, value: this.processInstanceDetails.status,
key: 'status' key: 'status'
}), }),
new CardViewTextItemModel( new CardViewTextItemModel({
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.INITIATOR', label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.INITIATOR',
value: this.processInstanceDetails.initiator, value: this.processInstanceDetails.initiator,
key: 'initiator' key: 'initiator'
}), }),
new CardViewDateItemModel( new CardViewDateItemModel({
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.START_DATE', label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.START_DATE',
value: this.processInstanceDetails.startDate, value: this.processInstanceDetails.startDate,
key: 'startDate', key: 'startDate',
format: this.dateFormat, format: this.dateFormat,
locale: this.dateLocale locale: this.dateLocale
}), }),
new CardViewDateItemModel( new CardViewDateItemModel({
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.LAST_MODIFIED', label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.LAST_MODIFIED',
value: this.processInstanceDetails.lastModified, value: this.processInstanceDetails.lastModified,
key: 'lastModified', key: 'lastModified',
format: this.dateFormat, format: this.dateFormat,
locale: this.dateLocale locale: this.dateLocale
}), }),
new CardViewTextItemModel( new CardViewTextItemModel({
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.PARENT_ID', label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.PARENT_ID',
value: this.processInstanceDetails.parentId, value: this.processInstanceDetails.parentId,
key: 'parentId', key: 'parentId',
default: this.translationService.instant('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NONE') default: this.translationService.instant('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NONE')
}), }),
new CardViewTextItemModel( new CardViewTextItemModel({
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.BUSINESS_KEY', label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.BUSINESS_KEY',
value: this.processInstanceDetails.businessKey, value: this.processInstanceDetails.businessKey,
key: 'businessKey', key: 'businessKey',