[ADF-3677] Add highlight configuration to SearchQueryBuilder (#4358)

* [ADF-3677] Add highlight configuration to SearchQueryBuilder

* highlight property in search

* Update files.component.ts

* remove comma

* highlight missspell

* fix schhema json highilight

* fix test

* fix lint

* fix lint

* fix lint

* fix search sorting tests

* fix search sorting

* fix lint

* remove useless test

* check for null nodes

* remove duplicated test

* lint

* fix sorting tests

* remove test not search component related
This commit is contained in:
davidcanonieto
2019-03-17 17:23:07 +00:00
committed by Eugenio Romano
parent d6f391c40e
commit 8dc9eba4c7
19 changed files with 401 additions and 444 deletions

View File

@@ -249,7 +249,23 @@
}
}
}
]
],
"highlight": {
"prefix": " ",
"postfix": " ",
"mergeContiguous": true,
"fields": [
{
"field": "cm:title"
},
{
"field": "description",
"prefix": "(",
"postfix": ")"
}
]
}
},
"pagination": {
"size": 20,

View File

@@ -1,10 +1,11 @@
<div class="adf-container">
<mat-accordion *ngIf="showRecentFiles" class="adf-container-recent">
<mat-expansion-panel hideToggle="true">
<mat-expansion-panel-header >
<mat-expansion-panel hideToggle="true">
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'DOCUMENT_LIST.RECENT.TITLE' | translate }}<mat-icon>history</mat-icon>
{{ 'DOCUMENT_LIST.RECENT.TITLE' | translate }}
<mat-icon>history</mat-icon>
</mat-panel-title>
</mat-expansion-panel-header>
@@ -31,7 +32,8 @@
</adf-sites-dropdown>
</div>
<div id="document-list-container" class="adf-document-list-container" fxLayout="row" fxLayoutAlign="start stretch" fxLayoutGap="16px">
<div id="document-list-container" class="adf-document-list-container" fxLayout="row" fxLayoutAlign="start stretch"
fxLayoutGap="16px">
<adf-upload-drag-area fxFlex="1 1 auto"
[disabled]="disableDragArea"
[acceptedFilesType]="getFileFiltering()"
@@ -67,8 +69,12 @@
data-automation-id="document-list-grid-view"
title="{{ 'DOCUMENT_LIST.TOOLBAR.CARDVIEW' | translate }}"
(click)="toggleGalleryView()">
<mat-icon *ngIf="displayMode === 'list'" matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.CARDVIEW' | translate }}">view_comfy</mat-icon>
<mat-icon *ngIf="displayMode === 'gallery'" matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.LISTVIEW' | translate }}">list</mat-icon>
<mat-icon *ngIf="displayMode === 'list'"
matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.CARDVIEW' | translate }}">view_comfy
</mat-icon>
<mat-icon *ngIf="displayMode === 'gallery'"
matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.LISTVIEW' | translate }}">list
</mat-icon>
</button>
<button
data-automation-id="create-new-folder"
@@ -136,7 +142,8 @@
</button>
</div>
<button fxFlex="1 0 auto" mat-icon-button [matMenuTriggerFor]="themePicker" matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.THEME' | translate }}">
<button fxFlex="1 0 auto" mat-icon-button [matMenuTriggerFor]="themePicker"
matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.THEME' | translate }}">
<mat-icon>format_color_fill</mat-icon>
</button>
@@ -148,8 +155,12 @@
</mat-menu>
<button mat-icon-button (click)="showVersions = !showVersions" class="adf-show-versions-button">
<mat-icon *ngIf="!showVersions" matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.SHOW_VERSION' | translate }}">chevron_left</mat-icon>
<mat-icon *ngIf="showVersions" matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.HIDE_VERSION' | translate }}">chevron_right</mat-icon>
<mat-icon *ngIf="!showVersions" matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.SHOW_VERSION' | translate }}">
chevron_left
</mat-icon>
<mat-icon *ngIf="showVersions" matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.HIDE_VERSION' | translate }}">
chevron_right
</mat-icon>
</button>
<adf-toolbar-divider fxFlex="0 0 auto" fxHide fxShow.lt-sm="true"></adf-toolbar-divider>
@@ -160,7 +171,7 @@
<mat-menu #menu="matMenu">
<button mat-menu-item
(click)="toggleGalleryView()">
<mat-icon *ngIf="displayMode === 'list'" >view_comfy</mat-icon>
<mat-icon *ngIf="displayMode === 'list'">view_comfy</mat-icon>
<mat-icon *ngIf="displayMode === 'gallery'">list</mat-icon>
<span>{{ 'DOCUMENT_LIST.TOOLBAR.CARDVIEW' | translate }}</span>
</button>
@@ -225,12 +236,12 @@
(permissionError)="handlePermissionError($event)"
(name-click)="documentList.onNodeDblClick($event.detail?.node)">
<adf-custom-no-permission-template *ngIf="enableCustomPermissionMessage">
<h1>You don't have permissions</h1>
<h1>You don't have permissions</h1>
</adf-custom-no-permission-template>
<adf-custom-empty-content-template *ngIf="disableDragArea">
<div class="adf-empty_template">
<div class="adf-no-result-message">{{ 'SEARCH.NO_RESULT' | translate }}</div>
</div>
<div class="adf-empty_template">
<div class="adf-no-result-message">{{ 'SEARCH.NO_RESULT' | translate }}</div>
</div>
</adf-custom-empty-content-template>
<data-columns>
<data-column
@@ -271,6 +282,14 @@
title="{{'DOCUMENT_LIST.COLUMNS.SIZE' | translate}}"
type="fileSize">
</data-column>
<data-column
key="search"
title="Search">
<ng-template let-entry="$implicit">
<div *ngIf="searchTerm" [innerHTML]="searchResultsHighlight(entry.row.node.entry.search) | highlight:searchTerm">
</div>
</ng-template>
</data-column>
<!-- Notes: has performance overhead due to multiple files/folders causing separate HTTP calls to get tags -->
<!--
<data-column
@@ -422,7 +441,7 @@
<adf-info-drawer-layout *ngIf="showVersions" class="adf-manage-versions-sidebar" fxFlex="0 0 auto">
<div info-drawer-content>
<adf-info-drawer [title]="'Details'" *ngIf="documentList.selection[0]" >
<adf-info-drawer [title]="'Details'" *ngIf="documentList.selection[0]">
<adf-info-drawer-tab [label]="'Properties'">
<adf-content-metadata-card
[node]="documentList.selection[0].entry"
@@ -514,7 +533,8 @@
</section>
<section>
<mat-slide-toggle id="adf-extension-filter-upload-switch" [color]="'primary'" [(ngModel)]="acceptedFilesTypeShow">
<mat-slide-toggle id="adf-extension-filter-upload-switch" [color]="'primary'"
[(ngModel)]="acceptedFilesTypeShow">
{{'DOCUMENT_LIST.CUSTOM_FILTER' | translate}}
</mat-slide-toggle>
</section>
@@ -532,13 +552,14 @@
</section>
<section>
<mat-slide-toggle id="adf-document-list-enable-drop-files" [color]="'primary'" [(ngModel)]="allowDropFiles" (click)="toggleAllowDropFiles()" >
<mat-slide-toggle id="adf-document-list-enable-drop-files" [color]="'primary'" [(ngModel)]="allowDropFiles"
(click)="toggleAllowDropFiles()">
{{'DOCUMENT_LIST.ALLOW_DROP_FILES' | translate}}
</mat-slide-toggle>
</section>
<section>
<mat-slide-toggle id="adf-version-upload-switch" [color]="'primary'" [(ngModel)]="versioning">
<mat-slide-toggle id="adf-version-upload-switch" [color]="'primary'" [(ngModel)]="versioning">
{{'DOCUMENT_LIST.ENABLE_VERSIONING' | translate}}
</mat-slide-toggle>
</section>
@@ -656,4 +677,4 @@
</div>
</div>
<adf-file-uploading-dialog #fileDialog (error)="openSnackMessage($event)" ></adf-file-uploading-dialog>
<adf-file-uploading-dialog #fileDialog (error)="openSnackMessage($event)"></adf-file-uploading-dialog>

