mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
Name column fixes (#6904)
This commit is contained in:
parent
ec2436e73b
commit
a244200258
@ -31,7 +31,7 @@
|
||||
"application": {
|
||||
"storagePrefix": "ADF",
|
||||
"name": "Alfresco ADF Application",
|
||||
"copyright": "© 2016 - 2018 Alfresco Software, Inc. All Rights Reserved."
|
||||
"copyright": "© 2016 - 2021 Alfresco Software, Inc. All Rights Reserved."
|
||||
},
|
||||
"search": {
|
||||
"filterWithContains": true,
|
||||
|
@ -44,6 +44,9 @@ export class NameColumnComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
@Input()
|
||||
key = 'name';
|
||||
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
node: NodeEntry;
|
||||
|
||||
@ -73,7 +76,8 @@ export class NameColumnComponent implements OnInit, OnDestroy {
|
||||
this.node = this.context.row.node;
|
||||
|
||||
if (this.node && this.node.entry) {
|
||||
this.displayText$.next(this.node.entry.name || this.node.entry.id);
|
||||
const displayText = this.context.row.getValue(this.key);
|
||||
this.displayText$.next(displayText || this.node.entry.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@
|
||||
title="{{'DOCUMENT_LIST.COLUMNS.DISPLAY_NAME' | translate}}"
|
||||
[formatTooltip]="getNodeNameTooltip">
|
||||
<ng-template let-context>
|
||||
<adf-name-column [context]="context"></adf-name-column>
|
||||
<adf-name-column key="name" [context]="context"></adf-name-column>
|
||||
</ng-template>
|
||||
</data-column>
|
||||
<data-column
|
||||
|
@ -583,7 +583,7 @@ For example:
|
||||
```html
|
||||
<data-column key="name" title="Name">
|
||||
<ng-template let-context>
|
||||
<adf-name-column [context]="context"></adf-name-column>
|
||||
<adf-name-column key="name" [context]="context"></adf-name-column>
|
||||
</ng-template>
|
||||
</data-column>
|
||||
```
|
||||
|
@ -16,9 +16,59 @@
|
||||
*/
|
||||
|
||||
import { NameColumnComponent } from './name-column.component';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||
import { skip } from 'rxjs/operators';
|
||||
|
||||
describe('NameColumnComponent', () => {
|
||||
it('should be defined', () => {
|
||||
expect(NameColumnComponent).toBeDefined();
|
||||
});
|
||||
let fixture: ComponentFixture<NameColumnComponent>;
|
||||
let context: any;
|
||||
let component: NameColumnComponent;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(NameColumnComponent);
|
||||
|
||||
context = {
|
||||
row: {
|
||||
node: {entry: {}},
|
||||
getValue(key) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
component = fixture.componentInstance;
|
||||
component.context = context;
|
||||
});
|
||||
|
||||
it('should set the display value based on default key', (done) => {
|
||||
component.displayText$
|
||||
.pipe(skip(1))
|
||||
.subscribe(value => {
|
||||
expect(value).toBe('name');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnInit();
|
||||
});
|
||||
|
||||
it('should set the display value based on the custom key', (done) => {
|
||||
component.key = 'title';
|
||||
component.displayText$
|
||||
.pipe(skip(1))
|
||||
.subscribe(value => {
|
||||
expect(value).toBe('title');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnInit();
|
||||
});
|
||||
});
|
||||
|
@ -53,6 +53,9 @@ export class NameColumnComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
@Input()
|
||||
key = 'name';
|
||||
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
node: NodeEntry;
|
||||
|
||||
@ -82,7 +85,8 @@ export class NameColumnComponent implements OnInit, OnDestroy {
|
||||
this.node = this.context.row.node;
|
||||
|
||||
if (this.node && this.node.entry) {
|
||||
this.displayText$.next(this.node.entry.name || this.node.entry.id);
|
||||
const displayText = this.context.row.getValue(this.key);
|
||||
this.displayText$.next(displayText || this.node.entry.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user