mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-10-08 14:51:14 +00:00
move search button to extensions
This commit is contained in:
committed by
Sheena Malhotra
parent
be64da15ef
commit
52cbf442d4
@@ -287,6 +287,23 @@
|
||||
}
|
||||
],
|
||||
"toolbar": [
|
||||
{
|
||||
"id": "app.toolbar.search.separator",
|
||||
"type": "separator",
|
||||
"order": 90
|
||||
},
|
||||
{
|
||||
"id": "app.toolbar.search",
|
||||
"order": 90,
|
||||
"title": "SEARCH.BUTTON.TOOLTIP",
|
||||
"icon": "search",
|
||||
"actions": {
|
||||
"click": "SEARCH"
|
||||
},
|
||||
"rules": {
|
||||
"visible": "app.isSearchSupported"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "app.toolbar.share",
|
||||
"type": "custom",
|
||||
|
@@ -21,6 +21,5 @@
|
||||
</div>
|
||||
</mat-menu>
|
||||
|
||||
<adf-toolbar-divider *ngIf="canShowSearchSeparator()"></adf-toolbar-divider>
|
||||
<aca-search-input class="app-search-input"></aca-search-input>
|
||||
</adf-toolbar>
|
||||
|
@@ -78,8 +78,4 @@ export class HeaderActionsComponent implements OnInit, OnDestroy {
|
||||
canShowUploadButton(): boolean {
|
||||
return this.uploadActions.length > 0;
|
||||
}
|
||||
|
||||
canShowSearchSeparator(): boolean {
|
||||
return this.canShowUploadButton() || this.canShowCreateButton();
|
||||
}
|
||||
}
|
||||
|
@@ -28,13 +28,6 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!searchInputService.isSearchRoute()"
|
||||
class="app-search-container">
|
||||
<button mat-icon-button class="app-search-button" (click)="navigateToSearch()" [title]="'SEARCH.BUTTON.TOOLTIP' | translate">
|
||||
<mat-icon [attr.aria-label]="'SEARCH.BUTTON.ARIA-LABEL' | translate">search</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<mat-menu #searchOptionsMenu="matMenu" [overlapTrigger]="true" class="app-search-options-menu">
|
||||
<div (keydown.tab)="$event.stopPropagation()" (keydown.shift.tab)="$event.stopPropagation()">
|
||||
<div cdkTrapFocus>
|
||||
|
@@ -210,26 +210,6 @@ describe('SearchInputComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('navigateToSearch()', () => {
|
||||
it('should navigate to search on click of search icon', async () => {
|
||||
spyOn(searchInputService, 'isSearchRoute').and.returnValue(false);
|
||||
spyOn(component, 'navigateToSearch').and.callThrough();
|
||||
spyOn(searchInputService, 'navigateToSearch').and.callThrough();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const searchIcon = fixture.debugElement.nativeElement.querySelector('.app-search-button');
|
||||
searchIcon.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.navigateToSearch).toHaveBeenCalled();
|
||||
expect(searchInputService.navigateToSearch).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('exitSearch()', () => {
|
||||
it('should exit search on click of close icon', async () => {
|
||||
spyOn(searchInputService, 'isSearchRoute').and.returnValue(true);
|
||||
|
@@ -111,10 +111,6 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
navigateToSearch() {
|
||||
this.searchInputService.navigateToSearch();
|
||||
}
|
||||
|
||||
exitSearch() {
|
||||
this.searchInputService.navigateBack();
|
||||
}
|
||||
|
@@ -26,12 +26,24 @@
|
||||
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SearchActionTypes, SearchByTermAction, SearchOptionIds } from '@alfresco/aca-shared/store';
|
||||
import { SearchAction, SearchActionTypes, SearchByTermAction, SearchOptionIds } from '@alfresco/aca-shared/store';
|
||||
import { Router } from '@angular/router';
|
||||
import { SearchNavigationService } from '../../components/search/search-navigation.service';
|
||||
|
||||
@Injectable()
|
||||
export class SearchEffects {
|
||||
constructor(private actions$: Actions, private router: Router) {}
|
||||
constructor(private actions$: Actions, private router: Router, private searchNavigationService: SearchNavigationService) {}
|
||||
|
||||
search$ = createEffect(
|
||||
() =>
|
||||
this.actions$.pipe(
|
||||
ofType<SearchAction>(SearchActionTypes.Search),
|
||||
map(() => {
|
||||
this.searchNavigationService.navigateToSearch();
|
||||
})
|
||||
),
|
||||
{ dispatch: false }
|
||||
);
|
||||
|
||||
searchByTerm$ = createEffect(
|
||||
() =>
|
||||
|
@@ -91,6 +91,13 @@ export interface AcaRuleContext extends RuleContext {
|
||||
*/
|
||||
export const isContentServiceEnabled = (): boolean => localStorage && localStorage.getItem('contentService') !== 'false';
|
||||
|
||||
/**
|
||||
* Checks if Search is supported for active view
|
||||
* JSON ref: `app.isSearchSupported`
|
||||
*/
|
||||
export const isSearchSupported = (context: RuleContext): boolean =>
|
||||
[navigation.isNotSearchResults(context) /*, !hasSelection(context)*/].every(Boolean);
|
||||
|
||||
/**
|
||||
* Checks if upload action is supported for the given context
|
||||
* JSON ref: `app.isUploadSupported`
|
||||
|
@@ -27,9 +27,15 @@ import { Action } from '@ngrx/store';
|
||||
import { SearchOptionModel } from '../models/search-option.model';
|
||||
|
||||
export enum SearchActionTypes {
|
||||
Search = 'SEARCH',
|
||||
SearchByTerm = 'SEARCH_BY_TERM'
|
||||
}
|
||||
|
||||
export class SearchAction implements Action {
|
||||
readonly type = SearchActionTypes.Search;
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
export class SearchByTermAction implements Action {
|
||||
readonly type = SearchActionTypes.SearchByTerm;
|
||||
constructor(public payload: string, public searchOptions?: SearchOptionModel[]) {}
|
||||
|
Reference in New Issue
Block a user