View File

@@ -28,7 +28,7 @@ import {
AlfrescoApiService, AuthenticationService, AppConfigService, AppConfigValues, ContentService, TranslationService,
FileUploadEvent, FolderCreatedEvent, LogService, NotificationService,
UploadService, DataColumn, DataRow, UserPreferencesService,
PaginationComponent, FormValues, DisplayMode, InfinitePaginationComponent
PaginationComponent, FormValues, DisplayMode, InfinitePaginationComponent, HighlightDirective
} from '@alfresco/adf-core';
import {
@@ -46,6 +46,7 @@ import { MetadataDialogAdapterComponent } from './metadata-dialog-adapter.compon
import { Subscription } from 'rxjs';
import { PreviewService } from '../../services/preview.service';
import { debounceTime } from 'rxjs/operators';
import { SearchEntry } from '@alfresco/js-api';
const DEFAULT_FOLDER_TO_SHOW = '-my-';
@@ -150,6 +151,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
@Input()
showNameColumn = true;
@Input()
searchTerm = '';
@Output()
documentListReady: EventEmitter<any> = new EventEmitter();
@@ -180,6 +184,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
@ViewChild(InfinitePaginationComponent)
infinitePaginationComponent: InfinitePaginationComponent;
@ViewChild(HighlightDirective)
highlighter: HighlightDirective;
permissionsStyle: PermissionStyleModel[] = [];
infiniteScrolling: boolean;
warnOnMultipleUploads = false;
@@ -581,4 +588,10 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
);
});
}
searchResultsHighlight(search: SearchEntry): string {
if (search && search.highlight) {
return search.highlight.map((currentHighlight) => currentHighlight.snippets).join(', ');
}
}
}

View File

@@ -21,6 +21,7 @@
[nodeResult]="data"
[disableDragArea]="true"
[pagination]="pagination"
[searchTerm]="searchedWord"
(changedPageSize)="onRefreshPagination($event)"
(changedPageNumber)="onRefreshPagination($event)"
(turnedNextPage)="onRefreshPagination($event)"