mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-6642] Tags column and getTags API call is now dynamic on app.config.json for search page (#3607)
This commit is contained in:
parent
91cdb1a9d1
commit
47fb269c4d
@ -75,7 +75,7 @@
|
||||
<data-column id="app.search.size" key="content.sizeInBytes" type="fileSize" title="APP.DOCUMENT_LIST.COLUMNS.SIZE" class="adf-no-grow-cell adf-ellipsis-cell" [sortable]="false" *ngIf="!isSmallScreen" [draggable]="true"></data-column>
|
||||
<data-column id="app.search.modifiedOn" key="modifiedAt" type="date" title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON" class="adf-no-grow-cell adf-ellipsis-cell" format="timeAgo" [sortable]="false" *ngIf="!isSmallScreen" [draggable]="true"></data-column>
|
||||
<data-column id="app.search.modifiedBy" key="modifiedByUser.displayName" title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY" class="adf-no-grow-cell adf-ellipsis-cell" [sortable]="false" *ngIf="!isSmallScreen" [draggable]="true"></data-column>
|
||||
<data-column id="app.search.tags" key="$tags" type="text" title="APP.DOCUMENT_LIST.COLUMNS.TAGS" class="adf-full-width adf-expand-cell-4" [sortable]="false" [draggable]="true">
|
||||
<data-column id="app.search.tags" key="$tags" type="text" title="APP.DOCUMENT_LIST.COLUMNS.TAGS" class="adf-full-width adf-expand-cell-4" [sortable]="false" [draggable]="true" *ngIf="isTagsEnabled">
|
||||
<ng-template let-context>
|
||||
<aca-tags-column [context]="context"></aca-tags-column>
|
||||
</ng-template>
|
||||
|
@ -22,15 +22,15 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
|
||||
import { SearchResultsComponent } from './search-results.component';
|
||||
import { AppConfigService, TranslationService } from '@alfresco/adf-core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { NavigateToFolder, SnackbarErrorAction } from '@alfresco/aca-shared/store';
|
||||
import { Pagination, SearchRequest } from '@alfresco/js-api';
|
||||
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||
import { Pagination, ResultSetPaging, SearchRequest } from '@alfresco/js-api';
|
||||
import { SearchQueryBuilderService, TagService } from '@alfresco/adf-content-services';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { BehaviorSubject, of, Subject } from 'rxjs';
|
||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||
import { AppService } from '@alfresco/aca-shared';
|
||||
|
||||
@ -274,4 +274,80 @@ describe('SearchComponent', () => {
|
||||
expect(queryBuilder.userQuery).toBe(`((=cm:tag:"orange"))`);
|
||||
expect(queryBuilder.update).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('Dynamic Columns', () => {
|
||||
let tagsService: TagService;
|
||||
|
||||
beforeEach(() => {
|
||||
tagsService = TestBed.inject(TagService);
|
||||
|
||||
spyOn(queryBuilder['searchApi'], 'search').and.returnValue(
|
||||
Promise.resolve({
|
||||
list: {
|
||||
pagination: {
|
||||
count: 1,
|
||||
hasMoreItems: false,
|
||||
totalItems: 1,
|
||||
skipCount: 0,
|
||||
maxItems: 25
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
nodeType: 'cm:content',
|
||||
isFolder: false,
|
||||
name: 'test-file.txt',
|
||||
id: '8dd4d319-ec9f-4ea0-8276-f3b195918477'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
} as ResultSetPaging)
|
||||
);
|
||||
|
||||
spyOn(queryBuilder, 'buildQuery').and.returnValue(searchRequest);
|
||||
});
|
||||
|
||||
it('should not show tags column if tags are disabled', fakeAsync(() => {
|
||||
spyOn(tagsService, 'areTagsEnabled').and.returnValue(false);
|
||||
fixture = TestBed.createComponent(SearchResultsComponent);
|
||||
fixture.detectChanges();
|
||||
queryBuilder.execute();
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
const tagsColumnHeader = fixture.nativeElement.querySelector(`[data-automation-id='auto_id_$tags']`);
|
||||
expect(tagsColumnHeader).toBeNull();
|
||||
}));
|
||||
|
||||
it('should show tags column if tags are enabled', fakeAsync(() => {
|
||||
spyOn(tagsService, 'areTagsEnabled').and.returnValue(true);
|
||||
spyOn(tagsService, 'getTagsByNodeId').and.returnValue(
|
||||
of({
|
||||
list: {
|
||||
pagination: {
|
||||
count: 0,
|
||||
hasMoreItems: false,
|
||||
totalItems: 0,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: []
|
||||
}
|
||||
})
|
||||
);
|
||||
fixture = TestBed.createComponent(SearchResultsComponent);
|
||||
fixture.detectChanges();
|
||||
queryBuilder.execute();
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
const tagsColumnHeader = fixture.nativeElement.querySelector(`[data-automation-id='auto_id_$tags']`);
|
||||
expect(tagsColumnHeader).not.toBeNull();
|
||||
flush();
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -25,7 +25,7 @@
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { NodeEntry, Pagination, ResultSetPaging } from '@alfresco/js-api';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { AlfrescoViewerModule, DocumentListModule, SearchModule, SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||
import { AlfrescoViewerModule, DocumentListModule, SearchModule, SearchQueryBuilderService, TagService } from '@alfresco/adf-content-services';
|
||||
import {
|
||||
infoDrawerPreview,
|
||||
NavigateToFolder,
|
||||
@ -102,10 +102,18 @@ export class SearchResultsComponent extends PageComponent implements OnInit {
|
||||
sorting = ['name', 'asc'];
|
||||
isLoading = false;
|
||||
totalResults: number;
|
||||
isTagsEnabled = false;
|
||||
|
||||
constructor(private queryBuilder: SearchQueryBuilderService, private route: ActivatedRoute, private translationService: TranslationService) {
|
||||
constructor(
|
||||
tagsService: TagService,
|
||||
private queryBuilder: SearchQueryBuilderService,
|
||||
private route: ActivatedRoute,
|
||||
private translationService: TranslationService
|
||||
) {
|
||||
super();
|
||||
|
||||
this.isTagsEnabled = tagsService.areTagsEnabled();
|
||||
|
||||
queryBuilder.paging = {
|
||||
skipCount: 0,
|
||||
maxItems: 25
|
||||
|
Loading…
x
Reference in New Issue
Block a user