[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:
Mario Romano 2018-10-23 14:35:44 +01:00 committed by Eugenio Romano
parent 2baf20b370
commit 53d96679ea
7 changed files with 46 additions and 17 deletions

View File

@ -409,7 +409,8 @@
<adf-info-drawer [title]="'Details'" *ngIf="documentList.selection[0]" > <adf-info-drawer [title]="'Details'" *ngIf="documentList.selection[0]" >
<adf-info-drawer-tab [label]="'Properties'"> <adf-info-drawer-tab [label]="'Properties'">
<adf-content-metadata-card <adf-content-metadata-card
[node]="documentList.selection[0].entry"> [node]="documentList.selection[0].entry"
[displayEmpty]="displayEmptyMetadata">
</adf-content-metadata-card> </adf-content-metadata-card>
</adf-info-drawer-tab> </adf-info-drawer-tab>
<adf-info-drawer-tab [label]="'Versions'"> <adf-info-drawer-tab [label]="'Versions'">
@ -556,6 +557,14 @@
</mat-slide-toggle> </mat-slide-toggle>
</section> </section>
<section>
<mat-slide-toggle
color="primary" [(ngModel)]="displayEmptyMetadata" id="displayEmptyMetadata">
Display Empty Metadata
</mat-slide-toggle>
</section>
<h5>Upload</h5> <h5>Upload</h5>
<section *ngIf="acceptedFilesTypeShow"> <section *ngIf="acceptedFilesTypeShow">
<mat-form-field floatPlaceholder="float"> <mat-form-field floatPlaceholder="float">

View File

@ -186,6 +186,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
thumbnails = false; thumbnails = false;
enableCustomPermissionMessage = false; enableCustomPermissionMessage = false;
enableMediumTimeFormat = false; enableMediumTimeFormat = false;
displayEmptyMetadata = false;
private onCreateFolder: Subscription; private onCreateFolder: Subscription;
private onEditFolder: Subscription; private onEditFolder: Subscription;
@ -415,7 +416,10 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
if (this.contentService.hasPermission(contentEntry, 'update')) { if (this.contentService.hasPermission(contentEntry, 'update')) {
this.dialog.open(MetadataDialogAdapterComponent, { this.dialog.open(MetadataDialogAdapterComponent, {
data: { contentEntry }, data: {
contentEntry: contentEntry,
displayEmptyMetadata: this.displayEmptyMetadata
},
panelClass: 'adf-metadata-manager-dialog', panelClass: 'adf-metadata-manager-dialog',
width: '630px' width: '630px'
}); });
@ -439,8 +443,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
hasOneFileSelected(): boolean { hasOneFileSelected(): boolean {
const selection: Array<MinimalNodeEntity> = this.documentList.selection; const selection: Array<MinimalNodeEntity> = this.documentList.selection;
const hasOneFileSelected = selection && selection.length === 1 && selection[0].entry.isFile; return selection && selection.length === 1 && selection[0].entry.isFile;
return hasOneFileSelected;
} }
userHasPermissionToManageVersions(): boolean { userHasPermissionToManageVersions(): boolean {
@ -528,11 +531,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
this.documentList.reload(); this.documentList.reload();
} }
canDownloadNode = (node: MinimalNodeEntity): boolean => { canDownloadNode(node: MinimalNodeEntity): boolean {
if (node && node.entry && node.entry.name === 'custom') { return node && node.entry && node.entry.name === 'custom';
return true;
}
return false;
} }
onBeginUpload(event: UploadFilesEvent) { onBeginUpload(event: UploadFilesEvent) {
@ -558,7 +559,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
} }
} }
isCustomActionDisabled = (node: MinimalNodeEntity): boolean => { isCustomActionDisabled(node: MinimalNodeEntity): boolean {
if (node && node.entry && node.entry.name === 'custom') { if (node && node.entry && node.entry.name === 'custom') {
return false; return false;
} }

View File

@ -1,6 +1,7 @@
<header mat-dialog-title>{{'METADATA.DIALOG.TITLE' | translate}}</header> <header mat-dialog-title>{{'METADATA.DIALOG.TITLE' | translate}}</header>
<section mat-dialog-content> <section mat-dialog-content>
<adf-content-metadata-card [node]="contentEntry"></adf-content-metadata-card> <adf-content-metadata-card [node]="contentEntry"
[displayEmpty]="displayEmptyMetadata"></adf-content-metadata-card>
</section> </section>
<footer mat-dialog-actions fxLayout="row" fxLayoutAlign="end center"> <footer mat-dialog-actions fxLayout="row" fxLayoutAlign="end center">
<button mat-button (click)="close()">{{'METADATA.DIALOG.CLOSE' | translate}}</button> <button mat-button (click)="close()">{{'METADATA.DIALOG.CLOSE' | translate}}</button>

View File

@ -27,9 +27,12 @@ export class MetadataDialogAdapterComponent {
public contentEntry: MinimalNodeEntryEntity; public contentEntry: MinimalNodeEntryEntity;
displayEmptyMetadata = false;
constructor(@Inject(MAT_DIALOG_DATA) data: any, constructor(@Inject(MAT_DIALOG_DATA) data: any,
private containingDialog?: MatDialogRef<MetadataDialogAdapterComponent>) { private containingDialog?: MatDialogRef<MetadataDialogAdapterComponent>) {
this.contentEntry = data.contentEntry; this.contentEntry = data.contentEntry;
this.displayEmptyMetadata = data.displayEmptyMetadata;
} }
close() { close() {

View File

@ -19,5 +19,6 @@ import { Property } from './property.interface';
export interface OrganisedPropertyGroup { export interface OrganisedPropertyGroup {
title: string; title: string;
name?: string;
properties: Property[]; properties: Property[];
} }

View File

@ -21,7 +21,7 @@ import { BasicPropertiesService } from './basic-properties.service';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { PropertyGroupTranslatorService } from './property-groups-translator.service'; import { PropertyGroupTranslatorService } from './property-groups-translator.service';
import { CardViewItem } from '@alfresco/adf-core'; 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 { ContentMetadataConfigFactory } from './config/content-metadata-config.factory';
import { PropertyDescriptorsService } from './property-descriptors.service'; import { PropertyDescriptorsService } from './property-descriptors.service';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
@ -53,6 +53,7 @@ export class ContentMetadataService {
if (groupNames.length > 0) { if (groupNames.length > 0) {
groupedProperties = this.propertyDescriptorsService.load(groupNames).pipe( groupedProperties = this.propertyDescriptorsService.load(groupNames).pipe(
map(groups => config.reorganiseByConfig(groups)), map(groups => config.reorganiseByConfig(groups)),
map(groups => this.setTitleToNameIfNotSet(groups)),
map(groups => this.propertyGroupTranslatorService.translateToCardViewGroups(groups, node.properties)) map(groups => this.propertyGroupTranslatorService.translateToCardViewGroups(groups, node.properties))
); );
} }
@ -60,4 +61,11 @@ export class ContentMetadataService {
return groupedProperties; return groupedProperties;
} }
setTitleToNameIfNotSet(propertyGroups: OrganisedPropertyGroup[]): OrganisedPropertyGroup[] {
propertyGroups.map(propertyGroup => {
propertyGroup.title = propertyGroup.title || propertyGroup.name;
});
return propertyGroups;
}
} }

View File

@ -44,9 +44,10 @@ const D_BOOLEAN = 'd:boolean';
}) })
export class PropertyGroupTranslatorService { 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[] { public translateToCardViewGroups(propertyGroups: OrganisedPropertyGroup[], propertyValues): CardViewGroup[] {
return propertyGroups.map(propertyGroup => { return propertyGroups.map(propertyGroup => {
@ -58,17 +59,22 @@ export class PropertyGroupTranslatorService {
private translateArray(properties: Property[], propertyValues: any): CardViewItem[] { private translateArray(properties: Property[], propertyValues: any): CardViewItem[] {
return properties.map(property => { 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); this.checkECMTypeValidity(property.dataType);
const prefix = 'properties.'; const prefix = 'properties.';
let propertyDefinition: CardViewItemProperties = { let propertyDefinition: CardViewItemProperties = {
label: property.title, label: property.title || property.name,
value: propertyValue, value: propertyValue,
key: `${prefix}${property.name}`, key: `${prefix}${property.name}`,
default: property.defaultValue, default: property.defaultValue,