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 { AppStore } from '../../../store/states/app.state';
|
||||||
import { SearchByTermAction } from '../../../store/actions';
|
import { SearchByTermAction } from '../../../store/actions';
|
||||||
import { filter, takeUntil } from 'rxjs/operators';
|
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 { SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||||
import { ContentManagementService } from '../../../services/content-management.service';
|
import { ContentManagementService } from '../../../services/content-management.service';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
export enum SearchOptionIds {
|
export enum SearchOptionIds {
|
||||||
Files = 'files',
|
Files = 'content',
|
||||||
Folders = 'folders',
|
Folders = 'folder',
|
||||||
Libraries = 'libraries'
|
Libraries = 'libraries'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +93,6 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
|||||||
searchInputControl: SearchInputControlComponent;
|
searchInputControl: SearchInputControlComponent;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private librariesQueryBuilder: SearchLibrariesQueryBuilderService,
|
|
||||||
private queryBuilder: SearchQueryBuilderService,
|
private queryBuilder: SearchQueryBuilderService,
|
||||||
private content: ContentManagementService,
|
private content: ContentManagementService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
@ -185,24 +183,27 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
onOptionChange() {
|
onOptionChange() {
|
||||||
this.has400LibraryError = false;
|
this.has400LibraryError = false;
|
||||||
if (this.searchedWord) {
|
if (this.isLibrariesChecked()) {
|
||||||
if (this.isLibrariesChecked()) {
|
if (this.searchedWord && !this.onLibrariesSearchResults) {
|
||||||
if (this.onLibrariesSearchResults) {
|
this.store.dispatch(
|
||||||
this.librariesQueryBuilder.update();
|
new SearchByTermAction(this.searchedWord, this.searchOptions)
|
||||||
} else {
|
);
|
||||||
this.store.dispatch(
|
}
|
||||||
new SearchByTermAction(this.searchedWord, this.searchOptions)
|
} else {
|
||||||
);
|
if (this.isFoldersChecked() && !this.isFilesChecked()) {
|
||||||
}
|
this.filterContent(SearchOptionIds.Folders);
|
||||||
} else if (this.isContentChecked()) {
|
} else if (this.isFilesChecked() && !this.isFoldersChecked()) {
|
||||||
if (this.onSearchResults) {
|
this.filterContent(SearchOptionIds.Files);
|
||||||
// TODO: send here data to this.queryBuilder to be able to search for files/folders
|
} else {
|
||||||
this.queryBuilder.update();
|
this.removeContentFilters();
|
||||||
} else {
|
}
|
||||||
this.store.dispatch(
|
|
||||||
new SearchByTermAction(this.searchedWord, this.searchOptions)
|
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;
|
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.executed.subscribe(data => {
|
||||||
this.librariesQueryBuilder.paging.skipCount = 0;
|
|
||||||
|
|
||||||
this.onSearchResultLoaded(data);
|
this.onSearchResultLoaded(data);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
}),
|
}),
|
||||||
@ -119,6 +117,7 @@ export class SearchLibrariesResultsComponent extends PageComponent
|
|||||||
const query = this.formatSearchQuery(this.searchedWord);
|
const query = this.formatSearchQuery(this.searchedWord);
|
||||||
|
|
||||||
if (query && query.length > 1) {
|
if (query && query.length > 1) {
|
||||||
|
this.librariesQueryBuilder.paging.skipCount = 0;
|
||||||
this.librariesQueryBuilder.userQuery = query;
|
this.librariesQueryBuilder.userQuery = query;
|
||||||
this.librariesQueryBuilder.update();
|
this.librariesQueryBuilder.update();
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,8 +42,7 @@ import { AppConfigService } from '@alfresco/adf-core';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'aca-search-results',
|
selector: 'aca-search-results',
|
||||||
templateUrl: './search-results.component.html',
|
templateUrl: './search-results.component.html',
|
||||||
styleUrls: ['./search-results.component.scss'],
|
styleUrls: ['./search-results.component.scss']
|
||||||
providers: [SearchQueryBuilderService]
|
|
||||||
})
|
})
|
||||||
export class SearchResultsComponent extends PageComponent implements OnInit {
|
export class SearchResultsComponent extends PageComponent implements OnInit {
|
||||||
@ViewChild('search')
|
@ViewChild('search')
|
||||||
|
@ -28,6 +28,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { SEARCH_BY_TERM, SearchByTermAction } from '../actions/search.actions';
|
import { SEARCH_BY_TERM, SearchByTermAction } from '../actions/search.actions';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { SearchOptionIds } from '../../components/search/search-input/search-input.component';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SearchEffects {
|
export class SearchEffects {
|
||||||
@ -37,11 +38,12 @@ export class SearchEffects {
|
|||||||
searchByTerm$ = this.actions$.pipe(
|
searchByTerm$ = this.actions$.pipe(
|
||||||
ofType<SearchByTermAction>(SEARCH_BY_TERM),
|
ofType<SearchByTermAction>(SEARCH_BY_TERM),
|
||||||
map(action => {
|
map(action => {
|
||||||
if (
|
const libItem = action.searchOptions.find(
|
||||||
action.searchOptions &&
|
item => item.id === SearchOptionIds.Libraries
|
||||||
action.searchOptions[2] &&
|
);
|
||||||
action.searchOptions[2].value
|
const librarySelected = !!libItem && libItem.value;
|
||||||
) {
|
|
||||||
|
if (librarySelected) {
|
||||||
this.router.navigateByUrl('/search-libraries;q=' + action.payload);
|
this.router.navigateByUrl('/search-libraries;q=' + action.payload);
|
||||||
} else {
|
} else {
|
||||||
this.router.navigateByUrl('/search;q=' + action.payload);
|
this.router.navigateByUrl('/search;q=' + action.payload);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user