[ADF-2311] fix metadata components with folders (#2985)

* fix metadata folders

* remove dead code

* fix check mimetype
This commit is contained in:
Eugenio Romano
2018-02-23 10:41:03 +00:00
committed by GitHub
parent ad3dbd4d0b
commit 7f63b76d37
9 changed files with 142 additions and 26 deletions

View File

@@ -9,6 +9,12 @@
"TITLE": "Manage Versions" "TITLE": "Manage Versions"
} }
}, },
"METADATA": {
"DIALOG": {
"CLOSE": "Close",
"TITLE": "Metadata"
}
},
"APP_LAYOUT": { "APP_LAYOUT": {
"APP_NAME": "ADF Demo Application", "APP_NAME": "ADF Demo Application",
"HOME": "Home", "HOME": "Home",
@@ -74,6 +80,8 @@
"DELETE":"Delete" "DELETE":"Delete"
}, },
"ACTIONS": { "ACTIONS": {
"VERSIONS": "Manage versions",
"METADATA": "Info",
"DOWNLOAD": "Download", "DOWNLOAD": "Download",
"FOLDER": { "FOLDER": {
"COPY": "Copy", "COPY": "Copy",

View File

@@ -36,6 +36,7 @@ import { WebscriptComponent } from './components/webscript/webscript.component';
import { TagComponent } from './components/tag/tag.component'; import { TagComponent } from './components/tag/tag.component';
import { SocialComponent } from './components/social/social.component'; import { SocialComponent } from './components/social/social.component';
import { VersionManagerDialogAdapterComponent } from './components/files/version-manager-dialog-adapter.component'; import { VersionManagerDialogAdapterComponent } from './components/files/version-manager-dialog-adapter.component';
import { MetadataDialogAdapterComponent } from './components/files/metadata-dialog-adapter.component';
import { ThemePickerModule } from './components/theme-picker/theme-picker'; import { ThemePickerModule } from './components/theme-picker/theme-picker';
import { DebugAppConfigService } from './services/debug-app-config.service'; import { DebugAppConfigService } from './services/debug-app-config.service';
@@ -87,6 +88,7 @@ import { SharedLinkViewComponent } from './components/shared-link-view/shared-li
SocialComponent, SocialComponent,
CustomSourcesComponent, CustomSourcesComponent,
VersionManagerDialogAdapterComponent, VersionManagerDialogAdapterComponent,
MetadataDialogAdapterComponent,
TaskAttachmentsComponent, TaskAttachmentsComponent,
ProcessAttachmentsComponent, ProcessAttachmentsComponent,
OverlayViewerComponent, OverlayViewerComponent,
@@ -112,7 +114,8 @@ import { SharedLinkViewComponent } from './components/shared-link-view/shared-li
} }
], ],
entryComponents: [ entryComponents: [
VersionManagerDialogAdapterComponent VersionManagerDialogAdapterComponent,
MetadataDialogAdapterComponent
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })

View File

@@ -245,11 +245,16 @@
(success)="onDeleteActionSuccess($event)" (success)="onDeleteActionSuccess($event)"
handler="delete"> handler="delete">
</content-action> </content-action>
<content-action
icon="info"
title="{{'DOCUMENT_LIST.ACTIONS.METADATA' | translate}}"
(execute)="onManageMetadata($event)">
</content-action>
<!-- document actions --> <!-- document actions -->
<content-action <content-action
icon="storage" icon="storage"
target="document" target="document"
title="Manage versions..." title="{{'DOCUMENT_LIST.ACTIONS.VERSIONS' | translate}}"
(execute)="onManageVersions($event)"> (execute)="onManageVersions($event)">
</content-action> </content-action>
<content-action <content-action
@@ -281,6 +286,7 @@
</adf-upload-drag-area> </adf-upload-drag-area>
<adf-info-drawer-layout *ngIf="showVersions" class="adf-manage-versions-sidebar" fxFlex="0 0 auto"> <adf-info-drawer-layout *ngIf="showVersions" class="adf-manage-versions-sidebar" fxFlex="0 0 auto">
<div info-drawer-content> <div info-drawer-content>
<ng-container *ngIf="hasOneFileSelected();else choose_document_template"> <ng-container *ngIf="hasOneFileSelected();else choose_document_template">
<ng-container *ngIf="userHasPermissionToManageVersions(); else no_permission_to_versions"> <ng-container *ngIf="userHasPermissionToManageVersions(); else no_permission_to_versions">

View File

