mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
[ACA-1964] Filter results by Files / Folders option (#812)
* [ACA-1964] keep skipCount after library delete * [ACA-1964] refactor code * [ACA-1964] remove service scope's limitation * [ACA-1964] filter results by files/folders option * [ACA-1964] refactor code * [ACA-1964] revert package-lock
This commit is contained in:
parent
9b7ad0b0b3
commit
01ea887d5d
@ -44,14 +44,13 @@ import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../../store/states/app.state';
|
||||
import { SearchByTermAction } from '../../../store/actions';
|
||||
import { filter, takeUntil } from 'rxjs/operators';
|
||||
import { SearchLibrariesQueryBuilderService } from '../search-libraries-results/search-libraries-query-builder.service';
|
||||
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||
import { ContentManagementService } from '../../../services/content-management.service';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
export enum SearchOptionIds {
|
||||
Files = 'files',
|
||||
Folders = 'folders',
|
||||
Files = 'content',
|
||||
Folders = 'folder',
|
||||
Libraries = 'libraries'
|
||||
}
|
||||
|
||||
@ -94,7 +93,6 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
searchInputControl: SearchInputControlComponent;
|
||||
|
||||
constructor(
|
||||
private librariesQueryBuilder: SearchLibrariesQueryBuilderService,
|
||||
private queryBuilder: SearchQueryBuilderService,
|
||||
private content: ContentManagementService,
|
||||
private router: Router,
|
||||
@ -185,24 +183,27 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
|
||||
onOptionChange() {
|
||||
this.has400LibraryError = false;
|
||||
if (this.searchedWord) {
|
||||
if (this.isLibrariesChecked()) {
|
||||
if (this.onLibrariesSearchResults) {
|
||||
this.librariesQueryBuilder.update();
|
||||
} else {
|
||||
this.store.dispatch(
|
||||
new SearchByTermAction(this.searchedWord, this.searchOptions)
|
||||
);
|
||||
}
|
||||
} else if (this.isContentChecked()) {
|
||||
if (this.onSearchResults) {
|
||||
// TODO: send here data to this.queryBuilder to be able to search for files/folders
|
||||
this.queryBuilder.update();
|
||||
} else {
|
||||
this.store.dispatch(
|
||||
new SearchByTermAction(this.searchedWord, this.searchOptions)
|
||||
);
|
||||
}
|
||||
if (this.isLibrariesChecked()) {
|
||||
if (this.searchedWord && !this.onLibrariesSearchResults) {
|
||||
this.store.dispatch(
|
||||
new SearchByTermAction(this.searchedWord, this.searchOptions)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (this.isFoldersChecked() && !this.isFilesChecked()) {
|
||||
this.filterContent(SearchOptionIds.Folders);
|
||||
} else if (this.isFilesChecked() && !this.isFoldersChecked()) {
|
||||
this.filterContent(SearchOptionIds.Files);
|
||||
} else {
|
||||
this.removeContentFilters();
|
||||
}
|
||||
|
||||
if (this.onSearchResults) {
|
||||
this.queryBuilder.update();
|
||||
} else if (this.searchedWord) {
|
||||
this.store.dispatch(
|
||||
new SearchByTermAction(this.searchedWord, this.searchOptions)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -246,4 +247,21 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
filterContent(option: SearchOptionIds.Folders | SearchOptionIds.Files) {
|
||||
const oppositeOption =
|
||||
option === SearchOptionIds.Folders
|
||||
? SearchOptionIds.Files
|
||||
: SearchOptionIds.Folders;
|
||||
|
||||
this.queryBuilder.addFilterQuery(`+TYPE:'cm:${option}'`);
|
||||
this.queryBuilder.removeFilterQuery(`+TYPE:'cm:${oppositeOption}'`);
|
||||
}
|
||||
|
||||
removeContentFilters() {
|
||||
this.queryBuilder.removeFilterQuery(`+TYPE:'cm:${SearchOptionIds.Files}'`);
|
||||
this.queryBuilder.removeFilterQuery(
|
||||
`+TYPE:'cm:${SearchOptionIds.Folders}'`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,6 @@ export class SearchLibrariesResultsComponent extends PageComponent
|
||||
}),
|
||||
|
||||
this.librariesQueryBuilder.executed.subscribe(data => {
|
||||
this.librariesQueryBuilder.paging.skipCount = 0;
|
||||
|
||||
this.onSearchResultLoaded(data);
|
||||
this.isLoading = false;
|
||||
}),
|
||||
@ -119,6 +117,7 @@ export class SearchLibrariesResultsComponent extends PageComponent
|
||||
const query = this.formatSearchQuery(this.searchedWord);
|
||||
|
||||
if (query && query.length > 1) {
|
||||
this.librariesQueryBuilder.paging.skipCount = 0;
|
||||
this.librariesQueryBuilder.userQuery = query;
|
||||
this.librariesQueryBuilder.update();
|
||||
} else {
|
||||
|
@ -42,8 +42,7 @@ import { AppConfigService } from '@alfresco/adf-core';
|
||||
@Component({
|
||||
selector: 'aca-search-results',
|
||||
templateUrl: './search-results.component.html',
|
||||
styleUrls: ['./search-results.component.scss'],
|
||||
providers: [SearchQueryBuilderService]
|
||||
styleUrls: ['./search-results.component.scss']
|
||||
})
|
||||
export class SearchResultsComponent extends PageComponent implements OnInit {
|
||||
@ViewChild('search')
|
||||
|
@ -28,6 +28,7 @@ import { Injectable } from '@angular/core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SEARCH_BY_TERM, SearchByTermAction } from '../actions/search.actions';
|
||||
import { Router } from '@angular/router';
|
||||
import { SearchOptionIds } from '../../components/search/search-input/search-input.component';
|
||||
|
||||
@Injectable()
|
||||
export class SearchEffects {
|
||||
@ -37,11 +38,12 @@ export class SearchEffects {
|
||||
searchByTerm$ = this.actions$.pipe(
|
||||
ofType<SearchByTermAction>(SEARCH_BY_TERM),
|
||||
map(action => {
|
||||
if (
|
||||
action.searchOptions &&
|
||||
action.searchOptions[2] &&
|
||||
action.searchOptions[2].value
|
||||
) {
|
||||
const libItem = action.searchOptions.find(
|
||||
item => item.id === SearchOptionIds.Libraries
|
||||
);
|
||||
const librarySelected = !!libItem && libItem.value;
|
||||
|
||||
if (librarySelected) {
|
||||
this.router.navigateByUrl('/search-libraries;q=' + action.payload);
|
||||
} else {
|
||||
this.router.navigateByUrl('/search;q=' + action.payload);
|
||||
|
Loading…
x
Reference in New Issue
Block a user