mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +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:
parent
2baf20b370
commit
53d96679ea
@ -409,7 +409,8 @@
|
||||
<adf-info-drawer [title]="'Details'" *ngIf="documentList.selection[0]" >
|
||||
<adf-info-drawer-tab [label]="'Properties'">
|
||||
<adf-content-metadata-card
|
||||
[node]="documentList.selection[0].entry">
|
||||
[node]="documentList.selection[0].entry"
|
||||
[displayEmpty]="displayEmptyMetadata">
|
||||
</adf-content-metadata-card>
|
||||
</adf-info-drawer-tab>
|
||||
<adf-info-drawer-tab [label]="'Versions'">
|
||||
@ -556,6 +557,14 @@
|
||||
</mat-slide-toggle>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<mat-slide-toggle
|
||||
color="primary" [(ngModel)]="displayEmptyMetadata" id="displayEmptyMetadata">
|
||||
Display Empty Metadata
|
||||
</mat-slide-toggle>
|
||||
</section>
|
||||
|
||||
|
||||
<h5>Upload</h5>
|
||||
<section *ngIf="acceptedFilesTypeShow">
|
||||
<mat-form-field floatPlaceholder="float">
|
||||
|
@ -186,6 +186,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
||||
thumbnails = false;
|
||||
enableCustomPermissionMessage = false;
|
||||
enableMediumTimeFormat = false;
|
||||
displayEmptyMetadata = false;
|
||||
|
||||
private onCreateFolder: Subscription;
|
||||
private onEditFolder: Subscription;
|
||||
@ -415,7 +416,10 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
if (this.contentService.hasPermission(contentEntry, 'update')) {
|
||||
this.dialog.open(MetadataDialogAdapterComponent, {
|
||||
data: { contentEntry },
|
||||
data: {
|
||||
contentEntry: contentEntry,
|
||||
displayEmptyMetadata: this.displayEmptyMetadata
|
||||
},
|
||||
panelClass: 'adf-metadata-manager-dialog',
|
||||
width: '630px'
|
||||
});
|
||||
@ -439,8 +443,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
hasOneFileSelected(): boolean {
|
||||
const selection: Array<MinimalNodeEntity> = this.documentList.selection;
|
||||
const hasOneFileSelected = selection && selection.length === 1 && selection[0].entry.isFile;
|
||||
return hasOneFileSelected;
|
||||
return selection && selection.length === 1 && selection[0].entry.isFile;
|
||||
}
|
||||
|
||||
userHasPermissionToManageVersions(): boolean {
|
||||
@ -528,11 +531,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.documentList.reload();
|
||||
}
|
||||
|
||||
canDownloadNode = (node: MinimalNodeEntity): boolean => {
|
||||
if (node && node.entry && node.entry.name === 'custom') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
canDownloadNode(node: MinimalNodeEntity): boolean {
|
||||
return node && node.entry && node.entry.name === 'custom';
|
||||
|
||||
}
|
||||
|
||||
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') {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<header mat-dialog-title>{{'METADATA.DIALOG.TITLE' | translate}}</header>
|
||||
<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>
|
||||
<footer mat-dialog-actions fxLayout="row" fxLayoutAlign="end center">
|
||||
<button mat-button (click)="close()">{{'METADATA.DIALOG.CLOSE' | translate}}</button>
|
||||
|
@ -27,9 +27,12 @@ export class MetadataDialogAdapterComponent {
|
||||
|
||||
public contentEntry: MinimalNodeEntryEntity;
|
||||
|
||||
displayEmptyMetadata = false;
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) data: any,
|
||||
private containingDialog?: MatDialogRef<MetadataDialogAdapterComponent>) {
|
||||
this.contentEntry = data.contentEntry;
|
||||
this.displayEmptyMetadata = data.displayEmptyMetadata;
|
||||
}
|
||||
|
||||
close() {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ 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];
|
||||
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user