@@ -34,6 +34,7 @@ import { DocumentListComponent, PermissionStyleModel } from '@alfresco/adf-conte
import { SelectAppsDialogComponent } from '@alfresco/adf-process-services'; import { SelectAppsDialogComponent } from '@alfresco/adf-process-services';
import { VersionManagerDialogAdapterComponent } from './version-manager-dialog-adapter.component'; import { VersionManagerDialogAdapterComponent } from './version-manager-dialog-adapter.component';
import { MetadataDialogAdapterComponent } from './metadata-dialog-adapter.component';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
const DEFAULT_FOLDER_TO_SHOW = '-my-'; const DEFAULT_FOLDER_TO_SHOW = '-my-';
@@ -342,6 +343,21 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
} }
} }
onManageMetadata(event) {
const contentEntry = event.value.entry;
if (this.contentService.hasPermission(contentEntry, 'update')) {
this.dialog.open(MetadataDialogAdapterComponent, {
data: { contentEntry },
panelClass: 'adf-metadata-manager-dialog',
width: '630px'
});
} else {
const translatedErrorMessage: any = this.translateService.get('OPERATION.ERROR.PERMISSION');
this.notificationService.openSnackMessage(translatedErrorMessage.value, 4000);
}
}
getSiteContent(site: SiteEntry) { getSiteContent(site: SiteEntry) {
this.currentFolderId = site && site.entry.guid ? site.entry.guid : DEFAULT_FOLDER_TO_SHOW; this.currentFolderId = site && site.entry.guid ? site.entry.guid : DEFAULT_FOLDER_TO_SHOW;
} }

View File

@@ -0,0 +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>
</section>
<footer mat-dialog-actions fxLayout="row" fxLayoutAlign="end center">
<button mat-button (click)="close()">{{'METADATA.DIALOG.CLOSE' | translate}}</button>
</footer>

View File

@@ -0,0 +1,38 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, Inject, ViewEncapsulation } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
@Component({
templateUrl: './metadata-dialog-adapter.component.html',
encapsulation: ViewEncapsulation.None
})
export class MetadataDialogAdapterComponent {
public contentEntry: MinimalNodeEntryEntity;
constructor(@Inject(MAT_DIALOG_DATA) data: any,
private containingDialog?: MatDialogRef<MetadataDialogAdapterComponent>) {
this.contentEntry = data.contentEntry;
}
close() {
this.containingDialog.close();
}
}

View File

