Files
alfresco-ng2-components/lib/process-services-cloud/src/lib/process/process-header/components/process-header-cloud.component.ts
T
64826c3a99 AAE-40649 Material Design 3 migration (#11286)
* AAE-38957 Cleanup code from color assignments on Material elements (#11266)

* AAE-38646   cleanup core lib from custom variables (#11259)

* AAE-38646 General cleanup of custom variables from core lib

* AAE-38646 Cleanup some of the remaining variables

* AAE-38646 Last color-mix removal

* AAE-38646 Reduce amount of customizations

* AAE-38646 apply overrides, reduce customization

* AAE-38646 modify remaining styles

* AAE-38646 Fix override assignemnts

* AAE-38646 Address comments, cleanup unused

* AAE-38978 Cleanup process-services-cloud lib from custom css variables (#11295)

* AAE-38978 Cleanup custom variables inside process-services-cloud lib

* AAE-38978 Adjust rich text widget styling

* AAE-38978 Comment fixes

* AAE-38980 Cleanup insights lib from custom css variables (#11314)

* AAE-38980 Cleanup insights lib from custom css variables

* AAE-38980 Removed unnecessarily specific selector

* AAE-38979 Cleanup content-services lib from custom css variables (#11313)

* AAE-38979 Remove/replace variable and hardcoded customizations

* AAE-38979 Cleanup unused @use and @import statements

* AAE-39159 Cleanup process-services lib from custom css variables (#11316)

* AAE-39159 Cleanup process-services lib from custom css variables

* AAE-39159 Fix import and build

* Fix build

* Remove leftover button customization

* fix missing brace

* AAE-39748 Pagination font size match md3

* fix incorrect html templates after rebase

* swap leftover variables

* fix units

* copilot comments

* visual regression result fixes

* CSX-204 Update card view components (#11358)

* CSX-535 Update background color on readonly for card view selectitem (#11799)

* remove invalid color test

* add stylelint rule

---------

Co-authored-by: Ehsan Rezaei <ehsan.rezaei@hyland.com>
Co-authored-by: Ricardo Dias <ricardo.dias@hyland.com>
2026-04-22 10:02:17 +01:00

158 lines
6.2 KiB
TypeScript

/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, DestroyRef, EventEmitter, inject, Input, OnChanges, OnInit, Output, ViewEncapsulation } from '@angular/core';
import {
AppConfigService,
CardViewBaseItemModel,
CardViewComponent,
CardViewDateItemModel,
CardViewItem,
CardViewTextItemModel,
TranslationService
} from '@alfresco/adf-core';
import { ProcessInstanceCloud } from '../../start-process/models/process-instance-cloud.model';
import { ProcessCloudService } from '../../services/process-cloud.service';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MatCardModule } from '@angular/material/card';
import { NgIf } from '@angular/common';
@Component({
selector: 'adf-cloud-process-header',
imports: [CardViewComponent, MatCardModule, NgIf],
templateUrl: './process-header-cloud.component.html',
encapsulation: ViewEncapsulation.None,
host: { class: 'adf-cloud-process-header' }
})
export class ProcessHeaderCloudComponent implements OnChanges, OnInit {
private readonly processCloudService = inject(ProcessCloudService);
private readonly translationService = inject(TranslationService);
private readonly appConfig = inject(AppConfigService);
/** (Required) The name of the application. */
@Input({ required: true })
appName: string = '';
/** (Required) The id of the process instance. */
@Input({ required: true })
processInstanceId: string;
/** Gets emitted each time a new process instance details are loaded. */
@Output()
loaded = new EventEmitter<ProcessInstanceCloud>();
processInstanceDetails: ProcessInstanceCloud;
properties: CardViewItem[];
dateFormat: string;
dateLocale: string;
private readonly destroyRef = inject(DestroyRef);
ngOnInit() {
this.dateFormat = this.appConfig.get('adf-cloud-process-header.defaultDateFormat');
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
this.processCloudService.dataChangesDetected
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((processDetails) => this.onLoaded(processDetails));
}
ngOnChanges() {
if ((this.appName || this.appName === '') && this.processInstanceId) {
this.loadProcessInstanceDetails(this.appName, this.processInstanceId);
}
}
private loadProcessInstanceDetails(appName: string, processInstanceId: string) {
this.processCloudService.getProcessInstanceById(appName, processInstanceId).subscribe((result) => this.onLoaded(result));
}
private onLoaded(processInstanceDetails: ProcessInstanceCloud) {
this.processInstanceDetails = processInstanceDetails;
this.refreshData();
this.loaded.emit(processInstanceDetails);
}
/**
* Refresh the card data
*/
refreshData() {
if (this.processInstanceDetails) {
const defaultProperties = this.initDefaultProperties();
const filteredProperties = this.appConfig.get<string[]>('adf-cloud-process-header.presets.properties');
this.properties = defaultProperties.filter((cardItem) => this.isValidSelection(filteredProperties, cardItem));
}
}
private initDefaultProperties(): any[] {
return [
new CardViewTextItemModel({
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.ID',
value: this.processInstanceDetails.id,
key: 'id'
}),
new CardViewTextItemModel({
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME',
value: this.processInstanceDetails.name,
key: 'name',
default: this.translationService.instant('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME_DEFAULT')
}),
new CardViewTextItemModel({
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.STATUS',
value: this.processInstanceDetails.status,
key: 'status'
}),
new CardViewTextItemModel({
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.INITIATOR',
value: this.processInstanceDetails.initiator,
key: 'initiator'
}),
new CardViewDateItemModel({
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.START_DATE',
value: this.processInstanceDetails.startDate,
key: 'startDate',
format: this.dateFormat,
locale: this.dateLocale
}),
new CardViewDateItemModel({
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.LAST_MODIFIED',
value: this.processInstanceDetails.lastModified,
key: 'lastModified',
format: this.dateFormat,
locale: this.dateLocale
}),
new CardViewTextItemModel({
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.PARENT_ID',
value: this.processInstanceDetails.parentId,
key: 'parentId',
default: this.translationService.instant('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NONE')
}),
new CardViewTextItemModel({
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.BUSINESS_KEY',
value: this.processInstanceDetails.businessKey,
key: 'businessKey',
default: this.translationService.instant('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NONE')
})
];
}
private isValidSelection(filteredProperties: string[], cardItem: CardViewBaseItemModel): boolean {
return filteredProperties ? filteredProperties.indexOf(cardItem.key) >= 0 : true;
}
}