mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5344] - fixed counter for custom aspects (#6727)
This commit is contained in:
@@ -68,6 +68,27 @@ const aspectListMock: AspectEntry[] = [{
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
const customAspectListMock: AspectEntry[] = [{
|
||||||
|
entry: {
|
||||||
|
parentId: 'cst:customAspect',
|
||||||
|
id: 'cst:customAspect',
|
||||||
|
description: 'Custom Aspect with random description',
|
||||||
|
title: 'CustomAspect',
|
||||||
|
properties: [
|
||||||
|
{
|
||||||
|
id: 'channelPassword',
|
||||||
|
title: 'The authenticated channel password',
|
||||||
|
dataType: 'd:propA'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'channelUsername',
|
||||||
|
title: 'The authenticated channel username',
|
||||||
|
dataType: 'd:propB'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
describe('AspectListDialogComponent', () => {
|
describe('AspectListDialogComponent', () => {
|
||||||
let fixture: ComponentFixture<AspectListDialogComponent>;
|
let fixture: ComponentFixture<AspectListDialogComponent>;
|
||||||
let aspectListService: AspectListService;
|
let aspectListService: AspectListService;
|
||||||
@@ -246,9 +267,10 @@ describe('AspectListDialogComponent', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
aspectListService = TestBed.inject(AspectListService);
|
aspectListService = TestBed.inject(AspectListService);
|
||||||
nodeService = TestBed.inject(NodesApiService);
|
nodeService = TestBed.inject(NodesApiService);
|
||||||
spyOn(aspectListService, 'getAspects').and.returnValue(of(aspectListMock));
|
spyOn(aspectListService, 'getAspects').and.returnValue(of([...aspectListMock, ...customAspectListMock]));
|
||||||
spyOn(aspectListService, 'getVisibleAspects').and.returnValue(['frs:AspectOne']);
|
spyOn(aspectListService, 'getVisibleAspects').and.returnValue(['frs:AspectOne']);
|
||||||
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node-id', aspectNames: ['frs:AspectOne'] }).pipe(delay(0)));
|
spyOn(aspectListService, 'getCustomAspects').and.returnValue(of(customAspectListMock));
|
||||||
|
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node-id', aspectNames: ['frs:AspectOne', 'cst:customAspect'] }).pipe(delay(0)));
|
||||||
fixture = TestBed.createComponent(AspectListDialogComponent);
|
fixture = TestBed.createComponent(AspectListDialogComponent);
|
||||||
fixture.componentInstance.data.select = new Subject<string[]>();
|
fixture.componentInstance.data.select = new Subject<string[]>();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -266,6 +288,16 @@ describe('AspectListDialogComponent', () => {
|
|||||||
expect(firstAspectCheckbox).toBeDefined();
|
expect(firstAspectCheckbox).toBeDefined();
|
||||||
expect(firstAspectCheckbox).not.toBeNull();
|
expect(firstAspectCheckbox).not.toBeNull();
|
||||||
expect(firstAspectCheckbox.checked).toBeTruthy();
|
expect(firstAspectCheckbox.checked).toBeTruthy();
|
||||||
|
|
||||||
|
const notCheckedAspect: HTMLInputElement = fixture.nativeElement.querySelector('#aspect-list-1-check-input');
|
||||||
|
expect(notCheckedAspect).toBeDefined();
|
||||||
|
expect(notCheckedAspect).not.toBeNull();
|
||||||
|
expect(notCheckedAspect.checked).toBeFalsy();
|
||||||
|
|
||||||
|
const customAspectCheckbox: HTMLInputElement = fixture.nativeElement.querySelector('#aspect-list-2-check-input');
|
||||||
|
expect(customAspectCheckbox).toBeDefined();
|
||||||
|
expect(customAspectCheckbox).not.toBeNull();
|
||||||
|
expect(customAspectCheckbox.checked).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -66,6 +66,27 @@ const aspectListMock: AspectEntry[] = [{
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
const customAspectListMock: AspectEntry[] = [{
|
||||||
|
entry: {
|
||||||
|
parentId: 'cst:customAspect',
|
||||||
|
id: 'cst:customAspect',
|
||||||
|
description: 'Custom Aspect with random description',
|
||||||
|
title: 'CustomAspect',
|
||||||
|
properties: [
|
||||||
|
{
|
||||||
|
id: 'channelPassword',
|
||||||
|
title: 'The authenticated channel password',
|
||||||
|
dataType: 'd:propA'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'channelUsername',
|
||||||
|
title: 'The authenticated channel username',
|
||||||
|
dataType: 'd:propB'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
describe('AspectListComponent', () => {
|
describe('AspectListComponent', () => {
|
||||||
|
|
||||||
let component: AspectListComponent;
|
let component: AspectListComponent;
|
||||||
@@ -107,7 +128,8 @@ describe('AspectListComponent', () => {
|
|||||||
fixture = TestBed.createComponent(AspectListComponent);
|
fixture = TestBed.createComponent(AspectListComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
aspectListService = TestBed.inject(AspectListService);
|
aspectListService = TestBed.inject(AspectListService);
|
||||||
spyOn(aspectListService, 'getAspects').and.returnValue(of(aspectListMock));
|
spyOn(aspectListService, 'getAspects').and.returnValue(of([...aspectListMock, ...customAspectListMock]));
|
||||||
|
spyOn(aspectListService, 'getCustomAspects').and.returnValue(of(customAspectListMock));
|
||||||
spyOn(aspectListService, 'getVisibleAspects').and.returnValue(['frs:AspectOne']);
|
spyOn(aspectListService, 'getVisibleAspects').and.returnValue(['frs:AspectOne']);
|
||||||
nodeService = TestBed.inject(NodesApiService);
|
nodeService = TestBed.inject(NodesApiService);
|
||||||
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node-id', aspectNames: ['frs:AspectOne'] }));
|
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node-id', aspectNames: ['frs:AspectOne'] }));
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||||
import { NodesApiService } from '@alfresco/adf-core';
|
import { NodesApiService } from '@alfresco/adf-core';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject, zip } from 'rxjs';
|
||||||
import { concatMap, takeUntil, tap } from 'rxjs/operators';
|
import { concatMap, map, takeUntil, tap } from 'rxjs/operators';
|
||||||
import { AspectListService } from './aspect-list.service';
|
import { AspectListService } from './aspect-list.service';
|
||||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||||
import { AspectEntry } from '@alfresco/js-api';
|
import { AspectEntry } from '@alfresco/js-api';
|
||||||
@@ -56,9 +56,14 @@ export class AspectListComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.nodeId) {
|
if (this.nodeId) {
|
||||||
this.aspects$ = this.nodeApiService.getNode(this.nodeId).pipe(
|
const node$ = this.nodeApiService.getNode(this.nodeId);
|
||||||
tap((node) => {
|
const customAspect$ = this.aspectListService.getCustomAspects()
|
||||||
this.nodeAspects = node.aspectNames.filter((aspect) => this.aspectListService.getVisibleAspects().includes(aspect));
|
.pipe(map(
|
||||||
|
(customAspects) => customAspects.flatMap((customAspect) => customAspect.entry.id)
|
||||||
|
));
|
||||||
|
this.aspects$ = zip(node$, customAspect$).pipe(
|
||||||
|
tap(([node, customAspects]) => {
|
||||||
|
this.nodeAspects = node.aspectNames.filter((aspect) => this.aspectListService.getVisibleAspects().includes(aspect) || customAspects.includes(aspect));
|
||||||
this.nodeAspectStatus = Array.from(node.aspectNames);
|
this.nodeAspectStatus = Array.from(node.aspectNames);
|
||||||
this.valueChanged.emit(this.nodeAspects);
|
this.valueChanged.emit(this.nodeAspects);
|
||||||
}),
|
}),
|
||||||
|
Reference in New Issue
Block a user