@@ -28,7 +28,13 @@ import { BasicPropertiesService } from '../../services/basic-properties.service'
import { PropertyGroupTranslatorService } from '../../services/property-groups-translator.service'; import { PropertyGroupTranslatorService } from '../../services/property-groups-translator.service';
import { PropertyDescriptorsService } from '../../services/property-descriptors.service'; import { PropertyDescriptorsService } from '../../services/property-descriptors.service';
import { AlfrescoApiService } from '@alfresco/adf-core'; import { AlfrescoApiService } from '@alfresco/adf-core';
import { CardViewBaseItemModel, CardViewComponent, CardViewUpdateService, NodesApiService, LogService } from '@alfresco/adf-core'; import {
CardViewBaseItemModel,
CardViewComponent,
CardViewUpdateService,
NodesApiService,
LogService
} from '@alfresco/adf-core';
import { ErrorObservable } from 'rxjs/observable/ErrorObservable'; import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { ContentMetadataConfigFactory } from '../../services/config/content-metadata-config.factory'; import { ContentMetadataConfigFactory } from '../../services/config/content-metadata-config.factory';
@@ -38,6 +44,7 @@ describe('ContentMetadataComponent', () => {
let component: ContentMetadataComponent, let component: ContentMetadataComponent,
fixture: ComponentFixture<ContentMetadataComponent>, fixture: ComponentFixture<ContentMetadataComponent>,
node: MinimalNodeEntryEntity, node: MinimalNodeEntryEntity,
folderNode: MinimalNodeEntryEntity,
preset = 'custom-preset'; preset = 'custom-preset';
beforeEach(async(() => { beforeEach(async(() => {
@@ -76,6 +83,14 @@ describe('ContentMetadataComponent', () => {
modifiedByUser: {} modifiedByUser: {}
}; };
folderNode = <MinimalNodeEntryEntity> {
id: 'folder-id',
aspectNames: [],
nodeType: '',
createdByUser: {},
modifiedByUser: {}
};
component.node = node; component.node = node;
component.preset = preset; component.preset = preset;
fixture.detectChanges(); fixture.detectChanges();
@@ -101,6 +116,22 @@ describe('ContentMetadataComponent', () => {
}); });
}); });
describe('Folder', () => {
it('should show the folder node', () => {
component.expanded = false;
fixture.detectChanges();
component.ngOnChanges({ node: new SimpleChange(node, folderNode, false) });
component.basicProperties$.subscribe(() => {
fixture.detectChanges();
const basicPropertiesComponent = fixture.debugElement.query(By.directive(CardViewComponent)).componentInstance;
expect(basicPropertiesComponent.properties).toBeDefined();
});
});
});
describe('Saving', () => { describe('Saving', () => {
it('should save the node on itemUpdate', () => { it('should save the node on itemUpdate', () => {

View File

@@ -22,9 +22,17 @@ import { CardViewDateItemModel, CardViewTextItemModel, FileSizePipe } from '@alf
@Injectable() @Injectable()
export class BasicPropertiesService { export class BasicPropertiesService {
constructor(private fileSizePipe: FileSizePipe) {} constructor(private fileSizePipe: FileSizePipe) {
}
getProperties(node: MinimalNodeEntryEntity) { getProperties(node: MinimalNodeEntryEntity) {
const sizeInBytes = node.content ? node.content.sizeInBytes : '',
mimeTypeName = node.content ? node.content.mimeTypeName : '',
author = node.properties ? node.properties['cm:author'] : '',
description = node.properties ? node.properties['cm:description'] : '',
title = node.properties ? node.properties['cm:title'] : '';
return [ return [
new CardViewTextItemModel({ new CardViewTextItemModel({
label: 'CORE.METADATA.BASIC.NAME', label: 'CORE.METADATA.BASIC.NAME',
@@ -34,7 +42,7 @@ export class BasicPropertiesService {
}), }),
new CardViewTextItemModel({ new CardViewTextItemModel({
label: 'CORE.METADATA.BASIC.TITLE', label: 'CORE.METADATA.BASIC.TITLE',
value: node.properties['cm:title'], value: title,
key: 'properties.cm:title', key: 'properties.cm:title',
editable: true editable: true
}), }),
@@ -52,7 +60,7 @@ export class BasicPropertiesService {
}), }),
new CardViewTextItemModel({ new CardViewTextItemModel({
label: 'CORE.METADATA.BASIC.SIZE', label: 'CORE.METADATA.BASIC.SIZE',
value: node.content.sizeInBytes, value: sizeInBytes,
key: 'content.sizeInBytes', key: 'content.sizeInBytes',
pipes: [{ pipe: this.fileSizePipe }], pipes: [{ pipe: this.fileSizePipe }],
editable: false editable: false
@@ -71,19 +79,19 @@ export class BasicPropertiesService {
}), }),
new CardViewTextItemModel({ new CardViewTextItemModel({
label: 'CORE.METADATA.BASIC.MIMETYPE', label: 'CORE.METADATA.BASIC.MIMETYPE',
value: node.content.mimeTypeName, value: mimeTypeName,
key: 'content.mimeTypeName', key: 'content.mimeTypeName',
editable: false editable: false
}), }),
new CardViewTextItemModel({ new CardViewTextItemModel({
label: 'CORE.METADATA.BASIC.AUTHOR', label: 'CORE.METADATA.BASIC.AUTHOR',
value: node.properties['cm:author'], value: author,
key: 'properties.cm:author', key: 'properties.cm:author',
editable: true editable: true
}), }),
new CardViewTextItemModel({ new CardViewTextItemModel({
label: 'CORE.METADATA.BASIC.DESCRIPTION', label: 'CORE.METADATA.BASIC.DESCRIPTION',
value: node.properties['cm:description'], value: description,
key: 'properties.cm:description', key: 'properties.cm:description',
multiline: true, multiline: true,
editable: true editable: true

View File

@@ -28,31 +28,30 @@ import { PropertyDescriptorsService } from './property-descriptors.service';
@Injectable() @Injectable()
export class ContentMetadataService { export class ContentMetadataService {
constructor( constructor(private basicPropertiesService: BasicPropertiesService,
private basicPropertiesService: BasicPropertiesService, private contentMetadataConfigFactory: ContentMetadataConfigFactory,
private contentMetadataConfigFactory: ContentMetadataConfigFactory, private propertyGroupTranslatorService: PropertyGroupTranslatorService,
private propertyGroupTranslatorService: PropertyGroupTranslatorService, private propertyDescriptorsService: PropertyDescriptorsService) {
private propertyDescriptorsService: PropertyDescriptorsService }
) {}
getBasicProperties(node: MinimalNodeEntryEntity): Observable<CardViewItem[]> { getBasicProperties(node: MinimalNodeEntryEntity): Observable<CardViewItem[]> {
return Observable.of(this.basicPropertiesService.getProperties(node)); return Observable.of(this.basicPropertiesService.getProperties(node));
} }
getGroupedProperties(node: MinimalNodeEntryEntity, presetName: string = 'default'): Observable<CardViewGroup[]> { getGroupedProperties(node: MinimalNodeEntryEntity, presetName: string = 'default'): Observable<CardViewGroup[]> {
const config = this.contentMetadataConfigFactory.get(presetName), let groupedProperties = Observable.of([]);
groupNames = node.aspectNames
.concat(node.nodeType)
.filter(groupName => config.isGroupAllowed(groupName));
let groupedProperties; if (node.aspectNames) {
const config = this.contentMetadataConfigFactory.get(presetName),
groupNames = node.aspectNames
.concat(node.nodeType)
.filter(groupName => config.isGroupAllowed(groupName));
if (groupNames.length > 0) { if (groupNames.length > 0) {
groupedProperties = this.propertyDescriptorsService.load(groupNames) groupedProperties = this.propertyDescriptorsService.load(groupNames)
.map(groups => config.reorganiseByConfig(groups)) .map(groups => config.reorganiseByConfig(groups))
.map(groups => this.propertyGroupTranslatorService.translateToCardViewGroups(groups, node.properties)); .map(groups => this.propertyGroupTranslatorService.translateToCardViewGroups(groups, node.properties));
} else { }
groupedProperties = Observable.of([]);
} }
return groupedProperties; return groupedProperties;