mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3609 ] fallback for metadata and undefined value check (#3838)
* [ADF-3609 ] fallback for metadata and undefined value check * fix lint issues * make name new property optional
This commit is contained in:
committed by
Eugenio Romano
parent
2baf20b370
commit
53d96679ea
@@ -19,5 +19,6 @@ import { Property } from './property.interface';
|
||||
|
||||
export interface OrganisedPropertyGroup {
|
||||
title: string;
|
||||
name?: string;
|
||||
properties: Property[];
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ import { BasicPropertiesService } from './basic-properties.service';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { PropertyGroupTranslatorService } from './property-groups-translator.service';
|
||||
import { CardViewItem } from '@alfresco/adf-core';
|
||||
import { CardViewGroup } from '../interfaces/content-metadata.interfaces';
|
||||
import { CardViewGroup, OrganisedPropertyGroup } from '../interfaces/content-metadata.interfaces';
|
||||
import { ContentMetadataConfigFactory } from './config/content-metadata-config.factory';
|
||||
import { PropertyDescriptorsService } from './property-descriptors.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
@@ -53,6 +53,7 @@ export class ContentMetadataService {
|
||||
if (groupNames.length > 0) {
|
||||
groupedProperties = this.propertyDescriptorsService.load(groupNames).pipe(
|
||||
map(groups => config.reorganiseByConfig(groups)),
|
||||
map(groups => this.setTitleToNameIfNotSet(groups)),
|
||||
map(groups => this.propertyGroupTranslatorService.translateToCardViewGroups(groups, node.properties))
|
||||
);
|
||||
}
|
||||
@@ -60,4 +61,11 @@ export class ContentMetadataService {
|
||||
|
||||
return groupedProperties;
|
||||
}
|
||||
|
||||
setTitleToNameIfNotSet(propertyGroups: OrganisedPropertyGroup[]): OrganisedPropertyGroup[] {
|
||||
propertyGroups.map(propertyGroup => {
|
||||
propertyGroup.title = propertyGroup.title || propertyGroup.name;
|
||||
});
|
||||
return propertyGroups;
|
||||
}
|
||||
}
|
||||
|
@@ -44,9 +44,10 @@ const D_BOOLEAN = 'd:boolean';
|
||||
})
|
||||
export class PropertyGroupTranslatorService {
|
||||
|
||||
static readonly RECOGNISED_ECM_TYPES = [ D_TEXT, D_MLTEXT, D_DATE, D_DATETIME, D_INT, D_LONG , D_FLOAT, D_DOUBLE, D_BOOLEAN ];
|
||||
static readonly RECOGNISED_ECM_TYPES = [D_TEXT, D_MLTEXT, D_DATE, D_DATETIME, D_INT, D_LONG, D_FLOAT, D_DOUBLE, D_BOOLEAN];
|
||||
|
||||
constructor(private logService: LogService) {}
|
||||
constructor(private logService: LogService) {
|
||||
}
|
||||
|
||||
public translateToCardViewGroups(propertyGroups: OrganisedPropertyGroup[], propertyValues): CardViewGroup[] {
|
||||
return propertyGroups.map(propertyGroup => {
|
||||
@@ -58,17 +59,22 @@ export class PropertyGroupTranslatorService {
|
||||
|
||||
private translateArray(properties: Property[], propertyValues: any): CardViewItem[] {
|
||||
return properties.map(property => {
|
||||
return this.translate(property, propertyValues[property.name]);
|
||||
return this.translate(property, propertyValues);
|
||||
});
|
||||
}
|
||||
|
||||
private translate(property: Property, propertyValue: any): CardViewItem {
|
||||
private translate(property: Property, propertyValues: any): CardViewItem {
|
||||
let propertyValue;
|
||||
if (propertyValues && propertyValues[property.name]) {
|
||||
propertyValue = propertyValues[property.name];
|
||||
}
|
||||
|
||||
this.checkECMTypeValidity(property.dataType);
|
||||
|
||||
const prefix = 'properties.';
|
||||
|
||||
let propertyDefinition: CardViewItemProperties = {
|
||||
label: property.title,
|
||||
label: property.title || property.name,
|
||||
value: propertyValue,
|
||||
key: `${prefix}${property.name}`,
|
||||
default: property.defaultValue,
|
||||
|
Reference in New Issue
Block a user