mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2186] Update calculated properties on node change in content metadata compo… (#2862)
* Update calculated properties on node change in content metadata component * Add module to public api
This commit is contained in:
committed by
Eugenio Romano
parent
b481bde483
commit
eb6db1d449
@@ -237,5 +237,22 @@ describe('ContentMetadataComponent', () => {
|
||||
expect(basicPropertiesComponent.displayEmpty).toBe(false);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should be performed again if property updating occured, since the originally passed node has changed, so the previously calculated properties', () => {
|
||||
const property = <CardViewBaseItemModel> { key: 'property-key', value: 'original-value' },
|
||||
updateService = fixture.debugElement.injector.get(CardViewUpdateService),
|
||||
nodesApiService = TestBed.get(NodesApiService);
|
||||
|
||||
spyOn(nodesApiService, 'updateNode').and.callFake(() => Observable.of(node));
|
||||
spyOn(contentMetadataService, 'getBasicProperties');
|
||||
component.ngOnChanges({ node: new SimpleChange(null, node, true) });
|
||||
updateService.update(property, 'updated-value');
|
||||
|
||||
component.ngOnChanges({ expanded: new SimpleChange(false, true, false) });
|
||||
component.ngOnChanges({ expanded: new SimpleChange(true, false, false) });
|
||||
component.ngOnChanges({ expanded: new SimpleChange(false, true, false) });
|
||||
|
||||
expect(contentMetadataService.getBasicProperties).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -47,6 +47,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit {
|
||||
@Input()
|
||||
preset: string;
|
||||
|
||||
nodeHasBeenUpdated: boolean = false;
|
||||
basicProperties$: Observable<CardViewItem[]>;
|
||||
aspects$: Observable<CardViewAspect[]>;
|
||||
|
||||
@@ -59,15 +60,20 @@ export class ContentMetadataComponent implements OnChanges, OnInit {
|
||||
this.cardViewUpdateService.itemUpdated$
|
||||
.switchMap(this.saveNode.bind(this))
|
||||
.subscribe(
|
||||
node => this.node = node,
|
||||
(node) => {
|
||||
this.nodeHasBeenUpdated = true;
|
||||
this.node = node;
|
||||
},
|
||||
error => this.logService.error(error)
|
||||
);
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
const nodeChange: SimpleChange = changes['node'];
|
||||
if (nodeChange) {
|
||||
const node = nodeChange.currentValue;
|
||||
if (nodeChange || this.nodeHasBeenUpdated) {
|
||||
const node = nodeChange && nodeChange.currentValue || this.node;
|
||||
this.nodeHasBeenUpdated = false;
|
||||
|
||||
this.basicProperties$ = this.contentMetadataService.getBasicProperties(node);
|
||||
this.aspects$ = this.contentMetadataService.getAspectProperties(node, this.preset);
|
||||
}
|
||||
|
@@ -16,3 +16,4 @@
|
||||
*/
|
||||
|
||||
export * from './components/content-metadata-card/content-metadata-card.component';
|
||||
export { ContentMetadataModule } from './content-metadata.module';
|
||||
|
Reference in New Issue
Block a user