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();
|
fixture.detectChanges();
|
||||||
expect(value).toBe('LIBRARY.ROLE.NONE');
|
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 { ChangeDetectionStrategy, Component, DestroyRef, inject, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
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 { ShareDataRow } from '../../data/share-data-row.model';
|
||||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
@@ -64,26 +64,23 @@ export class LibraryRoleColumnComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected updateValue() {
|
protected updateValue() {
|
||||||
const node: SiteEntry = this.context.row.node;
|
const role = this.context.row.node?.entry.role ?? this.context.row.obj.role;
|
||||||
if (node?.entry) {
|
switch (role) {
|
||||||
const role: string = node.entry.role;
|
case Site.RoleEnum.SiteManager:
|
||||||
switch (role) {
|
this.displayText$.next('LIBRARY.ROLE.MANAGER');
|
||||||
case Site.RoleEnum.SiteManager:
|
break;
|
||||||
this.displayText$.next('LIBRARY.ROLE.MANAGER');
|
case Site.RoleEnum.SiteCollaborator:
|
||||||
break;
|
this.displayText$.next('LIBRARY.ROLE.COLLABORATOR');
|
||||||
case Site.RoleEnum.SiteCollaborator:
|
break;
|
||||||
this.displayText$.next('LIBRARY.ROLE.COLLABORATOR');
|
case Site.RoleEnum.SiteContributor:
|
||||||
break;
|
this.displayText$.next('LIBRARY.ROLE.CONTRIBUTOR');
|
||||||
case Site.RoleEnum.SiteContributor:
|
break;
|
||||||
this.displayText$.next('LIBRARY.ROLE.CONTRIBUTOR');
|
case Site.RoleEnum.SiteConsumer:
|
||||||
break;
|
this.displayText$.next('LIBRARY.ROLE.CONSUMER');
|
||||||
case Site.RoleEnum.SiteConsumer:
|
break;
|
||||||
this.displayText$.next('LIBRARY.ROLE.CONSUMER');
|
default:
|
||||||
break;
|
this.displayText$.next('LIBRARY.ROLE.NONE');
|
||||||
default:
|
break;
|
||||||
this.displayText$.next('LIBRARY.ROLE.NONE');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,54 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { LibraryStatusColumnComponent } from './library-status-column.component';
|
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', () => {
|
describe('LibraryStatusColumnComponent', () => {
|
||||||
it('should be defined', () => {
|
let fixture: ComponentFixture<LibraryStatusColumnComponent>;
|
||||||
expect(LibraryStatusColumnComponent).toBeDefined();
|
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 { Component, DestroyRef, inject, Input, OnInit } from '@angular/core';
|
||||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
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 { ShareDataRow } from '../../data/share-data-row.model';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
@@ -62,24 +62,21 @@ export class LibraryStatusColumnComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected updateValue() {
|
protected updateValue() {
|
||||||
const node: SiteEntry = this.context.row.node;
|
const visibility = this.context.row.node?.entry.visibility ?? this.context.row.obj.visibility;
|
||||||
if (node?.entry) {
|
|
||||||
const visibility: string = node.entry.visibility;
|
|
||||||
|
|
||||||
switch (visibility) {
|
switch (visibility) {
|
||||||
case Site.VisibilityEnum.PUBLIC:
|
case Site.VisibilityEnum.PUBLIC:
|
||||||
this.displayText$.next('LIBRARY.VISIBILITY.PUBLIC');
|
this.displayText$.next('LIBRARY.VISIBILITY.PUBLIC');
|
||||||
break;
|
break;
|
||||||
case Site.VisibilityEnum.PRIVATE:
|
case Site.VisibilityEnum.PRIVATE:
|
||||||
this.displayText$.next('LIBRARY.VISIBILITY.PRIVATE');
|
this.displayText$.next('LIBRARY.VISIBILITY.PRIVATE');
|
||||||
break;
|
break;
|
||||||
case Site.VisibilityEnum.MODERATED:
|
case Site.VisibilityEnum.MODERATED:
|
||||||
this.displayText$.next('LIBRARY.VISIBILITY.MODERATED');
|
this.displayText$.next('LIBRARY.VISIBILITY.MODERATED');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.displayText$.next('UNKNOWN');
|
this.displayText$.next('UNKNOWN');
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,6 +69,7 @@ export abstract class InfiniteScrollDatasource<T> extends DataSource<T> {
|
|||||||
|
|
||||||
reset(): void {
|
reset(): void {
|
||||||
this.isLoading$.next(true);
|
this.isLoading$.next(true);
|
||||||
|
this.dataStream.next([]);
|
||||||
this.getNextBatch({ skipCount: 0, maxItems: this.batchSize })
|
this.getNextBatch({ skipCount: 0, maxItems: this.batchSize })
|
||||||
.pipe(take(1))
|
.pipe(take(1))
|
||||||
.subscribe((firstBatch) => {
|
.subscribe((firstBatch) => {
|
||||||
|
Reference in New Issue
Block a user