Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-7688] Reduce the usage of LogService and TranslateModule (tests) #9567

Merged
merged 16 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<adf-host-settings (cancel)="onCancel()" (success)="onSuccess()" (error)="onError($event)"></adf-host-settings>
<adf-host-settings (cancel)="onCancel()" (success)="onSuccess()"></adf-host-settings>
10 changes: 1 addition & 9 deletions demo-shell/src/app/components/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,14 @@
*/

import { Component } from '@angular/core';
import { LogService } from '@alfresco/adf-core';
import { Router } from '@angular/router';

@Component({
selector: 'app-settings',
templateUrl: './settings.component.html'
})
export class SettingsComponent {

constructor(private router: Router,
public logService: LogService) {
}

onError(error: string) {
this.logService.log(error);
}
constructor(private router: Router) {}

onCancel() {
this.router.navigate(['/login']);
Expand Down
20 changes: 5 additions & 15 deletions demo-shell/src/app/services/in-memory-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
*/

import { Injectable } from '@angular/core';
import { AppConfigService, LogService,
FormFieldOption, FormService, FormValues, FormModel,
FormOutcomeModel, FormOutcomeEvent } from '@alfresco/adf-core';
import { AppConfigService, FormFieldOption, FormService, FormValues, FormModel, FormOutcomeModel, FormOutcomeEvent } from '@alfresco/adf-core';
import { Observable, Subject } from 'rxjs';

interface ProcessServiceData {
Expand All @@ -37,13 +35,11 @@ interface ProcessServiceData {
//
@Injectable()
export class InMemoryFormService extends FormService {

private data: ProcessServiceData;

executeOutcome = new Subject<FormOutcomeEvent>();

constructor(appConfig: AppConfigService,
protected logService: LogService) {
constructor(appConfig: AppConfigService) {
super();
this.data = appConfig.get<ProcessServiceData>('activiti');
}
Expand All @@ -53,14 +49,10 @@ export class InMemoryFormService extends FormService {
// Uncomment this to use original call
// return super.getRestFieldValues(taskId, fieldId);

this.logService.log(`getRestFieldValues: ${taskId} => ${field}`);
return new Observable<FormFieldOption[]>((observer) => {
const currentField = this.data.rest.fields.find(
(f) => f.taskId === taskId && f.fieldId === field
);
if ( currentField ) {
const currentField = this.data.rest.fields.find((f) => f.taskId === taskId && f.fieldId === field);
if (currentField) {
const values: FormFieldOption[] = currentField.values || [];
this.logService.log(values);
observer.next(values);
}
});
Expand All @@ -75,7 +67,7 @@ export class InMemoryFormService extends FormService {
delete flattenForm.formDefinition;

const formValues: FormValues = {};
(data || []).forEach(variable => {
(data || []).forEach((variable) => {
formValues[variable.name] = variable.value;
});

Expand All @@ -99,13 +91,11 @@ export class InMemoryFormService extends FormService {
// Uncomment this to use original call
// return super.getRestFieldValuesByProcessId(processDefinitionId, fieldId);

this.logService.log(`getRestFieldValuesByProcessId: ${processDefinitionId} => ${fieldId}`);
return new Observable<FormFieldOption[]>((observer) => {
const field = this.data.rest.fields.find(
(currentField) => currentField.processId === processDefinitionId && currentField.fieldId === fieldId
);
const values: FormFieldOption[] = field.values || [];
this.logService.log(values);
observer.next(values);
});
}
Expand Down
4 changes: 4 additions & 0 deletions docs/process-services/components/people.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Displays users involved with a specified task
| readOnly | `boolean` | false | Should the data be read-only? |
| taskId | `string` | "" | The numeric ID of the task. |

### Events

- `error`: Emitted when an error occurs.

## Details

### How to customize the people component behavior
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Injectable } from '@angular/core';
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
import { from, Observable, of, zip } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { AspectEntry, AspectPaging, AspectsApi } from '@alfresco/js-api';
Expand All @@ -25,17 +25,13 @@ import { AspectEntry, AspectPaging, AspectsApi } from '@alfresco/js-api';
providedIn: 'root'
})
export class AspectListService {

private _aspectsApi: AspectsApi;
get aspectsApi(): AspectsApi {
this._aspectsApi = this._aspectsApi ?? new AspectsApi(this.alfrescoApiService.getInstance());
return this._aspectsApi;
}

constructor(private alfrescoApiService: AlfrescoApiService,
private appConfigService: AppConfigService,
private logService: LogService) {
}
constructor(private alfrescoApiService: AlfrescoApiService, private appConfigService: AppConfigService) {}

getAspects(): Observable<AspectEntry[]> {
const visibleAspectList = this.getVisibleAspects();
Expand All @@ -52,14 +48,11 @@ export class AspectListService {
where,
include: ['properties']
};
return from(this.aspectsApi.listAspects(opts))
.pipe(
map((result: AspectPaging) => this.filterAspectByConfig(whiteList, result?.list?.entries)),
catchError((error) => {
this.logService.error(error);
return of([]);
})
);

return from(this.aspectsApi.listAspects(opts)).pipe(
map((result: AspectPaging) => this.filterAspectByConfig(whiteList, result?.list?.entries)),
catchError(() => of([]))
);
}

getCustomAspects(whiteList?: string[]): Observable<AspectEntry[]> {
Expand All @@ -68,14 +61,10 @@ export class AspectListService {
where,
include: ['properties']
};
return from(this.aspectsApi.listAspects(opts))
.pipe(
map((result: AspectPaging) => this.filterAspectByConfig(whiteList, result?.list?.entries)),
catchError((error) => {
this.logService.error(error);
return of([]);
})
);
return from(this.aspectsApi.listAspects(opts)).pipe(
map((result: AspectPaging) => this.filterAspectByConfig(whiteList, result?.list?.entries)),
catchError(() => of([]))
);
}

private filterAspectByConfig(visibleAspectList: string[], aspectEntries: AspectEntry[]): AspectEntry[] {
Expand All @@ -96,5 +85,4 @@ export class AspectListService {
}
return visibleAspectList;
}

}
Loading
Loading