mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-19604] fix unwanted notification error (#9246)
* [AAE-19604] fix unwanted notification error Unknown type for mapping is enough as log error * [AAE-19604] Fix build and unit tests --------- Co-authored-by: MichalKinas <michal.kinas@hyland.com>
This commit is contained in:
@@ -25,11 +25,11 @@ import {
|
|||||||
CardViewDateItemModel,
|
CardViewDateItemModel,
|
||||||
CardViewIntItemModel,
|
CardViewIntItemModel,
|
||||||
CardViewFloatItemModel,
|
CardViewFloatItemModel,
|
||||||
NotificationService,
|
|
||||||
CardViewBoolItemModel,
|
CardViewBoolItemModel,
|
||||||
CardViewDatetimeItemModel,
|
CardViewDatetimeItemModel,
|
||||||
CardViewSelectItemModel,
|
CardViewSelectItemModel,
|
||||||
CardViewSelectItemProperties
|
CardViewSelectItemProperties,
|
||||||
|
LogService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
@@ -42,7 +42,7 @@ describe('PropertyGroupTranslatorService', () => {
|
|||||||
let propertyGroup: OrganisedPropertyGroup;
|
let propertyGroup: OrganisedPropertyGroup;
|
||||||
let property: Property;
|
let property: Property;
|
||||||
let propertyValues: { [key: string]: any };
|
let propertyValues: { [key: string]: any };
|
||||||
let notificationService: NotificationService;
|
let logService: LogService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -51,7 +51,7 @@ describe('PropertyGroupTranslatorService', () => {
|
|||||||
ContentTestingModule
|
ContentTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
notificationService = TestBed.inject(NotificationService);
|
logService = TestBed.inject(LogService);
|
||||||
service = TestBed.inject(PropertyGroupTranslatorService);
|
service = TestBed.inject(PropertyGroupTranslatorService);
|
||||||
|
|
||||||
property = {
|
property = {
|
||||||
@@ -137,7 +137,7 @@ describe('PropertyGroupTranslatorService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should log an error if unrecognised type is found', () => {
|
it('should log an error if unrecognised type is found', () => {
|
||||||
const showError = spyOn(notificationService, 'showError').and.stub();
|
const logServiceError = spyOn(logService, 'error').and.stub();
|
||||||
|
|
||||||
property.name = 'FAS:PLAGUE';
|
property.name = 'FAS:PLAGUE';
|
||||||
property.title = 'The Faro Plague';
|
property.title = 'The Faro Plague';
|
||||||
@@ -149,7 +149,7 @@ describe('PropertyGroupTranslatorService', () => {
|
|||||||
propertyGroups.push(Object.assign({}, propertyGroup));
|
propertyGroups.push(Object.assign({}, propertyGroup));
|
||||||
|
|
||||||
service.translateToCardViewGroups(propertyGroups, propertyValues, null);
|
service.translateToCardViewGroups(propertyGroups, propertyValues, null);
|
||||||
expect(showError).toHaveBeenCalledWith('Unknown type for mapping: daemonic:scorcher');
|
expect(logServiceError).toHaveBeenCalledWith('Unknown type for mapping: daemonic:scorcher');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fall back to single-line property type if unrecognised type is found', () => {
|
it('should fall back to single-line property type if unrecognised type is found', () => {
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable, inject } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
CardViewItemProperties,
|
CardViewItemProperties,
|
||||||
CardViewItem,
|
CardViewItem,
|
||||||
@@ -29,7 +29,7 @@ import {
|
|||||||
MultiValuePipe,
|
MultiValuePipe,
|
||||||
AppConfigService,
|
AppConfigService,
|
||||||
DecimalNumberPipe,
|
DecimalNumberPipe,
|
||||||
NotificationService
|
LogService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { Property, CardViewGroup, OrganisedPropertyGroup } from '../interfaces/content-metadata.interfaces';
|
import { Property, CardViewGroup, OrganisedPropertyGroup } from '../interfaces/content-metadata.interfaces';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
@@ -51,12 +51,12 @@ export const RECOGNISED_ECM_TYPES = [D_TEXT, D_MLTEXT, D_DATE, D_DATETIME, D_INT
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class PropertyGroupTranslatorService {
|
export class PropertyGroupTranslatorService {
|
||||||
private notificationService = inject(NotificationService);
|
|
||||||
valueSeparator: string;
|
valueSeparator: string;
|
||||||
|
|
||||||
constructor(private multiValuePipe: MultiValuePipe,
|
constructor(private multiValuePipe: MultiValuePipe,
|
||||||
private decimalNumberPipe: DecimalNumberPipe,
|
private decimalNumberPipe: DecimalNumberPipe,
|
||||||
private appConfig: AppConfigService) {
|
private appConfig: AppConfigService,
|
||||||
|
private logService: LogService) {
|
||||||
this.valueSeparator = this.appConfig.get<string>('content-metadata.multi-value-pipe-separator');
|
this.valueSeparator = this.appConfig.get<string>('content-metadata.multi-value-pipe-separator');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ export class PropertyGroupTranslatorService {
|
|||||||
|
|
||||||
private checkECMTypeValidity(ecmPropertyType: string) {
|
private checkECMTypeValidity(ecmPropertyType: string) {
|
||||||
if (RECOGNISED_ECM_TYPES.indexOf(ecmPropertyType) === -1) {
|
if (RECOGNISED_ECM_TYPES.indexOf(ecmPropertyType) === -1) {
|
||||||
this.notificationService.showError(`Unknown type for mapping: ${ecmPropertyType}`);
|
this.logService.error(`Unknown type for mapping: ${ecmPropertyType}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user