mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
update
This commit is contained in:
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
@if (processDefinitionLoaded && !isFormCloudLoading) {
|
{{processDefinitionLoaded}}
|
||||||
|
@if (processDefinitionLoaded) {
|
||||||
<mat-card appearance="outlined" class="adf-start-process">
|
<mat-card appearance="outlined" class="adf-start-process">
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
@if (showTitle) {
|
@if (showTitle) {
|
||||||
|
|||||||
+70
-21
@@ -41,7 +41,7 @@ import {
|
|||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { AbstractControl, FormControl, FormGroup, ReactiveFormsModule, ValidatorFn, Validators } from '@angular/forms';
|
import { AbstractControl, FormControl, FormGroup, ReactiveFormsModule, ValidatorFn, Validators } from '@angular/forms';
|
||||||
import { MatAutocompleteModule, MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
import { MatAutocompleteModule, MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
||||||
import { catchError, debounceTime, map } from 'rxjs/operators';
|
import { catchError, debounceTime, map, switchMap } from 'rxjs/operators';
|
||||||
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
|
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
|
||||||
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
|
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
|
||||||
import { ProcessWithFormPayloadCloud } from '../models/process-with-form-payload-cloud.model';
|
import { ProcessWithFormPayloadCloud } from '../models/process-with-form-payload-cloud.model';
|
||||||
@@ -304,24 +304,22 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setProcessDefinitionOnForm(selectedProcessDefinitionName: string) {
|
private fetchStaticVariablesAndConstants(selectedProcessDefinitionName: string): Observable<[TaskVariableCloud[], TaskVariableCloud[]]> {
|
||||||
this.isFormCloudLoading = true;
|
const processDefinitionCurrent = this.selectProcessDefinition(selectedProcessDefinitionName);
|
||||||
const processDefinitionCurrent = this.filteredProcesses.find(
|
|
||||||
(process: ProcessDefinitionCloud) => process.name === selectedProcessDefinitionName || process.key === selectedProcessDefinitionName
|
|
||||||
);
|
|
||||||
|
|
||||||
forkJoin([
|
return forkJoin([
|
||||||
this.startProcessCloudService
|
this.startProcessCloudService
|
||||||
.getStartEventFormStaticValuesMapping(this.appName, processDefinitionCurrent.id)
|
.getStartEventFormStaticValuesMapping(this.appName, processDefinitionCurrent.id)
|
||||||
.pipe(catchError(() => of([] as TaskVariableCloud[]))),
|
.pipe(catchError(() => of([] as TaskVariableCloud[]))),
|
||||||
this.startProcessCloudService
|
this.startProcessCloudService
|
||||||
.getStartEventConstants(this.appName, processDefinitionCurrent.id)
|
.getStartEventConstants(this.appName, processDefinitionCurrent.id)
|
||||||
.pipe(catchError(() => of([] as TaskVariableCloud[])))
|
.pipe(catchError(() => of([] as TaskVariableCloud[])))
|
||||||
]).subscribe({
|
]);
|
||||||
next: ([staticMappings, constants]) => {
|
}
|
||||||
|
|
||||||
|
private onFetchStaticVariablesAndConstants([staticMappings, constants]: [TaskVariableCloud[], TaskVariableCloud[]]): void {
|
||||||
this.staticMappings = staticMappings;
|
this.staticMappings = staticMappings;
|
||||||
this.resolvedValues = this.staticMappings.concat(this.values || []);
|
this.resolvedValues = this.staticMappings.concat(this.values || []);
|
||||||
this.processDefinitionCurrent = processDefinitionCurrent;
|
|
||||||
|
|
||||||
const displayStart = constants?.find((constant) => constant.name === 'startEnabled');
|
const displayStart = constants?.find((constant) => constant.name === 'startEnabled');
|
||||||
const startLabel = constants?.find((constant) => constant.name === 'startLabel');
|
const startLabel = constants?.find((constant) => constant.name === 'startLabel');
|
||||||
@@ -333,8 +331,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
|||||||
this.displayStartSubject.next(displayStart?.value);
|
this.displayStartSubject.next(displayStart?.value);
|
||||||
}
|
}
|
||||||
if (startLabel) {
|
if (startLabel) {
|
||||||
this.startProcessButtonLabel =
|
this.startProcessButtonLabel = startLabel?.value?.trim()?.length > 0 ? startLabel.value.trim() : this.defaultStartProcessButtonLabel;
|
||||||
startLabel?.value?.trim()?.length > 0 ? startLabel.value.trim() : this.defaultStartProcessButtonLabel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayCancel) {
|
if (displayCancel) {
|
||||||
@@ -346,10 +343,24 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
this.isFormCloudLoading = false;
|
this.isFormCloudLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProcessDefinitionOnForm(selectedProcessDefinitionName: string) {
|
||||||
|
// this.isFormCloudLoading = true;
|
||||||
|
|
||||||
|
this.fetchStaticVariablesAndConstants(selectedProcessDefinitionName).subscribe({
|
||||||
|
next: ([staticMappings, constants]) => this.onFetchStaticVariablesAndConstants([staticMappings, constants])
|
||||||
});
|
});
|
||||||
|
|
||||||
this.isFormCloudLoaded = false;
|
// this.isFormCloudLoaded = false;
|
||||||
this.processPayloadCloud.processDefinitionKey = processDefinitionCurrent.key;
|
this.processPayloadCloud.processDefinitionKey = this.processDefinitionCurrent.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectProcessDefinition(keyOrName: string): ProcessDefinitionCloud | undefined {
|
||||||
|
this.processDefinitionCurrent = this.filteredProcesses.find(
|
||||||
|
(process: ProcessDefinitionCloud) => process.name === keyOrName || process.key === keyOrName
|
||||||
|
);
|
||||||
|
|
||||||
|
return this.processDefinitionCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getProcessDefinitionListByNameOrKey(processDefinitionName: string): ProcessDefinitionCloud[] {
|
private getProcessDefinitionListByNameOrKey(processDefinitionName: string): ProcessDefinitionCloud[] {
|
||||||
@@ -382,28 +393,40 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
public loadProcessDefinitions() {
|
public loadProcessDefinitions() {
|
||||||
this.resetErrorMessage();
|
this.resetErrorMessage();
|
||||||
|
debugger;
|
||||||
|
|
||||||
this.startProcessCloudService
|
this.startProcessCloudService
|
||||||
.getProcessDefinitions(this.appName)
|
.getProcessDefinitions(this.appName)
|
||||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
.pipe(
|
||||||
.subscribe({
|
takeUntilDestroyed(this.destroyRef),
|
||||||
next: (processDefinitionRepresentations: ProcessDefinitionCloud[]) => {
|
switchMap((processDefinitionRepresentations: ProcessDefinitionCloud[]) => {
|
||||||
this.processDefinitionList = processDefinitionRepresentations;
|
this.processDefinitionList = processDefinitionRepresentations;
|
||||||
if (processDefinitionRepresentations.length === 1) {
|
if (processDefinitionRepresentations.length === 1) {
|
||||||
this.selectDefaultProcessDefinition();
|
this.selectDefaultProcessDefinition();
|
||||||
} else if (this.processDefinitionName) {
|
return of();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.processDefinitionName) {
|
||||||
this.processDefinition.setValue(this.processDefinitionName);
|
this.processDefinition.setValue(this.processDefinitionName);
|
||||||
|
|
||||||
const processDefinition = this.processDefinitionList.find((process) => process.name === this.processDefinitionName);
|
const processDefinition = this.processDefinitionList.find((process) => process.name === this.processDefinitionName);
|
||||||
if (processDefinition) {
|
if (processDefinition) {
|
||||||
this.filteredProcesses = this.getProcessDefinitionListByNameOrKey(processDefinition.name);
|
this.filteredProcesses = this.getProcessDefinitionListByNameOrKey(processDefinition.name);
|
||||||
this.setProcessDefinitionOnForm(processDefinition.name);
|
|
||||||
this.processDefinitionSelectionChanged(processDefinition);
|
this.processDefinitionSelectionChanged(processDefinition);
|
||||||
|
|
||||||
|
return this.fetchStaticVariablesAndConstants(processDefinition.name);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.isFormCloudLoading = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return of();
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe({
|
||||||
|
next: ([staticMappings, constants]: [TaskVariableCloud[], TaskVariableCloud[]]) => {
|
||||||
|
if (staticMappings && constants) {
|
||||||
|
this.onFetchStaticVariablesAndConstants([staticMappings, constants]);
|
||||||
|
}
|
||||||
|
this.isFormCloudLoading = false;
|
||||||
this.processDefinitionLoaded = true;
|
this.processDefinitionLoaded = true;
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
@@ -411,6 +434,32 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
|||||||
this.isFormCloudLoading = false;
|
this.isFormCloudLoading = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// .subscribe({
|
||||||
|
// next: (processDefinitionRepresentations: ProcessDefinitionCloud[]) => {
|
||||||
|
// this.processDefinitionList = processDefinitionRepresentations;
|
||||||
|
// if (processDefinitionRepresentations.length === 1) {
|
||||||
|
// this.selectDefaultProcessDefinition();
|
||||||
|
// } else if (this.processDefinitionName) {
|
||||||
|
// this.processDefinition.setValue(this.processDefinitionName);
|
||||||
|
|
||||||
|
// const processDefinition = this.processDefinitionList.find((process) => process.name === this.processDefinitionName);
|
||||||
|
// if (processDefinition) {
|
||||||
|
// this.filteredProcesses = this.getProcessDefinitionListByNameOrKey(processDefinition.name);
|
||||||
|
// this.processDefinitionSelectionChanged(processDefinition);
|
||||||
|
// this.setProcessDefinitionOnForm(processDefinition.name);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// this.isFormCloudLoading = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// this.processDefinitionLoaded = true;
|
||||||
|
// },
|
||||||
|
// error: () => {
|
||||||
|
// this.errorMessageId = 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.LOAD_PROCESS_DEFS';
|
||||||
|
// this.isFormCloudLoading = false;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
private isValidName(name: string): boolean {
|
private isValidName(name: string): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user