mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
[ACA-2194] better custom aspects in metadata tab (#985)
* better custom aspects in metadata tab * update test
This commit is contained in:
parent
830357e892
commit
ab860cf7b2
@ -35,9 +35,9 @@ import { of } from 'rxjs';
|
||||
describe('InfoDrawerComponent', () => {
|
||||
let fixture: ComponentFixture<InfoDrawerComponent>;
|
||||
let component: InfoDrawerComponent;
|
||||
let contentApiService;
|
||||
let contentApiService: ContentApiService;
|
||||
let tab;
|
||||
let appExtensionService;
|
||||
let appExtensionService: AppExtensionService;
|
||||
const storeMock = {
|
||||
dispatch: jasmine.createSpy('dispatch')
|
||||
};
|
||||
@ -66,6 +66,10 @@ describe('InfoDrawerComponent', () => {
|
||||
spyOn(appExtensionService, 'getSidebarTabs').and.returnValue([tab]);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should get tabs configuration on initialization', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
@ -83,7 +87,7 @@ describe('InfoDrawerComponent', () => {
|
||||
|
||||
it('should set displayNode when node is from personal list', () => {
|
||||
spyOn(contentApiService, 'getNodeInfo');
|
||||
const nodeMock = <any>{ entry: { id: 'nodeId' } };
|
||||
const nodeMock = <any>{ entry: { id: 'nodeId', aspectNames: [] } };
|
||||
component.node = nodeMock;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
@ -33,7 +33,6 @@ import { ContentApiService } from '../../services/content-api.service';
|
||||
import { AppExtensionService } from '../../extensions/extension.service';
|
||||
import { SidebarTabRef } from '@alfresco/adf-extensions';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../store/states/app.state';
|
||||
import { SetInfoDrawerStateAction } from '../../store/actions';
|
||||
|
||||
@Component({
|
||||
@ -51,7 +50,7 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
tabs: Array<SidebarTabRef> = [];
|
||||
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private store: Store<any>,
|
||||
private contentApi: ContentApiService,
|
||||
private extensions: AppExtensionService
|
||||
) {}
|
||||
@ -66,39 +65,21 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
ngOnChanges() {
|
||||
if (this.node) {
|
||||
const entry: any = this.node.entry;
|
||||
|
||||
if (this.isLibraryListNode(this.node)) {
|
||||
if (this.node['isLibrary']) {
|
||||
return this.setDisplayNode(this.node);
|
||||
}
|
||||
|
||||
if (this.isSharedFilesNode(this.node)) {
|
||||
return this.loadNodeInfo(entry.nodeId);
|
||||
}
|
||||
const entry: any = this.node.entry;
|
||||
|
||||
if (this.isFavoriteListNode(this.node)) {
|
||||
return this.loadNodeInfo(entry.id);
|
||||
}
|
||||
|
||||
if (this.isRecentListFileNode(this.node)) {
|
||||
return this.loadNodeInfo(entry.id);
|
||||
if (!entry.aspectNames) {
|
||||
const id = entry.nodeId || entry.id;
|
||||
return this.loadNodeInfo(id);
|
||||
}
|
||||
|
||||
this.setDisplayNode(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private hasAspectNames(entry: MinimalNodeEntryEntity): boolean {
|
||||
return entry.aspectNames && entry.aspectNames.includes('exif:exif');
|
||||
}
|
||||
|
||||
private isTypeImage(entry: MinimalNodeEntryEntity): boolean {
|
||||
if (entry && entry.content && entry.content.mimeType) {
|
||||
return entry.content.mimeType.includes('image/');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private loadNodeInfo(nodeId: string) {
|
||||
if (nodeId) {
|
||||
this.isLoading = true;
|
||||
@ -116,20 +97,4 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
private setDisplayNode(node: any) {
|
||||
this.displayNode = node;
|
||||
}
|
||||
|
||||
private isLibraryListNode(node: any): boolean {
|
||||
return node.isLibrary;
|
||||
}
|
||||
|
||||
private isFavoriteListNode(node: MinimalNodeEntity): boolean {
|
||||
return !this.isLibraryListNode(node) && (<any>node).entry.guid;
|
||||
}
|
||||
|
||||
private isSharedFilesNode(node: any): boolean {
|
||||
return !!node.entry.nodeId;
|
||||
}
|
||||
|
||||
private isRecentListFileNode(node: MinimalNodeEntity): boolean {
|
||||
return this.isTypeImage(node.entry) && !this.hasAspectNames(node.entry);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user