mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-9247] Extend library column context (#10894)
* [ACS-9247] extend library column context * [ACS-9247] cr fix
This commit is contained in:
committed by
GitHub
parent
79163cbae0
commit
d1e48f9c33
@@ -92,4 +92,19 @@ describe('LibraryRoleColumnComponent', () => {
|
||||
fixture.detectChanges();
|
||||
expect(value).toBe('LIBRARY.ROLE.NONE');
|
||||
});
|
||||
|
||||
it('should take role from obj when node entry role is not provided', () => {
|
||||
component.context = {
|
||||
row: {
|
||||
node: { entry: {} },
|
||||
obj: { role: 'SiteManager' }
|
||||
}
|
||||
};
|
||||
|
||||
let value = '';
|
||||
component.displayText$.subscribe((val) => (value = val));
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(value).toBe('LIBRARY.ROLE.MANAGER');
|
||||
});
|
||||
});
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { ChangeDetectionStrategy, Component, DestroyRef, inject, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Site, SiteEntry } from '@alfresco/js-api';
|
||||
import { Site } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@@ -64,26 +64,23 @@ export class LibraryRoleColumnComponent implements OnInit {
|
||||
}
|
||||
|
||||
protected updateValue() {
|
||||
const node: SiteEntry = this.context.row.node;
|
||||
if (node?.entry) {
|
||||
const role: string = node.entry.role;
|
||||
switch (role) {
|
||||
case Site.RoleEnum.SiteManager:
|
||||
this.displayText$.next('LIBRARY.ROLE.MANAGER');
|
||||
break;
|
||||
case Site.RoleEnum.SiteCollaborator:
|
||||
this.displayText$.next('LIBRARY.ROLE.COLLABORATOR');
|
||||
break;
|
||||
case Site.RoleEnum.SiteContributor:
|
||||
this.displayText$.next('LIBRARY.ROLE.CONTRIBUTOR');
|
||||
break;
|
||||
case Site.RoleEnum.SiteConsumer:
|
||||
this.displayText$.next('LIBRARY.ROLE.CONSUMER');
|
||||
break;
|
||||
default:
|
||||
this.displayText$.next('LIBRARY.ROLE.NONE');
|
||||
break;
|
||||
}
|
||||
const role = this.context.row.node?.entry.role ?? this.context.row.obj.role;
|
||||
switch (role) {
|
||||
case Site.RoleEnum.SiteManager:
|
||||
this.displayText$.next('LIBRARY.ROLE.MANAGER');
|
||||
break;
|
||||
case Site.RoleEnum.SiteCollaborator:
|
||||
this.displayText$.next('LIBRARY.ROLE.COLLABORATOR');
|
||||
break;
|
||||
case Site.RoleEnum.SiteContributor:
|
||||
this.displayText$.next('LIBRARY.ROLE.CONTRIBUTOR');
|
||||
break;
|
||||
case Site.RoleEnum.SiteConsumer:
|
||||
this.displayText$.next('LIBRARY.ROLE.CONSUMER');
|
||||
break;
|
||||
default:
|
||||
this.displayText$.next('LIBRARY.ROLE.NONE');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,9 +16,54 @@
|
||||
*/
|
||||
|
||||
import { LibraryStatusColumnComponent } from './library-status-column.component';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { Site } from '@alfresco/js-api';
|
||||
|
||||
describe('LibraryStatusColumnComponent', () => {
|
||||
it('should be defined', () => {
|
||||
expect(LibraryStatusColumnComponent).toBeDefined();
|
||||
});
|
||||
let fixture: ComponentFixture<LibraryStatusColumnComponent>;
|
||||
let component: LibraryStatusColumnComponent;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule, LibraryStatusColumnComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
fixture = TestBed.createComponent(LibraryStatusColumnComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(LibraryStatusColumnComponent).toBeDefined();
|
||||
});
|
||||
|
||||
it('should take default visibility from node entry', () => {
|
||||
component.context = {
|
||||
row: {
|
||||
node: { entry: { visibility: Site.VisibilityEnum.PUBLIC } }
|
||||
}
|
||||
};
|
||||
|
||||
let value = '';
|
||||
component.displayText$.subscribe((val) => (value = val));
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(value).toBe('LIBRARY.VISIBILITY.PUBLIC');
|
||||
});
|
||||
|
||||
it('should take visibility from obj when node entry visibility is not provided', () => {
|
||||
component.context = {
|
||||
row: {
|
||||
node: { entry: {} },
|
||||
obj: { visibility: Site.VisibilityEnum.PUBLIC }
|
||||
}
|
||||
};
|
||||
|
||||
let value = '';
|
||||
component.displayText$.subscribe((val) => (value = val));
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(value).toBe('LIBRARY.VISIBILITY.PUBLIC');
|
||||
});
|
||||
});
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { Component, DestroyRef, inject, Input, OnInit } from '@angular/core';
|
||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Site, SiteEntry } from '@alfresco/js-api';
|
||||
import { Site } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -62,24 +62,21 @@ export class LibraryStatusColumnComponent implements OnInit {
|
||||
}
|
||||
|
||||
protected updateValue() {
|
||||
const node: SiteEntry = this.context.row.node;
|
||||
if (node?.entry) {
|
||||
const visibility: string = node.entry.visibility;
|
||||
const visibility = this.context.row.node?.entry.visibility ?? this.context.row.obj.visibility;
|
||||
|
||||
switch (visibility) {
|
||||
case Site.VisibilityEnum.PUBLIC:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.PUBLIC');
|
||||
break;
|
||||
case Site.VisibilityEnum.PRIVATE:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.PRIVATE');
|
||||
break;
|
||||
case Site.VisibilityEnum.MODERATED:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.MODERATED');
|
||||
break;
|
||||
default:
|
||||
this.displayText$.next('UNKNOWN');
|
||||
break;
|
||||
}
|
||||
switch (visibility) {
|
||||
case Site.VisibilityEnum.PUBLIC:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.PUBLIC');
|
||||
break;
|
||||
case Site.VisibilityEnum.PRIVATE:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.PRIVATE');
|
||||
break;
|
||||
case Site.VisibilityEnum.MODERATED:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.MODERATED');
|
||||
break;
|
||||
default:
|
||||
this.displayText$.next('UNKNOWN');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -69,6 +69,7 @@ export abstract class InfiniteScrollDatasource<T> extends DataSource<T> {
|
||||
|
||||
reset(): void {
|
||||
this.isLoading$.next(true);
|
||||
this.dataStream.next([]);
|
||||
this.getNextBatch({ skipCount: 0, maxItems: this.batchSize })
|
||||
.pipe(take(1))
|
||||
.subscribe((firstBatch) => {
|
||||
|
Reference in New Issue
Block a user