mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-2232] Content metadata layout oriented configuration (#2918)
* Small refactoring I. * Small refactoring II. * On the way of implementing the soultion * Refactoring aspect to groups and supporting different type of configs * Fixed linter errors * Fix debug project runner * Fix linting errors * Fix and align tests * Config factory tests * Layout oriented config parser * Adding layout oriented config to the config factory * Update config schema * Layout oriented config * Aspect oriented and indifferent configs alignment to the new propertyGroups structure * Remove dead codes * Fixinfinite loading error and custom type properties * Add documentation * Fix tests
This commit is contained in:
committed by
Eugenio Romano
parent
a863631f0d
commit
c109b9f6f3
@@ -25,10 +25,10 @@ import { ContentMetadataComponent } from '../content-metadata/content-metadata.c
|
||||
import { MatExpansionModule, MatCardModule, MatButtonModule, MatIconModule } from '@angular/material';
|
||||
import { ContentMetadataService } from '../../services/content-metadata.service';
|
||||
import { BasicPropertiesService } from '../../services/basic-properties.service';
|
||||
import { PropertyDescriptorLoaderService } from '../../services/properties-loader.service';
|
||||
import { PropertyGroupTranslatorService } from '../../services/property-groups-translator.service';
|
||||
import { PropertyDescriptorsService } from '../../services/property-descriptors.service';
|
||||
import { AspectWhiteListService } from '../../services/aspect-whitelist.service';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { ContentMetadataConfigFactory } from '../../services/config/content-metadata-config.factory';
|
||||
|
||||
describe('ContentMetadataCardComponent', () => {
|
||||
|
||||
@@ -52,9 +52,9 @@ describe('ContentMetadataCardComponent', () => {
|
||||
providers: [
|
||||
ContentMetadataService,
|
||||
BasicPropertiesService,
|
||||
PropertyDescriptorLoaderService,
|
||||
PropertyGroupTranslatorService,
|
||||
ContentMetadataConfigFactory,
|
||||
PropertyDescriptorsService,
|
||||
AspectWhiteListService,
|
||||
AlfrescoApiService
|
||||
]
|
||||
}).compileComponents();
|
||||
@@ -65,6 +65,7 @@ describe('ContentMetadataCardComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
node = <MinimalNodeEntryEntity> {
|
||||
aspectNames: [],
|
||||
nodeType: '',
|
||||
content: {},
|
||||
properties: {},
|
||||
createdByUser: {},
|
||||
|
@@ -8,8 +8,6 @@
|
||||
</mat-expansion-panel-header>
|
||||
|
||||
<adf-card-view
|
||||
class="adf-metadata-properties-basic"
|
||||
data-automation-id="adf-metadata-properties-basic"
|
||||
[properties]="basicProperties$ | async"
|
||||
[editable]="editable"
|
||||
[displayEmpty]="displayEmpty">
|
||||
@@ -17,18 +15,17 @@
|
||||
</mat-expansion-panel>
|
||||
|
||||
<ng-container *ngIf="expanded">
|
||||
<ng-container *ngIf="aspects$ | async; else loading; let aspects">
|
||||
<div *ngFor="let aspect of aspects" class="adf-metadata-properties-aspect">
|
||||
<ng-container *ngIf="groupedProperties$ | async; else loading; let groupedProperties">
|
||||
<div *ngFor="let group of groupedProperties" class="adf-metadata-grouped-properties-container">
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
{{aspect.title}}
|
||||
{{group.title}}
|
||||
</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
|
||||
<adf-card-view
|
||||
class="adf-node-aspect-properties"
|
||||
[properties]="aspect.properties"
|
||||
[properties]="group.properties"
|
||||
[editable]="editable"
|
||||
[displayEmpty]="displayEmpty">
|
||||
</adf-card-view>
|
||||
|
@@ -25,13 +25,13 @@ import { ContentMetadataComponent } from './content-metadata.component';
|
||||
import { MatExpansionModule, MatButtonModule, MatIconModule } from '@angular/material';
|
||||
import { ContentMetadataService } from '../../services/content-metadata.service';
|
||||
import { BasicPropertiesService } from '../../services/basic-properties.service';
|
||||
import { PropertyDescriptorLoaderService } from '../../services/properties-loader.service';
|
||||
import { PropertyGroupTranslatorService } from '../../services/property-groups-translator.service';
|
||||
import { PropertyDescriptorsService } from '../../services/property-descriptors.service';
|
||||
import { AspectWhiteListService } from '../../services/aspect-whitelist.service';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { CardViewBaseItemModel, CardViewComponent, CardViewUpdateService, NodesApiService, LogService } from '@alfresco/adf-core';
|
||||
import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { ContentMetadataConfigFactory } from '../../services/config/content-metadata-config.factory';
|
||||
|
||||
describe('ContentMetadataComponent', () => {
|
||||
|
||||
@@ -53,9 +53,9 @@ describe('ContentMetadataComponent', () => {
|
||||
providers: [
|
||||
ContentMetadataService,
|
||||
BasicPropertiesService,
|
||||
PropertyDescriptorLoaderService,
|
||||
PropertyGroupTranslatorService,
|
||||
PropertyDescriptorsService,
|
||||
AspectWhiteListService,
|
||||
ContentMetadataConfigFactory,
|
||||
AlfrescoApiService,
|
||||
NodesApiService,
|
||||
{ provide: LogService, useValue: { error: jasmine.createSpy('error') } }
|
||||
@@ -69,6 +69,7 @@ describe('ContentMetadataComponent', () => {
|
||||
node = <MinimalNodeEntryEntity> {
|
||||
id: 'node-id',
|
||||
aspectNames: [],
|
||||
nodeType: '',
|
||||
content: {},
|
||||
properties: {},
|
||||
createdByUser: {},
|
||||
@@ -198,19 +199,19 @@ describe('ContentMetadataComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should load the aspect properties on node change', () => {
|
||||
spyOn(contentMetadataService, 'getAspectProperties');
|
||||
it('should load the group properties on node change', () => {
|
||||
spyOn(contentMetadataService, 'getGroupedProperties');
|
||||
|
||||
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
||||
|
||||
expect(contentMetadataService.getAspectProperties).toHaveBeenCalledWith(expectedNode, 'custom-preset');
|
||||
expect(contentMetadataService.getGroupedProperties).toHaveBeenCalledWith(expectedNode, 'custom-preset');
|
||||
});
|
||||
|
||||
it('should pass through the loaded aspect properties to the card view', async(() => {
|
||||
it('should pass through the loaded group properties to the card view', async(() => {
|
||||
const expectedProperties = [];
|
||||
component.expanded = true;
|
||||
fixture.detectChanges();
|
||||
spyOn(contentMetadataService, 'getAspectProperties').and.callFake(() => {
|
||||
spyOn(contentMetadataService, 'getGroupedProperties').and.callFake(() => {
|
||||
return Observable.of([{ properties: expectedProperties }]);
|
||||
});
|
||||
|
||||
@@ -218,22 +219,22 @@ describe('ContentMetadataComponent', () => {
|
||||
|
||||
component.basicProperties$.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
const firstAspectPropertiesComponent = fixture.debugElement.query(By.css('.adf-metadata-properties-aspect adf-card-view')).componentInstance;
|
||||
expect(firstAspectPropertiesComponent.properties).toBe(expectedProperties);
|
||||
const firstGroupedPropertiesComponent = fixture.debugElement.query(By.css('.adf-metadata-grouped-properties-container adf-card-view')).componentInstance;
|
||||
expect(firstGroupedPropertiesComponent.properties).toBe(expectedProperties);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should pass through the displayEmpty to the card view of aspect properties', async(() => {
|
||||
it('should pass through the displayEmpty to the card view of grouped properties', async(() => {
|
||||
component.expanded = true;
|
||||
component.displayEmpty = false;
|
||||
fixture.detectChanges();
|
||||
spyOn(contentMetadataService, 'getAspectProperties').and.returnValue(Observable.of([{ properties: [] }]));
|
||||
spyOn(contentMetadataService, 'getGroupedProperties').and.returnValue(Observable.of([{ properties: [] }]));
|
||||
|
||||
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
||||
|
||||
component.basicProperties$.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
const basicPropertiesComponent = fixture.debugElement.query(By.css('.adf-metadata-properties-aspect adf-card-view')).componentInstance;
|
||||
const basicPropertiesComponent = fixture.debugElement.query(By.css('.adf-metadata-grouped-properties-container adf-card-view')).componentInstance;
|
||||
expect(basicPropertiesComponent.displayEmpty).toBe(false);
|
||||
});
|
||||
}));
|
||||
|
@@ -20,7 +20,7 @@ import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { CardViewItem, CardViewUpdateService, NodesApiService, LogService } from '@alfresco/adf-core';
|
||||
import { ContentMetadataService } from '../../services/content-metadata.service';
|
||||
import { CardViewAspect } from '../../interfaces/content-metadata.interfaces';
|
||||
import { CardViewGroup } from '../../interfaces/content-metadata.interfaces';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-content-metadata',
|
||||
@@ -49,7 +49,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit {
|
||||
|
||||
nodeHasBeenUpdated: boolean = false;
|
||||
basicProperties$: Observable<CardViewItem[]>;
|
||||
aspects$: Observable<CardViewAspect[]>;
|
||||
groupedProperties$: Observable<CardViewGroup[]>;
|
||||
|
||||
constructor(private contentMetadataService: ContentMetadataService,
|
||||
private cardViewUpdateService: CardViewUpdateService,
|
||||
@@ -75,7 +75,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit {
|
||||
this.nodeHasBeenUpdated = false;
|
||||
|
||||
this.basicProperties$ = this.contentMetadataService.getBasicProperties(node);
|
||||
this.aspects$ = this.contentMetadataService.getAspectProperties(node, this.preset);
|
||||
this.groupedProperties$ = this.contentMetadataService.getGroupedProperties(node, this.preset);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user